From 411f1b3166875094376e45c51b9b7133b587a0dd Mon Sep 17 00:00:00 2001 From: Adam Morgan Date: Mon, 2 Nov 2026 20:54:30 +0000 Subject: [PATCH] fix(bank-sync): treat provider data as untrusted and keep secrets out of logs - Escape a mapping's last balance and currency in the Account Mappings list, and store a currency only when it is a three-letter code and a balance only when it is a number. - Open the bank authorization link with noopener,noreferrer (the fallback link carries the same rel), and refuse a link that isn't https on the server before the connection is stored or the browser sees it. - Factory reset, clearing sample data and purging a deleted user now revoke each bank connection at the provider once the delete commits, through the same path Disconnect uses. Best-effort: failures are logged and never stop the reset. - Bank sync controller errors are logged with the exception's class and message only, never the exception object, whose trace carries the decrypted credentials on PHP 8.1. Throwable is caught so a TypeError doesn't reach Nextcloud's own handler with its trace. --- budget/CHANGELOG.md | 8 + budget/js/budget-app.js | 2 +- budget/js/budget-app.js.map | 2 +- budget/js/budget-bank-sync.js | 4 +- budget/js/budget-bank-sync.js.map | 2 +- .../Queued/BankSyncConnectionJob.php | 5 +- budget/lib/Controller/BankSyncController.php | 43 ++- .../BankSync/BankConnectionRevoker.php | 93 +++++ .../lib/Service/BankSync/BankSyncService.php | 91 ++++- budget/lib/Service/FactoryResetService.php | 15 + budget/lib/Traits/ApiErrorHandlerTrait.php | 40 ++- .../src/modules/bank-sync/BankSyncModule.js | 53 ++- budget/templates/index.php | 2 +- .../Controller/BankSyncControllerTest.php | 97 +++++ .../BankSync/BankSyncProviderDataTest.php | 338 ++++++++++++++++++ .../Unit/Service/FactoryResetServiceTest.php | 114 ++++++ budget/tests/js/bankSyncProviderText.test.js | 115 ++++++ 17 files changed, 965 insertions(+), 59 deletions(-) create mode 100644 budget/lib/Service/BankSync/BankConnectionRevoker.php create mode 100644 budget/tests/Unit/Service/BankSync/BankSyncProviderDataTest.php create mode 100644 budget/tests/js/bankSyncProviderText.test.js diff --git a/budget/CHANGELOG.md b/budget/CHANGELOG.md index 57bd2b13e..d3fe8acd9 100644 --- a/budget/CHANGELOG.md +++ b/budget/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed +- **Bank sync shows what the bank sends as text.** The balance and currency in **Account Mappings** went into the page as they came from the bank provider, so a provider sending markup could run script in Budget. They are now shown as plain text, and the server only keeps a currency that is a three-letter code and a balance that is a number. +- **The bank authorization page opens safely.** The GoCardless authorization link now opens with no link back to the Budget window and no referrer, and the server refuses a link that isn't https before your browser sees it. The "click here to authorize" link is always shown, since the browser can no longer say whether the window opened. +- **A factory reset ends your bank connections at the provider.** Factory reset, clearing the sample data and purging a deleted user removed the bank connections from Budget but left the consent at GoCardless running, as only **Disconnect** revoked it. They now revoke each connection once the data has gone. A provider that can't be reached is logged and never stops the reset. +- **Bank sync errors no longer put credentials in the log.** A failed connect, sync or bank list logged the error with its stack trace, and on PHP 8.1 that trace can hold the decrypted bank credentials. These errors are now logged with their type and message only. The message you see is the same as before. + ## [3.3.0] - 2026-11-01 ### Added diff --git a/budget/js/budget-app.js b/budget/js/budget-app.js index c3b593a80..f745ef9f3 100644 --- a/budget/js/budget-app.js +++ b/budget/js/budget-app.js @@ -1,3 +1,3 @@ /*! For license information please see budget-app.js.LICENSE.txt */ -(()=>{"use strict";var t={586(t,e,n){n.d(e,{O:()=>s});var a=n(688);function r(){var t,e,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function s(n,a,r,o){var s=a&&a.prototype instanceof l?a:l,u=Object.create(s.prototype);return i(u,"_invoke",function(n,a,r){var i,o,s,l=0,u=r||[],d=!1,h={p:0,n:0,v:t,a:g,f:g.bind(t,4),d:function(e,n){return i=e,o=0,s=t,h.n=n,c}};function g(n,a){for(o=n,s=a,e=0;!d&&l&&!r&&e3?(r=p===a)&&(s=i[(o=i[4])?5:(o=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,o=0))}if(r||n>1)return c;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),o=u,s=p;(e=o<2?t:s)||!d;){i||(o?o<3?(o>1&&(h.n=-1),g(o,s)):h.n=s:h.v=s);try{if(l=2,i){if(o||(r="next"),e=i[r]){if(!(e=e.call(i,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,o<2&&(o=0)}else 1===o&&(e=i.return)&&e.call(i),o<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),o=1);i=t}else if((e=(d=h.n<0)?s:n.call(a,h))!==c)break}catch(e){i=t,o=1,s=e}finally{l=1}}return{value:e,done:d}}}(n,r,o),!0),u}var c={};function l(){}function u(){}function d(){}e=Object.getPrototypeOf;var h=[][a]?e(e([][a]())):(i(e={},a,function(){return this}),e),g=d.prototype=l.prototype=Object.create(h);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,i(t,o,"GeneratorFunction")),t.prototype=Object.create(g),t}return u.prototype=d,i(g,"constructor",d),i(d,"constructor",u),u.displayName="GeneratorFunction",i(d,o,"GeneratorFunction"),i(g),i(g,o,"Generator"),i(g,a,function(){return this}),i(g,"toString",function(){return"[object Generator]"}),(r=function(){return{w:s,m:p}})()}function i(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}i=function(t,e,n,a){function o(e,n){i(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},i(t,e,n,a)}function o(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function s(){return c.apply(this,arguments)}function c(){var t;return t=r().m(function t(){var e,n,i;return r().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,a.n)("/apps/budget/api/bank-sync/status");case 1:return e=t.v,(n=document.getElementById("bank-sync-nav"))&&(n.style.display=e.enabled?"":"none"),t.a(2,e);case 2:return t.p=2,i=t.v,console.error("Failed to check bank sync status:",i),t.a(2,{enabled:!1})}},t,null,[[0,2]])}),c=function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function s(t){o(i,a,r,s,c,"next",t)}function c(t){o(i,a,r,s,c,"throw",t)}s(void 0)})},c.apply(this,arguments)}},136(t,e,n){n.d(e,{L7:()=>h,dx:()=>g,oR:()=>f,r1:()=>m,sG:()=>d});var a=n(583),r=n(400);function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function s(t){for(var e=1;e=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n0?t/e*100:0,r=Math.min(Math.max(n,0),100);return{width:r,status:(0,a.Gn)(r),percent:Math.round(n)}}function g(t,e){var n=e.reduce(function(t,e){var n=(0,r.F)(e);return t+(Number.isNaN(n)?0:n)},0),a=(0,r.F)(t);if(Number.isNaN(a))return{cents:-n,over:n>0,valid:!1};var i=a-n;return{cents:i,over:i<0,valid:!0}}function p(t,e){var n,a=l(t||[]);try{for(a.s();!(n=a.n()).done;){var r=n.value;if(r.id===e)return r;var i=p(r.children,e);if(i)return i}}catch(t){a.e(t)}finally{a.f()}return null}function f(t,e){var n=[],a=function(t,e){var r,i=l(t||[]);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.excludedFromReports||(n.push({id:o.id,name:o.name,depth:e}),a(o.children,e+1))}}catch(t){i.e(t)}finally{i.f()}},r=p(t,e);return r&&a(r.children,1),n}function m(t){return(t||[]).filter(function(t){return!t._shared&&"expense"===t.type}).map(function(t){return s(s({},t),{},{children:m(t.children)})})}},930(t,e,n){n.d(e,{$S:()=>C,E6:()=>y,FG:()=>I,GF:()=>f,HB:()=>g,Jo:()=>x,QN:()=>v,XH:()=>S,Zg:()=>E,au:()=>k,hM:()=>m,ig:()=>p,kq:()=>d,vy:()=>b});var a=n(746);function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function o(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,a=Array(e);n1&&void 0!==arguments[1]?arguments[1]:[],n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).readOnlyShares,a=void 0!==n&&n,r=new Set((Array.isArray(e)?e:[e]).filter(function(t){return null!=t&&""!==t}).map(String)),i=a?function(t){return!u(t)}:h;return l(t).filter(function(t){return i(t)||r.has(String(t.id))})}function f(t){return t&&t._shared&&t.userId?t.userId:null}function m(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=new Set(l(e).map(f).filter(Boolean));if(0===a.size)return null;var r=1===a.size?function(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return c(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(a)[0]:null,i=new Set((n||[]).filter(function(t){return null!=t&&""!==t}).map(String));return l(t).filter(function(t){return null!==r&&t.userId===r||i.has(String(t.id))})}function v(t){var e=new Map(l(t).map(function(t){return[String(t.id),o(o({},t),{},{children:[]})]})),n=function(t){return null!==t.parentId&&void 0!==t.parentId?e.get(String(t.parentId)):null},a=[];return e.forEach(function(t){var e=n(t);(e&&!function(t){for(var e=new Set([t]),a=n(t);a;a=n(a)){if(e.has(a))return!0;e.add(a)}return!1}(t)?e.children:a).push(t)}),a}function y(t,e,n){var a=null==n?"":String(n),r=e?function(t){return t.userId===e}:function(t){return!t._shared};return l(t).filter(function(t){return""!==a&&String(t.id)===a||r(t)&&!u(t)})}function b(t,e){var n=new Map(l(e).map(function(t){return[String(t.id),t]}));return(Array.isArray(t)?t:[]).filter(function(t){var e,a=n.get(String(null==t||null===(e=t.transaction)||void 0===e?void 0:e.accountId));return!a||h(a)})}function w(t,e){var n=l(t).find(function(t){return String(t.id)===String(e)});return!!n&&!d(n)}function T(t){return null!=t&&""!==t}function k(t,e){var n,a,r,i,o=null!==(n=null!==(a=null==t?void 0:t.accountId)&&void 0!==a?a:null==t?void 0:t.account_id)&&void 0!==n?n:null;if(T(o)&&!w(e,o))return!1;if(null!==(r=null!==(i=null==t?void 0:t.isTransfer)&&void 0!==i?i:null==t?void 0:t.is_transfer)&&void 0!==r&&r){var s,c,l=null!==(s=null!==(c=t.destinationAccountId)&&void 0!==c?c:t.destination_account_id)&&void 0!==s?s:null;return T(l)&&w(e,l)}return!0}function E(t,e){var n,a,r=null!==(n=null!==(a=null==t?void 0:t.accountId)&&void 0!==a?a:null==t?void 0:t.account_id)&&void 0!==n?n:null;return!T(r)||w(e,r)}function x(t){var e,n=null!==(e=null==t?void 0:t.name)&&void 0!==e?e:"";return u(t)?(0,a.Tl)("budget","{name} (closed)",{name:n}):n}function S(t,e,n){if(!t)return!1;if(null==n||""===n)return t.value="",!0;var a=String(n);if(t.value=a,t.value===a)return!0;var r=l(e).find(function(t){return String(t.id)===a});if(!r)return t.value="",!1;var i=document.createElement("option");return i.value=a,i.textContent=x(r),i.dataset.closedAccount="1",t.appendChild(i),t.value=a,!0}function C(t,e){if(null==e||""===e)return null;var n=l(t).find(function(t){return String(t.id)===String(e)});return(null==n?void 0:n.currency)||null}function I(t){var e=new Set(((arguments.length>1&&void 0!==arguments[1]?arguments[1]:[])||[]).filter(T).map(String));return l(t).filter(function(t){return!t._shared&&!u(t)||e.has(String(t.id))})}},397(t,e,n){function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,r,i,o,s=[],c=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(s.push(a.value),s.length!==e);c=!0);}catch(t){l=!0,r=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||c(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function i(t){for(var e=1;e=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function c(t,e){if(t){if("string"==typeof t)return l(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(t,e):void 0}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);nF,ET:()=>B,MD:()=>L,N9:()=>d,PJ:()=>O,T8:()=>E,g4:()=>P,qA:()=>A,uo:()=>x,yN:()=>I});var d={light:{positive:"#0b62a4",negative:"#a84800",warning:"#8a6a00"},dark:{positive:"#6cb4ee",negative:"#f5a35c",warning:"#f0e442"}},h={light:"#c9a000",dark:"#f0e442"},g=[6,8,10,12,15,20,30],p="budget:amount-colours-changed",f="budget-amount-colours",m=["lightPositive","lightNegative","darkPositive","darkNegative"],v=/^#[0-9a-fA-F]{6}$/,y="#171717",b="#ffffff",w=["body","#app-navigation","#app-content","#budget-toast-container"],T=["body[data-theme-light]","body[data-theme-light-highcontrast]"],k=null;function E(t){if("string"!=typeof t||""===t)return null;var e;try{e=JSON.parse(t)}catch(t){return null}if(null===e||"object"!==u(e)||Array.isArray(e)||Object.keys(e).length!==m.length)return null;var n,a={},r=s(m);try{for(r.s();!(n=r.n()).done;){var i=n.value,o=e[i];if("string"!=typeof o||!v.test(o))return null;a[i]=o.toLowerCase()}}catch(t){r.e(t)}finally{r.f()}return a}function x(t,e){if("colorblind"===t)return{light:i({},d.light),dark:i({},d.dark)};if("custom"===t){var n=E(e);return null===n?null:{light:{positive:n.lightPositive,negative:n.lightNegative,warning:null},dark:{positive:n.darkPositive,negative:n.darkNegative,warning:null}}}return null}function S(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function C(t){var e=a(t.map(function(t){var e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}),3);return.2126*e[0]+.7152*e[1]+.0722*e[2]}function I(t,e){var n=C(S(t)),a=C(S(e));return(Math.max(n,a)+.05)/(Math.min(n,a)+.05)}function A(t){return I(t,y)>=I(t,b)?y:b}function _(t,e){var n,a=t.positive,r=t.negative,i=t.warning,o=["--budget-color-positive: ".concat(a,";"),"--budget-color-negative: ".concat(r,";"),"--color-success: ".concat(a,";"),"--color-error: ".concat(r,";"),"--color-success-hover: color-mix(in srgb, ".concat(a,", black 10%);"),"--color-error-hover: color-mix(in srgb, ".concat(r,", black 10%);"),"--budget-scheme-positive: ".concat(a,";"),"--budget-scheme-negative: ".concat(r,";")],c=s(g);try{for(c.s();!(n=c.n()).done;){var l=n.value;o.push("--budget-tint-positive-".concat(l,": color-mix(in srgb, ").concat(a," ").concat(l,"%, transparent);")),o.push("--budget-tint-negative-".concat(l,": color-mix(in srgb, ").concat(r," ").concat(l,"%, transparent);"))}}catch(t){c.e(t)}finally{c.f()}return o.push("--budget-color-on-success: ".concat(A(a),";")),o.push("--budget-color-on-error: ".concat(A(r),";")),i&&(o.push("--color-warning: ".concat(i,";")),o.push("--budget-scheme-warning: ".concat(i,";")),o.push("--budget-color-on-status: ".concat(A(i),";")),o.push("--budget-scheme-warning-fill: ".concat(h[e],";"))),o}function M(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=e.map(function(t){return"".concat(n," ").concat(t)}).join("\n");return"".concat(n).concat(t.join(",\n"+n)," {\n").concat(a,"\n").concat(n,"}")}function D(t){return t.flatMap(function(t){return w.map(function(e){return"body"===e?t:"".concat(t," ").concat(e)})})}function B(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:document,a=x(t,e),r=n.getElementById(f);if(null===a)null==r||r.remove();else{var i=null!=r?r:n.createElement("style");i.id=f,i.textContent=function(t){var e=_(t.light,"light"),n=_(t.dark,"dark");return[M([].concat(w,T),e),M(D(["body[data-theme-dark]","body[data-theme-dark-highcontrast]"]),n),"@media (prefers-color-scheme: dark) {\n"+M(D(["body[data-theme-default]"]),n," ")+"\n}"].join("\n\n")+"\n"}(a),r||n.head.appendChild(i)}var o=JSON.stringify(a)!==JSON.stringify(k);k=a,o&&window.dispatchEvent(new CustomEvent(p))}function L(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).getElementById("app-content");return{scheme:(null==t?void 0:t.getAttribute("data-amount-color-scheme"))||"default",custom:(null==t?void 0:t.getAttribute("data-amount-color-custom"))||""}}function P(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=t.body;if(!e)return!1;if(e.hasAttribute("data-theme-dark")||e.hasAttribute("data-theme-dark-highcontrast"))return!0;var n=t.defaultView;return e.hasAttribute("data-theme-default")&&"function"==typeof(null==n?void 0:n.matchMedia)&&n.matchMedia("(prefers-color-scheme: dark)").matches}function O(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(null===k)return e;var r=a(S(k[P()?"dark":"light"][t]),3),i=r[0],o=r[1],s=r[2];return"rgba(".concat(i,", ").concat(o,", ").concat(s,", ").concat(n,")")}function F(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window;if(n.addEventListener(p,function(){t.reloadCurrentView()}),"function"==typeof n.matchMedia){var a=n.matchMedia("(prefers-color-scheme: dark)");null==a||null===(e=a.addEventListener)||void 0===e||e.call(a,"change",function(){var e;null!==k&&null!==(e=n.document.body)&&void 0!==e&&e.hasAttribute("data-theme-default")&&t.reloadCurrentView()})}}},328(t,e,n){function a(t){var e=t.getAttribute("min");return null===e||""===e||Number(e)<0}function r(t){return t.type="text",t.inputMode="decimal",t.dataset.amount="",t}function i(t){var e,n=t.target;if(n instanceof HTMLInputElement&&"amount"in n.dataset){n.pattern=function(t){if(Number(t.getAttribute("min"))>0)return"0*[1-9][0-9]*(\\.[0-9]*)?|0*\\.?0*[1-9][0-9]*";var e="([0-9]+(\\.[0-9]*)?|\\.[0-9]+)";return a(t)?"-?".concat(e):e}(n);var r=null!==(e=n.selectionStart)&&void 0!==e?e:n.value.length,i=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.allowNegative,a=void 0===n||n,r=e.caret,i=void 0===r?String(null!=t?t:"").length:r,o=String(null!=t?t:""),s=Math.max(o.lastIndexOf("."),o.lastIndexOf(",")),c="",l=0,u=0;u="0"&&d<="9"?c+=d:u===s?c+=".":"-"===d&&a&&""===c&&(c+="-"),us,XV:()=>r});var o=!1;function s(){o||(o=!0,document.addEventListener("input",i,!0))}},688(t,e,n){n.d(e,{h:()=>g,n:()=>v});var a=n(17);function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function i(){var t,e,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function s(n,a,r,i){var s=a&&a.prototype instanceof l?a:l,u=Object.create(s.prototype);return o(u,"_invoke",function(n,a,r){var i,o,s,l=0,u=r||[],d=!1,h={p:0,n:0,v:t,a:g,f:g.bind(t,4),d:function(e,n){return i=e,o=0,s=t,h.n=n,c}};function g(n,a){for(o=n,s=a,e=0;!d&&l&&!r&&e3?(r=p===a)&&(s=i[(o=i[4])?5:(o=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,o=0))}if(r||n>1)return c;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),o=u,s=p;(e=o<2?t:s)||!d;){i||(o?o<3?(o>1&&(h.n=-1),g(o,s)):h.n=s:h.v=s);try{if(l=2,i){if(o||(r="next"),e=i[r]){if(!(e=e.call(i,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,o<2&&(o=0)}else 1===o&&(e=i.return)&&e.call(i),o<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),o=1);i=t}else if((e=(d=h.n<0)?s:n.call(a,h))!==c)break}catch(e){i=t,o=1,s=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),u}var c={};function l(){}function u(){}function d(){}e=Object.getPrototypeOf;var h=[][a]?e(e([][a]())):(o(e={},a,function(){return this}),e),g=d.prototype=l.prototype=Object.create(h);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,o(t,r,"GeneratorFunction")),t.prototype=Object.create(g),t}return u.prototype=d,o(g,"constructor",d),o(d,"constructor",u),u.displayName="GeneratorFunction",o(d,r,"GeneratorFunction"),o(g),o(g,r,"Generator"),o(g,a,function(){return this}),o(g,"toString",function(){return"[object Generator]"}),(i=function(){return{w:s,m:p}})()}function o(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}o=function(t,e,n,a){function i(e,n){o(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},o(t,e,n,a)}function s(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function c(t){return function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){s(i,a,r,o,c,"next",t)}function c(t){s(i,a,r,o,c,"throw",t)}o(void 0)})}}function l(t){var e="function"==typeof Map?new Map:void 0;return l=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(u())return Reflect.construct.apply(null,arguments);var a=[null];a.push.apply(a,e);var r=new(t.bind.apply(t,a));return n&&d(r,n.prototype),r}(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),d(n,t)},l(t)}function u(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(u=function(){return!!t})()}function d(t,e){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},d(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}var g=function(t){function e(t){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=a.status,o=a.data,s=void 0===o?null:o,c=a.response,l=void 0===c?null:c;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=function(t,e,n){return e=h(e),function(t,e){if(e&&("object"==r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,u()?Reflect.construct(e,n||[],h(t).constructor):e.apply(t,n))}(this,e,[t])).name="ApiError",n.status=i,n.data=s,n.response=l,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}(e,t),n=e,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(l(Error));function p(t){return"string"==typeof t||"undefined"!=typeof FormData&&t instanceof FormData||"undefined"!=typeof Blob&&t instanceof Blob||"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams||"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer}function f(t){return m.apply(this,arguments)}function m(){return(m=c(i().m(function t(e){return i().w(function(t){for(;;)switch(t.p=t.n){case 0:if("function"==typeof(null==e?void 0:e.json)){t.n=1;break}return t.a(2,null);case 1:return t.p=1,t.n=2,e.json();case 2:return t.a(2,t.v);case 3:return t.p=3,t.v,t.a(2,null)}},t,null,[[1,3]])}))).apply(this,arguments)}function v(t){return y.apply(this,arguments)}function y(){return y=c(i().m(function t(e){var n,r,o,s,c,l,u,d,h,m,v,y,b,w,T,k,E,x=arguments;return i().w(function(t){for(;;)switch(t.n){case 0:return s=(o=x.length>1&&void 0!==x[1]?x[1]:{}).method,c=o.body,l=o.headers,u=void 0===l?{}:l,d=o.responseType,h=void 0===d?"json":d,m=o.errorMessage,v=o.signal,y={headers:{requesttoken:OC.requestToken}},s&&(y.method=s),null!=c&&(p(c)?(y.body=c,"string"==typeof c&&(y.headers["Content-Type"]="application/json")):(y.body=JSON.stringify(c),y.headers["Content-Type"]="application/json")),Object.assign(y.headers,u),v&&(y.signal=v),t.n=1,fetch(OC.generateUrl(e),y);case 1:if((b=t.v).ok){t.n=3;break}return t.n=2,f(b);case 2:throw w=t.v,T=b.status,k=m||"HTTP ".concat(T).concat(b.statusText?": "+b.statusText:""),new g((0,a.l1)(w,k),{status:T,data:w,response:b});case 3:E=h,t.n="response"===E?4:"blob"===E?5:"text"===E?6:7;break;case 4:return t.a(2,b);case 5:return t.a(2,b.blob());case 6:return t.a(2,b.text());case 7:if(204!==b.status&&"function"==typeof b.json){t.n=8;break}return t.a(2,null);case 8:if("0"!==(null===(n=b.headers)||void 0===n||null===(r=n.get)||void 0===r?void 0:r.call(n,"Content-Length"))){t.n=9;break}return t.a(2,null);case 9:return t.a(2,b.json());case 10:return t.a(2)}},t)})),y.apply(this,arguments)}},78(t,e,n){n.d(e,{Zg:()=>s,y5:()=>c});var a=n(746),r=n(993),i=n(69),o=n(930);function s(t,e,n){var r,s,u,d,h,g,p,f,m=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,v=t.frequency||"monthly",y=t.nextDueDate||t.next_due_date||"one-time"===v&&(t.startDate||t.start_date)||null,b=null===(r=null!==(s=t.isActive)&&void 0!==s?s:t.is_active)||void 0===r||r,w=(0,i.L)({frequency:v,isActive:b,dueDate:b&&(t.nextDueDate||t.next_due_date)||null,lastDate:t.lastPaidDate||t.last_paid_date||null,pattern:null!==(u=null!==(d=t.customRecurrencePattern)&&void 0!==d?d:t.custom_recurrence_pattern)&&void 0!==u?u:null,dueDay:null!==(h=null!==(g=t.dueDay)&&void 0!==g?g:t.due_day)&&void 0!==h?h:null,skipped:!(null===(p=t.lastOccurrenceSkipped)||void 0===p||!p)},e),T=w.status,k=w.recentlySettled,E={inactive:"paid",settled:"paid",overdue:"overdue",soon:"due-soon",upcoming:"upcoming"}[T],x={paid:(0,a.Tl)("budget","Paid"),overdue:(0,a.Tl)("budget","Overdue"),"due-soon":(0,a.Tl)("budget","Due Soon"),upcoming:(0,a.Tl)("budget","Upcoming")}[E],S=!(0,o.kq)(t),C=void 0===m||(0,o.au)(t,m),I=S&&C,A="paid"!==E&&I,_=!(null===(f=t.canMarkUnpaid)||void 0===f||!f),M=!S||C||t._shared||"paid"===E&&!_?null:(0,a.Tl)("budget","This bill uses an account you can no longer change. Edit the bill and choose another account.");return{status:E,statusText:x,dateText:l(t,y,"paid"===E||k,n),dueDate:y,canPay:A,canSkip:A&&"one-time"!==v,canUnpay:I&&_,canWrite:S,accountHint:M,dateUnconfirmed:c(t)}}function c(t){var e,n;if("one-time"!==(t.frequency||"monthly"))return!1;var a=null!==(e=null!==(n=t.dueMonth)&&void 0!==n?n:t.due_month)&&void 0!==e?e:null,r=t.startDate||t.start_date||t.nextDueDate||t.next_due_date||null;return null===a&&null!==r}function l(t,e,n,i){var o,s,c=t.lastPaidDate||t.last_paid_date||null,l=null===(o=null!==(s=t.isActive)&&void 0!==s?s:t.is_active)||void 0===o||o,u="one-time"===(t.frequency||"monthly")&&l;if(n&&c&&!u){var d=r.Yq(c,i);return l&&e?(0,a.Tl)("budget","Paid {paidDate}, next due {dueDate}",{paidDate:d,dueDate:r.Yq(e,i)}):(0,a.Tl)("budget","Paid {date}",{date:d})}return e?r.Yq(e,i):(0,a.Tl)("budget","No due date")}},574(t,e,n){n.d(e,{E:()=>u,h:()=>l});var a=n(746),r=n(688),i=n(557);function o(){var t,e,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,a,r,i){var o=a&&a.prototype instanceof l?a:l,u=Object.create(o.prototype);return s(u,"_invoke",function(n,a,r){var i,o,s,l=0,u=r||[],d=!1,h={p:0,n:0,v:t,a:g,f:g.bind(t,4),d:function(e,n){return i=e,o=0,s=t,h.n=n,c}};function g(n,a){for(o=n,s=a,e=0;!d&&l&&!r&&e3?(r=p===a)&&(s=i[(o=i[4])?5:(o=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,o=0))}if(r||n>1)return c;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),o=u,s=p;(e=o<2?t:s)||!d;){i||(o?o<3?(o>1&&(h.n=-1),g(o,s)):h.n=s:h.v=s);try{if(l=2,i){if(o||(r="next"),e=i[r]){if(!(e=e.call(i,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,o<2&&(o=0)}else 1===o&&(e=i.return)&&e.call(i),o<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),o=1);i=t}else if((e=(d=h.n<0)?s:n.call(a,h))!==c)break}catch(e){i=t,o=1,s=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),u}var c={};function l(){}function u(){}function d(){}e=Object.getPrototypeOf;var h=[][a]?e(e([][a]())):(s(e={},a,function(){return this}),e),g=d.prototype=l.prototype=Object.create(h);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,r,"GeneratorFunction")),t.prototype=Object.create(g),t}return u.prototype=d,s(g,"constructor",d),s(d,"constructor",u),u.displayName="GeneratorFunction",s(d,r,"GeneratorFunction"),s(g),s(g,r,"Generator"),s(g,a,function(){return this}),s(g,"toString",function(){return"[object Generator]"}),(o=function(){return{w:i,m:p}})()}function s(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}s=function(t,e,n,a){function i(e,n){s(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},s(t,e,n,a)}function c(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function l(t){return null!=t&&t.lastPaymentUsedExisting?(0,a.Tl)("budget","Mark this bill as unpaid? The bill schedule will be rolled back, and any transaction created for the payment deleted. The transaction the payment used was already in the account: it stays there, still filed under the bill."):(0,a.Tl)("budget","Mark this bill as unpaid? Transactions created for the payment will be deleted, a linked imported transaction will be unlinked, and the bill schedule rolled back.")}function u(t,e){return d.apply(this,arguments)}function d(){var t;return t=o().m(function t(e,n){var a,s,c;return o().w(function(t){for(;;)switch(t.p=t.n){case 0:return a="/apps/budget/api/bills/".concat(e,"/unpaid"),t.p=1,t.n=2,(0,r.n)(a,{method:"POST",errorMessage:n});case 2:case 7:return t.a(2,!0);case 3:if(t.p=3,(c=t.v)instanceof r.h&&409===c.status&&"reconciled"===(null===(s=c.data)||void 0===s?void 0:s.code)){t.n=4;break}throw c;case 4:return t.n=5,(0,i.ZD)(c.message,{destructive:!0});case 5:if(t.v){t.n=6;break}return t.a(2,!1);case 6:return t.n=7,(0,r.n)(a,{method:"POST",body:{confirmReconciled:!0},errorMessage:n})}},t,null,[[1,3]])}),d=function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){c(i,a,r,o,s,"next",t)}function s(t){c(i,a,r,o,s,"throw",t)}o(void 0)})},d.apply(this,arguments)}},583(t,e,n){n.d(e,{Gn:()=>i,Nc:()=>o,t8:()=>s});var a=n(746),r=n(476);function i(t){return t>=100?"over":t>=80?"danger":t>=60?"warning":"good"}function o(t,e){var n=Number.isFinite(Number(t))?Number(t):0,a=Math.round(Math.min(Math.max(n,0),100)),i="".concat(Math.round(n),"%");return'role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="'.concat(a,'" aria-valuetext="').concat((0,r.ZD)(i),'"')+(e?' aria-label="'.concat((0,r.ZD)(e),'"'):"")}function s(t){return t?''.concat((0,r.ZD)((0,a.Tl)("budget","Over budget")),""):""}},692(t,e,n){var a=n(118);a.t1.register(a.ZT,a.A6,a.ju,a.No,a.FN,a.E8,a.Bs,a.PP,a.kc,a.dN,a.s$,a.m_,a.hE,a.Jy),a.t1.defaults.elements.line.cubicInterpolationMode="monotone";const r=a.t1;n.d(e,["A",0,r])},964(t,e,n){n.d(e,{Mv:()=>h,N1:()=>g,c6:()=>u,zH:()=>d});var a=n(421);function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function o(t){for(var e=1;e2&&void 0!==arguments[2]?arguments[2]:{},r=o(o({},l(e)),n),i=(0,a.A)(t,r);return c.push(i),i}function h(t,e){var n="string"==typeof t?document.getElementById(t):t;n&&(n._flatpickr?e?n._flatpickr.setDate(e,!1):n._flatpickr.clear():n.value=e||"")}function g(t){h(t,null)}},557(t,e,n){n.d(e,{T3:()=>b,Vb:()=>y,ZD:()=>v,so:()=>w});var a=n(746),r=n(17),i=n(707);function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function s(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function c(t){for(var e=1;e=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n1&&void 0!==arguments[1]?arguments[1]:{};return m({kind:"confirm",message:t,title:e.title||(0,a.Tl)("budget","Please confirm"),confirmLabel:e.confirmLabel||(0,a.Tl)("budget","Confirm"),cancelLabel:e.cancelLabel||(0,a.Tl)("budget","Cancel"),destructive:!0===e.destructive,confirmAnswer:function(){return!0},cancelAnswer:!1})}function y(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return m({kind:"prompt",message:t,title:n.title||(0,a.Tl)("budget","Enter a value"),defaultValue:null!==(e=n.defaultValue)&&void 0!==e?e:"",confirmLabel:n.confirmLabel||(0,a.Tl)("budget","OK"),cancelLabel:n.cancelLabel||(0,a.Tl)("budget","Cancel"),destructive:!1,confirmAnswer:function(t){return t?t.value:""},cancelAnswer:null})}function b(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return m({kind:"alert",message:t,title:e.title||(0,a.Tl)("budget","Notice"),confirmLabel:e.confirmLabel||(0,a.Tl)("budget","OK"),destructive:!1,confirmAnswer:function(){},cancelAnswer:void 0})}function w(t){return m({kind:"alert",title:(0,a.Tl)("budget","What's new in Budget"),panelClass:"budget-dialog-panel--wide",renderBody:function(e){var n,r=u(t);try{for(r.s();!(n=r.n()).done;){var i=n.value,o=document.createElement("section");o.className="whats-new-entry";var s=document.createElement("h4");s.className="whats-new-heading",s.textContent=i.title;var c=document.createElement("span");c.className="whats-new-version",c.textContent=i.version,s.appendChild(c),o.appendChild(s);var l=document.createElement("ul");l.className="whats-new-items";var d,h=u(i.items||[]);try{for(h.s();!(d=h.n()).done;){var g=d.value,p=document.createElement("li");p.textContent=g,l.appendChild(p)}}catch(t){h.e(t)}finally{h.f()}o.appendChild(l);var f=[];"string"==typeof i.link&&i.link.startsWith("https://")&&f.push({url:i.link,text:(0,a.Tl)("budget","Read more")});var m,v=u(Array.isArray(i.links)?i.links:[]);try{for(v.s();!(m=v.n()).done;){var y=m.value;y&&"string"==typeof y.url&&y.url.startsWith("https://")&&"string"==typeof y.text&&""!==y.text.trim()&&f.push(y)}}catch(t){v.e(t)}finally{v.f()}if(f.length>0){var b=document.createElement("div");b.className="whats-new-links";var w,T=u(f);try{for(T.s();!(w=T.n()).done;){var k=w.value,E=k.url,x=k.text,S=document.createElement("a");S.className="whats-new-link",S.href=E,S.target="_blank",S.rel="noopener noreferrer",S.textContent=x,b.appendChild(S)}}catch(t){T.e(t)}finally{T.f()}o.appendChild(b)}e.appendChild(o)}}catch(t){r.e(t)}finally{r.f()}},confirmLabel:(0,a.Tl)("budget","Got it"),destructive:!1,confirmAnswer:function(){},cancelAnswer:void 0})}},476(t,e,n){function a(t){return null==t||!1===t||""===t?"":String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}n.d(e,{Oo:()=>i,Vb:()=>o,ZD:()=>a,s0:()=>s,v9:()=>r});var r="(max-width: 640px)";function i(t){t&&(t.style.display="none",t.setAttribute("aria-hidden","true"))}function o(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(t&&Array.isArray(e)){var r=n.typeFilter,i=n.excludeId,s=n.selectedId;e.forEach(function(e){var c=!r||e.type===r;if(null==i||e.id!==i){if(c){var l=document.createElement("option");l.value=e.id,l.textContent="  ".repeat(a)+e.name,null!=s&&e.id==s&&(l.selected=!0),t.appendChild(l)}e.children&&e.children.length>0&&o(t,e.children,n,c?a+1:a)}})}}function s(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!Array.isArray(t))return"";var r=e.typeFilter,i=e.selectedId,o="";return t.forEach(function(t){var c=!r||t.type===r;if(c){var l="  ".repeat(n),u=null!=i&&t.id==i?" selected":"";o+='")}t.children&&t.children.length>0&&(o+=s(t.children,e,c?n+1:n))}),o}},707(t,e,n){function a(t){var e;return(null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:0)>1}function r(t,e){var n;return a(t)||1===(null!==(n=null==t?void 0:t.detail)&&void 0!==n?n:0)&&Date.now()-e<400}function i(t,e){t.addEventListener("mousedown",function(n){n.target===t&&r(n,e)&&n.preventDefault()})}function o(t,e,n){t.addEventListener("click",function(t){var a,i;null!==(a=(i=t.target).closest)&&void 0!==a&&a.call(i,e)&&r(t,n)&&t.preventDefault()},!0)}n.d(e,{oZ:()=>o,ou:()=>i,rV:()=>r,u$:()=>a})},119(t,e,n){n.d(e,{Qz:()=>c,c2:()=>l,pC:()=>o,ys:()=>s});var a=n(746),r=n(476),i=n(930);function o(t){return t?(0,a.Tl)("budget","{category} (not shared with you)",{category:t},void 0,{escape:!1,sanitize:!1}):(0,a.Tl)("budget","Unavailable (not shared with you)")}function s(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;if(!t)return"";var s="credit"===(arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)?"income":"expense",c=(0,i.hM)(t,[n],[e])||t,l=null!=e&&""!==e,u=a?' data-category-name="'.concat((0,r.ZD)(String(a)),'"'):"";return(l&&!c.some(function(t){return String(t.id)===String(e)})?'"):"")+c.filter(function(t){return t.type===s}).map(function(t){return'")}).join("")}function c(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(t)if(null!=e&&""!==e){var r=String(e);if(t.value=r,t.value!==r){var i=document.createElement("option");i.value=r,i.textContent=n||(0,a.Tl)("budget","Unavailable (not shared with you)"),i.disabled=!0,i.dataset.unavailable="1",t.appendChild(i),t.value=r}}else t.value=""}function l(t){t.forEach(function(t){var e=document.getElementById(t);e&&e.querySelectorAll('option[data-unavailable="1"], option[data-closed-account="1"]').forEach(function(t){return t.remove()})})}},993(t,e,n){n.d(e,{Br:()=>R,CZ:()=>L,Ds:()=>A,GH:()=>O,Go:()=>g,J$:()=>S,JV:()=>v,JX:()=>C,Jq:()=>b,Om:()=>w,X6:()=>k,Yo:()=>m,Yp:()=>o,Yq:()=>p,Zj:()=>T,__:()=>D,aN:()=>I,g6:()=>s,gg:()=>F,jt:()=>x,lU:()=>f,ng:()=>c,rG:()=>P,rT:()=>y,vv:()=>h,w:()=>u,x5:()=>E,xB:()=>B,yM:()=>d});var a=n(746);function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,r,i,o,s=[],c=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(s.push(a.value),s.length!==e);c=!0);}catch(t){l=!0,r=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n1&&void 0!==arguments[1]?arguments[1]:"long";return new Date(2e3,t-1,1).toLocaleDateString(o(),{month:e})}function c(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{month:"short",year:"numeric"},n=/^(\d{4})-(\d{2})$/.exec(String(null!=t?t:""));return n?new Date(Number(n[1]),Number(n[2])-1,1).toLocaleDateString(o(),e):t}var l={USD:{symbol:"$",position:"prefix"},CAD:{symbol:"C$",position:"prefix"},MXN:{symbol:"MX$",position:"prefix"},BRL:{symbol:"R$",position:"prefix"},ARS:{symbol:"AR$",position:"prefix"},CLP:{symbol:"CL$",position:"prefix",decimals:0},COP:{symbol:"CO$",position:"prefix"},PEN:{symbol:"S/",position:"prefix"},GTQ:{symbol:"Q",position:"prefix"},CRC:{symbol:"₡",position:"prefix"},UYU:{symbol:"$U",position:"prefix"},PYG:{symbol:"₲",position:"prefix",decimals:0},BOB:{symbol:"Bs.",position:"prefix"},DOP:{symbol:"RD$",position:"prefix"},HNL:{symbol:"L",position:"prefix"},NIO:{symbol:"C$",position:"prefix"},PAB:{symbol:"B/.",position:"prefix"},JMD:{symbol:"J$",position:"prefix"},TTD:{symbol:"TT$",position:"prefix"},EUR:{symbol:"€",position:"prefix"},GBP:{symbol:"£",position:"prefix"},CHF:{symbol:"CHF",position:"suffix"},SEK:{symbol:"kr",position:"suffix"},NOK:{symbol:"kr",position:"suffix"},DKK:{symbol:"kr",position:"suffix"},PLN:{symbol:"zł",position:"suffix"},CZK:{symbol:"Kč",position:"suffix"},HUF:{symbol:"Ft",position:"suffix",decimals:0},RON:{symbol:"lei",position:"suffix"},UAH:{symbol:"₴",position:"prefix"},ISK:{symbol:"kr",position:"suffix",decimals:0},RUB:{symbol:"₽",position:"prefix"},BYN:{symbol:"Br",position:"suffix"},TRY:{symbol:"₺",position:"prefix"},JPY:{symbol:"¥",position:"prefix",decimals:0},CNY:{symbol:"¥",position:"prefix"},KRW:{symbol:"₩",position:"prefix",decimals:0},INR:{symbol:"₹",position:"prefix"},IDR:{symbol:"Rp",position:"prefix",decimals:0},THB:{symbol:"฿",position:"prefix"},PHP:{symbol:"₱",position:"prefix"},MYR:{symbol:"RM",position:"prefix"},VND:{symbol:"₫",position:"suffix",decimals:0},TWD:{symbol:"NT$",position:"prefix"},SGD:{symbol:"S$",position:"prefix"},HKD:{symbol:"HK$",position:"prefix"},PKR:{symbol:"Rs",position:"prefix"},KZT:{symbol:"₸",position:"prefix"},BDT:{symbol:"৳",position:"prefix"},AUD:{symbol:"A$",position:"prefix"},NZD:{symbol:"NZ$",position:"prefix"},AED:{symbol:"AED",position:"prefix"},SAR:{symbol:"SAR",position:"prefix"},QAR:{symbol:"QAR",position:"prefix"},JOD:{symbol:"JOD",position:"prefix",decimals:3},ILS:{symbol:"₪",position:"prefix"},EGP:{symbol:"E£",position:"prefix"},NGN:{symbol:"₦",position:"prefix"},KES:{symbol:"KSh",position:"prefix"},ZAR:{symbol:"R",position:"prefix"},BTC:{symbol:"BTC",position:"suffix",decimals:8},ETH:{symbol:"ETH",position:"suffix",decimals:8},XRP:{symbol:"XRP",position:"suffix",decimals:6},SOL:{symbol:"SOL",position:"suffix",decimals:8},ADA:{symbol:"ADA",position:"suffix",decimals:6},DOGE:{symbol:"DOGE",position:"suffix",decimals:8},DOT:{symbol:"DOT",position:"suffix",decimals:8},LTC:{symbol:"LTC",position:"suffix",decimals:8},LINK:{symbol:"LINK",position:"suffix",decimals:8},AVAX:{symbol:"AVAX",position:"suffix",decimals:8},UNI:{symbol:"UNI",position:"suffix",decimals:8},ATOM:{symbol:"ATOM",position:"suffix",decimals:6},XLM:{symbol:"XLM",position:"suffix",decimals:7},ALGO:{symbol:"ALGO",position:"suffix",decimals:6},NEAR:{symbol:"NEAR",position:"suffix",decimals:8},FIL:{symbol:"FIL",position:"suffix",decimals:8},APT:{symbol:"APT",position:"suffix",decimals:8},ARB:{symbol:"ARB",position:"suffix",decimals:8},OP:{symbol:"OP",position:"suffix",decimals:8},USDT:{symbol:"USDT",position:"suffix",decimals:6},USDC:{symbol:"USDC",position:"suffix",decimals:6},DAI:{symbol:"DAI",position:"suffix",decimals:8},BNB:{symbol:"BNB",position:"suffix",decimals:8},MATIC:{symbol:"MATIC",position:"suffix",decimals:8},SHIB:{symbol:"SHIB",position:"suffix",decimals:8},XMR:{symbol:"XMR",position:"suffix",decimals:8}};function u(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=l[t];return n&&void 0!==n.decimals?n.decimals:parseInt(e.number_format_decimals)||2}function d(t){var e=u(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return e>0?"0."+"0".repeat(e-1)+"1":"1"}function h(t,e,n){var a,r=e||g(0,n),i=l[r]||{symbol:r,position:"prefix"},o=parseInt(null==n?void 0:n.number_format_decimals,10),s=void 0!==i.decimals?i.decimals:Number.isNaN(o)?2:o,c=n.number_format_decimal_sep||".",u=null!==(a=n.number_format_thousands_sep)&&void 0!==a?a:",",d=Math.abs(t).toFixed(s).split("."),h=d[0].replace(/\B(?=(\d{3})+(?!\d))/g,u),p=d[1]||"",f=i.symbol,m=i.position,v=s>0?"".concat(h).concat(c).concat(p):h,y=t<0?"-":"";return"suffix"===m?"".concat(y).concat(v," ").concat(f):"".concat(y).concat(f).concat(v)}function g(t,e){return(null==e?void 0:e.default_currency)||"GBP"}function p(t,e){if(!t)return"";var n=t.split(/[-/]/);if(3!==n.length)return t;var a=parseInt(n[0],10),r=parseInt(n[1],10),i=parseInt(n[2],10),o=(null==e?void 0:e.date_format)||"Y-m-d",c=function(t){return String(t).padStart(2,"0")},l={Y:function(){return String(a)},m:function(){return c(r)},d:function(){return c(i)},M:function(){return s(r,"short")},j:function(){return String(i)}};return o.replace(/[YmdMj]/g,function(t){return l[t]()})}function f(t){return t?{checking:(0,a.Tl)("budget","Checking"),savings:(0,a.Tl)("budget","Savings"),credit_card:(0,a.Tl)("budget","Credit Card"),investment:(0,a.Tl)("budget","Investment"),cash:(0,a.Tl)("budget","Cash"),loan:(0,a.Tl)("budget","Loan"),mortgage:(0,a.Tl)("budget","Mortgage"),pension:(0,a.Tl)("budget","Pension"),cryptocurrency:(0,a.Tl)("budget","Cryptocurrency")}[t]||t.replace(/_/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()}):""}function m(t,e,n){var a;n=n||{};var r,i,o=e||g(0,n),s=l[o]||{symbol:o,position:"prefix"},c=s.symbol,u=s.position,d=n.number_format_decimal_sep||".",p=null!==(a=n.number_format_thousands_sep)&&void 0!==a?a:",";if(Math.abs(t)>=1e6)r=t/1e6,i="M";else if(Math.abs(t)>=1e3)r=t/1e3,i="K";else{if(!Number.isInteger(t))return h(t,e,n);r=t,i=""}var f=Math.abs(r).toFixed(i?1:0).replace(/\.0$/,"").split("."),m=f[0].replace(/\B(?=(\d{3})+(?!\d))/g,p),v=f[1]||"",y=v?"".concat(m).concat(d).concat(v):m,b=r<0?"-":"";return"suffix"===u?"".concat(b).concat(y).concat(i," ").concat(c):"".concat(b).concat(c).concat(y).concat(i)}function v(t){var e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return"".concat(e,"-").concat(n,"-").concat(a)}function y(){return v(new Date)}function b(t,e){return"".concat(t,"-").concat(String(e).padStart(2,"0"),"-01")}function w(t,e){var n=new Date(t,e,0).getDate();return"".concat(t,"-").concat(String(e).padStart(2,"0"),"-").concat(String(n).padStart(2,"0"))}function T(t){var e=r(t.split("-").map(Number),3),n=e[0],a=e[1],i=e[2];return new Date(n,a-1,i)}function k(t,e){var n=T(t),a=T(e);return Math.round((a-n)/864e5)}function E(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;switch(e=r?"string"==typeof r&&/^\d{4}-\d{2}-\d{2}$/.test(r)?T(r):new Date(r):new Date,t){case"weekly":var i=new Date(e),s=i.getDay(),c=0===s?-6:1-s;i.setDate(i.getDate()+c);var l=new Date(i);return l.setDate(l.getDate()+6),{start:v(i),end:v(l),label:(0,a.Tl)("budget","Week of {date}",{date:i.toLocaleDateString(o(),{month:"short",day:"numeric"})})};case"monthly":if(n<=1){var u=new Date(e.getFullYear(),e.getMonth(),1),d=new Date(e.getFullYear(),e.getMonth()+1,0);return{start:v(u),end:v(d),label:e.toLocaleDateString(o(),{month:"long",year:"numeric"})}}var h,g,p=e.getDate(),f=new Date(e.getFullYear(),e.getMonth()+1,0).getDate(),m=Math.min(n,f);if(p>=m){h=new Date(e.getFullYear(),e.getMonth(),m);var y=e.getMonth()+1,b=new Date(e.getFullYear(),y+1,0).getDate(),w=Math.min(n,b);g=new Date(e.getFullYear(),y,w-1)}else{var k=e.getMonth()-1,x=new Date(e.getFullYear(),k+1,0).getDate(),S=Math.min(n,x);h=new Date(e.getFullYear(),k,S),g=new Date(e.getFullYear(),e.getMonth(),m-1)}var C=h.toLocaleDateString(o(),{month:"short",day:"numeric"})+" – "+g.toLocaleDateString(o(),{month:"short",day:"numeric"});return{start:v(h),end:v(g),label:C};case"quarterly":var I=Math.ceil((e.getMonth()+1)/3),A=3*(I-1),_=new Date(e.getFullYear(),A,1),M=new Date(e.getFullYear(),A+3,0);return{start:v(_),end:v(M),label:"Q".concat(I," ").concat(e.getFullYear())};case"yearly":var D=new Date(e.getFullYear(),0,1),B=new Date(e.getFullYear(),11,31);return{start:v(D),end:v(B),label:"".concat(e.getFullYear())};default:return E("monthly",n,r)}}function x(t,e){return parseInt(t.slice(8,10),10)<=15?t.slice(0,7):e.slice(0,7)}function S(){var t=E("monthly",arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null);return x(t.start,t.end)}function C(t){return E("monthly",arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,"".concat(t,"-15"))}function I(t,e){var n,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=parseInt(e.slice(5,7),10);if("yearly"===t)n=1;else{if("quarterly"!==t)return null;n=3*Math.floor((r-1)/3)+1}return{start:C("".concat(e.slice(0,4),"-").concat(String(n).padStart(2,"0")),a).start,end:C(e,a).end}}function A(t,e){var n=r(t.split("-").map(Number),2),a=n[0],i=n[1],o=new Date(a,i-1+e,1);return"".concat(o.getFullYear(),"-").concat(String(o.getMonth()+1).padStart(2,"0"))}var _=["7d","30d","90d","6m","1y","period"];function M(t,e){var n=t.getDate();t.setDate(1),t.setMonth(t.getMonth()+e);var a=new Date(t.getFullYear(),t.getMonth()+1,0).getDate();t.setDate(Math.min(n,a))}function D(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.budgetStartDay,a=void 0===n?1:n,r=e.fallback,i=void 0===r?"6m":r,o=e.referenceDate,s=void 0===o?null:o,c=s?new Date(s):new Date,l=t;if(_.includes(l)||(l=_.includes(i)?i:"6m"),"period"===l){var u=E("monthly",a,c);return{start:u.start,end:u.end,label:u.label}}var d=new Date(c);switch(l){case"7d":d.setDate(d.getDate()-7);break;case"30d":d.setDate(d.getDate()-30);break;case"90d":d.setDate(d.getDate()-90);break;case"1y":M(d,-12);break;default:M(d,-6)}return{start:v(d),end:v(c),label:null}}var B=[30,60,90],L=[3,6,12],P=[2,3,5];function O(t,e,n){var a=parseInt(t,10);return e.includes(a)?a:n}function F(t,e){var n=new Date(t+"T00:00:00"),a=new Date(e+"T00:00:00"),r=Math.round((a-n)/864e5)+1,i=new Date(n);i.setDate(i.getDate()-1);var o=new Date(i);return o.setDate(o.getDate()-(r-1)),{start:v(o),end:v(i)}}function R(t,e,n){if(e===n)return t;var a={weekly:52,monthly:12,quarterly:4,yearly:1};return t*a[e]/a[n]}},17(t,e,n){n.d(e,{TK:()=>v,Uv:()=>m,WP:()=>p,gb:()=>d,go:()=>y,l1:()=>b,m0:()=>f,mg:()=>g,qz:()=>w,sg:()=>u,wh:()=>T});var a=n(688);function r(){var t,e,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function s(n,a,r,o){var s=a&&a.prototype instanceof l?a:l,u=Object.create(s.prototype);return i(u,"_invoke",function(n,a,r){var i,o,s,l=0,u=r||[],d=!1,h={p:0,n:0,v:t,a:g,f:g.bind(t,4),d:function(e,n){return i=e,o=0,s=t,h.n=n,c}};function g(n,a){for(o=n,s=a,e=0;!d&&l&&!r&&e3?(r=p===a)&&(s=i[(o=i[4])?5:(o=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,o=0))}if(r||n>1)return c;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),o=u,s=p;(e=o<2?t:s)||!d;){i||(o?o<3?(o>1&&(h.n=-1),g(o,s)):h.n=s:h.v=s);try{if(l=2,i){if(o||(r="next"),e=i[r]){if(!(e=e.call(i,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,o<2&&(o=0)}else 1===o&&(e=i.return)&&e.call(i),o<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),o=1);i=t}else if((e=(d=h.n<0)?s:n.call(a,h))!==c)break}catch(e){i=t,o=1,s=e}finally{l=1}}return{value:e,done:d}}}(n,r,o),!0),u}var c={};function l(){}function u(){}function d(){}e=Object.getPrototypeOf;var h=[][a]?e(e([][a]())):(i(e={},a,function(){return this}),e),g=d.prototype=l.prototype=Object.create(h);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,i(t,o,"GeneratorFunction")),t.prototype=Object.create(g),t}return u.prototype=d,i(g,"constructor",d),i(d,"constructor",u),u.displayName="GeneratorFunction",i(d,o,"GeneratorFunction"),i(g),i(g,o,"Generator"),i(g,a,function(){return this}),i(g,"toString",function(){return"[object Generator]"}),(r=function(){return{w:s,m:p}})()}function i(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}i=function(t,e,n,a){function o(e,n){i(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},i(t,e,n,a)}function o(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||s(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){if(t){if("string"==typeof t)return c(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i=!0,o=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){o=!0,r=t},f:function(){try{i||null==e.return||e.return()}finally{if(o)throw r}}}}(t||[]);try{for(a.s();!(e=a.n()).done;){var r,i,c=e.value,l=(null!==(r=null==c?void 0:c.error)&&void 0!==r?r:"").toString().trim()||"Unknown error";n.has(l)||n.set(l,{message:l,reason:null!==(i=null==c?void 0:c.reason)&&void 0!==i?i:null,rows:[],count:0});var u=n.get(l);u.count++,void 0!==(null==c?void 0:c.row)&&null!==(null==c?void 0:c.row)&&u.rows.push(c.row)}}catch(t){a.e(t)}finally{a.f()}return o(n.values()).sort(function(t,e){return e.count-t.count})}function T(t){return String(null!=t?t:"").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}},192(t,e,n){n.d(e,{Cs:()=>i,KT:()=>s,e9:()=>o});var a=n(746),r="budget-loading";function i(t,e){var n="string"==typeof t?document.getElementById(t):t;if(!n||n.children.length>0)return!1;var i=document.createElement("div");i.className=r,i.setAttribute("role","status");var o=document.createElement("span");o.className="icon-loading",o.setAttribute("aria-hidden","true");var s=document.createElement("span");return s.textContent=e||(0,a.Tl)("budget","Loading..."),i.append(o,s),n.appendChild(i),!0}function o(t){var e="string"==typeof t?document.getElementById(t):t;null==e||e.querySelectorAll(":scope > .".concat(r)).forEach(function(t){return t.remove()})}function s(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i="string"==typeof t?document.getElementById(t):t;if(!i)return null;var o=document.createElement("div");o.className="budget-load-error",o.setAttribute("role","alert");var s=document.createElement("p");if(s.textContent=e,o.appendChild(s),"function"==typeof n){var c=document.createElement("button");c.type="button",c.className="budget-load-error-retry",c.textContent=(0,a.Tl)("budget","Retry"),c.addEventListener("click",function(){c.disabled=!0,n()}),o.appendChild(c)}if(i.replaceChildren(),"TBODY"===i.tagName){var l,u=document.createElement("tr"),d=document.createElement("td"),h=null===(l=i.closest("table"))||void 0===l?void 0:l.querySelectorAll("thead th").length;d.colSpan=r.colspan||h||1,d.appendChild(o),u.appendChild(d),i.appendChild(u)}else i.appendChild(o);return o}},577(t,e,n){n.d(e,{l:()=>s});var a=n(746),r=n(993),i=n(476),o=n(707);function s(t,e,n){return new Promise(function(s){var c=document.getElementById("matching-tx-modal");c&&c.remove();var l=t.currency||(null==n?void 0:n.default_currency)||"",u=function(t){return r.vv(t,l,n)},d=e.length>0&&e[0].score>=50,h=e.map(function(t,e){var n=t.transaction,o=t.matchReasons.map(function(t){return{exact_amount:(0,a.Tl)("budget","Exact amount"),similar_amount:(0,a.Tl)("budget","Similar amount (±5%)"),approximate_amount:(0,a.Tl)("budget","Approximate amount (±20%)"),exact_vendor:(0,a.Tl)("budget","Vendor matches"),partial_vendor:(0,a.Tl)("budget","Vendor partially matches"),exact_description:(0,a.Tl)("budget","Description matches"),partial_description:(0,a.Tl)("budget","Description partially matches"),same_day:(0,a.Tl)("budget","Same day"),next_day:(0,a.Tl)("budget","±1 day"),within_3_days:(0,a.Tl)("budget","±3 days"),within_7_days:(0,a.Tl)("budget","±7 days")}[t]||t}).join(", "),s=n.description||n.vendor||(0,a.Tl)("budget","(no description)"),c=d&&0===e?"checked":"";return'\n \n ")}).join(""),g="one-time"===t.frequency?(0,a.Tl)("budget","Whichever you choose, the bill is marked as paid."):(0,a.Tl)("budget","Whichever you choose, the bill is marked as paid and moves on to its next due date."),p=document.createElement("div");p.id="matching-tx-modal",p.className="budget-modal-overlay",p.innerHTML='\n
\n
\n

'.concat((0,a.Tl)("budget","Existing Transaction Found"),'

\n \n
\n
\n

').concat((0,a.Tl)("budget","We found existing transactions that may already represent this bill payment ({billName}, {amount}). Would you like to link one instead of creating a new transaction?",{billName:i.ZD(t.name),amount:i.ZD(u(t.amount))},void 0,{escape:!1}),'

\n

').concat(g,'

\n
\n ').concat(h,'\n
\n \n \n
\n \n
\n "),document.body.appendChild(p);var f=Date.now(),m=function(){return p.remove()};(0,o.oZ)(p,".matching-tx-option",f),p.querySelector(".close-btn").addEventListener("click",function(t){(0,o.u$)(t)||(m(),s(null))}),p.querySelector(".cancel-btn").addEventListener("click",function(t){(0,o.u$)(t)||(m(),s(null))}),p.addEventListener("click",function(t){t.target!==p||(0,o.rV)(t,f)||(m(),s(null))}),(0,o.ou)(p,f),p.querySelector(".confirm-btn").addEventListener("click",function(t){if(!(0,o.u$)(t)){var e=p.querySelector('input[name="matching-tx-choice"]:checked');if(!e)return m(),void s(null);var n=e.value;m(),s("create"===n?{action:"create"}:"skip"===n?{action:"skip"}:{action:"link",transactionId:parseInt(n,10)})}})})}},400(t,e,n){function a(t){if(null==t||""===String(t).trim())return NaN;var e=Number(t);return Number.isFinite(e)?Math.round(100*e):NaN}function r(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=Number(t);if(!Number.isFinite(n))return 0;var a=Math.pow(10,e),r=Math.round(Number((Math.abs(n)*a).toPrecision(14)))/a;return n<0&&0!==r?-r:r}n.d(e,{B:()=>r,F:()=>a})},568(t,e,n){n.d(e,{I9:()=>l,JC:()=>d,Qg:()=>c,Te:()=>s,cf:()=>u});var a=n(746),r=n(17);function i(t,e){var n=function(){var t=document.getElementById("budget-toast-container");return t||((t=document.createElement("div")).id="budget-toast-container",document.body.appendChild(t)),t}(),a=document.createElement("div");a.className="budget-toast budget-toast-".concat(e),a.textContent=(0,r.wh)(t),a.addEventListener("click",function(){return o(a)}),n.appendChild(a),requestAnimationFrame(function(){return a.classList.add("budget-toast--visible")}),setTimeout(function(){return o(a)},7e3)}function o(t){t.classList.contains("budget-toast--dismissing")||(t.classList.add("budget-toast--dismissing"),t.classList.remove("budget-toast--visible"),t.addEventListener("transitionend",function(){return t.remove()},{once:!0}),setTimeout(function(){return t.remove()},500))}function s(t){i(t,"success")}function c(t){i(t,"error")}function l(t){i(t,"warning")}function u(t){i(t,"info")}function d(t,e,n){var i=document.createElement("div");i.className="undo-notification";var o=!1;i.innerHTML='\n \n \n "),i.querySelector(".undo-message").textContent=(0,r.wh)(t),Object.assign(i.style,{position:"fixed",bottom:"20px",left:"50%",transform:"translateX(-50%)",backgroundColor:"#333",color:"#fff",padding:"12px 20px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"15px",zIndex:"10000",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",animation:"slideUp 0.3s ease-out"});var s=i.querySelector(".undo-btn");return Object.assign(s.style,{backgroundColor:"#fff",color:"#333",border:"none",padding:"6px 12px",borderRadius:"3px",cursor:"pointer",fontWeight:"bold",fontSize:"13px"}),s.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation(),o||(o=!0,e()),i.remove()}),document.body.appendChild(i),setTimeout(function(){i.style.animation="slideDown 0.3s ease-in",setTimeout(function(){i.remove(),!o&&n&&(o=!0,n())},300)},5e3),{dismiss:function(){o=!0,i.remove()}}}},10(t,e,n){n.d(e,{Fd:()=>w,tf:()=>y});var a=n(746),r=n(993),i=n(688),o=n(707);function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function c(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function l(t){for(var e=1;e3?(r=p===a)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),s=u,c=p;(e=s<2?t:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),g(s,c)):h.n=c:h.v=c);try{if(l=2,i){if(s||(r="next"),e=i[r]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=t}else if((e=(d=h.n<0)?c:n.call(a,h))!==o)break}catch(e){i=t,s=1,c=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),l}var o={};function s(){}function c(){}function l(){}e=Object.getPrototypeOf;var u=[][a]?e(e([][a]())):(h(e={},a,function(){return this}),e),g=l.prototype=s.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,h(t,r,"GeneratorFunction")),t.prototype=Object.create(g),t}return c.prototype=l,h(g,"constructor",l),h(l,"constructor",c),c.displayName="GeneratorFunction",h(l,r,"GeneratorFunction"),h(g),h(g,r,"Generator"),h(g,a,function(){return this}),h(g,"toString",function(){return"[object Generator]"}),(d=function(){return{w:i,m:p}})()}function h(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}h=function(t,e,n,a){function i(e,n){h(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},h(t,e,n,a)}function g(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function p(t){return function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){g(i,a,r,o,s,"next",t)}function s(t){g(i,a,r,o,s,"throw",t)}o(void 0)})}}var f={bill:"payment_recorded",income:"receipt_recorded"},m=null;function v(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.kind,s=void 0===i?"bill":i,c=n.currency,l=void 0===c?"":c;return new Promise(function(n){var i,c;null===(i=m)||void 0===i||i(null),null===(c=document.getElementById("payment-recorded-modal"))||void 0===c||c.remove();var u={date:r.Yq(t.date,e),amount:r.vv(t.amount,l||(null==e?void 0:e.default_currency)||"",e||{})},d={escape:!1,sanitize:!1},h="income"===s?(0,a.Tl)("budget","This income already has a payment on {date} ({amount}).",u,void 0,d):(0,a.Tl)("budget","This bill already has a payment on {date} ({amount}).",u,void 0,d),g=document.createElement("div");g.id="payment-recorded-modal",g.className="budget-modal-overlay",g.innerHTML='\n \n "),g.querySelector(".matching-tx-intro").textContent=h,document.body.appendChild(g);var p=Date.now(),f=function(t){m===f&&(m=null),document.removeEventListener("keydown",v,!0),g.remove(),n(t)};m=f;var v=function(t){"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),f(null))},y=function(t){return function(e){(0,o.u$)(e)||f(t)}};g.querySelector(".close-btn").addEventListener("click",y(null)),g.querySelector(".cancel-btn").addEventListener("click",y(null)),g.querySelector(".another-btn").addEventListener("click",y("another")),g.querySelector(".confirm-btn").addEventListener("click",y("use")),g.addEventListener("click",function(t){t.target!==g||(0,o.rV)(t,p)||f(null)}),(0,o.ou)(g,p),document.addEventListener("keydown",v,!0),g.querySelector(".confirm-btn").focus()})}function y(t,e,n){return b.apply(this,arguments)}function b(){return b=p(d().m(function t(e,n,a){var r,o,s,c,l,u,h=arguments;return d().w(function(t){for(;;)switch(t.n){case 0:return r=(h.length>3&&void 0!==h[3]?h[3]:{}).currency,o=void 0===r?"":r,s=n?"?dueDate=".concat(encodeURIComponent(n)):"",t.n=1,(0,i.n)("/apps/budget/api/bills/".concat(e,"/recorded-payment").concat(s)).catch(function(){return null});case 1:if(c=t.v,(l=null==c?void 0:c.existing)&&"string"==typeof l.date){t.n=2;break}return t.a(2,{usePayment:null,confirmSecondPayment:!1});case 2:return t.n=3,v(l,a,{kind:"bill",currency:o});case 3:if(null!==(u=t.v)){t.n=4;break}return t.a(2,null);case 4:return t.a(2,"use"===u?{usePayment:l,confirmSecondPayment:!1}:{usePayment:null,confirmSecondPayment:!0})}},t)})),b.apply(this,arguments)}function w(t,e,n){return T.apply(this,arguments)}function T(){return T=p(d().m(function t(e,n,a){var r,o,s,c,u,h,g,p,f,m,y,b,w,T,E,x,S,C=arguments;return d().w(function(t){for(;;)switch(t.p=t.n){case 0:return c=(s=C.length>3&&void 0!==C[3]?C[3]:{}).kind,u=void 0===c?"bill":c,h=s.currency,g=void 0===h?"":h,p=s.errorMessage,f=function(t){return(0,i.n)(e,{method:"POST",body:t,errorMessage:p})},t.p=1,t.n=2,f(n);case 2:return w=t.v,t.a(2,{result:w,usedPayment:null});case 3:if(t.p=3,T=t.v,null!==(m=k(T,u))){t.n=4;break}throw T;case 4:return t.n=5,v(m,a,{kind:u,currency:g});case 5:if(null!==(y=t.v)){t.n=6;break}return t.a(2,null);case 6:if("another"!==y){t.n=8;break}return t.n=7,f(l(l({},n),{},{confirmSecondPayment:!0}));case 7:return E=t.v,t.a(2,{result:E,usedPayment:null});case 8:return b="income"===u?{createTransaction:!1,receivedDate:m.date,expectedDate:null!==(r=n.expectedDate)&&void 0!==r?r:null}:{recordPayment:!1,paidDate:m.date,dueDate:null!==(o=n.dueDate)&&void 0!==o?o:null},t.n=9,f(b);case 9:return x=t.v,S=m,t.a(2,{result:x,usedPayment:S})}},t,null,[[1,3]])})),T.apply(this,arguments)}function k(t,e){var n;if(!(t instanceof i.h)||409!==t.status||(null===(n=t.data)||void 0===n?void 0:n.code)!==f[e])return null;var a=t.data.existing;return a&&"string"==typeof a.date?a:null}},42(t,e,n){function a(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function s(n,a,i,o){var s=a&&a.prototype instanceof l?a:l,u=Object.create(s.prototype);return r(u,"_invoke",function(n,a,r){var i,o,s,l=0,u=r||[],d=!1,h={p:0,n:0,v:t,a:g,f:g.bind(t,4),d:function(e,n){return i=e,o=0,s=t,h.n=n,c}};function g(n,a){for(o=n,s=a,e=0;!d&&l&&!r&&e3?(r=p===a)&&(s=i[(o=i[4])?5:(o=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,o=0))}if(r||n>1)return c;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),o=u,s=p;(e=o<2?t:s)||!d;){i||(o?o<3?(o>1&&(h.n=-1),g(o,s)):h.n=s:h.v=s);try{if(l=2,i){if(o||(r="next"),e=i[r]){if(!(e=e.call(i,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,o<2&&(o=0)}else 1===o&&(e=i.return)&&e.call(i),o<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),o=1);i=t}else if((e=(d=h.n<0)?s:n.call(a,h))!==c)break}catch(e){i=t,o=1,s=e}finally{l=1}}return{value:e,done:d}}}(n,i,o),!0),u}var c={};function l(){}function u(){}function d(){}e=Object.getPrototypeOf;var h=[][i]?e(e([][i]())):(r(e={},i,function(){return this}),e),g=d.prototype=l.prototype=Object.create(h);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,r(t,o,"GeneratorFunction")),t.prototype=Object.create(g),t}return u.prototype=d,r(g,"constructor",d),r(d,"constructor",u),u.displayName="GeneratorFunction",r(d,o,"GeneratorFunction"),r(g),r(g,o,"Generator"),r(g,i,function(){return this}),r(g,"toString",function(){return"[object Generator]"}),(a=function(){return{w:s,m:p}})()}function r(t,e,n,a){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}r=function(t,e,n,a){function o(e,n){r(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},r(t,e,n,a)}function i(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function o(t,e,n,a){return s.apply(this,arguments)}function s(){var t;return t=a().m(function t(e,n,r,i){var o;return a().w(function(t){for(;;)switch(t.p=t.n){case 0:return o=0===(null==e?void 0:e.detail),t.p=1,t.n=2,i();case 2:return t.a(2,t.v);case 3:return t.p=3,o&&c(n,r),t.f(3);case 4:return t.a(2)}},t,null,[[1,,3,4]])}),s=function(){var e=this,n=arguments;return new Promise(function(a,r){var o=t.apply(e,n);function s(t){i(o,a,r,s,c,"next",t)}function c(t){i(o,a,r,s,c,"throw",t)}s(void 0)})},s.apply(this,arguments)}function c(t,e){var n=document.activeElement;if(n&&n!==document.body&&n.isConnected)return!1;var a=document.querySelector(t);if(!a)return!1;var r=a.querySelector("".concat(e,":not([disabled])"))||a.querySelector("button:not([disabled])");return r?(r.focus(),!0):(a.setAttribute("tabindex","-1"),a.focus(),!0)}n.d(e,{m:()=>o})},69(t,e,n){n.d(e,{L:()=>l});var a=n(993);function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,r,i,o,s=[],c=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(s.push(a.value),s.length!==e);c=!0);}catch(t){l=!0,r=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n=1&&i(t)<=12};return Array.isArray(null===(n=r)||void 0===n?void 0:n.months)&&r.months.length>0?r.months.filter(o).map(function(t){return[i(t),e]}):Array.isArray(null===(a=r)||void 0===a?void 0:a.dates)&&r.dates.length>0?r.dates.filter(function(t){return o(null==t?void 0:t.month)&&void 0!==t.day&&null!==t.day}).map(function(t){return[i(t.month),Math.trunc(Number(t.day))]}):[]}(t,Number(e)||Number(n.slice(8,10)));if(0===i.length)return null;var o=c(i,n),s=a.X6(r,o);if(s<=0)return!0;var l=c(i,o);return 2*s<=a.X6(l,o)}(d,g,s,l):null,y=!f&&"one-time"!==r&&null!==m&&m>=0&&(null!=v?v:m<=(null!==(n=o[r])&&void 0!==n?n:31));if(!i||!s)return{status:"inactive",recentlySettled:y};var b=a.X6(e,s);return{status:b<0?"overdue":b<=7?"soon":y?"settled":"upcoming",recentlySettled:y}}},958(t,e,n){function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);ns,LB:()=>o,to:()=>i});var r=new Set;function i(t,e,n,a){Object.assign(t,{skipItem:e,skipDate:n,skipToast:a}),r.add(t)}function o(t){r.delete(t)}function s(t){if(r.delete(t),t.skipItem&&t.skipDate)for(var e=0,n=function(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return a(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(r);e=t.skipDate&&(s.spent=!0,r.delete(s),null===(i=s.skipToast)||void 0===i||null===(o=i.dismiss)||void 0===o||o.call(i))}}},933(t,e,n){function a(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function s(n,a,i,o){var s=a&&a.prototype instanceof l?a:l,u=Object.create(s.prototype);return r(u,"_invoke",function(n,a,r){var i,o,s,l=0,u=r||[],d=!1,h={p:0,n:0,v:t,a:g,f:g.bind(t,4),d:function(e,n){return i=e,o=0,s=t,h.n=n,c}};function g(n,a){for(o=n,s=a,e=0;!d&&l&&!r&&e3?(r=p===a)&&(s=i[(o=i[4])?5:(o=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,o=0))}if(r||n>1)return c;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),o=u,s=p;(e=o<2?t:s)||!d;){i||(o?o<3?(o>1&&(h.n=-1),g(o,s)):h.n=s:h.v=s);try{if(l=2,i){if(o||(r="next"),e=i[r]){if(!(e=e.call(i,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,o<2&&(o=0)}else 1===o&&(e=i.return)&&e.call(i),o<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),o=1);i=t}else if((e=(d=h.n<0)?s:n.call(a,h))!==c)break}catch(e){i=t,o=1,s=e}finally{l=1}}return{value:e,done:d}}}(n,i,o),!0),u}var c={};function l(){}function u(){}function d(){}e=Object.getPrototypeOf;var h=[][i]?e(e([][i]())):(r(e={},i,function(){return this}),e),g=d.prototype=l.prototype=Object.create(h);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,r(t,o,"GeneratorFunction")),t.prototype=Object.create(g),t}return u.prototype=d,r(g,"constructor",d),r(d,"constructor",u),u.displayName="GeneratorFunction",r(d,o,"GeneratorFunction"),r(g),r(g,o,"Generator"),r(g,i,function(){return this}),r(g,"toString",function(){return"[object Generator]"}),(a=function(){return{w:s,m:p}})()}function r(t,e,n,a){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}r=function(t,e,n,a){function o(e,n){r(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},r(t,e,n,a)}function i(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}n.d(e,{O:()=>s});var o=new Set;function s(t,e,n){return c.apply(this,arguments)}function c(){var t;return t=a().m(function t(e,n,r){return a().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!o.has(e)){t.n=1;break}return t.a(2,void 0);case 1:return o.add(e),n&&(n.disabled=!0),t.p=2,t.n=3,r();case 3:return t.a(2,t.v);case 4:return t.p=4,o.delete(e),n&&(n.disabled=!1),t.f(4);case 5:return t.a(2)}},t,null,[[2,,4,5]])}),c=function(){var e=this,n=arguments;return new Promise(function(a,r){var o=t.apply(e,n);function s(t){i(o,a,r,s,c,"next",t)}function c(t){i(o,a,r,s,c,"throw",t)}s(void 0)})},c.apply(this,arguments)}},475(t,e,n){function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function i(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:[]);return(t||[]).filter(function(t){return!t.hidden||e.has(t.id)})}function c(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return(t||[]).map(function(t){return{tagSet:t,offered:s(t.tags,e)}}).filter(function(t){var e=t.tagSet;return t.offered.length>0||0===(e.tags||[]).length}).map(function(t){var e=t.tagSet,n=t.offered;return i(i({},e),{},{tags:n})})}n.d(e,{g:()=>s,s:()=>c})},421(t,e,n){n.d(e,{A:()=>L});var a=n.cw(()=>{"function"!=typeof Object.assign&&(Object.assign=function(t){for(var e=[],n=1;n",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1},o={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(t){var e=t%100;if(e>3&&e<21)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",monthAriaLabel:"Month",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1};const s=o;var c=function(t,e){return void 0===e&&(e=2),("000"+t).slice(-1*e)},l=function(t){return!0===t?1:0};function u(t,e){var n;return function(){var a=this,r=arguments;clearTimeout(n),n=setTimeout(function(){return t.apply(a,r)},e)}}var d=function(t){return t instanceof Array?t:[t]};function h(t,e,n){if(!0===n)return t.classList.add(e);t.classList.remove(e)}function g(t,e,n){var a=window.document.createElement(t);return e=e||"",n=n||"",a.className=e,void 0!==n&&(a.textContent=n),a}function p(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function f(t,e){return e(t)?t:t.parentNode?f(t.parentNode,e):void 0}function m(t,e){var n=g("div","numInputWrapper"),a=g("input","numInput "+t),r=g("span","arrowUp"),i=g("span","arrowDown");if(-1===navigator.userAgent.indexOf("MSIE 9.0")?a.type="number":(a.type="text",a.pattern="\\d*"),void 0!==e)for(var o in e)a.setAttribute(o,e[o]);return n.appendChild(a),n.appendChild(r),n.appendChild(i),n}function v(t){try{return"function"==typeof t.composedPath?t.composedPath()[0]:t.target}catch(e){return t.target}}var y=function(){},b=function(t,e,n){return n.months[e?"shorthand":"longhand"][t]},w={D:y,F:function(t,e,n){t.setMonth(n.months.longhand.indexOf(e))},G:function(t,e){t.setHours((t.getHours()>=12?12:0)+parseFloat(e))},H:function(t,e){t.setHours(parseFloat(e))},J:function(t,e){t.setDate(parseFloat(e))},K:function(t,e,n){t.setHours(t.getHours()%12+12*l(new RegExp(n.amPM[1],"i").test(e)))},M:function(t,e,n){t.setMonth(n.months.shorthand.indexOf(e))},S:function(t,e){t.setSeconds(parseFloat(e))},U:function(t,e){return new Date(1e3*parseFloat(e))},W:function(t,e,n){var a=parseInt(e),r=new Date(t.getFullYear(),0,2+7*(a-1),0,0,0,0);return r.setDate(r.getDate()-r.getDay()+n.firstDayOfWeek),r},Y:function(t,e){t.setFullYear(parseFloat(e))},Z:function(t,e){return new Date(e)},d:function(t,e){t.setDate(parseFloat(e))},h:function(t,e){t.setHours((t.getHours()>=12?12:0)+parseFloat(e))},i:function(t,e){t.setMinutes(parseFloat(e))},j:function(t,e){t.setDate(parseFloat(e))},l:y,m:function(t,e){t.setMonth(parseFloat(e)-1)},n:function(t,e){t.setMonth(parseFloat(e)-1)},s:function(t,e){t.setSeconds(parseFloat(e))},u:function(t,e){return new Date(parseFloat(e))},w:y,y:function(t,e){t.setFullYear(2e3+parseFloat(e))}},T={D:"",F:"",G:"(\\d\\d|\\d)",H:"(\\d\\d|\\d)",J:"(\\d\\d|\\d)\\w+",K:"",M:"",S:"(\\d\\d|\\d)",U:"(.+)",W:"(\\d\\d|\\d)",Y:"(\\d{4})",Z:"(.+)",d:"(\\d\\d|\\d)",h:"(\\d\\d|\\d)",i:"(\\d\\d|\\d)",j:"(\\d\\d|\\d)",l:"",m:"(\\d\\d|\\d)",n:"(\\d\\d|\\d)",s:"(\\d\\d|\\d)",u:"(.+)",w:"(\\d\\d|\\d)",y:"(\\d{2})"},k={Z:function(t){return t.toISOString()},D:function(t,e,n){return e.weekdays.shorthand[k.w(t,e,n)]},F:function(t,e,n){return b(k.n(t,e,n)-1,!1,e)},G:function(t,e,n){return c(k.h(t,e,n))},H:function(t){return c(t.getHours())},J:function(t,e){return void 0!==e.ordinal?t.getDate()+e.ordinal(t.getDate()):t.getDate()},K:function(t,e){return e.amPM[l(t.getHours()>11)]},M:function(t,e){return b(t.getMonth(),!0,e)},S:function(t){return c(t.getSeconds())},U:function(t){return t.getTime()/1e3},W:function(t,e,n){return n.getWeek(t)},Y:function(t){return c(t.getFullYear(),4)},d:function(t){return c(t.getDate())},h:function(t){return t.getHours()%12?t.getHours()%12:12},i:function(t){return c(t.getMinutes())},j:function(t){return t.getDate()},l:function(t,e){return e.weekdays.longhand[t.getDay()]},m:function(t){return c(t.getMonth()+1)},n:function(t){return t.getMonth()+1},s:function(t){return t.getSeconds()},u:function(t){return t.getTime()},w:function(t){return t.getDay()},y:function(t){return String(t.getFullYear()).substring(2)}},E=function(t){var e=t.config,n=void 0===e?i:e,a=t.l10n,r=void 0===a?o:a,s=t.isMobile,c=void 0!==s&&s;return function(t,e,a){var i=a||r;return void 0===n.formatDate||c?e.split("").map(function(e,a,r){return k[e]&&"\\"!==r[a-1]?k[e](t,i,n):"\\"!==e?e:""}).join(""):n.formatDate(t,e,i)}},x=function(t){var e=t.config,n=void 0===e?i:e,a=t.l10n,r=void 0===a?o:a;return function(t,e,a,o){if(0===t||t){var s,c=o||r,l=t;if(t instanceof Date)s=new Date(t.getTime());else if("string"!=typeof t&&void 0!==t.toFixed)s=new Date(t);else if("string"==typeof t){var u=e||(n||i).dateFormat,d=String(t).trim();if("today"===d)s=new Date,a=!0;else if(n&&n.parseDate)s=n.parseDate(t,u);else if(/Z$/.test(d)||/GMT$/.test(d))s=new Date(t);else{for(var h=void 0,g=[],p=0,f=0,m="";p=0?new Date:new Date(n.config.minDate.getTime()),a=I(n.config);e.setHours(a.hours,a.minutes,a.seconds,e.getMilliseconds()),n.selectedDates=[e],n.latestSelectedDateObj=e}void 0!==t&&"blur"!==t.type&&function(t){t.preventDefault();var e="keydown"===t.type,a=v(t),r=a;void 0!==n.amPM&&a===n.amPM&&(n.amPM.textContent=n.l10n.amPM[l(n.amPM.textContent===n.l10n.amPM[0])]);var i=parseFloat(r.getAttribute("min")),o=parseFloat(r.getAttribute("max")),s=parseFloat(r.getAttribute("step")),u=parseInt(r.value,10),d=u+s*(t.delta||(e?38===t.which?1:-1:0));if(void 0!==r.value&&2===r.value.length){var h=r===n.hourElement,g=r===n.minuteElement;do&&(d=r===n.hourElement?d-o-l(!n.amPM):i,g&&N(void 0,1,n.hourElement)),n.amPM&&h&&(1===s?d+u===23:Math.abs(d-u)>s)&&(n.amPM.textContent=n.l10n.amPM[l(n.amPM.textContent===n.l10n.amPM[0])]),r.value=c(d)}}(t);var r=n._input.value;k(),kt(),n._input.value!==r&&n._debouncedChange()}function k(){if(void 0!==n.hourElement&&void 0!==n.minuteElement){var t,e,a=(parseInt(n.hourElement.value.slice(-2),10)||0)%24,r=(parseInt(n.minuteElement.value,10)||0)%60,i=void 0!==n.secondElement?(parseInt(n.secondElement.value,10)||0)%60:0;void 0!==n.amPM&&(t=a,e=n.amPM.textContent,a=t%12+12*l(e===n.l10n.amPM[1]));var o=void 0!==n.config.minTime||n.config.minDate&&n.minDateHasTime&&n.latestSelectedDateObj&&0===S(n.latestSelectedDateObj,n.config.minDate,!0),s=void 0!==n.config.maxTime||n.config.maxDate&&n.maxDateHasTime&&n.latestSelectedDateObj&&0===S(n.latestSelectedDateObj,n.config.maxDate,!0);if(void 0!==n.config.maxTime&&void 0!==n.config.minTime&&n.config.minTime>n.config.maxTime){var c=C(n.config.minTime.getHours(),n.config.minTime.getMinutes(),n.config.minTime.getSeconds()),u=C(n.config.maxTime.getHours(),n.config.maxTime.getMinutes(),n.config.maxTime.getSeconds()),d=C(a,r,i);if(d>u&&d=12)]),void 0!==n.secondElement&&(n.secondElement.value=c(a)))}function L(t){var e=v(t),n=parseInt(e.value)+(t.delta||0);(n/1e3>1||"Enter"===t.key&&!/[^\d]/.test(n.toString()))&&J(n)}function P(t,e,a,r){return e instanceof Array?e.forEach(function(e){return P(t,e,a,r)}):t instanceof Array?t.forEach(function(t){return P(t,e,a,r)}):(t.addEventListener(e,a,r),void n._handlers.push({remove:function(){return t.removeEventListener(e,a,r)}}))}function O(){vt("onChange")}function F(t,e){var a=void 0!==t?n.parseDate(t):n.latestSelectedDateObj||(n.config.minDate&&n.config.minDate>n.now?n.config.minDate:n.config.maxDate&&n.config.maxDate=0&&S(t,n.selectedDates[1])<=0}(e)&&!bt(e)&&o.classList.add("inRange"),n.weekNumbers&&1===n.config.showMonths&&"prevMonthDay"!==t&&r%7==6&&n.weekNumbers.insertAdjacentHTML("beforeend",""+n.config.getWeek(e)+""),vt("onDayCreate",o),o}function H(t){t.focus(),"range"===n.config.mode&&rt(t)}function z(t){for(var e=t>0?0:n.config.showMonths-1,a=t>0?n.config.showMonths:-1,r=e;r!=a;r+=t)for(var i=n.daysContainer.children[r],o=t>0?0:i.children.length-1,s=t>0?i.children.length:-1,c=o;c!=s;c+=t){var l=i.children[c];if(-1===l.className.indexOf("hidden")&&tt(l.dateObj))return l}}function V(t,e){var r=a(),i=et(r||document.body),o=void 0!==t?t:i?r:void 0!==n.selectedDateElem&&et(n.selectedDateElem)?n.selectedDateElem:void 0!==n.todayDateElem&&et(n.todayDateElem)?n.todayDateElem:z(e>0?1:-1);void 0===o?n._input.focus():i?function(t,e){for(var a=-1===t.className.indexOf("Month")?t.dateObj.getMonth():n.currentMonth,r=e>0?n.config.showMonths:-1,i=e>0?1:-1,o=a-n.currentMonth;o!=r;o+=i)for(var s=n.daysContainer.children[o],c=a-n.currentMonth===o?t.$i+e:e<0?s.children.length-1:0,l=s.children.length,u=c;u>=0&&u0?l:-1);u+=i){var d=s.children[u];if(-1===d.className.indexOf("hidden")&&tt(d.dateObj)&&Math.abs(t.$i-u)>=Math.abs(e))return H(d)}n.changeMonth(i),V(z(i),0)}(o,e):H(o)}function q(t,e){for(var a=(new Date(t,e,1).getDay()-n.l10n.firstDayOfWeek+7)%7,r=n.utils.getDaysInMonth((e-1+12)%12,t),i=n.utils.getDaysInMonth(e,t),o=window.document.createDocumentFragment(),s=n.config.showMonths>1,c=s?"prevMonthDay hidden":"prevMonthDay",l=s?"nextMonthDay hidden":"nextMonthDay",u=r+1-a,d=0;u<=r;u++,d++)o.appendChild(j("flatpickr-day "+c,new Date(t,e-1,u),0,d));for(u=1;u<=i;u++,d++)o.appendChild(j("flatpickr-day",new Date(t,e,u),0,d));for(var h=i+1;h<=42-a&&(1===n.config.showMonths||d%7!=0);h++,d++)o.appendChild(j("flatpickr-day "+l,new Date(t,e+1,h%i),0,d));var p=g("div","dayContainer");return p.appendChild(o),p}function W(){if(void 0!==n.daysContainer){p(n.daysContainer),n.weekNumbers&&p(n.weekNumbers);for(var t=document.createDocumentFragment(),e=0;e1||"dropdown"!==n.config.monthSelectorType)){var t=function(t){return!(void 0!==n.config.minDate&&n.currentYear===n.config.minDate.getFullYear()&&tn.config.maxDate.getMonth())};n.monthsDropdownContainer.tabIndex=-1,n.monthsDropdownContainer.innerHTML="";for(var e=0;e<12;e++)if(t(e)){var a=g("option","flatpickr-monthDropdown-month");a.value=new Date(n.currentYear,e).getMonth().toString(),a.textContent=b(e,n.config.shorthandCurrentMonth,n.l10n),a.tabIndex=-1,n.currentMonth===e&&(a.selected=!0),n.monthsDropdownContainer.appendChild(a)}}}function G(){var t,e=g("div","flatpickr-month"),a=window.document.createDocumentFragment();n.config.showMonths>1||"static"===n.config.monthSelectorType?t=g("span","cur-month"):(n.monthsDropdownContainer=g("select","flatpickr-monthDropdown-months"),n.monthsDropdownContainer.setAttribute("aria-label",n.l10n.monthAriaLabel),P(n.monthsDropdownContainer,"change",function(t){var e=v(t),a=parseInt(e.value,10);n.changeMonth(a-n.currentMonth),vt("onMonthChange")}),U(),t=n.monthsDropdownContainer);var r=m("cur-year",{tabindex:"-1"}),i=r.getElementsByTagName("input")[0];i.setAttribute("aria-label",n.l10n.yearAriaLabel),n.config.minDate&&i.setAttribute("min",n.config.minDate.getFullYear().toString()),n.config.maxDate&&(i.setAttribute("max",n.config.maxDate.getFullYear().toString()),i.disabled=!!n.config.minDate&&n.config.minDate.getFullYear()===n.config.maxDate.getFullYear());var o=g("div","flatpickr-current-month");return o.appendChild(t),o.appendChild(r),a.appendChild(o),e.appendChild(a),{container:e,yearElement:i,monthElement:t}}function Z(){p(n.monthNav),n.monthNav.appendChild(n.prevMonthNav),n.config.showMonths&&(n.yearElements=[],n.monthElements=[]);for(var t=n.config.showMonths;t--;){var e=G();n.yearElements.push(e.yearElement),n.monthElements.push(e.monthElement),n.monthNav.appendChild(e.container)}n.monthNav.appendChild(n.nextMonthNav)}function Y(){n.weekdayContainer?p(n.weekdayContainer):n.weekdayContainer=g("div","flatpickr-weekdays");for(var t=n.config.showMonths;t--;){var e=g("div","flatpickr-weekdaycontainer");n.weekdayContainer.appendChild(e)}return Q(),n.weekdayContainer}function Q(){if(n.weekdayContainer){var t=n.l10n.firstDayOfWeek,e=_(n.l10n.weekdays.shorthand);t>0&&t\n "+e.join("")+"\n \n "}}function $(t,e){void 0===e&&(e=!0);var a=e?t:t-n.currentMonth;a<0&&!0===n._hidePrevMonthArrow||a>0&&!0===n._hideNextMonthArrow||(n.currentMonth+=a,(n.currentMonth<0||n.currentMonth>11)&&(n.currentYear+=n.currentMonth>11?1:-1,n.currentMonth=(n.currentMonth+12)%12,vt("onYearChange"),U()),W(),vt("onMonthChange"),wt())}function K(t){return n.calendarContainer.contains(t)}function X(t){if(n.isOpen&&!n.config.inline){var e=v(t),a=K(e),r=!(e===n.input||e===n.altInput||n.element.contains(e)||t.path&&t.path.indexOf&&(~t.path.indexOf(n.input)||~t.path.indexOf(n.altInput))||a||K(t.relatedTarget)),i=!n.config.ignoredFocusElements.some(function(t){return t.contains(e)});r&&i&&(n.config.allowInput&&n.setDate(n._input.value,!1,n.config.altInput?n.config.altFormat:n.config.dateFormat),void 0!==n.timeContainer&&void 0!==n.minuteElement&&void 0!==n.hourElement&&""!==n.input.value&&void 0!==n.input.value&&w(),n.close(),n.config&&"range"===n.config.mode&&1===n.selectedDates.length&&n.clear(!1))}}function J(t){if(!(!t||n.config.minDate&&tn.config.maxDate.getFullYear())){var e=t,a=n.currentYear!==e;n.currentYear=e||n.currentYear,n.config.maxDate&&n.currentYear===n.config.maxDate.getFullYear()?n.currentMonth=Math.min(n.config.maxDate.getMonth(),n.currentMonth):n.config.minDate&&n.currentYear===n.config.minDate.getFullYear()&&(n.currentMonth=Math.max(n.config.minDate.getMonth(),n.currentMonth)),a&&(n.redraw(),vt("onYearChange"),U())}}function tt(t,e){var a;void 0===e&&(e=!0);var r=n.parseDate(t,void 0,e);if(n.config.minDate&&r&&S(r,n.config.minDate,void 0!==e?e:!n.minDateHasTime)<0||n.config.maxDate&&r&&S(r,n.config.maxDate,void 0!==e?e:!n.maxDateHasTime)>0)return!1;if(!n.config.enable&&0===n.config.disable.length)return!0;if(void 0===r)return!1;for(var i=!!n.config.enable,o=null!==(a=n.config.enable)&&void 0!==a?a:n.config.disable,s=0,c=void 0;s=c.from.getTime()&&r.getTime()<=c.to.getTime())return i}return!i}function et(t){return void 0!==n.daysContainer&&-1===t.className.indexOf("hidden")&&-1===t.className.indexOf("flatpickr-disabled")&&n.daysContainer.contains(t)}function nt(t){var e=t.target===n._input,a=n._input.value.trimEnd()!==Tt();!e||!a||t.relatedTarget&&K(t.relatedTarget)||n.setDate(n._input.value,!0,t.target===n.altInput?n.config.altFormat:n.config.dateFormat)}function at(e){var r=v(e),i=n.config.wrap?t.contains(r):r===n._input,o=n.config.allowInput,s=n.isOpen&&(!o||!i),c=n.config.inline&&i&&!o;if(13===e.keyCode&&i){if(o)return n.setDate(n._input.value,!0,r===n.altInput?n.config.altFormat:n.config.dateFormat),n.close(),r.blur();n.open()}else if(K(r)||s||c){var l=!!n.timeContainer&&n.timeContainer.contains(r);switch(e.keyCode){case 13:l?(e.preventDefault(),w(),dt()):ht(e);break;case 27:e.preventDefault(),dt();break;case 8:case 46:i&&!n.config.allowInput&&(e.preventDefault(),n.clear());break;case 37:case 39:if(l||i)n.hourElement&&n.hourElement.focus();else{e.preventDefault();var u=a();if(void 0!==n.daysContainer&&(!1===o||u&&et(u))){var d=39===e.keyCode?1:-1;e.ctrlKey?(e.stopPropagation(),$(d),V(z(1),0)):V(void 0,d)}}break;case 38:case 40:e.preventDefault();var h=40===e.keyCode?1:-1;n.daysContainer&&void 0!==r.$i||r===n.input||r===n.altInput?e.ctrlKey?(e.stopPropagation(),J(n.currentYear-h),V(z(1),0)):l||V(void 0,7*h):r===n.currentYearElement?J(n.currentYear-h):n.config.enableTime&&(!l&&n.hourElement&&n.hourElement.focus(),w(e),n._debouncedChange());break;case 9:if(l){var g=[n.hourElement,n.minuteElement,n.secondElement,n.amPM].concat(n.pluginElements).filter(function(t){return t}),p=g.indexOf(r);if(-1!==p){var f=g[p+(e.shiftKey?-1:1)];e.preventDefault(),(f||n._input).focus()}}else!n.config.noCalendar&&n.daysContainer&&n.daysContainer.contains(r)&&e.shiftKey&&(e.preventDefault(),n._input.focus())}}if(void 0!==n.amPM&&r===n.amPM)switch(e.key){case n.l10n.amPM[0].charAt(0):case n.l10n.amPM[0].charAt(0).toLowerCase():n.amPM.textContent=n.l10n.amPM[0],k(),kt();break;case n.l10n.amPM[1].charAt(0):case n.l10n.amPM[1].charAt(0).toLowerCase():n.amPM.textContent=n.l10n.amPM[1],k(),kt()}(i||K(r))&&vt("onKeyDown",e)}function rt(t,e){if(void 0===e&&(e="flatpickr-day"),1===n.selectedDates.length&&(!t||t.classList.contains(e)&&!t.classList.contains("flatpickr-disabled"))){for(var a=t?t.dateObj.getTime():n.days.firstElementChild.dateObj.getTime(),r=n.parseDate(n.selectedDates[0],void 0,!0).getTime(),i=Math.min(a,n.selectedDates[0].getTime()),o=Math.max(a,n.selectedDates[0].getTime()),s=!1,c=0,l=0,u=i;ui&&uc)?c=u:u>r&&(!l||u ."+e)).forEach(function(e){var i,o,u,d=e.dateObj.getTime(),h=c>0&&d0&&d>l;if(h)return e.classList.add("notAllowed"),void["inRange","startRange","endRange"].forEach(function(t){e.classList.remove(t)});s&&!h||(["startRange","inRange","endRange","notAllowed"].forEach(function(t){e.classList.remove(t)}),void 0!==t&&(t.classList.add(a<=n.selectedDates[0].getTime()?"startRange":"endRange"),ra&&d===r&&e.classList.add("endRange"),d>=c&&(0===l||d<=l)&&(o=r,u=a,(i=d)>Math.min(o,u)&&i0||a.getMinutes()>0||a.getSeconds()>0),n.selectedDates&&(n.selectedDates=n.selectedDates.filter(function(t){return tt(t)}),n.selectedDates.length||"min"!==t||M(a),kt()),n.daysContainer&&(ut(),void 0!==a?n.currentYearElement[t]=a.getFullYear().toString():n.currentYearElement.removeAttribute(t),n.currentYearElement.disabled=!!r&&void 0!==a&&r.getFullYear()===a.getFullYear())}}function st(){return n.config.wrap?t.querySelector("[data-input]"):t}function ct(){"object"!=typeof n.config.locale&&void 0===B.l10ns[n.config.locale]&&n.config.errorHandler(new Error("flatpickr: invalid locale "+n.config.locale)),n.l10n=A(A({},B.l10ns.default),"object"==typeof n.config.locale?n.config.locale:"default"!==n.config.locale?B.l10ns[n.config.locale]:void 0),T.D="("+n.l10n.weekdays.shorthand.join("|")+")",T.l="("+n.l10n.weekdays.longhand.join("|")+")",T.M="("+n.l10n.months.shorthand.join("|")+")",T.F="("+n.l10n.months.longhand.join("|")+")",T.K="("+n.l10n.amPM[0]+"|"+n.l10n.amPM[1]+"|"+n.l10n.amPM[0].toLowerCase()+"|"+n.l10n.amPM[1].toLowerCase()+")",void 0===A(A({},e),JSON.parse(JSON.stringify(t.dataset||{}))).time_24hr&&void 0===B.defaultConfig.time_24hr&&(n.config.time_24hr=n.l10n.time_24hr),n.formatDate=E(n),n.parseDate=x({config:n.config,l10n:n.l10n})}function lt(t){if("function"!=typeof n.config.position){if(void 0!==n.calendarContainer){vt("onPreCalendarPosition");var e=t||n._positionElement,a=Array.prototype.reduce.call(n.calendarContainer.children,function(t,e){return t+e.offsetHeight},0),r=n.calendarContainer.offsetWidth,i=n.config.position.split(" "),o=i[0],s=i.length>1?i[1]:null,c=e.getBoundingClientRect(),l=window.innerHeight-c.bottom,u="above"===o||"below"!==o&&la,d=window.pageYOffset+c.top+(u?-a-2:e.offsetHeight+2);if(h(n.calendarContainer,"arrowTop",!u),h(n.calendarContainer,"arrowBottom",u),!n.config.inline){var g=window.pageXOffset+c.left,p=!1,f=!1;"center"===s?(g-=(r-c.width)/2,p=!0):"right"===s&&(g-=r-c.width,f=!0),h(n.calendarContainer,"arrowLeft",!p&&!f),h(n.calendarContainer,"arrowCenter",p),h(n.calendarContainer,"arrowRight",f);var m=window.document.body.offsetWidth-(window.pageXOffset+c.right),v=g+r>window.document.body.offsetWidth,y=m+r>window.document.body.offsetWidth;if(h(n.calendarContainer,"rightMost",v),!n.config.static)if(n.calendarContainer.style.top=d+"px",v)if(y){var b=function(){for(var t=null,e=0;en.currentMonth+n.config.showMonths-1)&&"range"!==n.config.mode;if(n.selectedDateElem=a,"single"===n.config.mode)n.selectedDates=[r];else if("multiple"===n.config.mode){var o=bt(r);o?n.selectedDates.splice(parseInt(o),1):n.selectedDates.push(r)}else"range"===n.config.mode&&(2===n.selectedDates.length&&n.clear(!1,!1),n.latestSelectedDateObj=r,n.selectedDates.push(r),0!==S(r,n.selectedDates[0],!0)&&n.selectedDates.sort(function(t,e){return t.getTime()-e.getTime()}));if(k(),i){var s=n.currentYear!==r.getFullYear();n.currentYear=r.getFullYear(),n.currentMonth=r.getMonth(),s&&(vt("onYearChange"),U()),vt("onMonthChange")}if(wt(),W(),kt(),i||"range"===n.config.mode||1!==n.config.showMonths?void 0!==n.selectedDateElem&&void 0===n.hourElement&&n.selectedDateElem&&n.selectedDateElem.focus():H(a),void 0!==n.hourElement&&void 0!==n.hourElement&&n.hourElement.focus(),n.config.closeOnSelect){var c="single"===n.config.mode&&!n.config.enableTime,l="range"===n.config.mode&&2===n.selectedDates.length&&!n.config.enableTime;(c||l)&&dt()}O()}}n.parseDate=x({config:n.config,l10n:n.l10n}),n._handlers=[],n.pluginElements=[],n.loadedPlugins=[],n._bind=P,n._setHoursFromDate=M,n._positionCalendar=lt,n.changeMonth=$,n.changeYear=J,n.clear=function(t,e){if(void 0===t&&(t=!0),void 0===e&&(e=!0),n.input.value="",void 0!==n.altInput&&(n.altInput.value=""),void 0!==n.mobileInput&&(n.mobileInput.value=""),n.selectedDates=[],n.latestSelectedDateObj=void 0,!0===e&&(n.currentYear=n._initialDate.getFullYear(),n.currentMonth=n._initialDate.getMonth()),!0===n.config.enableTime){var a=I(n.config);D(a.hours,a.minutes,a.seconds)}n.redraw(),t&&vt("onChange")},n.close=function(){n.isOpen=!1,n.isMobile||(void 0!==n.calendarContainer&&n.calendarContainer.classList.remove("open"),void 0!==n._input&&n._input.classList.remove("active")),vt("onClose")},n.onMouseOver=rt,n._createElement=g,n.createDay=j,n.destroy=function(){void 0!==n.config&&vt("onDestroy");for(var t=n._handlers.length;t--;)n._handlers[t].remove();if(n._handlers=[],n.mobileInput)n.mobileInput.parentNode&&n.mobileInput.parentNode.removeChild(n.mobileInput),n.mobileInput=void 0;else if(n.calendarContainer&&n.calendarContainer.parentNode)if(n.config.static&&n.calendarContainer.parentNode){var e=n.calendarContainer.parentNode;if(e.lastChild&&e.removeChild(e.lastChild),e.parentNode){for(;e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);e.parentNode.removeChild(e)}}else n.calendarContainer.parentNode.removeChild(n.calendarContainer);n.altInput&&(n.input.type="text",n.altInput.parentNode&&n.altInput.parentNode.removeChild(n.altInput),delete n.altInput),n.input&&(n.input.type=n.input._type,n.input.classList.remove("flatpickr-input"),n.input.removeAttribute("readonly")),["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","monthsDropdownContainer","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach(function(t){try{delete n[t]}catch(t){}})},n.isEnabled=tt,n.jumpToDate=F,n.updateValue=kt,n.open=function(t,e){if(void 0===e&&(e=n._positionElement),!0===n.isMobile){if(t){t.preventDefault();var a=v(t);a&&a.blur()}return void 0!==n.mobileInput&&(n.mobileInput.focus(),n.mobileInput.click()),void vt("onOpen")}if(!n._input.disabled&&!n.config.inline){var r=n.isOpen;n.isOpen=!0,r||(n.calendarContainer.classList.add("open"),n._input.classList.add("active"),vt("onOpen"),lt(e)),!0===n.config.enableTime&&!0===n.config.noCalendar&&(!1!==n.config.allowInput||void 0!==t&&n.timeContainer.contains(t.relatedTarget)||setTimeout(function(){return n.hourElement.select()},50))}},n.redraw=ut,n.set=function(t,e){if(null!==t&&"object"==typeof t)for(var a in Object.assign(n.config,t),t)void 0!==gt[a]&>[a].forEach(function(t){return t()});else n.config[t]=e,void 0!==gt[t]?gt[t].forEach(function(t){return t()}):r.indexOf(t)>-1&&(n.config[t]=d(e));n.redraw(),kt(!0)},n.setDate=function(t,e,a){if(void 0===e&&(e=!1),void 0===a&&(a=n.config.dateFormat),0!==t&&!t||t instanceof Array&&0===t.length)return n.clear(e);pt(t,a),n.latestSelectedDateObj=n.selectedDates[n.selectedDates.length-1],n.redraw(),F(void 0,e),M(),0===n.selectedDates.length&&n.clear(!1),kt(e),e&&vt("onChange")},n.toggle=function(t){if(!0===n.isOpen)return n.close();n.open(t)};var gt={locale:[ct,Q],showMonths:[Z,y,Y],minDate:[F],maxDate:[F],positionElement:[mt],clickOpens:[function(){!0===n.config.clickOpens?(P(n._input,"focus",n.open),P(n._input,"click",n.open)):(n._input.removeEventListener("focus",n.open),n._input.removeEventListener("click",n.open))}]};function pt(t,e){var a=[];if(t instanceof Array)a=t.map(function(t){return n.parseDate(t,e)});else if(t instanceof Date||"number"==typeof t)a=[n.parseDate(t,e)];else if("string"==typeof t)switch(n.config.mode){case"single":case"time":a=[n.parseDate(t,e)];break;case"multiple":a=t.split(n.config.conjunction).map(function(t){return n.parseDate(t,e)});break;case"range":a=t.split(n.l10n.rangeSeparator).map(function(t){return n.parseDate(t,e)})}else n.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(t)));n.selectedDates=n.config.allowInvalidPreload?a:a.filter(function(t){return t instanceof Date&&tt(t,!1)}),"range"===n.config.mode&&n.selectedDates.sort(function(t,e){return t.getTime()-e.getTime()})}function ft(t){return t.slice().map(function(t){return"string"==typeof t||"number"==typeof t||t instanceof Date?n.parseDate(t,void 0,!0):t&&"object"==typeof t&&t.from&&t.to?{from:n.parseDate(t.from,void 0),to:n.parseDate(t.to,void 0)}:t}).filter(function(t){return t})}function mt(){n._positionElement=n.config.positionElement||n._input}function vt(t,e){if(void 0!==n.config){var a=n.config[t];if(void 0!==a&&a.length>0)for(var r=0;a[r]&&r1||"static"===n.config.monthSelectorType?n.monthElements[e].textContent=b(a.getMonth(),n.config.shorthandCurrentMonth,n.l10n)+" ":n.monthsDropdownContainer.value=a.getMonth().toString(),t.value=a.getFullYear().toString()}),n._hidePrevMonthArrow=void 0!==n.config.minDate&&(n.currentYear===n.config.minDate.getFullYear()?n.currentMonth<=n.config.minDate.getMonth():n.currentYearn.config.maxDate.getMonth():n.currentYear>n.config.maxDate.getFullYear()))}function Tt(t){var e=t||(n.config.altInput?n.config.altFormat:n.config.dateFormat);return n.selectedDates.map(function(t){return n.formatDate(t,e)}).filter(function(t,e,a){return"range"!==n.config.mode||n.config.enableTime||a.indexOf(t)===e}).join("range"!==n.config.mode?n.config.conjunction:n.l10n.rangeSeparator)}function kt(t){void 0===t&&(t=!0),void 0!==n.mobileInput&&n.mobileFormatStr&&(n.mobileInput.value=void 0!==n.latestSelectedDateObj?n.formatDate(n.latestSelectedDateObj,n.mobileFormatStr):""),n.input.value=Tt(n.config.dateFormat),void 0!==n.altInput&&(n.altInput.value=Tt(n.config.altFormat)),!1!==t&&vt("onValueUpdate")}function Et(t){var e=v(t),a=n.prevMonthNav.contains(e),r=n.nextMonthNav.contains(e);a||r?$(a?-1:1):n.yearElements.indexOf(e)>=0?e.select():e.classList.contains("arrowUp")?n.changeYear(n.currentYear+1):e.classList.contains("arrowDown")&&n.changeYear(n.currentYear-1)}return function(){n.element=n.input=t,n.isOpen=!1,function(){var a=["wrap","weekNumbers","allowInput","allowInvalidPreload","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],s=A(A({},JSON.parse(JSON.stringify(t.dataset||{}))),e),c={};n.config.parseDate=s.parseDate,n.config.formatDate=s.formatDate,Object.defineProperty(n.config,"enable",{get:function(){return n.config._enable},set:function(t){n.config._enable=ft(t)}}),Object.defineProperty(n.config,"disable",{get:function(){return n.config._disable},set:function(t){n.config._disable=ft(t)}});var l="time"===s.mode;if(!s.dateFormat&&(s.enableTime||l)){var u=B.defaultConfig.dateFormat||i.dateFormat;c.dateFormat=s.noCalendar||l?"H:i"+(s.enableSeconds?":S":""):u+" H:i"+(s.enableSeconds?":S":"")}if(s.altInput&&(s.enableTime||l)&&!s.altFormat){var h=B.defaultConfig.altFormat||i.altFormat;c.altFormat=s.noCalendar||l?"h:i"+(s.enableSeconds?":S K":" K"):h+" h:i"+(s.enableSeconds?":S":"")+" K"}Object.defineProperty(n.config,"minDate",{get:function(){return n.config._minDate},set:ot("min")}),Object.defineProperty(n.config,"maxDate",{get:function(){return n.config._maxDate},set:ot("max")});var g=function(t){return function(e){n.config["min"===t?"_minTime":"_maxTime"]=n.parseDate(e,"H:i:S")}};Object.defineProperty(n.config,"minTime",{get:function(){return n.config._minTime},set:g("min")}),Object.defineProperty(n.config,"maxTime",{get:function(){return n.config._maxTime},set:g("max")}),"time"===s.mode&&(n.config.noCalendar=!0,n.config.enableTime=!0),Object.assign(n.config,c,s);for(var p=0;p-1?n.config[m]=d(f[m]).map(o).concat(n.config[m]):void 0===s[m]&&(n.config[m]=f[m])}s.altInputClass||(n.config.altInputClass=st().className+" "+n.config.altInputClass),vt("onParseConfig")}(),ct(),n.input=st(),n.input?(n.input._type=n.input.type,n.input.type="text",n.input.classList.add("flatpickr-input"),n._input=n.input,n.config.altInput&&(n.altInput=g(n.input.nodeName,n.config.altInputClass),n._input=n.altInput,n.altInput.placeholder=n.input.placeholder,n.altInput.disabled=n.input.disabled,n.altInput.required=n.input.required,n.altInput.tabIndex=n.input.tabIndex,n.altInput.type="text",n.input.setAttribute("type","hidden"),!n.config.static&&n.input.parentNode&&n.input.parentNode.insertBefore(n.altInput,n.input.nextSibling)),n.config.allowInput||n._input.setAttribute("readonly","readonly"),mt()):n.config.errorHandler(new Error("Invalid input element specified")),function(){n.selectedDates=[],n.now=n.parseDate(n.config.now)||new Date;var t=n.config.defaultDate||("INPUT"!==n.input.nodeName&&"TEXTAREA"!==n.input.nodeName||!n.input.placeholder||n.input.value!==n.input.placeholder?n.input.value:null);t&&pt(t,n.config.dateFormat),n._initialDate=n.selectedDates.length>0?n.selectedDates[0]:n.config.minDate&&n.config.minDate.getTime()>n.now.getTime()?n.config.minDate:n.config.maxDate&&n.config.maxDate.getTime()0&&(n.latestSelectedDateObj=n.selectedDates[0]),void 0!==n.config.minTime&&(n.config.minTime=n.parseDate(n.config.minTime,"H:i")),void 0!==n.config.maxTime&&(n.config.maxTime=n.parseDate(n.config.maxTime,"H:i")),n.minDateHasTime=!!n.config.minDate&&(n.config.minDate.getHours()>0||n.config.minDate.getMinutes()>0||n.config.minDate.getSeconds()>0),n.maxDateHasTime=!!n.config.maxDate&&(n.config.maxDate.getHours()>0||n.config.maxDate.getMinutes()>0||n.config.maxDate.getSeconds()>0)}(),n.utils={getDaysInMonth:function(t,e){return void 0===t&&(t=n.currentMonth),void 0===e&&(e=n.currentYear),1===t&&(e%4==0&&e%100!=0||e%400==0)?29:n.l10n.daysInMonth[t]}},n.isMobile||function(){var t=window.document.createDocumentFragment();if(n.calendarContainer=g("div","flatpickr-calendar"),n.calendarContainer.tabIndex=-1,!n.config.noCalendar){if(t.appendChild((n.monthNav=g("div","flatpickr-months"),n.yearElements=[],n.monthElements=[],n.prevMonthNav=g("span","flatpickr-prev-month"),n.prevMonthNav.innerHTML=n.config.prevArrow,n.nextMonthNav=g("span","flatpickr-next-month"),n.nextMonthNav.innerHTML=n.config.nextArrow,Z(),Object.defineProperty(n,"_hidePrevMonthArrow",{get:function(){return n.__hidePrevMonthArrow},set:function(t){n.__hidePrevMonthArrow!==t&&(h(n.prevMonthNav,"flatpickr-disabled",t),n.__hidePrevMonthArrow=t)}}),Object.defineProperty(n,"_hideNextMonthArrow",{get:function(){return n.__hideNextMonthArrow},set:function(t){n.__hideNextMonthArrow!==t&&(h(n.nextMonthNav,"flatpickr-disabled",t),n.__hideNextMonthArrow=t)}}),n.currentYearElement=n.yearElements[0],wt(),n.monthNav)),n.innerContainer=g("div","flatpickr-innerContainer"),n.config.weekNumbers){var e=function(){n.calendarContainer.classList.add("hasWeeks");var t=g("div","flatpickr-weekwrapper");t.appendChild(g("span","flatpickr-weekday",n.l10n.weekAbbreviation));var e=g("div","flatpickr-weeks");return t.appendChild(e),{weekWrapper:t,weekNumbers:e}}(),a=e.weekWrapper,r=e.weekNumbers;n.innerContainer.appendChild(a),n.weekNumbers=r,n.weekWrapper=a}n.rContainer=g("div","flatpickr-rContainer"),n.rContainer.appendChild(Y()),n.daysContainer||(n.daysContainer=g("div","flatpickr-days"),n.daysContainer.tabIndex=-1),W(),n.rContainer.appendChild(n.daysContainer),n.innerContainer.appendChild(n.rContainer),t.appendChild(n.innerContainer)}n.config.enableTime&&t.appendChild(function(){n.calendarContainer.classList.add("hasTime"),n.config.noCalendar&&n.calendarContainer.classList.add("noCalendar");var t=I(n.config);n.timeContainer=g("div","flatpickr-time"),n.timeContainer.tabIndex=-1;var e=g("span","flatpickr-time-separator",":"),a=m("flatpickr-hour",{"aria-label":n.l10n.hourAriaLabel});n.hourElement=a.getElementsByTagName("input")[0];var r=m("flatpickr-minute",{"aria-label":n.l10n.minuteAriaLabel});if(n.minuteElement=r.getElementsByTagName("input")[0],n.hourElement.tabIndex=n.minuteElement.tabIndex=-1,n.hourElement.value=c(n.latestSelectedDateObj?n.latestSelectedDateObj.getHours():n.config.time_24hr?t.hours:function(t){switch(t%24){case 0:case 12:return 12;default:return t%12}}(t.hours)),n.minuteElement.value=c(n.latestSelectedDateObj?n.latestSelectedDateObj.getMinutes():t.minutes),n.hourElement.setAttribute("step",n.config.hourIncrement.toString()),n.minuteElement.setAttribute("step",n.config.minuteIncrement.toString()),n.hourElement.setAttribute("min",n.config.time_24hr?"0":"1"),n.hourElement.setAttribute("max",n.config.time_24hr?"23":"12"),n.hourElement.setAttribute("maxlength","2"),n.minuteElement.setAttribute("min","0"),n.minuteElement.setAttribute("max","59"),n.minuteElement.setAttribute("maxlength","2"),n.timeContainer.appendChild(a),n.timeContainer.appendChild(e),n.timeContainer.appendChild(r),n.config.time_24hr&&n.timeContainer.classList.add("time24hr"),n.config.enableSeconds){n.timeContainer.classList.add("hasSeconds");var i=m("flatpickr-second");n.secondElement=i.getElementsByTagName("input")[0],n.secondElement.value=c(n.latestSelectedDateObj?n.latestSelectedDateObj.getSeconds():t.seconds),n.secondElement.setAttribute("step",n.minuteElement.getAttribute("step")),n.secondElement.setAttribute("min","0"),n.secondElement.setAttribute("max","59"),n.secondElement.setAttribute("maxlength","2"),n.timeContainer.appendChild(g("span","flatpickr-time-separator",":")),n.timeContainer.appendChild(i)}return n.config.time_24hr||(n.amPM=g("span","flatpickr-am-pm",n.l10n.amPM[l((n.latestSelectedDateObj?n.hourElement.value:n.config.defaultHour)>11)]),n.amPM.title=n.l10n.toggleTitle,n.amPM.tabIndex=-1,n.timeContainer.appendChild(n.amPM)),n.timeContainer}()),h(n.calendarContainer,"rangeMode","range"===n.config.mode),h(n.calendarContainer,"animate",!0===n.config.animate),h(n.calendarContainer,"multiMonth",n.config.showMonths>1),n.calendarContainer.appendChild(t);var i=void 0!==n.config.appendTo&&void 0!==n.config.appendTo.nodeType;if((n.config.inline||n.config.static)&&(n.calendarContainer.classList.add(n.config.inline?"inline":"static"),n.config.inline&&(!i&&n.element.parentNode?n.element.parentNode.insertBefore(n.calendarContainer,n._input.nextSibling):void 0!==n.config.appendTo&&n.config.appendTo.appendChild(n.calendarContainer)),n.config.static)){var o=g("div","flatpickr-wrapper");n.element.parentNode&&n.element.parentNode.insertBefore(o,n.element),o.appendChild(n.element),n.altInput&&o.appendChild(n.altInput),o.appendChild(n.calendarContainer)}n.config.static||n.config.inline||(void 0!==n.config.appendTo?n.config.appendTo:window.document.body).appendChild(n.calendarContainer)}(),function(){if(n.config.wrap&&["open","close","toggle","clear"].forEach(function(t){Array.prototype.forEach.call(n.element.querySelectorAll("[data-"+t+"]"),function(e){return P(e,"click",n[t])})}),n.isMobile)!function(){var t=n.config.enableTime?n.config.noCalendar?"time":"datetime-local":"date";n.mobileInput=g("input",n.input.className+" flatpickr-mobile"),n.mobileInput.tabIndex=1,n.mobileInput.type=t,n.mobileInput.disabled=n.input.disabled,n.mobileInput.required=n.input.required,n.mobileInput.placeholder=n.input.placeholder,n.mobileFormatStr="datetime-local"===t?"Y-m-d\\TH:i:S":"date"===t?"Y-m-d":"H:i:S",n.selectedDates.length>0&&(n.mobileInput.defaultValue=n.mobileInput.value=n.formatDate(n.selectedDates[0],n.mobileFormatStr)),n.config.minDate&&(n.mobileInput.min=n.formatDate(n.config.minDate,"Y-m-d")),n.config.maxDate&&(n.mobileInput.max=n.formatDate(n.config.maxDate,"Y-m-d")),n.input.getAttribute("step")&&(n.mobileInput.step=String(n.input.getAttribute("step"))),n.input.type="hidden",void 0!==n.altInput&&(n.altInput.type="hidden");try{n.input.parentNode&&n.input.parentNode.insertBefore(n.mobileInput,n.input.nextSibling)}catch(t){}P(n.mobileInput,"change",function(t){n.setDate(v(t).value,!1,n.mobileFormatStr),vt("onChange"),vt("onClose")})}();else{var t=u(it,50);if(n._debouncedChange=u(O,300),n.daysContainer&&!/iPhone|iPad|iPod/i.test(navigator.userAgent)&&P(n.daysContainer,"mouseover",function(t){"range"===n.config.mode&&rt(v(t))}),P(n._input,"keydown",at),void 0!==n.calendarContainer&&P(n.calendarContainer,"keydown",at),n.config.inline||n.config.static||P(window,"resize",t),void 0!==window.ontouchstart?P(window.document,"touchstart",X):P(window.document,"mousedown",X),P(window.document,"focus",X,{capture:!0}),!0===n.config.clickOpens&&(P(n._input,"focus",n.open),P(n._input,"click",n.open)),void 0!==n.daysContainer&&(P(n.monthNav,"click",Et),P(n.monthNav,["keyup","increment"],L),P(n.daysContainer,"click",ht)),void 0!==n.timeContainer&&void 0!==n.minuteElement&&void 0!==n.hourElement){P(n.timeContainer,["increment"],w),P(n.timeContainer,"blur",w,{capture:!0}),P(n.timeContainer,"click",R),P([n.hourElement,n.minuteElement],["focus","click"],function(t){return v(t).select()}),void 0!==n.secondElement&&P(n.secondElement,"focus",function(){return n.secondElement&&n.secondElement.select()}),void 0!==n.amPM&&P(n.amPM,"click",function(t){w(t)})}n.config.allowInput&&P(n._input,"blur",nt)}}(),(n.selectedDates.length||n.config.noCalendar)&&(n.config.enableTime&&M(n.config.noCalendar?n.latestSelectedDateObj:void 0),kt(!1)),y();var a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);!n.isMobile&&a&<(),vt("onReady")}(),n}function D(t,e){for(var n=Array.prototype.slice.call(t).filter(function(t){return t instanceof HTMLElement}),a=[],r=0;rSt,Tl:()=>It,zw:()=>At});var a=n.cw(t=>{var e=/["'&<>]/;t.exports=function(t){var n,a=""+t,r=e.exec(a);if(!r)return a;var i="",o=0,s=0;for(o=r.index;ot.length)&&(e=t.length);for(var n=0,a=Array(e);n2?n-2:0),r=2;r1?e-1:0),a=1;a1?n-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:_;if(l&&l(t,null),!S(e))return t;let a=e.length;for(;a--;){let r=e[a];if("string"==typeof r){const t=n(r);t!==r&&(u(e)||(e[a]=t),r=t)}t[r]=!0}return t}function G(t){for(let e=0;e/g),ct=p(/\${[\w\W]*/g),lt=p(/^data-[\-\w.\u00B7-\uFFFF]+$/),ut=p(/^aria-[\-\w]+$/),dt=p(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ht=p(/^(?:\w+script|data):/i),gt=p(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),pt=p(/^html$/i),ft=p(/^[a-z][.\w]*(-[.\w]+)+$/i),mt=p(/<[/\w!]/g),vt=p(/<[/\w]/g),yt=p(/<\/no(script|embed|frames)/i),bt=p(/\/>/i),wt=g(U({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),Tt=function(){return"undefined"==typeof window?null:window},kt=function(t,e,n,a){return j(t,e)&&S(t[e])?U(a.base?Z(a.base):{},t[e],a.transform):n},Et=function(t,e,n){const a=j(t,e)?t[e]:void 0;return a&&"object"==typeof a?Z(a):n()};var xt=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Tt();const n=e=>t(e);if(n.version="3.4.17",n.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return n.isSupported=!1,n;let a=e.document;const r=a,i=r.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,s=e.Node,l=e.Element,u=e.NodeFilter;void 0===e.NamedNodeMap&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const m=e.DOMParser,v=e.trustedTypes,y=l.prototype,W=Y(y,"cloneNode"),G=Y(y,"remove"),xt=Y(y,"removeAttributeNode"),St=Y(y,"nextSibling"),Ct=Y(y,"childNodes"),It=Y(y,"parentNode"),At=Y(y,"shadowRoot"),_t=Y(y,"attributes"),Mt=s&&s.prototype?Y(s.prototype,"nodeType"):null,Dt=s&&s.prototype?Y(s.prototype,"nodeName"):null,Bt=s&&s.prototype?Y(s.prototype,"ownerDocument"):null,Lt=function(t){return Mt?Mt(t):t.nodeType},Pt=function(t){return Dt?Dt(t):t.nodeName},Ot=function(t){for(;null!==t;){const e=h(t,"namespaceURI");if(e)return e.get?q(e.get):null;t=d(t)}return null}(y),Ft=function(t){return Ot?Ot(t):t.namespaceURI};if("function"==typeof o){const t=a.createElement("template");t.content&&t.content.ownerDocument&&(a=t.content.ownerDocument)}let Rt,Nt,jt="",Ht=!1,zt=0;const Vt=function(){if(zt>0)throw V('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},qt=function(t){Vt(),zt++;try{return Rt.createHTML(t)}finally{zt--}},Wt=a,Ut=Wt.implementation,Gt=Wt.createNodeIterator,Zt=Wt.createDocumentFragment,Yt=Wt.getElementsByTagName,Qt=r.importNode;let $t={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof c&&"function"==typeof It&&Ut&&void 0!==Ut.createHTMLDocument;const Kt=ot,Xt=st,Jt=ct,te=lt,ee=ut,ne=ht,ae=gt,re=ft;let ie=dt,oe=null;const se=U({},[...Q,...$,...K,...J,...et]);let ce=null;const le=U({},[...nt,...at,...rt,...it]);let ue=Object.seal(f(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),de=null,he=null;const ge=Object.seal(f(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let pe=!0,fe=!0,me=!1,ve=!0,ye=!1,be=!0,we=!1,Te=!1,ke=null,Ee=null,xe=!1,Se=!1,Ce=!1,Ie=!1,Ae=!0,_e=!1;const Me="user-content-";let De=!0,Be=!1,Le=null,Pe={},Oe=null;const Fe=U({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Re=null;const Ne=U({},["audio","video","img","source","image","track"]);let je=null;const He=U({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ze="http://www.w3.org/1998/Math/MathML",Ve="http://www.w3.org/2000/svg",qe="http://www.w3.org/1999/xhtml";let We=qe,Ue=!1,Ge=null;const Ze=U({},[ze,Ve,qe],M),Ye=g(["mi","mo","mn","ms","mtext"]);let Qe=U({},Ye);const $e=g(["annotation-xml"]);let Ke=U({},$e);const Xe=U({},["title","style","font","a","script"]);let Je=null;const tn=["application/xhtml+xml","text/html"];let en=null,nn=null;const an=a.createElement("form"),rn=function(t){return t instanceof RegExp||t instanceof Function},on=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(nn&&nn===t)return;t&&"object"==typeof t||(t={}),t=Z(t),Je=-1===tn.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,en="application/xhtml+xml"===Je?M:_,oe=kt(t,"ALLOWED_TAGS",se,{transform:en}),ce=kt(t,"ALLOWED_ATTR",le,{transform:en}),Ge=kt(t,"ALLOWED_NAMESPACES",Ze,{transform:M}),je=kt(t,"ADD_URI_SAFE_ATTR",He,{transform:en,base:He}),Re=kt(t,"ADD_DATA_URI_TAGS",Ne,{transform:en,base:Ne}),Oe=kt(t,"FORBID_CONTENTS",Fe,{transform:en}),de=kt(t,"FORBID_TAGS",Z({}),{transform:en}),he=kt(t,"FORBID_ATTR",Z({}),{transform:en}),Pe=!!j(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?Z(t.USE_PROFILES):t.USE_PROFILES),pe=!1!==t.ALLOW_ARIA_ATTR,fe=!1!==t.ALLOW_DATA_ATTR,me=t.ALLOW_UNKNOWN_PROTOCOLS||!1,ve=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,ye=t.SAFE_FOR_TEMPLATES||!1,be=!1!==t.SAFE_FOR_XML,we=t.WHOLE_DOCUMENT||!1,Se=t.RETURN_DOM||!1,Ce=t.RETURN_DOM_FRAGMENT||!1,Ie=t.RETURN_TRUSTED_TYPE||!1,xe=t.FORCE_BODY||!1,Ae=!1!==t.SANITIZE_DOM,_e=t.SANITIZE_NAMED_PROPS||!1,De=!1!==t.KEEP_CONTENT,Be=t.IN_PLACE||!1,ie=function(t){try{return z(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:dt,We="string"==typeof t.NAMESPACE?t.NAMESPACE:qe,Qe=Et(t,"MATHML_TEXT_INTEGRATION_POINTS",()=>U({},Ye)),Ke=Et(t,"HTML_INTEGRATION_POINTS",()=>U({},$e));const e=Et(t,"CUSTOM_ELEMENT_HANDLING",()=>f(null));if(ue=f(null),j(e,"tagNameCheck")&&rn(e.tagNameCheck)&&(ue.tagNameCheck=e.tagNameCheck),j(e,"attributeNameCheck")&&rn(e.attributeNameCheck)&&(ue.attributeNameCheck=e.attributeNameCheck),j(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(ue.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),p(ue),ye&&(fe=!1),Ce&&(Se=!0),Pe&&(oe=U({},et),ce=f(null),!0===Pe.html&&(U(oe,Q),U(ce,nt)),!0===Pe.svg&&(U(oe,$),U(ce,at),U(ce,it)),!0===Pe.svgFilters&&(U(oe,K),U(ce,at),U(ce,it)),!0===Pe.mathMl&&(U(oe,J),U(ce,rt),U(ce,it))),ge.tagCheck=null,ge.attributeCheck=null,j(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?ge.tagCheck=t.ADD_TAGS:S(t.ADD_TAGS)&&(oe===se&&(oe=Z(oe)),U(oe,t.ADD_TAGS,en))),j(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?ge.attributeCheck=t.ADD_ATTR:S(t.ADD_ATTR)&&(ce===le&&(ce=Z(ce)),U(ce,t.ADD_ATTR,en))),j(t,"ADD_FORBID_CONTENTS")&&S(t.ADD_FORBID_CONTENTS)&&(Oe===Fe&&(Oe=Z(Oe)),U(Oe,t.ADD_FORBID_CONTENTS,en)),De&&(oe["#text"]=!0),we&&U(oe,["html","head","body"]),oe.table&&(U(oe,["tbody"]),delete de.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw V('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw V('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const e=Rt;Rt=t.TRUSTED_TYPES_POLICY;try{jt=qt("")}catch(t){throw Rt=e,t}}else null===t.TRUSTED_TYPES_POLICY?(Rt=void 0,jt=""):(void 0===Rt&&(Ht||(Nt=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let n=null;const a="data-tt-policy-suffix";e&&e.hasAttribute(a)&&(n=e.getAttribute(a));const r="dompurify"+(n?"#"+n:"");try{return t.createPolicy(r,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(v,i),Ht=!0),Rt=Nt),Rt&&"string"==typeof jt&&(jt=qt("")));g&&g(t),nn=t},sn=U({},[...$,...K,...X]),cn=U({},[...J,...tt]),ln=function(t){k(n.removed,{element:t});try{It(t).removeChild(t)}catch(e){if(G(t),!It(t))throw V("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},un=function(t,e,n){try{xt(t,e)}catch(e){try{t.removeAttribute(n)}catch(t){}}},dn=function(t){fn(t);const e=Ct(t);e&&b(E(e),t=>{try{G(t)}catch(t){}});const n=1===Lt(t)?_t(t):null;if(n)for(let e=n.length-1;e>=0;--e){const a=n[e],r=a&&a.name;"string"==typeof r&&un(t,a,r)}},hn=function(t,e,a){if(!a)try{a=e.getAttributeNode(t)}catch(t){a=null}k(n.removed,{attribute:a||null,from:e});try{a?xt(e,a):e.removeAttribute(t)}catch(n){try{e.removeAttribute(t)}catch(t){}}if("is"===t)if(Se||Ce)try{ln(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},gn=function(t){const e=_t(t);if(e)for(let n=e.length-1;n>=0;--n){const a=e[n],r=a&&a.name;"string"!=typeof r||ce[en(r)]||un(t,a,r)}},pn=function(t,e){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const a=[t];for(;a.length>0;){const t=a.pop();if(!1===e(t))continue;if(n&&1===Lt(t)){const e=At(t);Cn(e)&&a.push(e)}const r=Ct(t);if(r)for(let t=r.length-1;t>=0;--t)a.push(r[t])}},fn=function(t){pn(t,t=>{1===Lt(t)&&gn(t)})},mn=function(t){const e=[];return pn(t,t=>{e.push(t)},!0),e},vn=function(t,e){let a=!1;return b(n.removed,e=>{e.element&&(a=a||e.element===t,fn(e.element))}),function(t,e){const n=C();b(mn(t),t=>{1===Lt(t)&&I(n,t)}),b(e,t=>{1!==Lt(t)||A(n,t)||gn(t)})}(t,e),a},yn=function(t,e,n,a){const r=Tn(t);let i;for(;i=r.nextNode();)A(a,i)&&!A(Le,i)&&(e&&An($t.uponSanitizeShadowNode,i,null),Bn(i,n),jn(i,n),Cn(i.content)&&Hn(i.content))},bn=function(t,e){return!!be&&("patchsrc"===t||"for"===t&&"label"!==e&&"output"!==e)},wn=function(t){let e=null,n=null;if(xe)t=""+t;else{const e=D(t,/^[\r\n\t ]+/);n=e&&e[0]}"application/xhtml+xml"===Je&&We===qe&&(t=''+t+"");const r=Rt?qt(t):t;if(We===qe)try{e=(new m).parseFromString(r,Je)}catch(t){}if(!e||!e.documentElement){e=Ut.createDocument(We,"template",null);try{e.documentElement.innerHTML=Ue?jt:r}catch(t){}}const i=e.body||e.documentElement;return t&&n&&i.insertBefore(a.createTextNode(n),i.childNodes[0]||null),We===qe?Yt.call(e,we?"html":"body")[0]:we?e.documentElement:i},Tn=function(t){const e=Bt?Bt(t):t.ownerDocument;return Gt.call(e||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},kn=function(t){return t=B(t,Kt," "),t=B(t,Xt," "),B(t,Jt," ")},En=function(t){var e;xn(t);const n=null===(e=t.querySelectorAll)||void 0===e?void 0:e.call(t,"template");n&&b(n,t=>{Cn(t.content)&&En(t.content)})},xn=function(t){t.normalize();const e=Bt?Bt(t):t.ownerDocument,n=Gt.call(e||t,t,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let a=n.nextNode();for(;a;)a.data=kn(a.data),a=n.nextNode()},Sn=function(t){const e=Dt?Dt(t):null;return"string"==typeof e&&"form"===en(e)&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||t.attributes!==_t(t)||"function"!=typeof t.removeAttribute||"function"!=typeof t.removeAttributeNode||"function"!=typeof t.getAttributeNode||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes||t.nodeType!==Mt(t)||t.childNodes!==Ct(t))},Cn=function(t){if(!Mt||"object"!=typeof t||null===t)return!1;try{return 11===Mt(t)}catch(t){return!1}},In=function(t){if(!Mt||"object"!=typeof t||null===t)return!1;try{return"number"==typeof Mt(t)}catch(t){return!1}};function An(t,e,a){0!==t.length&&b(t,t=>{t.call(n,e,a,nn)})}const _n=function(t,e){if(t instanceof RegExp)return z(t,e);if(t instanceof Function){for(var n=arguments.length,a=new Array(n>2?n-2:0),r=2;r=0;--r){const i=t===n?W(a[r],!0):a[r];e.insertBefore(i,St(t))}}return ln(t),!0}(t,a,e);return!(!1!==n||(An($t.afterSanitizeElements,t,null),!Dn(t,e)))||n}if(1===Lt(t)&&!function(t){const e=Ft(t),n=_(Pt(t)),a=It(t);let r,i;return a&&1===Lt(a)?(r={namespaceURI:Ft(a)},i=_(Pt(a))):(r={namespaceURI:We},i="template"),!!Ge[e]&&(e===Ve?function(t,e,n){return e.namespaceURI===qe?"svg"===t:e.namespaceURI===ze?"svg"===t&&("annotation-xml"===n||Qe[n]):Boolean(sn[t])}(n,r,i):e===ze?function(t,e,n){return e.namespaceURI===qe?"math"===t:e.namespaceURI===Ve?"math"===t&&Ke[n]:Boolean(cn[t])}(n,r,i):e===qe?function(t,e,n){return!(e.namespaceURI===Ve&&!Ke[n])&&!(e.namespaceURI===ze&&!Qe[n])&&!cn[t]&&(Xe[t]||!sn[t])}(n,r,i):!("application/xhtml+xml"!==Je||!Ge[e]))}(t))return ln(t),!0;if(("noscript"===a||"noembed"===a||"noframes"===a)&&z(yt,t.innerHTML))return ln(t),!0;if(ye&&3===t.nodeType){const e=kn(t.textContent);t.textContent!==e&&(k(n.removed,{element:t.cloneNode()}),t.textContent=e)}return An($t.afterSanitizeElements,t,null),Dn(t,e)},Ln=function(t,e,n){if(he[e])return!1;if(bn(e,t))return!1;if(Ae&&("id"===e||"name"===e)&&(n in a||n in an))return!1;const r=ce[e]||ge.attributeCheck instanceof Function&&ge.attributeCheck(e,t);return!(!fe||!z(te,e))||!(!pe||!z(ee,e))||(r?!(!je[e]&&!z(ie,B(n,ae,""))&&("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==L(n,"data:")||!Re[t])&&(!me||z(ne,B(n,ae,"")))&&n):On(t)&&_n(ue.tagNameCheck,t)&&_n(ue.attributeNameCheck,e,t)||"is"===e&&ue.allowCustomizedBuiltInElements&&_n(ue.tagNameCheck,n))},Pn=U({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),On=function(t){return!Pn[_(t)]&&z(re,t)},Fn=function(t,e,n,a){if(Rt&&"object"==typeof v&&"function"==typeof v.getAttributeType&&!n)switch(v.getAttributeType(t,e)){case"TrustedHTML":return qt(a);case"TrustedScriptURL":return function(t){Vt(),zt++;try{return Rt.createScriptURL(t)}finally{zt--}}(a)}return a},Rn=function(t,e,n,a){try{return n?t.setAttributeNS(n,e,a):t.setAttribute(e,a),!Sn(t)||(ln(t),!1)}catch(n){return hn(e,t),!1}},Nn=function(t,e){return!(!be||!z(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,e))||"attributename"===_(t)&&null!==D(e,"href")},jn=function(t,e){if(An($t.beforeSanitizeAttributes,t,null),Dn(t,e))return;const a=t.attributes;if(!a||Sn(t))return;ce=Mn($t.uponSanitizeAttribute,ce,le,Ee);const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ce,forceKeepAttr:void 0};let i=a.length;const o=en(t.nodeName);for(;i--;){const e=a[i],s=e.name,c=e.namespaceURI,l=e.value,u=en(s),d=l;let h="value"===s?d:P(d),g=!1;r.attrName=u,r.attrValue=h,r.keepAttr=!0,r.forceKeepAttr=void 0,An($t.uponSanitizeAttribute,t,r),h=r.attrValue,!_e||"id"!==u&&"name"!==u||0===L(h,Me)||(hn(s,t,e),h=Me+h,g=!0),Nn(s,h)?hn(s,t,e):r.forceKeepAttr||(!r.keepAttr||!ve&&z(bt,h)?hn(s,t,e):(ye&&(h=kn(h)),Ln(o,u,h)?(h=Fn(o,u,c,h),h!==d&&Rn(t,s,c,h)&&g&&T(n.removed)):hn(s,t,e)))}An($t.afterSanitizeAttributes,t,null),Dn(t,e)},Hn=function(t){let e=null;const n=Tn(t);for(An($t.beforeSanitizeShadowDOM,t,null);e=n.nextNode();)if(An($t.uponSanitizeShadowNode,e,null),Bn(e,t),jn(e,t),Cn(e.content)&&Hn(e.content),1===Lt(e)){const t=At(e);Cn(t)&&(zn(t),Hn(t))}ye&&xn(t),An($t.afterSanitizeShadowDOM,t,null)},zn=function(t){const e=[{node:t,shadow:null}];for(;e.length>0;){const t=e.pop();if(t.shadow){Hn(t.shadow);continue}const n=t.node,a=1===Lt(n),r=Ct(n);if(r)for(let t=r.length-1;t>=0;--t)e.push({node:r[t],shadow:null});if(a){const t=Dt?Dt(n):null;if("string"==typeof t&&"template"===en(t)){const t=n.content;Cn(t)&&e.push({node:t,shadow:null})}}if(a){const t=At(n);Cn(t)&&e.push({node:null,shadow:t},{node:t,shadow:null})}}};return n.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null,i=null,o=null,s=null;if(Ue=!t,Ue&&(t="\x3c!--\x3e"),"string"!=typeof t&&!In(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return O(t);case"boolean":return F(t);case"bigint":return R?R(t):"0";case"symbol":return N?N(t):"Symbol()";case"undefined":default:return H(t);case"function":case"object":{if(null===t)return H(t);const e=t,n=Y(e,"toString");if("function"==typeof n){const t=n(e);return"string"==typeof t?t:H(t)}return H(t)}}}(t)))throw V("dirty is not a string, aborting");if(!n.isSupported)return t;Te?(oe=ke,ce=Ee):on(e),($t.uponSanitizeElement.length>0||$t.uponSanitizeAttribute.length>0)&&(oe=Z(oe)),$t.uponSanitizeAttribute.length>0&&(ce=Z(ce)),n.removed=[];const c=Be&&"string"!=typeof t&&In(t);let l=[];const u=Le;if(c){be&&pn(t,t=>{const e=Lt(t);if(7===e||8===e&&z(vt,t.data)){try{G(t)}catch(t){}return!1}if(1===e){const e=t,n=en(Pt(t));try{e.hasAttribute&&e.hasAttribute("patchsrc")&&e.removeAttribute("patchsrc"),e.hasAttribute&&e.hasAttribute("for")&&bn("for",n)&&e.removeAttribute("for")}catch(t){}}return!0});const e=Pt(t);if("string"==typeof e){const n=en(e);if(!oe[n]||de[n])throw dn(t),V("root node is forbidden and cannot be sanitized in-place")}if(Sn(t))throw dn(t),V("root node is clobbered and cannot be sanitized in-place");l=mn(t),Le=C()}else if(In(t))a=wn("\x3c!----\x3e"),i=a.ownerDocument.importNode(t,!0),1===i.nodeType&&"BODY"===i.nodeName||"HTML"===i.nodeName?a=i:a.appendChild(i),zn(a);else{if(!Se&&!ye&&!we&&-1===t.indexOf("<"))return Rt&&Ie?qt(t):t;if(a=wn(t),!a)return Se?null:Ie?jt:""}a&&xe&&ln(a.firstChild);const d=c?t:a;try{c&&zn(t);const e=Tn(d);for(;o=e.nextNode();)Bn(o,d),jn(o,d),Cn(o.content)&&Hn(o.content);c&&function(t,e){const n=Le;let a=null;const r=()=>(a||(a=C(),b(e,t=>{I(a,t)})),a);for(let e=0;;e++){const a=mn(t),i=[t];let o=!1;if(b(a,t=>{11===Lt(t)?k(i,t):o||A(n,t)||(o=A(r(),t))}),!o)return;if(e>=8)throw V("the tree kept changing during in-place sanitization; refusing to return it");b(i,(e,n)=>{yn(e,n>0,t,r())})}}(t,l)}catch(e){throw c&&(dn(t),vn(t,l)),e}finally{Le=u}if(c){if(vn(t,l))throw V("a node selected for removal could not be safely returned; refusing to sanitize in place");return ye&&En(t),t}if(Se){if(ye&&En(a),Ce)for(s=Zt.call(a.ownerDocument);a.firstChild;)s.appendChild(a.firstChild);else s=a;return(ce.shadowroot||ce.shadowrootmode)&&(s=Qt.call(r,s,!0)),s}let h=we?a.outerHTML:a.innerHTML;return we&&oe["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&z(pt,a.ownerDocument.doctype.name)&&(h="\n"+h),ye&&(h=kn(h)),Rt&&Ie?qt(h):h},n.setConfig=function(){on(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Te=!0,ke=oe,Ee=ce},n.clearConfig=function(){nn=null,Te=!1,ke=null,Ee=null,Rt=Nt,jt=""},n.isValidAttribute=function(t,e,n){nn||on({});const a=en(t),r=en(e);return("string"!=typeof n||!(Nn(e,n)||!ve&&z(bt,n)))&&Ln(a,r,n)},n.addHook=function(t,e){"function"==typeof e&&j($t,t)&&k($t[t],e)},n.removeHook=function(t,e){if(j($t,t)){if(void 0!==e){const n=w($t[t],e);return-1===n?void 0:x($t[t],n,1)[0]}return T($t[t])}},n.removeHooks=function(t){j($t,t)&&($t[t]=[])},n.removeAllHooks=function(){$t={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();function St(){return globalThis._nc_l10n_locale.replaceAll(/_/g,"-")}function Ct(t){return{translations:globalThis._oc_l10n_registry_translations[t]??{},pluralFunction:globalThis._oc_l10n_registry_plural_functions[t]??(t=>t)}}function It(t,e,n,r,i){const o="object"==typeof n?n:void 0,s="number"==typeof r?r:"number"==typeof n?n:void 0,c={escape:!0,sanitize:!0,..."object"==typeof i?i:"object"==typeof r?r:{}},l=t=>t,u=(c.sanitize?xt.sanitize:l)||l,d=c.escape?a():l,h=t=>"string"==typeof t||"number"==typeof t;let g=(i?.bundle??Ct(t)).translations[e]||e;return g=Array.isArray(g)?g[0]:g,u("object"==typeof o||void 0!==s?(p=o,f=s,g.replace(/%n/g,""+f).replace(/{([^{}]*)}/g,(t,e)=>{if(void 0===p||!(e in p))return d(t);const n=p[e];return h(n)?d(`${n}`):"object"==typeof n&&h(n.value)?(!1!==n.escape?a():l)(`${n.value}`):d(t)})):g);var p,f}function At(t,e,n,a,r,i){const o="_"+e+"_::_"+n+"_",s=i?.bundle??Ct(t),c=s.translations[o];if(void 0!==c){const e=c;if(Array.isArray(e))return It(t,e[s.pluralFunction(a)],r,a,i)}return It(t,1===a?e:n,r,a,i)}a(),globalThis._nc_l10n_locale??="undefined"!=typeof document&&document.documentElement.dataset.locale||Intl.DateTimeFormat().resolvedOptions().locale.replaceAll(/-/g,"_"),globalThis._nc_l10n_language??="undefined"!=typeof document&&document.documentElement.lang||(globalThis.navigator?.language??"en"),globalThis._oc_l10n_registry_translations??={},globalThis._oc_l10n_registry_plural_functions??={}},118(t,e,n){n.d(e,{A6:()=>M,Bs:()=>re,E8:()=>we,FN:()=>pe,Hg:()=>ft,Jy:()=>Ce,No:()=>he,PP:()=>gn,ZT:()=>B,dN:()=>qe,hE:()=>Qe,ju:()=>D,kc:()=>mn,m_:()=>dn,n:()=>T,s$:()=>Ze,t1:()=>te});var a=n(311);class r{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,n,a){const r=e.listeners[a],i=e.duration;r.forEach(a=>a({chart:t,initial:e.initial,numSteps:i,currentStep:Math.min(n-e.start,i)}))}_refresh(){this._request||(this._running=!0,this._request=a.r.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((n,a)=>{if(!n.running||!n.items.length)return;const r=n.items;let i,o=r.length-1,s=!1;for(;o>=0;--o)i=r[o],i._active?(i._total>n.duration&&(n.duration=i._total),i.tick(t),s=!0):(r[o]=r[r.length-1],r.pop());s&&(a.draw(),this._notify(a,n,t,"progress")),r.length||(n.running=!1,this._notify(a,n,t,"complete"),n.initial=!1),e+=r.length}),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let n=e.get(t);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,n)),n}listen(t,e,n){this._getAnims(t).listeners[e].push(n)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((t,e)=>Math.max(t,e._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const n=e.items;let a=n.length-1;for(;a>=0;--a)n[a].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var i=new r;const o="transparent",s={boolean:(t,e,n)=>n>.5?e:t,color(t,e,n){const r=(0,a.c)(t||o),i=r.valid&&(0,a.c)(e||o);return i&&i.valid?i.mix(r,n).hexString():e},number:(t,e,n)=>t+(e-t)*n};class c{constructor(t,e,n,r){const i=e[n];r=(0,a.a)([t.to,r,i,t.from]);const o=(0,a.a)([t.from,i,r]);this._active=!0,this._fn=t.fn||s[t.type||typeof o],this._easing=a.e[t.easing]||a.e.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=n,this._from=o,this._to=r,this._promises=void 0}active(){return this._active}update(t,e,n){if(this._active){this._notify(!1);const r=this._target[this._prop],i=n-this._start,o=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=i,this._loop=!!t.loop,this._to=(0,a.a)([t.to,e,r,t.from]),this._from=(0,a.a)([t.from,r,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,n=this._duration,a=this._prop,r=this._from,i=this._loop,o=this._to;let s;if(this._active=r!==o&&(i||e1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[a]=this._fn(r,o,s))}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,n)=>{t.push({res:e,rej:n})})}_notify(t){const e=t?"res":"rej",n=this._promises||[];for(let t=0;t{const i=t[r];if(!(0,a.i)(i))return;const o={};for(const t of e)o[t]=i[t];((0,a.b)(i.properties)&&i.properties||[r]).forEach(t=>{t!==r&&n.has(t)||n.set(t,o)})})}_animateOptions(t,e){const n=e.options,a=function(t,e){if(!e)return;let n=t.options;if(n)return n.$shared&&(t.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n;t.options=e}(t,n);if(!a)return[];const r=this._createAnimations(a,n);return n.$shared&&function(t,e){const n=[],a=Object.keys(e);for(let e=0;e{t.options=n},()=>{}),r}_createAnimations(t,e){const n=this._properties,a=[],r=t.$animations||(t.$animations={}),i=Object.keys(e),o=Date.now();let s;for(s=i.length-1;s>=0;--s){const l=i[s];if("$"===l.charAt(0))continue;if("options"===l){a.push(...this._animateOptions(t,e));continue}const u=e[l];let d=r[l];const h=n.get(l);if(d){if(h&&d.active()){d.update(h,u,o);continue}d.cancel()}h&&h.duration?(r[l]=d=new c(h,t,l,u),a.push(d)):t[l]=u}return a}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const n=this._createAnimations(t,e);return n.length?(i.add(this._chart,n),!0):void 0}}function u(t,e){const n=t&&t.options||{},a=n.reverse,r=void 0===n.min?e:0,i=void 0===n.max?e:0;return{start:a?i:r,end:a?r:i}}function d(t,e){const n=[],a=t._getSortedDatasetMetas(e);let r,i;for(r=0,i=a.length;r0||!n&&e<0)return r.index}return null}function m(t,e){const{chart:n,_cachedMeta:a}=t,r=n._stacks||(n._stacks={}),{iScale:i,vScale:o,index:s}=a,c=i.axis,l=o.axis,u=function(t,e,n){return`${t.id}.${e.id}.${n.stack||n.type}`}(i,o,a),d=e.length;let h;for(let t=0;tn[t].axis===e).shift()}function y(t,e){const n=t.controller.index,a=t.vScale&&t.vScale.axis;if(a){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[a]||void 0===e[a][n])return;delete e[a][n],void 0!==e[a]._visualValues&&void 0!==e[a]._visualValues[n]&&delete e[a]._visualValues[n]}}}const b=t=>"reset"===t||"none"===t,w=(t,e)=>e?t:Object.assign({},t);class T{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=g(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&y(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,n=this.getDataset(),r=(t,e,n,a)=>"x"===t?e:"r"===t?a:n,i=e.xAxisID=(0,a.v)(n.xAxisID,v(t,"x")),o=e.yAxisID=(0,a.v)(n.yAxisID,v(t,"y")),s=e.rAxisID=(0,a.v)(n.rAxisID,v(t,"r")),c=e.indexAxis,l=e.iAxisID=r(c,i,o,s),u=e.vAxisID=r(c,o,i,s);e.xScale=this.getScaleForId(i),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(s),e.iScale=this.getScaleForId(l),e.vScale=this.getScaleForId(u)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&(0,a.u)(this._data,this),t._stacked&&y(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),n=this._data;if((0,a.i)(e)){const t=this._cachedMeta;this._data=function(t,e){const{iScale:n,vScale:a}=e,r="x"===n.axis?"x":"y",i="x"===a.axis?"x":"y",o=Object.keys(t),s=new Array(o.length);let c,l,u;for(c=0,l=o.length;c0&&n._parsed[t-1];if(!1===this._parsing)n._parsed=r,n._sorted=!0,u=r;else{u=(0,a.b)(r[t])?this.parseArrayData(n,r,t,e):(0,a.i)(r[t])?this.parseObjectData(n,r,t,e):this.parsePrimitiveData(n,r,t,e);const i=()=>null===l[s]||h&&l[s]t&&!e.hidden&&e._stacked&&{keys:d(n,!0),values:null})(e,n,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:h}=function(t){const{min:e,max:n,minDefined:a,maxDefined:r}=t.getUserBounds();return{min:a?e:Number.NEGATIVE_INFINITY,max:r?n:Number.POSITIVE_INFINITY}}(s);let g,p;function f(){p=r[g];const e=p[s.axis];return!(0,a.g)(p[t.axis])||u>e||h=0;--g)if(!f()){this.updateRangeFromParsed(l,t,p,c);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,n=[];let r,i,o;for(r=0,i=e.length;r=0&&tthis.getContext(n,r,e),d);return p.$shared&&(p.$shared=c,i[o]=Object.freeze(w(p,c))),p}_resolveAnimations(t,e,n){const a=this.chart,r=this._cachedDataOpts,i=`animation-${e}`,o=r[i];if(o)return o;let s;if(!1!==a.options.animation){const a=this.chart.config,r=a.datasetAnimationScopeKeys(this._type,e),i=a.getOptionScopes(this.getDataset(),r);s=a.createResolver(i,this.getContext(t,n,e))}const c=new l(a,s&&s.animations);return s&&s._cacheable&&(r[i]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||b(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const n=this.resolveDataElementOptions(t,e),a=this._sharedOptions,r=this.getSharedOptions(n),i=this.includeOptions(e,r)||r!==a;return this.updateSharedOptions(r,e,n),{sharedOptions:r,includeOptions:i}}updateElement(t,e,n,a){b(a)?Object.assign(t,n):this._resolveAnimations(e,a).update(t,n)}updateSharedOptions(t,e,n){t&&!b(e)&&this._resolveAnimations(void 0,e).update(t,n)}_setStyle(t,e,n,a){t.active=a;const r=this.getStyle(e,a);this._resolveAnimations(e,n,a).update(t,{options:!a&&this.getSharedOptions(r)||r})}removeHoverStyle(t,e,n){this._setStyle(t,n,"active",!1)}setHoverStyle(t,e,n){this._setStyle(t,n,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,n=this._cachedMeta.data;for(const[t,e,n]of this._syncList)this[t](e,n);this._syncList=[];const a=n.length,r=e.length,i=Math.min(r,a);i&&this.parse(0,i),r>a?this._insertElements(a,r-a,t):r{for(t.length+=e,o=t.length-1;o>=i;o--)t[o]=t[o-e]};for(s(r),o=t;ot-e))}return t._cache.$bar}(e,t.type);let r,i,o,s,c=e._length;const l=()=>{32767!==o&&-32768!==o&&((0,a.h)(s)&&(c=Math.min(c,Math.abs(o-s)||c)),s=o)};for(r=0,i=n.length;rMath.abs(s)&&(c=s,l=o),e[n.axis]=l,e._custom={barStart:c,barEnd:l,start:r,end:i,min:o,max:s}}(t,e,n,r):e[n.axis]=n.parse(t,r),e}function x(t,e,n,a){const r=t.iScale,i=t.vScale,o=r.getLabels(),s=r===i,c=[];let l,u,d,h;for(l=n,u=n+a;lt.x,n="left",a="right"):(e=t.baset.controller.options.grouped),i=n.options.stacked,o=[],s=this._cachedMeta.controller.getParsed(e),c=s&&s[n.axis],l=t=>{const e=t._parsed.find(t=>t[n.axis]===c),r=e&&e[t.vScale.axis];if((0,a.k)(r)||isNaN(r))return!0};for(const n of r)if((void 0===e||!l(n))&&((!1===i||-1===o.indexOf(n.stack)||void 0===i&&void 0===n.stack)&&o.push(n.stack),n.index===t))break;return o.length||o.push(void 0),o}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,e=this.chart.options.indexAxis;return Object.keys(t).filter(n=>t[n].axis===e).shift()}_getAxis(){const t={},e=this.getFirstScaleIdForIndexAxis();for(const n of this.chart.data.datasets)t[(0,a.v)("x"===this.chart.options.indexAxis?n.xAxisID:n.yAxisID,e)]=!0;return Object.keys(t)}_getStackIndex(t,e,n){const a=this._getStacks(t,n),r=void 0!==e?a.indexOf(e):-1;return-1===r?a.length-1:r}_getRuler(){const t=this.options,e=this._cachedMeta,n=e.iScale,a=[];let r,i;for(r=0,i=e.data.length;r=n?1:-1)}(h,e,s)*o,g===s&&(v-=h/2);const t=e.getPixelForDecimal(0),i=e.getPixelForDecimal(1),l=Math.min(t,i),p=Math.max(t,i);v=Math.max(Math.min(v,p),l),d=v+h,n&&!u&&(c._stacks[e.axis]._visualValues[r]=e.getValueForPixel(d)-e.getValueForPixel(v))}if(v===e.getPixelForValue(s)){const t=(0,a.s)(h)*e.getLineWidthForValue(s)/2;v+=t,h-=t}return{size:h,base:v,head:d,center:d+h/2}}_calculateBarIndexPixels(t,e){const n=e.scale,r=this.options,i=r.skipNull,o=(0,a.v)(r.maxBarThickness,1/0);let s,c;const l=this._getAxisCount();if(e.grouped){const n=i?this._getStackCount(t):e.stackCount,u="flex"===r.barThickness?function(t,e,n,a){const r=e.pixels,i=r[t];let o=t>0?r[t-1]:null,s=t"spacing"!==t,_indexable:t=>"spacing"!==t&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:n,color:a}}=t.legend.options;return e.labels.map((e,r)=>{const i=t.getDatasetMeta(0).controller.getStyle(r);return{text:e,fillStyle:i.backgroundColor,strokeStyle:i.borderColor,fontColor:a,lineWidth:i.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const n=this.getDataset().data,r=this._cachedMeta;if(!1===this._parsing)r._parsed=n;else{let i,o,s=t=>+n[t];if((0,a.i)(n[t])){const{key:t="value"}=this._parsing;s=e=>+(0,a.f)(n[e],t)}for(i=t,o=t+e;i(0,a.p)(t,c,l,!0)?1:Math.max(e,e*n,r,r*n),f=(t,e,r)=>(0,a.p)(t,c,l,!0)?-1:Math.min(e,e*n,r,r*n),m=p(0,u,h),v=p(a.H,d,g),y=f(a.P,u,h),b=f(a.P+a.H,d,g);r=(m-y)/2,i=(v-b)/2,o=-(m+y)/2,s=-(v+b)/2}return{ratioX:r,ratioY:i,offsetX:o,offsetY:s}}(d,u,c),m=(n.width-o)/h,v=(n.height-o)/g,y=Math.max(Math.min(m,v)/2,0),b=(0,a.n)(this.options.radius,y),w=(b-Math.max(b*c,0))/this._getVisibleDatasetWeightTotal();this.offsetX=p*b,this.offsetY=f*b,r.total=this.calculateTotal(),this.outerRadius=b-w*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-w*l,0),this.updateElements(i,0,i.length,t)}_circumference(t,e){const n=this.options,r=this._cachedMeta,i=this._getCircumference();return e&&n.animation.animateRotate||!this.chart.getDataVisibility(t)||null===r._parsed[t]||r.data[t].hidden?0:this.calculateCircumference(r._parsed[t]*i/a.T)}updateElements(t,e,n,a){const r="reset"===a,i=this.chart,o=i.chartArea,s=i.options.animation,c=(o.left+o.right)/2,l=(o.top+o.bottom)/2,u=r&&s.animateScale,d=u?0:this.innerRadius,h=u?0:this.outerRadius,{sharedOptions:g,includeOptions:p}=this._getSharedOptions(e,a);let f,m=this._getRotation();for(f=0;f0&&!isNaN(t)?a.T*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=(0,a.o)(e._parsed[t],n.options.locale);return{label:r[t]||"",value:i}}getMaxBorderWidth(t){let e=0;const n=this.chart;let a,r,i,o,s;if(!t)for(a=0,r=n.data.datasets.length;a0&&this.getParsed(e-1);for(let n=0;n=y){b.skip=!0;continue}const T=this.getParsed(n),k=(0,a.k)(T[g]),E=b[h]=o.getPixelForValue(T[h],n),x=b[g]=i||k?s.getBasePixel():s.getPixelForValue(c?this.applyStack(s,T,c):T[g],n);b.skip=isNaN(E)||isNaN(x)||k,b.stop=n>0&&Math.abs(T[h]-w[h])>m,f&&(b.parsed=T,b.raw=l.data[n]),d&&(b.options=u||this.resolveDataElementOptions(n,p.active?"active":r)),v||this.updateElement(p,n,b,r),w=T}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,n=e.options&&e.options.borderWidth||0,a=t.data||[];if(!a.length)return n;const r=a[0].size(this.resolveDataElementOptions(0)),i=a[a.length-1].size(this.resolveDataElementOptions(a.length-1));return Math.max(n,r,i)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}class L extends T{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:n,color:a}}=t.legend.options;return e.labels.map((e,r)=>{const i=t.getDatasetMeta(0).controller.getStyle(r);return{text:e,fillStyle:i.backgroundColor,strokeStyle:i.borderColor,fontColor:a,lineWidth:i.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=(0,a.o)(e._parsed[t].r,n.options.locale);return{label:r[t]||"",value:i}}parseObjectData(t,e,n,r){return a.y.bind(this)(t,e,n,r)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((t,n)=>{const a=this.getParsed(n).r;!isNaN(a)&&this.chart.getDataVisibility(n)&&(ae.max&&(e.max=a))}),e}_updateRadius(){const t=this.chart,e=t.chartArea,n=t.options,a=Math.min(e.right-e.left,e.bottom-e.top),r=Math.max(a/2,0),i=(r-Math.max(n.cutoutPercentage?r/100*n.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=r-i*this.index,this.innerRadius=this.outerRadius-i}updateElements(t,e,n,r){const i="reset"===r,o=this.chart,s=o.options.animation,c=this._cachedMeta.rScale,l=c.xCenter,u=c.yCenter,d=c.getIndexAngle(0)-.5*a.P;let h,g=d;const p=360/this.countVisibleElements();for(h=0;h{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&e++}),e}_computeAngle(t,e,n){return this.chart.getDataVisibility(t)?(0,a.t)(this.resolveDataElementOptions(t,e).angle||n):0}}function P(t,e,n,r){const{controller:i,data:o,_sorted:s}=t,c=i._cachedMeta.iScale,l=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null;if(c&&e===c.axis&&"r"!==e&&s&&o.length){const s=c._reversePixels?a.A:a.B;if(!r){const r=s(o,e,n);if(l){const{vScale:e}=i._cachedMeta,{_parsed:n}=t,o=n.slice(0,r.lo+1).reverse().findIndex(t=>!(0,a.k)(t[e.axis]));r.lo-=Math.max(0,o);const s=n.slice(r.hi).findIndex(t=>!(0,a.k)(t[e.axis]));r.hi+=Math.max(0,s)}return r}if(i._sharedOptions){const t=o[0],a="function"==typeof t.getRange&&t.getRange(e);if(a){const t=s(o,e,n-a),r=s(o,e,n+a);return{lo:t.lo,hi:r.hi}}}}return{lo:0,hi:o.length-1}}function O(t,e,n,a,r){const i=t.getSortedVisibleDatasetMetas(),o=n[e];for(let t=0,n=i.length;t{t[o]&&t[o](e[n],r)&&(i.push({element:t,datasetIndex:a,index:c}),s=s||t.inRange(e.x,e.y,r))}),a&&!s?[]:i}var j={evaluateInteractionItems:O,modes:{index(t,e,n,r){const i=(0,a.z)(e,t),o=n.axis||"x",s=n.includeInvisible||!1,c=n.intersect?F(t,i,o,r,s):R(t,i,o,!1,r,s),l=[];return c.length?(t.getSortedVisibleDatasetMetas().forEach(t=>{const e=c[0].index,n=t.data[e];n&&!n.skip&&l.push({element:n,datasetIndex:t.index,index:e})}),l):[]},dataset(t,e,n,r){const i=(0,a.z)(e,t),o=n.axis||"xy",s=n.includeInvisible||!1;let c=n.intersect?F(t,i,o,r,s):R(t,i,o,!1,r,s);if(c.length>0){const e=c[0].datasetIndex,n=t.getDatasetMeta(e).data;c=[];for(let t=0;tF(t,(0,a.z)(e,t),n.axis||"xy",r,n.includeInvisible||!1),nearest(t,e,n,r){const i=(0,a.z)(e,t),o=n.axis||"xy",s=n.includeInvisible||!1;return R(t,i,o,n.intersect,r,s)},x:(t,e,n,r)=>N(t,(0,a.z)(e,t),"x",n.intersect,r),y:(t,e,n,r)=>N(t,(0,a.z)(e,t),"y",n.intersect,r)}};const H=["left","top","right","bottom"];function z(t,e){return t.filter(t=>t.pos===e)}function V(t,e){return t.filter(t=>-1===H.indexOf(t.pos)&&t.box.axis===e)}function q(t,e){return t.sort((t,n)=>{const a=e?n:t,r=e?t:n;return a.weight===r.weight?a.index-r.index:a.weight-r.weight})}function W(t,e,n,a){return Math.max(t[n],e[n])+Math.max(t[a],e[a])}function U(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function G(t,e,n,r){const{pos:i,box:o}=n,s=t.maxPadding;if(!(0,a.i)(i)){n.size&&(t[i]-=n.size);const e=r[n.stack]||{size:0,count:1};e.size=Math.max(e.size,n.horizontal?o.height:o.width),n.size=e.size/e.count,t[i]+=n.size}o.getPadding&&U(s,o.getPadding());const c=Math.max(0,e.outerWidth-W(s,t,"left","right")),l=Math.max(0,e.outerHeight-W(s,t,"top","bottom")),u=c!==t.w,d=l!==t.h;return t.w=c,t.h=l,n.horizontal?{same:u,other:d}:{same:d,other:u}}function Z(t,e){const n=e.maxPadding;return function(t){const a={left:0,top:0,right:0,bottom:0};return t.forEach(t=>{a[t]=Math.max(e[t],n[t])}),a}(t?["left","right"]:["top","bottom"])}function Y(t,e,n,a){const r=[];let i,o,s,c,l,u;for(i=0,o=t.length,l=0;it.box.fullSize),!0),a=q(z(e,"left"),!0),r=q(z(e,"right")),i=q(z(e,"top"),!0),o=q(z(e,"bottom")),s=V(e,"x"),c=V(e,"y");return{fullSize:n,leftAndTop:a.concat(i),rightAndBottom:r.concat(c).concat(o).concat(s),chartArea:z(e,"chartArea"),vertical:a.concat(r).concat(c),horizontal:i.concat(o).concat(s)}}(t.boxes),l=c.vertical,u=c.horizontal;(0,a.F)(t.boxes,t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()});const d=l.reduce((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1,0)||1,h=Object.freeze({outerWidth:e,outerHeight:n,padding:i,availableWidth:o,availableHeight:s,vBoxMaxWidth:o/2/d,hBoxMaxHeight:s/2}),g=Object.assign({},i);U(g,(0,a.E)(r));const p=Object.assign({maxPadding:g,w:o,h:s,x:i.left,y:i.top},i),f=function(t,e){const n=function(t){const e={};for(const n of t){const{stack:t,pos:a,stackWeight:r}=n;if(!t||!H.includes(a))continue;const i=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});i.count++,i.weight+=r}return e}(t),{vBoxMaxWidth:a,hBoxMaxHeight:r}=e;let i,o,s;for(i=0,o=t.length;i{const n=e.box;Object.assign(n,t.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}};class X{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,n){}removeEventListener(t,e,n){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,n,a){return e=Math.max(0,e||t.width),n=n||t.height,{width:e,height:Math.max(0,a?Math.floor(e/a):n)}}isAttached(t){return!0}updateConfig(t){}}class J extends X{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const tt="$chartjs",et={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},nt=t=>null===t||""===t,at=!!a.K&&{passive:!0};function rt(t,e,n){t&&t.canvas&&t.canvas.removeEventListener(e,n,at)}function it(t,e){for(const n of t)if(n===e||n.contains(e))return!0}function ot(t,e,n){const a=t.canvas,r=new MutationObserver(t=>{let e=!1;for(const n of t)e=e||it(n.addedNodes,a),e=e&&!it(n.removedNodes,a);e&&n()});return r.observe(document,{childList:!0,subtree:!0}),r}function st(t,e,n){const a=t.canvas,r=new MutationObserver(t=>{let e=!1;for(const n of t)e=e||it(n.removedNodes,a),e=e&&!it(n.addedNodes,a);e&&n()});return r.observe(document,{childList:!0,subtree:!0}),r}const ct=new Map;let lt=0;function ut(){const t=window.devicePixelRatio;t!==lt&&(lt=t,ct.forEach((e,n)=>{n.currentDevicePixelRatio!==t&&e()}))}function dt(t,e,n){const r=t.canvas,i=r&&(0,a.I)(r);if(!i)return;const o=(0,a.L)((t,e)=>{const a=i.clientWidth;n(t,e),a{const e=t[0],n=e.contentRect.width,a=e.contentRect.height;0===n&&0===a||o(n,a)});return s.observe(i),function(t,e){ct.size||window.addEventListener("resize",ut),ct.set(t,e)}(t,o),s}function ht(t,e,n){n&&n.disconnect(),"resize"===e&&function(t){ct.delete(t),ct.size||window.removeEventListener("resize",ut)}(t)}function gt(t,e,n){const r=t.canvas,i=(0,a.L)(e=>{null!==t.ctx&&n(function(t,e){const n=et[t.type]||t.type,{x:r,y:i}=(0,a.z)(t,e);return{type:n,chart:e,native:t,x:void 0!==r?r:null,y:void 0!==i?i:null}}(e,t))},t);return function(t,e,n){t&&t.addEventListener(e,n,at)}(r,e,i),i}class pt extends X{acquireContext(t,e){const n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(function(t,e){const n=t.style,r=t.getAttribute("height"),i=t.getAttribute("width");if(t[tt]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",nt(i)){const e=(0,a.J)(t,"width");void 0!==e&&(t.width=e)}if(nt(r))if(""===t.style.height)t.height=t.width/(e||2);else{const e=(0,a.J)(t,"height");void 0!==e&&(t.height=e)}}(t,e),n):null}releaseContext(t){const e=t.canvas;if(!e[tt])return!1;const n=e[tt].initial;["height","width"].forEach(t=>{const r=n[t];(0,a.k)(r)?e.removeAttribute(t):e.setAttribute(t,r)});const r=n.style||{};return Object.keys(r).forEach(t=>{e.style[t]=r[t]}),e.width=e.width,delete e[tt],!0}addEventListener(t,e,n){this.removeEventListener(t,e);const a=t.$proxies||(t.$proxies={}),r={attach:ot,detach:st,resize:dt}[e]||gt;a[e]=r(t,e,n)}removeEventListener(t,e){const n=t.$proxies||(t.$proxies={}),a=n[e];a&&(({attach:ht,detach:ht,resize:ht}[e]||rt)(t,e,a),n[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,n,r){return(0,a.G)(t,e,n,r)}isAttached(t){const e=t&&(0,a.I)(t);return!(!e||!e.isConnected)}}class ft{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}hasValue(){return(0,a.x)(this.x)&&(0,a.x)(this.y)}getProps(t,e){const n=this.$animations;if(!e||!n)return this;const a={};return t.forEach(t=>{a[t]=n[t]&&n[t].active()?n[t]._to:this[t]}),a}}function mt(t,e,n,r,i){const o=(0,a.v)(r,0),s=Math.min((0,a.v)(i,t.length),t.length);let c,l,u,d=0;for(n=Math.ceil(n),i&&(c=i-r,n=c/Math.floor(c/n)),u=o;u<0;)d++,u=Math.round(o+d*n);for(l=Math.max(o,0);l"top"===e||"left"===e?t[e]+n:t[e]-n,yt=(t,e)=>Math.min(e||t,t);function bt(t,e){const n=[],a=t.length/e,r=t.length;let i=0;for(;io+s)))return l}function Tt(t){return t.drawTicks?t.tickLength:0}function kt(t,e){if(!t.display)return 0;const n=(0,a.a0)(t.font,e),r=(0,a.E)(t.padding);return((0,a.b)(t.text)?t.text.length:1)*n.lineHeight+r.height}function Et(t,e,n){let r=(0,a.a1)(t);return(n&&"right"!==e||!n&&"right"===e)&&(r=(t=>"left"===t?"right":"right"===t?"left":t)(r)),r}class xt extends ft{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:n,_suggestedMax:r}=this;return t=(0,a.O)(t,Number.POSITIVE_INFINITY),e=(0,a.O)(e,Number.NEGATIVE_INFINITY),n=(0,a.O)(n,Number.POSITIVE_INFINITY),r=(0,a.O)(r,Number.NEGATIVE_INFINITY),{min:(0,a.O)(t,n),max:(0,a.O)(e,r),minDefined:(0,a.g)(t),maxDefined:(0,a.g)(e)}}getMinMax(t){let e,{min:n,max:r,minDefined:i,maxDefined:o}=this.getUserBounds();if(i&&o)return{min:n,max:r};const s=this.getMatchingVisibleMetas();for(let a=0,c=s.length;ar?r:n,r=i&&n>r?n:r,{min:(0,a.O)(n,(0,a.O)(r,n)),max:(0,a.O)(r,(0,a.O)(n,r))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){(0,a.Q)(this.options.beforeUpdate,[this])}update(t,e,n){const{beginAtZero:r,grace:i,ticks:o}=this.options,s=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=(0,a.R)(this,i,r),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const c=si)return function(t,e,n,a){let r,i=0,o=n[0];for(a=Math.ceil(a),r=0;ri)return e}return Math.max(i,1)}(o,e,i);if(s>0){let t,n;const r=s>1?Math.round((l-c)/(s-1)):null;for(mt(e,u,d,(0,a.k)(r)?0:c-r,c),t=0,n=s-1;t=i||n<=1||!this.isHorizontal())return void(this.labelRotation=r);const u=this._getLabelSizes(),d=u.widest.width,h=u.highest.height,g=(0,a.S)(this.chart.width-d,0,this.maxWidth);o=t.offset?this.maxWidth/n:g/(n-1),d+6>o&&(o=g/(n-(t.offset?.5:1)),s=this.maxHeight-Tt(t.grid)-e.padding-kt(t.title,this.chart.options.font),c=Math.sqrt(d*d+h*h),l=(0,a.U)(Math.min(Math.asin((0,a.S)((u.highest.height+6)/o,-1,1)),Math.asin((0,a.S)(s/c,-1,1))-Math.asin((0,a.S)(h/c,-1,1)))),l=Math.max(r,Math.min(i,l))),this.labelRotation=l}afterCalculateLabelRotation(){(0,a.Q)(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){(0,a.Q)(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:n,title:r,grid:i}}=this,o=this._isVisible(),s=this.isHorizontal();if(o){const o=kt(r,e.options.font);if(s?(t.width=this.maxWidth,t.height=Tt(i)+o):(t.height=this.maxHeight,t.width=Tt(i)+o),n.display&&this.ticks.length){const{first:e,last:r,widest:i,highest:o}=this._getLabelSizes(),c=2*n.padding,l=(0,a.t)(this.labelRotation),u=Math.cos(l),d=Math.sin(l);if(s){const e=n.mirror?0:d*i.width+u*o.height;t.height=Math.min(this.maxHeight,t.height+e+c)}else{const e=n.mirror?0:u*i.width+d*o.height;t.width=Math.min(this.maxWidth,t.width+e+c)}this._calculatePadding(e,r,d,u)}}this._handleMargins(),s?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,n,a){const{ticks:{align:r,padding:i},position:o}=this.options,s=0!==this.labelRotation,c="top"!==o&&"x"===this.axis;if(this.isHorizontal()){const o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1);let u=0,d=0;s?c?(u=a*t.width,d=n*e.height):(u=n*t.height,d=a*e.width):"start"===r?d=e.width:"end"===r?u=t.width:"inner"!==r&&(u=t.width/2,d=e.width/2),this.paddingLeft=Math.max((u-o+i)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+i)*this.width/(this.width-l),0)}else{let n=e.height/2,a=t.height/2;"start"===r?(n=0,a=t.height):"end"===r&&(n=e.height,a=0),this.paddingTop=n+i,this.paddingBottom=a+i}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){(0,a.Q)(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,n;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,n=t.length;e{const n=t.gc,a=n.length/2;let r;if(a>e){for(r=0;r({width:o[t]||0,height:s[t]||0});return{first:x(0),last:x(e-1),widest:x(k),highest:x(E),widths:o,heights:s}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return(0,a.W)(this._alignToPixels?(0,a.X)(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ts*r?s/n:c/r:c*r0}_computeGridLineItems(t){const e=this.axis,n=this.chart,r=this.options,{grid:i,position:o,border:s}=r,c=i.offset,l=this.isHorizontal(),u=this.ticks.length+(c?1:0),d=Tt(i),h=[],g=s.setContext(this.getContext()),p=g.display?g.width:0,f=p/2,m=function(t){return(0,a.X)(n,t,p)};let v,y,b,w,T,k,E,x,S,C,I,A;if("top"===o)v=m(this.bottom),k=this.bottom-d,x=v-f,C=m(t.top)+f,A=t.bottom;else if("bottom"===o)v=m(this.top),C=t.top,A=m(t.bottom)-f,k=v+f,x=this.top+d;else if("left"===o)v=m(this.right),T=this.right-d,E=v-f,S=m(t.left)+f,I=t.right;else if("right"===o)v=m(this.left),S=t.left,I=m(t.right)-f,T=v+f,E=this.left+d;else if("x"===e){if("center"===o)v=m((t.top+t.bottom)/2+.5);else if((0,a.i)(o)){const t=Object.keys(o)[0],e=o[t];v=m(this.chart.scales[t].getPixelForValue(e))}C=t.top,A=t.bottom,k=v+f,x=k+d}else if("y"===e){if("center"===o)v=m((t.left+t.right)/2);else if((0,a.i)(o)){const t=Object.keys(o)[0],e=o[t];v=m(this.chart.scales[t].getPixelForValue(e))}T=v-f,E=T-d,S=t.left,I=t.right}const _=(0,a.v)(r.ticks.maxTicksLimit,u),M=Math.max(1,Math.ceil(u/_));for(y=0;y0&&(o-=r/2)}h={left:o,top:i,width:r+e.width,height:n+e.height,color:t.backdropColor}}m.push({label:w,font:S,textOffset:A,options:{rotation:f,color:n,strokeColor:c,strokeWidth:u,textAlign:g,textBaseline:_,translation:[T,k],backdrop:h}})}return m}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-(0,a.t)(this.labelRotation))return"top"===t?"left":"right";let n="center";return"start"===e.align?n="left":"end"===e.align?n="right":"inner"===e.align&&(n="inner"),n}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:n,mirror:a,padding:r}}=this.options,i=t+r,o=this._getLabelSizes().widest.width;let s,c;return"left"===e?a?(c=this.right+r,"near"===n?s="left":"center"===n?(s="center",c+=o/2):(s="right",c+=o)):(c=this.right-i,"near"===n?s="right":"center"===n?(s="center",c-=o/2):(s="left",c=this.left)):"right"===e?a?(c=this.left+r,"near"===n?s="right":"center"===n?(s="center",c-=o/2):(s="left",c-=o)):(c=this.left+i,"near"===n?s="left":"center"===n?(s="center",c+=o/2):(s="right",c=this.right)):s="right",{textAlign:s,x:c}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;return"left"===e||"right"===e?{top:0,left:this.left,bottom:t.height,right:this.right}:"top"===e||"bottom"===e?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:n,top:a,width:r,height:i}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(n,a,r,i),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const n=this.ticks.findIndex(e=>e.value===t);return n>=0?e.setContext(this.getContext(n)).lineWidth:0}drawGrid(t){const e=this.options.grid,n=this.ctx,a=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let r,i;const o=(t,e,a)=>{a.width&&a.color&&(n.save(),n.lineWidth=a.width,n.strokeStyle=a.color,n.setLineDash(a.borderDash||[]),n.lineDashOffset=a.borderDashOffset,n.beginPath(),n.moveTo(t.x,t.y),n.lineTo(e.x,e.y),n.stroke(),n.restore())};if(e.display)for(r=0,i=a.length;r{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:r,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",a=[];let r,i;for(r=0,i=e.length;r{const r=n.split("."),i=r.pop(),o=[t].concat(r).join("."),s=e[n].split("."),c=s.pop(),l=s.join(".");a.d.route(o,i,l,c)})}(e,t.defaultRoutes),t.descriptors&&a.d.describe(e,t.descriptors)}(t,o,n),this.override&&a.d.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,n=t.id,r=this.scope;n in e&&delete e[n],r&&n in a.d[r]&&(delete a.d[r][n],this.override&&delete a.a3[n])}}class Ct{constructor(){this.controllers=new St(T,"datasets",!0),this.elements=new St(ft,"elements"),this.plugins=new St(Object,"plugins"),this.scales=new St(xt,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,n){[...e].forEach(e=>{const r=n||this._getRegistryForType(e);n||r.isForType(e)||r===this.plugins&&e.id?this._exec(t,r,e):(0,a.F)(e,e=>{const a=n||this._getRegistryForType(e);this._exec(t,a,e)})})}_exec(t,e,n){const r=(0,a.a5)(t);(0,a.Q)(n["before"+r],[],n),e[t](n),(0,a.Q)(n["after"+r],[],n)}_getRegistryForType(t){for(let e=0;et.filter(t=>!e.some(e=>t.plugin.id===e.plugin.id));this._notify(a(e,n),t,"stop"),this._notify(a(n,e),t,"start")}}function _t(t,e){return e||!1!==t?!0===t?{}:t:null}function Mt(t,{plugin:e,local:n},a,r){const i=t.pluginScopeKeys(e),o=t.getOptionScopes(a,i);return n&&e.defaults&&o.push(e.defaults),t.createResolver(o,r,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Dt(t,e){const n=a.d.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||n.indexAxis||"x"}function Bt(t){if("x"===t||"y"===t||"r"===t)return t}function Lt(t){return"top"===t||"bottom"===t?"x":"left"===t||"right"===t?"y":void 0}function Pt(t,...e){if(Bt(t))return t;for(const n of e){const e=n.axis||Lt(n.position)||t.length>1&&Bt(t[0].toLowerCase());if(e)return e}throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function Ot(t,e,n){if(n[e+"AxisID"]===t)return{axis:e}}function Ft(t){const e=t.options||(t.options={});e.plugins=(0,a.v)(e.plugins,{}),e.scales=function(t,e){const n=a.a3[t.type]||{scales:{}},r=e.scales||{},i=Dt(t.type,e),o=Object.create(null);return Object.keys(r).forEach(e=>{const s=r[e];if(!(0,a.i)(s))return console.error(`Invalid scale configuration for scale: ${e}`);if(s._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${e}`);const c=Pt(e,s,function(t,e){if(e.data&&e.data.datasets){const n=e.data.datasets.filter(e=>e.xAxisID===t||e.yAxisID===t);if(n.length)return Ot(t,"x",n[0])||Ot(t,"y",n[0])}return{}}(e,t),a.d.scales[s.type]),l=function(t,e){return t===e?"_index_":"_value_"}(c,i),u=n.scales||{};o[e]=(0,a.ab)(Object.create(null),[{axis:c},s,u[c],u[l]])}),t.data.datasets.forEach(n=>{const i=n.type||t.type,s=n.indexAxis||Dt(i,e),c=(a.a3[i]||{}).scales||{};Object.keys(c).forEach(t=>{const e=function(t,e){let n=t;return"_index_"===t?n=e:"_value_"===t&&(n="x"===e?"y":"x"),n}(t,s),i=n[e+"AxisID"]||e;o[i]=o[i]||Object.create(null),(0,a.ab)(o[i],[{axis:e},r[i],c[t]])})}),Object.keys(o).forEach(t=>{const e=o[t];(0,a.ab)(e,[a.d.scales[e.type],a.d.scale])}),o}(t,e)}function Rt(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const Nt=new Map,jt=new Set;function Ht(t,e){let n=Nt.get(t);return n||(n=e(),Nt.set(t,n),jt.add(n)),n}const zt=(t,e,n)=>{const r=(0,a.f)(e,n);void 0!==r&&t.add(r)};class Vt{constructor(t){this._config=function(t){return(t=t||{}).data=Rt(t.data),Ft(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Rt(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Ft(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Ht(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return Ht(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return Ht(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id;return Ht(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const n=this._scopeCache;let a=n.get(t);return a&&!e||(a=new Map,n.set(t,a)),a}getOptionScopes(t,e,n){const{options:r,type:i}=this,o=this._cachedScopes(t,n),s=o.get(e);if(s)return s;const c=new Set;e.forEach(e=>{t&&(c.add(t),e.forEach(e=>zt(c,t,e))),e.forEach(t=>zt(c,r,t)),e.forEach(t=>zt(c,a.a3[i]||{},t)),e.forEach(t=>zt(c,a.d,t)),e.forEach(t=>zt(c,a.a6,t))});const l=Array.from(c);return 0===l.length&&l.push(Object.create(null)),jt.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,a.a3[e]||{},a.d.datasets[e]||{},{type:e},a.d,a.a6]}resolveNamedOptions(t,e,n,r=[""]){const i={$shared:!0},{resolver:o,subPrefixes:s}=qt(this._resolverCache,t,r);let c=o;if(function(t,e){const{isScriptable:n,isIndexable:r}=(0,a.aa)(t);for(const i of e){const e=n(i),o=r(i),s=(o||e)&&t[i];if(e&&((0,a.a7)(s)||Wt(s))||o&&(0,a.b)(s))return!0}return!1}(o,e)){i.$shared=!1,n=(0,a.a7)(n)?n():n;const e=this.createResolver(t,n,s);c=(0,a.a8)(o,n,e)}for(const t of e)i[t]=c[t];return i}createResolver(t,e,n=[""],r){const{resolver:i}=qt(this._resolverCache,t,n);return(0,a.i)(e)?(0,a.a8)(i,e,void 0,r):i}}function qt(t,e,n){let r=t.get(e);r||(r=new Map,t.set(e,r));const i=n.join();let o=r.get(i);return o||(o={resolver:(0,a.a9)(e,n),subPrefixes:n.filter(t=>!t.toLowerCase().includes("hover"))},r.set(i,o)),o}const Wt=t=>(0,a.i)(t)&&Object.getOwnPropertyNames(t).some(e=>(0,a.a7)(t[e])),Ut=["top","bottom","left","right","chartArea"];function Gt(t,e){return"top"===t||"bottom"===t||-1===Ut.indexOf(t)&&"x"===e}function Zt(t,e){return function(n,a){return n[t]===a[t]?n[e]-a[e]:n[t]-a[t]}}function Yt(t){const e=t.chart,n=e.options.animation;e.notifyPlugins("afterRender"),(0,a.Q)(n&&n.onComplete,[t],e)}function Qt(t){const e=t.chart,n=e.options.animation;(0,a.Q)(n&&n.onProgress,[t],e)}function $t(t){return(0,a.M)()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const Kt={},Xt=t=>{const e=$t(t);return Object.values(Kt).filter(t=>t.canvas===e).pop()};function Jt(t,e,n){const a=Object.keys(t);for(const r of a){const a=+r;if(a>=e){const i=t[r];delete t[r],(n>0||a>e)&&(t[a+n]=i)}}}class te{static defaults=a.d;static instances=Kt;static overrides=a.a3;static registry=It;static version="4.5.0";static getChart=Xt;static register(...t){It.add(...t),ee()}static unregister(...t){It.remove(...t),ee()}constructor(t,e){const n=this.config=new Vt(e),r=$t(t),o=Xt(r);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const s=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||function(t){return!(0,a.M)()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?J:pt}(r)),this.platform.updateConfig(n);const c=this.platform.acquireContext(r,s.aspectRatio),l=c&&c.canvas,u=l&&l.height,d=l&&l.width;this.id=(0,a.ac)(),this.ctx=c,this.canvas=l,this.width=d,this.height=u,this._options=s,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new At,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=(0,a.ad)(t=>this.update(t),s.resizeDelay||0),this._dataChanges=[],Kt[this.id]=this,c&&l?(i.listen(this,"complete",Yt),i.listen(this,"progress",Qt),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:n,height:r,_aspectRatio:i}=this;return(0,a.k)(t)?e&&i?i:r?n/r:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return It}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():(0,a.ae)(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return(0,a.af)(this.canvas,this.ctx),this}stop(){return i.stop(this),this}resize(t,e){i.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(r,t,e,i),s=n.devicePixelRatio||this.platform.getDevicePixelRatio(),c=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,(0,a.ae)(this,s,!0)&&(this.notifyPlugins("resize",{size:o}),(0,a.Q)(n.onResize,[this,o],this),this.attached&&this._doResize(c)&&this.render())}ensureScalesHaveIDs(){const t=this.options.scales||{};(0,a.F)(t,(t,e)=>{t.id=e})}buildOrUpdateScales(){const t=this.options,e=t.scales,n=this.scales,r=Object.keys(n).reduce((t,e)=>(t[e]=!1,t),{});let i=[];e&&(i=i.concat(Object.keys(e).map(t=>{const n=e[t],a=Pt(t,n),r="r"===a,i="x"===a;return{options:n,dposition:r?"chartArea":i?"bottom":"left",dtype:r?"radialLinear":i?"category":"linear"}}))),(0,a.F)(i,e=>{const i=e.options,o=i.id,s=Pt(o,i),c=(0,a.v)(i.type,e.dtype);void 0!==i.position&&Gt(i.position,s)===Gt(e.dposition)||(i.position=e.dposition),r[o]=!0;let l=null;o in n&&n[o].type===c?l=n[o]:(l=new(It.getScale(c))({id:o,type:c,ctx:this.ctx,chart:this}),n[l.id]=l),l.init(i,t)}),(0,a.F)(r,(t,e)=>{t||delete n[e]}),(0,a.F)(n,t=>{K.configure(this,t,t.options),K.addBox(this,t)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,n=t.length;if(t.sort((t,e)=>t.index-e.index),n>e){for(let t=e;te.length&&delete this._stacks,t.forEach((t,n)=>{0===e.filter(e=>e===t._dataset).length&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let n,r;for(this._removeUnreferencedMetasets(),n=0,r=e.length;n{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const n=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const i=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t{t.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Zt("z","_idx"));const{_active:s,_lastEvent:c}=this;c?this._eventHandler(c,!0):s.length&&this._updateHoverStyles(s,s,!0),this.render()}_updateScales(){(0,a.F)(this.scales,t=>{K.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),n=new Set(t.events);(0,a.ag)(e,n)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:n,start:a,count:r}of e)Jt(t,a,"_removeElements"===n?-r:r)}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,n=e=>new Set(t.filter(t=>t[0]===e).map((t,e)=>e+","+t.splice(1).join(","))),r=n(0);for(let t=1;tt.split(",")).map(t=>({method:t[1],start:+t[2],count:+t[3]}))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;K.update(this,this.width,this.height,t);const e=this.chartArea,n=e.width<=0||e.height<=0;this._layers=[],(0,a.F)(this.boxes,t=>{n&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))},this),this._layers.forEach((t,e)=>{t._idx=e}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,n={meta:t,index:t.index,cancelable:!0},r=(0,a.ah)(this,t);!1!==this.notifyPlugins("beforeDatasetDraw",n)&&(r&&(0,a.Y)(e,r),t.controller.draw(),r&&(0,a.$)(e),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(t){return(0,a.C)(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,n,a){const r=j.modes[e];return"function"==typeof r?r(this,t,n,a):[]}getDatasetMeta(t){const e=this.data.datasets[t],n=this._metasets;let a=n.filter(t=>t&&t._dataset===e).pop();return a||(a={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},n.push(a)),a}getContext(){return this.$context||(this.$context=(0,a.j)(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const n=this.getDatasetMeta(t);return"boolean"==typeof n.hidden?!n.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,n){const r=n?"show":"hide",i=this.getDatasetMeta(t),o=i.controller._resolveAnimations(void 0,r);(0,a.h)(e)?(i.data[e].hidden=!n,this.update()):(this.setDatasetVisibility(t,n),o.update(i,{visible:n}),this.update(e=>e.datasetIndex===t?r:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),i.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,n,a),t[n]=a},r=(t,e,n)=>{t.offsetX=e,t.offsetY=n,this._eventHandler(t)};(0,a.F)(this.options.events,t=>n(t,r))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,n=(n,a)=>{e.addEventListener(this,n,a),t[n]=a},a=(n,a)=>{t[n]&&(e.removeEventListener(this,n,a),delete t[n])},r=(t,e)=>{this.canvas&&this.resize(t,e)};let i;const o=()=>{a("attach",o),this.attached=!0,this.resize(),n("resize",r),n("detach",i)};i=()=>{this.attached=!1,a("resize",r),this._stop(),this._resize(0,0),n("attach",o)},e.isAttached(this.canvas)?o():i()}unbindEvents(){(0,a.F)(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},(0,a.F)(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,n){const a=n?"set":"remove";let r,i,o,s;for("dataset"===e&&(r=this.getDatasetMeta(t[0].datasetIndex),r.controller["_"+a+"DatasetHoverStyle"]()),o=0,s=t.length;o{const n=this.getDatasetMeta(t);if(!n)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:n.data[e],index:e}});!(0,a.ai)(n,e)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,e))}notifyPlugins(t,e,n){return this._plugins.notify(this,t,e,n)}isPluginEnabled(t){return 1===this._plugins._cache.filter(e=>e.plugin.id===t).length}_updateHoverStyles(t,e,n){const a=this.options.hover,r=(t,e)=>t.filter(t=>!e.some(e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)),i=r(e,t),o=n?t:r(t,e);i.length&&this.updateHoverStyle(i,a.mode,!1),o.length&&a.mode&&this.updateHoverStyle(o,a.mode,!0)}_eventHandler(t,e){const n={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},a=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",n,a))return;const r=this._handleEvent(t,e,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,a),(r||n.changed)&&this.render(),this}_handleEvent(t,e,n){const{_active:r=[],options:i}=this,o=e,s=this._getActiveElements(t,r,n,o),c=(0,a.aj)(t),l=function(t,e,n,a){return n&&"mouseout"!==t.type?a?e:t:null}(t,this._lastEvent,n,c);n&&(this._lastEvent=null,(0,a.Q)(i.onHover,[t,s,this],this),c&&(0,a.Q)(i.onClick,[t,s,this],this));const u=!(0,a.ai)(s,r);return(u||e)&&(this._active=s,this._updateHoverStyles(s,r,e)),this._lastEvent=l,u}_getActiveElements(t,e,n,a){if("mouseout"===t.type)return[];if(!n)return e;const r=this.options.hover;return this.getElementsAtEventForMode(t,r.mode,r,a)}}function ee(){return(0,a.F)(te.instances,t=>t._plugins.invalidate())}function ne(t,e,n,a){return{x:n+t*Math.cos(e),y:a+t*Math.sin(e)}}function ae(t,e,n,r,i,o){const{x:s,y:c,startAngle:l,pixelMargin:u,innerRadius:d}=e,h=Math.max(e.outerRadius+r+n-u,0),g=d>0?d+r+n+u:0;let p=0;const f=i-l;if(r){const t=((d>0?d-r:0)+(h>0?h-r:0))/2;p=(f-(0!==t?f*t/(t+r):f))/2}const m=(f-Math.max(.001,f*h-n/a.P)/h)/2,v=l+m+p,y=i-m-p,{outerStart:b,outerEnd:w,innerStart:T,innerEnd:k}=function(t,e,n,r){const i=(o=t.options.borderRadius,(0,a.am)(o,["outerStart","outerEnd","innerStart","innerEnd"]));var o;const s=(n-e)/2,c=Math.min(s,r*e/2),l=t=>{const e=(n-Math.min(s,t))*r/2;return(0,a.S)(t,0,Math.min(s,e))};return{outerStart:l(i.outerStart),outerEnd:l(i.outerEnd),innerStart:(0,a.S)(i.innerStart,0,c),innerEnd:(0,a.S)(i.innerEnd,0,c)}}(e,g,h,y-v),E=h-b,x=h-w,S=v+b/E,C=y-w/x,I=g+T,A=g+k,_=v+T/I,M=y-k/A;if(t.beginPath(),o){const e=(S+C)/2;if(t.arc(s,c,h,S,e),t.arc(s,c,h,e,C),w>0){const e=ne(x,C,s,c);t.arc(e.x,e.y,w,C,y+a.H)}const n=ne(A,y,s,c);if(t.lineTo(n.x,n.y),k>0){const e=ne(A,M,s,c);t.arc(e.x,e.y,k,y+a.H,M+Math.PI)}const r=(y-k/g+(v+T/g))/2;if(t.arc(s,c,g,y-k/g,r,!0),t.arc(s,c,g,r,v+T/g,!0),T>0){const e=ne(I,_,s,c);t.arc(e.x,e.y,T,_+Math.PI,v-a.H)}const i=ne(E,v,s,c);if(t.lineTo(i.x,i.y),b>0){const e=ne(E,S,s,c);t.arc(e.x,e.y,b,v-a.H,S)}}else{t.moveTo(s,c);const e=Math.cos(S)*h+s,n=Math.sin(S)*h+c;t.lineTo(e,n);const a=Math.cos(C)*h+s,r=Math.sin(C)*h+c;t.lineTo(a,r)}t.closePath()}class re extends ft{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:"backgroundColor"};static descriptors={_scriptable:!0,_indexable:t=>"borderDash"!==t};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,e,n){const r=this.getProps(["x","y"],n),{angle:i,distance:o}=(0,a.D)(r,{x:t,y:e}),{startAngle:s,endAngle:c,innerRadius:l,outerRadius:u,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],n),h=(this.options.spacing+this.options.borderWidth)/2,g=(0,a.v)(d,c-s),p=(0,a.p)(i,s,c)&&s!==c,f=g>=a.T||p,m=(0,a.ak)(o,l+h,u+h);return f&&m}getCenterPoint(t){const{x:e,y:n,startAngle:a,endAngle:r,innerRadius:i,outerRadius:o}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:s,spacing:c}=this.options,l=(a+r)/2,u=(i+o+c+s)/2;return{x:e+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:n}=this,r=(e.offset||0)/4,i=(e.spacing||0)/2,o=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=n>a.T?Math.floor(n/a.T):0,0===n||this.innerRadius<0||this.outerRadius<0)return;t.save();const s=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(s)*r,Math.sin(s)*r);const c=r*(1-Math.sin(Math.min(a.P,n||0)));t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,function(t,e,n,r,i){const{fullCircles:o,startAngle:s,circumference:c}=e;let l=e.endAngle;if(o){ae(t,e,n,r,l,i);for(let e=0;ei?(u=i/l,t.arc(o,s,l,n+u,r-u,!0)):t.arc(o,s,i,n+a.H,r-a.H),t.closePath(),t.clip()}(t,e,m),l.selfJoin&&m-s>=a.P&&0===p&&"miter"!==d&&function(t,e,n){const{startAngle:r,x:i,y:o,outerRadius:s,innerRadius:c,options:l}=e,{borderWidth:u,borderJoinStyle:d}=l,h=Math.min(u/s,(0,a.al)(r-n));if(t.beginPath(),t.arc(i,o,s-u/2,r+h/2,n-h/2),c>0){const e=Math.min(u/c,(0,a.al)(r-n));t.arc(i,o,c+u/2,n-e/2,r+e/2,!0)}else{const e=Math.min(u/2,s*(0,a.al)(r-n));if("round"===d)t.arc(i,o,e,n-a.P/2,r+a.P/2,!0);else if("bevel"===d){const s=2*e*e,c=-s*Math.cos(n+a.P/2)+i,l=-s*Math.sin(n+a.P/2)+o,u=s*Math.cos(r+a.P/2)+i,d=s*Math.sin(r+a.P/2)+o;t.lineTo(c,l),t.lineTo(u,d)}}t.closePath(),t.moveTo(0,0),t.rect(0,0,t.canvas.width,t.canvas.height),t.clip("evenodd")}(t,e,m),o||(ae(t,e,n,r,m,i),t.stroke())}(t,this,c,i,o),t.restore()}}function ie(t,e,n=e){t.lineCap=(0,a.v)(n.borderCapStyle,e.borderCapStyle),t.setLineDash((0,a.v)(n.borderDash,e.borderDash)),t.lineDashOffset=(0,a.v)(n.borderDashOffset,e.borderDashOffset),t.lineJoin=(0,a.v)(n.borderJoinStyle,e.borderJoinStyle),t.lineWidth=(0,a.v)(n.borderWidth,e.borderWidth),t.strokeStyle=(0,a.v)(n.borderColor,e.borderColor)}function oe(t,e,n){t.lineTo(n.x,n.y)}function se(t,e,n={}){const a=t.length,{start:r=0,end:i=a-1}=n,{start:o,end:s}=e,c=Math.max(r,o),l=Math.min(i,s),u=rs&&i>s;return{count:a,start:c,loop:e.loop,ilen:l(o+(l?s-t:t))%i,b=()=>{g!==p&&(t.lineTo(m,p),t.lineTo(m,g),t.lineTo(m,f))};for(c&&(d=r[y(0)],t.moveTo(d.x,d.y)),u=0;u<=s;++u){if(d=r[y(u)],d.skip)continue;const e=d.x,n=d.y,a=0|e;a===h?(np&&(p=n),m=(v*m+e)/++v):(b(),t.lineTo(e,n),h=a,v=0,g=p=n),f=n}b()}function ue(t){const e=t.options,n=e.borderDash&&e.borderDash.length;return t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||n?ce:le}const de="function"==typeof Path2D;class he extends ft{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>"borderDash"!==t&&"fill"!==t};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const n=this.options;if((n.tension||"monotone"===n.cubicInterpolationMode)&&!n.stepped&&!this._pointsUpdated){const r=n.spanGaps?this._loop:this._fullLoop;(0,a.an)(this._points,n,t,r,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=(0,a.ao)(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,n=t.length;return n&&e[t[n-1].end]}interpolate(t,e){const n=this.options,r=t[e],i=this.points,o=(0,a.ap)(this,{property:e,start:r,end:r});if(!o.length)return;const s=[],c=function(t){return t.stepped?a.aq:t.tension||"monotone"===t.cubicInterpolationMode?a.ar:a.as}(n);let l,u;for(l=0,u=o.length;lt.replace("rgb(","rgba(").replace(")",", 0.5)"));function Ee(t){return Te[t%Te.length]}function xe(t){return ke[t%ke.length]}function Se(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}var Ce={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,n){if(!n.enabled)return;const{data:{datasets:r},options:i}=t.config,{elements:o}=i,s=Se(r)||(c=i)&&(c.borderColor||c.backgroundColor)||o&&Se(o)||"rgba(0,0,0,0.1)"!==a.d.borderColor||"rgba(0,0,0,0.1)"!==a.d.backgroundColor;var c;if(!n.forceOverride&&s)return;const l=function(t){let e=0;return(n,a)=>{const r=t.getDatasetMeta(a).controller;r instanceof D?e=function(t,e){return t.backgroundColor=t.data.map(()=>Ee(e++)),e}(n,e):r instanceof L?e=function(t,e){return t.backgroundColor=t.data.map(()=>xe(e++)),e}(n,e):r&&(e=function(t,e){return t.borderColor=Ee(e),t.backgroundColor=xe(e),++e}(n,e))}}(t);r.forEach(l)}};function Ie(t,e,n,r){if(r)return;let i=e[t],o=n[t];return"angle"===t&&(i=(0,a.al)(i),o=(0,a.al)(o)),{property:t,start:i,end:o}}function Ae(t,e,n){for(;e>t;e--){const t=n[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function _e(t,e,n,a){return t&&e?a(t[n],e[n]):t?t[n]:e?e[n]:0}function Me(t,e){let n=[],r=!1;return(0,a.b)(t)?(r=!0,n=t):n=function(t,e){const{x:n=null,y:a=null}=t||{},r=e.points,i=[];return e.segments.forEach(({start:t,end:e})=>{e=Ae(t,e,r);const o=r[t],s=r[e];null!==a?(i.push({x:o.x,y:a}),i.push({x:s.x,y:a})):null!==n&&(i.push({x:n,y:o.y}),i.push({x:n,y:s.y}))}),i}(t,e),n.length?new he({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function De(t){return t&&!1!==t.fill}function Be(t,e,n){let r=t[e].fill;const i=[e];let o;if(!n)return r;for(;!1!==r&&-1===i.indexOf(r);){if(!(0,a.g)(r))return r;if(o=t[r],!o)return!1;if(o.visible)return r;i.push(r),r=o.fill}return!1}function Le(t,e,n){const r=function(t){const e=t.options,n=e.fill;let r=(0,a.v)(n&&n.target,n);return void 0===r&&(r=!!e.backgroundColor),!1!==r&&null!==r&&(!0===r?"origin":r)}(t);if((0,a.i)(r))return!isNaN(r.value)&&r;let i=parseFloat(r);return(0,a.g)(i)&&Math.floor(i)===i?function(t,e,n,a){return"-"!==t&&"+"!==t||(n=e+n),!(n===e||n<0||n>=a)&&n}(r[0],e,i,n):["origin","start","end","stack","shape"].indexOf(r)>=0&&r}function Pe(t,e,n){const a=[];for(let r=0;r=0;--e){const n=r[e].$filler;n&&(n.line.updateControlPoints(i,n.axis),a&&n.fill&&Re(t.ctx,n,i))}},beforeDatasetsDraw(t,e,n){if("beforeDatasetsDraw"!==n.drawTime)return;const a=t.getSortedVisibleDatasetMetas();for(let e=a.length-1;e>=0;--e){const n=a[e].$filler;De(n)&&Re(t.ctx,n,t.chartArea)}},beforeDatasetDraw(t,e,n){const a=e.meta.$filler;De(a)&&"beforeDatasetDraw"===n.drawTime&&Re(t.ctx,a,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const We=(t,e)=>{let{boxHeight:n=e,boxWidth:a=e}=t;return t.usePointStyle&&(n=Math.min(n,e),a=t.pointStyleWidth||Math.min(a,e)),{boxWidth:a,boxHeight:n,itemHeight:Math.max(e,n)}};class Ue extends ft{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,n){this.maxWidth=t,this.maxHeight=e,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=(0,a.Q)(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(e=>t.filter(e,this.chart.data))),t.sort&&(e=e.sort((e,n)=>t.sort(e,n,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const n=t.labels,r=(0,a.a0)(n.font),i=r.size,o=this._computeTitleHeight(),{boxWidth:s,itemHeight:c}=We(n,i);let l,u;e.font=r.string,this.isHorizontal()?(l=this.maxWidth,u=this._fitRows(o,i,s,c)+10):(u=this.maxHeight,l=this._fitCols(o,r,s,c)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,e,n,a){const{ctx:r,maxWidth:i,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=a+o;let u=t;r.textAlign="left",r.textBaseline="middle";let d=-1,h=-l;return this.legendItems.forEach((t,g)=>{const p=n+e/2+r.measureText(t.text).width;(0===g||c[c.length-1]+p+2*o>i)&&(u+=l,c[c.length-(g>0?0:1)]=0,h+=l,d++),s[g]={left:0,top:h,row:d,width:p,height:a},c[c.length-1]+=p+o}),u}_fitCols(t,e,n,a){const{ctx:r,maxHeight:i,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=i-t;let u=o,d=0,h=0,g=0,p=0;return this.legendItems.forEach((t,i)=>{const{itemWidth:f,itemHeight:m}=function(t,e,n,a,r){const i=function(t,e,n,a){let r=t.text;return r&&"string"!=typeof r&&(r=r.reduce((t,e)=>t.length>e.length?t:e)),e+n.size/2+a.measureText(r).width}(a,t,e,n),o=function(t,e,n){let a=t;return"string"!=typeof e.text&&(a=Ge(e,n)),a}(r,a,e.lineHeight);return{itemWidth:i,itemHeight:o}}(n,e,r,t,a);i>0&&h+m+2*o>l&&(u+=d+o,c.push({width:d,height:h}),g+=d+o,p++,d=h=0),s[i]={left:g,top:h,col:p,width:f,height:m},d=Math.max(d,f),h+=m+o}),u+=d,c.push({width:d,height:h}),u}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:n,labels:{padding:r},rtl:i}}=this,o=(0,a.aA)(i,this.left,this.width);if(this.isHorizontal()){let i=0,s=(0,a.a2)(n,this.left+r,this.right-this.lineWidths[i]);for(const c of e)i!==c.row&&(i=c.row,s=(0,a.a2)(n,this.left+r,this.right-this.lineWidths[i])),c.top+=this.top+t+r,c.left=o.leftForLtr(o.x(s),c.width),s+=c.width+r}else{let i=0,s=(0,a.a2)(n,this.top+t+r,this.bottom-this.columnSizes[i].height);for(const c of e)c.col!==i&&(i=c.col,s=(0,a.a2)(n,this.top+t+r,this.bottom-this.columnSizes[i].height)),c.top=s,c.left+=this.left+r,c.left=o.leftForLtr(o.x(c.left),c.width),s+=c.height+r}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;(0,a.Y)(t,this),this._draw(),(0,a.$)(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:n,ctx:r}=this,{align:i,labels:o}=t,s=a.d.color,c=(0,a.aA)(t.rtl,this.left,this.width),l=(0,a.a0)(o.font),{padding:u}=o,d=l.size,h=d/2;let g;this.drawTitle(),r.textAlign=c.textAlign("left"),r.textBaseline="middle",r.lineWidth=.5,r.font=l.string;const{boxWidth:p,boxHeight:f,itemHeight:m}=We(o,d),v=this.isHorizontal(),y=this._computeTitleHeight();g=v?{x:(0,a.a2)(i,this.left+u,this.right-n[0]),y:this.top+u+y,line:0}:{x:this.left+u,y:(0,a.a2)(i,this.top+y+u,this.bottom-e[0].height),line:0},(0,a.aB)(this.ctx,t.textDirection);const b=m+u;this.legendItems.forEach((w,T)=>{r.strokeStyle=w.fontColor,r.fillStyle=w.fontColor;const k=r.measureText(w.text).width,E=c.textAlign(w.textAlign||(w.textAlign=o.textAlign)),x=p+h+k;let S=g.x,C=g.y;if(c.setWidth(this.width),v?T>0&&S+x+u>this.right&&(C=g.y+=b,g.line++,S=g.x=(0,a.a2)(i,this.left+u,this.right-n[g.line])):T>0&&C+b>this.bottom&&(S=g.x=S+e[g.line].width+u,g.line++,C=g.y=(0,a.a2)(i,this.top+y+u,this.bottom-e[g.line].height)),function(t,e,n){if(isNaN(p)||p<=0||isNaN(f)||f<0)return;r.save();const i=(0,a.v)(n.lineWidth,1);if(r.fillStyle=(0,a.v)(n.fillStyle,s),r.lineCap=(0,a.v)(n.lineCap,"butt"),r.lineDashOffset=(0,a.v)(n.lineDashOffset,0),r.lineJoin=(0,a.v)(n.lineJoin,"miter"),r.lineWidth=i,r.strokeStyle=(0,a.v)(n.strokeStyle,s),r.setLineDash((0,a.v)(n.lineDash,[])),o.usePointStyle){const s={radius:f*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},l=c.xPlus(t,p/2),u=e+h;(0,a.aE)(r,s,l,u,o.pointStyleWidth&&p)}else{const o=e+Math.max((d-f)/2,0),s=c.leftForLtr(t,p),l=(0,a.ay)(n.borderRadius);r.beginPath(),Object.values(l).some(t=>0!==t)?(0,a.aw)(r,{x:s,y:o,w:p,h:f,radius:l}):r.rect(s,o,p,f),r.fill(),0!==i&&r.stroke()}r.restore()}(c.x(S),C,w),S=(0,a.aC)(E,S+p+h,v?S+x:this.right,t.rtl),function(t,e,n){(0,a.Z)(r,n.text,t,e+m/2,l,{strikethrough:n.hidden,textAlign:c.textAlign(n.textAlign)})}(c.x(S),C,w),v)g.x+=x+u;else if("string"!=typeof w.text){const t=l.lineHeight;g.y+=Ge(w,t)+u}else g.y+=b}),(0,a.aD)(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,n=(0,a.a0)(e.font),r=(0,a.E)(e.padding);if(!e.display)return;const i=(0,a.aA)(t.rtl,this.left,this.width),o=this.ctx,s=e.position,c=n.size/2,l=r.top+c;let u,d=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),u=this.top+l,d=(0,a.a2)(t.align,d,this.right-h);else{const e=this.columnSizes.reduce((t,e)=>Math.max(t,e.height),0);u=l+(0,a.a2)(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const g=(0,a.a2)(s,d,d+h);o.textAlign=i.textAlign((0,a.a1)(s)),o.textBaseline="middle",o.strokeStyle=e.color,o.fillStyle=e.color,o.font=n.string,(0,a.Z)(o,e.text,g,u,n)}_computeTitleHeight(){const t=this.options.title,e=(0,a.a0)(t.font),n=(0,a.E)(t.padding);return t.display?e.lineHeight+n.height:0}_getLegendItemAt(t,e){let n,r,i;if((0,a.ak)(t,this.left,this.right)&&(0,a.ak)(e,this.top,this.bottom))for(i=this.legendHitBoxes,n=0;nt.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:o,useBorderRadius:s,borderRadius:c}}=t.legend.options;return t._getSortedDatasetMetas().map(t=>{const l=t.controller.getStyle(n?0:void 0),u=(0,a.E)(l.borderWidth);return{text:e[t.index].label,fillStyle:l.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:l.borderCapStyle,lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:(u.width+u.height)/4,strokeStyle:l.borderColor,pointStyle:r||l.pointStyle,rotation:l.rotation,textAlign:i||l.textAlign,borderRadius:s&&(c||l.borderRadius),datasetIndex:t.index}},this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Ye extends ft{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const n=this.options;if(this.left=0,this.top=0,!n.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const r=(0,a.b)(n.text)?n.text.length:1;this._padding=(0,a.E)(n.padding);const i=r*(0,a.a0)(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:n,bottom:r,right:i,options:o}=this,s=o.align;let c,l,u,d=0;return this.isHorizontal()?(l=(0,a.a2)(s,n,i),u=e+t,c=i-n):("left"===o.position?(l=n+t,u=(0,a.a2)(s,r,e),d=-.5*a.P):(l=i-t,u=(0,a.a2)(s,e,r),d=.5*a.P),c=r-e),{titleX:l,titleY:u,maxWidth:c,rotation:d}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const n=(0,a.a0)(e.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:o,maxWidth:s,rotation:c}=this._drawArgs(r);(0,a.Z)(t,e.text,0,0,n,{color:e.color,maxWidth:s,rotation:c,textAlign:(0,a.a1)(e.align),textBaseline:"middle",translation:[i,o]})}}var Qe={id:"title",_element:Ye,start(t,e,n){!function(t,e){const n=new Ye({ctx:t.ctx,options:e,chart:t});K.configure(t,n,e),K.addBox(t,n),t.titleBlock=n}(t,n)},stop(t){const e=t.titleBlock;K.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,n){const a=t.titleBlock;K.configure(t,a,n),a.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};new WeakMap;const $e={average(t){if(!t.length)return!1;let e,n,a=new Set,r=0,i=0;for(e=0,n=t.length;et+e)/a.size,y:r/i}},nearest(t,e){if(!t.length)return!1;let n,r,i,o=e.x,s=e.y,c=Number.POSITIVE_INFINITY;for(n=0,r=t.length;n-1?t.split("\n"):t}function Je(t,e){const{element:n,datasetIndex:a,index:r}=e,i=t.getDatasetMeta(a).controller,{label:o,value:s}=i.getLabelAndValue(r);return{chart:t,label:o,parsed:i.getParsed(r),raw:t.data.datasets[a].data[r],formattedValue:s,dataset:i.getDataset(),dataIndex:r,datasetIndex:a,element:n}}function tn(t,e){const n=t.chart.ctx,{body:r,footer:i,title:o}=t,{boxWidth:s,boxHeight:c}=e,l=(0,a.a0)(e.bodyFont),u=(0,a.a0)(e.titleFont),d=(0,a.a0)(e.footerFont),h=o.length,g=i.length,p=r.length,f=(0,a.E)(e.padding);let m=f.height,v=0,y=r.reduce((t,e)=>t+e.before.length+e.lines.length+e.after.length,0);y+=t.beforeBody.length+t.afterBody.length,h&&(m+=h*u.lineHeight+(h-1)*e.titleSpacing+e.titleMarginBottom),y&&(m+=p*(e.displayColors?Math.max(c,l.lineHeight):l.lineHeight)+(y-p)*l.lineHeight+(y-1)*e.bodySpacing),g&&(m+=e.footerMarginTop+g*d.lineHeight+(g-1)*e.footerSpacing);let b=0;const w=function(t){v=Math.max(v,n.measureText(t).width+b)};return n.save(),n.font=u.string,(0,a.F)(t.title,w),n.font=l.string,(0,a.F)(t.beforeBody.concat(t.afterBody),w),b=e.displayColors?s+2+e.boxPadding:0,(0,a.F)(r,t=>{(0,a.F)(t.before,w),(0,a.F)(t.lines,w),(0,a.F)(t.after,w)}),b=0,n.font=d.string,(0,a.F)(t.footer,w),n.restore(),v+=f.width,{width:v,height:m}}function en(t,e,n,a){const{x:r,width:i}=n,{width:o,chartArea:{left:s,right:c}}=t;let l="center";return"center"===a?l=r<=(s+c)/2?"left":"right":r<=i/2?l="left":r>=o-i/2&&(l="right"),function(t,e,n,a){const{x:r,width:i}=a,o=n.caretSize+n.caretPadding;return"left"===t&&r+i+o>e.width||"right"===t&&r-i-o<0||void 0}(l,t,e,n)&&(l="center"),l}function nn(t,e,n){const a=n.yAlign||e.yAlign||function(t,e){const{y:n,height:a}=e;return nt.height-a/2?"bottom":"center"}(t,n);return{xAlign:n.xAlign||e.xAlign||en(t,e,n,a),yAlign:a}}function an(t,e,n,r){const{caretSize:i,caretPadding:o,cornerRadius:s}=t,{xAlign:c,yAlign:l}=n,u=i+o,{topLeft:d,topRight:h,bottomLeft:g,bottomRight:p}=(0,a.ay)(s);let f=function(t,e){let{x:n,width:a}=t;return"right"===e?n-=a:"center"===e&&(n-=a/2),n}(e,c);const m=function(t,e,n){let{y:a,height:r}=t;return"top"===e?a+=n:a-="bottom"===e?r+n:r/2,a}(e,l,u);return"center"===l?"left"===c?f+=u:"right"===c&&(f-=u):"left"===c?f-=Math.max(d,g)+i:"right"===c&&(f+=Math.max(h,p)+i),{x:(0,a.S)(f,0,r.width-e.width),y:(0,a.S)(m,0,r.height-e.height)}}function rn(t,e,n){const r=(0,a.E)(n.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-r.right:t.x+r.left}function on(t){return Ke([],Xe(t))}function sn(t,e){const n=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return n?t.override(n):t}const cn={beforeTitle:a.aG,title(t){if(t.length>0){const e=t[0],n=e.chart.data.labels,a=n?n.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(a>0&&e.dataIndex{const e={before:[],lines:[],after:[]},a=sn(n,t);Ke(e.before,Xe(ln(a,"beforeLabel",this,t))),Ke(e.lines,ln(a,"label",this,t)),Ke(e.after,Xe(ln(a,"afterLabel",this,t))),r.push(e)}),r}getAfterBody(t,e){return on(ln(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:n}=e,a=ln(n,"beforeFooter",this,t),r=ln(n,"footer",this,t),i=ln(n,"afterFooter",this,t);let o=[];return o=Ke(o,Xe(a)),o=Ke(o,Xe(r)),o=Ke(o,Xe(i)),o}_createItems(t){const e=this._active,n=this.chart.data,r=[],i=[],o=[];let s,c,l=[];for(s=0,c=e.length;st.filter(e,a,r,n))),t.itemSort&&(l=l.sort((e,a)=>t.itemSort(e,a,n))),(0,a.F)(l,e=>{const n=sn(t.callbacks,e);r.push(ln(n,"labelColor",this,e)),i.push(ln(n,"labelPointStyle",this,e)),o.push(ln(n,"labelTextColor",this,e))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const n=this.options.setContext(this.getContext()),a=this._active;let r,i=[];if(a.length){const t=$e[n.position].call(this,a,this._eventPosition);i=this._createItems(n),this.title=this.getTitle(i,n),this.beforeBody=this.getBeforeBody(i,n),this.body=this.getBody(i,n),this.afterBody=this.getAfterBody(i,n),this.footer=this.getFooter(i,n);const e=this._size=tn(this,n),o=Object.assign({},t,e),s=nn(this.chart,n,o),c=an(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,r={opacity:1,x:c.x,y:c.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(r={opacity:0});this._tooltipItems=i,this.$context=void 0,r&&this._resolveAnimations().update(this,r),t&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,n,a){const r=this.getCaretPosition(t,n,a);e.lineTo(r.x1,r.y1),e.lineTo(r.x2,r.y2),e.lineTo(r.x3,r.y3)}getCaretPosition(t,e,n){const{xAlign:r,yAlign:i}=this,{caretSize:o,cornerRadius:s}=n,{topLeft:c,topRight:l,bottomLeft:u,bottomRight:d}=(0,a.ay)(s),{x:h,y:g}=t,{width:p,height:f}=e;let m,v,y,b,w,T;return"center"===i?(w=g+f/2,"left"===r?(m=h,v=m-o,b=w+o,T=w-o):(m=h+p,v=m+o,b=w-o,T=w+o),y=m):(v="left"===r?h+Math.max(c,u)+o:"right"===r?h+p-Math.max(l,d)-o:this.caretX,"top"===i?(b=g,w=b-o,m=v-o,y=v+o):(b=g+f,w=b+o,m=v+o,y=v-o),T=b),{x1:m,x2:v,x3:y,y1:b,y2:w,y3:T}}drawTitle(t,e,n){const r=this.title,i=r.length;let o,s,c;if(i){const l=(0,a.aA)(n.rtl,this.x,this.width);for(t.x=rn(this,n.titleAlign,n),e.textAlign=l.textAlign(n.titleAlign),e.textBaseline="middle",o=(0,a.a0)(n.titleFont),s=n.titleSpacing,e.fillStyle=n.titleColor,e.font=o.string,c=0;c0!==t)?(t.beginPath(),t.fillStyle=i.multiKeyBackground,(0,a.aw)(t,{x:e,y:p,w:l,h:c,radius:s}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),(0,a.aw)(t,{x:n,y:p+1,w:l-2,h:c-2,radius:s}),t.fill()):(t.fillStyle=i.multiKeyBackground,t.fillRect(e,p,l,c),t.strokeRect(e,p,l,c),t.fillStyle=o.backgroundColor,t.fillRect(n,p+1,l-2,c-2))}t.fillStyle=this.labelTextColors[n]}drawBody(t,e,n){const{body:r}=this,{bodySpacing:i,bodyAlign:o,displayColors:s,boxHeight:c,boxWidth:l,boxPadding:u}=n,d=(0,a.a0)(n.bodyFont);let h=d.lineHeight,g=0;const p=(0,a.aA)(n.rtl,this.x,this.width),f=function(n){e.fillText(n,p.x(t.x+g),t.y+h/2),t.y+=h+i},m=p.textAlign(o);let v,y,b,w,T,k,E;for(e.textAlign=o,e.textBaseline="middle",e.font=d.string,t.x=rn(this,m,n),e.fillStyle=n.bodyColor,(0,a.F)(this.beforeBody,f),g=s&&"right"!==m?"center"===o?l/2+u:l+2+u:0,w=0,k=r.length;w0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,n=this.$animations,a=n&&n.x,r=n&&n.y;if(a||r){const n=$e[t.position].call(this,this._active,this._eventPosition);if(!n)return;const i=this._size=tn(this,t),o=Object.assign({},n,this._size),s=nn(e,t,o),c=an(t,o,s,e);a._to===c.x&&r._to===c.y||(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=i.width,this.height=i.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let n=this.opacity;if(!n)return;this._updateAnimationTarget(e);const r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;const o=(0,a.E)(e.padding),s=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&s&&(t.save(),t.globalAlpha=n,this.drawBackground(i,t,r,e),(0,a.aB)(t,e.textDirection),i.y+=o.top,this.drawTitle(i,t,e),this.drawBody(i,t,e),this.drawFooter(i,t,e),(0,a.aD)(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const n=this._active,r=t.map(({datasetIndex:t,index:e})=>{const n=this.chart.getDatasetMeta(t);if(!n)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:n.data[e],index:e}}),i=!(0,a.ai)(n,r),o=this._positionChanged(r,e);(i||o)&&(this._active=r,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,n=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const r=this.options,i=this._active||[],o=this._getActiveElements(t,i,e,n),s=this._positionChanged(o,t),c=e||!(0,a.ai)(o,i)||s;return c&&(this._active=o,(r.enabled||r.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),c}_getActiveElements(t,e,n,a){const r=this.options;if("mouseout"===t.type)return[];if(!a)return e.filter(t=>this.chart.data.datasets[t.datasetIndex]&&void 0!==this.chart.getDatasetMeta(t.datasetIndex).controller.getParsed(t.index));const i=this.chart.getElementsAtEventForMode(t,r.mode,r,n);return r.reverse&&i.reverse(),i}_positionChanged(t,e){const{caretX:n,caretY:a,options:r}=this,i=$e[r.position].call(this,t,e);return!1!==i&&(n!==i.x||a!==i.y)}}var dn={id:"tooltip",_element:un,positioners:$e,afterInit(t,e,n){n&&(t.tooltip=new un({chart:t,options:n}))},beforeUpdate(t,e,n){t.tooltip&&t.tooltip.initialize(n)},reset(t,e,n){t.tooltip&&t.tooltip.initialize(n)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const n={tooltip:e};if(!1===t.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0}))return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",n)}},afterEvent(t,e){if(t.tooltip){const n=e.replay;t.tooltip.handleEvent(e.event,n,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:cn},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};function hn(t){const e=this.getLabels();return t>=0&&tnull===t?null:(0,a.S)(Math.round(t),0,e))(e=isFinite(e)&&n[e]===t?e:function(t,e,n,a){const r=t.indexOf(e);return-1===r?((t,e,n,a)=>("string"==typeof e?(n=t.push(e)-1,a.unshift({index:n,label:e})):isNaN(e)&&(n=null),n))(t,e,n,a):r!==t.lastIndexOf(e)?n:r}(n,t,(0,a.v)(e,t),this._addedLabels),n.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:n,max:a}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(n=0),e||(a=this.getLabels().length-1)),this.min=n,this.max=a}buildTicks(){const t=this.min,e=this.max,n=this.options.offset,a=[];let r=this.getLabels();r=0===t&&e===r.length-1?r:r.slice(t,e+1),this._valueRange=Math.max(r.length-(n?0:1),1),this._startValue=this.min-(n?.5:0);for(let n=t;n<=e;n++)a.push({value:n});return a}getLabelForValue(t){return hn.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return"number"!=typeof t&&(t=this.parse(t)),null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function pn(t,e,{horizontal:n,minRotation:r}){const i=(0,a.t)(r),o=(n?Math.sin(i):Math.cos(i))||.001,s=.75*e*(""+t).length;return Math.min(e/o,s)}class fn extends xt{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return(0,a.k)(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:n}=this.getUserBounds();let{min:r,max:i}=this;const o=t=>r=e?r:t,s=t=>i=n?i:t;if(t){const t=(0,a.s)(r),e=(0,a.s)(i);t<0&&e<0?s(0):t>0&&e>0&&o(0)}if(r===i){let e=0===i?1:Math.abs(.05*i);s(i+e),t||o(r-e)}this.min=r,this.max=i}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:n,stepSize:a}=t;return a?(e=Math.ceil(this.max/a)-Math.floor(this.min/a)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${a} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),n=n||11),n&&(e=Math.min(n,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let n=this.getTickLimit();n=Math.max(2,n);const r=function(t,e){const n=[],{bounds:r,step:i,min:o,max:s,precision:c,count:l,maxTicks:u,maxDigits:d,includeBounds:h}=t,g=i||1,p=u-1,{min:f,max:m}=e,v=!(0,a.k)(o),y=!(0,a.k)(s),b=!(0,a.k)(l),w=(m-f)/(d+1);let T,k,E,x,S=(0,a.aI)((m-f)/p/g)*g;if(S<1e-14&&!v&&!y)return[{value:f},{value:m}];x=Math.ceil(m/S)-Math.floor(f/S),x>p&&(S=(0,a.aI)(x*S/p/g)*g),(0,a.k)(c)||(T=Math.pow(10,c),S=Math.ceil(S*T)/T),"ticks"===r?(k=Math.floor(f/S)*S,E=Math.ceil(m/S)*S):(k=f,E=m),v&&y&&i&&(0,a.aJ)((s-o)/i,S/1e3)?(x=Math.round(Math.min((s-o)/S,u)),S=(s-o)/x,k=o,E=s):b?(k=v?o:k,E=y?s:E,x=l-1,S=(E-k)/x):(x=(E-k)/S,x=(0,a.aK)(x,Math.round(x),S/1e3)?Math.round(x):Math.ceil(x));const C=Math.max((0,a.aL)(S),(0,a.aL)(k));T=Math.pow(10,(0,a.k)(c)?C:c),k=Math.round(k*T)/T,E=Math.round(E*T)/T;let I=0;for(v&&(h&&k!==o?(n.push({value:o}),ks)break;n.push({value:t})}return y&&h&&E!==s?n.length&&(0,a.aK)(n[n.length-1].value,s,pn(s,w,t))?n[n.length-1].value=s:n.push({value:s}):y&&E!==s||n.push({value:E}),n}({maxTicks:n,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:!1!==e.includeBounds},this._range||this);return"ticks"===t.bounds&&(0,a.aH)(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let e=this.min,n=this.max;if(super.configure(),this.options.offset&&t.length){const a=(n-e)/Math.max(t.length-1,1)/2;e-=a,n+=a}this._startValue=e,this._endValue=n,this._valueRange=n-e}getLabelForValue(t){return(0,a.o)(t,this.chart.options.locale,this.options.ticks.format)}}class mn extends fn{static id="linear";static defaults={ticks:{callback:a.aM.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=(0,a.g)(t)?t:0,this.max=(0,a.g)(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,n=(0,a.t)(this.options.ticks.minRotation),r=(t?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,i.lineHeight/r))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}a.aM.formatters.logarithmic,a.aM.formatters.numeric},311(t,e,n){function a(t){return t+.5|0}n.d(e,{$:()=>Te,A:()=>Pt,B:()=>Lt,C:()=>be,D:()=>xt,E:()=>Oe,F:()=>W,G:()=>fn,H:()=>ut,I:()=>cn,J:()=>yn,K:()=>vn,L:()=>zt,M:()=>sn,N:()=>vt,O:()=>j,P:()=>it,Q:()=>q,R:()=>Ne,S:()=>_t,T:()=>ot,U:()=>kt,V:()=>ge,W:()=>Mt,X:()=>fe,Y:()=>we,Z:()=>Ce,_:()=>jt,a:()=>Re,a0:()=>Fe,a1:()=>qt,a2:()=>Wt,a3:()=>se,a4:()=>Q,a5:()=>tt,a6:()=>ce,a7:()=>nt,a8:()=>ze,a9:()=>He,aA:()=>kn,aB:()=>En,aC:()=>Ut,aD:()=>xn,aE:()=>ye,aF:()=>St,aG:()=>L,aH:()=>wt,aI:()=>mt,aJ:()=>bt,aK:()=>ft,aL:()=>Et,aM:()=>oe,aN:()=>gt,aO:()=>pe,aP:()=>Ot,aQ:()=>Bt,aS:()=>te,aa:()=>Ve,ab:()=>$,ac:()=>P,ad:()=>Vt,ae:()=>mn,af:()=>me,ag:()=>at,ah:()=>Pn,ai:()=>U,aj:()=>rt,ak:()=>Dt,al:()=>It,am:()=>Be,an:()=>on,ao:()=>_n,ap:()=>An,aq:()=>wn,ar:()=>Tn,as:()=>bn,at:()=>ke,au:()=>Ee,av:()=>ve,aw:()=>Ie,ax:()=>Le,ay:()=>Pe,az:()=>In,b:()=>F,c:()=>Jt,d:()=>he,e:()=>Kt,f:()=>J,g:()=>N,h:()=>et,i:()=>R,j:()=>je,k:()=>O,l:()=>Rt,m:()=>z,n:()=>V,o:()=>re,p:()=>At,q:()=>Gt,r:()=>Ht,s:()=>pt,t:()=>Tt,u:()=>Nt,v:()=>H,w:()=>Zt,x:()=>yt,y:()=>Je,z:()=>gn});const r=(t,e,n)=>Math.max(Math.min(t,n),e);function i(t){return r(a(2.55*t),0,255)}function o(t){return r(a(255*t),0,255)}function s(t){return r(a(t/2.55)/100,0,1)}function c(t){return r(a(100*t),0,100)}const l={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},u=[..."0123456789ABCDEF"],d=t=>u[15&t],h=t=>u[(240&t)>>4]+u[15&t],g=t=>(240&t)>>4==(15&t);const p=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function f(t,e,n){const a=e*Math.min(n,1-n),r=(e,r=(e+t/30)%12)=>n-a*Math.max(Math.min(r-3,9-r,1),-1);return[r(0),r(8),r(4)]}function m(t,e,n){const a=(a,r=(a+t/60)%6)=>n-n*e*Math.max(Math.min(r,4-r,1),0);return[a(5),a(3),a(1)]}function v(t,e,n){const a=f(t,1,.5);let r;for(e+n>1&&(r=1/(e+n),e*=r,n*=r),r=0;r<3;r++)a[r]*=1-e-n,a[r]+=e;return a}function y(t){const e=t.r/255,n=t.g/255,a=t.b/255,r=Math.max(e,n,a),i=Math.min(e,n,a),o=(r+i)/2;let s,c,l;return r!==i&&(l=r-i,c=o>.5?l/(2-r-i):l/(r+i),s=function(t,e,n,a,r){return t===r?(e-n)/a+(et<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,I=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function A(t,e,n){if(t){let a=y(t);a[e]=Math.max(0,Math.min(a[e]+a[e]*n,0===e?360:1)),a=w(a),t.r=a[0],t.g=a[1],t.b=a[2]}}function _(t,e){return t?Object.assign(e||{},t):t}function M(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=o(t[3]))):(e=_(t,{r:0,g:0,b:0,a:1})).a=o(e.a),e}function D(t){return"r"===t.charAt(0)?function(t){const e=S.exec(t);let n,a,o,s=255;if(e){if(e[7]!==n){const t=+e[7];s=e[8]?i(t):r(255*t,0,255)}return n=+e[1],a=+e[3],o=+e[5],n=255&(e[2]?i(n):r(n,0,255)),a=255&(e[4]?i(a):r(a,0,255)),o=255&(e[6]?i(o):r(o,0,255)),{r:n,g:a,b:o,a:s}}}(t):function(t){const e=p.exec(t);let n,a=255;if(!e)return;e[5]!==n&&(a=e[6]?i(+e[5]):o(+e[5]));const r=T(+e[2]),s=+e[3]/100,c=+e[4]/100;return n="hwb"===e[1]?function(t,e,n){return b(v,t,e,n)}(r,s,c):"hsv"===e[1]?function(t,e,n){return b(m,t,e,n)}(r,s,c):w(r,s,c),{r:n[0],g:n[1],b:n[2],a}}(t)}class B{constructor(t){if(t instanceof B)return t;const e=typeof t;let n;var a,r,i;"object"===e?n=M(t):"string"===e&&(i=(a=t).length,"#"===a[0]&&(4===i||5===i?r={r:255&17*l[a[1]],g:255&17*l[a[2]],b:255&17*l[a[3]],a:5===i?17*l[a[4]]:255}:7!==i&&9!==i||(r={r:l[a[1]]<<4|l[a[2]],g:l[a[3]]<<4|l[a[4]],b:l[a[5]]<<4|l[a[6]],a:9===i?l[a[7]]<<4|l[a[8]]:255})),n=r||function(t){x||(x=function(){const t={},e=Object.keys(E),n=Object.keys(k);let a,r,i,o,s;for(a=0;a>16&255,i>>8&255,255&i]}return t}(),x.transparent=[0,0,0,0]);const e=x[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}(t)||D(t)),this._rgb=n,this._valid=!!n}get valid(){return this._valid}get rgb(){var t=_(this._rgb);return t&&(t.a=s(t.a)),t}set rgb(t){this._rgb=M(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${s(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?(t=this._rgb,e=(t=>g(t.r)&&g(t.g)&&g(t.b)&&g(t.a))(t)?d:h,t?"#"+e(t.r)+e(t.g)+e(t.b)+((t,e)=>t<255?e(t):"")(t.a,e):void 0):void 0;var t,e}hslString(){return this._valid?function(t){if(!t)return;const e=y(t),n=e[0],a=c(e[1]),r=c(e[2]);return t.a<255?`hsla(${n}, ${a}%, ${r}%, ${s(t.a)})`:`hsl(${n}, ${a}%, ${r}%)`}(this._rgb):void 0}mix(t,e){if(t){const n=this.rgb,a=t.rgb;let r;const i=e===r?.5:e,o=2*i-1,s=n.a-a.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;r=1-c,n.r=255&c*n.r+r*a.r+.5,n.g=255&c*n.g+r*a.g+.5,n.b=255&c*n.b+r*a.b+.5,n.a=i*n.a+(1-i)*a.a,this.rgb=n}return this}interpolate(t,e){return t&&(this._rgb=function(t,e,n){const a=I(s(t.r)),r=I(s(t.g)),i=I(s(t.b));return{r:o(C(a+n*(I(s(e.r))-a))),g:o(C(r+n*(I(s(e.g))-r))),b:o(C(i+n*(I(s(e.b))-i))),a:t.a+n*(e.a-t.a)}}(this._rgb,t._rgb,e)),this}clone(){return new B(this.rgb)}alpha(t){return this._rgb.a=o(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=a(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return A(this._rgb,2,t),this}darken(t){return A(this._rgb,2,-t),this}saturate(t){return A(this._rgb,1,t),this}desaturate(t){return A(this._rgb,1,-t),this}rotate(t){return function(t,e){var n=y(t);n[0]=T(n[0]+e),n=w(n),t.r=n[0],t.g=n[1],t.b=n[2]}(this._rgb,t),this}}function L(){}const P=(()=>{let t=0;return()=>t++})();function O(t){return null==t}function F(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.slice(0,7)&&"Array]"===e.slice(-6)}function R(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function N(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function j(t,e){return N(t)?t:e}function H(t,e){return void 0===t?e:t}const z=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:+t/e,V=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function q(t,e,n){if(t&&"function"==typeof t.call)return t.apply(n,e)}function W(t,e,n,a){let r,i,o;if(F(t))if(i=t.length,a)for(r=i-1;r>=0;r--)e.call(n,t[r],r);else for(r=0;rt,x:t=>t.x,y:t=>t.y};function J(t,e){const n=X[e]||(X[e]=function(t){const e=function(t){const e=t.split("."),n=[];let a="";for(const t of e)a+=t,a.endsWith("\\")?a=a.slice(0,-1)+".":(n.push(a),a="");return n}(t);return t=>{for(const n of e){if(""===n)break;t=t&&t[n]}return t}}(e));return n(t)}function tt(t){return t.charAt(0).toUpperCase()+t.slice(1)}const et=t=>void 0!==t,nt=t=>"function"==typeof t,at=(t,e)=>{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0};function rt(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}const it=Math.PI,ot=2*it,st=ot+it,ct=Number.POSITIVE_INFINITY,lt=it/180,ut=it/2,dt=it/4,ht=2*it/3,gt=Math.log10,pt=Math.sign;function ft(t,e,n){return Math.abs(t-e)t-e).pop(),e}function yt(t){return!function(t){return"symbol"==typeof t||"object"==typeof t&&null!==t&&!(Symbol.toPrimitive in t||"toString"in t||"valueOf"in t)}(t)&&!isNaN(parseFloat(t))&&isFinite(t)}function bt(t,e){const n=Math.round(t);return n-e<=t&&n+e>=t}function wt(t,e,n){let a,r,i;for(a=0,r=t.length;ac&&l=Math.min(e,n)-a&&t<=Math.max(e,n)+a}function Bt(t,e,n){n=n||(n=>t[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}const Lt=(t,e,n,a)=>Bt(t,n,a?a=>{const r=t[a][e];return rt[a][e]Bt(t,n,a=>t[a][e]>=n);function Ot(t,e,n){let a=0,r=t.length;for(;aa&&t[r-1]>n;)r--;return a>0||r{const n="_onData"+tt(e),a=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const r=a.apply(this,e);return t._chartjs.listeners.forEach(t=>{"function"==typeof t[n]&&t[n](...e)}),r}})}))}function Nt(t,e){const n=t._chartjs;if(!n)return;const a=n.listeners,r=a.indexOf(e);-1!==r&&a.splice(r,1),a.length>0||(Ft.forEach(e=>{delete t[e]}),delete t._chartjs)}function jt(t){const e=new Set(t);return e.size===t.length?t:Array.from(e)}const Ht="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function zt(t,e){let n=[],a=!1;return function(...r){n=r,a||(a=!0,Ht.call(window,()=>{a=!1,t.apply(e,n)}))}}function Vt(t,e){let n;return function(...a){return e?(clearTimeout(n),n=setTimeout(t,e,a)):t.apply(this,a),e}}const qt=t=>"start"===t?"left":"end"===t?"right":"center",Wt=(t,e,n)=>"start"===t?e:"end"===t?n:(e+n)/2,Ut=(t,e,n,a)=>t===(a?"left":"right")?n:"center"===t?(e+n)/2:e;function Gt(t,e,n){const a=e.length;let r=0,i=a;if(t._sorted){const{iScale:o,vScale:s,_parsed:c}=t,l=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null,u=o.axis,{min:d,max:h,minDefined:g,maxDefined:p}=o.getUserBounds();if(g){if(r=Math.min(Lt(c,u,d).lo,n?a:Lt(e,u,o.getPixelForValue(d)).lo),l){const t=c.slice(0,r+1).reverse().findIndex(t=>!O(t[s.axis]));r-=Math.max(0,t)}r=_t(r,0,a-1)}if(p){let t=Math.max(Lt(c,o.axis,h,!0).hi+1,n?0:Lt(e,u,o.getPixelForValue(h),!0).hi+1);if(l){const e=c.slice(t-1).findIndex(t=>!O(t[s.axis]));t+=Math.max(0,e)}i=_t(t,r,a)-r}else i=a-r}return{start:r,count:i}}function Zt(t){const{xScale:e,yScale:n,_scaleRanges:a}=t,r={xmin:e.min,xmax:e.max,ymin:n.min,ymax:n.max};if(!a)return t._scaleRanges=r,!0;const i=a.xmin!==e.min||a.xmax!==e.max||a.ymin!==n.min||a.ymax!==n.max;return Object.assign(a,r),i}const Yt=t=>0===t||1===t,Qt=(t,e,n)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*ot/n),$t=(t,e,n)=>Math.pow(2,-10*t)*Math.sin((t-e)*ot/n)+1,Kt={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*ut),easeOutSine:t=>Math.sin(t*ut),easeInOutSine:t=>-.5*(Math.cos(it*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>Yt(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Yt(t)?t:Qt(t,.075,.3),easeOutElastic:t=>Yt(t)?t:$t(t,.075,.3),easeInOutElastic(t){const e=.1125;return Yt(t)?t:t<.5?.5*Qt(2*t,e,.45):.5+.5*$t(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-Kt.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,n=2.75;return t<1/n?e*t*t:t<2/n?e*(t-=1.5/n)*t+.75:t<2.5/n?e*(t-=2.25/n)*t+.9375:e*(t-=2.625/n)*t+.984375},easeInOutBounce:t=>t<.5?.5*Kt.easeInBounce(2*t):.5*Kt.easeOutBounce(2*t-1)+.5};function Xt(t){if(t&&"object"==typeof t){const e=t.toString();return"[object CanvasPattern]"===e||"[object CanvasGradient]"===e}return!1}function Jt(t){return Xt(t)?t:new B(t)}function te(t){return Xt(t)?t:new B(t).saturate(.5).darken(.1).hexString()}const ee=["x","y","borderWidth","radius","tension"],ne=["color","borderColor","backgroundColor"],ae=new Map;function re(t,e,n){return function(t,e){e=e||{};const n=t+JSON.stringify(e);let a=ae.get(n);return a||(a=new Intl.NumberFormat(t,e),ae.set(n,a)),a}(e,n).format(t)}const ie={values:t=>F(t)?t:""+t,numeric(t,e,n){if(0===t)return"0";const a=this.chart.options.locale;let r,i=t;if(n.length>1){const e=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(e<1e-4||e>1e15)&&(r="scientific"),i=function(t,e){let n=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;return Math.abs(n)>=1&&t!==Math.floor(t)&&(n=t-Math.floor(t)),n}(t,n)}const o=gt(Math.abs(i)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:r,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),re(t,a,c)},logarithmic(t,e,n){if(0===t)return"0";const a=n[e].significand||t/Math.pow(10,Math.floor(gt(t)));return[1,2,3,5,10,15].includes(a)||e>.8*n.length?ie.numeric.call(this,t,e,n):""}};var oe={formatters:ie};const se=Object.create(null),ce=Object.create(null);function le(t,e){if(!e)return t;const n=e.split(".");for(let e=0,a=n.length;et.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,e)=>te(e.backgroundColor),this.hoverBorderColor=(t,e)=>te(e.borderColor),this.hoverColor=(t,e)=>te(e.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return ue(this,t,e)}get(t){return le(this,t)}describe(t,e){return ue(ce,t,e)}override(t,e){return ue(se,t,e)}route(t,e,n,a){const r=le(this,t),i=le(this,n),o="_"+e;Object.defineProperties(r,{[o]:{value:r[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[o],e=i[a];return R(t)?Object.assign({},e,t):H(t,e)},set(t){this[o]=t}}})}apply(t){t.forEach(t=>t(this))}}var he=new de({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(t){t.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),t.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),t.set("animations",{colors:{type:"color",properties:ne},numbers:{type:"number",properties:ee}}),t.describe("animations",{_fallback:"animation"}),t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})},function(t){t.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(t){t.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:oe.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),t.route("scale.ticks","color","","color"),t.route("scale.grid","color","","borderColor"),t.route("scale.border","color","","borderColor"),t.route("scale.title","color","","color"),t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t&&"dash"!==t}),t.describe("scales",{_fallback:"scale"}),t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t})}]);function ge(t,e,n,a,r){let i=e[r];return i||(i=e[r]=t.measureText(r).width,n.push(r)),i>a&&(a=i),a}function pe(t,e,n,a){let r=(a=a||{}).data=a.data||{},i=a.garbageCollect=a.garbageCollect||[];a.font!==e&&(r=a.data={},i=a.garbageCollect=[],a.font=e),t.save(),t.font=e;let o=0;const s=n.length;let c,l,u,d,h;for(c=0;cn.length){for(c=0;c0&&t.stroke()}}function be(t,e,n){return n=n||.5,!e||t&&t.x>e.left-n&&t.xe.top-n&&t.y0&&""!==i.strokeColor;let c,l;for(t.save(),t.font=r.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]),O(e.rotation)||t.rotate(e.rotation),e.color&&(t.fillStyle=e.color),e.textAlign&&(t.textAlign=e.textAlign),e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,i),c=0;c+t||0;function Be(t,e){const n={},a=R(e),r=a?Object.keys(e):e,i=R(t)?a?n=>H(t[n],t[e[n]]):e=>t[e]:()=>t;for(const t of r)n[t]=De(i(t));return n}function Le(t){return Be(t,{top:"y",right:"x",bottom:"y",left:"x"})}function Pe(t){return Be(t,["topLeft","topRight","bottomLeft","bottomRight"])}function Oe(t){const e=Le(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function Fe(t,e){t=t||{},e=e||he.font;let n=H(t.size,e.size);"string"==typeof n&&(n=parseInt(n,10));let a=H(t.style,e.style);a&&!(""+a).match(_e)&&(console.warn('Invalid font style specified: "'+a+'"'),a=void 0);const r={family:H(t.family,e.family),lineHeight:Me(H(t.lineHeight,e.lineHeight),n),size:n,style:a,weight:H(t.weight,e.weight),string:""};return r.string=function(t){return!t||O(t.size)||O(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}(r),r}function Re(t,e,n,a){let r,i,o,s=!0;for(r=0,i=t.length;rn&&0===t?0:t+e;return{min:o(a,-Math.abs(i)),max:o(r,i)}}function je(t,e){return Object.assign(Object.create(t),e)}function He(t,e=[""],n,a,r=()=>t[0]){const i=n||t;void 0===a&&(a=Ke("_fallback",t));const o={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:a,_getTarget:r,override:n=>He([n,...t],e,i,a)};return new Proxy(o,{deleteProperty:(e,n)=>(delete e[n],delete e._keys,delete t[0][n],!0),get:(n,a)=>Ue(n,a,()=>function(t,e,n,a){let r;for(const i of e)if(r=Ke(qe(i,t),n),void 0!==r)return We(t,r)?Qe(n,a,t,r):r}(a,e,t,n)),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>Xe(t).includes(e),ownKeys:t=>Xe(t),set(t,e,n){const a=t._storage||(t._storage=r());return t[e]=a[e]=n,delete t._keys,!0}})}function ze(t,e,n,a){const r={_cacheable:!1,_proxy:t,_context:e,_subProxy:n,_stack:new Set,_descriptors:Ve(t,a),setContext:e=>ze(t,e,n,a),override:r=>ze(t.override(r),e,n,a)};return new Proxy(r,{deleteProperty:(e,n)=>(delete e[n],delete t[n],!0),get:(t,e,n)=>Ue(t,e,()=>function(t,e,n){const{_proxy:a,_context:r,_subProxy:i,_descriptors:o}=t;let s=a[e];return nt(s)&&o.isScriptable(e)&&(s=function(t,e,n,a){const{_proxy:r,_context:i,_subProxy:o,_stack:s}=n;if(s.has(t))throw new Error("Recursion detected: "+Array.from(s).join("->")+"->"+t);s.add(t);let c=e(i,o||a);return s.delete(t),We(t,c)&&(c=Qe(r._scopes,r,t,c)),c}(e,s,t,n)),F(s)&&s.length&&(s=function(t,e,n,a){const{_proxy:r,_context:i,_subProxy:o,_descriptors:s}=n;if(void 0!==i.index&&a(t))return e[i.index%e.length];if(R(e[0])){const n=e,a=r._scopes.filter(t=>t!==n);e=[];for(const c of n){const n=Qe(a,r,t,c);e.push(ze(n,i,o&&o[t],s))}}return e}(e,s,t,o.isIndexable)),We(e,s)&&(s=ze(s,r,i&&i[e],o)),s}(t,e,n)),getOwnPropertyDescriptor:(e,n)=>e._descriptors.allKeys?Reflect.has(t,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,n),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,n)=>Reflect.has(t,n),ownKeys:()=>Reflect.ownKeys(t),set:(e,n,a)=>(t[n]=a,delete e[n],!0)})}function Ve(t,e={scriptable:!0,indexable:!0}){const{_scriptable:n=e.scriptable,_indexable:a=e.indexable,_allKeys:r=e.allKeys}=t;return{allKeys:r,scriptable:n,indexable:a,isScriptable:nt(n)?n:()=>n,isIndexable:nt(a)?a:()=>a}}const qe=(t,e)=>t?t+tt(e):e,We=(t,e)=>R(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function Ue(t,e,n){if(Object.prototype.hasOwnProperty.call(t,e)||"constructor"===e)return t[e];const a=n();return t[e]=a,a}function Ge(t,e,n){return nt(t)?t(e,n):t}const Ze=(t,e)=>!0===t?e:"string"==typeof t?J(e,t):void 0;function Ye(t,e,n,a,r){for(const i of e){const e=Ze(n,i);if(e){t.add(e);const i=Ge(e._fallback,n,r);if(void 0!==i&&i!==n&&i!==a)return i}else if(!1===e&&void 0!==a&&n!==a)return null}return!1}function Qe(t,e,n,a){const r=e._rootScopes,i=Ge(e._fallback,n,a),o=[...t,...r],s=new Set;s.add(a);let c=$e(s,o,n,i||n,a);return null!==c&&(void 0===i||i===n||(c=$e(s,o,i,c,a),null!==c))&&He(Array.from(s),[""],r,i,()=>function(t,e,n){const a=t._getTarget();e in a||(a[e]={});const r=a[e];return F(r)&&R(n)?n:r||{}}(e,n,a))}function $e(t,e,n,a,r){for(;n;)n=Ye(t,e,n,a,r);return n}function Ke(t,e){for(const n of e){if(!n)continue;const e=n[t];if(void 0!==e)return e}}function Xe(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const n of t)for(const t of Object.keys(n).filter(t=>!t.startsWith("_")))e.add(t);return Array.from(e)}(t._scopes)),e}function Je(t,e,n,a){const{iScale:r}=t,{key:i="r"}=this._parsing,o=new Array(a);let s,c,l,u;for(s=0,c=a;se"x"===t?"y":"x";function an(t,e,n,a){const r=t.skip?e:t,i=e,o=n.skip?e:n,s=St(i,r),c=St(o,i);let l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;const d=a*l,h=a*u;return{previous:{x:i.x-d*(o.x-r.x),y:i.y-d*(o.y-r.y)},next:{x:i.x+h*(o.x-r.x),y:i.y+h*(o.y-r.y)}}}function rn(t,e,n){return Math.max(Math.min(t,n),e)}function on(t,e,n,a,r){let i,o,s,c;if(e.spanGaps&&(t=t.filter(t=>!t.skip)),"monotone"===e.cubicInterpolationMode)!function(t,e="x"){const n=nn(e),a=t.length,r=Array(a).fill(0),i=Array(a);let o,s,c,l=en(t,0);for(o=0;ot.ownerDocument.defaultView.getComputedStyle(t,null),dn=["top","right","bottom","left"];function hn(t,e,n){const a={};n=n?"-"+n:"";for(let r=0;r<4;r++){const i=dn[r];a[i]=parseFloat(t[e+"-"+i+n])||0}return a.width=a.left+a.right,a.height=a.top+a.bottom,a}function gn(t,e){if("native"in t)return t;const{canvas:n,currentDevicePixelRatio:a}=e,r=un(n),i="border-box"===r.boxSizing,o=hn(r,"padding"),s=hn(r,"border","width"),{x:c,y:l,box:u}=function(t,e){const n=t.touches,a=n&&n.length?n[0]:t,{offsetX:r,offsetY:i}=a;let o,s,c=!1;if(((t,e,n)=>(t>0||e>0)&&(!n||!n.shadowRoot))(r,i,t.target))o=r,s=i;else{const t=e.getBoundingClientRect();o=a.clientX-t.left,s=a.clientY-t.top,c=!0}return{x:o,y:s,box:c}}(t,n),d=o.left+(u&&s.left),h=o.top+(u&&s.top);let{width:g,height:p}=e;return i&&(g-=o.width+s.width,p-=o.height+s.height),{x:Math.round((c-d)/g*n.width/a),y:Math.round((l-h)/p*n.height/a)}}const pn=t=>Math.round(10*t)/10;function fn(t,e,n,a){const r=un(t),i=hn(r,"margin"),o=ln(r.maxWidth,t,"clientWidth")||ct,s=ln(r.maxHeight,t,"clientHeight")||ct,c=function(t,e,n){let a,r;if(void 0===e||void 0===n){const i=t&&cn(t);if(i){const t=i.getBoundingClientRect(),o=un(i),s=hn(o,"border","width"),c=hn(o,"padding");e=t.width-c.width-s.width,n=t.height-c.height-s.height,a=ln(o.maxWidth,i,"clientWidth"),r=ln(o.maxHeight,i,"clientHeight")}else e=t.clientWidth,n=t.clientHeight}return{width:e,height:n,maxWidth:a||ct,maxHeight:r||ct}}(t,e,n);let{width:l,height:u}=c;if("content-box"===r.boxSizing){const t=hn(r,"border","width"),e=hn(r,"padding");l-=e.width+t.width,u-=e.height+t.height}return l=Math.max(0,l-i.width),u=Math.max(0,a?l/a:u-i.height),l=pn(Math.min(l,o,c.maxWidth)),u=pn(Math.min(u,s,c.maxHeight)),l&&!u&&(u=pn(l/2)),(void 0!==e||void 0!==n)&&a&&c.height&&u>c.height&&(u=c.height,l=pn(Math.floor(u*a))),{width:l,height:u}}function mn(t,e,n){const a=e||1,r=Math.floor(t.height*a),i=Math.floor(t.width*a);t.height=Math.floor(t.height),t.width=Math.floor(t.width);const o=t.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${t.height}px`,o.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==a||o.height!==r||o.width!==i)&&(t.currentDevicePixelRatio=a,o.height=r,o.width=i,t.ctx.setTransform(a,0,0,a,0,0),!0)}const vn=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};sn()&&(window.addEventListener("test",null,e),window.removeEventListener("test",null,e))}catch(t){}return t}();function yn(t,e){const n=function(t,e){return un(t).getPropertyValue(e)}(t,e),a=n&&n.match(/^(\d+)(\.\d+)?px$/);return a?+a[1]:void 0}function bn(t,e,n,a){return{x:t.x+n*(e.x-t.x),y:t.y+n*(e.y-t.y)}}function wn(t,e,n,a){return{x:t.x+n*(e.x-t.x),y:"middle"===a?n<.5?t.y:e.y:"after"===a?n<1?t.y:e.y:n>0?e.y:t.y}}function Tn(t,e,n,a){const r={x:t.cp2x,y:t.cp2y},i={x:e.cp1x,y:e.cp1y},o=bn(t,r,n),s=bn(r,i,n),c=bn(i,e,n),l=bn(o,s,n),u=bn(s,c,n);return bn(l,u,n)}function kn(t,e,n){return t?function(t,e){return{x:n=>t+t+e-n,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,n):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function En(t,e){let n,a;"ltr"!==e&&"rtl"!==e||(n=t.canvas.style,a=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",e,"important"),t.prevTextDirection=a)}function xn(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Sn(t){return"angle"===t?{between:At,compare:Ct,normalize:It}:{between:Dt,compare:(t,e)=>t-e,normalize:t=>t}}function Cn({start:t,end:e,count:n,loop:a,style:r}){return{start:t%n,end:e%n,loop:a&&(e-t+1)%n==0,style:r}}function In(t,e,n){if(!n)return[t];const{property:a,start:r,end:i}=n,o=e.length,{compare:s,between:c,normalize:l}=Sn(a),{start:u,end:d,loop:h,style:g}=function(t,e,n){const{property:a,start:r,end:i}=n,{between:o,normalize:s}=Sn(a),c=e.length;let l,u,{start:d,end:h,loop:g}=t;if(g){for(d+=c,h+=c,l=0,u=c;ly||c(r,v,f)&&0!==s(r,v),T=()=>!y||0===s(i,f)||c(i,v,f);for(let t=u,n=u;t<=d;++t)m=e[t%o],m.skip||(f=l(m[a]),f!==v&&(y=c(f,r,i),null===b&&w()&&(b=0===s(f,r)?t:n),null!==b&&T()&&(p.push(Cn({start:b,end:t,loop:h,count:o,style:g})),b=null),n=t,v=f));return null!==b&&p.push(Cn({start:b,end:d,loop:h,count:o,style:g})),p}function An(t,e){const n=[],a=t.segments;for(let r=0;rr&&t[i%e].skip;)i--;return i%=e,{start:r,end:i}}(n,r,i,a);return Mn(t,!0===a?[{start:o,end:s,loop:i}]:function(t,e,n,a){const r=t.length,i=[];let o,s=e,c=t[e];for(o=e+1;o<=n;++o){const n=t[o%r];n.skip||n.stop?c.skip||(a=!1,i.push({start:e%r,end:(o-1)%r,loop:a}),e=s=n.stop?o:null):(s=o,c.skip&&(e=o)),c=n}return null!==s&&i.push({start:e%r,end:s%r,loop:a}),i}(n,o,s{var e;return()=>{if(t){var n=t;t=0,e={exports:{}},n.call(e.exports,e,e.exports)}return e.exports}},n.d=(t,e)=>{if(Array.isArray(e))for(var a=0;aPromise.all(Object.keys(n.f).reduce((e,a)=>(n.f[a](t,e),e),[])),n.u=t=>"budget-"+{135:"bank-sync",224:"assets",528:"reports",552:"rules",597:"projects",754:"pensions",836:"import",887:"bills",894:"exchange-rates",904:"forecast"}[t]+".js?v="+{135:"9b01859d",224:"017e9194",528:"988f3c44",552:"5084efc7",597:"cb711a66",754:"d318cd69",836:"04161ed5",887:"0334e40d",894:"adb0f257",904:"4da3abd1"}[t],n.miniCssF=t=>{},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{const t={},e="budget:";n.l=(a,r,i,o)=>{if(t[a])return void t[a].push(r);let s,c;if(void 0!==i){const t=document.getElementsByTagName("script");for(var l=0;l{s.onerror=s.onload=null,clearTimeout(d);const r=t[a];if(delete t[a],s.parentNode?.removeChild(s),r?.forEach(t=>t(n)),e)return e(n)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),c&&document.head.appendChild(s)}})(),n.r=t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{let t;n.g.importScripts&&(t=n.g.location+"");const e=n.g.document;if(!t&&e&&("SCRIPT"===e.currentScript?.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){const n=e.getElementsByTagName("script");if(n.length){let e=n.length-1;for(;e>-1&&(!t||!/^https?:/.test(t));)t=n[e--].src}}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:|[?#].*$/g,"").replace(/\/[^/]+$/,"/"),n.p=t})(),(()=>{const t={62:0};n.f.j=(e,a)=>{let r=n.o(t,e)?t[e]:void 0;if(0!==r)if(r)a.push(r[2]);else{const i=new Promise((n,a)=>r=t[e]=[n,a]);a.push(r[2]=i);const o=new Error,s=a=>{if(n.o(t,e)&&(r=t[e],0!==r&&(t[e]=void 0),r)){const t=a&&("load"===a.type?"missing":a.type),n=a&&a.target&&a.target.src;o.message="Loading chunk "+e+" failed.\n("+t+": "+n+")",o.name="ChunkLoadError",o.type=t,o.request=n,o.event=a,r[1](o)}};n.l(n.p+n.u(e),s,"chunk-"+e,e)}};const e=(e,a)=>{let[r,i,o]=a;var s,c,l=0;if(r.some(e=>0!==t[e])){for(s in i)n.o(i,s)&&(n.m[s]=i[s]);o&&o(n)}for(e&&e(a);l0?e:void 0)}}return t}();return i&&!r?(o+=`/index.php/apps/${t}`,e&&(o+=`/${encodeURI(e)}`),"index.php"!==n&&(o+=`/${n}`)):i||r?("settings"!==t&&"core"!==t&&"search"!==t||"ajax"!==e||(o+="/index.php"),t&&(o+=`/${t}`),e&&(o+=`/${e}`),o+=`/${n}`):(o=function(t){return a(),(window._oc_appswebroots??{})[t]??""}(t),e&&(o+=`/${e}/`),"/"!==o.at(-1)&&(o+="/"),o+=n),o}("budget","","js/"),n.nc=btoa(OC.requestToken);var r=n(692),i=n(746),o=n(993),s=n(476),c=n(568),l=n(557),u=n(964);function d(t,e){var n=document.body||document.documentElement;return getComputedStyle(n).getPropertyValue(t).trim()||e}function h(t){t.defaults.color=d("--color-text-maxcontrast","#6b6b6b"),t.defaults.borderColor=d("--color-border","#dbdbdb")}var g=n(397);function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n1&&void 0!==arguments[1]&&arguments[1],n=t.querySelector(".header-menu-toggle"),a=t.querySelector(".header-menu-list");a&&!a.hidden&&(a.hidden=!0,null==n||n.setAttribute("aria-expanded","false"),e&&(null==n||n.focus()))}function m(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;document.querySelectorAll(".header-menu").forEach(function(e){e!==t&&f(e)})}function v(t){return function(t){return function(t){if(Array.isArray(t))return p(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return p(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t.querySelectorAll("button:not([disabled])")).filter(function(t){return null!==t.offsetParent})}var y=[".account-card",".asset-card",".pension-card",".contact-card",".category-item",".rules-group-header","th.sortable"].join(", "),b=n(17),w=n(119),T=n(688),k=n(930),E=new WeakMap;function x(t,e){if(t){var n=t.closest(".table-scroll");n&&E.get(t)!==e&&(n.scrollTop=0),E.set(t,e)}}function S(t){return S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},S(t)}function C(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function I(t){for(var e=1;e'.concat((0,s.ZD)(t),"")}var M={escape:!1};function D(t){var e=t.vendor||t.description||t.billName||t.originalDescription;return e?(0,s.ZD)(e):(0,i.Tl)("budget","(unnamed)")}function B(t,e,n,a){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=t.map(function(t){return function(t,e){var n=Number(t.duplicateId);return'
\n \n ').concat(e(t.amount),'\n ').concat((0,s.ZD)(t.date),'\n ').concat(L(t,e),'\n \n
")}(I(I({},t),{},{selected:n.has(Number(t.duplicateId))}),a)}).join(""),c=t.length>0?'

'.concat((0,i.Tl)("budget","Only ticked rows are deleted. Rows that come ticked are bill payments the app recorded that an imported bank transaction records as well. The others only look like duplicates and may be real payments: check them in the account first, and tick only the ones you are sure about.")," ").concat((0,i.Tl)("budget","Ignore a row you have checked and want to keep, and it is no longer listed."),"

"):'

'.concat((0,i.Tl)("budget","Nothing left to check."),"

"),l=e.length>0?'
\n ").concat((0,i.zw)("budget","%n ignored row","%n ignored rows",e.length),"\n ").concat(e.map(function(t){return function(t,e){return'
\n '.concat(D(t),'\n ').concat(e(t.amount),'\n ').concat((0,s.ZD)(t.date),'\n ').concat(L(t,e),'\n \n
")}(t,a)}).join(""),"\n
"):"";return c+o+l}function L(t,e){var n;return n="same_occurrence"===t.reason?function(t){var e=Number(t.amount),n=Number(t.originalAmount);return Number.isFinite(e)&&Number.isFinite(n)&&Math.abs(e-n)>=.005}(t)?(0,i.Tl)("budget","Looks like a second payment for {occurrence} (other payment of {amount} on {date})",{occurrence:_(t.occurrence),amount:_(e(t.originalAmount)),date:_(t.originalDate)},void 0,M):(0,i.Tl)("budget","Looks like a second payment for {occurrence} (other payment on {date})",{occurrence:_(t.occurrence),date:_(t.originalDate)},void 0,M):"deleted_bill"===t.reason?(0,i.Tl)("budget","Looks like a second payment of {bill} (other payment on {date})",{bill:(0,s.ZD)(t.billName||t.vendor||(0,i.Tl)("budget","(unnamed)")),date:_(t.originalDate)},void 0,M):(0,i.Tl)("budget","Also recorded as {description} on {date}",{description:(0,s.ZD)(t.originalDescription||(0,i.Tl)("budget","(unnamed)")),date:_(t.originalDate)},void 0,M),t.originalReconciled&&(n+=" (".concat((0,i.Tl)("budget","reconciled"),")")),t.removesDeposit&&(n+=" ".concat((0,i.Tl)("budget","The other side of the transfer is removed with it."))),n}function P(t){var e=[];return t.duplicateTransactions&&e.push((0,i.Tl)("budget","{count} duplicate transactions removed",{count:t.duplicateTransactions.deleted})),t.stuckBills&&e.push((0,i.Tl)("budget","{count} bill due dates fixed",{count:t.stuckBills.fixed})),t.paidOneTimeBills&&e.push((0,i.Tl)("budget","{count} one-time bills deactivated",{count:t.paidOneTimeBills.fixed})),t.stuckIncome&&e.push((0,i.zw)("budget","%n income moved on to its next date","%n incomes moved on to their next date",t.stuckIncome.fixed)),t.futureClearedTransactions&&e.push((0,i.Tl)("budget","{count} future transactions set to scheduled",{count:t.futureClearedTransactions.fixed})),t.splitParentCategories&&e.push((0,i.Tl)("budget","{count} split transactions had a stray category removed",{count:t.splitParentCategories.fixed})),t.liabilitySignFlipped&&(e.push((0,i.Tl)("budget","{count} debts re-recorded as owed",{count:t.liabilitySignFlipped.fixed})),t.liabilitySignFlipped.confirmed>0&&e.push((0,i.Tl)("budget","{count} confirmed as genuine credits",{count:t.liabilitySignFlipped.confirmed}))),t.balanceDrift&&e.push((0,i.Tl)("budget","{count} account balances corrected",{count:t.balanceDrift.updated})),(0,i.Tl)("budget","Repair complete: {details}",{details:e.join(", ")})}var O=".modal, .budget-modal-overlay",F=0;function R(t){return!!t&&t.isConnected&&"none"!==getComputedStyle(t).display}function N(){return Array.from(document.querySelectorAll(O)).filter(R)}function j(t){var e=t.querySelector(".cancel-btn, .close-btn, .modal-close, [data-dismiss]");e?e.click():t.classList.contains("budget-modal-overlay")?t.remove():t.style.display="none"}function H(){N().reverse().forEach(j)}var z="scrolled-away";function V(t){return V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},V(t)}function q(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:document,n=new WeakMap;e.addEventListener("scroll",function(a){var r,i=a.target===e?e.scrollingElement:a.target;if(i&&(i===e.scrollingElement||"app-content"===i.id)){var o=i.scrollTop,s=null!==(r=n.get(i))&&void 0!==r?r:0;if(o<=50||os+4)||t.classList.contains("nav-open"))return;t.classList.add(z)}n.set(i,o)}},{capture:!0,passive:!0})}(r)}}},{key:"openMobileNavigation",value:function(){var t=document.getElementById("app-navigation"),e=document.getElementById("budget-nav-toggle-wrapper"),n=document.getElementById("nav-backdrop"),a=document.getElementById("nav-toggle-icon-open"),r=document.getElementById("nav-toggle-icon-close");t&&t.classList.add("nav-open"),e&&e.classList.add("nav-open"),n&&n.classList.add("active"),a&&(a.style.display="none"),r&&(r.style.display="")}},{key:"closeMobileNavigation",value:function(){var t=document.getElementById("app-navigation"),e=document.getElementById("budget-nav-toggle-wrapper"),n=document.getElementById("nav-backdrop"),a=document.getElementById("nav-toggle-icon-open"),r=document.getElementById("nav-toggle-icon-close");t&&t.classList.remove("nav-open"),e&&e.classList.remove("nav-open"),n&&n.classList.remove("active"),a&&(a.style.display=""),r&&(r.style.display="none")}},{key:"showView",value:function(e){var n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).history,a=void 0===n||n;document.querySelectorAll(".view").forEach(function(t){t.classList.remove("active"),t.style.display=""});var r=document.getElementById("".concat(e,"-view"));if(r){r.classList.add("active"),this.app.currentView=e,this.setActiveNav(e),"function"==typeof this.app._updateHelpContent&&this.app._updateHelpContent();var i=t.VIEW_LOADERS[e];i&&this.runLoader(i),a&&this.syncHistory(e)}}},{key:"setActiveNav",value:function(t){document.querySelectorAll(".app-navigation-entry").forEach(function(e){e.classList.toggle("active",e.dataset.id===t)})}},{key:"viewFromHash",value:function(){var t=window.location.hash.match(/^#\/?([a-z-]+)/);return t?t[1]:null}},{key:"syncHistory",value:function(t){var e={view:t};(window.history.state&&window.history.state.view||this.viewFromHash())===t?window.history.replaceState(e,"","#".concat(t)):window.history.pushState(e,"","#".concat(t))}},{key:"reloadCurrentView",value:function(){var e=this.app.currentView;if("settings"!==e){var n=t.VIEW_LOADERS[e];n&&this.runLoader(n)}}},{key:"runLoader",value:function(t){var e=this.app[t]();e&&"function"==typeof e.catch&&e.catch(function(e){return console.error("".concat(t," failed:"),e)})}}],a=[{key:"deepLink",value:function(e){var n=(e||"").match(/^#\/?([a-z-]+)(?:\?(.*))?$/);if(!n||!t.VIEW_LOADERS[n[1]])return null;var a=new URLSearchParams(n[2]||""),r=a.get("id");return{view:n[1],search:a.get("search"),transactionId:r&&/^[1-9]\d*$/.test(r)?parseInt(r,10):null}}}],n&&q(e.prototype,n),a&&q(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,a}();function Q(t){return Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Q(t)}function $(t,e){if(t){if("string"==typeof t)return K(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?K(t,e):void 0}}function K(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n0||t.offsetHeight>0||t===document.activeElement})}},{key:"_observeModals",value:function(){var t=this,e=function(e){if(e instanceof Element&&e.matches(O)){var n=e.isConnected&&"none"!==getComputedStyle(e).display;n&&"1"!==e.dataset.kbdOpen?(e.dataset.kbdOpen="1",function(t){var e=t;if(e.getAttribute("role")||e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-hidden","false"),!e.getAttribute("aria-labelledby")&&!e.getAttribute("aria-label")){var n=e.querySelector("h1, h2, h3, h4");n&&(n.id||(n.id="budget-modal-label-".concat(++F)),e.setAttribute("aria-labelledby",n.id))}e.querySelectorAll(".close-btn, .modal-close").forEach(function(t){t.getAttribute("aria-label")||t.setAttribute("aria-label",t.getAttribute("title")||(0,i.Tl)("budget","Close"))})}(e),t._onModalOpen(e)):n||"1"!==e.dataset.kbdOpen||(e.dataset.kbdOpen="",function(t){t.setAttribute("aria-hidden","true")}(e),t._onModalClose())}},n=new MutationObserver(function(t){var n,a=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=$(t))){e&&(t=e);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i=!0,o=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){o=!0,r=t},f:function(){try{i||null==e.return||e.return()}finally{if(o)throw r}}}}(t);try{for(a.s();!(n=a.n()).done;){var r=n.value;"attributes"!==r.type?(r.addedNodes.forEach(e),r.removedNodes.forEach(e)):e(r.target)}}catch(t){a.e(t)}finally{a.f()}});n.observe(document.body,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0})}},{key:"_onModalOpen",value:function(t){if(this._lastFocus=document.activeElement,!t.contains(document.activeElement)){var e=t.querySelector('input:not([type=hidden]):not([disabled]):not(.flatpickr-input):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), textarea:not([disabled]):not([tabindex="-1"])')||t.querySelector("button.primary");e&&setTimeout(function(){if("none"!==getComputedStyle(t).display&&!t.contains(document.activeElement)&&(e.focus(),"function"==typeof e.select&&"INPUT"===e.tagName))try{e.select()}catch(t){}},0)}}},{key:"_onModalClose",value:function(){var t=this._lastFocus;if(this._lastFocus=null,t&&document.body.contains(t)){var e=t.closest&&t.closest(O);if(!e||"none"!==getComputedStyle(e).display)try{t.focus()}catch(t){}}}},{key:"_focusSearch",value:function(){var t=document.querySelector(".view.active"),e=t&&t.querySelector('input[type="search"], input[id*="search" i], input[placeholder*="search" i]');e&&(e.offsetWidth>0||e.offsetHeight>0)||(e=document.getElementById("app-navigation-search-input")),e&&(e.focus(),"function"==typeof e.select&&e.select())}},{key:"_visibleRows",value:function(){return Array.from(document.querySelectorAll("#transactions-table tbody tr.transaction-row")).filter(function(t){return null!==t.offsetParent})}},{key:"_cursorIndex",value:function(t){var e=this;if(null!=this._cursorId){var n=t.findIndex(function(t){return t.dataset.transactionId===String(e._cursorId)});if(-1!==n)return n}return t.findIndex(function(t){return t.classList.contains("kbd-cursor")})}},{key:"_setCursor",value:function(t,e){t.forEach(function(t){return t.classList.remove("kbd-cursor")});var n=t[e];n?(n.classList.add("kbd-cursor"),this._cursorId=n.dataset.transactionId,n.scrollIntoView({block:"nearest"})):this._cursorId=null}},{key:"_handleListKey",value:function(t){if("Enter"===t.key){var e=t.target;if(e&&("BUTTON"===e.tagName||"A"===e.tagName||"SUMMARY"===e.tagName||"button"===e.getAttribute("role")))return}var n=this._visibleRows();if(n.length){var a=this._cursorIndex(n);switch(t.key){case"j":this._setCursor(n,a<0?0:Math.min(n.length-1,a+1)),t.preventDefault();break;case"k":this._setCursor(n,a<0?0:Math.max(0,a-1)),t.preventDefault();break;case"e":case"Enter":var r;a>=0&&(null===(r=n[a].querySelector(".transaction-edit-btn"))||void 0===r||r.click(),t.preventDefault());break;case"x":var i;a>=0&&(null===(i=n[a].querySelector(".transaction-checkbox"))||void 0===i||i.click(),t.preventDefault())}}}},{key:"openShortcuts",value:function(){this._openOverlay()}},{key:"_toggleOverlay",value:function(){this._overlay&&"none"!==this._overlay.style.display?this._closeOverlay():this._openOverlay()}},{key:"_openOverlay",value:function(){this._overlay||(this._overlay=this._buildOverlay()),this._overlay.style.display="flex"}},{key:"_closeOverlay",value:function(){this._overlay&&(this._overlay.style.display="none")}},{key:"_buildOverlay",value:function(){var t=this,e=[{title:(0,i.Tl)("budget","Global"),rows:[[["/"],(0,i.Tl)("budget","Focus search")],[["Ctrl","K"],(0,i.Tl)("budget","Focus search")],[["?"],(0,i.Tl)("budget","Show this help")],[["Esc"],(0,i.Tl)("budget","Close dialog / this help")],[["g","then","key"],(0,i.Tl)("budget","Go to a page (see below)")]]},{title:(0,i.Tl)("budget","Go to (press g, then)"),wide:!0,rows:[[["d"],(0,i.Tl)("budget","Dashboard")],[["a"],(0,i.Tl)("budget","Accounts")],[["t"],(0,i.Tl)("budget","Transactions")],[["c"],(0,i.Tl)("budget","Categories")],[["g"],(0,i.Tl)("budget","Tags")],[["b"],(0,i.Tl)("budget","Budget")],[["i"],(0,i.Tl)("budget","Income")],[["l"],(0,i.Tl)("budget","Bills")],[["n"],(0,i.Tl)("budget","Transfers")],[["v"],(0,i.Tl)("budget","Savings Goals")],[["y"],(0,i.Tl)("budget","Debt Payoff")],[["p"],(0,i.Tl)("budget","Pensions")],[["e"],(0,i.Tl)("budget","Assets")],[["h"],(0,i.Tl)("budget","Shared Expenses")],[["f"],(0,i.Tl)("budget","Forecast")],[["r"],(0,i.Tl)("budget","Reports")],[["m"],(0,i.Tl)("budget","Import")],[["u"],(0,i.Tl)("budget","Rules")],[["x"],(0,i.Tl)("budget","Exchange Rates")],[["w"],(0,i.Tl)("budget","Sharing")],[["k"],(0,i.Tl)("budget","Bank Sync")],[["s"],(0,i.Tl)("budget","Settings")]]},{title:(0,i.Tl)("budget","Transactions list"),rows:[[["j","/","k"],(0,i.Tl)("budget","Move row cursor down / up")],[["e"],(0,i.Tl)("budget","Edit the current row")],[["Enter"],(0,i.Tl)("budget","Edit the current row")],[["x"],(0,i.Tl)("budget","Select / deselect the current row")]]},{title:(0,i.Tl)("budget","Reordering"),rows:[[["Alt","↑","/","↓"],(0,i.Tl)("budget","Move a focused category or list column up / down")],[["Alt","→"],(0,i.Tl)("budget","Make a focused category a subcategory of the one above")],[["Alt","←"],(0,i.Tl)("budget","Move a focused subcategory out one level")]]}],n=document.createElement("div");n.id="kbd-shortcuts-overlay",n.className="kbd-shortcuts-overlay",n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label",(0,i.Tl)("budget","Keyboard shortcuts")),n.style.display="none";var a=e.map(function(t){return'\n
\n

').concat(t.title,"

\n
\n ").concat(t.rows.map(function(t){var e=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,r,i,o,s=[],c=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(s.push(a.value),s.length!==e);c=!0);}catch(t){l=!0,r=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||$(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),n=e[0],a=e[1];return'\n
\n
'.concat(n.map(function(t){return"then"===t||"/"===t?''.concat(t,""):"".concat(t,"")}).join(" "),"
\n
").concat(a,"
\n
")}).join(""),"\n
\n
")}).join("");return n.innerHTML='\n
\n
\n

'.concat((0,i.Tl)("budget","Keyboard shortcuts"),'

\n \n
\n
').concat(a,"
\n
"),n.addEventListener("click",function(e){(e.target===n||e.target.closest(".kbd-shortcuts-close"))&&t._closeOverlay()}),document.body.appendChild(n),n}}])}(),nt={hero:{netWorth:{id:"hero-net-worth",name:(0,i.Tl)("budget","Net Worth"),defaultSize:"hero",defaultVisible:!0,settingsSchema:{}},income:{id:"hero-income",name:(0,i.Tl)("budget","Income This Month"),defaultSize:"hero",defaultVisible:!0,settingsSchema:{}},expenses:{id:"hero-expenses",name:(0,i.Tl)("budget","Expenses This Month"),defaultSize:"hero",defaultVisible:!0,settingsSchema:{}},savings:{id:"hero-savings",name:(0,i.Tl)("budget","Net Savings"),defaultSize:"hero",defaultVisible:!0,settingsSchema:{}},pension:{id:"hero-pension",name:(0,i.Tl)("budget","Pension Worth"),defaultSize:"hero",defaultVisible:!0,settingsSchema:{}},assets:{id:"hero-assets",name:(0,i.Tl)("budget","Assets Worth"),defaultSize:"hero",defaultVisible:!0,settingsSchema:{}},savingsRate:{id:"hero-savings-rate",name:(0,i.Tl)("budget","Savings Rate"),defaultSize:"hero",defaultVisible:!1,category:"insights",settingsSchema:{}},cashFlow:{id:"hero-cash-flow",name:(0,i.Tl)("budget","Cash Flow"),defaultSize:"hero",defaultVisible:!1,category:"insights",settingsSchema:{}},budgetRemaining:{id:"hero-budget-remaining",name:(0,i.Tl)("budget","Budget Remaining"),defaultSize:"hero",defaultVisible:!1,category:"budgeting",settingsSchema:{}},budgetHealth:{id:"hero-budget-health",name:(0,i.Tl)("budget","Budget Health"),defaultSize:"hero",defaultVisible:!1,category:"budgeting",settingsSchema:{}},accountIncome:{id:"hero-account-income",name:(0,i.Tl)("budget","Account Income"),defaultSize:"hero",defaultVisible:!1,category:"accounts",settingsSchema:{}},accountExpenses:{id:"hero-account-expenses",name:(0,i.Tl)("budget","Account Expenses"),defaultSize:"hero",defaultVisible:!1,category:"accounts",settingsSchema:{}},uncategorizedCount:{id:"hero-uncategorized",name:(0,i.Tl)("budget","Uncategorized"),defaultSize:"hero",defaultVisible:!1,category:"alerts",settingsSchema:{}},lowBalanceAlert:{id:"hero-low-balance",name:(0,i.Tl)("budget","Low Balance Alert"),defaultSize:"hero",defaultVisible:!1,category:"alerts",settingsSchema:{}},burnRate:{id:"hero-burn-rate",name:(0,i.Tl)("budget","Burn Rate"),defaultSize:"hero",defaultVisible:!1,category:"forecasting",settingsSchema:{}},daysUntilDebtFree:{id:"hero-debt-free",name:(0,i.Tl)("budget","Days Until Debt Free"),defaultSize:"hero",defaultVisible:!1,category:"debts",settingsSchema:{displayFormat:["compact","full"],showChangeIndicator:!0}}},widgets:{trendChart:{id:"trend-chart-card",name:(0,i.Tl)("budget","Income vs Expenses"),defaultSize:"l",allowedSizes:["s","m","l"],defaultVisible:!0,settingsSchema:{dateRange:!0,accountSelector:!0,excludeShared:!0,showLegend:!0,chartType:["bar","line"]}},spendingChart:{id:"spending-chart-card",name:(0,i.Tl)("budget","Spending by Category"),defaultSize:"m",allowedSizes:["s","m","l"],defaultVisible:!0,settingsSchema:{dateRange:!0,shortRange:!0,budgetPeriodRange:!0,accountSelector:!0,excludeShared:!0,showLegend:!0,chartType:["doughnut","bar"],topLevelOnly:!0,categoryPicker:!0}},netWorthHistory:{id:"net-worth-history-card",name:(0,i.Tl)("budget","Net Worth History"),defaultSize:"m",allowedSizes:["s","m","l"],defaultVisible:!0,settingsSchema:{dateRange:!0,accountSelector:!0,showLegend:!0}},assetValueHistory:{id:"asset-value-history-card",name:(0,i.Tl)("budget","Asset Value History"),defaultSize:"m",allowedSizes:["s","m","l"],defaultVisible:!0,settingsSchema:{dateRange:!0,accountSelector:!0,showLegend:!0}},recentTransactions:{id:"recent-transactions-card",name:(0,i.Tl)("budget","Recent Transactions"),defaultSize:"m",allowedSizes:["s","m","l"],defaultVisible:!0,settingsSchema:{accountSelector:!0,excludeShared:!0,rowCount:{min:3,max:20,default:5}}},accounts:{id:"accounts-card",name:(0,i.Tl)("budget","Accounts"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!0,settingsSchema:{}},budgetAlerts:{id:"budget-alerts-card",name:(0,i.Tl)("budget","Budget Alerts"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!0,settingsSchema:{}},upcomingBills:{id:"upcoming-bills-card",name:(0,i.Tl)("budget","Upcoming Bills"),defaultSize:"s",allowedSizes:["s","m","l"],defaultVisible:!0,settingsSchema:{forwardHorizon:!0,accountSelector:!0,excludeSharedBills:!0,showAllOverdue:!0,rowCount:{min:3,max:20,default:5}}},budgetProgress:{id:"budget-progress-card",name:(0,i.Tl)("budget","Budget Progress"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!0,settingsSchema:{dateRange:!0,shortRange:!0,budgetPeriodRange:!0,accountSelector:!0,excludeShared:!0,topLevelOnly:!0}},savingsGoals:{id:"savings-goals-card",name:(0,i.Tl)("budget","Savings Goals"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!0,settingsSchema:{}},projects:{id:"projects-card",name:(0,i.Tl)("budget","Projects"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!0,settingsSchema:{}},debtPayoff:{id:"debt-payoff-card",name:(0,i.Tl)("budget","Debt Payoff"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!0,settingsSchema:{}},debtChart:{id:"debt-chart-card",name:(0,i.Tl)("budget","Debt Payoff Chart"),defaultSize:"m",allowedSizes:["s","m","l"],defaultVisible:!1,category:"debts",settingsSchema:{accountSelector:!0,showLegend:!0}},debtProgress:{id:"debt-progress-card",name:(0,i.Tl)("budget","Debt Progress"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"debts",settingsSchema:{}},topCategories:{id:"top-categories-card",name:(0,i.Tl)("budget","Top Spending Categories"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"insights",settingsSchema:{dateRange:!0,shortRange:!0,budgetPeriodRange:!0,accountSelector:!0,excludeShared:!0,topLevelOnly:!0}},accountPerformance:{id:"account-performance-card",name:(0,i.Tl)("budget","Account Performance"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"insights",settingsSchema:{}},budgetBreakdown:{id:"budget-breakdown-card",name:(0,i.Tl)("budget","Budget Breakdown"),defaultSize:"hero",defaultVisible:!1,category:"budgeting",settingsSchema:{}},goalsSummary:{id:"goals-summary-card",name:(0,i.Tl)("budget","Savings Goals Summary"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"goals",settingsSchema:{}},paymentBreakdown:{id:"payment-breakdown-card",name:(0,i.Tl)("budget","Payment Methods"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"insights",settingsSchema:{}},reconciliationStatus:{id:"reconciliation-card",name:(0,i.Tl)("budget","Reconciliation Status"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"transactions",settingsSchema:{}},pensionProjection:{id:"pension-projection-card",name:(0,i.Tl)("budget","Pension Projection"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"insights",settingsSchema:{}},monthlyComparison:{id:"monthly-comparison-card",name:(0,i.Tl)("budget","Monthly Comparison"),defaultSize:"hero",defaultVisible:!1,category:"insights",settingsSchema:{accountSelector:!0,excludeShared:!0,showLegend:!0}},largeTransactions:{id:"large-transactions-card",name:(0,i.Tl)("budget","Large Transactions"),defaultSize:"hero",defaultVisible:!1,category:"transactions",settingsSchema:{dateRange:!0,shortRange:!0,accountSelector:!0,excludeShared:!0,rowCount:{min:3,max:20,default:5}}},weeklyTrend:{id:"weekly-trend-card",name:(0,i.Tl)("budget","Weekly Spending"),defaultSize:"s",allowedSizes:["s","m","l"],defaultVisible:!1,category:"insights",settingsSchema:{dateRange:!0,shortRange:!0,accountSelector:!0,excludeShared:!0,showLegend:!0}},unmatchedTransfers:{id:"unmatched-transfers-card",name:(0,i.Tl)("budget","Unmatched Transfers"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"transactions",settingsSchema:{}},categoryTrends:{id:"category-trends-card",name:(0,i.Tl)("budget","Category Trends"),defaultSize:"hero",defaultVisible:!1,category:"insights",settingsSchema:{dateRange:!0,shortRange:!0,accountSelector:!0,excludeShared:!0,showLegend:!0,topLevelOnly:!0}},billsDueSoon:{id:"bills-due-soon-card",name:(0,i.Tl)("budget","Bills Due Soon"),defaultSize:"s",allowedSizes:["s","m","l"],defaultVisible:!1,category:"bills",settingsSchema:{forwardHorizon:!0,accountSelector:!0,rowCount:{min:3,max:20,default:5}}},cashFlowForecast:{id:"cash-flow-forecast-card",name:(0,i.Tl)("budget","Cash Flow Forecast"),defaultSize:"l",allowedSizes:["s","m","l"],defaultVisible:!1,category:"forecasting",settingsSchema:{forecastMonths:!0,excludeShared:!0}},yoyComparison:{id:"yoy-comparison-card",name:(0,i.Tl)("budget","Year-over-Year"),defaultSize:"l",allowedSizes:["s","m","l"],defaultVisible:!1,category:"insights",settingsSchema:{yearsToCompare:!0,accountSelector:!0,excludeShared:!0,showLegend:!0}},incomeTracking:{id:"income-tracking-card",name:(0,i.Tl)("budget","Income Tracking"),defaultSize:"hero",defaultVisible:!1,category:"income",settingsSchema:{accountSelector:!0}},recentImports:{id:"recent-imports-card",name:(0,i.Tl)("budget","Recent Imports"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"transactions",settingsSchema:{}},ruleEffectiveness:{id:"rule-effectiveness-card",name:(0,i.Tl)("budget","Rule Effectiveness"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"insights",settingsSchema:{}},spendingVelocity:{id:"spending-velocity-card",name:(0,i.Tl)("budget","Spending Velocity"),defaultSize:"s",allowedSizes:["xs","s","m","l"],defaultVisible:!1,category:"insights",settingsSchema:{}},quickAdd:{id:"quick-add-card",name:(0,i.Tl)("budget","Quick Add Transaction"),defaultSize:"hero",defaultVisible:!1,category:"interactive",settingsSchema:{}}}};class at{static getElements(t,e=document){if("string"==typeof t){const n="getElementById"in e?e:void 0;if(n&&!isNaN(+t[0])){const e=n.getElementById(t);return e?[e]:[]}let a=e.querySelectorAll(t);if(!a.length&&"."!==t[0]&&"#"!==t[0]&&(a=e.querySelectorAll("."+t),a.length||(a=e.querySelectorAll("#"+t)),!a.length)){const n=e.querySelector(`[gs-id="${t}"]`);return n?[n]:[]}return Array.from(a)}return[t]}static getElement(t,e=document){if("string"==typeof t){const n="getElementById"in e?e:void 0;if(!t.length)return null;if(n&&"#"===t[0])return n.getElementById(t.substring(1));if("#"===t[0]||"."===t[0]||"["===t[0])return e.querySelector(t);if(n&&!isNaN(+t[0]))return n.getElementById(t);let a=e.querySelector(t);return n&&!a&&(a=n.getElementById(t)),a||(a=e.querySelector("."+t)),a}return t}static lazyLoad(t){return t.lazyLoad||t.grid?.opts?.lazyLoad&&!1!==t.lazyLoad}static createDiv(t,e){const n=document.createElement("div");return t.forEach(t=>{t&&n.classList.add(t)}),e?.appendChild(n),n}static shouldSizeToContent(t,e=!1){return t?.grid&&(e?!0===t.sizeToContent||!0===t.grid.opts.sizeToContent&&void 0===t.sizeToContent:!!t.sizeToContent||t.grid.opts.sizeToContent&&!1!==t.sizeToContent)}static isIntercepted(t,e){return!(t.y>=e.y+e.h||t.y+t.h<=e.y||t.x+t.w<=e.x||t.x>=e.x+e.w)}static isTouching(t,e){return at.isIntercepted(t,{x:e.x-.5,y:e.y-.5,w:e.w+1,h:e.h+1})}static areaIntercept(t,e){const n=t.x>e.x?t.x:e.x,a=t.x+t.we.y?t.y:e.y,i=t.y+t.h{const r=e*((t.y??n)-(a.y??n));return 0===r?e*((t.x??n)-(a.x??n)):r})}static find(t,e){return e?t.find(t=>t.id===e):void 0}static toBool(t){return"boolean"==typeof t?t:"string"==typeof t?!(""===(t=t.toLowerCase())||"no"===t||"false"===t||"0"===t):Boolean(t)}static toNumber(t){return null===t||0===t.length?void 0:Number(t)}static parseHeight(t){let e,n="px";if("string"==typeof t)if("auto"===t||""===t)e=0;else{const a=t.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!a)throw new Error(`Invalid height val = ${t}`);n=a[2]||"px",e=parseFloat(a[1])}else e=t;return{h:e,unit:n}}static defaults(t,...e){return e.forEach(e=>{for(const n in e){if(!e.hasOwnProperty(n))return;null===t[n]||void 0===t[n]?t[n]=e[n]:"object"==typeof e[n]&&"object"==typeof t[n]&&at.defaults(t[n],e[n])}}),t}static same(t,e){if("object"!=typeof t)return t==e;if(typeof t!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}static copyPos(t,e,n=!1){return void 0!==e.x&&(t.x=e.x),void 0!==e.y&&(t.y=e.y),void 0!==e.w&&(t.w=e.w),void 0!==e.h&&(t.h=e.h),n&&(e.minW&&(t.minW=e.minW),e.minH&&(t.minH=e.minH),e.maxW&&(t.maxW=e.maxW),e.maxH&&(t.maxH=e.maxH)),t}static samePos(t,e){return t&&e&&t.x===e.x&&t.y===e.y&&(t.w||1)===(e.w||1)&&(t.h||1)===(e.h||1)}static sanitizeMinMax(t){t.minW||delete t.minW,t.minH||delete t.minH,t.maxW||delete t.maxW,t.maxH||delete t.maxH}static removeInternalAndSame(t,e){if("object"==typeof t&&"object"==typeof e&&!Array.isArray(t)&&!Array.isArray(e))for(let n in t){const a=t[n],r=e[n];"_"===n[0]||a===r?delete t[n]:a&&"object"==typeof a&&void 0!==r&&(at.removeInternalAndSame(a,r),Object.keys(a).length||delete t[n])}}static removeInternalForSave(t,e=!0){for(let e in t)"_"!==e[0]&&null!==t[e]&&void 0!==t[e]||delete t[e];delete t.grid,e&&delete t.el,t.autoPosition||delete t.autoPosition,t.noResize||delete t.noResize,t.noMove||delete t.noMove,t.locked||delete t.locked,1!==t.w&&t.w!==t.minW||delete t.w,1!==t.h&&t.h!==t.minH||delete t.h}static throttle(t,e){let n=!1;return(...a)=>{n||(n=!0,setTimeout(()=>{t(...a),n=!1},e))}}static removePositioningStyles(t){const e=t.style;e.position&&e.removeProperty("position"),e.left&&e.removeProperty("left"),e.top&&e.removeProperty("top"),e.width&&e.removeProperty("width"),e.height&&e.removeProperty("height")}static getScrollElement(t){if(!t)return document.scrollingElement||document.documentElement;const e=getComputedStyle(t).overflowY;return("auto"===e||"scroll"===e)&&t.scrollHeight>t.clientHeight?t:at.getScrollElement(t.parentElement)}static updateScrollResize(t,e,n){const a=at.getScrollElement(e),r=a.clientHeight,i=a===at.getScrollElement()?0:a.getBoundingClientRect().top,o=t.clientY-i,s=o>r-n;ot===a)&&(n[a]=at.cloneDeep(t[a]));return n}static cloneNode(t){const e=t.cloneNode(!0);return e.removeAttribute("id"),e}static appendTo(t,e){let n;n="string"==typeof e?at.getElement(e):e,n&&n.appendChild(t)}static addElStyles(t,e){if(e instanceof Object)for(const n in e)e.hasOwnProperty(n)&&(Array.isArray(e[n])?e[n].forEach(e=>{t.style[n]=e}):t.style[n]=e[n])}static initEvent(t,e){const n={type:e.type},a={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:e.target?e.target:t.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(e=>n[e]=t[e]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(e=>n[e]=t[e]),{...n,...a}}static simulateMouseEvent(t,e,n){const a=t,r=new MouseEvent(e,{bubbles:!0,composed:!0,cancelable:!0,view:window,detail:1,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY,ctrlKey:a.ctrlKey??!1,altKey:a.altKey??!1,shiftKey:a.shiftKey??!1,metaKey:a.metaKey??!1,button:0,relatedTarget:t.target});(n||t.target).dispatchEvent(r)}static getValuesFromTransformedElement(t){const e=document.createElement("div");at.addElStyles(e,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),t.appendChild(e);const n=e.getBoundingClientRect();return t.removeChild(e),e.remove(),{xScale:1/n.width,yScale:1/n.height,xOffset:n.left,yOffset:n.top}}static swap(t,e,n){if(!t)return;const a=t[e];t[e]=t[n],t[n]=a}static canBeRotated(t){return!(!t||t.w===t.h||t.locked||t.noResize||t.grid?.opts.disableResize||t.minW&&t.minW===t.maxW||t.minH&&t.minH===t.maxH)}}class rt{constructor(t={}){this.addedNodes=[],this.removedNodes=[],this.defaultColumn=12,this.column=t.column||this.defaultColumn,this.column>this.defaultColumn&&(this.defaultColumn=this.column),this.maxRow=t.maxRow,this._float=t.float,this.nodes=t.nodes||[],this.onChange=t.onChange}batchUpdate(t=!0,e=!0){return!!this.batchMode===t||(this.batchMode=t,t?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,e&&this._packNodes(),this._notify())),this}_useEntireRowArea(t,e){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!t._moving||t._skipDown||e.y<=t.y)}_fixCollisions(t,e=t,n,a={}){if(this.sortNodes(-1),!(n=n||this.collide(t,e)))return!1;if(t._moving&&!a.nested&&!this.float&&this.swap(t,n))return!0;let r=e;!this._loading&&this._useEntireRowArea(t,e)&&(r={x:0,w:this.column,y:e.y,h:e.h},n=this.collide(t,r,a.skip));let i=!1;const o={nested:!0,pack:!1};let s=0;for(;n=n||this.collide(t,r,a.skip);){if(s++>2*this.nodes.length)throw new Error("Infinite collide check");let r;if(n.locked||this._loading||t._moving&&!t._skipDown&&e.y>t.y&&!this.float&&(!this.collide(n,{...n,y:t.y},t)||!this.collide(n,{...n,y:e.y-n.h},t))){t._skipDown=t._skipDown||e.y>t.y;const s={...e,y:n.y+n.h,...o};r=!(!this._loading||!at.samePos(t,s))||this.moveNode(t,s),(n.locked||this._loading)&&r?at.copyPos(e,t):!n.locked&&r&&a.pack&&(this._packNodes(),e.y=n.y+n.h,at.copyPos(t,e)),i=i||r}else r=this.moveNode(n,{...n,y:e.y+e.h,skip:t,...o});if(!r)return i;n=void 0}return i}collide(t,e=t,n){const a=t._id,r=n?._id;return this.nodes.find(t=>t._id!==a&&t._id!==r&&at.isIntercepted(t,e))}collideAll(t,e=t,n){const a=t._id,r=n?._id;return this.nodes.filter(t=>t._id!==a&&t._id!==r&&at.isIntercepted(t,e))}directionCollideCoverage(t,e,n){if(!e.rect||!t._rect)return;const a=t._rect,r={...e.rect};let i;r.y>a.y?(r.h+=r.y-a.y,r.y=a.y):r.h+=a.y-r.y,r.x>a.x?(r.w+=r.x-a.x,r.x=a.x):r.w+=a.x-r.x;let o=.5;for(let t of n){if(t.locked||!t._rect)break;const e=t._rect;let n=Number.MAX_VALUE,s=Number.MAX_VALUE;a.ye.y+e.h&&(n=(e.y+e.h-r.y)/e.h),a.xe.x+e.w&&(s=(e.x+e.w-r.x)/e.w);const c=Math.min(s,n);c>o&&(o=c,i=t)}return e.collide=i,i}cacheRects(t,e,n,a,r,i){return this.nodes.forEach(o=>o._rect={y:o.y*e+n,x:o.x*t+i,w:o.w*t-i-a,h:o.h*e-n-r}),this}swap(t,e){if(!e||e.locked||!t||t.locked)return!1;function n(){const n=e.x,a=e.y;return e.x=t.x,e.y=t.y,t.h!=e.h?(t.x=n,t.y=e.y+e.h):t.w!=e.w?(t.x=e.x+e.w,t.y=a):(t.x=n,t.y=a),t._dirty=e._dirty=!0,!0}let a;if(t.w===e.w&&t.h===e.h&&(t.x===e.x||t.y===e.y)&&(a=at.isTouching(t,e)))return n();if(!1!==a){if(t.w===e.w&&t.x===e.x&&(a||(a=at.isTouching(t,e)))){if(e.y{let r;e.locked||(e.autoPosition=!0,"list"===t&&n&&(r=a[n-1])),this.addNode(e,!1,r)}),a||delete this._inColumnResize,n||this.batchUpdate(!1),this}set float(t){this._float!==t&&(this._float=t||!1,t||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(t=1){return this.nodes=at.sort(this.nodes,t),this}_packNodes(){return this.batchMode||(this.sortNodes(),this.float?this.nodes.forEach(t=>{if(t._updating||void 0===t._orig||t.y===t._orig.y)return;let e=t.y;for(;e>t._orig.y;)--e,this.collide(t,{x:t.x,y:e,w:t.w,h:t.h})||(t._dirty=!0,t.y=e)}):this.nodes.forEach((t,e)=>{if(!t.locked)for(;t.y>0;){const n=0===e?0:t.y-1;if(0!==e&&this.collide(t,{x:t.x,y:n,w:t.w,h:t.h}))break;t._dirty=t.y!==n,t.y=n}})),this}prepareNode(t,e){t._id=t._id??rt._idSeq++;const n=t.id;if(n){let e=1;for(;this.nodes.find(e=>e.id===t.id&&e!==t);)t.id=n+"_"+e++}void 0!==t.x&&void 0!==t.y&&null!==t.x&&null!==t.y||(t.autoPosition=!0);const a={x:0,y:0,w:1,h:1};return at.defaults(t,a),t.autoPosition||delete t.autoPosition,t.noResize||delete t.noResize,t.noMove||delete t.noMove,at.sanitizeMinMax(t),"string"==typeof t.x&&(t.x=Number(t.x)),"string"==typeof t.y&&(t.y=Number(t.y)),"string"==typeof t.w&&(t.w=Number(t.w)),"string"==typeof t.h&&(t.h=Number(t.h)),isNaN(t.x)&&(t.x=a.x,t.autoPosition=!0),isNaN(t.y)&&(t.y=a.y,t.autoPosition=!0),isNaN(t.w)&&(t.w=a.w),isNaN(t.h)&&(t.h=a.h),this.nodeBoundFix(t,e),t}nodeBoundFix(t,e){const n=t._orig||at.copyPos({},t);if(t.maxW&&(t.w=Math.min(t.w||1,t.maxW)),t.maxH&&(t.h=Math.min(t.h||1,t.maxH)),t.minW&&(t.w=Math.max(t.w||1,t.minW)),t.minH&&(t.h=Math.max(t.h||1,t.minH)),(t.x||0)+(t.w||1)>this.column&&this.columnthis.column?t.w=this.column:t.w<1&&(t.w=1),this.maxRow&&t.h>this.maxRow?t.h=this.maxRow:t.h<1&&(t.h=1),t.x<0&&(t.x=0),t.y<0&&(t.y=0),t.x+t.w>this.column&&(e?t.w=this.column-t.x:t.x=this.column-t.w),this.maxRow&&t.y+t.h>this.maxRow&&(e?t.h=this.maxRow-t.y:t.y=this.maxRow-t.h),at.samePos(t,n)||(t._dirty=!0),this}getDirtyNodes(t){return t?this.nodes.filter(t=>t._dirty&&!at.samePos(t,t._orig)):this.nodes.filter(t=>t._dirty)}_notify(t){if(this.batchMode||!this.onChange)return this;const e=(t||[]).concat(this.getDirtyNodes());return this.onChange(e),this}cleanNodes(){return this.batchMode||this.nodes.forEach(t=>{delete t._dirty,delete t._lastTried}),this}saveInitial(){return this.nodes.forEach(t=>{t._orig=at.copyPos({},t),delete t._dirty}),this._hasLocked=this.nodes.some(t=>t.locked),this}restoreInitial(){return this.nodes.forEach(t=>{t._orig&&!at.samePos(t,t._orig)&&(at.copyPos(t,t._orig),t._dirty=!0)}),this._notify(),this}findEmptyPosition(t,e=this.nodes,n=this.column,a){let r=!1;for(let i=a?a.y*n+(a.x+a.w):0;!r;++i){const a=i%n,o=Math.floor(i/n);if(a+t.w>n)continue;const s={x:a,y:o,w:t.w,h:t.h};e.find(t=>at.isIntercepted(s,t))||(t.x===a&&t.y===o||(t._dirty=!0),t.x=a,t.y=o,delete t.autoPosition,r=!0)}return r}addNode(t,e=!1,n){const a=this.nodes.find(e=>e._id===t._id);if(a)return a;let r;return this._inColumnResize?this.nodeBoundFix(t):this.prepareNode(t),delete t._temporaryRemoved,delete t._removeDOM,t.autoPosition&&this.findEmptyPosition(t,this.nodes,this.column,n)&&(delete t.autoPosition,r=!0),this.nodes.push(t),e&&this.addedNodes.push(t),r||this._fixCollisions(t),this.batchMode||this._packNodes()._notify(),t}removeNode(t,e=!0,n=!1){return this.nodes.find(e=>e._id===t._id)?(n&&this.removedNodes.push(t),e&&(t._removeDOM=!0),this.nodes=this.nodes.filter(e=>e._id!==t._id),t._isAboutToRemove||this._packNodes(),this._notify([t]),this):this}removeAll(t=!0,e=!0){if(delete this._layouts,!this.nodes.length)return this;t&&this.nodes.forEach(t=>t._removeDOM=!0);const n=this.nodes;return this.removedNodes=e?n:[],this.nodes=[],this._notify(n)}moveNodeCheck(t,e){if(!this.changedPosConstrain(t,e))return!1;if(e.pack=!0,!this.maxRow)return this.moveNode(t,e);let n;const a=new rt({column:this.column,float:this.float,nodes:this.nodes.map(e=>e._id===t._id?(n={...e},n):{...e})});if(!n)return!1;const r=a.moveNode(n,e)&&a.getRow()<=Math.max(this.getRow(),this.maxRow);if(!r&&!e.resizing&&e.collide){const n=e.collide.el.gridstackNode;if(this.swap(t,n))return this._notify(),!0}return!!r&&(a.nodes.filter(t=>t._dirty).forEach(t=>{const e=this.nodes.find(e=>e._id===t._id);e&&(at.copyPos(e,t),e._dirty=!0)}),this._notify(),!0)}willItFit(t){if(delete t._willFitPos,!this.maxRow)return!0;const e=new rt({column:this.column,float:this.float,nodes:this.nodes.map(t=>({...t}))}),n={...t};return this.cleanupNode(n),delete n.el,delete n._id,delete n.content,delete n.grid,e.addNode(n),e.getRow()<=this.maxRow&&(t._willFitPos=at.copyPos({},n),!0)}changedPosConstrain(t,e){return e.w=e.w||t.w,e.h=e.h||t.h,t.x!==e.x||t.y!==e.y||(t.maxW&&(e.w=Math.min(e.w,t.maxW)),t.maxH&&(e.h=Math.min(e.h,t.maxH)),t.minW&&(e.w=Math.max(e.w,t.minW)),t.minH&&(e.h=Math.max(e.h,t.minH)),t.w!==e.w||t.h!==e.h)}moveNode(t,e){if(!t||!e)return!1;let n;void 0!==e.pack||this.batchMode||(n=e.pack=!0),"number"!=typeof e.x&&(e.x=t.x),"number"!=typeof e.y&&(e.y=t.y),"number"!=typeof e.w&&(e.w=t.w),"number"!=typeof e.h&&(e.h=t.h);const a=t.w!==e.w||t.h!==e.h,r=at.copyPos({},t,!0);if(at.copyPos(r,e),this.nodeBoundFix(r,a),at.copyPos(e,r),!e.forceCollide&&at.samePos(t,e))return!1;const i=at.copyPos({},t),o=this.collideAll(t,r,e.skip);let s=!0;if(o.length){const a=t._moving&&!e.nested;let i=a?this.directionCollideCoverage(t,e,o):o[0];if(a&&i&&t.grid?.opts?.subGridDynamic&&!t.grid._isTemp){const n=at.areaIntercept(e.rect,i._rect),a=at.area(e.rect),r=at.area(i._rect);n/(a.8&&(i.grid.makeSubGrid(i.el,void 0,t),i=void 0)}i?s=!this._fixCollisions(t,r,i,e):(s=!1,n&&delete e.pack)}return s&&!at.samePos(t,r)&&(t._dirty=!0,at.copyPos(t,r)),e.pack&&this._packNodes()._notify(),!at.samePos(t,i)}getRow(){return this.nodes.reduce((t,e)=>Math.max(t,e.y+e.h),0)}beginUpdate(t){return t._updating||(t._updating=!0,delete t._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){const t=this.nodes.find(t=>t._updating);return t&&(delete t._updating,delete t._skipDown),this}save(t=!0,e,n){const a=this._layouts?.length||0;let r;a&&(n?n!==this.column&&(r=this._layouts[n]):this.column!==a-1&&(r=this._layouts[a-1]));const i=[];return this.sortNodes(),this.nodes.forEach(n=>{const a=r?.find(t=>t._id===n._id),o={...n,...a||{}};at.removeInternalForSave(o,!t),e&&e(n,o),i.push(o)}),i}layoutsNodesChange(t){return!this._layouts||this._inColumnResize||this._layouts.forEach((e,n)=>{if(!e||n===this.column)return this;if(n{if(!t._orig)return;const n=e.find(e=>e._id===t._id);n&&(n.y>=0&&t.y!==t._orig.y&&(n.y+=t.y-t._orig.y,n.y<0&&(n.y=0)),t.x!==t._orig.x&&(n.x=Math.round(t.x*a),n.x<0&&(n.x=0)),t.w!==t._orig.w&&(n.w=Math.round(t.w*a),n.w<1&&(n.w=1)))})}}),this}columnChanged(t,e,n="moveScale"){if(!this.nodes.length||!e||t===e)return this;const a="compact"===n||"list"===n;a&&this.sortNodes(1),et&&this._layouts){const n=this._layouts[e]||[],o=this._layouts.length-1;!n.length&&t!==o&&this._layouts[o]?.length&&(t=o,this._layouts[o].forEach(t=>{const e=i.find(e=>e._id===t._id);e&&(a||t.autoPosition||(e.x=t.x??e.x,e.y=t.y??e.y),e.w=t.w??e.w,null!=t.x&&void 0!==t.y||(e.autoPosition=!0))})),n.forEach(t=>{const e=i.findIndex(e=>e._id===t._id);if(-1!==e){const n=i[e];if(a)return void(n.w=t.w);(t.autoPosition||isNaN(t.x)||isNaN(t.y))&&this.findEmptyPosition(t,r),t.autoPosition||(n.x=t.x??n.x,n.y=t.y??n.y,n.w=t.w??n.w,r.push(n)),i.splice(e,1)}})}if(a)this.compact(n,!1);else{if(i.length)if("function"==typeof n)n(e,t,r,i);else{const o=a||"none"===n?1:e/t,s="move"===n||"moveScale"===n,c="scale"===n||"moveScale"===n;i.forEach(n=>{n.x=1===e?0:s?Math.round(n.x*o):Math.min(n.x,e-1),n.w=1===e||1===t?1:c?Math.round(n.w*o)||1:Math.min(n.w,e),r.push(n)}),i=[]}r=at.sort(r,-1),this._inColumnResize=!0,this.nodes=[],r.forEach(t=>{this.addNode(t,!1),delete t._orig})}return this.nodes.forEach(t=>delete t._orig),this.batchUpdate(!1,!a),delete this._inColumnResize,this}cacheLayout(t,e,n=!1){const a=[];return t.forEach((t,e)=>{if(void 0===t._id){const e=t.id?this.nodes.find(e=>e.id===t.id):void 0;t._id=e?._id??rt._idSeq++}a[e]={x:t.x,y:t.y,w:t.w,_id:t._id}}),this._layouts=n?[]:this._layouts||[],this._layouts[e]=a,this}cacheOneLayout(t,e){t._id=t._id??rt._idSeq++;const n={x:t.x,y:t.y,w:t.w,_id:t._id};(t.autoPosition||void 0===t.x)&&(delete n.x,delete n.y,t.autoPosition&&(n.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[e]=this._layouts[e]||[];const a=this.findCacheLayout(t,e);return-1===a?this._layouts[e].push(n):this._layouts[e][a]=n,this}findCacheLayout(t,e){return this._layouts?.[e]?.findIndex(e=>e._id===t._id)??-1}removeNodeFromLayoutCache(t){if(this._layouts)for(let e=0;e0||navigator.msMaxTouchPoints>0);class ct{}function lt(t,e){t.touches.length>1||(t.cancelable&&t.preventDefault(),at.simulateMouseEvent(t.changedTouches[0],e))}function ut(t,e){t.cancelable&&t.preventDefault(),at.simulateMouseEvent(t,e)}function dt(t){ct.touchHandled||(ct.touchHandled=!0,lt(t,"mousedown"))}function ht(t){ct.touchHandled&<(t,"mousemove")}function gt(t){if(!ct.touchHandled)return;ct.pointerLeaveTimeout&&(window.clearTimeout(ct.pointerLeaveTimeout),delete ct.pointerLeaveTimeout);const e=!!ot.dragElement;lt(t,"mouseup"),e||lt(t,"click"),ct.touchHandled=!1}function pt(t){"mouse"!==t.pointerType&&t.target.releasePointerCapture(t.pointerId)}function ft(t){ot.dragElement&&"mouse"!==t.pointerType&&ut(t,"mouseenter")}function mt(t){ot.dragElement&&"mouse"!==t.pointerType&&(ct.pointerLeaveTimeout=window.setTimeout(()=>{delete ct.pointerLeaveTimeout,ut(t,"mouseleave")},10))}class vt{constructor(t,e,n){this.host=t,this.dir=e,this.option=n,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this._init()}_init(){if(this.option.element)try{this.el=this.option.element instanceof HTMLElement?this.option.element:this.host.querySelector(this.option.element)}catch(t){this.option.element=void 0,console.error("Query for resizeable handle failed, falling back",t)}return this.el||(this.el=document.createElement("div"),this.host.appendChild(this.el)),this.el.classList.add("ui-resizable-handle"),this.el.classList.add(`${vt.prefix}${this.dir}`),this.el.style.zIndex="100",this.el.style.userSelect="none",this.el.addEventListener("mousedown",this._mouseDown),st&&(this.el.addEventListener("touchstart",dt),this.el.addEventListener("pointerdown",pt)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),st&&(this.el.removeEventListener("touchstart",dt),this.el.removeEventListener("pointerdown",pt)),this.option.element||this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(t){this.mouseDownEvent=t,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),st&&(this.el.addEventListener("touchmove",ht),this.el.addEventListener("touchend",gt)),t.stopPropagation(),t.preventDefault()}_mouseMove(t){const e=this.mouseDownEvent;this.moving?this._triggerEvent("move",t):Math.abs(t.x-e.x)+Math.abs(t.y-e.y)>2&&(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",t),document.addEventListener("keydown",this._keyEvent)),t.stopPropagation()}_mouseUp(t){this.moving&&(this._triggerEvent("stop",t),document.removeEventListener("keydown",this._keyEvent)),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),st&&(this.el.removeEventListener("touchmove",ht),this.el.removeEventListener("touchend",gt)),delete this.moving,delete this.mouseDownEvent,t.stopPropagation(),t.preventDefault()}_keyEvent(t){"Escape"===t.key&&(this.host.gridstackNode?.grid?.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(t,e){return this.option[t]&&this.option[t](e),this}}vt.prefix="ui-resizable-";class yt{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(t,e){this._eventRegister[t]=e}off(t){delete this._eventRegister[t]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(t,e){if(!this.disabled&&this._eventRegister&&this._eventRegister[t])return this._eventRegister[t](e)}}class bt extends yt{constructor(t,e={}){super(),this.el=t,this.option=e,this.rectScale={x:1,y:1},this._ui=()=>{const t=this.el.parentElement.getBoundingClientRect(),e={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,right:this.originalRect.right,top:this.originalRect.top-this.scrolled},n=this.temporalRect||e;return{position:{left:this.option.rtl?(t.right-n.right)*this.rectScale.x:(n.left-t.left)*this.rectScale.x,top:(n.top-t.top)*this.rectScale.y},size:{width:n.width*this.rectScale.x,height:n.height*this.rectScale.y}}},this._mouseOver=this._mouseOver.bind(this),this._mouseOut=this._mouseOut.bind(this),this.enable(),this._setupAutoHide(this.option.autoHide),this._setupHandlers()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){super.enable(),this.el.classList.remove("ui-resizable-disabled"),this._setupAutoHide(this.option.autoHide)}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this._setupAutoHide(!1)}destroy(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(t){const e=t.handles&&t.handles!==this.option.handles,n=t.autoHide&&t.autoHide!==this.option.autoHide;return Object.keys(t).forEach(e=>this.option[e]=t[e]),e&&(this._removeHandlers(),this._setupHandlers()),n&&this._setupAutoHide(this.option.autoHide),this}_setupAutoHide(t){return t?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._mouseOver),this.el.addEventListener("mouseout",this._mouseOut)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._mouseOver),this.el.removeEventListener("mouseout",this._mouseOut),ot.overResizeElement===this&&delete ot.overResizeElement),this}_mouseOver(t){ot.overResizeElement||ot.dragElement||(ot.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(t){ot.overResizeElement===this&&(delete ot.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(t=>t.trim()).map(t=>new vt(this.el,t,{element:this.option.element,start:t=>this._resizeStart(t),stop:t=>this._resizeStop(t),move:e=>this._resizing(e,t)})),this}_resizeStart(t){this.sizeToContent=at.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=at.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=t,this._setupHelper(),this._applyChange();const e=at.initEvent(t,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(e,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",e),this}_resizing(t,e){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(t,e),this._applyChange();const n=at.initEvent(t,{type:"resize",target:this.el});return n.resizeDir=e,n.hasMovedX=this.option.rtl?e.includes("e"):e.includes("w"),n.hasMovedY=e.includes("n"),this.option.resize&&this.option.resize(n,this._ui()),this.triggerEvent("resize",n),this}_resizeStop(t){const e=at.initEvent(t,{type:"resizestop",target:this.el});return this._cleanHelper(),this.option.stop&&this.option.stop(e),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",e),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=bt._originStyleProp.map(t=>this.el.style[t]),this.parentOriginStylePosition=this.el.parentElement.style.position;const t=this.el.parentElement,e=at.getValuesFromTransformedElement(t);return this.rectScale={x:e.xScale,y:e.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return bt._originStyleProp.forEach((t,e)=>{this.el.style[t]=this.elOriginStyleVal[e]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(t,e){const n=this.startEvent,a={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,right:this.originalRect.right,top:this.originalRect.top-this.scrolled},r=t.clientX-n.clientX,i=this.sizeToContent?0:t.clientY-n.clientY;let o,s;const c=this.option.rtl;!c&&e.indexOf("e")>-1?a.width+=r:c&&e.indexOf("w")>-1?a.width-=r:!c&&e.indexOf("w")>-1?(a.width-=r,a.left+=r,o=!0):c&&e.indexOf("e")>-1&&(a.width+=r,a.right+=r,o=!0),e.indexOf("s")>-1?a.height+=i:e.indexOf("n")>-1&&(a.height-=i,a.top+=i,s=!0);const l=this._constrainSize(a.width,a.height,o,s);return Math.round(a.width)!==Math.round(l.width)&&(!c&&e.indexOf("w")>-1?a.left+=a.width-l.width:c&&e.indexOf("e")>-1&&(a.right-=a.width-l.width),a.width=l.width),Math.round(a.height)!==Math.round(l.height)&&(e.indexOf("n")>-1&&(a.top+=a.height-l.height),a.height=l.height),a}_constrainSize(t,e,n,a){const r=this.option,i=(n?r.maxWidthMoveLeft:r.maxWidth)||Number.MAX_SAFE_INTEGER,o=r.minWidth/this.rectScale.x||t,s=(a?r.maxHeightMoveUp:r.maxHeight)||Number.MAX_SAFE_INTEGER,c=r.minHeight/this.rectScale.y||e;return{width:Math.min(i,Math.max(o,t)),height:Math.min(s,Math.max(c,e))}}_applyChange(){let t={left:0,right:0,top:0,width:0,height:0};if("absolute"===this.el.style.position){const e=this.el.parentElement,{left:n,right:a,top:r}=e.getBoundingClientRect();t={left:n,right:a,top:r,width:0,height:0}}return this.temporalRect?(Object.entries(this.temporalRect).forEach(([e,n])=>{if(this.option.rtl?"left"===e:"right"===e)return;const a="width"===e||"left"===e||"right"===e?this.rectScale.x:"height"===e||"top"===e?this.rectScale.y:1;let r;r="right"===e?(t.right-n)*this.rectScale.x+"px":(n-t[e])*a+"px",this.el.style[e]=r}),this):this}_removeHandlers(){return this.handlers.forEach(t=>t.destroy()),delete this.handlers,this}}bt._originStyleProp=["width","height","position","left","right","top","opacity","zIndex"];class wt extends yt{constructor(t,e={}){super(),this.el=t,this.option=e,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},this._autoScrollTick=()=>{const t=this.helper,e=this._autoScrollContainer;if(!t||!e)return void this._stopScrolling();const n=this._getClipping(t,e);if(0===n)return void this._stopScrolling();if(!this._autoScrollMaxSpeed){const t=window.innerHeight||document.documentElement.clientHeight;this._autoScrollMaxSpeed=Math.max(t/150,4)}const a=Math.abs(n),r=Math.min(.5*a,this._autoScrollMaxSpeed),i=n>0?r:-r,o=e.scrollTop;e.scrollTop+=i,e.scrollTop!==o?(this.dragging&&this.lastDrag&&(this._dragFollow(this.lastDrag),this._callDrag(this.lastDrag)),this._autoScrollAnimId=requestAnimationFrame(this._autoScrollTick)):this._stopScrolling()};const n=e?.handle?.substring(1),a=t.gridstackNode;this.dragEls=!n||t.classList.contains(n)?[t]:a?.subGrid?[t.querySelector(e.handle)||t]:this.getAllHandles(),0===this.dragEls.length&&(this.dragEls=[t]),this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this.enable()}getAllHandles(){return Array.from(this.el.querySelectorAll(this.option.handle)).filter(t=>{if(!(t instanceof HTMLElement))return!1;const e=t.closest(".grid-stack-item");return e===this.el||!e})}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){!1!==this.disabled&&(super.enable(),this.dragEls.forEach(t=>{t.addEventListener("mousedown",this._mouseDown),st&&(t.addEventListener("touchstart",dt),t.addEventListener("pointerdown",pt))}),this.el.classList.remove("ui-draggable-disabled"))}disable(t=!1){!0!==this.disabled&&(super.disable(),this.dragEls.forEach(t=>{t.removeEventListener("mousedown",this._mouseDown),st&&(t.removeEventListener("touchstart",dt),t.removeEventListener("pointerdown",pt))}),t||this.el.classList.add("ui-draggable-disabled"))}destroy(){this.dragTimeout&&window.clearTimeout(this.dragTimeout),delete this.dragTimeout,this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(t){return Object.keys(t).forEach(e=>this.option[e]=t[e]),this}_mouseDown(t){if(ct.touchHandled&&t.isTrusted&&(ct.touchHandled=!1),!ot.mouseHandled)return 0!==t.button||!this.dragEls.find(e=>e===t.target)&&t.target.closest('input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle')||this.option.cancel&&t.target.closest(this.option.cancel)||(this.mouseDownEvent=t,delete this.dragging,delete ot.dragElement,delete ot.dropElement,delete this._autoScrollMaxSpeed,delete this._autoScrollContainer,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),st&&(t.currentTarget.addEventListener("touchmove",ht),t.currentTarget.addEventListener("touchend",gt)),t.preventDefault(),document.activeElement&&document.activeElement.blur(),ot.mouseHandled=!0),!0}_callDrag(t){if(!this.dragging)return;const e=at.initEvent(t,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(e,this.ui()),this.triggerEvent("drag",e)}_mouseMove(t){const e=this.mouseDownEvent;if(this.lastDrag=t,this.dragging)if(this._dragFollow(t),ot.pauseDrag){const e=Number.isInteger(ot.pauseDrag)?ot.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(t),e)}else this._callDrag(t);else if(Math.abs(t.x-e.x)+Math.abs(t.y-e.y)>3){this.dragging=!0,ot.dragElement=this;const e=this.el.gridstackNode?.grid;e?ot.dropElement=e.el.ddElement.ddDroppable:delete ot.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=at.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(t,this.el,this.helperContainment),this._setupHelperStyle(t);const n=at.initEvent(t,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(n,this.ui()),this.triggerEvent("dragstart",n),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(t){if(this._stopScrolling(),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),st&&t.currentTarget&&(t.currentTarget.removeEventListener("touchmove",ht,!0),t.currentTarget.removeEventListener("touchend",gt,!0)),this.dragging){delete this.dragging,delete this.el.gridstackNode?._origRotate,document.removeEventListener("keydown",this._keyEvent),ot.dropElement?.el===this.el.parentElement&&delete ot.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();const e=at.initEvent(t,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(e),this.triggerEvent("dragstop",e),ot.dropElement&&ot.dropElement.drop(t)}delete this.helper,delete this.mouseDownEvent,delete ot.dragElement,delete ot.dropElement,delete ot.mouseHandled,t.preventDefault()}_keyEvent(t){const e=this.el.gridstackNode,n=e?.grid||ot.dropElement?.el?.gridstack;if("Escape"===t.key)e&&e._origRotate&&(e._orig=e._origRotate,delete e._origRotate),n?.cancelDrag(),this._mouseUp(this.mouseDownEvent);else if(e&&n&&("r"===t.key||"R"===t.key)){if(!at.canBeRotated(e))return;e._origRotate=e._origRotate||{...e._orig},delete e._moving,n.setAnimation(!1).rotate(e.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetX}).setAnimation(),e._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,e.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",at.swap(e._orig,"w","h"),delete e._rect,this._mouseMove(this.lastDrag)}}_createHelper(){let t=this.el;return"function"==typeof this.option.helper?t=this.option.helper(this.el):"clone"===this.option.helper&&(t=at.cloneNode(this.el)),t.parentElement||at.appendTo(t,"parent"===this.option.appendTo?this.el.parentElement:this.option.appendTo),this.dragElementOriginStyle=wt.originStyleProp.map(t=>this.el.style[t]),t}_setupHelperStyle(t){this.helper.classList.add("ui-draggable-dragging"),this.el.gridstackNode?.grid?.el.classList.add("grid-stack-dragging");const e=this.helper.style;return e.pointerEvents="none",e.width=this.dragOffset.width+"px",e.height=this.dragOffset.height+"px",e.willChange="left, right, top",e.position="fixed",this._dragFollow(t),e.transition="none",setTimeout(()=>{this.helper&&(e.transition=null)},0),this}_removeHelperStyle(){this.helper.classList.remove("ui-draggable-dragging"),this.el.gridstackNode?.grid?.el.classList.remove("grid-stack-dragging");const t=this.helper?.gridstackNode;if(!t?._isAboutToRemove&&this.dragElementOriginStyle){const t=this.helper,e=this.dragElementOriginStyle.transition||null;t.style.transition=this.dragElementOriginStyle.transition="none",wt.originStyleProp.forEach(e=>t.style[e]=this.dragElementOriginStyle[e]||null),setTimeout(()=>t.style.transition=e,50)}return delete this.dragElementOriginStyle,this}_dragFollow(t){const e=this.helper.style,n=this.dragOffset;this.option.rtl?(e.right=(window.innerWidth-t.clientX+n.offsetX)*this.dragTransform.xScale+"px",e.left&&(e.left="")):(e.left=(t.clientX+n.offsetX)*this.dragTransform.xScale+"px",e.right&&(e.right="")),e.top=(t.clientY+n.offsetTop)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,"fixed"!==this.helper.style.position&&(this.parentOriginStylePosition=this.helperContainment.style.position,getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_getDragOffset(t,e,n){let a=0,r=0;n&&(a=this.dragTransform.xOffset,r=this.dragTransform.yOffset);const i=e.getBoundingClientRect();let o=this.option.rtl?i.right:i.left,s=this.option.rtl?t.clientX-i.right+a:-t.clientX+i.left-a;return{x:o,top:i.top,offsetX:s,offsetTop:-t.clientY+i.top-r,width:i.width*this.dragTransform.xScale,height:i.height*this.dragTransform.yScale}}updateScrollPosition(t){this._autoScrollContainer=at.getScrollElement(t),0===this._getClipping(this.helper,this._autoScrollContainer)?this._stopScrolling():this._autoScrollAnimId||(this._autoScrollAnimId=requestAnimationFrame(this._autoScrollTick))}_getClipping(t,e){const n=t.getBoundingClientRect(),a=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight;if(n.bottoma.bottom)return 0;const i=n.bottom-Math.min(a.bottom,r),o=n.top-Math.max(a.top,0);return o<0?o:i>0?i:0}_stopScrolling(){this._autoScrollAnimId&&(cancelAnimationFrame(this._autoScrollAnimId),delete this._autoScrollAnimId)}ui(){const t=this.el.parentElement.getBoundingClientRect(),e=this.helper.getBoundingClientRect(),n=this.option.rtl?(t.right-e.right)*this.dragTransform.xScale:(e.left-t.left)*this.dragTransform.xScale;return{position:{top:(e.top-t.top)*this.dragTransform.yScale,left:n}}}}wt.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","right","top","minWidth","willChange"];class Tt extends yt{constructor(t,e={}){super(),this.el=t,this.option=e,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){!1!==this.disabled&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),st&&(this.el.addEventListener("pointerenter",ft),this.el.addEventListener("pointerleave",mt)))}disable(t=!1){!0!==this.disabled&&(super.disable(),this.el.classList.remove("ui-droppable"),t||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),st&&(this.el.removeEventListener("pointerenter",ft),this.el.removeEventListener("pointerleave",mt)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(t){return Object.keys(t).forEach(e=>this.option[e]=t[e]),this._setupAccept(),this}_mouseEnter(t){if(!ot.dragElement)return;if(ct.touchHandled&&t.isTrusted)return;if(!this._canDrop(ot.dragElement.el))return;t.preventDefault(),t.stopPropagation(),ot.dragElement._stopScrolling(),ot.dropElement&&ot.dropElement!==this&&ot.dropElement._mouseLeave(t,!0),ot.dropElement=this;const e=at.initEvent(t,{target:this.el,type:"dropover"});this.option.over&&this.option.over(e,this._ui(ot.dragElement)),this.triggerEvent("dropover",e),this.el.classList.add("ui-droppable-over")}_mouseLeave(t,e=!1){if(!ot.dragElement||ot.dropElement!==this)return;t.preventDefault(),t.stopPropagation(),e&&ot.dragElement._stopScrolling();const n=at.initEvent(t,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(n,this._ui(ot.dragElement)),this.triggerEvent("dropout",n),ot.dropElement===this&&(delete ot.dropElement,!e)){let e,n=this.el.parentElement;for(;!e&&n;)e=n.ddElement?.ddDroppable,n=n.parentElement;e&&e._mouseEnter(t)}}drop(t){t.preventDefault();const e=at.initEvent(t,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(e,this._ui(ot.dragElement)),this.triggerEvent("drop",e)}_canDrop(t){return t&&(!this.accept||this.accept(t))}_setupAccept(){return this.option.accept?("string"==typeof this.option.accept?this.accept=t=>t.classList.contains(this.option.accept)||t.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(t){return{draggable:t.el,...t.ui()}}}class kt{static init(t){return t.ddElement||(t.ddElement=new kt(t)),t.ddElement}constructor(t){this.el=t}on(t,e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(t)>-1?this.ddDraggable.on(t,e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(t)>-1?this.ddDroppable.on(t,e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(t)>-1&&this.ddResizable.on(t,e),this}off(t){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(t)>-1?this.ddDraggable.off(t):this.ddDroppable&&["drop","dropover","dropout"].indexOf(t)>-1?this.ddDroppable.off(t):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(t)>-1&&this.ddResizable.off(t),this}setupDraggable(t){return this.ddDraggable?this.ddDraggable.updateOption(t):this.ddDraggable=new wt(this.el,t),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(t){return this.ddResizable?this.ddResizable.updateOption(t):this.ddResizable=new bt(this.el,t),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(t){return this.ddDroppable?this.ddDroppable.updateOption(t):this.ddDroppable=new Tt(this.el,t),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}const Et=new class{resizable(t,e,n,a){return this._getDDElements(t,e).forEach(t=>{if("disable"===e||"enable"===e)t.ddResizable&&t.ddResizable[e]();else if("destroy"===e)t.ddResizable&&t.cleanResizable();else if("option"===e)t.setupResizable({[n]:a});else{const n=t.el.gridstackNode.grid;let a=t.el.getAttribute("gs-resize-handles")||n.opts.resizable.handles||"e,s,se";"all"===a&&(a="n,e,s,w,se,sw,ne,nw");const r=!n.opts.alwaysShowResizeHandle;t.setupResizable({...n.opts.resizable,handles:a,autoHide:r,start:e.start,stop:e.stop,resize:e.resize,rtl:e.rtl})}}),this}draggable(t,e,n,a){return this._getDDElements(t,e).forEach(t=>{if("disable"===e||"enable"===e)t.ddDraggable&&t.ddDraggable[e]();else if("destroy"===e)t.ddDraggable&&t.cleanDraggable();else if("option"===e)t.setupDraggable({[n]:a});else{const n=t.el.gridstackNode.grid;t.setupDraggable({...n.opts.draggable,start:e.start,stop:e.stop,drag:e.drag,rtl:e.rtl})}}),this}dragIn(t,e){return this._getDDElements(t).forEach(t=>t.setupDraggable(e)),this}droppable(t,e,n,a){return"function"!=typeof e.accept||e._accept||(e._accept=e.accept,e.accept=t=>e._accept(t)),this._getDDElements(t,e).forEach(t=>{"disable"===e||"enable"===e?t.ddDroppable&&t.ddDroppable[e]():"destroy"===e?t.ddDroppable&&t.cleanDroppable():"option"===e?t.setupDroppable({[n]:a}):t.setupDroppable(e)}),this}isDroppable(t){return!(!t?.ddElement?.ddDroppable||t.ddElement.ddDroppable.disabled)}isDraggable(t){return!(!t?.ddElement?.ddDraggable||t.ddElement.ddDraggable.disabled)}isResizable(t){return!(!t?.ddElement?.ddResizable||t.ddElement.ddResizable.disabled)}on(t,e,n){return this._getDDElements(t).forEach(t=>t.on(e,t=>{n(t,ot.dragElement?ot.dragElement.el:t.target,ot.dragElement?ot.dragElement.helper:null)})),this}off(t,e){return this._getDDElements(t).forEach(t=>t.off(e)),this}_getDDElements(t,e){const n=t.gridstack||"destroy"!==e&&"disable"!==e,a=at.getElements(t);if(!a.length)return[];const r=a.map(t=>t.ddElement||(n?kt.init(t):null)).filter(t=>t);return r}};class xt{static init(t={},e=".grid-stack"){if("undefined"==typeof document)return null;const n=xt.getGridElement(e);return n?(n.gridstack||(n.gridstack=new xt(n,at.cloneDeep(t))),n.gridstack):("string"==typeof e?console.error('GridStack.initAll() no grid was found with selector "'+e+'" - element missing or wrong selector ?\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.'):console.error("GridStack.init() no grid element was passed."),null)}static initAll(t={},e=".grid-stack"){const n=[];return"undefined"==typeof document||(xt.getGridElements(e).forEach(e=>{e.gridstack||(e.gridstack=new xt(e,at.cloneDeep(t))),n.push(e.gridstack)}),0===n.length&&console.error('GridStack.initAll() no grid was found with selector "'+e+'" - element missing or wrong selector ?\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.')),n}static addGrid(t,e={}){if(!t)return null;let n=t;if(n.gridstack){const t=n.gridstack;return e&&(t.opts={...t.opts,...e}),void 0!==e.children&&t.load(e.children),t}return t.classList.contains("grid-stack")&&!xt.addRemoveCB||(n=xt.addRemoveCB?xt.addRemoveCB(t,e,!0,!0):at.createDiv(["grid-stack",e.class],t)),xt.init(e,n)}static registerEngine(t){xt.engineClass=t}get placeholder(){if(!this._placeholder){this._placeholder=at.createDiv([this.opts.placeholderClass,it.itemClass,this.opts.itemClass]);const t=at.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(t.textContent=this.opts.placeholderText)}return this._placeholder}constructor(t,e={}){this.el=t,this.opts=e,this.animationDelay=310,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},t.gridstack=this,this.opts=e=e||{},t.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),e.row&&(e.minRow=e.maxRow=e.row,delete e.row);const n=at.toNumber(t.getAttribute("gs-row"));"auto"===e.column&&delete e.column,void 0!==e.alwaysShowResizeHandle&&(e._alwaysShowResizeHandle=e.alwaysShowResizeHandle);const a=e.columnOpts;if(a){const t=a.breakpoints;a.columnWidth||t?.length?(a.columnMax=a.columnMax||12,t?.length>1&&t.sort((t,e)=>(e.w||0)-(t.w||0))):delete e.columnOpts}const r={...at.cloneDeep(it),column:at.toNumber(t.getAttribute("gs-column"))||it.column,minRow:n||at.toNumber(t.getAttribute("gs-min-row"))||it.minRow,maxRow:n||at.toNumber(t.getAttribute("gs-max-row"))||it.maxRow,staticGrid:at.toBool(t.getAttribute("gs-static"))||it.staticGrid,sizeToContent:at.toBool(t.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||it.draggable.handle},removableOptions:{accept:e.itemClass||it.removableOptions.accept,decline:it.removableOptions.decline}};t.getAttribute("gs-animate")&&(r.animate=at.toBool(t.getAttribute("gs-animate"))),e=at.defaults(e,r),this._initMargin(),this.checkDynamicColumn(),this._updateColumnVar(e),"auto"===e.rtl&&(e.rtl="rtl"===t.style.direction),e.rtl&&this.el.classList.add("grid-stack-rtl");const i=this.el.closest("."+it.itemClass),o=i?.gridstackNode;if(o&&(o.subGrid=this,this.parentGridNode=o,this.el.classList.add("grid-stack-nested"),o.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight="auto"===e.cellHeight,this._isAutoCellHeight||"initial"===e.cellHeight)this.cellHeight(void 0);else{"number"==typeof e.cellHeight&&e.cellHeightUnit&&e.cellHeightUnit!==it.cellHeightUnit&&(e.cellHeight=e.cellHeight+e.cellHeightUnit,delete e.cellHeightUnit);const t=e.cellHeight;delete e.cellHeight,this.cellHeight(t)}"mobile"===e.alwaysShowResizeHandle&&(e.alwaysShowResizeHandle=st),this._setStaticClass();const s=e.engineClass||xt.engineClass||rt;if(this.engine=new s({column:this.getColumn(),float:e.float,maxRow:e.maxRow,onChange:t=>{t.forEach(t=>{const e=t.el;e&&(t._removeDOM?(e&&e.remove(),delete t._removeDOM):this._writePosAttr(e,t))}),this._updateContainerHeight()}}),e.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(t=>this._prepareElement(t)),delete this.engine._loading,this.batchUpdate(!1)),e.children){const t=e.children;delete e.children,t.length&&this.load(t)}this.setAnimation(),e.subGridDynamic&&!ot.pauseDrag&&(ot.pauseDrag=!0),void 0!==e.draggable?.pause&&(ot.pauseDrag=e.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}_updateColumnVar(t=this.opts){this.el.classList.add("gs-"+t.column),"number"==typeof t.column&&this.el.style.setProperty("--gs-column-width",100/t.column+"%")}addWidget(t){if(!t)return;if("string"==typeof t)return void console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");if(t.ELEMENT_NODE)return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"),this.makeWidget(t);let e,n=t;if(n.grid=this,e=n.el?n.el:xt.addRemoveCB?xt.addRemoveCB(this.el,t,!0,!1):this.createWidgetDivs(n),!e)return;if(n=e.gridstackNode,n&&e.parentElement===this.el&&this.engine.nodes.find(t=>t._id===n._id))return e;const a=this._readAttr(e);return at.defaults(t,a),this.engine.prepareNode(t),this.el.appendChild(e),this.makeWidget(e,t),e}createWidgetDivs(t){const e=at.createDiv(["grid-stack-item",this.opts.itemClass]),n=at.createDiv(["grid-stack-item-content"],e);return at.lazyLoad(t)?t.visibleObservable||(t.visibleObservable=new IntersectionObserver(([e])=>{e.isIntersecting&&(t.visibleObservable?.disconnect(),delete t.visibleObservable,xt.renderCB(n,t),t.grid?.prepareDragDrop(t.el))}),window.setTimeout(()=>t.visibleObservable?.observe(e))):xt.renderCB(n,t),e}makeSubGrid(t,e,n,a=!0){let r,i=t.gridstackNode;if(i||(i=this.makeWidget(t).gridstackNode),i.subGrid?.el)return i.subGrid;let o,s=this;for(;s&&!r;)r=s.opts?.subGridOpts,s=s.parentGridNode?.grid;e=at.cloneDeep({...this.opts,id:void 0,children:void 0,column:"auto",columnOpts:void 0,layout:"list",subGridOpts:void 0,...r||{},...e||i.subGridOpts||{}}),i.subGridOpts=e,"auto"===e.column&&(o=!0,e.column=Math.max(i.w||1,n?.w||1),delete e.columnOpts);let c,l,u=i.el.querySelector(".grid-stack-item-content");if(a&&(this._removeDD(i.el),l={...i,x:0,y:0},at.removeInternalForSave(l),delete l.subGridOpts,i.content&&(l.content=i.content,delete i.content),xt.addRemoveCB?c=xt.addRemoveCB(this.el,l,!0,!1):(c=at.createDiv(["grid-stack-item"]),c.appendChild(u),u=at.createDiv(["grid-stack-item-content"],i.el)),this.prepareDragDrop(i.el)),n){const t=o?e.column:i.w,a=i.h+n.h,r=i.el.style;r.transition="none",this.update(i.el,{w:t,h:a}),setTimeout(()=>r.transition=null)}const d=i.subGrid=xt.addGrid(u,e);return n?._moving&&(d._isTemp=!0),o&&(d._autoColumn=!0),a&&d.makeWidget(c,l),n&&(n._moving?window.setTimeout(()=>at.simulateMouseEvent(n._event,"mouseenter",d.el),0):d.makeWidget(i.el,i)),this.resizeToContentCheck(!1,i),d}removeAsSubGrid(t){const e=this.parentGridNode?.grid;e&&(e.batchUpdate(),e.removeWidget(this.parentGridNode.el,!0,!0),this.engine.nodes.forEach(t=>{t.x+=this.parentGridNode.x,t.y+=this.parentGridNode.y,e.makeWidget(t.el,t)}),e.batchUpdate(!1),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,t&&window.setTimeout(()=>at.simulateMouseEvent(t._event,"mouseenter",e.el),0))}save(t=!0,e=!1,n=xt.saveCB,a){const r=this.engine.save(t,n,a);if(r.forEach(a=>{if(t&&a.el&&!a.subGrid&&!n){const t=a.el.querySelector(".grid-stack-item-content");a.content=t?.innerHTML,a.content||delete a.content}else if(t||n||delete a.content,a.subGrid?.el){const r=a.w||a.subGrid.getColumn(),i=a.subGrid.save(t,e,n,r);a.subGridOpts=e?i:{children:i},delete a.subGrid}delete a.el}),e){const t=at.cloneDeep(this.opts);t.marginBottom===t.marginTop&&t.marginRight===t.marginLeft&&t.marginTop===t.marginRight&&(t.margin=t.marginTop,delete t.marginTop,delete t.marginRight,delete t.marginBottom,delete t.marginLeft),t.rtl===("rtl"===this.el.style.direction)&&(t.rtl="auto"),this._isAutoCellHeight&&(t.cellHeight="auto"),this._autoColumn&&(t.column="auto");const e=t._alwaysShowResizeHandle;return delete t._alwaysShowResizeHandle,void 0!==e?t.alwaysShowResizeHandle=e:delete t.alwaysShowResizeHandle,at.removeInternalAndSame(t,it),t.children=r,t}return r}load(t,e=xt.addRemoveCB||!0){t.forEach(t=>{t.w=t.w||t.minW||1,t.h=t.h||t.minH||1}),t=at.sort(t),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let n=0;t.forEach(t=>{n=Math.max(n,(t.x||0)+t.w)}),n>this.engine.defaultColumn&&(this.engine.defaultColumn=n);const a=this.getColumn();n>a&&(0===this.engine.nodes.length&&this.responseLayout?(this.engine.nodes=t,this.engine.columnChanged(n,a,this.responseLayout),t=this.engine.nodes,this.engine.nodes=[],delete this.responseLayout):this.engine.cacheLayout(t,n,!0));const r=xt.addRemoveCB;"function"==typeof e&&(xt.addRemoveCB=e);const i=[];this.batchUpdate();const o=!this.engine.nodes.length,s=o&&this.opts.animate;s&&this.setAnimation(!1),!o&&e&&[...this.engine.nodes].forEach(e=>{e.id&&(at.find(t,e.id)||(xt.addRemoveCB&&xt.addRemoveCB(this.el,e,!1,!1),i.push(e),this.removeWidget(e.el,!0,!1)))}),this.engine._loading=!0;const c=[];return this.engine.nodes=this.engine.nodes.filter(e=>!at.find(t,e.id)||(c.push(e),!1)),t.forEach(t=>{const n=at.find(c,t.id);if(n){if(at.shouldSizeToContent(n)&&(t.h=n.h),this.engine.nodeBoundFix(t),(t.autoPosition||void 0===t.x||void 0===t.y)&&(t.w=t.w||n.w,t.h=t.h||n.h,this.engine.findEmptyPosition(t)),this.engine.nodes.push(n),at.samePos(n,t)&&this.engine.nodes.length>1&&(this.moveNode(n,{...t,forceCollide:!0}),at.copyPos(t,n)),this.update(n.el,t),t.subGridOpts?.children){const e=n.el.querySelector(".grid-stack");e&&e.gridstack&&e.gridstack.load(t.subGridOpts.children)}}else e&&this.addWidget(t)}),delete this.engine._loading,this.engine.removedNodes=i,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,r?xt.addRemoveCB=r:delete xt.addRemoveCB,s&&this.setAnimation(!0,!0),this}batchUpdate(t=!0){return this.engine.batchUpdate(t),t||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(t=!1){if(this.opts.cellHeight&&"auto"!==this.opts.cellHeight&&(!t||!this.opts.cellHeightUnit||"px"===this.opts.cellHeightUnit))return this.opts.cellHeight;if("rem"===this.opts.cellHeightUnit)return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if("em"===this.opts.cellHeightUnit)return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if("cm"===this.opts.cellHeightUnit)return this.opts.cellHeight*(96/2.54);if("mm"===this.opts.cellHeightUnit)return this.opts.cellHeight*(96/2.54)/10;const e=this.el.querySelector("."+this.opts.itemClass);if(e){const t=at.toNumber(e.getAttribute("gs-h"))||1;return Math.round(e.offsetHeight/t)}const n=parseInt(this.el.getAttribute("gs-current-row"));return n?Math.round(this.el.getBoundingClientRect().height/n):this.opts.cellHeight}cellHeight(t){if(void 0!==t&&this._isAutoCellHeight!==("auto"===t)&&(this._isAutoCellHeight="auto"===t,this._updateResizeEvent()),"initial"!==t&&"auto"!==t||(t=void 0),void 0===t){const e=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;t=this.cellWidth()+e}const e=at.parseHeight(t);return this.opts.cellHeightUnit===e.unit&&this.opts.cellHeight===e.h||(this.opts.cellHeightUnit=e.unit,this.opts.cellHeight=e.h,this.el.style.setProperty("--gs-cell-height",`${this.opts.cellHeight}${this.opts.cellHeightUnit}`),this._updateContainerHeight(),this.resizeToContentCheck()),this}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(t=!1){return t&&this.opts.columnOpts?.breakpointForWindow?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){const t=this.opts.columnOpts;if(!t||!t.columnWidth&&!t.breakpoints?.length)return!1;const e=this.getColumn();let n=e;const a=this._widthOrContainer(!0);if(t.columnWidth)n=Math.min(Math.round(a/t.columnWidth)||1,t.columnMax);else{n=t.columnMax;let r=0;for(;rt.c===n);return this.column(n,e?.layout||t.layout),!0}return!1}compact(t="compact",e=!0){return this.engine.compact(t,e),this._triggerChangeEvent(),this}column(t,e="moveScale"){if(!t||t<1||this.opts.column===t)return this;const n=this.getColumn();return this.opts.column=t,this.engine?(this.engine.column=t,this.el.classList.remove("gs-"+n),this._updateColumnVar(),this.engine.columnChanged(n,t,e),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):(this.responseLayout=e,this)}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(t=>t.matches("."+this.opts.itemClass)&&!t.matches("."+this.opts.placeholderClass))}isIgnoreChangeCB(){return this._ignoreLayoutsNodeChange}destroy(t=!0){if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),t?this.el.parentNode.removeChild(this.el):(this.removeAll(t),this.el.removeAttribute("gs-current-row")),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,delete this.opts,delete this._placeholder?.gridstackNode,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(t){return this.opts.float!==t&&(this.opts.float=this.engine.float=t,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(t,e=!1){const n=this.el.getBoundingClientRect();let a;a=e?{top:n.top+document.documentElement.scrollTop,left:n.left}:{top:this.el.offsetTop,left:this.el.offsetLeft};const r=t.left-a.left,i=t.top-a.top,o=n.width/this.getColumn(),s=n.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(r/o),y:Math.floor(i/s)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow||0)}isAreaEmpty(t,e,n,a){return this.engine.isAreaEmpty(t,e,n,a)}makeWidget(t,e){const n=xt.getElement(t);if(!n||n.gridstackNode)return n;n.parentElement||this.el.appendChild(n),this._prepareElement(n,!0,e);const a=n.gridstackNode;let r;return this._updateContainerHeight(),a.subGridOpts&&this.makeSubGrid(n,a.subGridOpts,void 0,!1),1!==this.opts.column||this._ignoreLayoutsNodeChange||(r=this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),r&&delete this._ignoreLayoutsNodeChange,n}on(t,e){if(-1!==t.indexOf(" "))return t.split(" ").forEach(t=>this.on(t,e)),this;if("change"===t||"added"===t||"removed"===t||"enable"===t||"disable"===t){const n="enable"===t||"disable"===t;this._gsEventHandler[t]=n?t=>e(t):t=>{t.detail&&e(t,t.detail)},this.el.addEventListener(t,this._gsEventHandler[t])}else"drag"===t||"dragstart"===t||"dragstop"===t||"resizestart"===t||"resize"===t||"resizestop"===t||"dropped"===t||"resizecontent"===t?this._gsEventHandler[t]=e:console.error("GridStack.on("+t+") event not supported");return this}off(t){return-1!==t.indexOf(" ")?(t.split(" ").forEach(t=>this.off(t)),this):("change"!==t&&"added"!==t&&"removed"!==t&&"enable"!==t&&"disable"!==t||this._gsEventHandler[t]&&this.el.removeEventListener(t,this._gsEventHandler[t]),delete this._gsEventHandler[t],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(t=>this.off(t)),this}removeWidget(t,e=!0,n=!0){return t?(xt.getElements(t).forEach(t=>{if(t.parentElement&&t.parentElement!==this.el)return;let a=t.gridstackNode;a||(a=this.engine.nodes.find(e=>t===e.el)),a&&(e&&xt.addRemoveCB&&xt.addRemoveCB(this.el,a,!1,!1),delete t.gridstackNode,this._removeDD(t),this.engine.removeNode(a,e,n),e&&t.parentElement&&t.remove())}),n&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this):(console.error("Error: GridStack.removeWidget(undefined) called"),this)}removeAll(t=!0,e=!0){return this.engine.nodes.forEach(e=>{t&&xt.addRemoveCB&&xt.addRemoveCB(this.el,e,!1,!1),delete e.el.gridstackNode,this.opts.staticGrid||this._removeDD(e.el)}),this.engine.removeAll(t,e),e&&this._triggerRemoveEvent(),this}setAnimation(t=this.opts.animate,e){return e?setTimeout(()=>{this.opts&&this.setAnimation(t)}):t?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this.opts.animate=t,this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(t,e=!0,n=!0){return!!this.opts.staticGrid===t||(t?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(a=>{this.prepareDragDrop(a.el),a.subGrid&&n&&a.subGrid.setStatic(t,e,n)}),e&&this._setStaticClass()),this}updateOptions(t){const e=this.opts;if(t===e)return this;if(void 0!==t.acceptWidgets&&(e.acceptWidgets=t.acceptWidgets,this._setupAcceptWidget()),void 0!==t.animate&&this.setAnimation(t.animate),t.cellHeight&&this.cellHeight(t.cellHeight),void 0!==t.class&&t.class!==e.class&&(e.class&&this.el.classList.remove(e.class),t.class&&this.el.classList.add(t.class)),t.columnOpts){const e=!!this.opts.columnOpts;this.opts.columnOpts=t.columnOpts,e!==!!this.opts.columnOpts&&this._updateResizeEvent(),this.checkDynamicColumn()}else null===t.columnOpts&&this.opts.columnOpts?(delete this.opts.columnOpts,this._updateResizeEvent()):"number"==typeof t.column&&this.column(t.column);return void 0!==t.margin&&this.margin(t.margin),void 0!==t.staticGrid&&this.setStatic(t.staticGrid),void 0===t.disableDrag||t.staticGrid||this.enableMove(!t.disableDrag),void 0===t.disableResize||t.staticGrid||this.enableResize(!t.disableResize),void 0!==t.float&&this.float(t.float),void 0!==t.row?(e.minRow=e.maxRow=e.row=t.row,this._updateContainerHeight()):(void 0!==t.minRow&&(e.minRow=t.minRow,this._updateContainerHeight()),void 0!==t.maxRow&&(e.maxRow=this.engine.maxRow=t.maxRow)),void 0!==t.lazyLoad&&(e.lazyLoad=t.lazyLoad),t.children?.length&&this.load(t.children),this}update(t,e){return xt.getElements(t).forEach(t=>{const n=t?.gridstackNode;if(!n)return;const a={...at.copyPos({},n),...at.cloneDeep(e)};this.engine.nodeBoundFix(a),delete a.autoPosition;const r=["x","y","w","h"];let i;if(r.some(t=>void 0!==a[t]&&a[t]!==n[t])&&(i={},r.forEach(t=>{i[t]=void 0!==a[t]?a[t]:n[t],delete a[t]})),!i&&(a.minW||a.minH||a.maxW||a.maxH)&&(i={}),void 0!==a.content){const e=t.querySelector(".grid-stack-item-content");e&&e.textContent!==a.content&&(n.content=a.content,xt.renderCB(e,a),n.subGrid?.el&&(e.appendChild(n.subGrid.el),n.subGrid._updateContainerHeight())),delete a.content}let o=!1,s=!1;for(const t in a)"_"!==t[0]&&n[t]!==a[t]&&(n[t]=a[t],o=!0,s=s||!this.opts.staticGrid&&("noResize"===t||"noMove"===t||"locked"===t));if(at.sanitizeMinMax(n),i){const t=void 0!==i.w&&i.w!==n.w;this.moveNode(n,i),t&&n.subGrid?n.subGrid.onResize(this.hasAnimationCSS()?n.w:void 0):this.resizeToContentCheck(t,n),delete n._orig}(i||o)&&this._writeAttr(t,n),s&&this.prepareDragDrop(n.el),xt.updateCB&&xt.updateCB(n)}),this}moveNode(t,e){const n=t._updating;n||this.engine.cleanNodes().beginUpdate(t),this.engine.moveNode(t,e),this._updateContainerHeight(),n||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(t){if(!t)return;if(t.classList.remove("size-to-content-max"),!t.clientHeight)return;const e=t.gridstackNode;if(!e)return;const n=e.grid;if(!n||t.parentElement!==n.el)return;const a=n.getCellHeight(!0);if(!a)return;let r,i=e.h?e.h*a:t.clientHeight;if(e.resizeToContentParent&&(r=t.querySelector(e.resizeToContentParent)),r||(r=t.querySelector(xt.resizeToContentParent)),!r)return;const o=t.clientHeight-r.clientHeight,s=e.h?e.h*a-o:r.clientHeight;let c;if(e.subGrid){c=e.subGrid.getRow()*e.subGrid.getCellHeight(!0);const n=e.subGrid.el.getBoundingClientRect(),a=t.getBoundingClientRect();c+=n.top-a.top}else{if(e.subGridOpts?.children?.length)return;{const t=r.firstElementChild;if(!t)return void console.error(`Error: GridStack.resizeToContent() widget id:${e.id} '${xt.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);c=t.getBoundingClientRect().height||s}}if(s===c)return;i+=c-s;let l=Math.ceil(i/a);const u=Number.isInteger(e.sizeToContent)?e.sizeToContent:0;u&&l>u&&(l=u,t.classList.add("size-to-content-max")),e.minH&&le.maxH&&(l=e.maxH),l!==e.h&&(n._ignoreLayoutsNodeChange=!0,n.moveNode(e,{h:l}),delete n._ignoreLayoutsNodeChange)}resizeToContentCBCheck(t){xt.resizeToContentCB?xt.resizeToContentCB(t):this.resizeToContent(t)}rotate(t,e){return xt.getElements(t).forEach(t=>{const n=t.gridstackNode;if(!at.canBeRotated(n))return;const a={w:n.h,h:n.w,minH:n.minW,minW:n.minH,maxH:n.maxW,maxW:n.maxH};if(e){const t=e.left>0?Math.floor(e.left/this.cellWidth()):0,r=e.top>0?Math.floor(e.top/this.opts.cellHeight):0;a.x=n.x+t-(n.h-(r+1)),a.y=n.y+r-t}Object.keys(a).forEach(t=>{void 0===a[t]&&delete a[t]});const r=n._orig;this.update(t,a),n._orig=r}),this}margin(t){if(!("string"==typeof t&&t.split(" ").length>1)){const e=at.parseHeight(t);if(this.opts.marginUnit===e.unit&&this.opts.margin===e.h)return}return this.opts.margin=t,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this}getMargin(){return this.opts.margin}willItFit(t){return this.engine.willItFit(t)}_triggerChangeEvent(){if(this.engine.batchMode)return this;const t=this.engine.getDirtyNodes(!0);return t&&t.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(t),this._triggerEvent("change",t)),this.engine.saveInitial(),this}_triggerAddEvent(){if(this.engine.batchMode)return this;if(this.engine.addedNodes?.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(t=>{delete t._dirty});const t=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",t)}return this}_triggerRemoveEvent(){if(this.engine.batchMode)return this;if(this.engine.removedNodes?.length){const t=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",t)}return this}_triggerEvent(t,e){const n=e?new CustomEvent(t,{bubbles:!1,detail:e}):new Event(t);let a=this;for(;a.parentGridNode;)a=a.parentGridNode.grid;return a.el.dispatchEvent(n),this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;const t=this.parentGridNode;let e=this.getRow()+this._extraDragRow;const n=this.opts.cellHeight,a=this.opts.cellHeightUnit;if(!n)return this;if(!t&&!this.opts.minRow){const t=at.parseHeight(getComputedStyle(this.el).minHeight);if(t.h>0&&t.unit===a){const a=Math.floor(t.h/n);e1?`calc(${e.w} * var(--gs-column-width))`:null,t.style.height=e.h>1?`calc(${e.h} * var(--gs-cell-height))`:null}return t.setAttribute("gs-x",String(e.x)),t.setAttribute("gs-y",String(e.y)),e.w>1?t.setAttribute("gs-w",String(e.w)):t.removeAttribute("gs-w"),e.h>1?t.setAttribute("gs-h",String(e.h)):t.removeAttribute("gs-h"),this}_writeAttr(t,e){if(!e)return this;this._writePosAttr(t,e);const n={noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",sizeToContent:"gs-size-to-content"};for(const a in n)e[a]?t.setAttribute(n[a],String(e[a])):t.removeAttribute(n[a]);return this}_readAttr(t,e=!0){const n={};n.x=at.toNumber(t.getAttribute("gs-x")),n.y=at.toNumber(t.getAttribute("gs-y")),n.w=at.toNumber(t.getAttribute("gs-w")),n.h=at.toNumber(t.getAttribute("gs-h")),n.autoPosition=at.toBool(t.getAttribute("gs-auto-position")),n.noResize=at.toBool(t.getAttribute("gs-no-resize")),n.noMove=at.toBool(t.getAttribute("gs-no-move")),n.locked=at.toBool(t.getAttribute("gs-locked"));const a=t.getAttribute("gs-size-to-content");a&&(n.sizeToContent="true"===a||"false"===a?at.toBool(a):parseInt(a,10)),n.id=t.getAttribute("gs-id"),n.maxW=at.toNumber(t.getAttribute("gs-max-w")),n.minW=at.toNumber(t.getAttribute("gs-min-w")),n.maxH=at.toNumber(t.getAttribute("gs-max-h")),n.minH=at.toNumber(t.getAttribute("gs-min-h")),e&&(1===n.w&&t.removeAttribute("gs-w"),1===n.h&&t.removeAttribute("gs-h"),n.maxW&&t.removeAttribute("gs-max-w"),n.minW&&t.removeAttribute("gs-min-w"),n.maxH&&t.removeAttribute("gs-max-h"),n.minH&&t.removeAttribute("gs-min-h"));for(const t in n){if(!n.hasOwnProperty(t))return;n[t]||0===n[t]||"sizeToContent"===t||delete n[t]}return n}_setStaticClass(){const t=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...t),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...t),this.el.removeAttribute("gs-static")),this}onResize(t=this.el?.clientWidth){if(!t)return;if(this.prevWidth===t)return;this.prevWidth=t,this.batchUpdate();let e=!1;return this._autoColumn&&this.parentGridNode?this.opts.column!==this.parentGridNode.w&&(this.column(this.parentGridNode.w,this.opts.layout||"list"),e=!0):e=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(t=>{t.subGrid&&t.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(e),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(t=!1,e=void 0){if(this.engine){if(t&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,e),this.animationDelay);if(e)at.shouldSizeToContent(e)&&this.resizeToContentCBCheck(e.el);else if(this.engine.nodes.some(t=>at.shouldSizeToContent(t))){const t=[...this.engine.nodes];this.batchUpdate(),t.forEach(t=>{at.shouldSizeToContent(t)&&this.resizeToContentCBCheck(t.el)}),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(!1),this._ignoreLayoutsNodeChange=!1}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,e?[e]:this.engine.nodes)}}_updateResizeEvent(t=!1){const e=!this.parentGridNode&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(t=>t.sizeToContent));return t||!e||this.resizeObserver?!t&&e||!this.resizeObserver||(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle):(this._sizeThrottle=at.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0),this}static getElement(t=".grid-stack-item"){return at.getElement(t)}static getElements(t=".grid-stack-item"){return at.getElements(t)}static getGridElement(t){return xt.getElement(t)}static getGridElements(t){return at.getElements(t)}_initMargin(){let t,e=0,n=[];"string"==typeof this.opts.margin&&(n=this.opts.margin.split(" ")),2===n.length?(this.opts.marginTop=this.opts.marginBottom=n[0],this.opts.marginLeft=this.opts.marginRight=n[1]):4===n.length?(this.opts.marginTop=n[0],this.opts.marginRight=n[1],this.opts.marginBottom=n[2],this.opts.marginLeft=n[3]):(t=at.parseHeight(this.opts.margin),this.opts.marginUnit=t.unit,e=this.opts.margin=t.h),["marginTop","marginRight","marginBottom","marginLeft"].forEach(n=>{void 0===this.opts[n]?this.opts[n]=e:(t=at.parseHeight(this.opts[n]),this.opts[n]=t.h,delete this.opts.margin)}),this.opts.marginUnit=t.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop);const a=this.el.style;return a.setProperty("--gs-item-margin-top",`${this.opts.marginTop}${this.opts.marginUnit}`),a.setProperty("--gs-item-margin-bottom",`${this.opts.marginBottom}${this.opts.marginUnit}`),a.setProperty("--gs-item-margin-right",`${this.opts.marginRight}${this.opts.marginUnit}`),a.setProperty("--gs-item-margin-left",`${this.opts.marginLeft}${this.opts.marginUnit}`),this}static getDD(){return Et}static setupDragIn(t,e,n,a=document){void 0!==e?.pause&&(ot.pauseDrag=e.pause),e={appendTo:"body",helper:"clone",...e||{}},("string"==typeof t?at.getElements(t,a):t).forEach((t,a)=>{Et.isDraggable(t)||Et.dragIn(t,e),n?.[a]&&(t.gridstackNode=n[a])})}movable(t,e){return this.opts.staticGrid||xt.getElements(t).forEach(t=>{const n=t.gridstackNode;n&&(e?delete n.noMove:n.noMove=!0,this.prepareDragDrop(n.el))}),this}resizable(t,e){return this.opts.staticGrid||xt.getElements(t).forEach(t=>{const n=t.gridstackNode;n&&(e?delete n.noResize:n.noResize=!0,this.prepareDragDrop(n.el))}),this}disable(t=!0){if(!this.opts.staticGrid)return this.enableMove(!1,t),this.enableResize(!1,t),this._triggerEvent("disable"),this}enable(t=!0){if(!this.opts.staticGrid)return this.enableMove(!0,t),this.enableResize(!0,t),this._triggerEvent("enable"),this}enableMove(t,e=!0){return this.opts.staticGrid||(t?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(n=>{this.prepareDragDrop(n.el),n.subGrid&&e&&n.subGrid.enableMove(t,e)})),this}enableResize(t,e=!0){return this.opts.staticGrid||(t?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(n=>{this.prepareDragDrop(n.el),n.subGrid&&e&&n.subGrid.enableResize(t,e)})),this}cancelDrag(){const t=this._placeholder?.gridstackNode;t&&(t._isExternal?(t._isAboutToRemove=!0,this.engine.removeNode(t)):t._isAboutToRemove&&xt._itemRemoving(t.el,!1),this.engine.restoreInitial())}_removeDD(t){return Et.draggable(t,"destroy").resizable(t,"destroy"),t.gridstackNode&&delete t.gridstackNode._initDD,delete t.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return Et.droppable(this.el,"destroy"),this;let t,e;const n=(n,a,r)=>{const i=(r=r||a).gridstackNode;if(!i)return;if(!i.grid?.el){r.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;const t=r.getBoundingClientRect();r.style.left=t.x+(this.dragTransform.xScale-1)*(n.clientX-t.x)/this.dragTransform.xScale+"px",r.style.top=t.y+(this.dragTransform.yScale-1)*(n.clientY-t.y)/this.dragTransform.yScale+"px",r.style.transformOrigin="0px 0px"}let{top:o,left:s}=r.getBoundingClientRect();const c=this.el.getBoundingClientRect();s-=c.left,o-=c.top;const l={position:{top:o*this.dragTransform.xScale,left:s*this.dragTransform.yScale}};if(i._temporaryRemoved){if(i.x=Math.max(0,Math.round(s/e)),i.y=Math.max(0,Math.round(o/t)),delete i.autoPosition,this.engine.nodeBoundFix(i),!this.engine.willItFit(i)){if(i.autoPosition=!0,!this.engine.willItFit(i))return void Et.off(a,"drag");i._willFitPos&&(at.copyPos(i,i._willFitPos),delete i._willFitPos)}this._onStartMoving(r,n,l,i,e,t)}else this._dragOrResize(r,n,l,i,e,t)};return Et.droppable(this.el,{accept:t=>{const e=t.gridstackNode||this._readAttr(t,!1);if(e?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let n=!0;if("function"==typeof this.opts.acceptWidgets)n=this.opts.acceptWidgets(t);else{const e=!0===this.opts.acceptWidgets?".grid-stack-item":this.opts.acceptWidgets;n=t.matches(e)}if(n&&e&&this.opts.maxRow){const t={w:e.w,h:e.h,minW:e.minW,minH:e.minH};n=this.engine.willItFit(t)}return n}}).on(this.el,"dropover",(a,r,i)=>{let o=i?.gridstackNode||r.gridstackNode;if(o?.grid===this&&!o._temporaryRemoved)return!1;if(o?._sidebarOrig&&(o.w=o._sidebarOrig.w,o.h=o._sidebarOrig.h),o?.grid&&o.grid!==this&&!o._temporaryRemoved&&o.grid._leave(r,i),i=i||r,e=this.cellWidth(),t=this.getCellHeight(!0),!o){const t=i.getAttribute("data-gs-widget")||i.getAttribute("gridstacknode");if(t){try{o=JSON.parse(t)}catch(e){console.error("Gridstack dropover: Bad JSON format: ",t)}i.removeAttribute("data-gs-widget"),i.removeAttribute("gridstacknode")}o||(o=this._readAttr(i)),o._sidebarOrig={w:o.w,h:o.h}}o.grid||(o.el||(o={...o}),o._isExternal=!0,i.gridstackNode=o);const s=o.w||Math.round(i.offsetWidth/e)||1,c=o.h||Math.round(i.offsetHeight/t)||1;return o.grid&&o.grid!==this?(r._gridstackNodeOrig||(r._gridstackNodeOrig=o),r.gridstackNode=o={...o,w:s,h:c,grid:this},delete o.x,delete o.y,this.engine.cleanupNode(o).nodeBoundFix(o),o._initDD=o._isExternal=o._temporaryRemoved=!0):(o.w=s,o.h=c,o._temporaryRemoved=!0),xt._itemRemoving(o.el,!1),Et.on(r,"drag",n),n(a,r,i),!1}).on(this.el,"dropout",(t,e,n)=>{const a=n?.gridstackNode||e.gridstackNode;return!!a&&(a.grid&&a.grid!==this||(this._leave(e,n),this._isTemp&&this.removeAsSubGrid(a)),!1)}).on(this.el,"drop",(t,e,n)=>{const a=n?.gridstackNode||e.gridstackNode;if(a?.grid===this&&!a._isExternal)return!1;const r=!!this.placeholder.parentElement,i=e!==n;this.placeholder.remove(),delete this.placeholder.gridstackNode,r&&this.opts.animate&&(this.setAnimation(!1),this.setAnimation(!0,!0));const o=e._gridstackNodeOrig;if(delete e._gridstackNodeOrig,r&&o?.grid&&o.grid!==this){const t=o.grid;t.engine.removeNodeFromLayoutCache(o),t.engine.removedNodes.push(o),t._triggerRemoveEvent()._triggerChangeEvent(),t.parentGridNode&&!t.engine.nodes.length&&t.opts.subGridDynamic&&t.removeAsSubGrid()}if(!a)return!1;if(r&&(this.engine.cleanupNode(a),a.grid=this),delete a.grid?._isTemp,Et.off(e,"drag"),n!==e?(n.remove(),e=n):e.remove(),this._removeDD(e),!r)return!1;const s=a.subGrid?.el?.gridstack;return at.copyPos(a,this._readAttr(this.placeholder)),at.removePositioningStyles(e),i&&(a.content||a.subGridOpts||xt.addRemoveCB)?(delete a.el,e=this.addWidget(a)):(this._prepareElement(e,!0,a),this.el.appendChild(e),this.resizeToContentCheck(!1,a),s&&(s.parentGridNode=a),this._updateContainerHeight()),this.engine.addedNodes.push(a),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...t,type:"dropped"},o&&o.grid?o:void 0,a),!1}),this}static _itemRemoving(t,e){if(!t)return;const n=t?t.gridstackNode:void 0;n?.grid&&!t.classList.contains(n.grid.opts.removableOptions.decline)&&(e?n._isAboutToRemove=!0:delete n._isAboutToRemove,e?t.classList.add("grid-stack-item-removing"):t.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if("string"!=typeof this.opts.removable)return this;const t=document.querySelector(this.opts.removable);return t?(this.opts.staticGrid||Et.isDroppable(t)||Et.droppable(t,this.opts.removableOptions).on(t,"dropover",(t,e)=>xt._itemRemoving(e,!0)).on(t,"dropout",(t,e)=>xt._itemRemoving(e,!1)),this):this}prepareDragDrop(t,e=!1){const n=t?.gridstackNode;if(!n)return;const a=n.noMove||this.opts.disableDrag,r=n.noResize||this.opts.disableResize,i=this.opts.staticGrid||a&&r;if((e||i)&&(n._initDD&&(this._removeDD(t),delete n._initDD),i))return t.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!n._initDD){let e,a;const r=(r,i)=>{this.triggerEvent(r,r.target),e=this.cellWidth(),a=this.getCellHeight(!0),this._onStartMoving(t,r,i,n,e,a)},i=(r,i)=>{this._dragOrResize(t,r,i,n,e,a)},o=e=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete n._moving,delete n._resizing,delete n._event,delete n._lastTried;const a=n.w!==n._orig.w,r=e.target;if(r.gridstackNode&&r.gridstackNode.grid===this){if(n.el=r,n._isAboutToRemove){const a=t.gridstackNode.grid;a._gsEventHandler[e.type]&&a._gsEventHandler[e.type](e,r),a.engine.nodes.push(n),a.removeWidget(t,!0,!0)}else at.removePositioningStyles(r),n._temporaryRemoved?(this._writePosAttr(r,n),this.engine.addNode(n)):this._writePosAttr(r,n),this.triggerEvent(e,r);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),"resizestop"===e.type&&(Number.isInteger(n.sizeToContent)&&(n.sizeToContent=n.h),this.resizeToContentCheck(a,n))}};Et.draggable(t,{start:r,stop:o,drag:i,rtl:this.opts.rtl}).resizable(t,{start:r,stop:o,resize:i,rtl:this.opts.rtl}),n._initDD=!0}return Et.draggable(t,a?"disable":"enable").resizable(t,r?"disable":"enable"),this}_onStartMoving(t,e,n,a,r,i){if(this.engine.cleanNodes().beginUpdate(a),this._writePosAttr(this.placeholder,a),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=a,a.grid?.el)this.dragTransform=at.getValuesFromTransformedElement(t);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){const t=this.placeholder.closest(".grid-stack");this.dragTransform=at.getValuesFromTransformedElement(t)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(a.el=this.placeholder,a._lastUiPosition=n.position,a._prevYPix=n.position.top,a._moving="dragstart"===e.type,a._resizing="resizestart"===e.type,delete a._lastTried,"dropover"===e.type&&a._temporaryRemoved&&(this.engine.addNode(a),a._moving=!0),this.engine.cacheRects(r,i,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),"resizestart"===e.type){const e=this.getColumn()-a.x,n=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-a.y;Et.resizable(t,"option","minWidth",r*Math.min(a.minW||1,e)).resizable(t,"option","minHeight",i*Math.min(a.minH||1,n)).resizable(t,"option","maxWidth",r*Math.min(a.maxW||Number.MAX_SAFE_INTEGER,e)).resizable(t,"option","maxWidthMoveLeft",r*Math.min(a.maxW||Number.MAX_SAFE_INTEGER,a.x+a.w)).resizable(t,"option","maxHeight",i*Math.min(a.maxH||Number.MAX_SAFE_INTEGER,n)).resizable(t,"option","maxHeightMoveUp",i*Math.min(a.maxH||Number.MAX_SAFE_INTEGER,a.y+a.h))}}_dragOrResize(t,e,n,a,r,i){const o={...a._orig};let s,c=this.opts.marginLeft,l=this.opts.marginRight,u=this.opts.marginTop,d=this.opts.marginBottom;const h=Math.round(.1*i),g=Math.round(.1*r);if(c=Math.min(c,g),l=Math.min(l,g),u=Math.min(u,h),d=Math.min(d,h),"drag"===e.type){if(a._temporaryRemoved)return;a._prevYPix=n.position.top,!1!==this.opts.draggable.scroll&&ot.dragElement?.updateScrollPosition(this.el);const t=n.position.left+(n.position.left>a._lastUiPosition.left?-l:c),e=n.position.top+(n.position.top>a._lastUiPosition.top?-d:u);o.x=Math.round(t/r),o.y=Math.round(e/i);const s=this._extraDragRow;if(this.engine.collide(a,o)){const t=this.getRow();let e=Math.max(0,o.y+a.h-t);this.opts.maxRow&&t+e>this.opts.maxRow&&(e=Math.max(0,this.opts.maxRow-t)),this._extraDragRow=e}else this._extraDragRow=0;if(this._extraDragRow!==s&&this._updateContainerHeight(),a.x===o.x&&a.y===o.y)return}else if("resize"===e.type){if(o.x<0)return;if(at.updateScrollResize(e,t,i),o.w=Math.round((n.size.width-c)/r),o.h=Math.round((n.size.height-u)/i),a.w===o.w&&a.h===o.h)return;if(a._lastTried&&a._lastTried.w===o.w&&a._lastTried.h===o.h)return;if(e.hasMovedX){const t=n.position.left+c;o.x=Math.round(t/r)}if(e.hasMovedY){const t=n.position.top+u;o.y=Math.round(t/i)}s=!0}a._event=e,a._lastTried=o;const p={x:n.position.left+c,y:n.position.top+u,w:(n.size?n.size.width:a.w*r)-c-l,h:(n.size?n.size.height:a.h*i)-u-d};if(this.engine.moveNodeCheck(a,{...o,cellWidth:r,cellHeight:i,rect:p,resizing:s})){a._lastUiPosition=n.position,this.engine.cacheRects(r,i,u,l,d,c),delete a._skipDown,s&&a.subGrid&&a.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();const t=e.target;a._sidebarOrig||this._writePosAttr(t,a),this.triggerEvent(e,t)}}triggerEvent(t,e){let n=this;for(;n.parentGridNode;)n=n.parentGridNode.grid;n._gsEventHandler[t.type]&&n._gsEventHandler[t.type](t,e)}_leave(t,e){const n=(e=e||t).gridstackNode;if(!n)return;if(e.style.transform=e.style.transformOrigin=null,Et.off(t,"drag"),n._temporaryRemoved)return;n._temporaryRemoved=!0,this.engine.removeNode(n),n.el=n._isExternal&&e?e:t;const a=n._sidebarOrig;n._isExternal&&this.engine.cleanupNode(n),n._sidebarOrig=a,!0===this.opts.removable&&xt._itemRemoving(t,!0),t._gridstackNodeOrig?(t.gridstackNode=t._gridstackNodeOrig,delete t._gridstackNodeOrig):n._isExternal&&this.engine.restoreInitial()}}xt.renderCB=(t,e)=>{t&&e?.content&&(t.textContent=e.content)},xt.resizeToContentParent=".grid-stack-item-content",xt.Utils=at,xt.Engine=rt,xt.GDRev="12.6.0";var St=n(136),Ct=n(583);function It(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return At(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?At(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var a=0,r=function(){};return{s:r,n:function(){return a>=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function At(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);nt.length)&&(e=t.length);for(var n=0,a=Array(e);n=0?"positive":"negative").concat(e?" projected":""),o=e?' title="'.concat((0,i.Tl)("budget","Projected balance"),'"'):"",s=null!=t?'").concat(n(t,a),""):"";return''.concat(s,"")}function Pt(t,e){var n=e.currency,a=e.formatCurrency,r=e.formatDate,o="register"!==e.variant,c=(e.categories||[]).find(function(e){return e.id===t.categoryId}),l=Dt(t,c),u=(e.accounts||[]).find(function(e){return e.id===t.accountId}),d=t.isSplit||t.is_split,h=(0,b.Uv)(t),g="scheduled"===t.status,p=null!=t.linkedTransactionId,f=(0,i.Tl)("budget","No description"),m=function(t,e,n){var a=parseFloat(t.amount)||0,r=(0,b.Uv)(t),i=(0,b.TK)(t),o="credit"===t.type?i:-i,s=r?o>=0:"credit"===t.type,c=r?Math.abs(i):Math.abs(a),l=r&&Math.abs(Math.abs(i)-Math.abs(a))>.005;return{isCredit:s,text:(s?"+":"-")+n(c,e),whole:l?n(Math.abs(a),e):null}}(t,n,a),v=d?function(t,e,n){if(!t.splitCategories)return null;var a=function(t){return t.categoryName||(0,i.Tl)("budget","Uncategorized")};return{label:t.splitCategories.map(function(t){return''+(0,s.ZD)(a(t))+""}).join(" / "),title:t.splitCategories.map(function(t){return(0,s.ZD)(a(t)+": "+n(t.amount,e))}).join(" ")}}(t,n,a):null,y=function(t,e){var n=t.isSplit||t.is_split,a=(0,b.Uv)(t),r="scheduled"===t.status?'').concat((0,i.Tl)("budget","Scheduled"),""):"",o="pending"===t.status?'').concat((0,i.Tl)("budget","Pending"),""):"",c=t.excludedFromForecast?'').concat((0,i.Tl)("budget","No forecast"),""):"",l=e.attachmentCount,u=l?'📎').concat(l>1?" "+l:"",""):"",d="";if(null!=t.linkedTransactionId){var h,g=t.linkedAccountName||(null===(h=(e.accounts||[]).find(function(e){return e.id===t.linkedAccountId}))||void 0===h?void 0:h.name)||"",p="debit"===t.type?"→":"←",f=g?(0,i.Tl)("budget","Transfer {direction} {account}",{direction:p,account:(0,s.ZD)(g)},void 0,{escape:!1}):(0,i.Tl)("budget","Transfer"),m=g?(0,i.Tl)("budget","Click to view linked transaction in {account}",{account:(0,s.ZD)(g)},void 0,{escape:!1}):(0,i.Tl)("budget","Linked transfer");d='")}var v=r+o+c+u+d+(n?'').concat(a?(0,i.Tl)("budget","Split part"):(0,i.Tl)("budget","Split"),""):"")+("shared"===e.sharedStatus?'🤝 ').concat((0,i.Tl)("budget","Shared"),""):"settled"===e.sharedStatus?'✅ ').concat((0,i.Tl)("budget","Settled"),""):"")+(t.pensionContribId?'').concat((0,i.Tl)("budget","Pension"),""):"");return v?'
'.concat(v,"
"):""}(t,e),w=(0,k.kq)(u),T=w?' data-read-only="1"':"",E=w?"":"editable-cell",x=["transaction-row"];if(p&&x.push("is-linked"),t.reconciled&&x.push("is-reconciled"),g&&x.push("scheduled-transaction"),"pending"===t.status&&x.push("pending-transaction"),!o){var S=v?'').concat(v.label,""):d?''.concat((0,i.Tl)("budget","Split"),""):'").concat(null!==l?(0,s.ZD)(l):(0,i.Tl)("budget","Uncategorized"),"");return'\n \n \n ').concat(r(t.date),'\n \n \n
\n ").concat((0,s.ZD)(t.description)||f,"\n ").concat(t.reference?'").concat((0,s.ZD)(t.reference),""):"","\n ").concat(y,'\n
\n \n ").concat((0,s.ZD)(t.vendor||""),'\n \n ').concat(S,'\n
\n \n \n ').concat(m.text,"\n ").concat(m.whole?''.concat((0,i.Tl)("budget","of {total}",{total:m.whole}),""):"","\n \n ").concat(Lt(e.balance,g,a,n),'\n \n
\n ').concat(w?"":'\n '),"\n
\n \n \n ")}var C=v?''.concat(v.label,""):d?''.concat((0,i.Tl)("budget","Split"),""):'').concat(c&&c.color?''):"").concat(null!==l?(0,s.ZD)(l):(0,i.Tl)("budget","Uncategorized"),"");return'\n \n \n \n \n \n ').concat(r(t.date),'\n \n \n
\n ').concat((0,s.ZD)(t.description)||f,"\n ").concat(t.reference?''.concat((0,s.ZD)(t.reference),""):"","\n ").concat(y,'\n
\n \n \n ').concat((0,s.ZD)(t.vendor)||"-",'\n \n \n ").concat(C,'\n \n \n \n ').concat(e.tagsHtml||"",'\n \n \n \n ').concat(m.text,"\n ").concat(m.whole?''.concat((0,i.Tl)("budget","of {total}",{total:m.whole}),""):"","\n \n ").concat(Lt(e.balance,g,a,n),'\n \n \n \n \n
\n ').concat(w?"":''),'\n \n
\n \n \n ')}function Ot(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=jt(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var a=0,r=function(){};return{s:r,n:function(){return a>=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function Ft(t){return function(t){if(Array.isArray(t))return Ht(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||jt(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rt(t){return Rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rt(t)}function Nt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,r,i,o,s=[],c=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(s.push(a.value),s.length!==e);c=!0);}catch(t){l=!0,r=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||jt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function jt(t,e){if(t){if("string"==typeof t)return Ht(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ht(t,e):void 0}}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n3?(r=p===a)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),s=u,c=p;(e=s<2?t:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),g(s,c)):h.n=c:h.v=c);try{if(l=2,i){if(s||(r="next"),e=i[r]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=t}else if((e=(d=h.n<0)?c:n.call(a,h))!==o)break}catch(e){i=t,s=1,c=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),l}var o={};function s(){}function c(){}function l(){}e=Object.getPrototypeOf;var u=[][a]?e(e([][a]())):(Vt(e={},a,function(){return this}),e),d=l.prototype=s.prototype=Object.create(u);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Vt(t,r,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,Vt(d,"constructor",l),Vt(l,"constructor",c),c.displayName="GeneratorFunction",Vt(l,r,"GeneratorFunction"),Vt(d),Vt(d,r,"Generator"),Vt(d,a,function(){return this}),Vt(d,"toString",function(){return"[object Generator]"}),(zt=function(){return{w:i,m:h}})()}function Vt(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}Vt=function(t,e,n,a){function i(e,n){Vt(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},Vt(t,e,n,a)}function qt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function Wt(t){for(var e=1;e=a&&(a=s+1)}}return"".concat(t,"__").concat(a)}},{key:"countInstances",value:function(t){for(var e,n=1,a=(null===(e=this.dashboardConfig.widgets)||void 0===e?void 0:e.instances)||{},r=0,i=Object.keys(a);r1?r.label:null),(R=document.querySelector(".dashboard-hero"))&&(R.style.opacity="1"),this.updateAccountsWidget(v.accounts||[]),this.updateBudgetAlertsWidget(F),this.widgetDataLoaded.budgetAlerts=!0,this.updateRecentTransactions(b.transactions||b),this.widgetDataLoaded.recentTransactions=!0,this.widgetData.upcomingBills=M,this.updateUpcomingBillsWidget(M),this.widgetDataLoaded.upcomingBills=!0,this.updateBudgetProgressWidget(D.categories||[]),this.widgetDataLoaded.budgetProgress=!0,this.updateSavingsGoalsWidget(B),this.widgetDataLoaded.savingsGoals=!0,N=this,t.n=2,g;case 2:return N.updateProjectsWidget.call(N,t.v),this.widgetDataLoaded.projects=!0,this.updatePensionsSummary(L),this.updateAssetsSummary(P,_),this.updateDebtPayoffWidget(A),this.widgetDataLoaded.debtPayoff=!0,this.updateSavingsRateHero(v),this.updateCashFlowHero(v),this.updateBudgetRemainingHero(D),this.updateBudgetHealthHero(F,D),this._lastSummary=v,this.updateAccountIncomeHero(v),this.updateAccountExpensesHero(v),y.spending&&(this.updateTopCategoriesWidget(y.spending),this.widgetDataLoaded.topCategories=!0),this.updateAccountPerformanceWidget(v.accounts||[]),this.widgetDataLoaded.accountPerformance=!0,this.updateBudgetBreakdownWidget(D.categories||[]),this.widgetDataLoaded.budgetBreakdown=!0,this.updateGoalsSummaryWidget(B),this.widgetDataLoaded.goalsSummary=!0,this.updatePaymentBreakdownWidget(v.accounts||[]),this.widgetDataLoaded.paymentBreakdown=!0,this.updateReconciliationStatusWidget(v.accounts||[]),this.widgetDataLoaded.reconciliationStatus=!0,y.spending&&this.updateSpendingChart(y.spending,"spendingChart",{dateFrom:u,dateTo:d}),y.trends&&this.updateTrendChart(y.trends),this.updateNetWorthHistoryChart(O),_&&this.updateAssetValueHistoryChart(_),this.setupDashboardControls(),this.populateAccountSelector("trend-account-select"),this.populateAccountSelector("hero-account-income-select"),this.populateAccountSelector("hero-account-expenses-select"),this.populateAccountSelector("spending-account-select"),this.populateAccountSelector("net-worth-account-select"),this.populateAccountSelector("recent-transactions-account-select"),t.n=3,this.refreshSavedWidgetSelections();case 3:return this.applyDashboardOrder(),t.n=4,this.applyDashboardVisibility();case 4:this.createSavedInstances(),this.initGridstack(),this.applyDashboardLayout(),this.updateTilePeriodIndicators(),this.updateTileAccountIndicators(),setTimeout(function(){return H.refreshAllInstances()},50),setTimeout(function(){H._removeHiddenTilesFromGrid(),H._compactEmptyTiles()},500),t.n=6;break;case 5:t.p=5,j=t.v,console.error("Failed to load dashboard:",j);case 6:return t.a(2)}},t,this,[[0,5]])})),function(){return O.apply(this,arguments)})},{key:"updateDashboardHero",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=t.totals||{},r=t.baseCurrency||this.getPrimaryCurrency();this.updateConversionIndicator(t);var o=document.getElementById("hero-net-worth-value");if(o){var s=(a.currentBalance||0)+(e.totalPensionWorth||0)+(n.totalAssetWorth||0);o.textContent=this.formatCurrency(s,r),o.className="hero-value ".concat(s>=0?"":"expenses")}var c=document.getElementById("hero-income-value");c&&(c.textContent=this.formatCurrency(a.totalIncome||0,r));var l=document.getElementById("hero-income-change");if(l&&t.trends&&t.trends.income){var u=t.trends.income;if(u.length>=2){var d=u[u.length-1]||0,h=u[u.length-2]||0,g=h>0?(d-h)/h*100:0;0!==g&&(l.innerHTML="".concat(g>=0?"↑":"↓"," ").concat((0,i.Tl)("budget","{percent}% vs last month",{percent:Math.abs(g).toFixed(1)})),l.className="hero-change ".concat(g>=0?"positive":"negative"))}}var p=document.getElementById("hero-expenses-value");p&&(p.textContent=this.formatCurrency(a.totalExpenses||0,r));var f=document.getElementById("hero-expenses-change");if(f&&t.trends&&t.trends.expenses){var m=t.trends.expenses;if(m.length>=2){var v=m[m.length-1]||0,y=m[m.length-2]||0,b=y>0?(v-y)/y*100:0;0!==b&&(f.innerHTML="".concat(b>=0?"↑":"↓"," ").concat((0,i.Tl)("budget","{percent}% vs last month",{percent:Math.abs(b).toFixed(1)})),f.className="hero-change ".concat(b<=0?"positive":"negative"))}}var w=document.getElementById("hero-savings-value"),T=document.getElementById("hero-savings-rate");if(w){var k=(a.totalIncome||0)-(a.totalExpenses||0);if(w.textContent=this.formatCurrency(k,r),w.className="hero-value ".concat(k>=0?"income":"expenses"),T&&a.totalIncome>0){var E=k/a.totalIncome*100;T.textContent="".concat(E>=0?"":"-").concat((0,i.Tl)("budget","{percent}% savings rate",{percent:Math.abs(E).toFixed(1)}))}}}},{key:"updateHeroPeriodHints",value:function(t){var e=this;document.querySelectorAll(".hero-card[data-widget-id]").forEach(function(n){if(Jt.includes(e.getWidgetType(n.getAttribute("data-widget-id")))){var a=n.querySelector(".hero-content");if(a){var r=a.querySelector(".hero-period");if(t){if(!r){var i=a.querySelector(".hero-label-row")||a.querySelector(".hero-label");if(!i)return;(r=document.createElement("span")).className="hero-period",i.after(r)}r.textContent=t}else r&&r.remove()}}})}},{key:"updateSavingsRateHero",value:function(t){var e=document.getElementById("hero-savings-rate-value");if(e&&null!=t&&t.totals){var n=t.totals.totalIncome||0,a=t.totals.netSavings||n-(t.totals.totalExpenses||0),r=n>0?a/n*100:0;e.textContent="".concat(r.toFixed(1),"%"),e.className="hero-value ".concat(r>=0?"income":"expenses");var o=document.getElementById("hero-savings-rate-change");if(o){var s=r>=20?"positive":r>=10?"neutral":"negative",c=r>=20?"↑":r>=10?"→":"↓";o.innerHTML='').concat(c," ").concat(r>=20?(0,i.Tl)("budget","Great"):r>=10?(0,i.Tl)("budget","Good"):(0,i.Tl)("budget","Low"),""),o.className="hero-change ".concat(s)}}}},{key:"updateCashFlowHero",value:function(t){var e=document.getElementById("hero-cash-flow-value");if(e&&null!=t&&t.totals){var n=(t.totals.totalIncome||0)-(t.totals.totalExpenses||0);e.textContent=this.formatCurrency(n,t.baseCurrency||this.getPrimaryCurrency()),e.className="hero-value ".concat(n>=0?"income":"expenses");var a=document.getElementById("hero-cash-flow-change");if(a&&t.trends){var r=t.trends.income||[],o=t.trends.expenses||[];if(r.length>=2&&o.length>=2){var s=(r[r.length-1]||0)-(o[o.length-1]||0),c=(r[r.length-2]||0)-(o[o.length-2]||0),l=0!==c?(s-c)/Math.abs(c)*100:0;0!==l&&(a.innerHTML="".concat(l>=0?"↑":"↓"," ").concat((0,i.Tl)("budget","{percent}% vs last month",{percent:Math.abs(l).toFixed(1)})),a.className="hero-change ".concat(l>=0?"positive":"negative"))}}}}},{key:"populateAccountSelector",value:function(t){var e,n,a,r=document.getElementById(t);if(r&&!r.hasAttribute("data-populated")){r.setAttribute("data-populated","true"),this.accounts.forEach(function(t){var e=document.createElement("option");e.value=t.id,e.textContent=t.name,r.appendChild(e)});var i=null!==(e=null===(n=this.dashboardConfig.hero)||void 0===n||null===(n=n.settings)||void 0===n?void 0:n[t])&&void 0!==e?e:null===(a=this.dashboardConfig.widgets)||void 0===a||null===(a=a.settings)||void 0===a?void 0:a[t];i&&r.querySelector('option[value="'.concat(i,'"]'))&&(r.value=i)}}},{key:"_validAccountId",value:function(t){return t&&(this.accounts||[]).some(function(e){return String(e.id)===String(t)})?t:null}},{key:"refreshSavedWidgetSelections",value:(P=Zt(zt().m(function t(){var e,n,a,r,i,o,s,c,l,u,d=this;return zt().w(function(t){for(;;)switch(t.n){case 0:for(n=[],a=(null===(e=this.dashboardConfig.widgets)||void 0===e?void 0:e.tileSettings)||{},r={trendChart:function(t){var e={"30d":1,"90d":3,"6m":6,"1y":12}[t.dateRange]||6;return d.refreshTrendChart(e,d._validAccountId(t.accountId))},spendingChart:function(t){return d.refreshSpendingChart("spendingChart",d._validAccountId(t.accountId))},netWorthHistory:function(t){var e={"30d":30,"90d":90,"6m":180,"1y":365}[t.dateRange]||30;return d.refreshNetWorthChart(e,d._validAccountId(t.accountId))},recentTransactions:function(t){return d.refreshRecentTransactions(d._validAccountId(t.accountId))},assetValueHistory:function(t){var e={"30d":30,"90d":90,"6m":180,"1y":365}[t.dateRange]||30;return d.refreshAssetValueChart(e)},topCategories:function(){return d.refreshTopCategoriesWidget("topCategories")},budgetProgress:function(){return d.refreshBudgetProgressWidget("budgetProgress")}},i=0,o=Object.entries(r);i0)){t.n=1;break}return t.n=1,Promise.all(n);case 1:return t.a(2)}},t,this)})),function(){return P.apply(this,arguments)})},{key:"_defaultDateRange",value:function(t){return"netWorthHistory"===t||"assetValueHistory"===t?"30d":"weeklyTrend"===t?"7d":"6m"}},{key:"_dateRangeLabel",value:function(t,e){var n={"7d":(0,i.Tl)("budget","Last 7 days"),"30d":(0,i.Tl)("budget","Last 30 days"),"90d":(0,i.Tl)("budget","Last 90 days"),"6m":(0,i.Tl)("budget","Last 6 months"),"1y":(0,i.Tl)("budget","Last year"),period:(0,i.Tl)("budget","Current budget period")};return n[t]||n[this._defaultDateRange(e)]}},{key:"_tilePeriodLabel",value:function(t,e){var n,a=null===(n=this.dashboardConfig)||void 0===n||null===(n=n.widgets)||void 0===n||null===(n=n.tileSettings)||void 0===n||null===(n=n[t])||void 0===n?void 0:n.dateRange;return"period"===a&&this._tileRangeParams(t).label||this._dateRangeLabel(a,e)}},{key:"_tileRangeParams",value:function(t){var e,n,a=this.getWidgetType(t),r=(null===(e=this.dashboardConfig)||void 0===e||null===(e=e.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e?void 0:e[t])||{},i=o.__(r.dateRange,{budgetStartDay:parseInt((null===(n=this.settings)||void 0===n?void 0:n.budget_start_day)||"1",10),fallback:this._defaultDateRange(a)});return{startDate:i.start,endDate:i.end,label:i.label}}},{key:"_dateRangeField",value:function(t,e){var n=[];t.shortRange&&n.push(["7d",(0,i.Tl)("budget","Last 7 days")]),n.push(["30d",(0,i.Tl)("budget","Last 30 days")],["90d",(0,i.Tl)("budget","Last 90 days")],["6m",(0,i.Tl)("budget","Last 6 months")],["1y",(0,i.Tl)("budget","Last year")]),t.budgetPeriodRange&&n.push(["period",(0,i.Tl)("budget","Current budget period")]);var a=n.map(function(t){var n=Nt(t,2),a=n[0],r=n[1];return'")}).join("\n ");return'\n
\n \n \n
\n ")}},{key:"_excludeSharedBillsField",value:function(t,e){var n;if(!t.excludeSharedBills)return"";var a=!!e.excludeSharedBills,r=((null===(n=this.widgetData)||void 0===n?void 0:n.upcomingBills)||[]).some(function(t){return null==t?void 0:t._shared});return a||r?this._checkboxField("excludeSharedBills",(0,i.Tl)("budget","Exclude shared bills"),a):""}},{key:"_showAllOverdueField",value:function(t,e){return t.showAllOverdue?this._checkboxField("showAllOverdue",(0,i.Tl)("budget","Show bills overdue for more than a week"),!!e.showAllOverdue):""}},{key:"_checkboxField",value:function(t,e,n){return'\n
\n \n
\n ")}},{key:"_tileNumberSetting",value:function(t,e,n,a){var r,i=(null===(r=this.dashboardConfig)||void 0===r||null===(r=r.widgets)||void 0===r||null===(r=r.tileSettings)||void 0===r?void 0:r[t])||{};return o.GH(i[e],n,a)}},{key:"_numberChoiceField",value:function(t,e,n,a,r){var i=n.map(function(t){return'")}).join("\n ");return'\n
\n \n \n
\n ")}},{key:"updateTilePeriodIndicators",value:function(){var t=this;document.querySelectorAll(".dashboard-card[data-widget-id]").forEach(function(e){var n=e.getAttribute("data-widget-id"),a=t.getWidgetType(n),r=e.querySelector(".card-header");if(r){var i=r.querySelector(".tile-period-indicator");if(Xt.includes(a)){var o=t._tilePeriodLabel(n,a);if(!i){(i=document.createElement("span")).className="tile-period-indicator";var s=r.querySelector(".card-header-controls");s?s.insertBefore(i,s.firstChild):r.appendChild(i)}i.textContent=o}else i&&i.remove()}})}},{key:"_accountLabel",value:function(t){var e=this._validAccountId(t);if(!e)return(0,i.Tl)("budget","All accounts");var n=(this.accounts||[]).find(function(t){return String(t.id)===String(e)});return n?n.name:(0,i.Tl)("budget","All accounts")}},{key:"updateTileAccountIndicators",value:function(){var t,e=this,n=(null===(t=this.dashboardConfig)||void 0===t||null===(t=t.widgets)||void 0===t?void 0:t.tileSettings)||{};document.querySelectorAll(".dashboard-card[data-widget-id]").forEach(function(t){var a,r,i=t.getAttribute("data-widget-id"),o=t.querySelector(".card-header");if(o){var s=o.querySelector(".tile-account-indicator");if(null!==(a=e.findWidgetDef(i))&&void 0!==a&&null!==(a=a.settingsSchema)&&void 0!==a&&a.accountSelector){var c=e._accountLabel(null===(r=n[i])||void 0===r?void 0:r.accountId);if(!s){(s=document.createElement("span")).className="tile-account-indicator";var l=o.querySelector(".card-header-controls");l?l.insertBefore(s,l.firstChild):o.appendChild(s)}s.textContent=c}else s&&s.remove()}})}},{key:"updateAccountIncomeHero",value:function(t){var e,n;if(null!==(e=t=t||this._lastSummary)&&void 0!==e&&e.accounts){var a=document.getElementById("hero-account-income-select"),r=document.getElementById("hero-account-income-value");if(a&&r){var i=a.value||(null===(n=t.accounts[0])||void 0===n?void 0:n.id);if(i){var o=t.accounts.find(function(t){return t.id==i});if(o){var s=o.currency||this.getPrimaryCurrency();r.textContent=this.formatCurrency(o.income||0,s)}}}}}},{key:"updateAccountExpensesHero",value:function(t){var e,n;if(null!==(e=t=t||this._lastSummary)&&void 0!==e&&e.accounts){var a=document.getElementById("hero-account-expenses-select"),r=document.getElementById("hero-account-expenses-value");if(a&&r){var i=a.value||(null===(n=t.accounts[0])||void 0===n?void 0:n.id);if(i){var o=t.accounts.find(function(t){return t.id==i});if(o){var s=o.currency||this.getPrimaryCurrency();r.textContent=this.formatCurrency(o.expenses||0,s)}}}}}},{key:"saveHeroAccountSelection",value:(L=Zt(zt().m(function t(e,n){return zt().w(function(t){for(;;)switch(t.n){case 0:return this.dashboardConfig.hero.settings||(this.dashboardConfig.hero.settings={}),this.dashboardConfig.hero.settings[e]=n,t.n=1,this.saveDashboardVisibility();case 1:return t.a(2)}},t,this)})),function(t,e){return L.apply(this,arguments)})},{key:"saveWidgetAccountSelection",value:(B=Zt(zt().m(function t(e,n){return zt().w(function(t){for(;;)switch(t.n){case 0:return this.dashboardConfig.widgets.settings||(this.dashboardConfig.widgets.settings={}),this.dashboardConfig.widgets.settings[e]=n,t.n=1,this.saveDashboardVisibility();case 1:return t.a(2)}},t,this)})),function(t,e){return B.apply(this,arguments)})},{key:"updateBudgetRemainingHero",value:function(t){var e=document.getElementById("hero-budget-remaining-value");if(e)if(t&&t.categories&&0!==t.categories.length){var n=t.categories.filter(function(t){return"income"!==t.type}),a=function(t){return t.budgeted||t.budget||0},r=n.reduce(function(t,e){var n=a(e)-(e.spent||0);return t+(n>0?n:0)},0);e.textContent=this.formatCurrency(r,this.getPrimaryCurrency()),e.className="hero-value ".concat(r>=0?"income":"expenses");var o=document.getElementById("hero-budget-remaining-change");if(o){var s=n.filter(function(t){return a(t)-(t.spent||0)>0}).length;o.textContent=(0,i.zw)("budget","%n category under budget","%n categories under budget",s)}}else e.textContent="--"}},{key:"updateBudgetHealthHero",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=document.getElementById("hero-budget-health-value");if(n){var a=((null==e?void 0:e.categories)||[]).filter(function(t){return"income"!==t.type&&((t.budgeted||t.budget||0)>0||Math.abs(t.carried||0)>=.005)}).length;if(0!==a){var r=Array.isArray(t)?t.length:0,o=Math.max(a-r,0),s=o/a*100;n.textContent="".concat(s.toFixed(0),"%"),n.className="hero-value ".concat(s>=75?"income":s>=50?"":"expenses");var c=document.getElementById("hero-budget-health-change");c&&(c.textContent=(0,i.Tl)("budget","{onTrack}/{total} on track",{onTrack:o,total:a}))}else n.textContent="--"}}},{key:"updateDaysUntilDebtFreeHero",value:function(){var t=document.getElementById("hero-debt-free-value");if(t){var e=this.widgetData.daysUntilDebtFree;if(e&&e.debts&&0!==e.debts.length)if(e.payoffDate){var n=new Date,a=new Date(e.payoffDate),r=Math.max(0,Math.round((a-n)/864e5));t.textContent=r.toLocaleString(o.Yp());var s=document.getElementById("hero-debt-free-change");if(s){var c=a.toLocaleDateString(o.Yp(),{month:"short",year:"numeric"});s.textContent=(0,i.Tl)("budget","Debt free by {date}",{date:c})}}else t.textContent=(0,i.Tl)("budget","N/A");else{var l=document.querySelector('[data-widget-id="daysUntilDebtFree"]');l&&(l.style.display="none")}}}},{key:"updateConversionIndicator",value:function(t){var e=document.getElementById("currency-conversion-indicator");if(e&&e.remove(),t.currencyConverted){var n=document.querySelector(".hero-net-worth .hero-content");if(n){var a=document.createElement("span");a.id="currency-conversion-indicator",a.className="hero-subtext conversion-info";var r=t.unconvertedCurrencies||[];r.length>0?(a.className="hero-subtext conversion-warning",a.innerHTML="⚠ ".concat((0,i.Tl)("budget","Rates unavailable for {currencies}",{currencies:r.join(", ")}))):a.textContent=(0,i.Tl)("budget","Converted to {currency} at current rates",{currency:t.baseCurrency}),n.appendChild(a)}}}},{key:"getAccountsTileConfig",value:function(){var t;return(null===(t=this.dashboardConfig.widgets)||void 0===t||null===(t=t.settings)||void 0===t?void 0:t.accountsTile)||{order:[],hidden:[]}}},{key:"saveAccountsTileConfig",value:(D=Zt(zt().m(function t(e){return zt().w(function(t){for(;;)switch(t.n){case 0:return this.dashboardConfig.widgets.settings||(this.dashboardConfig.widgets.settings={}),this.dashboardConfig.widgets.settings.accountsTile=e,t.n=1,this.saveDashboardVisibility();case 1:return t.a(2)}},t,this)})),function(t){return D.apply(this,arguments)})},{key:"updateAccountsWidget",value:function(t){var e=this,n=document.getElementById("accounts-summary");if(n&&Array.isArray(t))if(0!==t.length){this._allDashboardAccounts=t;var a,r={checking:'',savings:'',credit_card:'',investment:'',cash:'',loan:''},o={checking:(0,i.Tl)("budget","Checking"),savings:(0,i.Tl)("budget","Savings"),credit_card:(0,i.Tl)("budget","Credit Card"),investment:(0,i.Tl)("budget","Investment"),cash:(0,i.Tl)("budget","Cash"),loan:(0,i.Tl)("budget","Loan")},c=this.getAccountsTileConfig(),l=new Set(c.hidden||[]);if(c.order&&c.order.length>0){var u={};c.order.forEach(function(t,e){u[t]=e}),a=Ft(t).sort(function(t,e){var n,a;return(null!==(n=u[t.id])&&void 0!==n?n:999)-(null!==(a=u[e.id])&&void 0!==a?a:999)})}else a=t;var d=a.filter(function(t){return!l.has(t.id)});0!==d.length?n.innerHTML=d.map(function(t){var n=t.type||"checking",a=parseFloat(t.balance)||0,i=t.currency||e.getPrimaryCurrency(),c=r[n]||r.checking;return'\n \n ")}).join(""):n.innerHTML='
'.concat((0,i.Tl)("budget","All accounts hidden"),"
")}else n.innerHTML='
'.concat((0,i.Tl)("budget","No accounts yet"),"
")}},{key:"setupAccountsTileConfig",value:function(){var t=this,e=document.getElementById("accounts-tile-settings-btn");e&&e.addEventListener("click",function(e){e.stopPropagation(),t.openTileSettingsModal("accounts","widget")})}},{key:"renderAccountsTileConfigList",value:function(){var t=this,e=document.getElementById("tile-settings-modal-list");if(e){var n=this._allDashboardAccounts||[];if(0!==n.length){var a,r=this.getAccountsTileConfig(),o=new Set(r.hidden||[]);if(r.order&&r.order.length>0){var c={};r.order.forEach(function(t,e){c[t]=e}),a=Ft(n).sort(function(t,e){var n,a;return(null!==(n=c[t.id])&&void 0!==n?n:999)-(null!==(a=c[e.id])&&void 0!==a?a:999)})}else a=n;e.innerHTML=a.map(function(t){return'\n
\n \n ').concat(s.ZD(t.name),'\n \n \n \n \n \n
\n ')}).join(""),e.querySelectorAll('input[type="checkbox"]').forEach(function(e){e.addEventListener("change",Zt(zt().m(function n(){var a,r;return zt().w(function(n){for(;;)switch(n.n){case 0:return a=t.getAccountsTileConfig(),r=parseInt(e.dataset.accountId),e.checked?a.hidden=(a.hidden||[]).filter(function(t){return t!==r}):(a.hidden||(a.hidden=[]),a.hidden.includes(r)||a.hidden.push(r)),n.n=1,t.saveAccountsTileConfig(a);case 1:t.updateAccountsWidget(t._allDashboardAccounts);case 2:return n.a(2)}},n)})))});var l=null;e.querySelectorAll(".tile-config-item").forEach(function(t){t.addEventListener("dragstart",function(e){l=t,t.classList.add("dragging"),e.dataTransfer.effectAllowed="move"}),t.addEventListener("dragend",function(){t.classList.remove("dragging"),l=null}),t.addEventListener("dragover",function(n){if(n.preventDefault(),l&&l!==t){var a=t.getBoundingClientRect(),r=a.top+a.height/2;n.clientY")}}},{key:"_recentTransactionCategoryCell",value:function(t){var e,n,a=this,r=(0,i.Tl)("budget","Uncategorized"),o=function(t){return'')},c=function(t,e,n){return'")+"".concat(t,'').concat(e,"")},l=!(!t.isSplit&&!t.is_split),u=l&&Array.isArray(t.splitCategories)?t.splitCategories:null;if(u&&u.length>0){var d=new Set,h=u.filter(function(t){var e,n=null!==(e=t.categoryId)&&void 0!==e?e:"none";return!d.has(n)&&(d.add(n),!0)});return c(h.slice(0,3).map(function(t){return o((e=t.categoryId,(null===(n=a.categories)||void 0===n||null===(n=n.find(function(t){return t.id===e}))||void 0===n?void 0:n.color)||"#999"));var e,n}).join(""),h.map(function(t){return s.ZD(t.categoryName||r)}).join(" / "),u.map(function(t){return s.ZD((t.categoryName||r)+": "+a.formatCurrency(t.amount))}).join(" "))}if(l)return c(o("#999"),s.ZD((0,i.Tl)("budget","Split")),s.ZD((0,i.Tl)("budget","Split transaction")));var g=null===(e=this.categories)||void 0===e?void 0:e.find(function(e){return e.id===t.categoryId||e.id===t.category_id});return c(o(g?g.color:"#999"),s.ZD(null!==(n=Dt(t,g))&&void 0!==n?n:r),"")}},{key:"updateRecentTransactions",value:function(t){var e,n,a=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"recentTransactions";if(this.isDuplicateInstance(r)){var o=this.getWidgetCard(r);n=o?o.querySelector(".recent-transactions-list"):null}else n=document.getElementById("recent-transactions");if(n)if(Array.isArray(t)&&0!==t.length){var c=((null===(e=this.dashboardConfig.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e?void 0:e[r])||{}).rowCount||5;n.innerHTML=t.slice(0,c).map(function(t){var e="credit"===t.type,n=parseFloat(t.amount)||0,r=t.date?a.formatDate(t.date):"";return'\n
\n
\n
\n ').concat(e?'':'','\n
\n
\n
').concat(s.ZD(t.description||t.vendor||(0,i.Tl)("budget","Transaction")),'
\n
\n ').concat(r,"\n ").concat(a._recentTransactionCategoryCell(t),'\n
\n
\n
\n
\n ').concat(e?"+":"-").concat(a.formatCurrency(n),"\n
\n
\n ")}).join("")}else n.innerHTML='
'.concat((0,i.Tl)("budget","No recent transactions"),"
")}},{key:"getBudgetAlertFilter",value:function(){var t,e="manual"===(null===(t=this.settings)||void 0===t?void 0:t.budget_alert_scope)?"manual":"all",n=[];try{var a,r=JSON.parse((null===(a=this.settings)||void 0===a?void 0:a.budget_alert_muted_categories)||"[]");Array.isArray(r)&&(n=r.map(function(t){return parseInt(t,10)}).filter(function(t){return Number.isInteger(t)}))}catch(t){}return{scope:e,muted:n}}},{key:"updateBudgetAlertsWidget",value:function(t){var e=this,n=document.getElementById("budget-alerts-card"),a=document.getElementById("budget-alerts");if(n&&a){if(!Array.isArray(t)||0===t.length){var r=this.getBudgetAlertFilter(),o=r.scope,c=r.muted;return"all"===o&&0===c.length?void(n.style.display="none"):(n.style.display="",void(a.innerHTML='
'.concat(c.length>0?(0,i.zw)("budget","No budget alerts. %n category is muted.","No budget alerts. %n categories are muted.",c.length):(0,i.Tl)("budget","No budget alerts from the budgets you set."),"
")))}n.style.display="";var l=this.getPrimaryCurrency();a.innerHTML=t.map(function(t){var n="danger"===t.severity?"alert-danger":"alert-warning",a="danger"===t.severity?'':'',r="danger"===t.severity?(0,i.Tl)("budget","{percent}% over",{percent:Math.max(0,Math.round(t.percentage-100))}):(0,i.Tl)("budget","{percent}% used",{percent:Math.round(t.percentage)});return'\n
\n
').concat(a,'
\n
\n
').concat(s.ZD(t.categoryName),'
\n
\n
\n
\n
\n ').concat(r,'\n
\n
\n ').concat(e.formatCurrency(t.spent,l),'\n /\n ').concat(e.formatCurrency(t.budgetAmount,l),"\n
\n
\n
\n ")}).join("")}}},{key:"_budgetAlertsTileConfigHtml",value:function(t){var e=this,n=new Set(this.getBudgetAlertFilter().muted),a=this.getPrimaryCurrency();return t.map(function(t){var r="recurring"===t.budgetSource?' '.concat((0,i.Tl)("budget","(from a bill)"),""):"";return'\n
\n ').concat(s.ZD(t.categoryName)).concat(r,'\n ').concat(e.formatCurrency(t.budgetAmount,a),'\n \n
\n ")}).join("")}},{key:"renderBudgetAlertsTileConfigList",value:(M=Zt(zt().m(function t(){var e,n,a,r=this;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.getElementById("tile-settings-modal-list")){t.n=1;break}return t.a(2);case 1:return n=[],t.p=2,t.n=3,(0,T.n)("/apps/budget/api/alerts/status").catch(function(t){if(t instanceof T.h)return[];throw t});case 3:n=t.v,t.n=5;break;case 4:t.p=4,a=t.v,console.error("Failed to load the categories that can alert",a);case 5:if(Array.isArray(n)&&0!==n.length){t.n=6;break}return e.innerHTML='
'.concat((0,i.Tl)("budget","No category has a budget yet."),"
"),t.a(2);case 6:e.innerHTML=this._budgetAlertsTileConfigHtml(n),e.querySelectorAll('input[type="checkbox"]').forEach(function(t){t.addEventListener("change",function(){var e=parseInt(t.dataset.categoryId,10),n=r.getBudgetAlertFilter().muted;r.saveBudgetAlertFilter({muted:t.checked?n.filter(function(t){return t!==e}):[].concat(Ft(n),[e])})})});case 7:return t.a(2)}},t,this,[[2,4]])})),function(){return M.apply(this,arguments)})},{key:"saveBudgetAlertFilter",value:(_=Zt(zt().m(function t(){var e,n,a,r,o,s,l=arguments;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=(e=l.length>0&&void 0!==l[0]?l[0]:{}).scope,a=e.muted,r=this.getBudgetAlertFilter(),o={budget_alert_scope:null!=n?n:r.scope,budget_alert_muted_categories:JSON.stringify(null!=a?a:r.muted)},Object.assign(this.settings,o),t.p=1,t.n=2,this._saveSettings(o);case 2:t.n=4;break;case 3:return t.p=3,s=t.v,console.error("Failed to save the budget alert filter",s),(0,c.Qg)((0,i.Tl)("budget","Failed to save the budget alert filter")),t.a(2);case 4:return t.n=5,this.refreshBudgetAlertsWidget();case 5:return t.a(2)}},t,this,[[1,3]])})),function(){return _.apply(this,arguments)})},{key:"refreshBudgetAlertsWidget",value:(A=Zt(zt().m(function t(){var e,n;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/alerts").catch(function(t){if(t instanceof T.h)return[];throw t});case 1:e=t.v,this.updateBudgetAlertsWidget(e),t.n=3;break;case 2:t.p=2,n=t.v,console.error("Failed to refresh the budget alerts tile",n);case 3:return t.a(2)}},t,this,[[0,2]])})),function(){return A.apply(this,arguments)})},{key:"renderSpendingTileCategoryList",value:function(t){var e,n=this,a=document.getElementById("tile-settings-modal-list");if(a){var r=this.app.categories||[],o=function(t){var e,n=(t||[]).filter(function(t){return"income"!==t.type}),a=new Set(n.map(function(t){return t.id})),r=new Map,i=It(n);try{for(i.s();!(e=i.n()).done;){var o=e.value,s=null!=o.parentId&&a.has(o.parentId)?o.parentId:null;r.has(s)||r.set(s,[]),r.get(s).push(o)}}catch(t){i.e(t)}finally{i.f()}var c=function(t,e){var n,a;return(null!==(n=t.sortOrder)&&void 0!==n?n:0)-(null!==(a=e.sortOrder)&&void 0!==a?a:0)||String(t.name).localeCompare(String(e.name))},l=[],u=new Set,d=function(t,e){var n,a=It((r.get(t)||[]).sort(c));try{for(a.s();!(n=a.n()).done;){var i,o=n.value;u.has(o.id)||e>=64||(u.add(o.id),l.push({id:o.id,name:o.name,depth:e,parentId:null!==(i=o.parentId)&&void 0!==i?i:null}),d(o.id,e+1))}}catch(t){a.e(t)}finally{a.f()}};return d(null,0),l}(r);if(0!==o.length){var c=(null===(e=this.dashboardConfig.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e||null===(e=e[t])||void 0===e?void 0:e.hiddenCategories)||[],l=new Set(c.map(function(t){return parseInt(t,10)})),u=_t(c,r);a.innerHTML=o.map(function(t){var e=u.has(t.id)&&!l.has(t.id);return'\n
\n ').concat(s.ZD(t.name),'\n \n
\n ")}).join(""),a.querySelectorAll('input[type="checkbox"]').forEach(function(e){e.addEventListener("change",function(){n.saveSpendingTileCategory(t,parseInt(e.dataset.categoryId,10),e.checked)})})}else a.innerHTML='
'.concat((0,i.Tl)("budget","No categories yet"),"
")}}},{key:"saveSpendingTileCategory",value:function(t,e,n){var a=this.dashboardConfig.widgets;a.tileSettings||(a.tileSettings={}),a.tileSettings[t]||(a.tileSettings[t]={});var r=a.tileSettings[t],i=(r.hiddenCategories||[]).map(function(t){return parseInt(t,10)}).filter(function(t){return t!==e});n||i.push(e),r.hiddenCategories=i,this.saveDashboardVisibility(),this.renderSpendingTileCategoryList(t),this.refreshTileAfterSettingsChange(t,"widgets")}},{key:"updateDebtPayoffWidget",value:function(t){var e=document.getElementById("debt-payoff-card");if(e)if(t&&0!==t.debtCount){e.style.display="";var n=this.getPrimaryCurrency(),a=document.getElementById("debt-total-balance"),r=document.getElementById("debt-account-count"),o=document.getElementById("debt-minimum-payment"),s=document.getElementById("debt-payoff-estimate");a&&(a.textContent=this.formatCurrency(t.totalBalance,n)),r&&(r.textContent=t.debtCount.toString()),o&&(o.textContent=this.formatCurrency(t.totalMinimumPayment,n)),s&&(t.highestInterestRate>0?s.innerHTML=''.concat((0,i.Tl)("budget","Highest rate: {rate}% APR",{rate:t.highestInterestRate.toFixed(1)}),""):s.innerHTML="")}else e.style.display="none"}},{key:"renderDebtChartWidget",value:(I=Zt(zt().m(function t(){var e,n,a,s,c,l,u,d,h,g,p,f;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/debt-scenarios").catch(function(){return null});case 1:if(n=t.v){t.n=2;break}return t.a(2);case 2:if(!(a=Array.isArray(n)?n.find(function(t){return t.isActive}):null)){t.n=5;break}return t.n=3,(0,T.n)("/apps/budget/api/debt-scenarios/".concat(a.id,"/calculate")).catch(function(){return null});case 3:if(e=t.v){t.n=4;break}return t.a(2);case 4:t.n=7;break;case 5:return t.n=6,(0,T.n)("/apps/budget/api/debts/payoff-plan?strategy=avalanche").catch(function(){return null});case 6:if(e=t.v){t.n=7;break}return t.a(2);case 7:if(e&&e.debts&&0!==e.debts.length){t.n=8;break}return t.a(2);case 8:if((s=document.getElementById("debt-chart-widget-stats"))&&(c=e.debts.reduce(function(t,e){return t+(parseFloat(e.originalBalance)||0)},0),l=e.payoffDate?new Date(e.payoffDate).toLocaleDateString(o.Yp(),{month:"short",year:"numeric"}):"N/A",s.innerHTML='\n
'.concat((0,i.Tl)("budget","Total Debt"),'
').concat(this.formatCurrency(c),'
\n
').concat((0,i.Tl)("budget","Debt Free"),'
').concat(l,"
\n ")),(u=document.getElementById("debt-chart-widget-end"))&&e.payoffDate&&(u.textContent=new Date(e.payoffDate).toLocaleDateString(o.Yp(),{year:"numeric"})),(d=document.getElementById("debt-chart-widget-canvas"))&&e.timeline&&0!==e.timeline.length){t.n=9;break}return t.a(2);case 9:h=["#e74c3c","#f39c12","#3498db","#2ecc71","#9b59b6","#1abc9c"],g=e.timeline.map(function(){return""}),p=e.debts.map(function(t,n){return{data:e.timeline.map(function(e){var n,a=null===(n=e.payments)||void 0===n?void 0:n.find(function(e){return e.debtId===t.id});return a?Math.max(0,a.remainingBalance):0}),borderColor:h[n%h.length],backgroundColor:h[n%h.length]+"40",fill:!0,tension:.3,pointRadius:0,borderWidth:1}}),this.debtChartWidget&&this.debtChartWidget.destroy(),this.debtChartWidget=new r.A(d.getContext("2d"),{type:"line",data:{labels:g,datasets:p},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{display:!1},y:{display:!1,stacked:!0}}}}),t.n=11;break;case 10:t.p=10,f=t.v,console.error("Failed to render debt chart widget",f);case 11:return t.a(2)}},t,this,[[0,10]])})),function(){return I.apply(this,arguments)})},{key:"renderDebtProgressWidget",value:(C=Zt(zt().m(function t(){var e,n,a,r,s,c,l,u,d,h,g,p,f,m,v,y,b,w,k,E,x,S,C;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,Promise.all([(0,T.n)("/apps/budget/api/debts/progress").catch(function(){return null}),(0,T.n)("/apps/budget/api/debts/summary").catch(function(){return null})]);case 1:if(e=t.v,n=Nt(e,2),a=n[0],r=n[1],a&&r){t.n=2;break}return t.a(2);case 2:if(0!==r.debtCount){t.n=3;break}return t.a(2);case 3:if((s=document.getElementById("debt-progress-months"))&&(s.textContent=a.hasActiveScenario?a.totalMonths:"?"),c=Math.abs(r.totalBalance||0),l=a.hasActiveScenario?a.originalTotalDebt:c,u=l>0?Math.max(0,Math.min(100,(l-c)/l*100)):0,(d=document.getElementById("debt-progress-remaining"))&&(d.textContent=this.formatCurrency(c)+" "+(0,i.Tl)("budget","remaining")),(h=document.getElementById("debt-progress-percent"))&&(h.textContent=Math.round(u)+"% "+(0,i.Tl)("budget","paid off")),(g=document.getElementById("debt-progress-bar"))&&(g.style.width=u+"%"),!a.hasActiveScenario){t.n=9;break}return t.n=4,(0,T.n)("/apps/budget/api/debt-scenarios").catch(function(){return null});case 4:if(p=t.v){t.n=5;break}return t.a(2);case 5:if(f=Array.isArray(p)?p.find(function(t){return t.isActive}):null,!f){t.n=8;break}return t.n=6,(0,T.n)("/apps/budget/api/debt-scenarios/".concat(f.id,"/calculate")).catch(function(){return null});case 6:if(v=t.v){t.n=7;break}return t.a(2);case 7:y=null===(m=v.debts)||void 0===m?void 0:m.find(function(t){return t.payoffMonth}),b=document.getElementById("debt-progress-next-name"),w=document.getElementById("debt-progress-next-date"),y&&b&&(b.textContent=y.name,(k=new Date).setMonth(k.getMonth()+y.payoffMonth),w&&(w.textContent=k.toLocaleDateString(o.Yp(),{month:"short",year:"numeric"})));case 8:(E=document.getElementById("debt-progress-status"))&&(x={ahead:{text:(0,i.Tl)("budget","Ahead of schedule"),color:"var(--color-success)"},behind:{text:(0,i.Tl)("budget","Behind schedule"),color:"var(--color-error)"},on_track:{text:(0,i.Tl)("budget","On track"),color:"var(--color-success)"}},S=x[a.status]||x.on_track,E.textContent=S.text,E.style.color=S.color);case 9:t.n=11;break;case 10:t.p=10,C=t.v,console.error("Failed to render debt progress widget",C);case 11:return t.a(2)}},t,this,[[0,10]])})),function(){return C.apply(this,arguments)})},{key:"_emptyBillsState",value:function(t,e){t.innerHTML='
'.concat(e,"
")}},{key:"upcomingBillsUrl",value:function(){return"/apps/budget/api/bills/upcoming?days=".concat(Math.max.apply(Math,Ft(o.xB)))}},{key:"_tileBills",value:function(t,e){var n,a=(null===(n=this.dashboardConfig)||void 0===n||null===(n=n.widgets)||void 0===n||null===(n=n.tileSettings)||void 0===n?void 0:n[t])||{},r=this._validAccountId(a.accountId);return r&&(e=e.filter(function(t){return String(t.accountId)===String(r)||String(t.destinationAccountId)===String(r)})),e.slice(0,this._tileRowCount(t))}},{key:"_tileRowCount",value:function(t){var e,n=parseInt(null===(e=this.dashboardConfig)||void 0===e||null===(e=e.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e||null===(e=e[t])||void 0===e?void 0:e.rowCount,10);return n>0?n:5}},{key:"updateUpcomingBillsWidget",value:function(t){var e,n=this,a=document.getElementById("upcoming-bills");if(a){void 0===t&&(t=this.widgetData.upcomingBills);var r=this._tileNumberSetting("upcomingBills","forwardHorizon",o.xB,30),c=(null===(e=this.dashboardConfig)||void 0===e||null===(e=e.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e?void 0:e.upcomingBills)||{};if(t=this.filterBillsByHorizon(t,r,null,{keepAllOverdue:!!c.showAllOverdue}),c.excludeSharedBills&&(t=t.filter(function(t){return!t._shared})),0!==(t=this._tileBills("upcomingBills",t)).length){var l=o.rT();a.innerHTML=t.map(function(t){var e=t.nextDueDate||t.next_due_date,a=o.X6(l,e),r="",c="";return a<0?(r="overdue",c=(0,i.zw)("budget","Overdue by %n day","Overdue by %n days",Math.abs(a))):0===a?(r="due-soon",c=(0,i.Tl)("budget","Due today")):a<=7?(r="due-soon",c=(0,i.zw)("budget","Due in %n day","Due in %n days",a)):c=(0,i.Tl)("budget","Due {date}",{date:o.Zj(e).toLocaleDateString(o.Yp(),{month:"short",day:"numeric"})}),'\n
\n
\n
').concat(s.ZD(t.name),'
\n
').concat(c,'
\n
\n
').concat(n.formatCurrency(t.amount,t.currency),"
\n
\n ")}).join("")}else this._emptyBillsState(a,(0,i.Tl)("budget","No upcoming bills"))}}},{key:"updateBudgetProgressWidget",value:function(t){var e,n=this,a=document.getElementById("budget-progress");if(a)if(Array.isArray(t)&&0!==t.length){var r=t;((null===(e=this.dashboardConfig.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e?void 0:e.budgetProgress)||{}).topLevelOnly&&(r=this.aggregateToTopLevel(t));var o=r.filter(function(t){return t.budgeted>0||t.budget>0||function(t){return(t.budgeted||t.budget||0)<=0&&Math.abs(t.carried||0)>=.005}(t)});0!==o.length?a.innerHTML=o.slice(0,5).map(function(t){var e=t.budgeted||t.budget||0,a=t.spent||0,r=e>0?Math.min(Math.max(a/e*100,0),100):a>0?100:0,i=e>0?a/e*100:0,o="good";"income"===t.type?o="good":i>100||e<=0&&a>0?o="over":i>80?o="danger":i>50&&(o="warning");var c=t.color||"#0082c9";return'\n
\n
\n
\n \n ').concat(s.ZD(t.categoryName||t.name),'\n
\n
\n ').concat(n.formatCurrency(a)," / ").concat(n.formatCurrency(e),'\n
\n
\n
0?i:r,t.categoryName||t.name),'>\n
\n
\n ').concat((0,Ct.t8)("over"===o),"\n
\n ")}).join(""):a.innerHTML='
'.concat((0,i.Tl)("budget","No budgets configured"),"
")}else a.innerHTML='
'.concat((0,i.Tl)("budget","No budgets configured"),"
")}},{key:"refreshBudgetProgressWidget",value:(S=Zt(zt().m(function t(){var e,n,a,r,i,s,c,l,u,d=arguments;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return e=d.length>0&&void 0!==d[0]?d[0]:"budgetProgress",t.p=1,a=(null===(n=this.dashboardConfig.widgets)||void 0===n||null===(n=n.tileSettings)||void 0===n?void 0:n[e])||{},r=this._tileRangeParams(e),i=r.startDate,s=r.endDate,c="/apps/budget/api/reports/budget?startDate=".concat(i,"&endDate=").concat(s),"period"===a.dateRange&&(c+="&snapshotMonth=".concat(o.jt(i,s))),a.accountId&&(c+="&accountId=".concat(a.accountId)),a.excludeShared&&(c+="&excludeShared=1"),t.n=2,(0,T.n)(c,{errorMessage:"Failed to fetch budget data"});case 2:l=t.v,this.updateBudgetProgressWidget(l.categories||[]),t.n=4;break;case 3:t.p=3,u=t.v,console.error("Failed to refresh budget progress:",u);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return S.apply(this,arguments)})},{key:"refreshTopCategoriesWidget",value:(x=Zt(zt().m(function t(){var e,n,a,r,i,o,s,c,l,u=arguments;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:"topCategories",t.p=1,a=(null===(n=this.dashboardConfig.widgets)||void 0===n||null===(n=n.tileSettings)||void 0===n?void 0:n[e])||{},r=this._tileRangeParams(e),i=r.startDate,o=r.endDate,s="/apps/budget/api/reports/spending?startDate=".concat(i,"&endDate=").concat(o),a.accountId&&(s+="&accountId=".concat(a.accountId)),a.excludeShared&&(s+="&excludeShared=1"),t.n=2,(0,T.n)(s,{errorMessage:"Failed to fetch spending data"});case 2:c=t.v,this.updateTopCategoriesWidget(this._categorySpendingRows(c.data||[])),t.n=4;break;case 3:t.p=3,l=t.v,console.error("Failed to refresh top categories:",l);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return x.apply(this,arguments)})},{key:"_categorySpendingRows",value:function(t){return Array.isArray(t)?t.filter(function(t){return!t.uncategorized}):t}},{key:"updateSavingsGoalsWidget",value:function(t){var e=this,n=document.getElementById("savings-goals-summary");n&&(Array.isArray(t)&&0!==t.length?n.innerHTML=t.slice(0,3).map(function(t){var n=t.targetAmount||t.target_amount||0,a=t.currentAmount||t.current_amount||0,r=n>0?Math.min(Math.max(a/n*100,0),100):0,o=t.color&&/^#[0-9a-fA-F]{3,6}$/.test(t.color)?t.color:"",c=o?"background: ".concat(o,";"):"";return'\n
\n
\n
'.concat(s.ZD(t.name),'
\n
').concat((0,i.Tl)("budget","Target: {amount}",{amount:e.formatCurrency(n)}),'
\n
\n
\n
\n
\n \n
\n ")}).join(""):n.innerHTML='
'.concat((0,i.Tl)("budget","No savings goals yet"),"
"))}},{key:"fetchProjectsForTile",value:(E=Zt(zt().m(function t(){var e;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/projects").catch(function(t){if(t instanceof T.h)return[];throw t});case 1:return t.a(2,t.v);case 2:return t.p=2,e=t.v,console.error("Failed to load projects for the dashboard:",e),t.a(2,[])}},t,null,[[0,2]])})),function(){return E.apply(this,arguments)})},{key:"loadProjectsWidget",value:(k=Zt(zt().m(function t(){var e;return zt().w(function(t){for(;;)switch(t.n){case 0:return e=this,t.n=1,this.fetchProjectsForTile();case 1:e.updateProjectsWidget.call(e,t.v);case 2:return t.a(2)}},t,this)})),function(){return k.apply(this,arguments)})},{key:"updateProjectsWidget",value:function(t){var e,n=this;if(void 0!==t){var a=document.getElementById("projects-card"),r=document.getElementById("projects-widget");if(a&&r){var o=(0,St.sG)(Array.isArray(t)?t:[]).open,c=!1===(null===(e=this.dashboardConfig)||void 0===e||null===(e=e.widgets)||void 0===e||null===(e=e.visibility)||void 0===e?void 0:e.projects);if(0===o.length||c)return a.style.display="none",void(c||this._syncConditionalTileSlot("projects",!1));a.style.display="",this._syncConditionalTileSlot("projects",!0),r.innerHTML=o.slice(0,5).map(function(t){var e=(0,St.L7)(t.spent,t.totalAmount);return'\n
\n
\n '.concat(s.ZD(t.name),'\n ').concat(e.percent,'%\n
\n
\n ').concat((0,Ct.t8)(t.spent>t.totalAmount&&t.totalAmount>0),'\n \n
")}).join("")}}else this.loadProjectsWidget()}},{key:"updatePensionsSummary",value:function(t){var e,n=t.baseCurrency||this.getPrimaryCurrency(),a=t.totalPensionWorth||0,r=t.totalProjectedIncome||0,o=t.pensionCount||0,s=document.getElementById("pensions-total-worth"),c=document.getElementById("pensions-count");s&&(s.textContent=this.formatCurrency(a,n)),c&&(c.textContent=o),null===(e=document.querySelector(".hero-pension"))||void 0===e||e.classList.toggle("hero-card--empty",0===o&&0===a&&0===r);var l=document.getElementById("hero-pension-value"),u=document.getElementById("hero-pension-count"),d=document.querySelector(".hero-pension .hero-label");if(l&&(a>0?(l.textContent=this.formatCurrency(a,n),d&&(d.textContent=(0,i.Tl)("budget","Pension Worth"))):r>0?(l.textContent=this.formatCurrency(r,n)+"/yr",d&&(d.textContent=(0,i.Tl)("budget","Pension Income"))):(l.textContent=this.formatCurrency(0,n),d&&(d.textContent=(0,i.Tl)("budget","Pension Worth")))),u){var h=(0,i.zw)("budget","%n pension","%n pensions",o);a>0&&r>0&&(h+=" · ".concat((0,i.Tl)("budget","{amount}/yr income",{amount:this.formatCurrency(r,n)}))),u.textContent=h}}},{key:"updateAssetsSummary",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=t.baseCurrency||this.getPrimaryCurrency(),r=t.totalAssetWorth||0,o=t.assetCount||0,s=document.getElementById("assets-total-worth"),c=document.getElementById("assets-count");s&&(s.textContent=this.formatCurrency(r,a)),c&&(c.textContent=o),null===(e=document.querySelector(".hero-assets"))||void 0===e||e.classList.toggle("hero-card--empty",0===o);var l=document.getElementById("hero-assets-value"),u=document.getElementById("hero-assets-count"),d=document.getElementById("hero-assets-change");if(l&&(l.textContent=this.formatCurrency(r,a)),u&&(u.textContent=(0,i.zw)("budget","%n asset","%n assets",o)),d&&null!=n&&n.change){var h=n.change,g=h.amount,p=h.percentage;if(0!==g){var f=g>=0?"↑":"↓",m=this.formatCurrency(Math.abs(g),a);d.textContent="".concat(f," ").concat((0,i.Tl)("budget","{amount} ({percent}%) vs 30d ago",{amount:m,percent:Math.abs(p).toFixed(1)})),d.className="hero-change ".concat(g>=0?"positive":"negative")}else d.textContent=""}}},{key:"updateTopCategoriesWidget",value:function(t){var e,n=this,a=document.getElementById("top-categories-list");if(a){var r;if(Array.isArray(t)){if(0===t.length)return void(a.innerHTML='
'.concat((0,i.Tl)("budget","No spending data"),"
"));r=t}else{if("object"!==Rt(t))return void(a.innerHTML='
'.concat((0,i.Tl)("budget","No spending data"),"
"));var o=Object.entries(t);if(0===o.length)return void(a.innerHTML='
'.concat((0,i.Tl)("budget","No spending data"),"
"));r=o.map(function(t){var e=Nt(t,2),n=e[0],a=e[1];return{categoryId:parseInt(n),amount:a}})}((null===(e=this.dashboardConfig.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e?void 0:e.topCategories)||{}).topLevelOnly&&(r=this.aggregateToTopLevel(r));var c=r.sort(function(t,e){return Math.abs(e.total||e.amount||0)-Math.abs(t.total||t.amount||0)}).slice(0,5);a.innerHTML=c.map(function(t){var e=t.name||"Unknown",a=t.color||"#999",r=t.total||t.amount||0;return'\n
\n \n ').concat(s.ZD(e),'\n ').concat(n.formatCurrency(Math.abs(r)),"\n
\n ")}).join("")}}},{key:"updateAccountPerformanceWidget",value:function(t){var e=this,n=document.getElementById("account-performance-list");if(n&&Array.isArray(t))if(0!==t.length){var a=t.map(function(t){return Wt(Wt({},t),{},{changeAmount:t.balance||0})}).sort(function(t,e){return Math.abs(e.changeAmount)-Math.abs(t.changeAmount)}).slice(0,5);n.innerHTML=a.map(function(t){var n=t.changeAmount,a=n>=0;return'\n \n ")}).join("")}else n.innerHTML='
'.concat((0,i.Tl)("budget","No account data"),"
")}},{key:"updateBudgetBreakdownWidget",value:function(t){var e=this,n=document.getElementById("budget-breakdown-table");n&&(Array.isArray(t)&&0!==t.length?n.innerHTML='\n \n \n \n \n \n \n \n \n \n \n ").concat(t.map(function(t){var n=t.budgeted||t.budget||0,a=t.spent||0,r=n-a;return"\n \n \n \n \n \n \n ")}).join(""),"\n \n
'.concat((0,i.Tl)("budget","Category"),"").concat((0,i.Tl)("budget","Budget"),"").concat((0,i.Tl)("budget","Spent"),"").concat((0,i.Tl)("budget","Remaining"),"
".concat(s.ZD(t.categoryName||t.name),"").concat(e.formatCurrency(n),"").concat(e.formatCurrency(a),'\n ').concat(e.formatCurrency(r),"\n
\n "):n.innerHTML='
'.concat((0,i.Tl)("budget","No budget data"),"
"))}},{key:"updateGoalsSummaryWidget",value:function(t){var e=this,n=document.getElementById("goals-summary-list");n&&(Array.isArray(t)&&0!==t.length?n.innerHTML=t.map(function(t){var n=t.targetAmount||t.target_amount||0,a=t.currentAmount||t.current_amount||0,r=n>0?Math.min(Math.max(a/n*100,0),100):0,i=t.color&&/^#[0-9a-fA-F]{3,6}$/.test(t.color)?t.color:"",o=i?"background: ".concat(i,";"):"";return'\n
\n
\n '.concat(s.ZD(t.name),'\n ').concat(r.toFixed(0),'%\n
\n
\n
\n
\n \n
\n ")}).join(""):n.innerHTML='
'.concat((0,i.Tl)("budget","No savings goals"),"
"))}},{key:"updatePaymentBreakdownWidget",value:function(t){var e=this,n=document.getElementById("payment-breakdown-list");if(n&&Array.isArray(t))if(0!==t.length){var a=t.reduce(function(t,e){var n=e.type||"Other";return t[n]||(t[n]={count:0,total:0}),t[n].count++,t[n].total+=e.balance||0,t},{}),r={checking:(0,i.Tl)("budget","Checking"),savings:(0,i.Tl)("budget","Savings"),credit:(0,i.Tl)("budget","Credit Cards"),investment:(0,i.Tl)("budget","Investments"),loan:(0,i.Tl)("budget","Loans"),Other:(0,i.Tl)("budget","Other")};n.innerHTML=Object.entries(a).map(function(t){var n=Nt(t,2),a=n[0],o=n[1];return'\n
\n
\n '.concat(r[a]||a,'\n ').concat((0,i.zw)("budget","%n account","%n accounts",o.count),'\n
\n
').concat(e.formatCurrency(o.total),"
\n
\n ")}).join("")}else n.innerHTML='
'.concat((0,i.Tl)("budget","No account data"),"
")}},{key:"updateReconciliationStatusWidget",value:function(t){var e=document.getElementById("reconciliation-status-list");if(e&&Array.isArray(t))if(0!==t.length){var n=t.map(function(t){return{name:t.name,unreconciledCount:0,lastReconciled:null}}).filter(function(t){return!0});0!==n.length?e.innerHTML=n.slice(0,5).map(function(t){return'\n
\n
'.concat(s.ZD(t.name),'
\n
\n ').concat((0,i.Tl)("budget","Up to date"),"\n
\n
\n ")}).join(""):e.innerHTML='
'.concat((0,i.Tl)("budget","All accounts reconciled"),"
")}else e.innerHTML='
'.concat((0,i.Tl)("budget","No accounts to reconcile"),"
")}},{key:"updateMonthlyComparisonWidget",value:function(){var t,e=document.getElementById("monthly-comparison-content");if(e){var n=this.widgetData.monthlyComparison;if(n&&n.current){var a=n.current.totals||{},r=(null===(t=n.previous)||void 0===t?void 0:t.totals)||{},o=parseFloat(a.totalIncome||0),c=parseFloat(a.totalExpenses||0),l=parseFloat(r.totalIncome||0),u=parseFloat(r.totalExpenses||0),d=l>0?((o-l)/l*100).toFixed(1):0,h=u>0?((c-u)/u*100).toFixed(1):0,g=d>=0?"↑":"↓",p=h>=0?"↑":"↓";e.innerHTML="\n ".concat(n.periodLabel?'
'.concat(s.ZD(n.periodLabel),"
"):"",'\n
\n ').concat((0,i.Tl)("budget","Income"),'\n ').concat(this.formatCurrency(o),'\n ').concat(g," ").concat(Math.abs(d),'%\n
\n
\n ').concat((0,i.Tl)("budget","Expenses"),'\n ').concat(this.formatCurrency(c),'\n ').concat(p," ").concat(Math.abs(h),"%\n
\n ")}else e.innerHTML='
'.concat((0,i.Tl)("budget","No data available"),"
")}}},{key:"updateLargeTransactionsWidget",value:function(){var t=this,e=document.getElementById("large-transactions-list");if(e){var n=this.widgetData.largeTransactions;if(Array.isArray(n)&&0!==n.length){var a=Ft(n).sort(function(t,e){return Math.abs(e.amount)-Math.abs(t.amount)});e.innerHTML=a.slice(0,5).map(function(e){return'\n
\n
\n
'.concat(s.ZD(e.vendor||e.description||(0,i.Tl)("budget","Unknown")),'
\n
').concat(o.Yq(e.date,t.settings),'
\n
\n
').concat(t.formatCurrency(e.amount),"
\n
\n ")}).join("")}else e.innerHTML='
'.concat((0,i.Tl)("budget","No large transactions"),"
")}}},{key:"updateWeeklyTrendWidget",value:function(){var t,e,n=document.getElementById("weekly-trend-content");if(n){var a=this.widgetData.weeklyTrend;if(a&&Array.isArray(a)&&0!==a.length){var r=a.reduce(function(t,e){return t+Math.abs(parseFloat(e.total||0))},0),o=r/Math.max(1,parseInt(null===(t=a[0])||void 0===t?void 0:t.days,10)||7),c=this._dateRangeLabel(null===(e=this.dashboardConfig)||void 0===e||null===(e=e.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e||null===(e=e.weeklyTrend)||void 0===e?void 0:e.dateRange,"weeklyTrend");n.innerHTML='\n
\n
'.concat(this.formatCurrency(r),'
\n
').concat(s.ZD(c),'
\n
\n
\n
').concat(this.formatCurrency(o),'
\n
').concat((0,i.Tl)("budget","Daily average"),"
\n
\n ")}else n.innerHTML='
'.concat((0,i.Tl)("budget","No spending data for this period"),"
")}}},{key:"updatePensionProjectionWidget",value:function(){var t=document.getElementById("pension-projection-widget-content");if(t){var e=this.widgetData.pensionProjection;if(e&&e.pensionCount){var n=null===e.currentAge||void 0===e.currentAge?'
'.concat((0,i.Tl)("budget","Set your date of birth in your Nextcloud profile for an accurate horizon"),"
"):"";t.innerHTML='\n
\n
'.concat(this.formatCurrency(e.totalProjectedValue||0),'
\n
').concat((0,i.Tl)("budget","Projected at retirement"),'
\n
\n
\n
').concat(this.formatCurrency(e.totalProjectedAnnualIncome||0),'
\n
').concat((0,i.Tl)("budget","Projected income / yr"),"
\n
\n ").concat(n,"\n ")}else t.innerHTML='
'.concat((0,i.Tl)("budget","No pensions to project"),"
")}}},{key:"updateUnmatchedTransfersWidget",value:function(){var t=this,e=document.getElementById("unmatched-transfers-list");if(e){var n=this.widgetData.unmatchedTransfers;Array.isArray(n)&&0!==n.length?e.innerHTML=n.slice(0,5).map(function(e){return'\n
\n
\n
'.concat(s.ZD(e.vendor||e.description||(0,i.Tl)("budget","Unknown")),'
\n
').concat(o.Yq(e.date,t.settings)," · ").concat(t.formatCurrency(e.amount),"
\n
\n
\n ")}).join(""):e.innerHTML='
'.concat((0,i.Tl)("budget","No unmatched transfers"),"
")}}},{key:"updateCategoryTrendsWidget",value:function(){var t=this,e=document.getElementById("category-trends-content");if(e){var n=this.widgetData.categoryTrends;n&&Array.isArray(n)&&0!==n.length?e.innerHTML=n.slice(0,5).map(function(e){var n=e.previousTotal>0?((e.currentTotal-e.previousTotal)/e.previousTotal*100).toFixed(1):0,a=n>=0?"↑":"↓";return'\n
\n
\n \n
').concat(s.ZD(e.name),'
\n
\n
\n ').concat(t.formatCurrency(e.currentTotal),'\n ').concat(a," ").concat(Math.abs(n),"%\n
\n
\n ")}).join(""):e.innerHTML='
'.concat((0,i.Tl)("budget","No category trends available"),"
")}}},{key:"updateBillsDueSoonWidget",value:function(){var t=this,e=document.getElementById("bills-due-soon-list");if(e){var n=this._tileNumberSetting("billsDueSoon","forwardHorizon",o.xB,30),a=this._tileBills("billsDueSoon",this.filterBillsByHorizon(this.widgetData.billsDueSoon,n));if(0!==a.length){var r=o.rT();e.innerHTML=a.map(function(e){var n=e.nextDueDate||e.next_due_date,a=o.X6(r,n),c="",l="";return a<0?(c="overdue",l=(0,i.zw)("budget","Overdue by %n day","Overdue by %n days",Math.abs(a))):0===a?(c="due-soon",l=(0,i.Tl)("budget","Due today")):(c=a<=7?"due-soon":"",l=(0,i.zw)("budget","Due in %n day","Due in %n days",a)),'\n
\n
\n
').concat(s.ZD(e.name),'
\n
').concat(l,'
\n
\n
').concat(t.formatCurrency(e.amount,e.currency),"
\n
\n ")}).join("")}else this._emptyBillsState(e,(0,i.Tl)("budget","No bills due soon"))}}},{key:"filterBillsByHorizon",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).keepAllOverdue,r=void 0!==a&&a,i=n||o.rT(),s=function(t){return t.nextDueDate||t.next_due_date};return(Array.isArray(t)?t:[]).filter(function(t){var n=s(t);if(!n)return!1;var a=o.X6(i,n);return(r||a>=-7)&&a<=e}).sort(function(t,e){return(s(t)||"").localeCompare(s(e)||"")})}},{key:"updateIncomeTrackingWidget",value:function(){var t=this,e=document.getElementById("income-tracking-content");if(e){var n=this.widgetData.incomeTracking||{},a=n.summary,r=void 0===a?null:a,c=n.incomes,l=void 0===c?[]:c;if(r&&0!==l.length){var u=r.receivedThisMonth||0,d=u+(r.expectedThisMonth||0),h=d>0?Math.round(u/d*100):0,g=Ft(l).sort(function(t,e){return(t.nextExpectedDate||"9999-12-31").localeCompare(e.nextExpectedDate||"9999-12-31")}).slice(0,5);e.innerHTML='\n
\n
\n
'.concat((0,i.Tl)("budget","Monthly income"),'
\n
').concat((0,i.Tl)("budget","{received} of {due} received this month",{received:u,due:d}),'
\n
\n
').concat(this.formatCurrency(r.monthlyTotal||0,r.baseCurrency||null),'
\n
\n
\n ').concat(g.map(function(e){return'\n
\n
\n
'.concat(s.ZD(e.name),'
\n
').concat(e.nextExpectedDate?s.ZD(o.Yq(e.nextExpectedDate,t.settings)):"",'
\n
\n
').concat(t.formatCurrency(e.amount,e.currency||null),"
\n
\n ")}).join(""),"\n ")}else e.innerHTML='
'.concat((0,i.Tl)("budget","No recurring income set up"),"
")}}},{key:"updateRecentImportsWidget",value:function(){var t=this,e=document.getElementById("recent-imports-list");if(e){var n=this.widgetData.recentImports;Array.isArray(n)&&0!==n.length?e.innerHTML=n.slice(0,5).map(function(e){var n=e.account_name||(0,i.Tl)("budget","Unknown"),a=parseInt(e.count)||0,r=e.imported_at?o.Yq(e.imported_at.split(" ")[0],t.settings):"";return'\n
\n
\n
'.concat(s.ZD(n),'
\n
').concat((0,i.zw)("budget","%n transaction","%n transactions",a)).concat(r?" · ".concat(r):"","
\n
\n
\n ")}).join(""):e.innerHTML='
'.concat((0,i.Tl)("budget","No recent imports"),"
")}}},{key:"updateRuleEffectivenessWidget",value:function(){var t=document.getElementById("rule-effectiveness-content");if(t){var e=this.widgetData.ruleEffectiveness;if(Array.isArray(e)&&0!==e.length){var n=e.filter(function(t){return!1!==t.isActive});t.innerHTML='\n
\n
'.concat(n.length,'
\n
').concat((0,i.Tl)("budget","Active rules"),'
\n
\n
\n
').concat(e.length,'
\n
').concat((0,i.Tl)("budget","Total rules"),"
\n
\n ")}else t.innerHTML='
'.concat((0,i.Tl)("budget","No import rules configured"),"
")}}},{key:"updateSpendingVelocityWidget",value:function(){var t=document.getElementById("spending-velocity-content");if(t){var e=this.widgetData.spendingVelocity;if(e){var n=parseFloat(e.dailyRate||0),a=30*n;t.innerHTML='\n
\n
'.concat(this.formatCurrency(n),'
\n
').concat((0,i.Tl)("budget","Per day"),'
\n
\n
\n
').concat(this.formatCurrency(a),'
\n
').concat((0,i.Tl)("budget","Projected monthly"),"
\n
\n ")}else t.innerHTML='
'.concat((0,i.Tl)("budget","No spending data available"),"
")}}},{key:"updateUncategorizedCountWidget",value:function(){var t=document.getElementById("uncategorized-count-content");if(t){var e=this.widgetData.uncategorizedCount,n=Array.isArray(e)?e.length:0;t.innerHTML='\n
\n
'.concat(n,'
\n
').concat((0,i.Tl)("budget","Uncategorized transactions"),"
\n
\n ")}}},{key:"categoryWithDescendants",value:function(t){var e=this.app.categories||[],n=[parseInt(t)],a=function(t){var r,i=Ot(e);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.parentId===t&&(n.push(o.id),a(o.id))}}catch(t){i.e(t)}finally{i.f()}};return a(parseInt(t)),n}},{key:"updateSpendingChart",value:function(t){var e,n,a,o,c,l,u=this,d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"spendingChart",h=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.isDuplicateInstance(d)){var g=this.getWidgetCard(d);n=g?g.querySelector("canvas"):null}else n=document.getElementById("spending-chart");if(n){var p;if(this.charts[d]&&this.charts[d].destroy(),Array.isArray(t)){if(0===t.length)return;p=t}else{if("object"!==Rt(t))return;var f=Object.entries(t);if(0===f.length)return;p=f.map(function(t){var e=Nt(t,2),n=e[0],a=e[1];return{categoryId:parseInt(n),amount:a}})}var m=(null===(e=this.dashboardConfig.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e?void 0:e[d])||{},v=_t(m.hiddenCategories,this.app.categories||[]),y=(a=p,o=m.hiddenCategories,c=this.app.categories||[],0===(l=_t(o,c)).size?a:a.filter(function(t){return!l.has(function(t){var e;return parseInt(null!==(e=t.id)&&void 0!==e?e:t.categoryId,10)}(t))})),b=p.length-y.length;p=y,m.topLevelOnly&&(p=this.aggregateToTopLevel(p));var w,T=n.getContext("2d"),k=p.sort(function(t,e){return Math.abs(e.total||e.amount||0)-Math.abs(t.total||t.amount||0)}).slice(0,10),E=k.map(function(t){return t.name||(0,i.Tl)("budget","Unknown")}),x=k.map(function(t){return Math.abs(t.total||t.amount||0)}),S=k.map(function(t){return t.color||"#999"}),C=this._validAccountId(m.accountId),I="bar"===(m.chartType||"doughnut");if(this.charts[d]=new r.A(T,{type:I?"bar":"doughnut",data:{labels:E,datasets:[Wt({data:x,backgroundColor:S},I?{borderRadius:4}:{})]},options:Wt(Wt({responsive:!0,maintainAspectRatio:!1},I?{indexAxis:"y"}:{}),{},{onClick:function(t,e){var n,a;if(e&&0!==e.length){var r=k[e[0].index];if(r){var i=null!==(n=null!==(a=r.id)&&void 0!==a?a:r.categoryId)&&void 0!==n?n:null;i&&m.topLevelOnly&&(i=u.categoryWithDescendants(i).filter(function(t){return!v.has(t)})),u.app.openTransactionsForCategory(i,{dateFrom:(null==h?void 0:h.dateFrom)||"",dateTo:(null==h?void 0:h.dateTo)||"",accountId:C||""})}}},onHover:function(t,e){var n,a=null===(n=t.native)||void 0===n?void 0:n.target;a&&(a.style.cursor=e.length?"pointer":"default")},plugins:{legend:{display:!1},tooltip:{callbacks:{label:function(t){return"".concat(t.label,": ").concat(u.formatCurrency(t.raw))},footer:function(){return(0,i.Tl)("budget","Click to view transactions")}}}},layout:{padding:10}})}),this.isDuplicateInstance(d)){var A=this.getWidgetCard(d);w=A?A.querySelector(".spending-legend"):null}else w=document.getElementById("spending-chart-legend");if(w){var _=p.reduce(function(t,e){return t+Math.abs(e.total||e.amount||0)},0),M=b>0?'
'.concat((0,i.zw)("budget","%n category hidden","%n categories hidden",b),"
"):"";w.innerHTML='\n
\n
\n '.concat((0,i.Tl)("budget","Total Spending"),"\n ").concat(this.formatCurrency(_),"\n
\n ").concat(M,"\n ").concat(k.map(function(t,e){var n=x[e],a=_>0?(n/_*100).toFixed(1):0;return'\n
\n
\n \n ').concat(s.ZD(E[e]),'\n
\n
\n ').concat(a,'%\n ').concat(u.formatCurrency(n),"\n
\n
\n ")}).join(""),"\n
\n ")}}}},{key:"updateTrendChart",value:function(t){var e,n,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"trendChart";if(this.isDuplicateInstance(s)){var c=this.getWidgetCard(s);n=c?c.querySelector("canvas"):null}else n=document.getElementById("trend-chart");if(n&&(this.charts[s]&&this.charts[s].destroy(),t&&t.labels&&0!==t.labels.length)){var l=n.getContext("2d"),u=(null===(e=this.dashboardConfig.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e?void 0:e[s])||{},d="bar"===(u.chartType||"line"),h=!1!==u.showLegend,p=Array.isArray(t.months)&&t.months.length===t.labels.length?t.months:null,f=p?p.map(function(t){return o.ng(t)}):t.labels,m=new Date,v="".concat(m.getFullYear(),"-").concat(String(m.getMonth()+1).padStart(2,"0")),y=t.labels.length-1,b=p&&p[y]===v?y:-1,w={borderDash:function(t){return b>0&&t.p1DataIndex===b?[6,4]:void 0}};this.charts[s]=new r.A(l,{type:d?"bar":"line",data:{labels:f,datasets:[{label:(0,i.Tl)("budget","Income"),data:t.income||[],borderColor:(0,g.PJ)("positive","#46ba61"),backgroundColor:d?(0,g.PJ)("positive","rgba(70, 186, 97, 0.6)",.6):(0,g.PJ)("positive","rgba(70, 186, 97, 0.1)",.1),fill:!d,tension:d?0:.3,segment:w},{label:(0,i.Tl)("budget","Expenses"),data:t.expenses||[],borderColor:(0,g.PJ)("negative","#e9322d"),backgroundColor:d?(0,g.PJ)("negative","rgba(233, 50, 45, 0.6)",.6):(0,g.PJ)("negative","rgba(233, 50, 45, 0.1)",.1),fill:!d,tension:d?0:.3,segment:w}]},options:{responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},plugins:{legend:{display:h,position:"top"},tooltip:{callbacks:{title:function(t){var e,n,a=(null===(e=t[0])||void 0===e?void 0:e.label)||"";return(null===(n=t[0])||void 0===n?void 0:n.dataIndex)===b?(0,i.Tl)("budget","{month} (so far)",{month:a}):a},label:function(t){return"".concat(t.dataset.label,": ").concat(a.formatCurrency(t.raw))}}}},scales:{y:{ticks:{callback:function(t){return o.Yo(t,null,a.settings)}}}}}})}}},{key:"updateNetWorthHistoryChart",value:function(t){var e,n,a,s=this,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"netWorthHistory";if(this.isDuplicateInstance(l)){var u=this.getWidgetCard(l);e=u?u.querySelector("canvas"):null,n=u?u.querySelector(".chart-empty-state"):null,a=u?u.querySelector(".net-worth-status"):null}else e=document.getElementById("net-worth-chart"),n=document.getElementById("net-worth-chart-empty"),a=document.getElementById("net-worth-snapshot-status");if(e){this.charts[l]&&this.charts[l].destroy();var d=e.closest(".chart-container");if(!t||0===t.length)return d&&(d.style.display="none"),n&&(n.style.display="flex"),void(a&&(a.style.display="none"));d&&(d.style.display=""),e.style.display="block",n&&(n.style.display="none");var h,p=this.getPrimaryCurrency(),f=t.map(function(t){return t.date});c?(a&&(a.style.display="none"),h=[{label:(0,i.Tl)("budget","Balance"),data:t.map(function(t){return t.balance}),borderColor:"#0082c9",backgroundColor:"rgba(0, 130, 201, 0.1)",fill:!0,tension:.3,borderWidth:2}]):(this.updateNetWorthStatus(t,a),h=[{label:(0,i.Tl)("budget","Net Worth"),data:t.map(function(t){return t.netWorth}),borderColor:(0,g.PJ)("positive","#46ba61"),backgroundColor:(0,g.PJ)("positive","rgba(70, 186, 97, 0.1)",.1),fill:!0,tension:.3,borderWidth:2},{label:(0,i.Tl)("budget","Assets"),data:t.map(function(t){return t.totalAssets}),borderColor:"#0082c9",borderDash:[5,5],fill:!1,tension:.3,borderWidth:1.5},{label:(0,i.Tl)("budget","Liabilities"),data:t.map(function(t){return t.totalLiabilities}),borderColor:(0,g.PJ)("negative","#e9322d"),borderDash:[5,5],fill:!1,tension:.3,borderWidth:1.5}]),this.charts[l]=new r.A(e,{type:"line",data:{labels:f,datasets:h},options:{responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},plugins:{legend:{display:!0,position:"bottom",labels:{usePointStyle:!0,padding:15}},tooltip:{callbacks:{label:function(t){return"".concat(t.dataset.label,": ").concat(s.formatCurrency(t.raw,p))}}}},scales:{y:{ticks:{callback:function(t){return o.Yo(t,p,s.settings)}}},x:{ticks:{maxTicksLimit:8}}}}})}}},{key:"updateAssetValueHistoryChart",value:function(t){var e,n,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"assetValueHistory";if(this.isDuplicateInstance(s)){var c=this.getWidgetCard(s);e=c?c.querySelector("canvas"):null,n=c?c.querySelector(".chart-empty-state"):null}else e=document.getElementById("asset-value-history-chart"),n=document.getElementById("asset-value-chart-empty");if(e){this.charts[s]&&this.charts[s].destroy();var l=(null==t?void 0:t.history)||[],u=e.closest(".chart-container");if(0===l.length)return u&&(u.style.display="none"),void(n&&(n.style.display="flex"));u&&(u.style.display=""),e.style.display="block",n&&(n.style.display="none");var d=t.baseCurrency||this.getPrimaryCurrency(),h=l.map(function(t){return t.date}),g=l.map(function(t){return t.totalValue});this.charts[s]=new r.A(e,{type:"line",data:{labels:h,datasets:[{label:(0,i.Tl)("budget","Asset Value"),data:g,borderColor:"#ff9800",backgroundColor:"rgba(255, 152, 0, 0.1)",fill:!0,tension:.3,borderWidth:2}]},options:{responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},plugins:{legend:{display:!1},tooltip:{callbacks:{label:function(t){return"".concat((0,i.Tl)("budget","Portfolio"),": ").concat(a.formatCurrency(t.raw,d))}}}},scales:{y:{ticks:{callback:function(t){return o.Yo(t,d,a.settings)}}},x:{ticks:{maxTicksLimit:8}}}}})}}},{key:"refreshAssetValueChart",value:(w=Zt(zt().m(function t(e){var n,a,r,i=arguments;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:"assetValueHistory",t.p=1,t.n=2,(0,T.n)("/apps/budget/api/assets/value-history?days=".concat(e),{errorMessage:"Failed to fetch asset value history"});case 2:a=t.v,this.updateAssetValueHistoryChart(a,n),t.n=4;break;case 3:t.p=3,r=t.v,console.error("Failed to refresh asset value chart:",r);case 4:return t.a(2)}},t,this,[[1,3]])})),function(t){return w.apply(this,arguments)})},{key:"updateCashFlowForecastWidget",value:function(){var t,e,n,a,s,c=this,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cashFlowForecast";if(this.isDuplicateInstance(l)){var u=this.getWidgetCard(l);a=u?u.querySelector("canvas"):null,s=u?u.querySelector(".chart-empty-state"):null}else a=document.getElementById("cash-flow-forecast-chart"),s=document.getElementById("cash-flow-forecast-empty");if(a){this.charts[l]&&this.charts[l].destroy();var d=(null===(t=this.widgetData)||void 0===t?void 0:t[l])||(null===(e=this.widgetData)||void 0===e?void 0:e.cashFlowForecast),h=null==d?void 0:d.monthlyProjections,g=a.closest(".chart-container");if(!Array.isArray(h)||0===h.length)return g&&(g.style.display="none"),void(s&&(s.style.display="flex"));g&&(g.style.display=""),a.style.display="block",s&&(s.style.display="none");var p=this.getPrimaryCurrency(),f=[(0,i.Tl)("budget","Now")].concat(Ft(h.map(function(t){return t.yearMonth?o.ng(t.yearMonth):t.month}))),m=[null!==(n=d.currentBalance)&&void 0!==n?n:0].concat(Ft(h.map(function(t){return t.balance})));this.charts[l]=new r.A(a.getContext("2d"),{type:"line",data:{labels:f,datasets:[{label:(0,i.Tl)("budget","Projected balance"),data:m,borderColor:"#0082c9",backgroundColor:"rgba(0, 130, 201, 0.1)",fill:!0,tension:.3,borderWidth:2}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{callbacks:{label:function(t){return"".concat((0,i.Tl)("budget","Balance"),": ").concat(c.formatCurrency(t.raw,p))},afterBody:function(t){var e,n,a=h[(null!==(e=null==t||null===(n=t[0])||void 0===n?void 0:n.dataIndex)&&void 0!==e?e:0)-1];return a?["".concat((0,i.Tl)("budget","Income"),": ").concat(c.formatCurrency(a.income,p)),"".concat((0,i.Tl)("budget","Expenses"),": ").concat(c.formatCurrency(a.expenses,p))]:""}}}},scales:{y:{ticks:{callback:function(t){return o.Yo(t,p,c.settings)}}}}}})}}},{key:"updateYoyComparisonWidget",value:function(){var t,e,n,a,s,c=this,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"yoyComparison";if(this.isDuplicateInstance(l)){var u=this.getWidgetCard(l);a=u?u.querySelector("canvas"):null,s=u?u.querySelector(".chart-empty-state"):null}else a=document.getElementById("yoy-comparison-chart"),s=document.getElementById("yoy-comparison-empty");if(a){this.charts[l]&&this.charts[l].destroy();var d=(null===(t=this.widgetData)||void 0===t?void 0:t[l])||(null===(e=this.widgetData)||void 0===e?void 0:e.yoyComparison),h=Array.isArray(null==d?void 0:d.years)?Ft(d.years).reverse():[],p=a.closest(".chart-container");if(0===h.length)return p&&(p.style.display="none"),void(s&&(s.style.display="flex"));p&&(p.style.display=""),a.style.display="block",s&&(s.style.display="none");var f=this.getPrimaryCurrency(),m=!1!==((null===(n=this.dashboardConfig)||void 0===n||null===(n=n.widgets)||void 0===n||null===(n=n.tileSettings)||void 0===n?void 0:n[l])||{}).showLegend;this.charts[l]=new r.A(a.getContext("2d"),{type:"bar",data:{labels:h.map(function(t){return String(t.year)}),datasets:[{label:(0,i.Tl)("budget","Income"),data:h.map(function(t){return t.income}),backgroundColor:(0,g.PJ)("positive","rgba(46, 125, 50, 0.7)",.7),borderColor:(0,g.PJ)("positive","rgba(46, 125, 50, 1)",1),borderWidth:1},{label:(0,i.Tl)("budget","Expenses"),data:h.map(function(t){return t.expenses}),backgroundColor:(0,g.PJ)("negative","rgba(198, 40, 40, 0.7)",.7),borderColor:(0,g.PJ)("negative","rgba(198, 40, 40, 1)",1),borderWidth:1}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:m},tooltip:{callbacks:{label:function(t){return"".concat(t.dataset.label,": ").concat(c.formatCurrency(t.raw,f))}}}},scales:{y:{beginAtZero:!0,ticks:{callback:function(t){return o.Yo(t,f,c.settings)}}}}}})}}},{key:"updateNetWorthStatus",value:function(t,e){var n=this;if(e){var a=t.filter(function(t){return"auto"===t.source}),r=a.length>0?a[a.length-1]:null,o='
';if(o+='📊',r){var s,c=new Date(r.date),l=new Date,u=Math.floor((l-c)/36e5),d=Math.floor(u/24);s=0===d?0===u?(0,i.Tl)("budget","just now"):(0,i.zw)("budget","%n hour ago","%n hours ago",u):1===d?(0,i.Tl)("budget","yesterday"):(0,i.zw)("budget","%n day ago","%n days ago",d),o+=''.concat((0,i.Tl)("budget","Snapshots recorded automatically daily")," • ").concat((0,i.Tl)("budget","Last: {time}",{time:s}),"")}else o+=''.concat((0,i.Tl)("budget","Snapshots recorded automatically daily"),"");o+='"),o+="
",e.innerHTML=o,e.style.display="block";var h=document.getElementById("record-net-worth-btn-inline");h&&!h.hasAttribute("data-initialized")&&(h.setAttribute("data-initialized","true"),h.addEventListener("click",Zt(zt().m(function t(){return zt().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.recordNetWorthSnapshot();case 1:return t.a(2)}},t)}))))}}},{key:"setupDashboardControls",value:function(){var t=this,e=document.getElementById("trend-account-select");e&&!e.hasAttribute("data-initialized")&&(e.setAttribute("data-initialized","true"),e.addEventListener("change",Zt(zt().m(function n(){var a,r,i;return zt().w(function(n){for(;;)switch(n.n){case 0:return a=document.getElementById("trend-period-select"),r=a?parseInt(a.value):6,i=e.value||null,n.n=1,t.refreshTrendChart(r,i);case 1:return n.n=2,t.saveWidgetAccountSelection("trend-account-select",e.value);case 2:return n.a(2)}},n)}))));var n=document.getElementById("trend-period-select");n&&!n.hasAttribute("data-initialized")&&(n.setAttribute("data-initialized","true"),n.addEventListener("change",function(){var e=Zt(zt().m(function e(n){var a,r,i;return zt().w(function(e){for(;;)switch(e.n){case 0:return a=parseInt(n.target.value),r=document.getElementById("trend-account-select"),i=r&&r.value||null,e.n=1,t.refreshTrendChart(a,i);case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}()));var a=document.getElementById("spending-account-select");a&&!a.hasAttribute("data-initialized")&&(a.setAttribute("data-initialized","true"),a.addEventListener("change",Zt(zt().m(function e(){var n;return zt().w(function(e){for(;;)switch(e.n){case 0:return n=a.value||null,e.n=1,t.refreshSpendingChart("spendingChart",n);case 1:return e.n=2,t.saveWidgetAccountSelection("spending-account-select",a.value);case 2:return e.a(2)}},e)}))));var r=document.getElementById("net-worth-account-select");r&&!r.hasAttribute("data-initialized")&&(r.setAttribute("data-initialized","true"),r.addEventListener("change",Zt(zt().m(function e(){var n,a,i;return zt().w(function(e){for(;;)switch(e.n){case 0:return n=document.querySelector("#net-worth-period-selector .period-btn.active"),a=n?parseInt(n.dataset.days):30,i=r.value||null,e.n=1,t.refreshNetWorthChart(a,i);case 1:return e.n=2,t.saveWidgetAccountSelection("net-worth-account-select",r.value);case 2:return e.a(2)}},e)}))));var i=document.getElementById("net-worth-period-selector");i&&!i.hasAttribute("data-initialized")&&(i.setAttribute("data-initialized","true"),i.addEventListener("click",function(){var e=Zt(zt().m(function e(n){var a,r,o;return zt().w(function(e){for(;;)switch(e.n){case 0:if(!n.target.classList.contains("period-btn")){e.n=1;break}return i.querySelectorAll(".period-btn").forEach(function(t){return t.classList.remove("active")}),n.target.classList.add("active"),a=parseInt(n.target.dataset.days),r=document.getElementById("net-worth-account-select"),o=r&&r.value||null,e.n=1,t.refreshNetWorthChart(a,o);case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}()));var o=document.getElementById("asset-value-period-selector");o&&!o.hasAttribute("data-initialized")&&(o.setAttribute("data-initialized","true"),o.addEventListener("click",function(){var e=Zt(zt().m(function e(n){var a;return zt().w(function(e){for(;;)switch(e.n){case 0:if(!n.target.classList.contains("period-btn")){e.n=1;break}return o.querySelectorAll(".period-btn").forEach(function(t){return t.classList.remove("active")}),n.target.classList.add("active"),a=parseInt(n.target.dataset.days),e.n=1,t.refreshAssetValueChart(a);case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}()));var s=document.getElementById("record-net-worth-btn");s&&!s.hasAttribute("data-initialized")&&(s.setAttribute("data-initialized","true"),s.addEventListener("click",Zt(zt().m(function e(){return zt().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.recordNetWorthSnapshot();case 1:return e.a(2)}},e)}))));var c=document.getElementById("recent-transactions-account-select");c&&!c.hasAttribute("data-initialized")&&(c.setAttribute("data-initialized","true"),c.addEventListener("change",Zt(zt().m(function e(){var n;return zt().w(function(e){for(;;)switch(e.n){case 0:return n=c.value||null,e.n=1,t.refreshRecentTransactions(n);case 1:return e.n=2,t.saveWidgetAccountSelection("recent-transactions-account-select",c.value);case 2:return e.a(2)}},e)})))),["hero-account-income-select","hero-account-expenses-select"].forEach(function(e){var n=document.getElementById(e);n&&!n.hasAttribute("data-initialized")&&(n.setAttribute("data-initialized","true"),n.addEventListener("change",function(){e.includes("income")?t.updateAccountIncomeHero():t.updateAccountExpensesHero(),t.saveHeroAccountSelection(e,n.value)}))})}},{key:"refreshTrendChart",value:(b=Zt(zt().m(function t(e){var n,a,r,i,s,c,l,u=arguments;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=u.length>1&&void 0!==u[1]?u[1]:null,a=u.length>2&&void 0!==u[2]?u[2]:"trendChart",t.p=1,(i=new Date).setMonth(i.getMonth()-e),s="/apps/budget/api/reports/summary?startDate=".concat(o.JV(i)),n&&(s+="&accountId=".concat(n)),null!==(r=this.dashboardConfig.widgets)&&void 0!==r&&null!==(r=r.tileSettings)&&void 0!==r&&null!==(r=r[a])&&void 0!==r&&r.excludeShared&&(s+="&excludeShared=1"),t.n=2,(0,T.n)(s);case 2:(c=t.v).trends&&this.updateTrendChart(c.trends,a),t.n=4;break;case 3:t.p=3,l=t.v,console.error("Failed to refresh trend chart:",l);case 4:return t.a(2)}},t,this,[[1,3]])})),function(t){return b.apply(this,arguments)})},{key:"refreshSpendingChart",value:(y=Zt(zt().m(function t(){var e,n,a,r,i,o,s,c,l,u=arguments;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:"spendingChart",n=u.length>1&&void 0!==u[1]?u[1]:null,t.p=1,r=this._tileRangeParams(e),i=r.startDate,o=r.endDate,s="/apps/budget/api/reports/spending?startDate=".concat(i,"&endDate=").concat(o),n&&(s+="&accountId=".concat(n)),null!==(a=this.dashboardConfig.widgets)&&void 0!==a&&null!==(a=a.tileSettings)&&void 0!==a&&null!==(a=a[e])&&void 0!==a&&a.excludeShared&&(s+="&excludeShared=1"),t.n=2,(0,T.n)(s);case 2:(c=t.v).data&&this.updateSpendingChart(this._categorySpendingRows(c.data),e,{dateFrom:i,dateTo:o}),t.n=4;break;case 3:t.p=3,l=t.v,console.error("Failed to refresh spending chart:",l);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return y.apply(this,arguments)})},{key:"refreshNetWorthChart",value:(v=Zt(zt().m(function t(e){var n,a,r,i,o,s,c=arguments;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=c.length>1&&void 0!==c[1]?c[1]:null,a=c.length>2&&void 0!==c[2]?c[2]:"netWorthHistory",t.p=1,!n){t.n=7;break}return t.p=2,t.n=3,(0,T.n)("/apps/budget/api/accounts/".concat(n,"/balance-history?days=").concat(e),{errorMessage:"Failed to fetch balance history"});case 3:r=t.v,t.n=6;break;case 4:if(t.p=4,!((o=t.v)instanceof T.h&&404===o.status)){t.n=5;break}return t.a(2,this.refreshNetWorthChart(e,null,a));case 5:throw o;case 6:this.updateNetWorthHistoryChart(r,n,a),t.n=9;break;case 7:return t.n=8,(0,T.n)("/apps/budget/api/net-worth/snapshots?days=".concat(e),{errorMessage:"Failed to fetch net worth snapshots"});case 8:i=t.v,this.updateNetWorthHistoryChart(i,null,a);case 9:t.n=11;break;case 10:t.p=10,s=t.v,console.error("Failed to refresh net worth chart:",s);case 11:return t.a(2)}},t,this,[[2,4],[1,10]])})),function(t){return v.apply(this,arguments)})},{key:"_recentTxLimit",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"recentTransactions",n=parseInt(null===(t=this.dashboardConfig)||void 0===t||null===(t=t.widgets)||void 0===t||null===(t=t.tileSettings)||void 0===t||null===(t=t[e])||void 0===t?void 0:t.rowCount,10);return n>0?n:5}},{key:"refreshRecentTransactions",value:(m=Zt(zt().m(function t(){var e,n,a,r,i,o,s=arguments;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return e=s.length>0&&void 0!==s[0]?s[0]:null,n=s.length>1&&void 0!==s[1]?s[1]:"recentTransactions",t.p=1,r="/apps/budget/api/transactions?limit=".concat(this._recentTxLimit(n)),e&&(r+="&accountId=".concat(e)),null!==(a=this.dashboardConfig.widgets)&&void 0!==a&&null!==(a=a.tileSettings)&&void 0!==a&&null!==(a=a[n])&&void 0!==a&&a.excludeShared&&(r+="&excludeShared=1"),t.n=2,(0,T.n)(r,{errorMessage:"Failed to fetch recent transactions"});case 2:i=t.v,this.updateRecentTransactions(i.transactions||i,n),t.n=4;break;case 3:t.p=3,o=t.v,console.error("Failed to refresh recent transactions:",o);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return m.apply(this,arguments)})},{key:"refreshWidgetInstance",value:(f=Zt(zt().m(function t(e){var n,a,r,i,o,s,c;return zt().w(function(t){for(;;)switch(t.n){case 0:a=this.getWidgetType(e),r=(null===(n=this.dashboardConfig.widgets)||void 0===n||null===(n=n.tileSettings)||void 0===n?void 0:n[e])||{},i=r.dateRange||this._defaultDateRange(a),o={"30d":30,"90d":90,"6m":180,"1y":365}[i]||180,s={"30d":1,"90d":3,"6m":6,"1y":12}[i]||6,c=a,t.n="trendChart"===c?1:"spendingChart"===c?2:"netWorthHistory"===c?3:"assetValueHistory"===c?4:"recentTransactions"===c?5:6;break;case 1:return t.a(2,this.refreshTrendChart(s,this._validAccountId(r.accountId),e));case 2:return t.a(2,this.refreshSpendingChart(e,this._validAccountId(r.accountId)));case 3:return t.a(2,this.refreshNetWorthChart(o,this._validAccountId(r.accountId),e));case 4:return t.a(2,this.refreshAssetValueChart(o,e));case 5:return t.a(2,this.refreshRecentTransactions(this._validAccountId(r.accountId),e));case 6:return t.a(2)}},t,this)})),function(t){return f.apply(this,arguments)})},{key:"recordNetWorthSnapshot",value:(p=Zt(zt().m(function t(){var e,n,a;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/net-worth/snapshots",{method:"POST",errorMessage:"Failed to record snapshot"});case 1:return(0,c.Te)((0,i.Tl)("budget","Net worth snapshot recorded")),e=document.querySelector("#net-worth-period-selector .period-btn.active"),n=e?parseInt(e.dataset.days):30,t.n=2,this.refreshNetWorthChart(n);case 2:t.n=4;break;case 3:t.p=3,a=t.v,console.error("Failed to record net worth snapshot:",a),(0,c.Qg)((0,i.Tl)("budget","Failed to record snapshot"));case 4:return t.a(2)}},t,this,[[0,3]])})),function(){return p.apply(this,arguments)})},{key:"parseDashboardConfig",value:function(t,e){var n=nt[e],a={order:Object.keys(n),visibility:Object.keys(n).reduce(function(t,e){return t[e]=n[e].defaultVisible,t},{})};if(!t)return a;try{var r=JSON.parse(t);if(!r||"object"!==Rt(r))return a;var i=Array.isArray(r.order)?r.order:[],o=r.visibility||{},s=new Set([].concat(Ft(i),Ft(a.order))),c=i.filter(function(t){return s.has(t)});a.order.forEach(function(t){c.includes(t)||c.push(t)});var l=Wt(Wt({},a.visibility),o),u={order:c,visibility:l,settings:r.settings||{}};return u.sizes||(u.sizes=r.sizes||{}),u.tileSettings||(u.tileSettings=r.tileSettings||{}),u.instances||(u.instances=r.instances||{}),u.positions||(u.positions=r.positions||{}),u}catch(t){return console.error("Failed to parse dashboard config",t),a}}},{key:"applyDashboardVisibility",value:(h=Zt(zt().m(function t(){var e,n,a,r,i,o,s,c,l,u,d,h,g,p,f,m,v,y;return zt().w(function(t){for(;;)switch(t.n){case 0:e=0,n=Object.entries(this.dashboardConfig.hero.visibility);case 1:if(!(e\n

'.concat(e.name,'

\n
\n \n
\n \n
\n
\n ')},spendingChart:function(t,e){return'\n
\n

'.concat(e.name,'

\n
\n
\n
\n
\n \n
\n
\n
\n ')},netWorthHistory:function(t,e){return'\n
\n

'.concat(e.name,'

\n
\n
\n \n
\n \n
\n \n ")},assetValueHistory:function(t,e){return'\n
\n

'.concat(e.name,'

\n
\n
\n
\n \n
\n \n ")},recentTransactions:function(t,e){return'\n
\n
\n ')}}}},{key:"_wrapCardsForGridstack",value:function(t){var e;t.classList.add("grid-stack");var n=(null===(e=this.dashboardConfig.widgets)||void 0===e?void 0:e.visibility)||{},a=document.getElementById("hidden-widgets");Array.from(t.querySelectorAll('[data-widget-category="widget"]')).forEach(function(t){if(!t.closest(".grid-stack-item")){var e=t.dataset.widgetId,r=["budgetAlerts","debtPayoff","debtChart","debtProgress","projects"].includes(e),i=(!0===n[e]||void 0===n[e]&&"none"!==t.style.display)&&!(r&&"none"===t.style.display),o=document.createElement("div");o.className="grid-stack-item",o.setAttribute("gs-id",e);var s=document.createElement("div");s.className="grid-stack-item-content",t.parentNode.insertBefore(o,t),s.appendChild(t),o.appendChild(s),i||(o.style.display="none",a&&a.appendChild(o))}})}},{key:"_computeInitialPositions",value:function(){var t,e,n,a=(null===(t=this.dashboardConfig.widgets)||void 0===t?void 0:t.visibility)||{},r=Object.values(a).filter(function(t){return!1!==t}).length,i=null===(e=this.dashboardConfig.widgets)||void 0===e?void 0:e.positions;if(i&&Object.keys(i).length>0){var o=Object.keys(i).filter(function(t){return!1!==a[t]}).length;if(o>=.8*r){for(var s=0,c=Object.entries(a);sp&&(y+=4,v=0),m[w]={x:v,y,w:E,h:x},(v+=E)>=p&&(v=0,y+=x)}}}catch(t){b.e(t)}finally{b.f()}return m}},{key:"initGridstack",value:function(){var t=this,e=document.querySelector(".dashboard-grid");if(e&&!this.gridstack){this._wrapCardsForGridstack(e);var n=this._computeInitialPositions();this.gridstack=xt.init({column:this.gridColumns||3,cellHeight:100,margin:10,float:!1,animate:!0,disableOneColumnMode:!0,disableResize:!0,staticGrid:!1},e),this._tilesDraggable()||this.gridstack.disable();for(var a=[],r=0,i=Object.entries(n);r2?(e.dataset.fullH=String(n.h),t.gridstack.update(e,{h:2})):!r&&e.dataset.fullH&&(t.gridstack.update(e,{h:parseInt(e.dataset.fullH,10)}),delete e.dataset.fullH)}}),this.gridstack.batchUpdate(!1)}finally{this._compactingTiles=!1}requestAnimationFrame(function(){return t.resizeAllCharts()})}}},{key:"_isTileEmpty",value:function(t){var e=function(t){return t.getClientRects().length>0};if(0===Ft(t.querySelectorAll(".empty-state-small, .chart-empty-state")).filter(e).length)return!1;if(Ft(t.querySelectorAll("canvas")).some(e))return!1;for(var n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),a=n.nextNode();a;a=n.nextNode())if(a.textContent.trim()){var r=a.parentElement;if(r&&e(r)&&!r.closest(".card-header, .empty-state-small, .chart-empty-state, .widget-tile-controls"))return!1}return!0}},{key:"_saveGridstackPositions",value:function(){if(this.gridstack){var t={};if(this.gridstack.getGridItems().forEach(function(e){var n=e.getAttribute("gs-id");if(n){var a=e.gridstackNode;if(a){var r=e.dataset.fullH?parseInt(e.dataset.fullH,10):a.h;t[n]={x:a.x,y:a.y,w:a.w,h:r}}}}),this.dashboardConfig.widgets||(this.dashboardConfig.widgets={}),this._gridNarrowed()||(this.dashboardConfig.widgets.positions=t),Object.keys(t).length>0){var e=Object.entries(t).sort(function(t,e){var n=Nt(t,2)[1],a=Nt(e,2)[1];return n.y-a.y||n.x-a.x}).map(function(t){return Nt(t,1)[0]}),n=(this.dashboardConfig.widgets.order||[]).filter(function(t){return!e.includes(t)});this.dashboardConfig.widgets.order=[].concat(Ft(e),Ft(n))}this.saveDashboardVisibility("widgets")}}},{key:"_updateFullWidthTiles",value:function(t){var e,n=this;if(this.gridstack){var a=(null===(e=this.dashboardConfig.widgets)||void 0===e?void 0:e.sizes)||{};this.gridstack.getGridItems().forEach(function(e){var r=e.getAttribute("gs-id");r&&"l"===a[r]&&n.gridstack.update(e,{w:t})})}}},{key:"setupHeroDragAndDrop",value:function(){var t=this,e=document.querySelector(".dashboard-hero");e&&e.querySelectorAll('[data-widget-category="hero"]').forEach(function(n){n.setAttribute("draggable","true"),n.style.cursor="move",n.addEventListener("dragstart",function(e){t._heroDragItem=n,n.classList.add("hero-dragging"),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",n.dataset.widgetId)}),n.addEventListener("dragend",function(){n.classList.remove("hero-dragging"),e.querySelectorAll('[data-widget-category="hero"]').forEach(function(t){t.classList.remove("hero-drag-over")}),t._heroDragItem=null}),n.addEventListener("dragover",function(e){e.preventDefault(),e.dataTransfer.dropEffect="move",t._heroDragItem&&t._heroDragItem!==n&&n.classList.add("hero-drag-over")}),n.addEventListener("dragleave",function(){n.classList.remove("hero-drag-over")}),n.addEventListener("drop",function(a){if(a.preventDefault(),n.classList.remove("hero-drag-over"),t._heroDragItem&&t._heroDragItem!==n){var r=Array.from(e.querySelectorAll('[data-widget-category="hero"]'));r.indexOf(t._heroDragItem)1&&void 0!==arguments[1]?arguments[1]:{}).account,a=void 0===n||n,r=(null===(e=this.dashboardConfig)||void 0===e||null===(e=e.widgets)||void 0===e||null===(e=e.tileSettings)||void 0===e?void 0:e[t])||{},i="";if(a){var o=this._validAccountId(r.accountId);o&&(i+="&accountId=".concat(o))}return r.excludeShared&&(i+="&excludeShared=1"),i}},{key:"needsLazyLoad",value:function(t){return!["savingsRate","cashFlow","budgetRemaining","budgetHealth","topCategories","accountPerformance","budgetBreakdown","goalsSummary","paymentBreakdown","reconciliationStatus"].includes(t)}},{key:"loadWidgetData",value:(a=Zt(zt().m(function t(e){var n,a,r,i,s,c,l,u,d,h,g,p,f,m,v,y,b,w,k,E,x,S,C,I,A,_,M,D,B,L,P,O,F,R,N,j,H,z,V,q,W,U,G,Z=arguments;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=Z.length>1&&void 0!==Z[1]&&Z[1],!this.widgetDataLoaded[e]||n){t.n=1;break}return t.a(2);case 1:t.p=1,U=e,t.n="uncategorizedCount"===U?2:"monthlyComparison"===U?4:"largeTransactions"===U?6:"pensionProjection"===U?8:"cashFlowForecast"===U?10:"yoyComparison"===U?12:"incomeTracking"===U?14:"daysUntilDebtFree"===U?16:"debtChart"===U?18:"debtProgress"===U?20:"recentImports"===U?22:"ruleEffectiveness"===U?24:"weeklyTrend"===U?26:"unmatchedTransfers"===U?28:"billsDueSoon"===U?30:"categoryTrends"===U?32:"spendingVelocity"===U?34:36;break;case 2:return t.n=3,(0,T.n)("/apps/budget/api/transactions/uncategorized?limit=100");case 3:return this.widgetData.uncategorizedCount=t.v,t.a(3,36);case 4:return r=parseInt((null===(a=this.settings)||void 0===a?void 0:a.budget_start_day)||"1",10),i=o.J$(r),s=o.JX(i,r),c=o.JX(o.Ds(i,-1),r),l=this._tileScopeParams("monthlyComparison"),t.n=5,Promise.all([(0,T.n)("/apps/budget/api/reports/summary?startDate=".concat(s.start,"&endDate=").concat(s.end).concat(l)),(0,T.n)("/apps/budget/api/reports/summary?startDate=".concat(c.start,"&endDate=").concat(c.end).concat(l))]);case 5:return u=t.v,d=Nt(u,2),h=d[0],g=d[1],this.widgetData.monthlyComparison={current:h,previous:g,periodLabel:r>1?s.label:null},t.a(3,36);case 6:return p=this._tileRangeParams(e),t.n=7,(0,T.n)("/apps/budget/api/transactions?limit=10&sort=amount&dateFrom=".concat(p.startDate,"&dateTo=").concat(p.endDate).concat(this._tileScopeParams(e)));case 7:return this.widgetData.largeTransactions=t.v,t.a(3,36);case 8:return t.n=9,(0,T.n)("/apps/budget/api/pensions/projection").catch(function(t){if(t instanceof T.h)return null;throw t});case 9:return this.widgetData.pensionProjection=t.v,t.a(3,36);case 10:return f=this._tileNumberSetting(e,"forecastMonths",o.CZ,6),t.n=11,(0,T.n)("/apps/budget/api/forecast/live?forecastMonths=".concat(f).concat(this._tileScopeParams(e,{account:!1})));case 11:return this.widgetData.cashFlowForecast=t.v,t.a(3,36);case 12:return m=this._tileNumberSetting(e,"yearsToCompare",o.rG,2),t.n=13,(0,T.n)("/apps/budget/api/yoy/years?years=".concat(m).concat(this._tileScopeParams(e)));case 13:return this.widgetData.yoyComparison=t.v,t.a(3,36);case 14:return y=this._validAccountId(null===(v=this.dashboardConfig)||void 0===v||null===(v=v.widgets)||void 0===v||null===(v=v.tileSettings)||void 0===v||null===(v=v.incomeTracking)||void 0===v?void 0:v.accountId),t.n=15,Promise.all([(0,T.n)("/apps/budget/api/recurring-income/summary".concat(y?"?accountId=".concat(y):"")),(0,T.n)("/apps/budget/api/recurring-income?activeOnly=true")]);case 15:return b=t.v,w=Nt(b,2),k=w[0],E=w[1],this.widgetData.incomeTracking={summary:k,incomes:(Array.isArray(E)?E:[]).filter(function(t){return!1!==t.isActive}).filter(function(t){return!y||String(t.accountId)===String(y)})},t.a(3,36);case 16:return t.n=17,(0,T.n)("/apps/budget/api/debts/payoff-plan?strategy=avalanche");case 17:return this.widgetData.daysUntilDebtFree=t.v,t.a(3,36);case 18:return t.n=19,this.renderDebtChartWidget();case 19:return t.a(3,36);case 20:return t.n=21,this.renderDebtProgressWidget();case 21:return t.a(3,36);case 22:return t.n=23,(0,T.n)("/apps/budget/api/import/history?limit=5").catch(function(t){if(t instanceof T.h)return[];throw t});case 23:return this.widgetData.recentImports=t.v,t.a(3,36);case 24:return t.n=25,(0,T.n)("/apps/budget/api/import-rules");case 25:return this.widgetData.ruleEffectiveness=t.v,t.a(3,36);case 26:return S=this._tileRangeParams(e),t.n=27,(0,T.n)("/apps/budget/api/reports/summary?startDate=".concat(S.startDate,"&endDate=").concat(S.endDate).concat(this._tileScopeParams(e)));case 27:return C=t.v,I=o.X6(S.startDate,S.endDate)+1,this.widgetData.weeklyTrend=[{total:(null===(x=C.totals)||void 0===x?void 0:x.totalExpenses)||0,days:I}],t.a(3,36);case 28:return t.n=29,(0,T.n)("/apps/budget/api/transactions?limit=10&unmatched=true");case 29:return A=t.v,this.widgetData.unmatchedTransfers=Array.isArray(A)?A:[],t.a(3,36);case 30:return t.n=31,(0,T.n)("/apps/budget/api/bills?activeOnly=true");case 31:return this.widgetData.billsDueSoon=t.v,t.a(3,36);case 32:return _=this._tileRangeParams(e),M={start:_.startDate,end:_.endDate},D=o.gg(_.startDate,_.endDate),B=this._tileScopeParams("categoryTrends",{account:!1}),t.n=33,Promise.all([(0,T.n)("/apps/budget/api/categories/spending?startDate=".concat(M.start,"&endDate=").concat(M.end).concat(B)),(0,T.n)("/apps/budget/api/categories/spending?startDate=".concat(D.start,"&endDate=").concat(D.end).concat(B))]);case 33:return L=t.v,P=Nt(L,2),O=P[0],F=P[1],R={},Array.isArray(F)&&F.forEach(function(t){R[t.categoryId]=parseFloat(t.spent||0)}),N=new Set((this.app.categories||[]).filter(function(t){return"income"===t.type}).map(function(t){return Number(t.id)})),this.widgetData.categoryTrends=(Array.isArray(O)?O:[]).filter(function(t){return!N.has(Number(t.categoryId))}).map(function(t){return{name:t.name,color:t.color,currentTotal:parseFloat(t.spent||0),previousTotal:R[t.categoryId]||0}}).filter(function(t){return t.currentTotal>0||t.previousTotal>0}).sort(function(t,e){return e.currentTotal-t.currentTotal}),t.a(3,36);case 34:return j=new Date,H=o.Jq(j.getFullYear(),j.getMonth()+1),z=o.JV(j),V=j.getDate(),t.n=35,(0,T.n)("/apps/budget/api/reports/summary?startDate=".concat(H,"&endDate=").concat(z));case 35:return q=t.v,W=parseFloat(q.totalExpenses||0),this.widgetData.spendingVelocity={dailyRate:V>0?W/V:0},t.a(3,36);case 36:this.widgetDataLoaded[e]=!0,t.n=38;break;case 37:t.p=37,G=t.v,console.error("Failed to load data for ".concat(e,":"),G);case 38:return t.a(2)}},t,this,[[1,37]])})),function(t){return a.apply(this,arguments)})},{key:"setupDashboardCustomization",value:function(){var t,e=this,n=document.getElementById("toggle-dashboard-lock-btn");if(n){var a="false"!==this.settings.dashboard_locked;this.app.dashboardLocked=a,this.gridColumns=parseInt(null===(t=this.app.settings)||void 0===t?void 0:t.dashboard_grid_columns)||3,this.updateDashboardLockUI(),n.addEventListener("click",function(){return e.toggleDashboardLock()});var r=document.getElementById("add-tiles-btn"),i=document.getElementById("add-tiles-menu");r&&i&&(r.addEventListener("click",function(t){t.stopPropagation();var e="none"!==i.style.display;i.style.display=e?"none":"block"}),document.addEventListener("click",function(t){r.contains(t.target)||i.contains(t.target)||(i.style.display="none")})),this.setupColumnPicker(),this.setupAccountsTileConfig()}}},{key:"setupColumnPicker",value:function(){var t=this,e=document.getElementById("dashboard-columns-picker");e&&e.querySelectorAll(".columns-btn").forEach(function(n){n.classList.toggle("active",parseInt(n.dataset.cols)===t.gridColumns),n.onclick=function(){var a=parseInt(n.dataset.cols);t.gridColumns=a,e.querySelectorAll(".columns-btn").forEach(function(t){return t.classList.remove("active")}),n.classList.add("active"),t._saveSettings({dashboard_grid_columns:a.toString()}),t.gridstack&&t._applyResponsiveColumns(),requestAnimationFrame(function(){return t.resizeAllCharts()})}})}},{key:"_tilesDraggable",value:function(){var t,e;return!(this.dashboardLocked||null!==(t=(e=window).matchMedia)&&void 0!==t&&t.call(e,"(hover: none)").matches)}},{key:"toggleDashboardLock",value:(n=Zt(zt().m(function t(){var e;return zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return this.app.dashboardLocked=!this.app.dashboardLocked,this.updateDashboardLockUI(),this.gridstack&&(this._tilesDraggable()?this.gridstack.enable():this.gridstack.disable()),this._tilesDraggable()?this.setupHeroDragAndDrop():this.teardownHeroDragAndDrop(),t.p=1,t.n=2,this._saveSettings({dashboard_locked:this.app.dashboardLocked.toString()});case 2:t.n=4;break;case 3:t.p=3,e=t.v,console.error("Failed to save lock state:",e),(0,c.Qg)((0,i.Tl)("budget","Failed to save dashboard lock state"));case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return n.apply(this,arguments)})},{key:"updateDashboardLockUI",value:function(){var t,e=document.getElementById("toggle-dashboard-lock-btn"),n=document.getElementById("lock-btn-text"),a=document.getElementById("dashboard-hint"),r=document.getElementById("lock-btn-icon"),o=document.getElementById("add-tiles-dropdown");if(e&&n&&a){null===(t=document.getElementById("dashboard-view"))||void 0===t||t.classList.toggle("dashboard-locked",!!this.dashboardLocked),a.style.display=this.dashboardLocked?"none":"",n.classList.toggle("visually-hidden",!!this.dashboardLocked);var s=this.dashboardLocked?(0,i.Tl)("budget","Unlock Dashboard"):(0,i.Tl)("budget","Lock Dashboard");e.setAttribute("aria-label",s),e.title=s;var c=document.getElementById("dashboard-columns-picker");if(this.dashboardLocked){n.textContent=(0,i.Tl)("budget","Unlock Dashboard"),a.querySelector("span:last-child").textContent=(0,i.Tl)("budget","Dashboard is locked. Click unlock to reorder tiles."),r&&(r.innerHTML=''),o&&(o.style.display="none"),c&&(c.style.display="none"),document.querySelectorAll(".tile-settings-btn").forEach(function(t){return t.style.display="none"});var l=document.getElementById("tile-settings-modal");l&&(l.style.display="none"),document.querySelectorAll(".widget-tile-controls").forEach(function(t){return t.remove()}),document.querySelectorAll(".card-select, .card-header-controls .period-selector").forEach(function(t){return t.style.display="none"})}else{var u,d;n.textContent=(0,i.Tl)("budget","Lock Dashboard"),a.querySelector("span:last-child").textContent=null!==(u=(d=window).matchMedia)&&void 0!==u&&u.call(d,"(hover: none)").matches?(0,i.Tl)("budget","Use the arrows on each tile to reorder your dashboard"):(0,i.Tl)("budget","Drag tiles to reorder your dashboard"),r&&(r.innerHTML=''),o&&(o.style.display="block"),c&&(c.style.display="flex"),document.querySelectorAll(".tile-settings-btn").forEach(function(t){return t.style.display=""}),document.querySelectorAll(".card-select, .card-header-controls .period-selector").forEach(function(t){return t.style.display="none"}),this.addTileControls()}this.updateAddTilesMenu(),this._compactEmptyTiles()}}},{key:"addTileControls",value:function(){var t=this;document.querySelectorAll(".widget-tile-controls").forEach(function(t){return t.remove()});var e=function(e,n){var a=e.dataset.widgetId;if(a){var r=document.createElement("div");r.className="widget-tile-controls";var o=t.findWidgetDef(a),s=null==o?void 0:o.allowedSizes;if(s&&s.length>1){var c="hero"===n?"hero":"widgets",l=t.getWidgetSize(a,c),u=document.createElement("div");u.className="tile-size-picker",s.forEach(function(n){var r=document.createElement("button");r.className="size-btn ".concat(n===l?"active":""),r.dataset.size=n,r.textContent=n.toUpperCase(),r.title={xs:(0,i.Tl)("budget","Extra small"),s:(0,i.Tl)("budget","Small"),m:(0,i.Tl)("budget","Medium"),l:(0,i.Tl)("budget","Large")}[n],r.setAttribute("aria-label",r.title),r.setAttribute("aria-pressed",n===l?"true":"false"),r.onclick=function(i){i.stopPropagation(),t.changeTileSize(a,n,e),u.querySelectorAll(".size-btn").forEach(function(t){t.classList.remove("active"),t.setAttribute("aria-pressed","false")}),r.classList.add("active"),r.setAttribute("aria-pressed","true")},u.appendChild(r)}),r.appendChild(u);var d=document.createElement("div");d.className="tile-controls-divider",r.appendChild(d)}[[-1,(0,i.Tl)("budget","Move earlier"),"←"],[1,(0,i.Tl)("budget","Move later"),"→"]].forEach(function(a){var i=Nt(a,3),o=i[0],s=i[1],c=i[2],l=document.createElement("button");l.type="button",l.className="tile-move-btn",l.dataset.direction=String(o),l.textContent=c,l.title=s,l.setAttribute("aria-label",s),l.onclick=function(a){a.stopPropagation(),"hero"===n?t.moveHeroTile(e,o):t.moveGridTile(e,o),l.focus()},r.appendChild(l)});var h=document.createElement("div");if(h.className="tile-controls-divider",r.appendChild(h),"hero"!==n){var g=document.createElement("button");g.className="tile-gear-btn",g.innerHTML='',g.title=(0,i.Tl)("budget","Tile Settings"),g.setAttribute("aria-label",g.title),g.onclick=function(e){e.stopPropagation(),t.openTileSettingsModal(a,n)},r.appendChild(g);var p=document.createElement("div");p.className="tile-controls-divider",r.appendChild(p)}var f=document.createElement("button");f.className="widget-remove-btn",f.innerHTML="×",f.title=t.isDuplicateInstance(a)?(0,i.Tl)("budget","Remove tile"):(0,i.Tl)("budget","Hide tile"),f.setAttribute("aria-label",f.title),f.onclick=function(e){e.stopPropagation(),t.isDuplicateInstance(a)?t.removeWidgetInstance(a):t.hideWidget(a,"widget"===n?"widgets":"hero")},r.appendChild(f),e.style.position="relative",e.prepend(r)}};document.querySelectorAll(".hero-card").forEach(function(t){return e(t,"hero")}),document.querySelectorAll(".dashboard-card").forEach(function(t){return e(t,"widget")})}},{key:"findWidgetDef",value:function(t){for(var e=this.getWidgetType(t),n=0,a=["hero","widgets"];n'.concat((0,i.Tl)("budget","All Accounts"),"");this.accounts&&this.accounts.forEach(function(t){x+='")}),y.push('\n
\n \n \n
\n "))}if(l.excludeShared&&Array.isArray(this.accounts)&&this.accounts.some(function(t){return t._shared})){var S=d.excludeShared||!1;y.push('\n
\n \n
\n "))}for(var C=0,I=[this._excludeSharedBillsField(l,d),this._showAllOverdueField(l,d)];C\n \n \n "))}if(l.topLevelOnly){var M=d.topLevelOnly||!1;y.push('\n
\n \n \n
\n "))}if(l.chartType&&Array.isArray(l.chartType)){var D=d.chartType||l.chartType[0],B=l.chartType.map(function(t){var e=t.charAt(0).toUpperCase()+t.slice(1);return'")}).join("");y.push('\n
\n \n \n
\n "))}if(l.rowCount){var L=d.rowCount||l.rowCount.default||5;y.push('\n
\n \n \n
\n '))}if(l.displayFormat&&Array.isArray(l.displayFormat)){var P=d.displayFormat||l.displayFormat[0],O=l.displayFormat.map(function(t){var e=t.charAt(0).toUpperCase()+t.slice(1);return'")}).join("");y.push('\n
\n \n \n
\n "))}if(l.showChangeIndicator){var F=!1!==d.showChangeIndicator;y.push('\n
\n \n
\n "))}var R=["accounts","budgetAlerts"].includes(t);if(f&&(y.length>0?f.innerHTML=y.join(""):R||(f.innerHTML='

'.concat((0,i.Tl)("budget","No settings available for this tile."),"

"))),"accounts"===t&&(m&&(m.innerHTML='

'.concat((0,i.Tl)("budget","Drag to reorder. Toggle visibility for each item."),"

")),this.renderAccountsTileConfigList()),"budgetAlerts"===t){if(m){var N=this.getBudgetAlertFilter().scope;m.innerHTML='\n
\n \n

').concat((0,i.Tl)("budget","Leaves out the budgets worked out from your bills and recurring income."),'

\n

').concat((0,i.Tl)("budget","Untick a category to stop it alerting, here and in notifications."),"

\n
\n ");var j=document.getElementById("budget-alerts-own-budgets-only");j&&(j.onchange=function(){a.saveBudgetAlertFilter({scope:j.checked?"manual":"all"})})}this.renderBudgetAlertsTileConfigList()}l.categoryPicker&&(m&&(m.innerHTML='\n
\n \n

').concat((0,i.Tl)("budget","Untick a category to leave it off this tile, along with its subcategories. Reports and totals still count it."),"

\n
\n ")),this.renderSpendingTileCategoryList(t)),r.querySelectorAll(".tile-setting-input").forEach(function(e){e.onchange=function(){a.saveTileSetting(t,u,e)}});var H=document.getElementById("tile-settings-close");H&&(H.onclick=function(){r.style.display="none",r.setAttribute("aria-hidden","true")}),r.style.display="",r.setAttribute("aria-hidden","false")}}},{key:"saveTileSetting",value:function(t,e,n){var a,r=n.dataset.setting;a="checkbox"===n.type?n.checked:"number"===n.type?parseInt(n.value)||0:n.value,this.dashboardConfig[e].tileSettings||(this.dashboardConfig[e].tileSettings={}),this.dashboardConfig[e].tileSettings[t]||(this.dashboardConfig[e].tileSettings[t]={}),this.dashboardConfig[e].tileSettings[t][r]=a,this.saveDashboardVisibility(),this.refreshTileAfterSettingsChange(t,e),"dateRange"===r?this.updateTilePeriodIndicators():"accountId"===r&&this.updateTileAccountIndicators()}},{key:"refreshTileAfterSettingsChange",value:function(t,e){var n=this,a=this.getWidgetType(t);if(Kt.includes(a))return this.refreshWidgetInstance(t);var r={upcomingBills:function(){var t;return null===(t=n.updateUpcomingBillsWidget)||void 0===t?void 0:t.call(n)},accounts:function(){return n.updateAccountsWidget(n._allDashboardAccounts)},budgetProgress:function(){return n.refreshBudgetProgressWidget(t)},topCategories:function(){return n.refreshTopCategoriesWidget(t)},budgetAlerts:function(){return n.refreshBudgetAlertsWidget()},savingsGoals:function(){var t;return null===(t=n.updateSavingsGoalsWidget)||void 0===t?void 0:t.call(n)},projects:function(){return n.loadProjectsWidget()},debtPayoff:function(){var t;return null===(t=n.updateDebtPayoffWidget)||void 0===t?void 0:t.call(n)},debtChart:function(){return n.renderDebtChartWidget()},debtProgress:function(){return n.renderDebtProgressWidget()},monthlyComparison:function(){return n.loadWidgetData("monthlyComparison",!0).then(function(){var t;return null===(t=n.updateMonthlyComparisonWidget)||void 0===t?void 0:t.call(n)})},largeTransactions:function(){return n.loadWidgetData("largeTransactions",!0).then(function(){var t;return null===(t=n.updateLargeTransactionsWidget)||void 0===t?void 0:t.call(n)})},pensionProjection:function(){var t;return null===(t=n.updatePensionProjectionWidget)||void 0===t?void 0:t.call(n)},weeklyTrend:function(){return n.loadWidgetData("weeklyTrend",!0).then(function(){var t;return null===(t=n.updateWeeklyTrendWidget)||void 0===t?void 0:t.call(n)})},categoryTrends:function(){return n.loadWidgetData("categoryTrends",!0).then(function(){var t;return null===(t=n.updateCategoryTrendsWidget)||void 0===t?void 0:t.call(n)})},billsDueSoon:function(){var t;return null===(t=n.updateBillsDueSoonWidget)||void 0===t?void 0:t.call(n)},incomeTracking:function(){return n.loadWidgetData("incomeTracking",!0).then(function(){var t;return null===(t=n.updateIncomeTrackingWidget)||void 0===t?void 0:t.call(n)})},cashFlowForecast:function(){return n.loadWidgetData("cashFlowForecast",!0).then(function(){var t;return null===(t=n.updateCashFlowForecastWidget)||void 0===t?void 0:t.call(n)})},yoyComparison:function(){return n.loadWidgetData("yoyComparison",!0).then(function(){var t;return null===(t=n.updateYoyComparisonWidget)||void 0===t?void 0:t.call(n)})},accountIncome:function(){var t;return null===(t=n.updateAccountIncomeHero)||void 0===t?void 0:t.call(n)},accountExpenses:function(){var t;return null===(t=n.updateAccountExpensesHero)||void 0===t?void 0:t.call(n)}}[t];if(r)try{r()}catch(e){console.error("Failed to refresh tile",t,e)}}},{key:"aggregateToTopLevel",value:function(t){if(!t||!Array.isArray(t)||0===t.length)return t;var e,n=this.app.categories||[],a={},r={},i=Ot(n);try{for(i.s();!(e=i.n()).done;){var o=e.value;a[o.id]=o}}catch(t){i.e(t)}finally{i.f()}var s,c=function(t){if(void 0!==r[t])return r[t];var e=a[t];return e&&e.parentId?(r[t]=c(e.parentId),r[t]):(r[t]=t,t)},l={},u=Ot(t);try{for(u.s();!(s=u.n()).done;){var d=s.value,h=d.id||d.categoryId,g=c(h),p=a[g];l[g]||(l[g]=Wt(Wt({},d),{},{id:g,categoryId:g,name:(null==p?void 0:p.name)||d.categoryName||d.name,categoryName:(null==p?void 0:p.name)||d.categoryName||d.name,color:(null==p?void 0:p.color)||d.color,total:0,amount:0,count:0,budgeted:0,budget:0,spent:0,carried:0})),l[g].total+=Math.abs(parseFloat(d.total||d.amount||0)),l[g].amount+=Math.abs(parseFloat(d.total||d.amount||0)),l[g].count+=parseInt(d.count||1),l[g].budgeted+=parseFloat(d.budgeted||d.budget||0),l[g].budget+=parseFloat(d.budgeted||d.budget||0),l[g].spent+=parseFloat(d.spent||0),l[g].carried+=parseFloat(d.carried||0)}}catch(t){u.e(t)}finally{u.f()}return Object.values(l)}},{key:"resizeAllCharts",value:function(){var t=this;Object.keys(this.charts||{}).forEach(function(e){var n=t.charts[e];if(n&&"function"==typeof n.resize&&n.canvas&&n.canvas.isConnected)try{n.resize()}catch(t){console.warn("Chart resize failed for ".concat(e,":"),t)}})}},{key:"updateAddTilesMenu",value:function(){var t=this,e=document.getElementById("add-tiles-menu-list");if(e){e.innerHTML="";var n={};if(Object.entries(nt.hero).forEach(function(e){var a=Nt(e,2),r=a[0],i=a[1];if(!t.dashboardConfig.hero.visibility[r]){var o=i.category||"other";n[o]||(n[o]=[]),n[o].push({key:r,name:i.name,type:"hero",size:"hero"})}}),Object.entries(nt.widgets).forEach(function(e){var a=Nt(e,2),r=a[0],i=a[1];if(!t.dashboardConfig.widgets.visibility[r]){var o=i.category||"other";n[o]||(n[o]=[]),n[o].push({key:r,name:i.name,type:"widget",size:i.defaultSize})}}),0!==Object.values(n).reduce(function(t,e){return t+e.length},0)){[{key:"insights",label:(0,i.Tl)("budget","Insights & Analytics")},{key:"budgeting",label:(0,i.Tl)("budget","Budgeting")},{key:"forecasting",label:(0,i.Tl)("budget","Forecasting")},{key:"transactions",label:(0,i.Tl)("budget","Transactions")},{key:"income",label:(0,i.Tl)("budget","Income")},{key:"debts",label:(0,i.Tl)("budget","Debts")},{key:"goals",label:(0,i.Tl)("budget","Goals")},{key:"bills",label:(0,i.Tl)("budget","Bills")},{key:"alerts",label:(0,i.Tl)("budget","Alerts")},{key:"interactive",label:(0,i.Tl)("budget","Interactive")},{key:"other",label:(0,i.Tl)("budget","Other")}].forEach(function(t){var a=t.key,r=t.label,o=n[a];if(o&&0!==o.length){var s=document.createElement("div");s.className="add-tiles-category-header",s.textContent=r,e.appendChild(s),o.forEach(function(t){var n=document.createElement("div");n.className="add-tiles-menu-item";var a="hero"===t.size?''.concat((0,i.Tl)("budget","Hero"),""):"";n.innerHTML='\n \n '.concat(t.name,"\n ").concat(a,'\n \n \n '),e.appendChild(n)})}});var a=[];if(Kt.forEach(function(e){if(!1!==t.dashboardConfig.widgets.visibility[e]&&t.countInstances(e)<5){var n=nt.widgets[e];n&&a.push({key:e,name:n.name})}}),a.length>0){var r=document.createElement("div");r.className="add-tiles-category-header",r.textContent=(0,i.Tl)("budget","Add Another"),e.appendChild(r),a.forEach(function(n){var a=document.createElement("div");a.className="add-tiles-menu-item",a.innerHTML='\n \n '.concat(n.name,'\n ').concat(t.countInstances(n.key),"/").concat(5,'\n \n \n '),e.appendChild(a)})}e.querySelectorAll(".add-tile-btn:not(.add-another-btn)").forEach(function(e){e.addEventListener("click",function(n){n.stopPropagation();var a=e.dataset.widgetId,r=e.dataset.category;t.showWidget(a,r)})}),e.querySelectorAll(".add-another-btn").forEach(function(e){e.addEventListener("click",function(n){n.stopPropagation(),t.addWidgetInstance(e.dataset.widgetType)})})}else e.innerHTML='
'.concat((0,i.Tl)("budget","All tiles are visible"),"
")}}},{key:"createSavedInstances",value:function(){var t,e=(null===(t=this.dashboardConfig.widgets)||void 0===t?void 0:t.instances)||{},n=document.querySelector(".dashboard-grid");if(n)for(var a=0,r=Object.entries(e);a=5)){t.n=2;break}return(0,c.Qg)((0,i.Tl)("budget","Maximum of {max} instances reached",{max:5})),t.a(2);case 2:if(a=this.generateInstanceId(e),this.dashboardConfig.widgets.instances||(this.dashboardConfig.widgets.instances={}),this.dashboardConfig.widgets.instances[a]=e,this.dashboardConfig.widgets.visibility[a]=!0,r=(null===(n=nt.widgets[e])||void 0===n?void 0:n.defaultSize)||"m",this.dashboardConfig.widgets.sizes||(this.dashboardConfig.widgets.sizes={}),this.dashboardConfig.widgets.sizes[a]=r,this.dashboardConfig.widgets.order||(this.dashboardConfig.widgets.order=[]),this.dashboardConfig.widgets.order.push(a),o=this.createWidgetDOM(a)){t.n=3;break}return t.a(2);case 3:if(s=document.querySelector(".dashboard-grid")){t.n=4;break}return t.a(2);case 4:return this.gridstack?(l=$t[r]||{w:2,h:4},u="l"===r?this.gridColumns||3:l.w,(d=document.createElement("div")).className="grid-stack-item",d.setAttribute("gs-id",a),d.setAttribute("gs-w",u),d.setAttribute("gs-h",l.h),d.setAttribute("gs-auto-position","true"),(h=document.createElement("div")).className="grid-stack-item-content",h.appendChild(o),d.appendChild(h),s.appendChild(d),this.gridstack.makeWidget(d)):s.appendChild(o),this._saveGridstackPositions(),this.saveDashboardVisibility("widgets"),this.dashboardLocked||this.addTileControls(),t.n=5,this.refreshWidgetInstance(a);case 5:this.updateTilePeriodIndicators(),this.updateTileAccountIndicators(),this.updateAddTilesMenu(),(0,c.Te)((0,i.Tl)("budget","Tile added"));case 6:return t.a(2)}},t,this)})),function(e){return t.apply(this,arguments)})},{key:"removeWidgetInstance",value:function(t){var e,n,a,r,o,s;if(this.isDuplicateInstance(t)){if(this.gridstack){var l=document.querySelector('.grid-stack-item[gs-id="'.concat(t,'"]'));l&&this.gridstack.removeWidget(l)}else{var u=this.getWidgetCard(t);u&&u.remove()}this.charts[t]&&(this.charts[t].destroy(),delete this.charts[t]),null===(e=this.dashboardConfig.widgets.instances)||void 0===e||delete e[t],null===(n=this.dashboardConfig.widgets.visibility)||void 0===n||delete n[t],null===(a=this.dashboardConfig.widgets.sizes)||void 0===a||delete a[t],null===(r=this.dashboardConfig.widgets.positions)||void 0===r||delete r[t],null===(o=this.dashboardConfig.widgets.tileSettings)||void 0===o||delete o[t];var d=null===(s=this.dashboardConfig.widgets.order)||void 0===s?void 0:s.indexOf(t);d>-1&&this.dashboardConfig.widgets.order.splice(d,1),this.saveDashboardVisibility("widgets"),this.updateAddTilesMenu(),(0,c.Te)((0,i.Tl)("budget","Tile removed"))}else this.hideWidget(t,"widgets")}}]);var t,e,n,a,l,u,d,h,p,f,m,v,y,b,w,k,E,x,S,C,I,A,_,M,D,B,L,P,O}(),ee=n(933),ne=n(475),ae=n(400),re=n(707);function ie(t,e){return(t||[]).filter(function(t){return!t._shared&&null!=t.accountId&&Number(t.accountId)===Number(null==e?void 0:e.accountId)})}function oe(t){return"one-time"===t.frequency?t.startDate||t.nextDueDate||null:!1===t.isActive?null:t.nextDueDate||null}function se(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return new Promise(function(a){var r=document.getElementById("bill-link-modal");r&&r.remove();var c=(t||[]).map(function(t){return{bill:t,due:oe(t),exact:null!=n&&(e=t.amount,a=n.amount,r=(0,ae.F)(e),i=(0,ae.F)(a),Number.isFinite(r)&&Number.isFinite(i)&&Math.abs(r)===Math.abs(i))};var e,a,r,i}),l=function(t){return t.due||t.bill.lastPaidDate||"9999-12-31"};c.sort(function(t,e){var n,a;return Number(e.exact)-Number(t.exact)||String(null!==(n=t.bill.name)&&void 0!==n?n:"").localeCompare(String(null!==(a=e.bill.name)&&void 0!==a?a:""))||l(t).localeCompare(l(e))||Number(t.bill.id)-Number(e.bill.id)});var u=c.map(function(t){var n=t.bill,a=t.due,r=t.exact,c=n.currency||(null==e?void 0:e.default_currency)||"",l=[a?(0,i.Tl)("budget","Due {date}",{date:o.Yq(a,e)}):null,n.lastPaidDate?(0,i.Tl)("budget","Paid {date}",{date:o.Yq(n.lastPaidDate,e)}):null,!1===n.isActive?(0,i.Tl)("budget","Inactive"):null].filter(Boolean).join(" · ");return'\n \n ")}).join(""),d=c.length>0?'

'.concat((0,i.Tl)("budget","Choose the bill this transaction paid. It then counts as one of the bill's payments, in the Bills Calendar too. The bill's due date doesn't change."),'

\n
').concat(u,"
"):'

'.concat((0,i.Tl)("budget","There are no bills on this account yet. Add the bill first, then link this payment to it."),"

"),h=document.createElement("div");h.id="bill-link-modal",h.className="budget-modal-overlay",h.innerHTML='\n \n "),document.body.appendChild(h);var g=Date.now();(0,re.oZ)(h,".matching-tx-option",g),(0,re.ou)(h,g);var p=function(t){document.removeEventListener("keydown",f,!0),h.remove(),a(t)},f=function(t){"Escape"===t.key&&document.body.contains(h)&&(t.preventDefault(),t.stopPropagation(),p(null))};document.addEventListener("keydown",f,!0),h.querySelector(".close-btn").addEventListener("click",function(){return p(null)}),h.querySelector(".cancel-btn").addEventListener("click",function(){return p(null)}),h.addEventListener("click",function(t){t.target!==h||(0,re.rV)(t,g)||p(null)});var m=h.querySelector(".confirm-btn");m&&(h.addEventListener("change",function(t){"bill-link-choice"===t.target.name&&(m.disabled=!1)}),m.addEventListener("click",function(){var t=h.querySelector('input[name="bill-link-choice"]:checked');t&&p(parseInt(t.value,10))})),(h.querySelector('input[name="bill-link-choice"]')||h.querySelector(".cancel-btn")).focus()})}function ce(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);ni&&o>i;t.classList.toggle("cell-popup--above",s),t.style.top="".concat(s?Math.max(8,n.top-a):n.bottom,"px"),t.style.left="".concat(Math.max(8,Math.min(n.left,window.innerWidth-8-r)),"px")}function ue(t,e){var n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).onHidden,a=void 0===n?null:n;t.classList.add("cell-popup");var r=!1,i=function(){return!t.isConnected||r?(window.removeEventListener("scroll",i,!0),void window.removeEventListener("resize",i)):a&&function(t){var e=t.closest(".table-scroll");if(!e)return!1;var n=e.getBoundingClientRect();if(!n.height||!n.width)return!1;var a=n.top,r=function(t){return function(t){if(Array.isArray(t))return ce(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return ce(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ce(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e.querySelectorAll("thead th")).find(function(t){return t.getBoundingClientRect().height>0});if(r){var i=r.getBoundingClientRect();i.top>=n.top-1&&i.bottom>a&&(a=i.bottom)}var o=t.getBoundingClientRect();return o.bottom<=a||o.top>=n.bottom||o.right<=n.left||o.left>=n.right}(e)?(r=!0,t.style.display="none",void a()):void("none"!==t.style.display&&le(t,e))};return window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),function(){return le(t,e)}}function de(t,e,n){return{name:t,groupName:n,priority:1,active:!0,applyOnImport:!1,schemaVersion:2,criteria:{version:2,root:{operator:"AND",conditions:[{type:"condition",field:"description",matchType:"equals",pattern:t}]}},actions:{version:2,stopProcessing:!0,actions:[{type:"set_category",value:Number(e)}]},stopProcessing:!0}}function he(t,e){var n=String(e).toLowerCase();return(t||[]).find(function(t){var e,a;if(2!==t.schemaVersion||!1!==t.applyOnImport)return!1;var r=null===(e=t.criteria)||void 0===e||null===(e=e.root)||void 0===e?void 0:e.conditions;if(!Array.isArray(r)||1!==r.length)return!1;var i=r[0];return"description"===i.field&&"equals"===i.matchType&&String(null!==(a=i.pattern)&&void 0!==a?a:"").toLowerCase()===n})||null}var ge=n(421),pe=n(328);function fe(t){return fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fe(t)}function me(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Ie(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var a=0,r=function(){};return{s:r,n:function(){return a>=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function ve(t){return function(t){if(Array.isArray(t))return Ae(t)}(t)||_e(t)||Ie(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ye(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function be(t){for(var e=1;e3?(r=p===a)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),s=u,c=p;(e=s<2?t:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),g(s,c)):h.n=c:h.v=c);try{if(l=2,i){if(s||(r="next"),e=i[r]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=t}else if((e=(d=h.n<0)?c:n.call(a,h))!==o)break}catch(e){i=t,s=1,c=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),l}var o={};function s(){}function c(){}function l(){}e=Object.getPrototypeOf;var u=[][a]?e(e([][a]())):(ke(e={},a,function(){return this}),e),d=l.prototype=s.prototype=Object.create(u);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,ke(t,r,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,ke(d,"constructor",l),ke(l,"constructor",c),c.displayName="GeneratorFunction",ke(l,r,"GeneratorFunction"),ke(d),ke(d,r,"Generator"),ke(d,a,function(){return this}),ke(d,"toString",function(){return"[object Generator]"}),(Te=function(){return{w:i,m:h}})()}function ke(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}ke=function(t,e,n,a){function i(e,n){ke(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},ke(t,e,n,a)}function Ee(t,e){return Me(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,r,i,o,s=[],c=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(s.push(a.value),s.length!==e);c=!0);}catch(t){l=!0,r=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||Ie(t,e)||Ce()}function xe(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function Se(t){return function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){xe(i,a,r,o,s,"next",t)}function s(t){xe(i,a,r,o,s,"throw",t)}o(void 0)})}}function Ce(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ie(t,e){if(t){if("string"==typeof t)return Ae(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ae(t,e):void 0}}function Ae(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n1&&(t.app.currentPage--,t.app.loadTransactions())});var k=document.getElementById("next-page-btn");k&&k.addEventListener("click",function(){t.app.currentPage++,t.app.loadTransactions()});var E=document.getElementById("prev-page-btn-bottom");E&&E.addEventListener("click",function(){t.app.currentPage>1&&(t.app.currentPage--,t.app.loadTransactions())});var x=document.getElementById("next-page-btn-bottom");x&&x.addEventListener("click",function(){t.app.currentPage++,t.app.loadTransactions()}),document.addEventListener("click",function(e){var n=e.target.closest("#transactions-table th.sortable");n&&t.sortTransactions(n.getAttribute("data-sort")),"select-all-transactions"===e.target.id&&t.toggleAllTransactionSelection(e.target.checked),e.target.classList.contains("transaction-checkbox")&&t.handleTransactionCheckbox(e.target)})}},{key:"handleTransactionCheckbox",value:function(t){var e=parseInt(t.getAttribute("data-transaction-id")),n=this.reconcileMode&&this.reconcileSession;if(n&&t.checked&&!this.isReconcileTickable(e))return t.checked=!1,void(0,c.I9)((0,i.Tl)("budget","This transaction is scheduled, so it is not on a statement yet and cannot be ticked."));this.toggleTransactionSelection(e,t.checked),n&&this.queueReconcileTick(e,t.checked)}},{key:"isReconcileTickable",value:function(t){var e,n,a=null===(e=this.app.transactions)||void 0===e?void 0:e.find(function(e){return e.id===t});return"scheduled"!==(null!==(n=null==a?void 0:a.status)&&void 0!==n?n:"cleared")}},{key:"toggleFiltersPanel",value:function(){var t=document.getElementById("transactions-filters"),e=document.getElementById("toggle-filters-btn");"none"===t.style.display?(t.style.display="block",e.classList.add("active"),this.populateFilterDropdowns()):(t.style.display="none",e.classList.remove("active"))}},{key:"refreshFilterTags",value:function(){var t=this,e=document.getElementById("transactions-filters");e&&"none"!==e.style.display&&this.loadFilterTags().then(function(){return t.populateFilterTagsDropdown()})}},{key:"syncFilterControlsFromState",value:function(){var t=this.app.transactionFilters||{};this.selectedFilterTags=new Set(t.tagIds||[]);var e=document.getElementById("transactions-filters");if(e&&"none"!==e.style.display){var n=function(t,e){var n=document.getElementById(t);n&&(n._flatpickr?e?n._flatpickr.setDate(e,!1):n._flatpickr.clear(!1):n.value=e||"")};n("filter-account",t.account),this.syncCategoryFilterControl(t.category),n("filter-type",t.type),n("filter-status",t.status),n("filter-reconciled",t.reconciled),n("filter-date-from",t.dateFrom),n("filter-date-to",t.dateTo),n("filter-created-from",t.createdAtFrom),n("filter-created-to",t.createdAtTo),n("filter-amount-min",t.amountMin),n("filter-amount-max",t.amountMax),n("filter-search",t.search)}}},{key:"syncCategoryFilterControl",value:function(t){var e=document.getElementById("filter-category");if(e){var n=e.querySelector("option[data-synthetic-category]");n&&n.remove();var a=t?String(t).split(","):[];if(a.length<=1)e.value=t||"";else{var r=function(t){return Me(t)||_e(t)||Ie(t)||Ce()}(a),o=r[0],s=r.slice(1),c=(this.app.categories||[]).find(function(t){return String(t.id)===String(o)}),l=c?c.name:o,u=document.createElement("option");u.value=String(t),u.dataset.syntheticCategory="true",u.textContent=(0,i.zw)("budget","{category} + {count} subcategory","{category} + {count} subcategories",s.length,{category:l,count:s.length});var d=Array.from(e.options).find(function(t){return t.value===String(o)});d?d.after(u):e.insertBefore(u,e.firstChild),e.value=String(t)}}}},{key:"populateFilterDropdowns",value:function(){var t=this,e=document.getElementById("filter-account");e&&this.accounts&&(e.innerHTML='")+this.accounts.map(function(t){return'")}).join(""));var n=document.getElementById("filter-category");n&&this.categories&&(n.innerHTML='"),s.Vb(n,this.categoryTree||this.categories)),this.syncFilterControlsFromState();var a=document.getElementById("reconcile-account");a&&this.accounts&&(a.innerHTML='"),(0,k.HB)(this.accounts).forEach(function(t){a.innerHTML+='")})),this.loadFilterTags().then(function(){return t.populateFilterTagsDropdown()})}},{key:"loadFilterTags",value:(pt=Se(Te().m(function t(){var e,n,a,r,o;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,Promise.all([(0,T.n)("/apps/budget/api/tag-sets").catch(function(){return null}),(0,T.n)("/apps/budget/api/tags/global").catch(function(){return null})]);case 1:e=t.v,n=Ee(e,2),a=n[0],r=n[1],a&&(this.allFilterTagSets=a),r&&r.length>0&&(this.allFilterTagSets=this.allFilterTagSets||[],this.allFilterTagSets.unshift({id:"global",name:(0,i.Tl)("budget","Tags"),tags:r})),t.n=3;break;case 2:t.p=2,o=t.v,console.error("Failed to load tags for filter:",o);case 3:return t.a(2)}},t,this,[[0,2]])})),function(){return pt.apply(this,arguments)})},{key:"populateFilterTagsDropdown",value:function(){var t=this,e=document.getElementById("filter-tags");if(e)if(e.innerHTML="",this.allFilterTagSets&&0!==this.allFilterTagSets.length){var n=document.createElement("div");n.className="filter-tags-chips";var a=document.createElement("input");a.type="text",a.id="filter-tags-input",a.className="tags-autocomplete-input",a.placeholder=(0,i.Tl)("budget","Type to filter tags...");var r=document.createElement("div");r.className="tags-autocomplete-dropdown",r.style.display="none",e.appendChild(n),e.appendChild(a),e.appendChild(r);var o=function(){n.innerHTML="",0!==t.selectedFilterTags.size?(n.style.display="flex",t.selectedFilterTags.forEach(function(e){var r=c.find(function(t){return t.id===e});if(r){var i=document.createElement("span");i.className="filter-tag-chip",i.style.cssText="display: inline-flex; align-items: center; gap: 4px; background-color: ".concat(s.ZD(r.color||"#888"),"; color: white; padding: 2px 8px; border-radius: 10px; font-size: 11px; cursor: pointer;"),i.innerHTML="".concat(s.ZD(r.name),' ×'),i.addEventListener("click",function(){t.selectedFilterTags.delete(e),o(),l(a.value),t.updateFilters()}),n.appendChild(i)}})):n.style.display="none"},c=[];this.allFilterTagSets.forEach(function(t){t.tags&&t.tags.length>0&&t.tags.forEach(function(e){c.push({id:e.id,name:e.name,color:e.color,tagSetName:t.name,tagSetId:t.id})})});var l=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=e?c.filter(function(t){return t.name.toLowerCase().includes(e.toLowerCase())||t.tagSetName.toLowerCase().includes(e.toLowerCase())}):c,a={};n.forEach(function(t){a[t.tagSetId]||(a[t.tagSetId]={name:t.tagSetName,tags:[]}),a[t.tagSetId].tags.push(t)});var o="";Object.values(a).forEach(function(e){o+='
'.concat(s.ZD(e.name),"
"),e.tags.forEach(function(e){var n=t.selectedFilterTags.has(e.id);o+='\n
\n \n ').concat(s.ZD(e.name),'\n \n ').concat(n?"✓":"","\n
\n ")})}),r.innerHTML=o||'
'.concat((0,i.Tl)("budget","No tags found"),"
"),r.style.display="block"};a.addEventListener("focus",function(){return l(a.value)}),a.addEventListener("input",function(){return l(a.value)}),r.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation();var n=e.target.closest(".tags-autocomplete-item");if(n){var r=parseInt(n.dataset.tagId),i=c.find(function(t){return t.id===r});if(!i)return;c.filter(function(t){return t.tagSetId===i.tagSetId}).forEach(function(e){e.id!==r&&t.selectedFilterTags.delete(e.id)}),t.selectedFilterTags.has(r)?t.selectedFilterTags.delete(r):t.selectedFilterTags.add(r),o(),l(a.value),t.updateFilters()}}),r.addEventListener("click",function(t){t.stopPropagation()}),o(),document.addEventListener("click",function(t){e.contains(t.target)||(r.style.display="none")})}else e.innerHTML='
'.concat((0,i.Tl)("budget","No tags available"),"
")}},{key:"_maybeCheckReconcileSession",value:function(t){t&&String(t)!==this._lastReconCheckedAccount&&(this._lastReconCheckedAccount=String(t),this.checkActiveReconcileSession(parseInt(t)))}},{key:"resetAllMatchingSelectionOnFilterChange",value:function(){if(this.allMatchingSelection){this.allMatchingSelection=null,this.selectedTransactions.clear();var t=document.getElementById("select-all-transactions");t&&(t.checked=!1,t.indeterminate=!1),this.updateBulkActionsState()}}},{key:"updateFilters",value:function(){var t,e,n,a,r,i,o,s,c,l,u,d;this.resetAllMatchingSelectionOnFilterChange(),this.app.transactionFilters={account:(null===(t=document.getElementById("filter-account"))||void 0===t?void 0:t.value)||"",category:(null===(e=document.getElementById("filter-category"))||void 0===e?void 0:e.value)||"",type:(null===(n=document.getElementById("filter-type"))||void 0===n?void 0:n.value)||"",status:(null===(a=document.getElementById("filter-status"))||void 0===a?void 0:a.value)||"",reconciled:(null===(r=document.getElementById("filter-reconciled"))||void 0===r?void 0:r.value)||"",dateFrom:(null===(i=document.getElementById("filter-date-from"))||void 0===i?void 0:i.value)||"",dateTo:(null===(o=document.getElementById("filter-date-to"))||void 0===o?void 0:o.value)||"",createdAtFrom:(null===(s=document.getElementById("filter-created-from"))||void 0===s?void 0:s.value)||"",createdAtTo:(null===(c=document.getElementById("filter-created-to"))||void 0===c?void 0:c.value)||"",amountMin:(null===(l=document.getElementById("filter-amount-min"))||void 0===l?void 0:l.value)||"",amountMax:(null===(u=document.getElementById("filter-amount-max"))||void 0===u?void 0:u.value)||"",search:(null===(d=document.getElementById("filter-search"))||void 0===d?void 0:d.value)||"",tagIds:Array.from(this.selectedFilterTags)},this.app.currentPage=1,this.app.loadTransactions(),this._maybeCheckReconcileSession(this.app.transactionFilters.account)}},{key:"applySearchLink",value:function(t){this.app.transactionFilters=be(be({},this.app.transactionFilters||{}),{},{search:t}),this.app.currentPage=1;var e=document.getElementById("transactions-filters");"none"===(null==e?void 0:e.style.display)?this.toggleFiltersPanel():this.syncFilterControlsFromState()}},{key:"clearFilters",value:function(){this.resetAllMatchingSelectionOnFilterChange(),this.app.transactionFilters={},this.syncFilterControlsFromState(),this.app.currentPage=1,this.app.loadTransactions()}},{key:"sortTransactions",value:function(t){var e=this;this.app.currentSort.field===t?this.app.currentSort.direction="asc"===this.app.currentSort.direction?"desc":"asc":(this.app.currentSort.field=t,this.app.currentSort.direction="asc"),document.querySelectorAll("#transactions-table .sort-indicator").forEach(function(t){t.className="sort-indicator"});var n=document.querySelector('#transactions-table [data-sort="'.concat(t,'"] .sort-indicator'));n&&(n.className="sort-indicator ".concat(this.app.currentSort.direction)),document.querySelectorAll("#transactions-table th[data-sort]").forEach(function(n){n.setAttribute("aria-sort",n.dataset.sort===t?"asc"===e.app.currentSort.direction?"ascending":"descending":"none")}),this.app.loadTransactions()}},{key:"toggleBulkMode",value:function(){var t=document.getElementById("bulk-actions-panel"),e=document.getElementById("bulk-actions-btn");"none"===t.style.display?(t.style.display="block",e.classList.add("active")):this.cancelBulkMode()}},{key:"cancelBulkMode",value:function(){var t=document.getElementById("bulk-actions-panel"),e=document.getElementById("bulk-actions-btn");t.style.display="none",e.classList.remove("active"),this.selectedTransactions.clear(),this.allMatchingSelection=null,document.querySelectorAll(".transaction-checkbox:checked").forEach(function(t){t.checked=!1});var n=document.getElementById("select-all-transactions");n&&(n.checked=!1,n.indeterminate=!1),this.updateBulkActionsState(),this.refreshSelectAllBanner()}},{key:"toggleAllTransactionSelection",value:function(t){var e=this;if(this.allMatchingSelection=null,this.reconcileMode&&this.reconcileSession)return document.querySelectorAll(".transaction-checkbox").forEach(function(n){var a=parseInt(n.getAttribute("data-transaction-id"));t&&!e.isReconcileTickable(a)||(n.checked!==t&&(n.checked=t,e.queueReconcileTick(a,t)),t?e.selectedTransactions.add(a):e.selectedTransactions.delete(a))}),this.updateBulkActionsState(),void this.refreshSelectAllBanner();this.selectedTransactions.clear(),t?document.querySelectorAll(".transaction-checkbox").forEach(function(t){t.checked=!0;var n=parseInt(t.getAttribute("data-transaction-id"));e.selectedTransactions.add(n)}):document.querySelectorAll(".transaction-checkbox").forEach(function(t){t.checked=!1}),this.updateBulkActionsState(),this.refreshSelectAllBanner()}},{key:"toggleTransactionSelection",value:function(t,e){this.allMatchingSelection=null,e?this.selectedTransactions.add(t):this.selectedTransactions.delete(t);var n=document.getElementById("select-all-transactions"),a=document.querySelectorAll(".transaction-checkbox"),r=document.querySelectorAll(".transaction-checkbox:checked");n&&(n.checked=a.length===r.length&&a.length>0,n.indeterminate=r.length>0&&r.length0&&s>r&&o===r)return e.textContent=(0,i.zw)("budget","All %n transaction on this page is selected.","All %n transactions on this page are selected.",r),n.textContent=(0,i.Tl)("budget","Select all {total} matching transactions",{total:s}),void(t.style.display="flex");t.style.display="none"}}},{key:"updateBulkActionsState",value:function(){var t=this.selectedTransactions.size,e=document.getElementById("selected-count"),n=document.getElementById("bulk-actions-btn"),a=document.getElementById("bulk-delete-btn"),r=document.getElementById("bulk-reconcile-btn"),i=document.getElementById("bulk-unreconcile-btn"),o=document.getElementById("bulk-edit-btn"),s=document.getElementById("bulk-tags-btn");e&&(e.textContent=t);var c=0===t;n&&(n.disabled=c),a&&(a.disabled=c),r&&(r.disabled=c),i&&(i.disabled=c),o&&(o.disabled=c),s&&(s.disabled=c)}},{key:"bulkDeleteTransactions",value:(dt=Se(Te().m(function t(){var e,n,a,r,o,s=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(0!==this.selectedTransactions.size){t.n=1;break}return t.a(2);case 1:return e=this.transactions.filter(function(t){return s.selectedTransactions.has(t.id)}),n=this.allMatchingSelection?this.allMatchingSelection.billCount:e.filter(function(t){return t.billId}).length,a=(0,i.zw)("budget","Are you sure you want to delete %n transaction? This action cannot be undone.","Are you sure you want to delete %n transactions? This action cannot be undone.",this.selectedTransactions.size),n>0&&(a+="\n\n"+(0,i.zw)("budget","%n of these was auto-generated from bill payments. Deleting real payments will cause your balance to diverge from your bank statement.","%n of these were auto-generated from bill payments. Deleting real payments will cause your balance to diverge from your bank statement.",n)),t.n=2,(0,l.ZD)(a,{destructive:!0});case 2:if(t.v){t.n=3;break}return t.a(2);case 3:return t.p=3,t.n=4,(0,T.n)("/apps/budget/api/transactions/bulk-delete",{method:"POST",body:{ids:Array.from(this.selectedTransactions)}});case 4:(r=t.v).success>0&&((0,c.Te)((0,i.zw)("budget","Successfully deleted %n transaction","Successfully deleted %n transactions",r.success)),this.selectedTransactions.clear(),this.allMatchingSelection=null,this.app.currentPage=1,this.app.loadTransactions()),r.failed>0&&(0,c.Qg)((0,i.zw)("budget","Failed to delete %n transaction","Failed to delete %n transactions",r.failed)),t.n=6;break;case 5:t.p=5,o=t.v,console.error("Bulk deletion failed:",o),(0,c.Qg)((0,i.Tl)("budget","Failed to delete transactions"));case 6:return t.a(2)}},t,this,[[3,5]])})),function(){return dt.apply(this,arguments)})},{key:"bulkReconcileTransactions",value:(ut=Se(Te().m(function t(){var e,n;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(0!==this.selectedTransactions.size){t.n=1;break}return t.a(2);case 1:return t.n=2,(0,l.ZD)((0,i.zw)("budget","Are you sure you want to mark %n transaction as reconciled?","Are you sure you want to mark %n transactions as reconciled?",this.selectedTransactions.size));case 2:if(t.v){t.n=3;break}return t.a(2);case 3:return t.p=3,t.n=4,(0,T.n)("/apps/budget/api/transactions/bulk-reconcile",{method:"POST",body:{ids:Array.from(this.selectedTransactions),reconciled:!0}});case 4:(e=t.v).success>0&&((0,c.Te)((0,i.zw)("budget","Successfully reconciled %n transaction","Successfully reconciled %n transactions",e.success)),this.selectedTransactions.clear(),this.allMatchingSelection=null,this.app.currentPage=1,this.app.loadTransactions()),e.failed>0&&(0,c.Qg)((0,i.zw)("budget","Failed to reconcile %n transaction","Failed to reconcile %n transactions",e.failed)),t.n=6;break;case 5:t.p=5,n=t.v,console.error("Bulk reconcile failed:",n),(0,c.Qg)((0,i.Tl)("budget","Failed to reconcile transactions"));case 6:return t.a(2)}},t,this,[[3,5]])})),function(){return ut.apply(this,arguments)})},{key:"bulkUnreconcileTransactions",value:(lt=Se(Te().m(function t(){var e,n;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(0!==this.selectedTransactions.size){t.n=1;break}return t.a(2);case 1:return t.n=2,(0,l.ZD)((0,i.zw)("budget","Are you sure you want to mark %n transaction as unreconciled?","Are you sure you want to mark %n transactions as unreconciled?",this.selectedTransactions.size));case 2:if(t.v){t.n=3;break}return t.a(2);case 3:return t.p=3,t.n=4,(0,T.n)("/apps/budget/api/transactions/bulk-reconcile",{method:"POST",body:{ids:Array.from(this.selectedTransactions),reconciled:!1}});case 4:(e=t.v).success>0&&((0,c.Te)((0,i.zw)("budget","Successfully unreconciled %n transaction","Successfully unreconciled %n transactions",e.success)),this.selectedTransactions.clear(),this.allMatchingSelection=null,this.app.currentPage=1,this.app.loadTransactions()),e.failed>0&&(0,c.Qg)((0,i.zw)("budget","Failed to unreconcile %n transaction","Failed to unreconcile %n transactions",e.failed)),t.n=6;break;case 5:t.p=5,n=t.v,console.error("Bulk unreconcile failed:",n),(0,c.Qg)((0,i.Tl)("budget","Failed to unreconcile transactions"));case 6:return t.a(2)}},t,this,[[3,5]])})),function(){return lt.apply(this,arguments)})},{key:"showBulkEditModal",value:function(){var t=this;if(0!==this.selectedTransactions.size){var e=document.getElementById("bulk-edit-modal"),n=document.getElementById("bulk-edit-count"),a=document.getElementById("bulk-edit-category");if(n&&(n.textContent=this.selectedTransactions.size),a&&this.categories){a.innerHTML='")+'");var r=(this.transactions||[]).filter(function(e){return t.selectedTransactions.has(e.id)}).map(function(e){return(t.accounts||[]).find(function(t){return t.id===e.accountId})}),o=(0,k.hM)(this.categories,r);s.Vb(a,o?(0,k.QN)(o):this.categoryTree||this.categories)}document.getElementById("bulk-edit-vendor").value="",document.getElementById("bulk-edit-reference").value="",document.getElementById("bulk-edit-notes").value="",e.style.display="flex"}}},{key:"submitBulkEdit",value:(ct=Se(Te().m(function t(){var e,n,a,r,o,s,u;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.getElementById("bulk-edit-category").value,n=document.getElementById("bulk-edit-vendor").value.trim(),a=document.getElementById("bulk-edit-reference").value.trim(),r=document.getElementById("bulk-edit-notes").value.trim(),o={},"none"===e?o.categoryId=null:e&&(o.categoryId=parseInt(e)),n&&(o.vendor=n),a&&(o.reference=a),r&&(o.notes=r),0!==Object.keys(o).length){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Please fill in at least one field to update")),t.a(2);case 1:return t.n=2,(0,l.ZD)((0,i.zw)("budget","Are you sure you want to update %n transaction?","Are you sure you want to update %n transactions?",this.selectedTransactions.size));case 2:if(t.v){t.n=3;break}return t.a(2);case 3:return t.p=3,t.n=4,(0,T.n)("/apps/budget/api/transactions/bulk-edit",{method:"POST",body:{ids:Array.from(this.selectedTransactions),updates:o}});case 4:(s=t.v).success>0&&((0,c.Te)((0,i.zw)("budget","Successfully updated %n transaction","Successfully updated %n transactions",s.success)),this.selectedTransactions.clear(),this.allMatchingSelection=null,this.app.currentPage=1,this.app.loadTransactions(),document.getElementById("bulk-edit-modal").style.display="none"),s.failed>0&&(0,c.Qg)((0,i.zw)("budget","Failed to update %n transaction","Failed to update %n transactions",s.failed)),t.n=6;break;case 5:t.p=5,u=t.v,console.error("Bulk edit failed:",u),(0,c.Qg)((0,i.Tl)("budget","Failed to update transactions"));case 6:return t.a(2)}},t,this,[[3,5]])})),function(){return ct.apply(this,arguments)})},{key:"showBulkTagsModal",value:(st=Se(Te().m(function t(){var e,n,a,r,o,c,l,u,d,h,g,p,f,m,v,y=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(0!==this.selectedTransactions.size){t.n=1;break}return t.a(2);case 1:if(e=document.getElementById("bulk-tags-modal"),n=document.getElementById("bulk-tags-description"),a=document.getElementById("bulk-tags-add"),r=document.getElementById("bulk-tags-remove"),o=document.getElementById("bulk-tags-unaffected"),e&&a&&r){t.n=2;break}return t.a(2);case 2:return n&&(n.textContent=(0,i.zw)("budget","Add or remove tags on %n selected transaction. Tags you leave unchecked are not touched.","Add or remove tags on %n selected transactions. Tags you leave unchecked are not touched.",this.selectedTransactions.size)),c=''.concat((0,i.Tl)("budget","Loading..."),""),a.innerHTML=c,r.innerHTML=c,o&&(o.textContent=""),e.style.display="flex",l={totalSelected:0,globalTags:[],tagSets:[],unaffectedCount:0},t.p=3,t.n=4,(0,T.n)("/apps/budget/api/transactions/bulk-tag-options",{method:"POST",body:{ids:Array.from(this.selectedTransactions)}}).catch(function(){return null});case 4:(u=t.v)&&(l=u),t.n=6;break;case 5:t.p=5,v=t.v,console.error("Failed to load bulk tag options:",v);case 6:if(d=(0,ne.g)(l.globalTags||[]),h=(l.tagSets||[]).map(function(t){return be(be({},t),{},{tags:(0,ne.g)(t.tags||[])})}).filter(function(t){return t.tags.length>0}),this._bulkTagNames=new Map,[d].concat(ve(h.map(function(t){return t.tags}))).forEach(function(t){t.forEach(function(t){return y._bulkTagNames.set(t.id,t.name)})}),0!==d.length||0!==h.length){t.n=7;break}return g=''.concat((0,i.Tl)("budget","No tags available"),""),a.innerHTML=g,r.innerHTML=g,t.a(2);case 7:p=function(t,e,n,a){return'\n
\n \n
\n ').concat(n.map(function(t){return'\n \n ")}).join(""),"\n
\n
\n ")},f=function(t){var e="";return d.length>0&&(e+=p((0,i.Tl)("budget","Tags"),"",d,t)),h.forEach(function(n){var a="".concat(n.categoryName," → ").concat(n.name),r=(0,i.Tl)("budget","applies to {count} of {total}",{count:n.matchingCount,total:l.totalSelected});e+=p(a,r,n.tags,t)}),e},a.innerHTML=f("bulk-tag-add"),r.innerHTML=f("bulk-tag-remove"),o&&(o.textContent=l.unaffectedCount>0?(0,i.zw)("budget","%n selected transaction is in a category these tags do not cover.","%n selected transactions are in categories these tags do not cover.",l.unaffectedCount):""),(m=function(t,e){t.querySelectorAll('input[type="checkbox"]').forEach(function(t){t.addEventListener("change",function(){if(t.checked){var n=e.querySelector('input[value="'.concat(t.value,'"]'));n&&(n.checked=!1)}})})})(a,r),m(r,a);case 8:return t.a(2)}},t,this,[[3,5]])})),function(){return st.apply(this,arguments)})},{key:"submitBulkTags",value:(ot=Se(Te().m(function t(){var e,n,a,r,o,s;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=(e=function(t){return Array.from(document.querySelectorAll("#".concat(t,' input[type="checkbox"]:checked'))).map(function(t){return parseInt(t.value)})})("bulk-tags-add"),a=e("bulk-tags-remove"),0!==n.length||0!==a.length){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Please select at least one tag to add or remove")),t.a(2);case 1:return t.p=1,t.p=2,t.n=3,(0,T.n)("/apps/budget/api/transactions/bulk-tags",{method:"POST",body:{ids:Array.from(this.selectedTransactions),addTagIds:n,removeTagIds:a},errorMessage:(0,i.Tl)("budget","Failed to update tags")});case 3:r=t.v,t.n=6;break;case 4:if(t.p=4,(o=t.v)instanceof T.h){t.n=5;break}throw o;case 5:return(0,c.Qg)(o.message),t.a(2);case 6:r.success>0&&((0,c.Te)(this.bulkTagSummary(r)),this.selectedTransactions.clear(),this.allMatchingSelection=null,this.app.currentPage=1,this.app.loadTransactions(),document.getElementById("bulk-tags-modal").style.display="none"),r.failed>0&&(0,c.Qg)((0,i.zw)("budget","Failed to update tags on %n transaction","Failed to update tags on %n transactions",r.failed)),t.n=8;break;case 7:t.p=7,s=t.v,console.error("Bulk tag update failed:",s),(0,c.Qg)((0,i.Tl)("budget","Failed to update tags"));case 8:return t.a(2)}},t,this,[[2,4],[1,7]])})),function(){return ot.apply(this,arguments)})},{key:"bulkTagSummary",value:function(t){var e=(0,i.zw)("budget","Updated tags on %n transaction","Updated tags on %n transactions",t.success),n=this._bulkTagNames||new Map,a=Object.entries(t.applied||{}).filter(function(e){var a=Ee(e,2),r=a[0];return a[1]0?"".concat(e,". ").concat(a.join(" ")):e}},{key:"toggleReconcileMode",value:function(){var t=document.getElementById("reconcile-panel"),e=document.getElementById("reconcile-mode-btn");"none"===t.style.display?(t.style.display="block",e.classList.add("active"),this.populateFilterDropdowns()):(t.style.display="none",e.classList.remove("active"),this.reconcileMode=!1,this.app.loadTransactions())}},{key:"reconcileErrorMessage",value:function(t){return t instanceof T.h&&null===t.data?(0,i.Tl)("budget","Server error ({status}) — check the Nextcloud logs",{status:t.status}):t.message}},{key:"startReconciliation",value:(it=Se(Te().m(function t(){var e,n,a,r,o,s;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.getElementById("reconcile-account").value,n=document.getElementById("reconcile-statement-balance").value,a=document.getElementById("reconcile-statement-date").value,e&&n&&a){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Please fill in all reconciliation fields")),t.a(2);case 1:return t.p=1,t.p=2,t.n=3,(0,T.n)("/apps/budget/api/accounts/".concat(e,"/reconciliation/session"),{method:"POST",body:{statementBalance:parseFloat(n),statementDate:a},errorMessage:(0,i.Tl)("budget","Failed to start reconciliation")});case 3:r=t.v,t.n=8;break;case 4:if(t.p=4,(o=t.v)instanceof T.h&&409===o.status){t.n=5;break}throw o;case 5:return t.n=6,(0,l.ZD)((0,i.Tl)("budget","A reconciliation is already in progress for this account. Resume it?"));case 6:if(!t.v){t.n=7;break}return t.n=7,this.enterReconcileSession(o.data.existing);case 7:return t.a(2);case 8:return t.n=9,this.enterReconcileSession(r);case 9:t.n=11;break;case 10:t.p=10,s=t.v,console.error("Reconciliation failed:",s),(0,c.Qg)((0,i.Tl)("budget","Failed to start reconciliation: {message}",{message:this.reconcileErrorMessage(s)}));case 11:return t.a(2)}},t,this,[[2,4],[1,10]])})),function(){return it.apply(this,arguments)})},{key:"enterReconcileSession",value:(rt=Se(Te().m(function t(e){var n,a,r;return Te().w(function(t){for(;;)switch(t.n){case 0:this.reconcileMode=!0,this.reconcileSession=e,this._reconTickQueue=new Set,this._reconUntickQueue=new Set,this.allMatchingSelection=null,this.selectedTransactions=new Set(e.tickedIds||[]),(n=document.getElementById("filter-account"))&&(a=String(e.session.accountId),ve(n.options).some(function(t){return t.value===a})||this.populateFilterDropdowns(),n.value=a,(0,u.Mv)("filter-date-to",e.session.statementDate||""),(r=document.getElementById("filter-reconciled"))&&(r.value="no"),this.updateFilters()),document.getElementById("reconcile-panel").style.display="none",this.renderReconcileBar(),(0,c.Te)((0,i.Tl)("budget","Reconciliation started — tick the transactions on your statement"));case 1:return t.a(2)}},t,this)})),function(t){return rt.apply(this,arguments)})},{key:"renderReconcileBar",value:function(){var t,e,n=this,a=this.reconcileSession;if(a){var r=document.getElementById("reconcile-session-bar");r&&r.remove();var o=document.createElement("div");o.id="reconcile-session-bar",o.className="reconcile-session-bar";var s=a.difference||0,c=a.isBalanced,l=s>0?"credit":"debit",u=a.untickedCount||0;o.innerHTML='\n
\n
\n \n ").concat(this.formatCurrency(a.session.statementBalance),'\n
\n
\n \n ').concat(this.formatCurrency(a.session.startingBalance),'\n
\n
\n \n ").concat(this.formatCurrency(a.tickedSum||0),'\n
\n
\n \n ').concat(this.formatCurrency(s),'\n
\n
\n
\n \n ").concat(u>0?'"):"","\n ").concat(!c&&(a.tickedCount||0)>0?'"):"",'\n \n \n
\n "),document.body.appendChild(o),document.getElementById("finish-reconcile-btn").addEventListener("click",function(){return n.finishReconciliation()}),null===(t=document.getElementById("adjust-reconcile-btn"))||void 0===t||t.addEventListener("click",function(){return n.createReconciliationAdjustment(l,Math.abs(s))}),null===(e=document.getElementById("tick-all-reconcile-btn"))||void 0===e||e.addEventListener("click",function(){return n.tickAllUpToStatementDate()}),document.getElementById("leave-reconcile-btn").addEventListener("click",function(){return n.exitReconcileMode()}),document.getElementById("cancel-reconcile-session-btn").addEventListener("click",function(){return n.cancelReconcileSession()})}}},{key:"tickAllUpToStatementDate",value:(at=Se(Te().m(function t(){var e,n,a;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.reconcileSession){t.n=1;break}return t.a(2);case 1:return e=this.reconcileSession.session.accountId,t.p=2,t.n=3,(0,T.n)("/apps/budget/api/accounts/".concat(e,"/reconciliation/tick-all"),{method:"POST",errorMessage:(0,i.Tl)("budget","Failed to tick transactions")});case 3:return n=t.v,this.reconcileSession=n,this.selectedTransactions=new Set(n.tickedIds||[]),this._reconTickQueue.clear(),this._reconUntickQueue.clear(),this.renderReconcileBar(),t.n=4,this.app.loadTransactions();case 4:t.n=6;break;case 5:t.p=5,a=t.v,console.error("Tick all failed:",a),(0,c.Qg)((0,i.Tl)("budget","Failed to tick transactions: {message}",{message:this.reconcileErrorMessage(a)}));case 6:return t.a(2)}},t,this,[[2,5]])})),function(){return at.apply(this,arguments)})},{key:"queueReconcileTick",value:function(t,e){var n,a=this;if(this.reconcileSession){e?(this._reconUntickQueue.delete(t),this._reconTickQueue.add(t)):(this._reconTickQueue.delete(t),this._reconUntickQueue.add(t));var r=null===(n=this.app.transactions)||void 0===n?void 0:n.find(function(e){return e.id===t});if(r){var i=("credit"===r.type?1:-1)*parseFloat(r.amount)*(e?1:-1);this.reconcileSession.tickedSum=(this.reconcileSession.tickedSum||0)+i,this.reconcileSession.tickedCount=(this.reconcileSession.tickedCount||0)+(e?1:-1),this.reconcileSession.difference=this.reconcileSession.session.statementBalance-(this.reconcileSession.session.startingBalance+this.reconcileSession.tickedSum),this.reconcileSession.isBalanced=Math.abs(this.reconcileSession.difference)<.005,this.renderReconcileBar()}clearTimeout(this._reconFlushTimer),this._reconFlushTimer=setTimeout(function(){return a.flushReconcileTicks()},400)}}},{key:"flushReconcileTicks",value:(nt=Se(Te().m(function t(){var e,n,a,r,o,s,l,u,d,h;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.reconcileSession){t.n=1;break}return t.a(2);case 1:if(e=this.reconcileSession.session.accountId,n=Array.from(this._reconTickQueue),a=Array.from(this._reconUntickQueue),this._reconTickQueue.clear(),this._reconUntickQueue.clear(),0!==n.length||0!==a.length){t.n=2;break}return t.a(2);case 2:t.p=2,r=null,o=0,s=[[n,!0],[a,!1]];case 3:if(!(o".concat((0,i.Tl)("budget","A reconciliation is in progress for this account (statement of {date})",{date:this.formatDate(t.session.statementDate)}),'\n \n \n ");var r=document.querySelector("#transactions-view .table-container");r&&(r.parentNode.insertBefore(a,r),document.getElementById("resume-reconcile-btn").addEventListener("click",Se(Te().m(function n(){return Te().w(function(n){for(;;)switch(n.n){case 0:return a.remove(),n.n=1,e.enterReconcileSession(t);case 1:return n.a(2)}},n)}))),document.getElementById("dismiss-resume-banner-btn").addEventListener("click",function(){return a.remove()}))}},{key:"exitReconcileMode",value:function(){var t,e;this.reconcileMode=!1,this.reconcileSession=null,this.selectedTransactions=new Set,clearTimeout(this._reconFlushTimer),null===(t=document.getElementById("reconcile-session-bar"))||void 0===t||t.remove(),document.getElementById("reconcile-panel").style.display="none",null===(e=document.getElementById("reconcile-mode-btn"))||void 0===e||e.classList.remove("active");var n=document.getElementById("filter-date-to"),a=document.getElementById("filter-reconciled");if(n||a)return(0,u.Mv)("filter-date-to",""),a&&(a.value=""),void this.updateFilters();this.app.loadTransactions()}},{key:"cancelReconcileSession",value:(J=Se(Te().m(function t(){var e,n;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.reconcileSession){t.n=1;break}return t.a(2);case 1:return t.n=2,(0,l.ZD)((0,i.Tl)("budget","Cancel this reconciliation? Ticked transactions will be released (nothing is marked reconciled)."));case 2:if(t.v){t.n=3;break}return t.a(2);case 3:return e=this.reconcileSession.session.accountId,t.p=4,t.n=5,this.flushReconcileTicks();case 5:return t.n=6,(0,T.n)("/apps/budget/api/accounts/".concat(e,"/reconciliation/session"),{method:"DELETE",errorMessage:(0,i.Tl)("budget","Failed to cancel")});case 6:this.exitReconcileMode(),(0,c.Te)((0,i.Tl)("budget","Reconciliation cancelled")),t.n=8;break;case 7:t.p=7,n=t.v,(0,c.Qg)((0,i.Tl)("budget","Failed to cancel reconciliation: {message}",{message:this.reconcileErrorMessage(n)}));case 8:return t.a(2)}},t,this,[[4,7]])})),function(){return J.apply(this,arguments)})},{key:"cancelReconciliation",value:function(){this.exitReconcileMode()}},{key:"finishReconciliation",value:(X=Se(Te().m(function t(){var e,n,a;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.reconcileSession){t.n=1;break}return t.a(2);case 1:return e=this.reconcileSession.session.accountId,t.p=2,t.n=3,this.flushReconcileTicks();case 3:return t.n=4,(0,T.n)("/apps/budget/api/accounts/".concat(e,"/reconciliation/complete"),{method:"POST",errorMessage:(0,i.Tl)("budget","Failed to complete reconciliation")});case 4:n=t.v,this.exitReconcileMode(),this.app.loadAccounts(),this.app.loadTransactions(),(0,c.Te)((0,i.Tl)("budget","Reconciliation completed — {count} transactions marked as reconciled",{count:n.reconciledCount})),n.untickedBeforeStatementDate>0&&(0,c.I9)((0,i.zw)("budget","%n older uncleared transaction was not ticked and remains unreconciled","%n older uncleared transactions were not ticked and remain unreconciled",n.untickedBeforeStatementDate)),t.n=6;break;case 5:t.p=5,a=t.v,(0,c.Qg)((0,i.Tl)("budget","Failed to complete reconciliation: {error}",{error:this.reconcileErrorMessage(a)}));case 6:return t.a(2)}},t,this,[[2,5]])})),function(){return X.apply(this,arguments)})},{key:"createReconciliationAdjustment",value:(K=Se(Te().m(function t(e,n){var a,r,s,l,u;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.reconcileSession){t.n=1;break}return t.a(2);case 1:return a=this.reconcileSession.session.accountId,r=o.rT(),t.p=2,t.n=3,(0,T.n)("/apps/budget/api/transactions",{method:"POST",body:{date:r,accountId:a,type:e,amount:n,description:(0,i.Tl)("budget","Reconciliation Adjustment"),notes:(0,i.Tl)("budget","Adjustment to match statement balance of {amount}",{amount:this.formatCurrency(this.reconcileSession.session.statementBalance)})},errorMessage:(0,i.Tl)("budget","Failed to create adjustment")});case 3:return s=t.v,t.n=4,(0,T.n)("/apps/budget/api/accounts/".concat(a,"/reconciliation/tick"),{method:"POST",body:{transactionIds:[s.id],ticked:!0}}).catch(function(){return null});case 4:return(l=t.v)&&(this.reconcileSession=l,this.selectedTransactions=new Set(this.reconcileSession.tickedIds||[])),(0,c.Te)((0,i.Tl)("budget","Adjustment transaction created")),t.n=5,this.app.loadTransactions();case 5:this.renderReconcileBar(),t.n=7;break;case 6:t.p=6,u=t.v,console.error("Failed to create adjustment:",u),(0,c.Qg)((0,i.Tl)("budget","Failed to create adjustment: {message}",{message:this.reconcileErrorMessage(u)}));case 7:return t.a(2)}},t,this,[[2,6]])})),function(t,e){return K.apply(this,arguments)})},{key:"renderTransactionsList",value:function(t){var e=this;return t.map(function(t){return'\n
\n '.concat(e.formatDate(t.date),'\n ').concat(s.ZD(t.description),'\n ').concat(e.formatCurrency(t.amount,t.accountCurrency),"\n
\n ")}).join("")}},{key:"populateTransactionModalDropdowns",value:function(){var t=document.getElementById("transaction-account");if(t&&this.accounts){var e=t.value;t.innerHTML='"),(0,k.ig)(this.accounts,e).forEach(function(e){var n=document.createElement("option");n.value=e.id,n.textContent=(0,k.Jo)(e),t.appendChild(n)}),e&&(t.value=e)}var n=document.getElementById("transfer-to-account");if(n&&this.accounts){var a=n.value;n.innerHTML='"),(0,k.ig)(this.accounts,a).forEach(function(t){var e=document.createElement("option");e.value=t.id,e.textContent=(0,k.Jo)(t),n.appendChild(e)}),a&&(n.value=a)}var r=document.getElementById("transaction-category");if(r&&this.categories){var o=r.value;r.innerHTML='"),s.Vb(r,this.categoryTree||this.categories),o&&(r.value=o)}}},{key:"showTransactionModal",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=document.getElementById("transaction-modal");if(a){var r;this._formTransaction=null!=e&&e.id?e:null;var s=document.getElementById("transaction-modal-title");s&&(s.textContent=null!=e&&e.id?(0,i.Tl)("budget","Edit transaction"):(0,i.Tl)("budget","New transaction")),this.populateTransactionModalDropdowns();var c=document.getElementById("transaction-type");if(c){var l=c.querySelector('option[value="transfer"]');e&&l?l.remove():e||l||c.appendChild(new Option((0,i.Tl)("budget","Transfer"),"transfer"))}if(e){document.getElementById("transaction-id").value=e.id||"",(0,u.Mv)("transaction-date",e.date),(0,k.XH)(document.getElementById("transaction-account"),this.accounts,e.accountId),document.getElementById("transaction-type").value=e.type,document.getElementById("transaction-amount").value=e.amount,document.getElementById("transaction-description").value=e.description,document.getElementById("transaction-vendor").value=e.vendor||"",document.getElementById("transaction-category").value=e.categoryId||"",document.getElementById("transaction-notes").value=e.notes||"";var d=document.getElementById("transaction-excluded-from-forecast");d&&(d.checked=!!e.excludedFromForecast),this.setupAttachmentsSection(e.id,(this.accounts||[]).find(function(t){return t.id===e.accountId})||null),this.setupReceiptScan(!1),this.app.renderTransactionTagSelectors(e.categoryId,e.id)}else{document.getElementById("transaction-form").reset(),document.getElementById("transaction-id").value="",(0,u.Mv)("transaction-date",o.rT()),document.getElementById("transaction-type").value="debit",this._pendingAttachments=[],this.setupAttachmentsSection(null),this.setupReceiptScan(!0);var h=document.getElementById("transfer-dest-amount-wrapper");h&&(h.style.display="none");var g=document.getElementById("transfer-dest-amount");g&&(g.value="",g.dataset.userEdited="");var p=document.getElementById("transaction-amount-label");p&&(p.textContent=(0,i.Tl)("budget","Amount"));var f=document.getElementById("transaction-account"),m=n||this._defaultTransactionAccountId();m&&f.querySelector('option[value="'.concat(m,'"]'))&&(f.value=String(m)),this.app.renderTransactionTagSelectors(null,null)}var v=document.getElementById("transaction-category");if(v){var y=v.onchange;v.onchange=function(){y&&y();var e=document.getElementById("transaction-id").value;t.app.renderTransactionTagSelectors(v.value||null,e||null)}}var b=document.getElementById("transaction-type"),w=document.getElementById("transfer-to-account-wrapper"),T=document.getElementById("transfer-dest-amount-wrapper");if(b&&w){var E=function(){var e="transfer"===b.value;w.style.display=e?"block":"none",!e&&T&&(T.style.display="none"),e&&t._checkCrossCurrencyTransfer()};b.onchange=E,E()}this._bindTransferAmountFields(),this._updateAmountStep(),this._refreshFormCategoryOptions(null!=e&&e.id?null!==(r=e.categoryId)&&void 0!==r?r:"":void 0);var x=document.getElementById("transaction-account");x&&!this._categoryScopeBound&&(this._categoryScopeBound=!0,x.addEventListener("change",function(){return t._refreshFormCategoryOptions()})),this.setupInlineSplitToggle(),this._bindDescriptionRule();var S,C=document.getElementById("transaction-extras");C&&(C.open=!(!e||!(e.notes||e.excludedFromForecast||null!==(S=this.app.attachmentCounts)&&void 0!==S&&S[e.id]))),this._setupTypeToggle(),this._syncTypeToggle(),a.style.display="flex",this._keepKeyboardDownWhenViewing(e)}}},{key:"_bindDescriptionRule",value:function(){var t=this,e=document.getElementById("transaction-vendor");e&&!e.dataset.descriptionRule&&(e.dataset.descriptionRule="1",e.addEventListener("input",function(){return t._syncDescriptionRequired()}),e.addEventListener("change",function(){return t._syncDescriptionRequired()})),this._syncDescriptionRequired()}},{key:"_syncDescriptionRequired",value:function(){var t,e,n=document.getElementById("transaction-description");if(n){var a=""===(null!==(t=null===(e=document.getElementById("transaction-vendor"))||void 0===e?void 0:e.value)&&void 0!==t?t:"").trim();n.required=a;var r=document.querySelector('label[for="transaction-description"] .required');r&&(r.hidden=!a)}}},{key:"_formAccount",value:function(){var t,e=null===(t=document.getElementById("transaction-account"))||void 0===t?void 0:t.value;return e&&(this.accounts||[]).find(function(t){return String(t.id)===String(e)})||null}},{key:"_refreshFormCategoryOptions",value:function(){var t,e,n=this,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,r=document.getElementById("transaction-category");if(r&&this.categories){var o=this._formAccount(),c=void 0!==a||"1"===(null===(t=r.selectedOptions)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.dataset.unavailable),l=void 0!==a?String(null!=a?a:""):r.value,u=(0,k.hM)(this.categories,[o],[l]);if(r.innerHTML='"),s.Vb(r,u?(0,k.QN)(u):this.categoryTree||this.categories),c){var d,h=this._formTransaction,g=h&&String(null!==(d=h.categoryId)&&void 0!==d?d:"")===l?h.categoryName:null;(0,w.Qz)(r,l,g?(0,w.pC)(g):null)}else r.value=l;var p=null===(e=document.getElementById("transaction-type"))||void 0===e?void 0:e.value;document.querySelectorAll("#inline-splits-container .inline-split-category").forEach(function(t){var e,a=t.value,r=(null===(e=t.selectedOptions)||void 0===e||null===(e=e[0])||void 0===e?void 0:e.dataset.categoryName)||null;t.innerHTML='")+n.app.getCategoryOptions(a?parseInt(a,10):null,p,o,r),t.value=a})}}},{key:"_keepKeyboardDownWhenViewing",value:function(t){var e,n;if(null!=t&&t.id&&null!==(e=(n=window).matchMedia)&&void 0!==e&&e.call(n,Le).matches){var a=document.getElementById("transaction-modal-title");a&&(a.setAttribute("tabindex","-1"),a.focus({preventScroll:!0}))}}},{key:"_defaultTransactionAccountId",value:function(){var t,e=(0,k.HB)(this.accounts),n=function(t){return e.some(function(e){return String(e.id)===String(t)})},a=null===(t=document.getElementById("filter-account"))||void 0===t?void 0:t.value;if(a&&n(a))return a;var r=null;try{r=window.localStorage.getItem("budget.lastTransactionAccountId")}catch(t){}return r&&n(r)?r:1===e.length?e[0].id:null}},{key:"_setupTypeToggle",value:function(){var t=this;if(!this._typeToggleBound){var e=document.getElementById("transaction-type-toggle"),n=document.getElementById("transaction-type");if(e&&n){this._typeToggleBound=!0;var a=function(e){e&&!e.hidden&&n.value!==e.dataset.value&&(n.value=e.dataset.value,n.dispatchEvent(new Event("change")),t._syncTypeToggle())};e.addEventListener("click",function(t){return a(t.target.closest("button[data-value]"))}),e.addEventListener("keydown",function(t){if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)){t.preventDefault();var r=ve(e.querySelectorAll("button[data-value]")).filter(function(t){return!t.hidden}),i=r.findIndex(function(t){return t.dataset.value===n.value}),o=r[(i+("ArrowRight"===t.key||"ArrowDown"===t.key?1:-1)+r.length)%r.length];a(o),null==o||o.focus()}})}}}},{key:"_syncTypeToggle",value:function(){var t=document.getElementById("transaction-type-toggle"),e=document.getElementById("transaction-type");t&&e&&t.querySelectorAll("button[data-value]").forEach(function(t){var n=!!e.querySelector('option[value="'.concat(t.dataset.value,'"]')),a=n&&e.value===t.dataset.value;t.hidden=!n,t.classList.toggle("active",a),t.setAttribute("aria-checked",a?"true":"false"),t.tabIndex=a||!e.value&&"debit"===t.dataset.value?0:-1})}},{key:"editTransaction",value:($=Se(Te().m(function t(e){var n,a,r;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!(a=this.transactions.find(function(t){return t.id===e}))&&null!==(n=this.app.accountsModule)&&void 0!==n&&n.accountTransactions&&(a=this.app.accountsModule.accountTransactions.find(function(t){return t.id===e})),a){t.n=4;break}return t.p=1,t.n=2,(0,T.n)("/apps/budget/api/transactions/".concat(e));case 2:a=t.v,t.n=4;break;case 3:return t.p=3,r=t.v,console.error("Failed to fetch transaction for editing:",r),(0,c.Qg)((0,i.Tl)("budget","Failed to load transaction")),t.a(2);case 4:a&&this.showTransactionModal(a);case 5:return t.a(2)}},t,this,[[1,3]])})),function(t){return $.apply(this,arguments)})},{key:"duplicateTransaction",value:(Q=Se(Te().m(function t(e){var n,a,r,o;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!(a=this.transactions.find(function(t){return t.id===e}))&&null!==(n=this.app.accountsModule)&&void 0!==n&&n.accountTransactions&&(a=this.app.accountsModule.accountTransactions.find(function(t){return t.id===e})),a){t.n=4;break}return t.p=1,t.n=2,(0,T.n)("/apps/budget/api/transactions/".concat(e));case 2:a=t.v,t.n=4;break;case 3:return t.p=3,o=t.v,console.error("Failed to fetch transaction for duplicating:",o),(0,c.Qg)((0,i.Tl)("budget","Failed to load transaction")),t.a(2);case 4:a&&(r=be(be({},a),{},{id:null}),this.showTransactionModal(r));case 5:return t.a(2)}},t,this,[[1,3]])})),function(t){return Q.apply(this,arguments)})},{key:"setupReceiptScan",value:(Y=Se(Te().m(function t(e){var n,a,r,i,o,s,c,l,u=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=document.getElementById("transaction-scan-group")){t.n=1;break}return t.a(2);case 1:if(this._scannedReceiptFile=null,this._allowNegativeRemainder=!1,this.clearScanResult(),void 0!==this._ocrAvailable){t.n=7;break}return t.p=2,t.n=3,(0,T.n)("/apps/budget/api/receipts/ocr-status");case 3:if(l=a=t.v,!(c=null!==l)){t.n=4;break}c=void 0!==a;case 4:if(!(s=c)){t.n=5;break}s=a.available;case 5:this._ocrAvailable=!!s,t.n=7;break;case 6:t.p=6,t.v,this._ocrAvailable=!1;case 7:if(n.style.display=this._ocrAvailable?"":"none",this._ocrAvailable){t.n=8;break}return t.a(2);case 8:if(e&&(r=document.getElementById("transaction-extras"))&&(r.open=!0),this._scanIsNewTransaction=e,!this._scanBound){t.n=9;break}return t.a(2);case 9:this._scanBound=!0,i=document.getElementById("transaction-scan-drop"),o=document.getElementById("transaction-scan-input"),i.addEventListener("click",function(){return o.click()}),i.addEventListener("keydown",function(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o.click())}),o.addEventListener("change",function(){o.files[0]&&u.scanReceipt(o.files[0]),o.value=""}),["dragenter","dragover"].forEach(function(t){return i.addEventListener(t,function(t){t.preventDefault(),i.classList.add("is-over")})}),["dragleave","drop"].forEach(function(t){return i.addEventListener(t,function(t){t.preventDefault(),i.classList.remove("is-over")})}),i.addEventListener("drop",function(t){var e,n=null===(e=t.dataTransfer)||void 0===e||null===(e=e.files)||void 0===e?void 0:e[0];n&&u.scanReceipt(n)});case 10:return t.a(2)}},t,this,[[2,6]])})),function(t){return Y.apply(this,arguments)})},{key:"clearScanResult",value:function(){var t=document.getElementById("transaction-scan-result");t&&(t.hidden=!0,t.textContent="");var e=document.getElementById("transaction-scan-drop");e&&e.classList.remove("has-file")}},{key:"setScanBusy",value:function(t){var e=document.getElementById("transaction-scan-drop");e&&(e.classList.toggle("is-busy",t),e.querySelector(".receipt-scan-idle").hidden=t,e.querySelector(".receipt-scan-busy").hidden=!t)}},{key:"scanReceipt",value:(Z=Se(Te().m(function t(e){var n,a,r,o,s;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return this.clearScanResult(),this.setScanBusy(!0),t.p=1,(a=new FormData).append("image",e),t.n=2,(0,T.n)("/apps/budget/api/receipts/extract",{method:"POST",body:a,errorMessage:(0,i.Tl)("budget","The receipt could not be read")});case 2:r=t.v,o=this.applyReceiptDraft(r),this._scannedReceiptFile=e,null===(n=document.getElementById("transaction-scan-drop"))||void 0===n||n.classList.add("has-file"),this.showScanResult(r,o),t.n=4;break;case 3:t.p=3,s=t.v,(0,c.Qg)(s.message||(0,i.Tl)("budget","The receipt could not be read"));case 4:return t.p=4,this.setScanBusy(!1),t.f(4);case 5:return t.a(2)}},t,this,[[1,3,4,5]])})),function(t){return Z.apply(this,arguments)})},{key:"applyReceiptDraft",value:function(t){var e=[],n=this._scanIsNewTransaction,a=function(t,a,r){t&&null!=a&&""!==a&&(n||""===t.value)&&(t.value=a,t.dispatchEvent(new Event("change",{bubbles:!0})),e.push(r))};if(t.date){var r=document.getElementById("transaction-date");r&&(n||""===r.value)&&((0,u.Mv)("transaction-date",t.date),e.push((0,i.Tl)("budget","date")))}if(t.total&&a(document.getElementById("transaction-amount"),t.total,(0,i.Tl)("budget","amount")),t.merchant&&(a(document.getElementById("transaction-description"),t.merchant,(0,i.Tl)("budget","description")),a(document.getElementById("transaction-vendor"),t.merchant,(0,i.Tl)("budget","vendor"))),t.suggestedCategoryId){var o=document.getElementById("transaction-category");o&&ve(o.options).some(function(e){return e.value===String(t.suggestedCategoryId)})&&a(o,String(t.suggestedCategoryId),(0,i.Tl)("budget","category"))}return e}},{key:"receiptSplitPlan",value:function(t){var e=Number(t.total),n=(t.lineItems||[]).map(function(t){var e,n;return{description:String(null!==(e=t.description)&&void 0!==e?e:"").slice(0,255),amount:Number(t.amount),suggestedCategoryId:null!==(n=t.suggestedCategoryId)&&void 0!==n?n:null}}).filter(function(t){return Number.isFinite(t.amount)&&t.amount>0});if(n.length<2||!Number.isFinite(e)||e<=0)return null;var a=function(t){return Math.round(100*t)},r=n.reduce(function(t,e){return t+a(e.amount)},0),i=a(e),o=a(Number(t.tax)||0),s=a(Math.abs(Number(t.discount)||0)),c=s>0?Math.abs(Number(t.discount)):null,l=o>0?Number(t.tax):null;return r===i?{rows:n,tax:null,discount:null}:o>0&&r+o===i?{rows:n,tax:l,discount:null}:s>0&&r-s===i?{rows:n,tax:null,discount:c}:s>0&&o>0&&r-s+o===i?{rows:n,tax:l,discount:c}:null}},{key:"applyReceiptSplits",value:function(t){var e=this,n=document.getElementById("transaction-split-toggle"),a=document.getElementById("inline-splits-section"),r=document.getElementById("inline-splits-container"),o=document.getElementById("transaction-category-group");if(n&&a&&r){n.checked=!0,a.style.display="",o&&(o.style.display="none"),this._allowNegativeRemainder=null!==t.discount,r.innerHTML="";var s=ve(t.rows);null!==t.discount&&s.push({description:(0,i.Tl)("budget","Savings / discount"),amount:-t.discount}),null!==t.tax&&s.push({description:(0,i.Tl)("budget","VAT / tax"),amount:t.tax}),s.forEach(function(t,n){e.addInlineSplitRow(0===n,{amount:"",categoryId:null,description:t.description})});var l=ve(r.querySelectorAll(".split-row"));l.forEach(function(t,e){if(!(e>=l.length-1)){var n=t.querySelector(".inline-split-amount");n&&(n.value=s[e].amount.toFixed(2),s[e].amount<0&&n.removeAttribute("min"))}});var u=0;l.forEach(function(n,a){if(!(a>=t.rows.length)){var r=n.querySelector(".inline-split-category");r&&(e.preselectSuggestedCategory(r,t.rows[a].suggestedCategoryId)&&u++,e.offerRememberItemCategory(n,r,t.rows[a]))}}),this.refreshInlineSplitRows(),this.recomputeRemainderRow(),(0,c.Te)(u?(0,i.Tl)("budget","Split into {count} lines from the receipt. Your rules set a category on {suggested} of them; check them and set the rest.",{count:s.length,suggested:u}):(0,i.Tl)("budget","Split into {count} lines from the receipt. Set a category on each.",{count:s.length}))}}},{key:"preselectSuggestedCategory",value:function(t,e){if(null==e)return!1;var n=ve(t.options).find(function(t){return t.value===String(e)&&!t.disabled});return!!n&&(t.value=n.value,!0)}},{key:"offerRememberItemCategory",value:function(t,e,n){var a=t.querySelector(".split-category-field");if(a&&n.description){var r=document.createElement("button");r.type="button",r.className="receipt-remember-btn",r.textContent=(0,i.Tl)("budget","Remember"),r.title=(0,i.Tl)("budget",'Use this category for "{item}" on future receipts',{item:n.description}),r.hidden=!0,a.appendChild(r);var o=null!==n.suggestedCategoryId?String(n.suggestedCategoryId):"";e.addEventListener("change",function(){r.hidden=""===e.value||e.value===o,r.disabled=!1,r.textContent=(0,i.Tl)("budget","Remember")}),r.addEventListener("click",Se(Te().m(function t(){var a,s,l,u,d;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(""!==(a=e.value)){t.n=1;break}return t.a(2);case 1:return r.disabled=!0,t.p=2,t.n=3,(0,T.n)("/apps/budget/api/import-rules");case 3:return s=t.v,l=he(s,n.description),u=de(n.description,a,(0,i.Tl)("budget","Receipt items")),t.n=4,(0,T.n)(l?"/apps/budget/api/import-rules/".concat(l.id):"/apps/budget/api/import-rules",{method:l?"PUT":"POST",body:u,errorMessage:(0,i.Tl)("budget","Could not save the rule")});case 4:o=a,r.textContent=(0,i.Tl)("budget","Remembered"),t.n=6;break;case 5:t.p=5,d=t.v,r.disabled=!1,(0,c.Qg)((null==d?void 0:d.message)||(0,i.Tl)("budget","Could not save the rule"));case 6:return t.a(2)}},t,null,[[2,5]])})))}}},{key:"showScanResult",value:function(t,e){var n,a,r=this,o=document.getElementById("transaction-scan-result");if(o){var s=[];s.push(e.length?(0,i.Tl)("budget","Filled in: {fields}. Check them before saving.",{fields:e.join(", ")}):(0,i.Tl)("budget","Nothing was filled in — the fields already had values. Clear one and scan again to use the receipt."));var c=(null===(n=t.lineItems)||void 0===n?void 0:n.length)||0;c&&s.push((0,i.Tl)("budget","Read {count} items from the receipt.",{count:c})),null!==(a=t.warnings)&&void 0!==a&&a.includes("line-items-sum-mismatch")&&s.push((0,i.Tl)("budget","The items do not add up to the total — worth a look.")),t.currency&&""!==t.currency&&s.push((0,i.Tl)("budget","Receipt currency: {currency}.",{currency:t.currency})),s.push((0,i.Tl)("budget","The photo will be attached when you save.")),o.textContent=s.join(" ");var l=this.receiptSplitPlan(t);if(!l&&c>=2&&(o.textContent+=" "+(0,i.Tl)("budget","These items cannot be split individually: they do not add up to the total, so the parts would not balance.")),l){var u=l.rows.length+(null!==l.tax?1:0)+(null!==l.discount?1:0),d=document.createElement("button");d.type="button",d.className="secondary receipt-scan-split-btn",d.textContent=(0,i.Tl)("budget","Split into {count} lines",{count:u});var h=[];null!==l.discount&&h.push((0,i.Tl)("budget","the savings as a negative line")),null!==l.tax&&h.push((0,i.Tl)("budget","the tax as its own line")),d.title=h.length?(0,i.Tl)("budget","One line per item, plus {extras}",{extras:h.join((0,i.Tl)("budget"," and "))}):(0,i.Tl)("budget","One line per item on the receipt"),d.addEventListener("click",function(){r.applyReceiptSplits(l),d.disabled=!0}),o.appendChild(document.createElement("br")),o.appendChild(d)}o.hidden=!1}}},{key:"setupAttachmentsSection",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=document.getElementById("transaction-attachments-group");if(a){if(t&&(0,k.GF)(n))return a.style.display="none",void(this._attachmentTxId=null);if(a.style.display="",this._attachmentTxId=t,!this._attachmentsBound){var r,o;this._attachmentsBound=!0;var s=document.getElementById("attachment-file-input");null===(r=document.getElementById("attachment-upload-btn"))||void 0===r||r.addEventListener("click",function(){return null==s?void 0:s.click()}),null==s||s.addEventListener("change",Se(Te().m(function t(){var n,a,r,i,o,c,l;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e._attachmentTxId){t.n=1;break}n=me(s.files);try{for(n.s();!(a=n.n()).done;)r=a.value,e._pendingAttachments.push({kind:"file",file:r,name:r.name})}catch(t){n.e(t)}finally{n.f()}return s.value="",e.renderPendingAttachments(),t.a(2);case 1:i=me(s.files),t.p=2,i.s();case 3:if((o=i.n()).done){t.n=5;break}return c=o.value,t.n=4,e.uploadAttachment(e._attachmentTxId,c);case 4:t.n=3;break;case 5:t.n=7;break;case 6:t.p=6,l=t.v,i.e(l);case 7:return t.p=7,i.f(),t.f(7);case 8:return s.value="",t.n=9,e.loadAttachments(e._attachmentTxId);case 9:return t.a(2)}},t,null,[[2,6,7,8]])}))),null===(o=document.getElementById("attachment-pick-btn"))||void 0===o||o.addEventListener("click",function(){OC.dialogs.filepicker((0,i.Tl)("budget","Select receipt"),function(){var t=Se(Te().m(function t(n){return Te().w(function(t){for(;;)switch(t.n){case 0:if(e._attachmentTxId){t.n=1;break}return e._pendingAttachments.push({kind:"path",path:n,name:n.split("/").pop()||n}),e.renderPendingAttachments(),t.a(2);case 1:return t.n=2,e.attachExistingFile(e._attachmentTxId,n);case 2:return t.n=3,e.loadAttachments(e._attachmentTxId);case 3:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),!1,["image/*","application/pdf"],!0)})}t?this.loadAttachments(t):this.renderPendingAttachments()}}},{key:"renderPendingAttachments",value:function(){var t=this,e=document.getElementById("transaction-attachments-list");e&&(this._pendingAttachments.length?(e.innerHTML=this._pendingAttachments.map(function(t,e){return'\n
\n ').concat("path"===t.kind?"🗂️":"📄","\n ").concat(s.ZD(t.name),'\n ').concat((0,i.Tl)("budget","on save"),'\n \n
')}).join(""),e.querySelectorAll(".attachment-remove").forEach(function(e){e.addEventListener("click",function(){t._pendingAttachments.splice(parseInt(e.dataset.pendingIndex),1),t.renderPendingAttachments()})})):e.innerHTML=''.concat((0,i.Tl)("budget","No receipts yet — they are attached when you save."),""))}},{key:"flushPendingAttachments",value:(G=Se(Te().m(function t(e){var n,a,r,i,o,s;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:n=0,a=me(this._pendingAttachments),t.p=1,a.s();case 2:if((r=a.n()).done){t.n=10;break}if(i=r.value,t.p=3,"path"!==i.kind){t.n=5;break}return t.n=4,this.attachExistingFile(e,i.path);case 4:o=t.v,t.n=7;break;case 5:return t.n=6,this.uploadAttachment(e,i.file);case 6:o=t.v;case 7:o||n++,t.n=9;break;case 8:t.p=8,t.v,n++;case 9:t.n=2;break;case 10:t.n=12;break;case 11:t.p=11,s=t.v,a.e(s);case 12:return t.p=12,a.f(),t.f(12);case 13:return this._pendingAttachments=[],t.a(2,n)}},t,this,[[3,8],[1,11,12,13]])})),function(t){return G.apply(this,arguments)})},{key:"loadAttachments",value:(U=Se(Te().m(function t(e){var n,a,r,o=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=document.getElementById("transaction-attachments-list")){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/attachments"));case 2:a=t.v,n.innerHTML=a.map(function(t){var e=t.isImage&&!t.missing?''):"📄",n=s.ZD(t.fileName||(0,i.Tl)("budget","Receipt")),a=t.missing?'').concat(n,""):'').concat(n,"");return'\n
\n ').concat(e,"\n ").concat(a,'\n \n
')}).join("")||''.concat((0,i.Tl)("budget","No receipts attached"),""),n.querySelectorAll(".attachment-remove").forEach(function(t){t.addEventListener("click",Se(Te().m(function n(){return Te().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,o.detachAttachment(e,parseInt(t.dataset.attachmentId));case 1:return n.n=2,o.loadAttachments(e);case 2:return n.a(2)}},n)})))}),t.n=4;break;case 3:t.p=3,r=t.v,console.error("Failed to load attachments:",r),n.innerHTML=''.concat((0,i.Tl)("budget","Failed to load attachments"),"");case 4:return t.a(2)}},t,null,[[1,3]])})),function(t){return U.apply(this,arguments)})},{key:"uploadAttachment",value:(W=Se(Te().m(function t(e,n){var a,r;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,(a=new FormData).append("file",n),t.n=1,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/attachments/upload"),{method:"POST",body:a,errorMessage:(0,i.Tl)("budget","Failed to upload receipt")});case 1:return this.app.attachmentCounts=null,t.a(2,!0);case 2:return t.p=2,r=t.v,(0,c.Qg)(r.message||(0,i.Tl)("budget","Failed to upload receipt")),t.a(2,!1)}},t,this,[[0,2]])})),function(t,e){return W.apply(this,arguments)})},{key:"attachExistingFile",value:(q=Se(Te().m(function t(e,n){var a;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/attachments"),{method:"POST",body:{path:n},errorMessage:(0,i.Tl)("budget","Failed to attach file")});case 1:return this.app.attachmentCounts=null,t.a(2,!0);case 2:return t.p=2,a=t.v,(0,c.Qg)(a.message||(0,i.Tl)("budget","Failed to attach file")),t.a(2,!1)}},t,this,[[0,2]])})),function(t,e){return q.apply(this,arguments)})},{key:"detachAttachment",value:(V=Se(Te().m(function t(e,n){return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/attachments/").concat(n),{method:"DELETE"});case 1:this.app.attachmentCounts=null,t.n=3;break;case 2:t.p=2,t.v,(0,c.Qg)((0,i.Tl)("budget","Failed to remove attachment"));case 3:return t.a(2)}},t,this,[[0,2]])})),function(t,e){return V.apply(this,arguments)})},{key:"saveTransaction",value:function(){var t=this;return(0,ee.O)("transaction-save",document.querySelector('#transaction-form [type="submit"]'),function(){return t._saveTransaction()})}},{key:"_saveTransaction",value:(z=Se(Te().m(function t(){var e,n,a,r,o,s,u,d,h,g,p,f,m,v,y,b,w,k,E,x,S,C,I,A,_,M,D,B,L,P,O,F,R,N,j,H;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=document.getElementById("transaction-id").value,a=document.getElementById("transaction-date").value,r=parseInt(document.getElementById("transaction-account").value),!n&&r)try{window.localStorage.setItem("budget.lastTransactionAccountId",String(r))}catch(t){}if(o=document.getElementById("transaction-type").value,s=parseFloat(document.getElementById("transaction-amount").value),!n){t.n=3;break}if(null==(d=null===(u=this.transactions)||void 0===u?void 0:u.find(function(t){return t.id===parseInt(n)}))||!d.reconciled){t.n=3;break}if(h=parseFloat(d.amount)!==s||d.type!==o||d.accountId!==r||d.date!==a,!(N=h)){t.n=2;break}return t.n=1,(0,l.ZD)((0,i.Tl)("budget","This transaction was reconciled against a bank statement. Changing its amount, type, account or date will make past reconciliations no longer match. Continue?"));case 1:N=!t.v;case 2:if(!N){t.n=3;break}return t.a(2);case 3:if(g=document.getElementById("transaction-description").value,p=document.getElementById("transaction-vendor").value,f=document.getElementById("transaction-category").value,m=document.getElementById("transaction-notes").value,v=(null===(e=document.getElementById("transaction-excluded-from-forecast"))||void 0===e?void 0:e.checked)||!1,y=Array.from(document.querySelectorAll('#transaction-tags-container input[type="checkbox"]:checked')).map(function(t){return parseInt(t.value)}),"transfer"!==o||n){t.n=16;break}if(b=parseInt(document.getElementById("transfer-to-account").value)){t.n=4;break}return(0,c.I9)((0,i.Tl)("budget","Please select destination account")),t.a(2);case 4:if(b!==r){t.n=5;break}return(0,c.I9)((0,i.Tl)("budget","Cannot transfer to same account")),t.a(2);case 5:return t.p=5,t.n=6,(0,T.n)("/apps/budget/api/transactions",{method:"POST",body:{date:a,accountId:r,type:"debit",amount:s,description:g,vendor:p||null,categoryId:f?parseInt(f):null,notes:m||null},errorMessage:"Failed to create transfer debit transaction"});case 6:return w=t.v,k=w.id,E=document.getElementById("transfer-dest-amount-wrapper"),x=document.getElementById("transfer-dest-amount"),S="none"!==(null==E?void 0:E.style.display)&&null!=x&&x.value?parseFloat(x.value):s,t.n=7,(0,T.n)("/apps/budget/api/transactions",{method:"POST",body:{date:a,accountId:b,type:"credit",amount:S,description:g,vendor:p||null,categoryId:f?parseInt(f):null,notes:m||null},errorMessage:"Failed to create transfer credit transaction"});case 7:return C=t.v,I=C.id,t.n=8,(0,T.n)("/apps/budget/api/transactions/".concat(k,"/link/").concat(I),{method:"POST",errorMessage:"Failed to link transfer transactions"});case 8:if(!(y.length>0)){t.n=10;break}return t.n=9,this.app.tagSetsModule.saveTransactionTags(k,y);case 9:return t.n=10,this.app.tagSetsModule.saveTransactionTags(I,y);case 10:return(0,c.Te)((0,i.Tl)("budget","Transfer created successfully")),this.app.hideModals(),t.n=11,this.app.loadTransactions();case 11:return t.n=12,this.app.loadAccounts();case 12:return t.n=13,this.app.refreshCurrentAccountView();case 13:if(""!==window.location.hash&&"#/dashboard"!==window.location.hash){t.n=14;break}return t.n=14,this.app.loadDashboard();case 14:return t.a(2);case 15:return t.p=15,j=t.v,console.error("Transfer creation failed:",j),(0,c.Qg)(j.message||(0,i.Tl)("budget","Failed to create transfer")),t.a(2);case 16:if(A={date:a,accountId:r,type:o,amount:s,description:g,vendor:p||null,categoryId:f?parseInt(f):null,notes:m||null,excludedFromForecast:v},null==(_=document.getElementById("transaction-split-toggle"))||!_.checked){t.n=17;break}if((M=this.validateInlineSplits()).ok){t.n=17;break}return(0,c.Qg)(M.message),t.a(2);case 17:if(D=this._editedTransaction(n),B=!(!D||!D.isSplit&&!D.is_split||null!=_&&_.checked),t.p=18,P=null,!n){t.n=21;break}if(!B){t.n=19;break}return t.n=19,(0,T.n)("/apps/budget/api/transactions/".concat(n,"/splits"),{method:"DELETE",body:{categoryId:A.categoryId},errorMessage:(0,i.Tl)("budget","Failed to unsplit transaction")});case 19:return t.n=20,(0,T.n)("/apps/budget/api/transactions/".concat(n),{method:"PUT",body:A,errorMessage:(0,i.Tl)("budget","Failed to save transaction")});case 20:t.n=23;break;case 21:return t.n=22,(0,T.n)("/apps/budget/api/transactions",{method:"POST",body:A,errorMessage:(0,i.Tl)("budget","Failed to save transaction")});case 22:P=t.v;case 23:if(O=(null===(L=P)||void 0===L?void 0:L.id)||parseInt(n),!(!n&&y.length>0&&O)){t.n=24;break}return t.n=24,this.app.tagSetsModule.saveTransactionTags(O,y);case 24:if(null==(F=document.getElementById("transaction-split-toggle"))||!F.checked||!O){t.n=25;break}return t.n=25,this.saveInlineSplits(O);case 25:if(!O){t.n=27;break}return this._scannedReceiptFile&&(this._pendingAttachments.push({kind:"file",file:this._scannedReceiptFile,name:this._scannedReceiptFile.name}),this._scannedReceiptFile=null),t.n=26,this.flushPendingAttachments(O);case 26:(R=t.v)>0&&(0,c.I9)((0,i.Tl)("budget","The transaction was saved, but {count} receipt(s) could not be attached",{count:R}));case 27:return(0,c.Te)(n?(0,i.Tl)("budget","Transaction updated"):(0,i.Tl)("budget","Transaction created")),this.app.hideModals(),t.n=28,this.app.loadTransactions();case 28:return t.n=29,this.app.loadAccounts();case 29:return t.n=30,this.app.refreshCurrentAccountView();case 30:if(""!==window.location.hash&&"#/dashboard"!==window.location.hash){t.n=31;break}return t.n=31,this.app.loadDashboard();case 31:t.n=33;break;case 32:t.p=32,H=t.v,console.error("Failed to save transaction:",H),(0,c.Qg)(H.message||(0,i.Tl)("budget","Failed to save transaction"));case 33:return t.a(2)}},t,this,[[18,32],[5,15]])})),function(){return z.apply(this,arguments)})},{key:"_editedTransaction",value:function(t){var e,n,a=parseInt(t);return a?(null===(e=this._formTransaction)||void 0===e?void 0:e.id)===a?this._formTransaction:(null===(n=this.transactions)||void 0===n?void 0:n.find(function(t){return t.id===a}))||null:null}},{key:"setupInlineSplitToggle",value:function(){var t,e=this,n=document.getElementById("transaction-split-toggle"),a=document.getElementById("inline-splits-section"),r=document.getElementById("transaction-category-group"),i=document.getElementById("split-toggle-group");if(n&&a){var o=null===(t=document.getElementById("transaction-id"))||void 0===t?void 0:t.value,s=!!o,c=document.getElementById("transaction-type"),l="transfer"===(null==c?void 0:c.value),u=this._editedTransaction(o),d=(null==u?void 0:u.isSplit)||(null==u?void 0:u.is_split);if(n.checked=!1,this.hideInlineSplits(),i&&(i.style.display=l?"none":""),s&&d&&(n.checked=!0,a.style.display="",r&&(r.style.display="none"),this.loadExistingSplits(parseInt(o))),c){var h=c.onchange;c.onchange=function(){h&&h(),i&&(i.style.display="transfer"===c.value?"none":""),"transfer"===c.value&&n.checked&&(n.checked=!1,n.dispatchEvent(new Event("change")))}}n.onchange=function(){n.checked?(a.style.display="",r&&(r.style.display="none"),e.initInlineSplitRows()):e.hideInlineSplits()};var g=document.getElementById("transaction-amount");g&&g.addEventListener("input",function(){return e.recomputeRemainderRow()});var p=document.getElementById("inline-add-split-btn");p&&(p.onclick=function(){return e.addInlineSplitRow()})}}},{key:"hideInlineSplits",value:function(){var t=document.getElementById("inline-splits-section"),e=document.getElementById("transaction-category-group"),n=document.getElementById("inline-splits-container");t&&(t.style.display="none"),e&&(e.style.display=""),n&&(n.innerHTML=""),this.updateInlineSplitRemaining()}},{key:"initInlineSplitRows",value:function(){var t=document.getElementById("inline-splits-container");t&&(this._allowNegativeRemainder=!1,t.innerHTML="",this.addInlineSplitRow(!0),this.addInlineSplitRow(!1),this.refreshInlineSplitRows())}},{key:"addInlineSplitRow",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).defer,r=void 0!==a&&a,o=document.getElementById("inline-splits-container");if(o){var c=document.getElementById("transaction-type"),l=(null==c?void 0:c.value)||"debit",u=document.createElement("div");u.className="split-row";var d=n?Number(n.amount):null,h=null!==d&&d<0?"":'min="0.01"';u.innerHTML='\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n
\n '),u.querySelector(".inline-split-amount").addEventListener("input",function(){t.recomputeRemainderRow()}),u.querySelector(".split-remove-btn").addEventListener("click",function(e){e.currentTarget.classList.contains("disabled")||(u.remove(),t.refreshInlineSplitRows())}),o.appendChild(u),r||this.refreshInlineSplitRows()}}},{key:"updateInlineSplitRemaining",value:function(){var t,e=parseFloat(null===(t=document.getElementById("transaction-amount"))||void 0===t?void 0:t.value)||0,n=document.querySelectorAll("#inline-splits-container .split-row"),a=0;n.forEach(function(t){var e;a+=parseFloat(null===(e=t.querySelector(".inline-split-amount"))||void 0===e?void 0:e.value)||0});var r=e-a,o=document.getElementById("inline-split-remaining");if(o){var s=Math.abs(r)<.01;o.textContent=s?(0,i.Tl)("budget","Fully allocated"):(0,i.Tl)("budget","Remaining: {amount}",{amount:r.toFixed(2)}),o.style.color=s?(0,g.PJ)("positive","#4caf50"):"var(--budget-color-negative)"}}},{key:"refreshInlineSplitRows",value:function(){var t=Array.from(document.querySelectorAll("#inline-splits-container .split-row"));t.forEach(function(e,n){var a=e.querySelector(".inline-split-amount"),r=e.querySelector(".split-amount-field label"),o=t.length>=2&&n===t.length-1;a.readOnly=o,a.classList.toggle("inline-split-remainder",o),a.title=o?(0,i.Tl)("budget","Auto-calculated from the transaction total minus the other splits"):"",r&&(r.textContent=o?(0,i.Tl)("budget","Amount (remaining)"):(0,i.Tl)("budget","Amount"))}),this.recomputeRemainderRow()}},{key:"recomputeRemainderRow",value:function(){var t=Array.from(document.querySelectorAll("#inline-splits-container .split-row"));if(t.length>=2){var e,n=parseFloat(null===(e=document.getElementById("transaction-amount"))||void 0===e?void 0:e.value)||0,a=t[t.length-1].querySelector(".inline-split-amount"),r=0;t.slice(0,-1).forEach(function(t){var e;r+=parseFloat(null===(e=t.querySelector(".inline-split-amount"))||void 0===e?void 0:e.value)||0});var i=Math.round(100*(n-r))/100;a.value=i>0||this._allowNegativeRemainder?i.toFixed(2):"0.00"}this.updateInlineSplitRemaining()}},{key:"validateInlineSplits",value:function(){var t,e=parseFloat(null===(t=document.getElementById("transaction-amount"))||void 0===t?void 0:t.value)||0,n=Array.from(document.querySelectorAll("#inline-splits-container .split-row .inline-split-amount")).map(function(t){return parseFloat(t.value)}).filter(function(t){return Number.isFinite(t)&&Math.abs(t)>=.005});if(n.length<2)return{ok:!1,message:(0,i.Tl)("budget","A split needs at least two parts with an amount.")};var a=Math.round(100*n.reduce(function(t,e){return t+e},0))/100;return Math.abs(a-e)>=.01?{ok:!1,message:(0,i.Tl)("budget","Split amounts must add up to the transaction total ({total}).",{total:e.toFixed(2)})}:{ok:!0}}},{key:"loadExistingSplits",value:(H=Se(Te().m(function t(e){var n,a,r,i=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=document.getElementById("inline-splits-container")){t.n=1;break}return t.a(2);case 1:return n.innerHTML="",t.p=2,t.n=3,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/splits")).catch(function(){return null});case 3:if(a=t.v){t.n=4;break}return t.a(2);case 4:a.length>0?(this._allowNegativeRemainder=a.some(function(t){return Number(t.amount)<0}),a.forEach(function(t,e){i.addInlineSplitRow(0===e,t,{defer:!0})})):(this.addInlineSplitRow(!0),this.addInlineSplitRow(!1)),t.n=6;break;case 5:t.p=5,r=t.v,console.error("Failed to load splits:",r),this.addInlineSplitRow(!0),this.addInlineSplitRow(!1);case 6:this.refreshInlineSplitRows();case 7:return t.a(2)}},t,this,[[2,5]])})),function(t){return H.apply(this,arguments)})},{key:"saveInlineSplits",value:(j=Se(Te().m(function t(e){var n,a,r,o,s;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=document.querySelectorAll("#inline-splits-container .split-row"),!((a=Array.from(n).map(function(t){var e,n,a;return{amount:parseFloat(null===(e=t.querySelector(".inline-split-amount"))||void 0===e?void 0:e.value),categoryId:parseInt(null===(n=t.querySelector(".inline-split-category"))||void 0===n?void 0:n.value)||null,description:(null===(a=t.querySelector(".inline-split-description"))||void 0===a||null===(a=a.value)||void 0===a?void 0:a.trim())||null}}).filter(function(t){return Number.isFinite(t.amount)&&Math.abs(t.amount)>=.005})).length<2)){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/splits"),{method:"POST",body:{splits:a}});case 2:t.n=4;break;case 3:t.p=3,s=t.v,console.error("Failed to save inline splits:",s),o=s instanceof T.h&&(null===(r=s.data)||void 0===r?void 0:r.error)||"",(0,c.I9)(o?(0,i.Tl)("budget","The transaction was saved, but not split: {reason}",{reason:o}):(0,i.Tl)("budget","The transaction was saved, but its splits could not be stored"));case 4:return t.a(2)}},t,null,[[1,3]])})),function(t){return j.apply(this,arguments)})},{key:"deleteTransaction",value:(N=Se(Te().m(function t(e){var n,a,r,s,u,d,h;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=this.transactions.find(function(t){return t.id===e}),a=(0,i.Tl)("budget","Are you sure you want to delete this transaction?"),n&&(s=o.vv(n.amount,null===(r=this.accounts.find(function(t){return t.id===n.accountId}))||void 0===r?void 0:r.currency,this.settings),u="credit"===n.type?(0,i.Tl)("budget","This will decrease the account balance by {amount}.",{amount:s}):(0,i.Tl)("budget","This will increase the account balance by {amount}.",{amount:s}),a="scheduled"===n.status?n.billId?(0,i.Tl)("budget","This is the upcoming payment of a bill, not money that has moved. Deleting it removes the scheduled entry until the bill is next paid; the bill itself stays, and the account balance does not change. Are you sure?"):(0,i.Tl)("budget","This transaction is scheduled and not in the account balance yet, so the balance does not change. Are you sure you want to delete it?"):n.billId?(0,i.Tl)("budget","This transaction was auto-generated from a bill payment.")+"\n\n".concat(u,"\n\n")+(0,i.Tl)("budget","If this is a real payment, deleting it will cause your balance to diverge from your bank statement. Are you sure?"):(0,i.Tl)("budget","Are you sure you want to delete this transaction?")+"\n\n".concat(u)),null!=n&&n.reconciled&&(a+="\n\n"+(0,i.Tl)("budget","This transaction was reconciled against a bank statement. Deleting it will make past reconciliations no longer match.")),null!=n&&n.pensionContribId&&(a+="\n\n"+(0,i.Tl)("budget","This transaction funds a pension contribution. Deleting it will unlink it from that contribution (the contribution itself is kept).")),t.n=1,(0,l.ZD)(a,{destructive:!0});case 1:if(t.v){t.n=2;break}return t.a(2);case 2:return t.p=2,t.p=3,t.n=4,(0,T.n)("/apps/budget/api/transactions/".concat(e),{method:"DELETE",errorMessage:(0,i.Tl)("budget","Failed to delete transaction")});case 4:t.n=7;break;case 5:if(t.p=5,(d=t.v)instanceof T.h){t.n=6;break}throw d;case 6:return(0,c.Qg)(d.message),t.a(2);case 7:return(0,c.Te)((0,i.Tl)("budget","Transaction deleted")),t.n=8,this.app.loadTransactions();case 8:return t.n=9,this.app.loadAccounts();case 9:return t.n=10,this.app.refreshCurrentAccountView();case 10:if(""!==window.location.hash&&"#/dashboard"!==window.location.hash){t.n=11;break}return t.n=11,this.app.loadDashboard();case 11:t.n=13;break;case 12:t.p=12,h=t.v,console.error("Failed to delete transaction:",h),(0,c.Qg)((0,i.Tl)("budget","Failed to delete transaction"));case 13:return t.a(2)}},t,this,[[3,5],[2,12]])})),function(t){return N.apply(this,arguments)})},{key:"findTransactionMatches",value:(R=Se(Te().m(function t(e){var n;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/matches"));case 1:return t.a(2,t.v);case 2:throw t.p=2,n=t.v,console.error("Failed to find matches:",n),n;case 3:return t.a(2)}},t,null,[[0,2]])})),function(t){return R.apply(this,arguments)})},{key:"linkTransactions",value:(F=Se(Te().m(function t(e,n){var a;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/link/").concat(n),{method:"POST"});case 1:return t.a(2,t.v);case 2:throw t.p=2,a=t.v,console.error("Failed to link transactions:",a),a;case 3:return t.a(2)}},t,null,[[0,2]])})),function(t,e){return F.apply(this,arguments)})},{key:"unlinkTransaction",value:(O=Se(Te().m(function t(e){var n;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/link"),{method:"DELETE"});case 1:return t.a(2,t.v);case 2:throw t.p=2,n=t.v,console.error("Failed to unlink transaction:",n),n;case 3:return t.a(2)}},t,null,[[0,2]])})),function(t){return O.apply(this,arguments)})},{key:"_updateAmountStep",value:function(){var t=this,e=function(e,n){var a,r=document.getElementById(e);if(r){var i=parseInt(null===(a=document.getElementById(n))||void 0===a?void 0:a.value),s=(t.accounts||[]).find(function(t){return t.id===i}),c=(null==s?void 0:s.currency)||"USD";r.step=o.yM(c,t.settings||{})}};e("transaction-amount","transaction-account"),e("transfer-dest-amount","transfer-to-account")}},{key:"_bindTransferAmountFields",value:function(){var t=this,e=function(t,e,n){var a=document.getElementById(t);a&&!a.dataset.transferFieldsBound&&(a.dataset.transferFieldsBound="1",a.addEventListener(e,n))},n=function(){t._checkCrossCurrencyTransfer(),t._updateAmountStep()};e("transaction-account","change",n),e("transfer-to-account","change",n),e("transaction-amount","input",function(){var e=document.getElementById("transfer-dest-amount");e&&(e.dataset.userEdited=""),t._updateDestAmountFromRate()}),e("transfer-dest-amount","input",function(t){t.target.dataset.userEdited="true"})}},{key:"_checkCrossCurrencyTransfer",value:function(){var t,e,n,a,r=document.getElementById("transfer-dest-amount-wrapper");if(r){var o=parseInt(null===(t=document.getElementById("transaction-account"))||void 0===t?void 0:t.value),s=parseInt(null===(e=document.getElementById("transfer-to-account"))||void 0===e?void 0:e.value);if(o&&s){var c=null===(n=this.accounts)||void 0===n?void 0:n.find(function(t){return t.id===o}),l=null===(a=this.accounts)||void 0===a?void 0:a.find(function(t){return t.id===s});if(c&&l){var u=c.currency||"",d=l.currency||"";if(u&&d&&u!==d){r.style.display="block";var h=document.getElementById("transaction-amount-label"),g=document.getElementById("transfer-dest-amount-label");h&&(h.textContent=(0,i.Tl)("budget","Amount ({currency})",{currency:u})),g&&(g.textContent=(0,i.Tl)("budget","Destination Amount ({currency})",{currency:d})),this._updateDestAmountFromRate()}else{r.style.display="none";var p=document.getElementById("transaction-amount-label");p&&(p.textContent=(0,i.Tl)("budget","Amount"))}}else r.style.display="none"}else r.style.display="none"}}},{key:"_updateDestAmountFromRate",value:(P=Se(Te().m(function t(){var e,n,a,r,i,o,s,c,l,u,d,h,g,p;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(o=this._destRateSeq=(this._destRateSeq||0)+1,(s=document.getElementById("transfer-dest-amount-wrapper"))&&"none"!==s.style.display){t.n=1;break}return t.a(2);case 1:if((c=parseFloat(null===(e=document.getElementById("transaction-amount"))||void 0===e?void 0:e.value))&&!(c<=0)){t.n=2;break}return t.a(2);case 2:if(l=parseInt(null===(n=document.getElementById("transaction-account"))||void 0===n?void 0:n.value),u=parseInt(null===(a=document.getElementById("transfer-to-account"))||void 0===a?void 0:a.value),d=null===(r=this.accounts)||void 0===r?void 0:r.find(function(t){return t.id===l}),h=null===(i=this.accounts)||void 0===i?void 0:i.find(function(t){return t.id===u}),null!=d&&d.currency&&null!=h&&h.currency){t.n=3;break}return t.a(2);case 3:return t.p=3,t.n=4,(0,T.n)("/apps/budget/api/exchange-rates/convert?from=".concat(d.currency,"&to=").concat(h.currency,"&amount=").concat(c)).catch(function(){return null});case 4:if(g=t.v,o===this._destRateSeq){t.n=5;break}return t.a(2);case 5:g&&(p=document.getElementById("transfer-dest-amount"))&&!p.dataset.userEdited&&(p.value=g.convertedAmount),t.n=7;break;case 6:t.p=6,t.v;case 7:return t.a(2)}},t,this,[[3,6]])})),function(){return P.apply(this,arguments)})},{key:"showMatchingModal",value:(L=Se(Te().m(function t(e){var n,a,r,o,l,u,d,h,g,p,f,m,v,y,b,w=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=null===(n=this.transactions)||void 0===n?void 0:n.find(function(t){return t.id===e})){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Transaction not found")),t.a(2);case 1:return o=document.getElementById("matching-modal"),l=o.querySelector(".source-details"),u=document.getElementById("matching-loading"),d=document.getElementById("matching-empty"),h=document.getElementById("matching-list"),g=null===(a=this.accounts)||void 0===a?void 0:a.find(function(t){return t.id===r.accountId}),p=r.accountCurrency||(null==g?void 0:g.currency)||this.getPrimaryCurrency(),f="credit"===r.type?"positive":"negative",l.querySelector(".source-date").textContent=this.formatDate(r.date),l.querySelector(".source-description").textContent=r.description,l.querySelector(".source-amount").textContent=this.formatCurrency(r.amount,p),l.querySelector(".source-amount").className="source-amount ".concat(f),l.querySelector(".source-account").textContent=(null==g?void 0:g.name)||(0,i.Tl)("budget","Unknown Account"),o.dataset.transactionId=e,m=document.getElementById("matching-convert-account"),v=document.getElementById("matching-convert"),m&&v&&(y=(0,k.HB)(this.accounts).filter(function(t){return t.id!==r.accountId&&(t.currency||w.getPrimaryCurrency())===p}),m.innerHTML=y.map(function(t){return'")}).join(""),v.style.display=y.length?"":"none"),o.style.display="flex",u.style.display="flex",d.style.display="none",h.innerHTML="",t.p=2,t.n=3,this.findTransactionMatches(e);case 3:if(b=t.v,u.style.display="none",b.matches&&0!==b.matches.length){t.n=4;break}return d.style.display="flex",t.a(2);case 4:h.innerHTML=b.matches.map(function(t){var n,a=null===(n=w.accounts)||void 0===n?void 0:n.find(function(e){return e.id===t.accountId}),r=t.accountCurrency||(null==a?void 0:a.currency)||w.getPrimaryCurrency(),o="credit"===t.type?"positive":"negative";return'\n
\n ').concat(w.formatDate(t.date),'\n ').concat(s.ZD(t.description),'\n ').concat(w.formatCurrency(t.amount,r),'\n \n \n
\n ")}).join(""),t.n=6;break;case 5:t.p=5,t.v,u.style.display="none",d.style.display="flex",d.querySelector("p").textContent=(0,i.Tl)("budget","Failed to search for matches. Please try again.");case 6:return t.a(2)}},t,this,[[2,5]])})),function(t){return L.apply(this,arguments)})},{key:"handleLinkMatch",value:(B=Se(Te().m(function t(e,n){var a;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,this.linkTransactions(e,n);case 1:return(0,c.Te)((0,i.Tl)("budget","Transactions linked as transfer")),document.getElementById("matching-modal").style.display="none",t.n=2,this.app.loadTransactions();case 2:t.n=4;break;case 3:t.p=3,a=t.v,(0,c.Qg)(a.message||(0,i.Tl)("budget","Failed to link transactions"));case 4:return t.a(2)}},t,this,[[0,3]])})),function(t,e){return B.apply(this,arguments)})},{key:"handleUnlinkTransaction",value:(D=Se(Te().m(function t(e){var n;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.n=1,(0,l.ZD)((0,i.Tl)("budget","Are you sure you want to unlink this transaction from its transfer pair?"));case 1:if(t.v){t.n=2;break}return t.a(2);case 2:return t.p=2,t.n=3,this.unlinkTransaction(e);case 3:return(0,c.Te)((0,i.Tl)("budget","Transaction unlinked")),t.n=4,this.app.loadTransactions();case 4:t.n=6;break;case 5:t.p=5,n=t.v,(0,c.Qg)(n.message||(0,i.Tl)("budget","Failed to unlink transaction"));case 6:return t.a(2)}},t,this,[[2,5]])})),function(t){return D.apply(this,arguments)})},{key:"linkTransactionToBill",value:(M=Se(Te().m(function t(e){var n,a,r=this;return Te().w(function(t){for(;;)switch(t.n){case 0:if(a=null===(n=this.transactions)||void 0===n?void 0:n.find(function(t){return t.id===e})){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Transaction not found")),t.a(2);case 1:return t.n=2,(0,ee.O)("transaction-bill-".concat(e),null,Se(Te().m(function t(){var n,o,s,l,u,d;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/bills",{errorMessage:(0,i.Tl)("budget","Failed to load bills")});case 1:o=t.v,t.n=3;break;case 2:return t.p=2,u=t.v,(0,c.Qg)(u.message),t.a(2);case 3:return t.n=4,se(ie(o,a),r.settings,a);case 4:if(null!==(s=t.v)){t.n=5;break}return t.a(2);case 5:return t.p=5,t.n=6,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/bill"),{method:"POST",body:{billId:s},errorMessage:(0,i.Tl)("budget","Failed to link the transaction to the bill")});case 6:t.n=8;break;case 7:return t.p=7,d=t.v,(0,c.Qg)(d.message),t.a(2);case 8:return l=(o||[]).find(function(t){return t.id===s}),(0,c.Te)((0,i.Tl)("budget","Transaction linked to {bill}",{bill:null!==(n=null==l?void 0:l.name)&&void 0!==n?n:""})),t.n=9,r.app.loadTransactions();case 9:return t.a(2)}},t,null,[[5,7],[0,2]])})));case 2:return t.a(2)}},t,this)})),function(t){return M.apply(this,arguments)})},{key:"unlinkTransactionFromBill",value:(_=Se(Te().m(function t(e){var n,a=this;return Te().w(function(t){for(;;)switch(t.n){case 0:if(null==(n=(this.transactions||[]).find(function(t){return t.id===e}))||!n.billLatestPayment){t.n=2;break}return t.n=1,(0,l.T3)((0,i.Tl)("budget","This is the bill's latest payment. Use Mark Unpaid on the bill to undo it."),{title:(0,i.Tl)("budget","Unlink from bill")});case 1:case 5:return t.a(2);case 2:return t.n=3,(0,l.ZD)((0,i.Tl)("budget","Unlink this transaction from its bill? It stays in the account, but the bill no longer counts it as a payment."),{confirmLabel:(0,i.Tl)("budget","Unlink from bill")});case 3:if(t.v){t.n=4;break}return t.a(2);case 4:return t.n=5,(0,ee.O)("transaction-bill-".concat(e),null,Se(Te().m(function t(){var n;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/bill"),{method:"DELETE",errorMessage:(0,i.Tl)("budget","Failed to unlink the transaction from the bill")});case 1:t.n=3;break;case 2:return t.p=2,n=t.v,(0,c.Qg)(n.message),t.a(2);case 3:return(0,c.Te)((0,i.Tl)("budget","Transaction unlinked from its bill")),t.n=4,a.app.loadTransactions();case 4:return t.a(2)}},t,null,[[0,2]])})))}},t,this)})),function(t){return _.apply(this,arguments)})},{key:"showSplitModal",value:(A=Se(Te().m(function t(e){var n,a,r,o,l,u,d,h,g,p,f,m,v=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=null===(n=this.transactions)||void 0===n?void 0:n.find(function(t){return t.id===e})){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Transaction not found")),t.a(2);case 1:if(o=document.getElementById("split-modal")){t.n=2;break}return console.error("Split modal not found"),t.a(2);case 2:if(l=r.isSplit||r.is_split,u=document.getElementById("split-modal-title"),d=document.getElementById("split-transaction-info"),h=document.getElementById("splits-container"),u.textContent=l?(0,i.Tl)("budget","Edit Transaction Splits"):(0,i.Tl)("budget","Split Transaction"),o.dataset.transactionId=e,g=null===(a=this.accounts)||void 0===a?void 0:a.find(function(t){return t.id===r.accountId}),p=r.accountCurrency||(null==g?void 0:g.currency)||this.getPrimaryCurrency(),d.innerHTML='\n
\n '.concat((0,i.Tl)("budget","Date:"),"\n ").concat(this.formatDate(r.date),'\n
\n
\n ').concat((0,i.Tl)("budget","Description:"),"\n ").concat(s.ZD(r.description),'\n
\n
\n ').concat((0,i.Tl)("budget","Total Amount:"),'\n ').concat(this.formatCurrency(r.amount,p),"\n
\n "),o.dataset.totalAmount=r.amount,o.dataset.currency=p,h.innerHTML="",!l){t.n=7;break}return t.p=3,t.n=4,this.getTransactionSplits(e);case 4:t.v.forEach(function(t,e){v.addSplitRow(h,t,0===e)}),t.n=6;break;case 5:t.p=5,m=t.v,console.error("Failed to load splits:",m),this.addSplitRow(h,null,!0),this.addSplitRow(h,null,!1);case 6:t.n=8;break;case 7:this.addSplitRow(h,null,!0),this.addSplitRow(h,null,!1);case 8:(f=document.getElementById("split-unsplit-btn"))&&(f.style.display=l?"":"none",f.onclick=function(){return v.unsplitTransaction()}),this.updateSplitRemaining(),o.style.display="flex";case 9:return t.a(2)}},t,this,[[3,5]])})),function(t){return A.apply(this,arguments)})},{key:"addSplitRow",value:function(t){var e,n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=document.getElementById("split-modal"),c=t.children.length,l=parseInt(null==o?void 0:o.dataset.transactionId),u=null===(e=this.transactions)||void 0===e?void 0:e.find(function(t){return t.id===l}),d=(null==u?void 0:u.type)||"debit",h=document.createElement("div");h.className="split-row",h.dataset.index=c,h.innerHTML='\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n
\n '),h.querySelector(".split-amount").addEventListener("input",function(){return n.updateSplitRemaining()}),h.querySelector(".split-remove-btn").addEventListener("click",function(t){t.currentTarget.classList.contains("disabled")||(h.remove(),n.updateSplitRemaining())}),t.appendChild(h)}},{key:"getCategoryOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!this.categories)return"";var n="credit"===e?"income":"expense";return this.categories.filter(function(t){return t.type===n}).map(function(e){return'")}).join("")}},{key:"updateSplitRemaining",value:function(){var t=document.getElementById("split-modal"),e=parseFloat((null==t?void 0:t.dataset.totalAmount)||0),n=(null==t?void 0:t.dataset.currency)||this.getPrimaryCurrency(),a=document.getElementById("split-remaining"),r=document.getElementById("split-remaining-amount"),i=e-Array.from(document.querySelectorAll(".split-amount")).reduce(function(t,e){return t+(parseFloat(e.value)||0)},0);a&&r&&(r.textContent=this.formatCurrency(Math.abs(i),n),a.classList.toggle("over",i<-.01),a.classList.toggle("balanced",Math.abs(i)<.01))}},{key:"getTransactionSplits",value:(I=Se(Te().m(function t(e){return Te().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,(0,T.n)("/apps/budget/api/transactions/".concat(e,"/splits"));case 1:return t.a(2,t.v)}},t)})),function(t){return I.apply(this,arguments)})},{key:"saveSplits",value:(C=Se(Te().m(function t(){var e,n,a,r,o,s;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.getElementById("split-modal"),n=parseInt(null==e?void 0:e.dataset.transactionId),a=parseFloat((null==e?void 0:e.dataset.totalAmount)||0),!((r=Array.from(document.querySelectorAll(".split-row")).map(function(t){return{amount:parseFloat(t.querySelector(".split-amount").value)||0,categoryId:parseInt(t.querySelector(".split-category").value)||null,description:t.querySelector(".split-description").value.trim()||null}}).filter(function(t){return t.amount>0})).length<2)){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","A split transaction must have at least 2 parts")),t.a(2);case 1:if(o=r.reduce(function(t,e){return t+e.amount},0),!(Math.abs(o-a)>.01)){t.n=2;break}return(0,c.I9)((0,i.Tl)("budget","Split amounts ({splitTotal}) must equal transaction amount ({totalAmount})",{splitTotal:o.toFixed(2),totalAmount:a.toFixed(2)})),t.a(2);case 2:return t.p=2,t.n=3,(0,T.n)("/apps/budget/api/transactions/".concat(n,"/splits"),{method:"POST",body:{splits:r}});case 3:return this.hideSplitModal(),(0,c.Te)((0,i.Tl)("budget","Transaction split successfully")),t.n=4,this.app.loadTransactions();case 4:t.n=6;break;case 5:t.p=5,s=t.v,console.error("Failed to save splits:",s),(0,c.Qg)(s.message||(0,i.Tl)("budget","Failed to save splits"));case 6:return t.a(2)}},t,this,[[2,5]])})),function(){return C.apply(this,arguments)})},{key:"unsplitTransaction",value:(S=Se(Te().m(function t(){var e,n,a;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return e=document.getElementById("split-modal"),n=parseInt(null==e?void 0:e.dataset.transactionId),t.n=1,(0,l.ZD)((0,i.Tl)("budget","Are you sure you want to remove the split and revert to a single transaction?"));case 1:if(t.v){t.n=2;break}return t.a(2);case 2:return t.p=2,t.n=3,(0,T.n)("/apps/budget/api/transactions/".concat(n,"/splits"),{method:"DELETE"});case 3:return this.hideSplitModal(),(0,c.Te)((0,i.Tl)("budget","Transaction unsplit successfully")),t.n=4,this.app.loadTransactions();case 4:t.n=6;break;case 5:t.p=5,a=t.v,console.error("Failed to unsplit transaction:",a),(0,c.Qg)(a.message||(0,i.Tl)("budget","Failed to unsplit transaction"));case 6:return t.a(2)}},t,this,[[2,5]])})),function(){return S.apply(this,arguments)})},{key:"hideSplitModal",value:function(){var t=document.getElementById("split-modal");t&&(t.style.display="none")}},{key:"scanForMatches",value:(x=Se(Te().m(function t(){var e,n=arguments;return Te().w(function(t){for(;;)switch(t.n){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:3,t.n=1,(0,T.n)("/apps/budget/api/transactions/scan-matches?dateWindow=".concat(e));case 1:return t.a(2,t.v)}},t)})),function(){return x.apply(this,arguments)})},{key:"bulkLinkPairs",value:(E=Se(Te().m(function t(e){return Te().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,(0,T.n)("/apps/budget/api/transactions/bulk-link",{method:"POST",body:{pairs:e}});case 1:return t.a(2,t.v)}},t)})),function(t){return E.apply(this,arguments)})},{key:"showBulkMatchModal",value:function(){var t=document.getElementById("bulk-match-modal"),e=document.getElementById("bulk-match-config"),n=document.getElementById("bulk-match-loading"),a=document.getElementById("bulk-match-results"),r=document.getElementById("bulk-match-empty"),o=document.getElementById("confirm-selected-btn");e.style.display="block",n.style.display="none",a.style.display="none",r.style.display="none",o&&(o.style.display="none"),document.getElementById("auto-matched-section").style.display="none",document.getElementById("needs-review-section").style.display="none",document.getElementById("auto-matched-list").innerHTML="",document.getElementById("needs-review-list").innerHTML="",e.innerHTML='\n
\n \n
\n \n 3\n
\n

').concat((0,i.Tl)("budget","Matches must be within this many days of each other. Use 0 for exact date match."),'

\n
\n
\n \n
\n \n \n
\n
\n ");var s=document.getElementById("match-date-window"),c=document.getElementById("match-date-window-value");s.addEventListener("input",function(){c.textContent=s.value}),this._bulkMatchDirty=!1,t.style.display="flex"}},{key:"startScan",value:(y=Se(Te().m(function t(){var e,n,a,r,o,s,c,l,u,d,h,g;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=document.getElementById("bulk-match-config"),a=document.getElementById("bulk-match-loading"),r=parseInt(document.getElementById("match-date-window").value)||3,o=(null===(e=document.querySelector('input[name="match-mode"]:checked'))||void 0===e?void 0:e.value)||"auto",n.style.display="none",(s=document.getElementById("start-scan-btn"))&&(s.style.display="none"),a.style.display="flex",a.querySelector("p").textContent=(0,i.Tl)("budget","Scanning for matching transactions..."),t.p=1,t.n=2,this.scanForMatches(r);case 2:if(c=t.v,a.style.display="none",0!==c.stats.totalCandidates){t.n=3;break}return l=document.getElementById("bulk-match-results"),u=document.getElementById("bulk-match-empty"),l.style.display="block",u.style.display="flex",u.querySelector("p").textContent=(0,i.Tl)("budget","No matching transactions found."),t.a(2);case 3:if("auto"!==o){t.n=5;break}return t.n=4,this.handleAutoMode(c);case 4:t.n=6;break;case 5:this.handleReviewMode(c);case 6:t.n=8;break;case 7:t.p=7,g=t.v,a.style.display="none",d=document.getElementById("bulk-match-results"),h=document.getElementById("bulk-match-empty"),d.style.display="block",h.style.display="flex",h.querySelector("p").textContent=g.message||(0,i.Tl)("budget","Failed to scan for matches. Please try again.");case 8:return t.a(2)}},t,this,[[1,7]])})),function(){return y.apply(this,arguments)})},{key:"handleAutoMode",value:(v=Se(Te().m(function t(e){var n,a,r,o,s,c,l,u,d,h,g,p=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=document.getElementById("bulk-match-loading"),a=document.getElementById("bulk-match-results"),r=document.getElementById("auto-matched-section"),o=document.getElementById("needs-review-section"),s=document.getElementById("auto-matched-list"),c=document.getElementById("needs-review-list"),l=e.candidates.filter(function(t){return 1===t.matchCount}),u=e.candidates.filter(function(t){return t.matchCount>1}),d=0,!(l.length>0)){t.n=5;break}return n.style.display="flex",n.querySelector("p").textContent=(0,i.zw)("budget","Linking %n exact match pair...","Linking %n exact match pairs...",l.length),h=l.map(function(t){return{sourceId:parseInt(t.transaction.id),targetId:parseInt(t.matches[0].id)}}),t.p=1,t.n=2,this.bulkLinkPairs(h);case 2:g=t.v,d=g.stats.linkedCount,this._bulkMatchDirty=!0,t.n=4;break;case 3:return t.p=3,t.v,n.style.display="none",this.handleReviewMode(e),t.a(2);case 4:n.style.display="none";case 5:a.style.display="block",document.getElementById("auto-matched-count").textContent=d,document.getElementById("needs-review-count").textContent=u.length,d>0&&(r.style.display="block",s.innerHTML=l.map(function(t){return p.renderAutoMatchedPair({transaction:t.transaction,linkedTo:t.matches[0]})}).join("")),u.length>0&&(o.style.display="block",c.innerHTML=u.map(function(t,e){return p.renderNeedsReviewItem(t,e)}).join("")),0===d&&0===u.length&&(document.getElementById("bulk-match-empty").style.display="flex");case 6:return t.a(2)}},t,this,[[1,3]])})),function(t){return v.apply(this,arguments)})},{key:"handleReviewMode",value:function(t){var e=this,n=document.getElementById("bulk-match-results"),a=document.getElementById("auto-matched-section"),r=document.getElementById("needs-review-section"),o=document.getElementById("auto-matched-list"),s=document.getElementById("needs-review-list"),c=document.getElementById("confirm-selected-btn");n.style.display="block";var l=t.candidates.filter(function(t){return 1===t.matchCount}),u=t.candidates.filter(function(t){return t.matchCount>1});document.getElementById("auto-matched-count").textContent=l.length,document.getElementById("needs-review-count").textContent=u.length,l.length>0&&(a.style.display="block",a.querySelector("h4").textContent=(0,i.Tl)("budget","Exact Matches"),a.querySelector(".section-hint").textContent=(0,i.Tl)("budget","These transactions have exactly one match. Uncheck any you don't want to link."),o.innerHTML=l.map(function(t,n){return e.renderReviewSingleMatch(t,n)}).join("")),u.length>0&&(r.style.display="block",s.innerHTML=u.map(function(t,n){return e.renderNeedsReviewItem(t,n)}).join("")),c&&(c.style.display="inline-block")}},{key:"renderAutoMatchedPair",value:function(t){var e=t.transaction,n=t.linkedTo,a=e.account_currency||this.getPrimaryCurrency(),r=n.accountCurrency||this.getPrimaryCurrency(),o="credit"===e.type?"positive":"negative",c="credit"===n.type?"positive":"negative";return'\n
\n
\n ').concat(this.formatDate(e.date),'\n ').concat(s.ZD(e.description),'\n
\n ').concat(this.formatCurrency(e.amount,a),'\n \n
\n
\n ↔\n
\n ').concat(this.formatDate(n.date),'\n ').concat(s.ZD(n.description),'\n
\n ').concat(this.formatCurrency(n.amount,r),'\n \n
\n
\n \n
\n ")}},{key:"renderReviewSingleMatch",value:function(t,e){var n=t.transaction,a=t.matches[0],r=n.account_currency||this.getPrimaryCurrency(),i=a.accountCurrency||this.getPrimaryCurrency(),o="credit"===n.type?"positive":"negative",c="credit"===a.type?"positive":"negative";return'\n
\n \n
\n
\n ').concat(this.formatDate(n.date),'\n ').concat(s.ZD(n.description),'\n
\n ').concat(this.formatCurrency(n.amount,r),'\n \n
\n
\n ↔\n
\n ').concat(this.formatDate(a.date),'\n ').concat(s.ZD(a.description),'\n
\n ').concat(this.formatCurrency(a.amount,i),'\n \n
\n
\n
\n
\n ")}},{key:"renderNeedsReviewItem",value:function(t,e){var n=this,a=t.transaction,r=a.account_currency||this.getPrimaryCurrency(),o="credit"===a.type?"positive":"negative",c=t.matches.map(function(t){var a=t.accountCurrency||n.getPrimaryCurrency(),r="credit"===t.type?"positive":"negative";return'\n \n ")}).join("");return'\n
\n
\n
\n ').concat(this.formatDate(a.date),'\n ').concat(s.ZD(a.description),'\n
\n ').concat(this.formatCurrency(a.amount,r),'\n \n
\n
\n
\n
').concat((0,i.zw)("budget","Select a match (%n option):","Select a match (%n options):",t.matchCount),'
\n
\n ').concat(c,'\n
\n \n
\n ")}},{key:"handleConfirmSelected",value:(m=Se(Te().m(function t(){var e,n,a,r,o,s,l,u,d;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=[],document.querySelectorAll(".review-single-check:checked").forEach(function(t){e.push({sourceId:parseInt(t.dataset.sourceId),targetId:parseInt(t.dataset.targetId)})}),document.querySelectorAll(".bulk-review-item").forEach(function(t){var n=t.querySelector('input[type="radio"]:checked');n&&e.push({sourceId:parseInt(t.dataset.txId),targetId:parseInt(n.value)})}),0!==e.length){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","No matches selected")),t.a(2);case 1:return(n=document.getElementById("confirm-selected-btn"))&&(n.disabled=!0,n.textContent=(0,i.Tl)("budget","Linking...")),t.p=2,t.n=3,this.bulkLinkPairs(e);case 3:a=t.v,this._bulkMatchDirty=!0,r=(0,i.zw)("budget","Linked %n pair","Linked %n pairs",a.stats.linkedCount),a.stats.failedCount>0&&(r+=", "+(0,i.zw)("budget","%n failed","%n failed",a.stats.failedCount)),(0,c.Te)(r),o=document.getElementById("auto-matched-section"),s=document.getElementById("auto-matched-list"),l=document.getElementById("needs-review-section"),a.stats.linkedCount>0&&(o.style.display="block",o.querySelector("h4").textContent=(0,i.Tl)("budget","Linked Pairs"),o.querySelector(".section-hint").textContent=(0,i.Tl)("budget","These transactions have been linked. Click Undo to unlink a pair."),u=[],document.querySelectorAll(".review-single-match").forEach(function(t){var e=t.dataset.sourceId,n=t.dataset.targetId;if(a.linked.some(function(t){return t.sourceId==e&&t.targetId==n})){var r=t.querySelector(".pair-content");r&&u.push('\n
\n ').concat(r.innerHTML,'\n \n
\n "))}}),s.innerHTML=u.join(""),document.getElementById("auto-matched-count").textContent=a.stats.linkedCount),l.style.display="none",n&&(n.style.display="none"),document.getElementById("needs-review-count").textContent="0",t.n=5;break;case 4:t.p=4,d=t.v,(0,c.Qg)(d.message||(0,i.Tl)("budget","Failed to link transactions"));case 5:return t.p=5,n&&(n.disabled=!1,n.textContent=(0,i.Tl)("budget","Confirm Selected")),t.f(5);case 6:return t.a(2)}},t,this,[[2,4,5,6]])})),function(){return m.apply(this,arguments)})},{key:"handleBulkMatchUndo",value:(f=Se(Te().m(function t(e){var n,a,r,o;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,this.unlinkTransaction(e);case 1:this._bulkMatchDirty=!0,(n=document.querySelector('.bulk-match-pair[data-tx-id="'.concat(e,'"]')))&&n.remove(),a=document.getElementById("auto-matched-count"),r=parseInt(a.textContent),a.textContent=r-1,0===document.getElementById("auto-matched-list").children.length&&(document.getElementById("auto-matched-section").style.display="none"),(0,c.Te)((0,i.Tl)("budget","Match undone")),t.n=3;break;case 2:t.p=2,o=t.v,(0,c.Qg)(o.message||(0,i.Tl)("budget","Failed to undo match"));case 3:return t.a(2)}},t,this,[[0,2]])})),function(t){return f.apply(this,arguments)})},{key:"handleBulkMatchLink",value:(p=Se(Te().m(function t(e,n){var a,r,o,s,l,u,d,h;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(a=document.querySelector('.bulk-review-item[data-index="'.concat(n,'"]')),r=a.querySelector('input[name="review-match-'.concat(n,'"]:checked'))){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Please select a match first")),t.a(2);case 1:return o=parseInt(r.value),t.p=2,t.n=3,this.linkTransactions(e,o);case 3:this._bulkMatchDirty=!0,a.remove(),s=document.getElementById("needs-review-count"),l=document.getElementById("auto-matched-count"),u=parseInt(s.textContent),d=parseInt(l.textContent),s.textContent=u-1,l.textContent=d+1,0===document.getElementById("needs-review-list").children.length&&(document.getElementById("needs-review-section").style.display="none"),(0,c.Te)((0,i.Tl)("budget","Transactions linked")),t.n=5;break;case 4:t.p=4,h=t.v,(0,c.Qg)(h.message||(0,i.Tl)("budget","Failed to link transactions"));case 5:return t.a(2)}},t,this,[[2,4]])})),function(t,e){return p.apply(this,arguments)})},{key:"setupInlineEditingListeners",value:function(){var t=this,e=document.getElementById("transactions-table");e&&(e.addEventListener("click",function(e){if(window.matchMedia(Le).matches){var n=e.target.closest("tr.transaction-row");n&&!e.target.closest("input, button, a, select, .linked-indicator, .cell-editing, .editing")&&(e.preventDefault(),e.stopPropagation(),n.dataset.readOnly||t.editTransaction(parseInt(n.dataset.transactionId,10)))}},!0),e.addEventListener("click",function(e){var n=e.target.closest(".editable-cell");if(n&&!n.classList.contains("editing")){if("checkbox"===e.target.type)return;if(e.target.closest(".linked-indicator"))return;t.startInlineEdit(n)}}),document.addEventListener("click",function(e){e.target.closest(".editable-cell")||e.target.closest(".category-autocomplete-dropdown")||t.closeAllInlineEditors()}))}},{key:"startInlineEdit",value:function(t){this.closeAllInlineEditors();var e=t.dataset.field,n=t.dataset.value,a=parseInt(t.dataset.transactionId),r=this.transactions.find(function(t){return t.id===a});if(r)switch(t.classList.add("editing"),t.removeAttribute("title"),this.currentEditingCell=t,this.originalValue=n,e){case"date":this.createDateEditor(t,n);break;case"description":this.createTextEditor(t,n,"description");break;case"categoryId":this.createCategoryEditor(t,n,r);break;case"amount":this.createAmountEditor(t,r);break;case"accountId":this.createAccountEditor(t,n);break;case"tags":this.createTagsEditor(t,r);break;default:this.createTextEditor(t,n,e)}}},{key:"createDateEditor",value:function(t,e){var n,a=this,r=document.createElement("input");r.type="text",r.className="inline-edit-input",t.innerHTML="",t.appendChild(r);var i=(null===(n=this.app.settings)||void 0===n?void 0:n.date_format)||"Y-m-d",o=(0,ge.A)(r,{dateFormat:i,defaultDate:e,allowInput:!0,disableMobile:!0}),s=function(){return o.selectedDates.length>0?o.formatDate(o.selectedDates[0],"Y-m-d"):e};r.addEventListener("keydown",function(e){if("Escape"===e.key)o.destroy(),a.cancelInlineEdit(t);else if("Enter"===e.key){e.preventDefault();var n=s();o.destroy(),a.saveInlineEdit(t,"date",n)}}),r.addEventListener("blur",function(){setTimeout(function(){if(t.classList.contains("editing")&&!o.isOpen){var e=s();o.destroy(),a.saveInlineEdit(t,"date",e)}},200)}),r.focus()}},{key:"createTextEditor",value:function(t,e,n){var a=document.createElement("input");a.type="text",a.className="inline-edit-input",a.value=e||"",a.placeholder="description"===n?(0,i.Tl)("budget","Enter description..."):"",this.setupEditorEvents(a,t,n),t.innerHTML="",t.appendChild(a),a.focus(),a.select()}},{key:"createAmountEditor",value:function(t,e){var n=(0,pe.XV)(document.createElement("input"));n.className="inline-edit-input",n.value="debit"===e.type?-Math.abs(e.amount):Math.abs(e.amount),n.dataset.type=e.type,this.setupEditorEvents(n,t,"amount"),t.innerHTML="",t.appendChild(n),n.focus(),n.select()}},{key:"createCategoryEditor",value:function(t,e){var n=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=document.createElement("div");r.className="category-autocomplete";var o=document.createElement("input");o.type="text",o.className="category-autocomplete-input",o.placeholder=(0,i.Tl)("budget","Type to search...");var c=a?(this.accounts||[]).find(function(t){return t.id===a.accountId}):null,l=(0,k.hM)(this.categories,[c],[e]),u=null;l?u=(0,k.QN)(l):this.categoryTree&&this.categoryTree.length>0?u=this.categoryTree:this.allCategories&&this.allCategories.length>0?u=this.allCategories:this.categories&&this.categories.length>0&&(u=this.categories);var d=u?this.getFlatCategoryList(u):[],h=d.find(function(t){return t.id===parseInt(e)});o.value=h?h.name:e?(null==a?void 0:a.categoryName)||(0,w.pC)(null):"",o.dataset.categoryId=e||"";var g=document.createElement("div");g.className="category-autocomplete-dropdown",g.style.display="none",r.appendChild(o),r.appendChild(g);var p=ue(g,r,{onHidden:function(){return v(function(){return n.cancelInlineEdit(t)})}}),f=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=t?d.filter(function(e){return e.name.toLowerCase().includes(t.toLowerCase())}):d;0===e.length?g.innerHTML='
'.concat((0,i.Tl)("budget","No categories found"),"
"):g.innerHTML=e.map(function(t){return'\n
\n ').concat(s.ZD(t.prefix)).concat(s.ZD(t.name),"\n
\n ")}).join(""),g.innerHTML='\n
\n ').concat((0,i.Tl)("budget","Uncategorized"),"\n
\n ")+g.innerHTML,g.style.display="block",p()};o.addEventListener("focus",function(){return f(o.value)}),o.addEventListener("input",function(){return f(o.value)});var m=!1,v=function(t){m||(m=!0,g.style.display="none",t())};g.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation();var a=e.target.closest(".category-autocomplete-item");a&&(o.dataset.categoryId=a.dataset.categoryId,o.value=a.dataset.categoryName,v(function(){return n.saveInlineEdit(t,"categoryId",a.dataset.categoryId)}))}),g.addEventListener("click",function(t){t.stopPropagation()}),o.addEventListener("keydown",function(e){"Escape"===e.key?v(function(){return n.cancelInlineEdit(t)}):"Enter"===e.key?(e.preventDefault(),v(function(){return n.saveInlineEdit(t,"categoryId",o.dataset.categoryId)})):"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),n.navigateCategoryDropdown(g,"ArrowDown"===e.key?1:-1,o))}),o.addEventListener("blur",function(){setTimeout(function(){r.contains(document.activeElement)||v(function(){o.dataset.categoryId!==(e||"")?n.saveInlineEdit(t,"categoryId",o.dataset.categoryId):n.cancelInlineEdit(t)})},200)}),t.innerHTML="",t.appendChild(r),o.focus(),o.select(),f()}},{key:"navigateCategoryDropdown",value:function(t,e,n){var a=t.querySelectorAll(".category-autocomplete-item");if(0!==a.length){var r=t.querySelector(".category-autocomplete-item.highlighted"),i=0;r?(r.classList.remove("highlighted"),(i=Array.from(a).indexOf(r)+e)<0&&(i=a.length-1),i>=a.length&&(i=0)):i=1===e?0:a.length-1,a[i].classList.add("highlighted"),a[i].scrollIntoView({block:"nearest"}),n.dataset.categoryId=a[i].dataset.categoryId}}},{key:"createAccountEditor",value:function(t,e){var n=this,a=document.createElement("select");a.className="inline-edit-select",(0,k.ig)(this.accounts,e).forEach(function(t){var n=document.createElement("option");n.value=t.id,n.textContent=(0,k.Jo)(t),n.selected=t.id===parseInt(e),a.appendChild(n)}),a.addEventListener("keydown",function(e){"Escape"===e.key?n.cancelInlineEdit(t):"Enter"===e.key&&(e.preventDefault(),n.saveInlineEdit(t,"accountId",a.value))}),a.addEventListener("change",function(){n.saveInlineEdit(t,"accountId",a.value)}),a.addEventListener("blur",function(){setTimeout(function(){t.classList.contains("editing")&&n.cancelInlineEdit(t)},100)}),t.innerHTML="",t.appendChild(a),a.focus()}},{key:"createTagsEditor",value:(h=Se(Te().m(function t(e,n){var a,r,o,c,l,u,d,h,g,p,f,m,v,y,b,w,k,E,x,S,C,I,A,_,M,D,B,L=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return a=n.categoryId,e.innerHTML=''.concat((0,i.Tl)("budget","Loading..."),""),t.p=1,o=null===(r=this.accounts)||void 0===r?void 0:r.find(function(t){return t.id===n.accountId}),c=!(null==o||!o._shared),t.n=2,Promise.all([c?Promise.resolve([]):(0,T.n)("/apps/budget/api/tags/global").catch(function(){return[]}),a?this.loadTagSetsForCategory(a):Promise.resolve([])]);case 2:if(l=t.v,u=Ee(l,2),d=u[0],h=u[1],0!==(g=d||[]).length||0!==h.length){t.n=3;break}return e.innerHTML=''.concat((0,i.Tl)("budget","No tags"),""),setTimeout(function(){return L.cancelInlineEdit(e)},1500),t.a(2);case 3:p=this.app.getTransactionTagIds(n.id),f=new Set(p),m=new Set(p),v=null,y=!1,(b=document.createElement("div")).className="tags-autocomplete",(w=document.createElement("input")).type="text",w.className="tags-autocomplete-input",w.placeholder=(0,i.Tl)("budget","Type to filter tags..."),(k=document.createElement("div")).className="tags-autocomplete-dropdown",k.style.display="none",b.appendChild(w),b.appendChild(k),E=ue(k,b,{onHidden:function(){return D(!1)}}),x=[],g.length>0&&g.forEach(function(t){x.push({id:t.id,name:t.name,color:t.color,tagSetName:(0,i.Tl)("budget","Tags"),tagSetId:"global"})}),h.forEach(function(t){t.tags.forEach(function(e){x.push({id:e.id,name:e.name,color:e.color,tagSetName:t.name,tagSetId:t.id})})}),S=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=t?x.filter(function(e){return e.name.toLowerCase().includes(t.toLowerCase())||e.tagSetName.toLowerCase().includes(t.toLowerCase())}):x,n={};e.forEach(function(t){n[t.tagSetId]||(n[t.tagSetId]={name:t.tagSetName,tags:[]}),n[t.tagSetId].tags.push(t)});var a="";Object.values(n).forEach(function(t){a+='
'.concat(s.ZD(t.name),"
"),t.tags.forEach(function(t){var e=f.has(t.id),n=t.id===v;a+='\n
\n \n ').concat(s.ZD(t.name),'\n \n ').concat(e?"✓":"","\n
\n ")})}),k.innerHTML=a||'
'.concat((0,i.Tl)("budget","No tags found"),"
"),k.style.display="block",E()},w.addEventListener("focus",function(){return S(w.value)}),w.addEventListener("input",function(){return S(w.value)}),C=function(t){var e=x.find(function(e){return e.id===t});e&&("global"!==e.tagSetId&&x.filter(function(t){return t.tagSetId===e.tagSetId}).forEach(function(e){e.id!==t&&f.delete(e.id)}),f.has(t)?f.delete(t):f.add(t),t===v&&(y=!0))},I=function(){return null===v?null:k.querySelector('.tags-autocomplete-item[data-tag-id="'.concat(v,'"]'))},A=function(t){var e=ve(k.querySelectorAll(".tags-autocomplete-item"));if(0!==e.length){var n=e.indexOf(I()),a=n<0?1===t?0:e.length-1:(n+t+e.length)%e.length;e.forEach(function(t){return t.classList.remove("highlighted")}),e[a].classList.add("highlighted"),e[a].scrollIntoView({block:"nearest"}),v=parseInt(e[a].dataset.tagId,10),y=!1}},_=function(){return f.size===m.size&&ve(f).every(function(t){return m.has(t)})},M=!1,D=function(t){M||(M=!0,k.style.display="none",t&&!_()?L.saveTagsFromEditor(e,f,n.id):L.cancelInlineEdit(e))},k.addEventListener("mousedown",function(t){t.preventDefault(),t.stopPropagation();var e=t.target.closest(".tags-autocomplete-item");e&&(C(parseInt(e.dataset.tagId,10)),S(w.value))}),k.addEventListener("click",function(t){t.stopPropagation()}),w.addEventListener("keydown",function(t){"Escape"===t.key?D(!1):"Enter"===t.key?(t.preventDefault(),!I()||y||f.has(v)||C(v),D(!0)):"ArrowDown"===t.key||"ArrowUp"===t.key?(t.preventDefault(),A("ArrowDown"===t.key?1:-1)):" "===t.key&&I()&&(t.preventDefault(),C(v),S(w.value))}),w.addEventListener("blur",function(){setTimeout(function(){return D(!0)},200)}),e.innerHTML="",e.appendChild(b),w.focus(),S(),t.n=5;break;case 4:t.p=4,B=t.v,console.error("Failed to load tag sets:",B),e.innerHTML=''.concat((0,i.Tl)("budget","Error loading tags"),""),setTimeout(function(){return L.cancelInlineEdit(e)},1500);case 5:return t.a(2)}},t,this,[[1,4]])})),function(t,e){return h.apply(this,arguments)})},{key:"saveTagsFromEditor",value:(d=Se(Te().m(function t(e,n,a){var r,o,s;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return r=Array.from(n),t.p=1,t.n=2,(0,T.n)("/apps/budget/api/transactions/".concat(a,"/tags"),{method:"PUT",body:{tagIds:r},errorMessage:(0,i.Tl)("budget","Failed to update tags")});case 2:return t.n=3,this.app.loadTransactionTags(a);case 3:this.cancelInlineEdit(e),(o=e.querySelector(".cell-display"))&&(o.innerHTML=this.app.renderTransactionTags(a)),t.n=5;break;case 4:t.p=4,s=t.v,console.error("Failed to save tags:",s),(0,c.Qg)(s.message||(0,i.Tl)("budget","Failed to update tags")),this.cancelInlineEdit(e);case 5:return t.a(2)}},t,this,[[1,4]])})),function(t,e,n){return d.apply(this,arguments)})},{key:"loadTagSetsForCategory",value:(r=Se(Te().m(function t(e){var n;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)("/apps/budget/api/tag-sets?categoryId=".concat(e));case 1:return t.a(2,t.v);case 2:return t.p=2,n=t.v,console.error("Failed to load tag sets:",n),t.a(2,[])}},t,null,[[0,2]])})),function(t){return r.apply(this,arguments)})},{key:"setupEditorEvents",value:function(t,e,n){var a=this;t.addEventListener("keydown",function(r){if("Escape"===r.key)a.cancelInlineEdit(e);else if("Enter"===r.key)if(r.preventDefault(),"amount"===n){var i=parseFloat(t.value)||0,o=i<0?"debit":"credit";a.saveInlineEdit(e,n,Math.abs(i).toString(),{type:o})}else a.saveInlineEdit(e,n,t.value)}),t.addEventListener("blur",function(r){setTimeout(function(){if(e.isConnected&&e.classList.contains("editing"))if("amount"===n){var r=parseFloat(t.value)||0,i=r<0?"debit":"credit";a.saveInlineEdit(e,n,Math.abs(r).toString(),{type:i})}else a.saveInlineEdit(e,n,t.value)},100)})}},{key:"saveInlineEdit",value:(a=Se(Te().m(function t(e,n,a){var r,i=arguments;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=i.length>3&&void 0!==i[3]?i[3]:{},"true"!==e.dataset.inlineSaving){t.n=1;break}return t.a(2);case 1:return e.dataset.inlineSaving="true",t.p=2,t.n=3,this._saveInlineEdit(e,n,a,r);case 3:return t.a(2,t.v);case 4:return t.p=4,delete e.dataset.inlineSaving,t.f(4);case 5:return t.a(2)}},t,this,[[2,,4,5]])})),function(t,e,n){return a.apply(this,arguments)})},{key:"_saveInlineEdit",value:(n=Se(Te().m(function t(e,n,a){var r,o,s,u,d,h,g,p,f,m,v=arguments;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=v.length>3&&void 0!==v[3]?v[3]:{},o=parseInt(e.dataset.transactionId),s=this.transactions.find(function(t){return t.id===o})){t.n=1;break}return this.cancelInlineEdit(e),t.a(2);case 1:if(!s.reconciled||!["amount","date","accountId"].includes(n)){t.n=3;break}return t.n=2,(0,l.ZD)((0,i.Tl)("budget","This transaction was reconciled against a bank statement. Changing its amount, type, account or date will make past reconciliations no longer match. Continue?"));case 2:if(t.v){t.n=3;break}return this.cancelInlineEdit(e),t.a(2);case 3:if(u=!1,"amount"===n?(d=parseFloat(a),h=r.type||s.type,u=d!==s.amount||h!==s.type):"categoryId"===n?(g=""===a?null:parseInt(a),u=g!==s.categoryId):u="accountId"===n?parseInt(a)!==s.accountId:a!==(s[n]||""),u){t.n=4;break}return this.cancelInlineEdit(e),t.a(2);case 4:return e.classList.add("cell-saving"),p={},"amount"===n?(p.amount=parseFloat(a),r.type&&(p.type=r.type)):"categoryId"===n?p.categoryId=""===a?null:parseInt(a):"accountId"===n?p.accountId=parseInt(a):p[n]=a,t.p=5,t.n=6,(0,T.n)("/apps/budget/api/transactions/".concat(o),{method:"PUT",body:p,errorMessage:(0,i.Tl)("budget","Failed to update transaction")});case 6:if(f=t.v,Object.assign(s,f),"accountId"!==n){t.n=7;break}return t.n=7,this.app.loadAccounts();case 7:this.app.renderEnhancedTransactionsTable(),this.app.applyColumnVisibility(),(0,c.Te)((0,i.Tl)("budget","Transaction updated")),t.n=9;break;case 8:t.p=8,m=t.v,console.error("Failed to save inline edit:",m),(0,c.Qg)(m.message||(0,i.Tl)("budget","Failed to update transaction")),this.cancelInlineEdit(e);case 9:return t.a(2)}},t,this,[[5,8]])})),function(t,e,a){return n.apply(this,arguments)})},{key:"cancelInlineEdit",value:function(t){t&&t.classList.contains("editing")&&(this.app.renderEnhancedTransactionsTable(),this.app.applyColumnVisibility(),this.currentEditingCell=null,this.originalValue=null)}},{key:"closeAllInlineEditors",value:function(){var t=this;document.querySelectorAll(".editable-cell.editing").forEach(function(e){t.cancelInlineEdit(e)})}},{key:"getFlatCategoryList",value:function(){var t,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=[],a=me((arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||this.categories||[]);try{for(a.s();!(t=a.n()).done;){var r=t.value;n.push({id:r.id,name:r.name,prefix:e}),r.children&&r.children.length>0&&(n=n.concat(this.getFlatCategoryList(r.children,e+" ")))}}catch(t){a.e(t)}finally{a.f()}return n}},{key:"showDuplicatesModal",value:(e=Se(Te().m(function t(){var e,n,a,r,o,s,c=this;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return(e=document.getElementById("duplicates-modal"))&&e.remove(),(n=document.createElement("div")).id="duplicates-modal",n.className="budget-modal-overlay",n.innerHTML='\n
\n
\n

'.concat((0,i.Tl)("budget","Find Duplicate Transactions"),'

\n \n
\n
\n
\n \n

').concat((0,i.Tl)("budget","Scanning for duplicates..."),'

\n
\n \n
\n
\n '),document.body.appendChild(n),n.querySelector(".close-btn").addEventListener("click",function(){n.remove(),c._duplicatesDirty&&(c.app.loadTransactions(),c.app.loadAccounts())}),n.addEventListener("click",function(t){t.target===n&&(n.remove(),c._duplicatesDirty&&(c.app.loadTransactions(),c.app.loadAccounts()))}),this._duplicatesDirty=!1,t.p=1,t.n=2,(0,T.n)("/apps/budget/api/transactions/duplicates");case 2:if(a=t.v,document.getElementById("duplicates-loading").style.display="none",(r=document.getElementById("duplicates-content")).style.display="block",a.groups&&0!==a.groups.length){t.n=3;break}return r.innerHTML='

'.concat((0,i.Tl)("budget","No duplicate transactions found."),"

"),t.a(2);case 3:this.renderDuplicateGroups(r,a.groups),t.n=5;break;case 4:t.p=4,s=t.v,console.error("Failed to find duplicates:",s),document.getElementById("duplicates-loading").style.display="none",(o=document.getElementById("duplicates-content")).style.display="block",o.innerHTML='

'.concat((0,i.Tl)("budget","Failed to scan for duplicates. Please try again."),"

");case 5:return t.a(2)}},t,this,[[1,4]])})),function(){return e.apply(this,arguments)})},{key:"renderDuplicateGroups",value:function(t,e){var n=this,a=e.reduce(function(t,e){return t+e.length-1},0),r='\n
\n

'.concat((0,i.Tl)("budget","Found {groupCount} group(s) with {duplicateCount} suspected duplicate(s). The oldest transaction in each group is kept by default. Review and adjust the selection, then delete the checked items.",{groupCount:e.length,duplicateCount:a}),'

\n
\n \n \n
\n
\n
\n ');e.forEach(function(t,e){var a=t[0],c=o.vv(a.amount,a.currency,n.settings);r+='\n
\n
\n '.concat(s.ZD(a.description)||(0,i.Tl)("budget","(no description)"),"\n — ").concat(c," (").concat(s.ZD(a.type),")\n — ").concat(s.ZD(a.accountName),'\n
\n
\n '),t.forEach(function(t,a){var c=a>0,l=c?"checked":"",u=c?"":''.concat((0,i.Tl)("budget","keep"),""),d=t.billId?''.concat((0,i.Tl)("budget","bill"),""):"",h="scheduled"===t.status?''.concat((0,i.Tl)("budget","scheduled"),""):"pending"===t.status?''.concat((0,i.Tl)("budget","pending"),""):"";r+='\n \n ")}),r+="
"}),r+="
",t.innerHTML=r,t.addEventListener("change",function(t){t.target.classList.contains("duplicate-checkbox")&&n.updateDuplicatesSelectedCount()}),document.getElementById("duplicates-delete-btn").addEventListener("click",function(){n.deleteDuplicates()}),document.getElementById("duplicates-select-none-btn").addEventListener("click",function(){t.querySelectorAll(".duplicate-checkbox").forEach(function(t){return t.checked=!1}),n.updateDuplicatesSelectedCount()})}},{key:"updateDuplicatesSelectedCount",value:function(){var t=document.querySelectorAll(".duplicate-checkbox:checked"),e=document.getElementById("duplicates-selected-count"),n=document.getElementById("duplicates-delete-btn");e&&(e.textContent=t.length),n&&(n.disabled=0===t.length)}},{key:"deleteDuplicates",value:(t=Se(Te().m(function t(){var e,n,a,r,o,s,u;return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.querySelectorAll(".duplicate-checkbox:checked"),0!==(n=Array.from(e).map(function(t){return parseInt(t.dataset.txId)})).length){t.n=1;break}return t.a(2);case 1:return a=Array.from(e).filter(function(t){var e=t.closest(".duplicate-item");return e&&e.querySelector(".bill-badge")}).length,r=(0,i.zw)("budget","Delete %n suspected duplicate transaction? This cannot be undone.","Delete %n suspected duplicate transactions? This cannot be undone.",n.length),a>0&&(r+="\n\n"+(0,i.zw)("budget","%n of these was generated from bill payments. Make sure they are truly duplicates before deleting.","%n of these were generated from bill payments. Make sure they are truly duplicates before deleting.",a)),t.n=2,(0,l.ZD)(r,{destructive:!0});case 2:if(t.v){t.n=3;break}return t.a(2);case 3:return(o=document.getElementById("duplicates-delete-btn")).disabled=!0,o.textContent=(0,i.Tl)("budget","Deleting..."),t.p=4,t.n=5,(0,T.n)("/apps/budget/api/transactions/bulk-delete",{method:"POST",body:{ids:n}});case 5:(s=t.v).success>0&&((0,c.Te)((0,i.zw)("budget","Deleted %n duplicate transaction","Deleted %n duplicate transactions",s.success)),this._duplicatesDirty=!0,e.forEach(function(t){var e=t.closest(".duplicate-item");e&&e.remove()}),document.querySelectorAll(".duplicate-group").forEach(function(t){t.querySelectorAll(".duplicate-item").length<=1&&t.remove()}),this.updateDuplicatesSelectedCount(),0===document.querySelectorAll(".duplicate-group").length&&(document.getElementById("duplicates-content").innerHTML='

'.concat((0,i.Tl)("budget","All duplicates have been resolved."),"

"))),s.failed>0&&(0,c.Qg)((0,i.zw)("budget","Failed to delete %n transaction","Failed to delete %n transactions",s.failed)),t.n=7;break;case 6:t.p=6,u=t.v,console.error("Failed to delete duplicates:",u),(0,c.Qg)((0,i.Tl)("budget","Failed to delete duplicates"));case 7:return t.p=7,o&&document.body.contains(o)&&(o.disabled=!1,o.textContent=(0,i.Tl)("budget","Delete Selected")+" (".concat(document.querySelectorAll(".duplicate-checkbox:checked").length,")")),t.f(7);case 8:return t.a(2)}},t,this,[[4,6,7,8]])})),function(){return t.apply(this,arguments)})}]);var t,e,n,a,r,d,h,p,f,m,v,y,E,x,S,C,I,A,_,M,D,B,L,P,O,F,R,N,j,H,z,V,q,W,U,G,Z,Y,Q,$,K,X,J,tt,et,nt,at,rt,it,ot,st,ct,lt,ut,dt,ht,gt,pt}(),Oe=n(192);function Fe(t){return Fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fe(t)}function Re(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=je(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var a=0,r=function(){};return{s:r,n:function(){return a>=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function Ne(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,r,i,o,s=[],c=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(s.push(a.value),s.length!==e);c=!0);}catch(t){l=!0,r=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||je(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function je(t,e){if(t){if("string"==typeof t)return He(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?He(t,e):void 0}}function He(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n3?(r=p===a)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),s=u,c=p;(e=s<2?t:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),g(s,c)):h.n=c:h.v=c);try{if(l=2,i){if(s||(r="next"),e=i[r]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=t}else if((e=(d=h.n<0)?c:n.call(a,h))!==o)break}catch(e){i=t,s=1,c=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),l}var o={};function s(){}function c(){}function l(){}e=Object.getPrototypeOf;var u=[][a]?e(e([][a]())):(Ve(e={},a,function(){return this}),e),d=l.prototype=s.prototype=Object.create(u);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Ve(t,r,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,Ve(d,"constructor",l),Ve(l,"constructor",c),c.displayName="GeneratorFunction",Ve(l,r,"GeneratorFunction"),Ve(d),Ve(d,r,"Generator"),Ve(d,a,function(){return this}),Ve(d,"toString",function(){return"[object Generator]"}),(ze=function(){return{w:i,m:h}})()}function Ve(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}Ve=function(t,e,n,a){function i(e,n){Ve(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},Ve(t,e,n,a)}function qe(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function We(t){return function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){qe(i,a,r,o,s,"next",t)}function s(t){qe(i,a,r,o,s,"throw",t)}o(void 0)})}}function Ue(t,e){for(var n=0;n0?Math.min(Math.max(a/r*100,0),100):0,l=a>=r,u=null!=t.tagId,d=t.color||"#0082c9",h=t.targetDate||t.target_date,p=!0===t._shared,f=!p||!0===t._canWrite,m=!p||!0===t._canManage,v=t.userId||t.user_id||"",y="";if(h){var b=o.Zj(h),w=new Date,T=Math.ceil((b-w)/864e5);y=T<0?(0,i.Tl)("budget","Target date passed"):0===T?(0,i.Tl)("budget","Target date: Today"):T<=30?(0,i.zw)("budget","%n day left","%n days left",T):(0,i.Tl)("budget","Target: {date}",{date:o.Yq(h,e.settings)})}n=l?' '.concat((0,i.Tl)("budget","Goal reached!"),""):u?' '.concat((0,i.Tl)("budget","Auto-tracked"),""):f?'"):"";var k=p?' ').concat((0,i.Tl)("budget","Shared"),""):"";return'\n
\n
\n
\n \n

').concat(s.ZD(t.name),"

\n ").concat(k,'\n
\n
\n ').concat(f?''):"","\n ").concat(m?''):"",'\n
\n
\n\n
\n
\n
\n
\n
\n ').concat(o.vv(a,null,e.settings),'\n ').concat(c.toFixed(0),'%\n ').concat((0,i.Tl)("budget","of {amount}",{amount:o.vv(r,null,e.settings)}),'\n
\n
\n\n \n
\n ")}).join("")}},{key:"setupGoalsEventListeners",value:function(){var t,e,n,a,r,i,o,s=this;null===(t=document.getElementById("add-goal-btn"))||void 0===t||t.addEventListener("click",function(){s.showGoalModal()}),null===(e=document.getElementById("empty-goals-add-btn"))||void 0===e||e.addEventListener("click",function(){s.showGoalModal()}),null===(n=document.getElementById("goal-form"))||void 0===n||n.addEventListener("submit",function(){var t=We(ze().m(function t(e){return ze().w(function(t){for(;;)switch(t.n){case 0:return e.preventDefault(),t.n=1,s.saveGoal();case 1:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()),null===(a=document.getElementById("add-to-goal-form"))||void 0===a||a.addEventListener("submit",function(){var t=We(ze().m(function t(e){return ze().w(function(t){for(;;)switch(t.n){case 0:return e.preventDefault(),t.n=1,s.addMoneyToGoal();case 1:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()),null===(r=document.getElementById("goals-list"))||void 0===r||r.addEventListener("click",function(t){var e=t.target.closest(".edit-goal-btn"),n=t.target.closest(".delete-goal-btn"),a=t.target.closest(".goal-add-money-btn");if(e){var r=parseInt(e.dataset.goalId);s.editGoal(r)}else if(n){var i=parseInt(n.dataset.goalId);s.deleteGoal(i)}else if(a){var o=parseInt(a.dataset.goalId);s.showAddMoneyModal(o)}});var c=document.getElementById("goal-modal");c&&c.querySelectorAll(".cancel-btn").forEach(function(t){t.addEventListener("click",function(){c.style.display="none"})});var l=document.getElementById("add-to-goal-modal");l&&l.querySelectorAll(".cancel-btn").forEach(function(t){t.addEventListener("click",function(){l.style.display="none"})}),null===(i=document.getElementById("goal-tag"))||void 0===i||i.addEventListener("change",function(t){s.updateCurrentAmountFieldState(""!==t.target.value)}),null===(o=document.getElementById("goal-color"))||void 0===o||o.addEventListener("input",function(t){var e=document.getElementById("goal-color-preview");e&&(e.style.backgroundColor=t.target.value)})}},{key:"updateCurrentAmountFieldState",value:function(t){var e=document.getElementById("goal-current"),n=document.getElementById("goal-tag-hint");e&&(e.disabled=t,t?(e.value="",e.placeholder=(0,i.Tl)("budget","Auto-calculated from tag")):e.placeholder="0.00"),n&&(n.style.display=t?"block":"none")}},{key:"populateGoalAccountDropdown",value:function(){var t=document.getElementById("goal-account");t&&(t.innerHTML='")+(0,k.ig)(this.accounts,t.value,{readOnlyShares:!0}).map(function(t){return'")}).join(""))}},{key:"populateGoalTagDropdown",value:(a=We(ze().m(function t(){var e,n,a,r,o,c,l,u,d,h,g,p,f,m,v,y,b,w,k=this;return ze().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.getElementById("goal-tag")){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,Promise.all([(0,T.n)("/apps/budget/api/tag-sets"),(0,T.n)("/apps/budget/api/tags/global").catch(function(){return null})]);case 2:if(n=t.v,a=Ne(n,2),r=a[0],o=a[1],this._allTagSets=r,this._goalTagsById=new Map,c='"),o&&(o.forEach(function(t){return k._goalTagsById.set(t.id,t)}),(l=(0,ne.g)(o)).length>0)){c+=''),u=Re(l);try{for(u.s();!(d=u.n()).done;)h=d.value,c+='")}catch(t){u.e(t)}finally{u.f()}c+=""}g=Re(this._allTagSets);try{for(g.s();!(p=g.n()).done;)if(((f=p.value).tags||[]).forEach(function(t){return k._goalTagsById.set(t.id,t)}),(m=(0,ne.g)(f.tags)).length>0){c+=''),v=Re(m);try{for(v.s();!(y=v.n()).done;)b=y.value,c+='")}catch(t){v.e(t)}finally{v.f()}c+=""}}catch(t){g.e(t)}finally{g.f()}e.innerHTML=c,t.n=4;break;case 3:t.p=3,w=t.v,console.error("Failed to load tags for goal dropdown:",w);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return a.apply(this,arguments)})},{key:"ensureGoalTagOption",value:function(t){var e,n=document.getElementById("goal-tag");if(n&&t&&!n.querySelector('option[value="'.concat(t,'"]'))){var a=null===(e=this._goalTagsById)||void 0===e?void 0:e.get(t);if(a){var r=document.createElement("option");r.value=String(a.id),r.textContent=a.name,n.appendChild(r)}}}},{key:"showGoalModal",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=document.getElementById("goal-modal"),n=document.getElementById("goal-modal-title"),a=document.getElementById("goal-form");if(e&&a){n.textContent=t?(0,i.Tl)("budget","Edit Savings Goal"):(0,i.Tl)("budget","Add Savings Goal"),a.reset(),document.getElementById("goal-id").value="",document.getElementById("goal-color").value="#0082c9",(0,u.N1)("goal-target-date");var r=document.getElementById("goal-tag");if(r&&(r.value=""),this.updateCurrentAmountFieldState(!1),t){document.getElementById("goal-id").value=t.id,document.getElementById("goal-name").value=t.name,document.getElementById("goal-target").value=t.targetAmount||t.target_amount||"",document.getElementById("goal-current").value=t.currentAmount||t.current_amount||0,(0,u.Mv)("goal-target-date",t.targetDate||t.target_date||""),document.getElementById("goal-notes").value=t.description||"",r&&t.tagId&&(this.ensureGoalTagOption(t.tagId),r.value=t.tagId,this.updateCurrentAmountFieldState(!0));var o=document.getElementById("goal-account");o&&t.accountId&&(0,k.XH)(o,this.accounts,t.accountId),t.color&&(document.getElementById("goal-color").value=t.color)}e.style.display="flex"}}},{key:"saveGoal",value:function(){var t=this;return(0,ee.O)("goal-save",document.querySelector('#goal-form [type="submit"]'),function(){return t._saveGoal()})}},{key:"_saveGoal",value:(n=We(ze().m(function t(){var e,n,a,r,o,s,l,u,d,h,g,p,f;return ze().w(function(t){for(;;)switch(t.p=t.n){case 0:return r=document.getElementById("goal-id").value,o=null===(e=document.getElementById("goal-tag"))||void 0===e?void 0:e.value,s=document.getElementById("goal-target-date").value,l=document.getElementById("goal-notes").value,u=null===(n=document.getElementById("goal-account"))||void 0===n?void 0:n.value,d=null===(a=document.getElementById("goal-color"))||void 0===a?void 0:a.value,h={name:document.getElementById("goal-name").value,targetAmount:parseFloat(document.getElementById("goal-target").value)||0,currentAmount:parseFloat(document.getElementById("goal-current").value)||0,targetDate:s||null,description:l||null,tagId:o?parseInt(o):null,accountId:u?parseInt(u):null,color:d||null},t.p=1,g=r?"/apps/budget/api/savings-goals/".concat(r):"/apps/budget/api/savings-goals",t.p=2,t.n=3,(0,T.n)(g,{method:r?"PUT":"POST",body:h,errorMessage:(0,i.Tl)("budget","Failed to save goal")});case 3:t.n=6;break;case 4:if(t.p=4,(p=t.v)instanceof T.h){t.n=5;break}throw p;case 5:return console.error("Save goal error response:",p.status,p.data),(0,c.Qg)(p.message),t.a(2);case 6:return document.getElementById("goal-modal").style.display="none",(0,c.Te)(r?(0,i.Tl)("budget","Goal updated"):(0,i.Tl)("budget","Goal created")),t.n=7,this.loadSavingsGoalsView();case 7:t.n=9;break;case 8:t.p=8,f=t.v,console.error("Failed to save goal:",f),(0,c.Qg)((0,i.Tl)("budget","Failed to save goal"));case 9:return t.a(2)}},t,this,[[2,4],[1,8]])})),function(){return n.apply(this,arguments)})},{key:"editGoal",value:function(t){var e,n=null===(e=this.savingsGoals)||void 0===e?void 0:e.find(function(e){return e.id===t});n&&this.showGoalModal(n)}},{key:"deleteGoal",value:(e=We(ze().m(function t(e){var n;return ze().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.n=1,(0,l.ZD)((0,i.Tl)("budget","Are you sure you want to delete this savings goal?"),{destructive:!0});case 1:if(t.v){t.n=2;break}return t.a(2);case 2:return t.p=2,t.n=3,(0,T.n)("/apps/budget/api/savings-goals/".concat(e),{method:"DELETE"});case 3:return(0,c.Te)((0,i.Tl)("budget","Goal deleted")),t.n=4,this.loadSavingsGoalsView();case 4:t.n=6;break;case 5:t.p=5,n=t.v,console.error("Failed to delete goal:",n),(0,c.Qg)((0,i.Tl)("budget","Failed to delete goal"));case 6:return t.a(2)}},t,this,[[2,5]])})),function(t){return e.apply(this,arguments)})},{key:"showAddMoneyModal",value:function(t){var e,n=null===(e=this.savingsGoals)||void 0===e?void 0:e.find(function(e){return e.id===t});if(n)if(n.tagId)(0,c.cf)((0,i.Tl)("budget","This goal is auto-tracked via a tag"));else{var a=document.getElementById("add-to-goal-modal");document.getElementById("add-to-goal-name").textContent=n.name,document.getElementById("add-to-goal-id").value=t,document.getElementById("add-amount").value="",a.style.display="flex"}}},{key:"addMoneyToGoal",value:function(){var t=this;return(0,ee.O)("goal-add-money",document.querySelector('#add-to-goal-form [type="submit"]'),function(){return t._addMoneyToGoal()})}},{key:"_addMoneyToGoal",value:(t=We(ze().m(function t(){var e,n,a,r,s,l,u;return ze().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=document.getElementById("add-to-goal-id").value,!((a=parseFloat(document.getElementById("add-amount").value)||0)<=0)){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Please enter a valid amount")),t.a(2);case 1:if(r=null===(e=this.savingsGoals)||void 0===e?void 0:e.find(function(t){return t.id===parseInt(n)})){t.n=2;break}return t.a(2);case 2:if(!r.tagId){t.n=3;break}return(0,c.cf)((0,i.Tl)("budget","This goal is auto-tracked via a tag")),t.a(2);case 3:return s=parseFloat(r.currentAmount||r.current_amount)||0,l=s+a,t.p=4,t.n=5,(0,T.n)("/apps/budget/api/savings-goals/".concat(n),{method:"PUT",body:{currentAmount:l}});case 5:return document.getElementById("add-to-goal-modal").style.display="none",(0,c.Te)((0,i.Tl)("budget","Added {amount} to goal",{amount:o.vv(a,null,this.settings)})),t.n=6,this.loadSavingsGoalsView();case 6:t.n=8;break;case 7:t.p=7,u=t.v,console.error("Failed to add money to goal:",u),(0,c.Qg)((0,i.Tl)("budget","Failed to add money to goal"));case 8:return t.a(2)}},t,this,[[4,7]])})),function(){return t.apply(this,arguments)})}]);var t,e,n,a,r}(),Ye=n(42),Qe=n(958),$e=n(69),Ke=n(10);function Xe(t){return Xe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xe(t)}function Je(){var t,e,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function i(n,a,r,i){var c=a&&a.prototype instanceof s?a:s,l=Object.create(c.prototype);return tn(l,"_invoke",function(n,a,r){var i,s,c,l=0,u=r||[],d=!1,h={p:0,n:0,v:t,a:g,f:g.bind(t,4),d:function(e,n){return i=e,s=0,c=t,h.n=n,o}};function g(n,a){for(s=n,c=a,e=0;!d&&l&&!r&&e3?(r=p===a)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),s=u,c=p;(e=s<2?t:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),g(s,c)):h.n=c:h.v=c);try{if(l=2,i){if(s||(r="next"),e=i[r]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=t}else if((e=(d=h.n<0)?c:n.call(a,h))!==o)break}catch(e){i=t,s=1,c=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),l}var o={};function s(){}function c(){}function l(){}e=Object.getPrototypeOf;var u=[][a]?e(e([][a]())):(tn(e={},a,function(){return this}),e),d=l.prototype=s.prototype=Object.create(u);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,tn(t,r,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,tn(d,"constructor",l),tn(l,"constructor",c),c.displayName="GeneratorFunction",tn(l,r,"GeneratorFunction"),tn(d),tn(d,r,"Generator"),tn(d,a,function(){return this}),tn(d,"toString",function(){return"[object Generator]"}),(Je=function(){return{w:i,m:h}})()}function tn(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}tn=function(t,e,n,a){function i(e,n){tn(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},tn(t,e,n,a)}function en(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function nn(t){return function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){en(i,a,r,o,s,"next",t)}function s(t){en(i,a,r,o,s,"throw",t)}o(void 0)})}}function an(t,e){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:void 0,u=!(0,k.kq)(t),d=void 0===l||(0,k.Zg)(t,l),h=t.frequency||"monthly",g=null===(a=null!==(r=t.isActive)&&void 0!==r?r:t.is_active)||void 0===a||a,p="one-time"===h,f=t.nextExpectedDate||t.next_expected_date||null,m=t.lastReceivedDate||t.last_received_date||null,v=t.startDate||t.start_date||null,y=function(t){return o.Yq(t,n)},b=!(null===(s=t.lastOccurrenceSkipped)||void 0===s||!s),w=(0,$e.L)({frequency:h,isActive:g,dueDate:f,lastDate:m,skipped:b},e),T=w.status,E=w.recentlySettled;if("inactive"===T)return c=m?(0,i.Tl)("budget","Received {date}",{date:y(m)}):p&&v?y(v):(0,i.Tl)("budget","No date set"),{status:p?"completed":"inactive",statusText:p?(0,i.Tl)("budget","Completed"):(0,i.Tl)("budget","Inactive"),dateText:c,canReceive:!1,canSkip:!1,canWrite:u,accountHint:null};var x={overdue:"overdue",soon:"expected-soon",settled:"received",upcoming:"upcoming"}[T],S="received"!==x&&u;return{status:x,statusText:{overdue:(0,i.Tl)("budget","Overdue"),"expected-soon":(0,i.Tl)("budget","Expected Soon"),received:(0,i.Tl)("budget","Received"),upcoming:(0,i.Tl)("budget","Upcoming")}[x],dateText:E?(0,i.Tl)("budget","Received {receivedDate}, next expected {expectedDate}",{receivedDate:y(m),expectedDate:y(f)}):y(f),canReceive:S&&d,canSkip:S&&!p,canWrite:u,accountHint:!S||d||t._shared?null:(0,i.Tl)("budget","This income uses an account you can no longer change. Edit it and choose another account.")}}(t,r,e.settings,e.accounts),l=c.status,u=c.statusText,d=t.frequency||"monthly",h={weekly:(0,i.Tl)("budget","Weekly"),biweekly:(0,i.Tl)("budget","Bi-Weekly"),"semi-monthly":(0,i.Tl)("budget","Semi-Monthly"),monthly:(0,i.Tl)("budget","Monthly"),quarterly:(0,i.Tl)("budget","Quarterly"),"semi-annually":(0,i.Tl)("budget","Semi-Annually"),yearly:(0,i.Tl)("budget","Yearly"),"one-time":(0,i.Tl)("budget","One-Time")}[d]||d.charAt(0).toUpperCase()+d.slice(1),g=t.source||"",p=null!==(n=null!==(a=t.autoCreateEnabled)&&void 0!==a?a:t.auto_create_enabled)&&void 0!==n&&n;return'\n
\n
\n
\n

').concat(s.ZD(t.name),'

\n ').concat(h,"\n ").concat(g?''.concat(s.ZD(g),""):"",'\n
\n
').concat(o.vv(t.amount,t.currency||(0,k.$S)(e.accounts,t.accountId),e.settings),'
\n
\n
\n
\n \n ').concat(s.ZD(c.dateText),'\n
\n
\n ').concat(u,"\n ").concat(p?' ').concat((0,i.Tl)("budget","Auto-create"),""):"","\n
\n
\n ").concat(c.accountHint?'"):"",'\n
\n ').concat(c.canReceive?'\n \n "):"","\n ").concat(c.canSkip?'\n \n "):"","\n ").concat(c.canWrite?''):"","\n ").concat(t._shared&&!t._canManage?"":''),"\n
\n
\n ")}).join("")}},{key:"filterIncome",value:function(t){document.querySelectorAll(".income-card").forEach(function(e){var n=e.dataset.status,a=!1;switch(t){case"all":default:a=!0;break;case"expected":a="expected-soon"===n||"upcoming"===n||"overdue"===n;break;case"received":a="received"===n||"completed"===n}e.style.display=a?"flex":"none"})}},{key:"setupIncomeEventListeners",value:function(){var t=this,e=document.getElementById("add-income-btn"),n=document.getElementById("empty-income-add-btn");e&&e.addEventListener("click",function(){return t.showIncomeModal()}),n&&n.addEventListener("click",function(){return t.showIncomeModal()});var a=document.getElementById("detect-income-btn");a&&a.addEventListener("click",function(){return t.detectIncome()});var r=document.getElementById("close-detected-income-panel");r&&r.addEventListener("click",function(){document.getElementById("detected-income-panel").style.display="none"});var i=document.getElementById("cancel-detected-income-btn");i&&i.addEventListener("click",function(){document.getElementById("detected-income-panel").style.display="none"});var o=document.getElementById("add-selected-income-btn");o&&o.addEventListener("click",function(){return t.addSelectedDetectedIncome()});var s=document.getElementById("income-form");s&&s.addEventListener("submit",function(e){e.preventDefault(),t.saveIncome()});var c=document.getElementById("income-modal");c&&(c.querySelectorAll(".cancel-btn").forEach(function(e){e.addEventListener("click",function(){return t.hideIncomeModal()})}),c.addEventListener("click",function(e){e.target===c&&t.hideIncomeModal()}));var l=document.getElementById("income-account"),u=document.getElementById("income-auto-create");l&&u&&(l.addEventListener("change",function(){l.value&&""!==l.value?u.disabled=!1:(u.checked=!1,u.disabled=!0)}),l.value&&""!==l.value||(u.disabled=!0));var d=document.getElementById("income-frequency");d&&d.addEventListener("change",function(){return t.updateIncomeFormFields()});var h=document.getElementById("income-start-date");h&&h.addEventListener("change",function(){return t.updateIncomeFormFields()});var g=document.querySelectorAll(".income-tabs .tab-button");g.forEach(function(e){e.addEventListener("click",function(){g.forEach(function(t){return t.classList.remove("active")}),e.classList.add("active"),t.filterIncome(e.dataset.filter)})});var p=document.getElementById("income-list");p&&p.addEventListener("click",function(e){var n=e.target.closest(".income-edit-btn"),a=e.target.closest(".income-delete-btn"),r=e.target.closest(".income-received-btn"),i=e.target.closest(".income-skip-btn");if(n){var o=parseInt(n.dataset.incomeId),s=t.recurringIncome.find(function(t){return t.id===o});s&&t.showIncomeModal(s)}if(a){var c=parseInt(a.dataset.incomeId);t.deleteIncome(c)}if(!r&&!i||!(0,re.u$)(e)){var l=function(t){return'#income-list .income-card[data-income-id="'.concat(t,'"]')};if(r){var u=parseInt(r.dataset.incomeId);(0,Ye.m)(e,l(u),".income-received-btn",function(){return t.markIncomeReceived(u,r)})}if(i){var d=parseInt(i.dataset.incomeId);(0,Ye.m)(e,l(d),".income-skip-btn",function(){return t.skipIncome(d,i)})}}})}},{key:"showIncomeModal",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=document.getElementById("income-modal"),n=document.getElementById("income-modal-title");if(document.getElementById("income-form").reset(),document.getElementById("income-id").value="",(0,w.c2)(["income-category","income-account"]),t){var a,r,o,s,c,l,d,h;n.textContent=(0,i.Tl)("budget","Edit Recurring Income"),document.getElementById("income-id").value=t.id,document.getElementById("income-name").value=t.name||"",document.getElementById("income-description").value=t.description||"",document.getElementById("income-amount").value=t.amount||"",document.getElementById("income-source").value=t.source||"",document.getElementById("income-frequency").value=t.frequency||"monthly",document.getElementById("income-expected-day").value=t.expectedDay||t.expected_day||"",document.getElementById("income-expected-month").value=t.expectedMonth||t.expected_month||"",(0,w.Qz)(document.getElementById("income-category"),null!==(a=null!==(r=t.categoryId)&&void 0!==r?r:t.category_id)&&void 0!==a?a:null,t.categoryName?(0,w.pC)(t.categoryName):null);var g=document.getElementById("income-account"),p=null!==(o=null!==(s=t.accountId)&&void 0!==s?s:t.account_id)&&void 0!==o?o:null;(0,k.XH)(g,this.accounts,p)||(0,w.Qz)(g,p),document.getElementById("income-auto-pattern").value=t.autoDetectPattern||t.auto_detect_pattern||"",document.getElementById("income-notes").value=t.notes||"",(0,u.Mv)("income-start-date",t.startDate||t.start_date||"");var f=null!==(c=null!==(l=t.autoCreateEnabled)&&void 0!==l?l:t.auto_create_enabled)&&void 0!==c&&c;document.getElementById("income-auto-create").checked=f;var m=document.getElementById("income-excluded-from-forecast");m&&(m.checked=null!==(d=null!==(h=t.excludedFromForecast)&&void 0!==h?h:t.excluded_from_forecast)&&void 0!==d&&d)}else{n.textContent=(0,i.Tl)("budget","Add Recurring Income"),document.getElementById("income-auto-create").checked=!1;var v=document.getElementById("income-excluded-from-forecast");v&&(v.checked=!1),(0,u.N1)("income-start-date")}this.updateIncomeFormFields(),e.style.display="flex",e.setAttribute("aria-hidden","false")}},{key:"hideIncomeModal",value:function(){var t=document.getElementById("income-modal");t.style.display="none",t.setAttribute("aria-hidden","true")}},{key:"updateIncomeFormFields",value:function(){var t,e=document.getElementById("income-frequency").value,n=document.getElementById("expected-day-group"),a=document.getElementById("expected-month-group"),r="one-time"===e,o=document.getElementById("income-account"),s=document.getElementById("income-auto-create");o&&s&&(o.value&&""!==o.value?s.disabled=!1:(s.checked=!1,s.disabled=!0));var c=document.getElementById("income-start-date-group"),l=document.getElementById("income-start-date");if(c){c.style.display="weekly"===e||"biweekly"===e||r?"block":"none";var u=c.querySelector("label"),d=document.getElementById("income-start-date-help");u&&(u.textContent=r?(0,i.Tl)("budget","Date"):(0,i.Tl)("budget","First payment date")),d&&(d.textContent=r?(0,i.Tl)("budget","The date this income is expected. It can be in the past."):(0,i.Tl)("budget","Payments repeat from this date (optional)")),l&&(l.required=r)}if(r)return n.style.display="none",void(a.style.display="none");n.style.display="block",a.style.display="yearly"===e||"semi-annually"===e||"quarterly"===e?"block":"none";var h=n.querySelector("label"),g=document.getElementById("income-expected-day-help"),p=document.getElementById("income-expected-day");"weekly"===e||"biweekly"===e?(h.textContent=(0,i.Tl)("budget","Expected Day (1-7)"),g.textContent=(0,i.Tl)("budget","Day of the week (1=Monday, 7=Sunday)"),p.max=7):(h.textContent=(0,i.Tl)("budget","Expected Day"),g.textContent=(0,i.Tl)("budget","Day of the month when income is expected"),p.max=31);var f=("weekly"===e||"biweekly"===e)&&(null===(t=document.getElementById("income-start-date"))||void 0===t?void 0:t.value)||"";f?(p.value=String((0,b.mg)(f)),p.disabled=!0,g.textContent=(0,i.Tl)("budget","Follows the start date")):p.disabled=!1}},{key:"populateIncomeModalDropdowns",value:function(){var t=document.getElementById("income-category");if(t&&this.categories){var e=t.value;t.innerHTML='"),s.Vb(t,this.categoryTree||this.categories,{typeFilter:"income"}),e&&(t.value=e)}var n=document.getElementById("income-account");if(n&&this.accounts){var a=n.value;n.innerHTML='"),(0,k.ig)(this.accounts,a).forEach(function(t){var e=t.currency?" (".concat(s.ZD(t.currency),")"):"";n.innerHTML+='")}),a&&(n.value=a)}}},{key:"saveIncome",value:function(){var t=this;return(0,ee.O)("income-save",document.querySelector('#income-form [type="submit"]'),function(){return t._saveIncome()})}},{key:"_saveIncome",value:(p=nn(Je().m(function t(){var e,n,a,r,o,s,l,u,d,h,g,p,f,m;return Je().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,o=document.getElementById("income-id").value,s=!o,l=document.getElementById("income-frequency").value,u="weekly"===l||"biweekly"===l,d="one-time"===l,h=(null===(e=document.getElementById("income-start-date"))||void 0===e?void 0:e.value)||null,!d||h){t.n=1;break}return(0,c.Qg)((0,i.Tl)("budget","Choose the date this income is expected")),t.a(2);case 1:return g="yearly"===l||"semi-annually"===l||"quarterly"===l,p={name:document.getElementById("income-name").value.trim(),description:(null===(n=document.getElementById("income-description"))||void 0===n?void 0:n.value.trim())||null,amount:parseFloat(document.getElementById("income-amount").value)||0,source:document.getElementById("income-source").value.trim()||null,frequency:l,expectedDay:parseInt(document.getElementById("income-expected-day").value)||null,expectedMonth:g&&parseInt(document.getElementById("income-expected-month").value)||null,categoryId:parseInt(document.getElementById("income-category").value)||null,accountId:parseInt(document.getElementById("income-account").value)||null,autoDetectPattern:document.getElementById("income-auto-pattern").value.trim()||null,notes:document.getElementById("income-notes").value.trim()||null,autoCreateEnabled:(null===(a=document.getElementById("income-auto-create"))||void 0===a?void 0:a.checked)||!1,excludedFromForecast:(null===(r=document.getElementById("income-excluded-from-forecast"))||void 0===r?void 0:r.checked)||!1,startDate:u||d?h:null},f=s?"/apps/budget/api/recurring-income":"/apps/budget/api/recurring-income/".concat(o),t.n=2,(0,T.n)(f,{method:s?"POST":"PUT",body:p});case 2:return this.hideIncomeModal(),(0,c.Te)(s?(0,i.Tl)("budget","Income source created successfully"):(0,i.Tl)("budget","Income source updated successfully")),t.n=3,this.loadIncomeView();case 3:t.n=5;break;case 4:t.p=4,m=t.v,console.error("Failed to save income:",m),(0,c.Qg)(m.message||(0,i.Tl)("budget","Failed to save income"));case 5:return t.a(2)}},t,this,[[0,4]])})),function(){return p.apply(this,arguments)})},{key:"deleteIncome",value:(g=nn(Je().m(function t(e){var n;return Je().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.n=1,(0,l.ZD)((0,i.Tl)("budget","Are you sure you want to delete this recurring income?"),{destructive:!0});case 1:if(t.v){t.n=2;break}return t.a(2);case 2:return t.p=2,t.n=3,(0,T.n)("/apps/budget/api/recurring-income/".concat(e),{method:"DELETE"});case 3:return(0,c.Te)((0,i.Tl)("budget","Income source deleted successfully")),t.n=4,this.loadIncomeView();case 4:t.n=6;break;case 5:t.p=5,n=t.v,console.error("Failed to delete income:",n),(0,c.Qg)((0,i.Tl)("budget","Failed to delete income"));case 6:return t.a(2)}},t,this,[[2,5]])})),function(t){return g.apply(this,arguments)})},{key:"markIncomeReceived",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,ee.O)("income-received-".concat(t),n,function(){return e._markIncomeReceived(t)})}},{key:"_markIncomeReceived",value:(h=nn(Je().m(function t(e){var n,a,r,s,l,u,d=this;return Je().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,n=this.recurringIncome.find(function(t){return t.id===e})){t.n=1;break}throw new Error("Income not found");case 1:return a=o.rT(),t.n=2,(0,Ke.Fd)("/apps/budget/api/recurring-income/".concat(e,"/received"),{receivedDate:a,createTransaction:!0,expectedDate:n.nextExpectedDate||n.next_expected_date||null},this.settings,{kind:"income",currency:n.currency||(0,k.$S)(this.accounts,n.accountId)});case 2:if(null!==(r=t.v)){t.n=3;break}return t.a(2);case 3:return s={incomeId:e,action:"markReceived"},this._undoData=s,t.n=4,this.loadIncomeView();case 4:this._undoTimer&&clearTimeout(this._undoTimer),l=r.usedPayment?(0,i.Tl)("budget","Marked as received with the payment of {date}",{date:o.Yq(r.usedPayment.date,this.settings)}):n.accountId?(0,i.Tl)("budget","Income marked as received. Transaction created."):(0,i.Tl)("budget","Income marked as received."),(0,c.JC)(l,function(){return d.undoMarkReceived(s)},function(){return d._dropUndo(s)}),t.n=6;break;case 5:return t.p=5,u=t.v,console.error("Failed to mark income as received:",u),(0,c.Qg)(u.message||(0,i.Tl)("budget","Failed to mark income as received")),t.n=6,this._reloadAfterRefusal(u);case 6:return t.a(2)}},t,this,[[0,5]])})),function(t){return h.apply(this,arguments)})},{key:"_reloadAfterRefusal",value:(d=nn(Je().m(function t(e){return Je().w(function(t){for(;;)switch(t.n){case 0:if(!(e instanceof T.h)){t.n=1;break}return t.n=1,this.loadIncomeView();case 1:return t.a(2)}},t,this)})),function(t){return d.apply(this,arguments)})},{key:"_dropUndo",value:function(t){t.spent=!0,this._undoData===t&&(this._undoData=null)}},{key:"undoMarkReceived",value:(r=nn(Je().m(function t(){var e,n,a,r=arguments;return Je().w(function(t){for(;;)switch(t.p=t.n){case 0:if((e=r.length>0&&void 0!==r[0]?r[0]:this._undoData)&&!e.spent&&"markReceived"===e.action){t.n=1;break}return t.a(2);case 1:return e.spent=!0,t.p=2,n=e.incomeId,t.n=3,(0,T.n)("/apps/budget/api/recurring-income/".concat(n,"/unreceived"),{method:"POST"});case 3:return this._undoData===e&&(this._undoData=null),t.n=4,this.loadIncomeView();case 4:(0,c.Te)((0,i.Tl)("budget","Action undone")),t.n=6;break;case 5:t.p=5,a=t.v,console.error("Failed to undo mark received:",a),(0,c.Qg)((0,i.Tl)("budget","Failed to undo action: {message}",{message:a.message}));case 6:return t.a(2)}},t,this,[[2,5]])})),function(){return r.apply(this,arguments)})},{key:"skipIncome",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,ee.O)("income-received-".concat(t),n,function(){return e._skipIncome(t)})}},{key:"_skipIncome",value:(a=nn(Je().m(function t(e){var n,a,r,o,s,u,d=this;return Je().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=this.recurringIncome.find(function(t){return t.id===e})){t.n=1;break}return t.a(2);case 1:return t.n=2,(0,l.ZD)((0,i.Tl)("budget","Skip this payment and advance to the next expected date?"));case 2:if(t.v){t.n=3;break}return t.a(2);case 3:return t.p=3,t.n=4,(0,T.n)("/apps/budget/api/recurring-income/".concat(e,"/skip"),{method:"POST",body:{expectedDate:n.nextExpectedDate||n.next_expected_date||null},errorMessage:(0,i.Tl)("budget","Failed to skip income")});case 4:return r=t.v,this._undoTimer&&(clearTimeout(this._undoTimer),this._undoTimer=null),o={incomeId:e,previousNextExpectedDate:null!==(a=r.previousNextExpectedDate)&&void 0!==a?a:null,action:"skip"},this._undoData=o,t.n=5,this.loadIncomeView();case 5:s=(0,c.JC)((0,i.Tl)("budget","Payment skipped. Advanced to next expected date."),function(){return d.undoSkipIncome(o)},function(){(0,Qe.LB)(o),d._dropUndo(o)}),(0,Qe.to)(o,"income-".concat(e),o.previousNextExpectedDate,s),t.n=7;break;case 6:return t.p=6,u=t.v,console.error("Failed to skip income:",u),(0,c.Qg)(u.message||(0,i.Tl)("budget","Failed to skip income")),t.n=7,this._reloadAfterRefusal(u);case 7:return t.a(2)}},t,this,[[3,6]])})),function(t){return a.apply(this,arguments)})},{key:"undoSkipIncome",value:(n=nn(Je().m(function t(){var e,n,a,r,o=arguments;return Je().w(function(t){for(;;)switch(t.p=t.n){case 0:if((e=o.length>0&&void 0!==o[0]?o[0]:this._undoData)&&!e.spent&&"skip"===e.action){t.n=1;break}return t.a(2);case 1:return e.spent=!0,t.p=2,n=e.incomeId,a=e.previousNextExpectedDate,t.n=3,(0,T.n)("/apps/budget/api/recurring-income/".concat(n,"/undo-skip"),{method:"POST",body:{previousNextExpectedDate:a}});case 3:return(0,Qe.Ib)(e),this._undoData===e&&(this._undoData=null),t.n=4,this.loadIncomeView();case 4:(0,c.Te)((0,i.Tl)("budget","Action undone")),t.n=6;break;case 5:t.p=5,r=t.v,(0,Qe.LB)(e),console.error("Failed to undo skip:",r),(0,c.Qg)((0,i.Tl)("budget","Failed to undo action: {message}",{message:r.message}));case 6:return t.a(2)}},t,this,[[2,5]])})),function(){return n.apply(this,arguments)})},{key:"detectIncome",value:(e=nn(Je().m(function t(){var e,n,a;return Je().w(function(t){for(;;)switch(t.p=t.n){case 0:return(e=document.getElementById("detect-income-btn")).disabled=!0,e.innerHTML=' '.concat((0,i.Tl)("budget","Detecting...")),t.p=1,t.n=2,(0,T.n)("/apps/budget/api/recurring-income/detect?months=6");case 2:if(0!==(n=t.v).length){t.n=3;break}return(0,c.cf)((0,i.Tl)("budget","No recurring income patterns found in your transactions")),t.a(2);case 3:this._detectedIncome=n,this.renderDetectedIncome(n),document.getElementById("detected-income-panel").style.display="flex",t.n=5;break;case 4:t.p=4,a=t.v,console.error("Failed to detect income:",a),(0,c.Qg)((0,i.Tl)("budget","Failed to detect recurring income"));case 5:return t.p=5,e.disabled=!1,e.innerHTML=' '.concat((0,i.Tl)("budget","Detect Income")),t.f(5);case 6:return t.a(2)}},t,this,[[1,4,5,6]])})),function(){return e.apply(this,arguments)})},{key:"renderDetectedIncome",value:function(t){var e=this;document.getElementById("detected-income-list").innerHTML=t.map(function(t,n){var a=t.confidence>=.8?"high":t.confidence>=.5?"medium":"low",r=Math.round(100*t.confidence),c=(0,k.$S)(e.accounts,t.accountId);return'\n
\n
\n =.7?"checked":"",'>\n
\n
\n
').concat(s.ZD(t.suggestedName),'
\n
\n ').concat(o.vv(t.amount,c,e.settings),'\n ').concat(t.frequency,'\n ').concat((0,i.zw)("budget","%n occurrence","%n occurrences",t.occurrences),'\n ').concat((0,i.Tl)("budget","Source: {source}",{source:s.ZD(t.source)},void 0,{escape:!1}),'\n
\n
\n ').concat((0,i.Tl)("budget","{percent}% confidence",{percent:r}),"\n ").concat(t.amountVariance?'±'.concat(o.vv(t.amountVariance,c,e.settings),""):"","\n
\n
\n
\n ")}).join("")}},{key:"addSelectedDetectedIncome",value:function(){var t=this;return(0,ee.O)("income-add-detected",document.getElementById("add-selected-income-btn"),function(){return t._addSelectedDetectedIncome()})}},{key:"_addSelectedDetectedIncome",value:(t=nn(Je().m(function t(){var e,n,a,r,o,s=this;return Je().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.querySelectorAll('#detected-income-list input[type="checkbox"]:checked'),0!==(n=Array.from(e).map(function(t){return parseInt(t.id.replace("detected-income-",""))})).length){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Please select at least one income source to add")),t.a(2);case 1:return a=n.map(function(t){return s._detectedIncome[t]}),t.p=2,t.n=3,(0,T.n)("/apps/budget/api/recurring-income/create-from-detected",{method:"POST",body:{incomes:a}});case 3:return r=t.v,document.getElementById("detected-income-panel").style.display="none",(0,c.Te)((0,i.zw)("budget","%n income source added successfully","%n income sources added successfully",r.created)),t.n=4,this.loadIncomeView();case 4:t.n=6;break;case 5:t.p=5,o=t.v,console.error("Failed to add income:",o),(0,c.Qg)((0,i.Tl)("budget","Failed to add selected income sources"));case 6:return t.a(2)}},t,this,[[2,5]])})),function(){return t.apply(this,arguments)})}]);var t,e,n,a,r,d,h,g,p,f,m}(),sn=n(78),cn=n(577),ln=n(574);function un(t){return un="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},un(t)}function dn(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=mn(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var a=0,r=function(){};return{s:r,n:function(){return a>=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function hn(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)}return n}function gn(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,a=Array(e);n3?(r=p===a)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),s=u,c=p;(e=s<2?t:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),g(s,c)):h.n=c:h.v=c);try{if(l=2,i){if(s||(r="next"),e=i[r]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=t}else if((e=(d=h.n<0)?c:n.call(a,h))!==o)break}catch(e){i=t,s=1,c=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),l}var o={};function s(){}function c(){}function l(){}e=Object.getPrototypeOf;var u=[][a]?e(e([][a]())):(bn(e={},a,function(){return this}),e),d=l.prototype=s.prototype=Object.create(u);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,bn(t,r,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,bn(d,"constructor",l),bn(l,"constructor",c),c.displayName="GeneratorFunction",bn(l,r,"GeneratorFunction"),bn(d),bn(d,r,"Generator"),bn(d,a,function(){return this}),bn(d,"toString",function(){return"[object Generator]"}),(yn=function(){return{w:i,m:h}})()}function bn(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}bn=function(t,e,n,a){function i(e,n){bn(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},bn(t,e,n,a)}function wn(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function Tn(t){return function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){wn(i,a,r,o,s,"next",t)}function s(t){wn(i,a,r,o,s,"throw",t)}o(void 0)})}}function kn(t,e){for(var n=0;n\n

'.concat((0,i.Tl)("budget","Recurring Transfers"),'

\n
\n \n \n
\n \n\n \x3c!-- Transfers Summary Cards --\x3e\n
\n
\n
\n \n
\n
\n
0
\n
').concat((0,i.Tl)("budget","Active Transfers"),'
\n
\n
\n
\n
\n \n
\n
\n
0
\n
').concat((0,i.Tl)("budget","Due This Month"),'
\n
\n
\n
\n
\n \n
\n
\n
$0
\n
').concat((0,i.Tl)("budget","Monthly Total"),'
\n
\n
\n
\n
\n \n
\n
\n
0
\n
').concat((0,i.Tl)("budget","Completed This Month"),'
\n
\n
\n
\n\n \x3c!-- Transfers Filter Tabs --\x3e\n
\n \n \n \n \n
\n\n \x3c!-- Transfers List --\x3e\n
\n
\n \x3c!-- Transfers will be rendered here --\x3e\n
\n\n \n\n \x3c!-- Detected Transfers Panel --\x3e\n \n
\n "),this._eventsSetup||(this.setupEventListeners(),this._eventsSetup=!0),this.renderTransfers(),this.updateSummary()):console.error("Transfers view not found")}},{key:"setupEventListeners",value:function(){var t=this;document.addEventListener("click",function(e){if(("add-transfer-btn"===e.target.id||"empty-transfers-add-btn"===e.target.id||e.target.closest("#add-transfer-btn")||e.target.closest("#empty-transfers-add-btn"))&&(e.preventDefault(),t.showTransferModal()),e.target.closest("#detect-transfers-btn")&&(e.preventDefault(),t.detectTransfers()),e.target.closest("#close-detected-transfers-panel")||e.target.closest("#cancel-detected-transfers-btn")){e.preventDefault();var n=document.getElementById("detected-transfers-panel");n&&(n.style.display="none")}e.target.closest("#add-detected-transfers-btn")&&(e.preventDefault(),t.addSelectedDetectedTransfers())});var e=function(t){return'#transfers-list .bill-card[data-bill-id="'.concat(t,'"]')};document.addEventListener("click",function(n){var a=n.target.closest(".transfer-paid-btn");if(a){if(n.preventDefault(),(0,re.u$)(n))return;var r=parseInt(a.dataset.transferId);(0,Ye.m)(n,e(r),".transfer-paid-btn",function(){return t.markTransferPaid(r,a)})}}),document.addEventListener("click",function(n){var a=n.target.closest(".transfer-skip-btn");if(a){if(n.preventDefault(),(0,re.u$)(n))return;var r=parseInt(a.dataset.transferId);(0,Ye.m)(n,e(r),".transfer-skip-btn",function(){return t.skipTransfer(r,a)})}}),document.addEventListener("click",function(n){var a=n.target.closest(".transfer-unpaid-btn");if(a){if(n.preventDefault(),(0,re.u$)(n))return;var r=parseInt(a.dataset.transferId);(0,Ye.m)(n,e(r),".transfer-unpaid-btn",function(){return t.markTransferUnpaid(r,a)})}}),document.addEventListener("click",function(e){var n=e.target.closest(".transfer-edit-btn");if(n){e.preventDefault();var a=parseInt(n.dataset.transferId),r=t.transfers.find(function(t){return t.id===a});r&&t.showTransferModal(r)}}),document.addEventListener("click",function(e){var n=e.target.closest(".transfer-delete-btn");if(n){e.preventDefault();var a=parseInt(n.dataset.transferId);t.deleteTransfer(a)}}),document.addEventListener("click",function(e){var n;if(e.target.classList.contains("tab-button")&&e.target.closest(".bills-tabs")&&null!==(n=document.getElementById("transfers-view"))&&void 0!==n&&n.contains(e.target)){e.preventDefault(),document.querySelectorAll(".bills-tabs .tab-button").forEach(function(t){t.classList.remove("active")}),e.target.classList.add("active");var a=e.target.dataset.filter;t.filterTransfers(a)}})}},{key:"renderTransfers",value:function(){var t=this,e=document.getElementById("transfers-list"),n=document.getElementById("empty-transfers");if(!this.transfers||0===this.transfers.length)return e.innerHTML="",void(n.style.display="flex");n.style.display="none";var a=o.rT();e.innerHTML=this.transfers.map(function(e){var n,r,c,l,u=(0,sn.Zg)(e,a,t.settings,t.accounts),d=u.status,h=u.statusText,g=e.frequency||"monthly",p={"one-time":(0,i.Tl)("budget","One-Time"),weekly:(0,i.Tl)("budget","Weekly"),biweekly:(0,i.Tl)("budget","Bi-Weekly"),"semi-monthly":(0,i.Tl)("budget","Semi-Monthly"),monthly:(0,i.Tl)("budget","Monthly"),quarterly:(0,i.Tl)("budget","Quarterly"),"semi-annually":(0,i.Tl)("budget","Semi-Annually"),yearly:(0,i.Tl)("budget","Yearly")}[g]||g.charAt(0).toUpperCase()+g.slice(1),f=null!==(n=null!==(r=e.autoPayEnabled)&&void 0!==r?r:e.auto_pay_enabled)&&void 0!==n&&n,m=null!==(c=null!==(l=e.autoPayFailed)&&void 0!==l?l:e.auto_pay_failed)&&void 0!==c&&c;return'\n
\n
\n
\n

').concat(s.ZD(e.name),'

\n ').concat(p,'\n
\n
').concat(o.vv(e.amount,e.currency||null,t.settings)).concat(t.amountTypeBadge(e.amountType),'
\n
\n
\n
\n \n ').concat(s.ZD(u.dateText),'\n
\n
\n ').concat(h,"\n ").concat(f?' ').concat((0,i.Tl)("budget","Auto-pay"),""):"","\n ").concat(m?' ').concat((0,i.Tl)("budget","Auto-pay Failed"),""):"","\n
\n
\n ").concat(u.accountHint?'"):"",'\n
\n ').concat(u.canPay?'\n \n "):"","\n ").concat(u.canSkip?'\n \n "):"","\n ").concat(u.canUnpay?'\n \n "):"","\n ").concat(u.canWrite?''):"","\n ").concat(e._shared&&!e._canManage?"":''),"\n
\n
\n ")}).join("")}},{key:"filterTransfers",value:function(t){var e={all:function(){return!0},due:function(t){return"due-soon"===t},overdue:function(t){return"overdue"===t},completed:function(t){return"paid"===t}},n=e[t]||e.all;document.querySelectorAll("#transfers-list .bill-card").forEach(function(t){t.style.display=n(t.dataset.status)?"":"none"})}},{key:"updateSummary",value:(v=Tn(yn().m(function t(){var e,n,a,r,i,s,c,l;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:return e=o.rT(),n=e.slice(0,7),a=this.transfers.filter(function(t){return t.isActive}).length,r=this.transfers.filter(function(t){if(!t.isActive)return!1;var e=t.nextDueDate||t.next_due_date;return!!e&&e.slice(0,7)===n}).length,i=this.transfers.filter(function(t){var e=t.lastPaidDate||t.last_paid_date;return!!e&&e.slice(0,7)===n}).length,document.getElementById("transfers-active-count").textContent=a,document.getElementById("transfers-due-count").textContent=r,document.getElementById("transfers-completed-count").textContent=i,t.p=1,t.n=2,(0,T.n)("/apps/budget/api/bills/summary?isTransfer=true");case 2:s=t.v,(c=document.getElementById("transfers-monthly-total"))&&(c.textContent=o.vv(s.monthlyTotal||0,s.baseCurrency||null,this.settings)),t.n=4;break;case 3:t.p=3,l=t.v,console.error("Failed to load transfers summary:",l);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return v.apply(this,arguments)})},{key:"showTransferModal",value:function(){var t,e,n,a=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,c=null!==r,l=c?(0,i.Tl)("budget","Edit Transfer"):(0,i.Tl)("budget","Add Transfer"),d='\n \n "),h=document.querySelector(".budget-modal-overlay");h&&h.remove(),document.body.insertAdjacentHTML("beforeend",d),c&&((0,w.Qz)(document.getElementById("transfer-category"),null!==(t=r.categoryId)&&void 0!==t?t:null,r.categoryName?(0,w.pC)(r.categoryName):null),(0,w.Qz)(document.getElementById("recurring-transfer-from-account"),null!==(e=r.accountId)&&void 0!==e?e:null),(0,w.Qz)(document.getElementById("recurring-transfer-to-account"),null!==(n=r.destinationAccountId)&&void 0!==n?n:null));var g=document.getElementById("transfer-transaction-date");g&&(0,u.zH)(g,this.app.settings);var p=document.getElementById("transfer-start-date");p&&((0,u.zH)(p,this.app.settings),p.addEventListener("change",function(){return a.updateTransferScheduleFields()}));var f=document.getElementById("transfer-frequency");f&&f.addEventListener("change",function(){return a.updateTransferScheduleFields()}),this.updateTransferScheduleFields();var m=document.getElementById("transfer-category");m&&m.addEventListener("change",function(){a.loadTransferTagSets(m.value||null,c?r:null)}),this.loadTransferTagSets((null==m?void 0:m.value)||null,c?r:null);var v=document.getElementById("recurring-transfer-to-account"),y=document.getElementById("transfer-amount-type-group"),b=document.getElementById("transfer-amount-type"),T=document.getElementById("transfer-amount-type-hint"),E=document.getElementById("transfer-amount"),x={statement:(0,i.Tl)("budget","Pays what was owed at the due date. Later charges roll to the next payment"),current_balance:(0,i.Tl)("budget","Pays everything owed on the card at payment time"),minimum_payment:(0,i.Tl)("budget","Pays the card's minimum payment, never more than is owed")},S=function(){var t,e=a.accounts.find(function(t){return t.id===parseInt(v.value)}),n=e||"1"!==(null===(t=v.selectedOptions[0])||void 0===t?void 0:t.dataset.unavailable)?!!e&&["credit_card","line_of_credit"].includes(e.type):c&&"fixed"!==(r.amountType||"fixed");n||"fixed"===b.value||(b.value="fixed"),y.style.display=n?"block":"none";var o=n&&"fixed"!==b.value;T.textContent=o?x[b.value]:"",E.disabled=o,E.required=!o,E.placeholder=o?(0,i.Tl)("budget","Resolved from the card at each payment"):""};v.addEventListener("change",S),b.addEventListener("change",S),!c&&o&&(o.name&&(document.getElementById("transfer-name").value=o.name),o.destinationAccountId&&(v.value=String(o.destinationAccountId)),o.dueDay&&(document.getElementById("transfer-due-day").value=String(o.dueDay)),o.amountType&&(b.value=o.amountType)),S();var C=document.getElementById("transfer-create-transaction");C&&C.addEventListener("change",function(t){var e=document.getElementById("transfer-transaction-date-group");e&&(e.style.display=t.target.checked?"block":"none")});var I=document.querySelector(".budget-modal-overlay"),A=document.getElementById("transfer-form"),_=document.getElementById("close-transfer-modal"),M=document.getElementById("cancel-transfer"),D=function(){I.remove()};_.addEventListener("click",D),M.addEventListener("click",D),I.addEventListener("click",function(t){t.target===I&&D()}),A.addEventListener("submit",function(){var t=Tn(yn().m(function t(e){return yn().w(function(t){for(;;)switch(t.n){case 0:return e.preventDefault(),t.n=1,a.saveTransfer(r);case 1:t.v&&D();case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}())}},{key:"updateTransferScheduleFields",value:function(){var t,e=null===(t=document.getElementById("transfer-frequency"))||void 0===t?void 0:t.value,n=document.getElementById("transfer-due-day-group"),a=document.getElementById("transfer-due-day-label"),r=document.getElementById("transfer-due-day"),o=document.getElementById("transfer-due-day-help"),s=document.getElementById("transfer-start-date"),c=document.getElementById("transfer-start-date-group"),l=document.getElementById("transfer-start-date-label"),u=document.getElementById("transfer-start-date-help");if(e&&a&&r){var d="one-time"===e;n&&(n.style.display=d?"none":"block");var h=document.getElementById("transfer-due-month-group");if(h&&(h.style.display=["yearly","semi-annually","quarterly"].includes(e)?"block":"none"),c&&(c.style.display="block"),l&&(l.textContent=d?(0,i.Tl)("budget","Due Date"):(0,i.Tl)("budget","Start Date")),s&&(s.required=d),d)u&&(u.textContent=(0,i.Tl)("budget","The date this transfer is due. It can be in the past."));else{var g="weekly"===e||"biweekly"===e;g?(a.textContent=(0,i.Tl)("budget","Due Day (1-7)"),o&&(o.textContent=(0,i.Tl)("budget","Day of the week (1=Monday, 7=Sunday)")),r.max=7):(a.textContent=(0,i.Tl)("budget","Day of Month (1-31)"),o&&(o.textContent=(0,i.Tl)("budget","Day of the month when the transfer is due")),r.max=31);var p=g&&(null==s?void 0:s.value)||"";p?(r.value=String((0,b.mg)(p)),r.disabled=!0,o&&(o.textContent=(0,i.Tl)("budget","Follows the start date"))):r.disabled=!1,u&&(u.textContent=g?(0,i.Tl)("budget","The transfer repeats from this date (optional)"):(0,i.Tl)("budget","Transfer only occurs on or after this date (optional)"))}}}},{key:"saveTransfer",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return(0,ee.O)("transfer-save",document.querySelector('#transfer-form [type="submit"]'),function(){return t._saveTransfer(e)})}},{key:"_saveTransfer",value:(m=Tn(yn().m(function t(){var e,n,a,r,o,s,l,u,d,h,g,p,f,m,v,y,b,w,k,E,x,S,C,I,A,_,M,D,B,L,P,O,F=arguments;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:if(s=F.length>0&&void 0!==F[0]?F[0]:null,l=document.getElementById("transfer-name").value,u=(null===(e=document.getElementById("transfer-amount-type"))||void 0===e?void 0:e.value)||"fixed",d=parseFloat(document.getElementById("transfer-amount").value),h="fixed"!==u&&isNaN(d)?0:d,g=document.getElementById("transfer-frequency").value,p=parseInt(document.getElementById("recurring-transfer-from-account").value),f=parseInt(document.getElementById("recurring-transfer-to-account").value),m=document.getElementById("transfer-due-day").value?parseInt(document.getElementById("transfer-due-day").value):null,y=(null===(n=document.getElementById("transfer-start-date"))||void 0===n?void 0:n.value)||null,"one-time"!==g){t.n=2;break}if(y){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Please enter the date the transfer is due")),t.a(2,!1);case 1:b=y.split("-").map(Number),w=fn(b,3),k=w[1],E=w[2],k&&E&&(m=E,v=k);case 2:if(["yearly","semi-annually","quarterly"].includes(g)&&(v=parseInt(null===(x=document.getElementById("transfer-due-month"))||void 0===x?void 0:x.value)||null),S=document.getElementById("transfer-description-pattern").value||null,C=null!==(a=document.getElementById("transfer-category"))&&void 0!==a&&a.value?parseInt(document.getElementById("transfer-category").value):null,I=this.getSelectedTagIds(),A=document.getElementById("transfer-notes").value||null,_=(null===(r=document.getElementById("transfer-create-transaction"))||void 0===r?void 0:r.checked)||!1,M=(null===(o=document.getElementById("transfer-transaction-date"))||void 0===o?void 0:o.value)||null,D=document.getElementById("transfer-auto-pay").checked,p&&!isNaN(p)){t.n=3;break}return(0,c.I9)((0,i.Tl)("budget","Please select a source account")),t.a(2,!1);case 3:if(f&&!isNaN(f)){t.n=4;break}return(0,c.I9)((0,i.Tl)("budget","Please select a destination account")),t.a(2,!1);case 4:if(p!==f){t.n=5;break}return(0,c.I9)((0,i.Tl)("budget","Cannot transfer to the same account")),t.a(2,!1);case 5:return B=gn(gn({name:l,amount:h,amountType:u,frequency:g,accountId:p,destinationAccountId:f,dueDay:m},void 0!==v?{dueMonth:v}:{}),{},{startDate:y,transferDescriptionPattern:S,categoryId:C,tagIds:I,notes:A,autoPayEnabled:D,isTransfer:!0}),s||(B.createTransaction=_,B.transactionDate=M),t.p=6,L=s?"/apps/budget/api/bills/".concat(s.id):"/apps/budget/api/bills",P=s?"PUT":"POST",t.n=7,(0,T.n)(L,{method:P,body:B,errorMessage:(0,i.Tl)("budget","Failed to save transfer")});case 7:return(0,c.Te)(s?(0,i.Tl)("budget","Transfer updated"):(0,i.Tl)("budget","Transfer added")),t.n=8,this.loadTransfers();case 8:return this.renderTransfers(),this.updateSummary(),t.a(2,!0);case 9:return t.p=9,O=t.v,console.error("Failed to save transfer:",O),(0,c.Qg)(O.message||(0,i.Tl)("budget","Failed to save transfer")),t.a(2,!1)}},t,this,[[6,9]])})),function(){return m.apply(this,arguments)})},{key:"deleteTransfer",value:(f=Tn(yn().m(function t(e){var n;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.n=1,(0,l.ZD)((0,i.Tl)("budget","Are you sure you want to delete this transfer?"),{destructive:!0});case 1:if(t.v){t.n=2;break}return t.a(2);case 2:return t.p=2,t.n=3,(0,T.n)("/apps/budget/api/bills/".concat(e),{method:"DELETE",errorMessage:(0,i.Tl)("budget","Failed to delete transfer")});case 3:return(0,c.Te)((0,i.Tl)("budget","Transfer deleted")),t.n=4,this.loadTransfers();case 4:this.renderTransfers(),this.updateSummary(),t.n=6;break;case 5:t.p=5,n=t.v,console.error("Failed to delete transfer:",n),(0,c.Qg)((0,i.Tl)("budget","Failed to delete transfer"));case 6:return t.a(2)}},t,this,[[2,5]])})),function(t){return f.apply(this,arguments)})},{key:"toggleTransferActive",value:(p=Tn(yn().m(function t(e){var n,a;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=this.transfers.find(function(t){return t.id===e})){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,(0,T.n)("/apps/budget/api/bills/".concat(e),{method:"PUT",body:{active:!n.isActive},errorMessage:(0,i.Tl)("budget","Failed to update transfer")});case 2:return(0,c.Te)(n.isActive?(0,i.Tl)("budget","Transfer deactivated"):(0,i.Tl)("budget","Transfer activated")),t.n=3,this.loadTransfers();case 3:this.renderTransfers(),this.updateSummary(),t.n=5;break;case 4:t.p=4,a=t.v,console.error("Failed to toggle transfer:",a),(0,c.Qg)((0,i.Tl)("budget","Failed to update transfer"));case 5:return t.a(2)}},t,this,[[1,4]])})),function(t){return p.apply(this,arguments)})},{key:"markTransferPaid",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,ee.O)("bill-paid-".concat(t),n,function(){return e._markTransferPaid(t)})}},{key:"_markTransferPaid",value:(g=Tn(yn().m(function t(e){var n,a,r,s,l,u,d,h,g,p,f,m,v;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=this.transfers.find(function(t){return t.id===e})){t.n=1;break}return t.a(2);case 1:return t.p=1,r=n.nextDueDate||n.next_due_date||null,s=n.currency||(0,k.$S)(this.accounts,null!==(a=n.accountId)&&void 0!==a?a:n.account_id),t.n=2,(0,Ke.tf)(e,r,this.settings,{currency:s});case 2:if(null!==(l=t.v)){t.n=3;break}return t.a(2);case 3:if(u={action:"create"},!l.usePayment){t.n=4;break}u={action:"use",payment:l.usePayment},t.n=7;break;case 4:if(!n.accountId&&!n.account_id){t.n=7;break}return t.n=5,(0,T.n)("/apps/budget/api/bills/".concat(e,"/matching-transactions")).catch(function(){return null});case 5:if(d=t.v,!((h=d?(0,k.vy)(d,this.accounts):null)&&h.length>0)){t.n=7;break}return t.n=6,(0,cn.l)(n,h,this.settings);case 6:if(null!==(u=t.v)){t.n=7;break}return t.a(2);case 7:return g={recordPayment:"create"===u.action,dueDate:r},"link"===u.action?g.existingTransactionId=u.transactionId:"use"===u.action?g.paidDate=u.payment.date:g.paidDate=o.rT(),l.confirmSecondPayment&&(g.confirmSecondPayment=!0),t.n=8,(0,Ke.Fd)("/apps/budget/api/bills/".concat(e,"/paid"),g,this.settings,{currency:s,errorMessage:(0,i.Tl)("budget","Failed to mark transfer as paid")});case 8:if(null!==(p=t.v)){t.n=9;break}return t.a(2);case 9:return f=p.result,(m="use"===u.action?u.payment:p.usedPayment)?(0,c.Te)((0,i.Tl)("budget","Marked as paid with the payment of {date}",{date:o.Yq(m.date,this.settings)})):f&&!1===f.paymentTransactionRecorded?(0,c.I9)((0,i.Tl)("budget","The transfer was marked as paid, but no transactions were recorded. Check both accounts, or add the transfer manually.")):(0,c.Te)((0,i.Tl)("budget","Transfer marked as paid")),t.n=10,this.loadTransfers();case 10:this.renderTransfers(),this.updateSummary(),t.n=12;break;case 11:return t.p=11,v=t.v,console.error("Failed to mark transfer as paid:",v),(0,c.Qg)(v.message||(0,i.Tl)("budget","Failed to mark transfer as paid")),t.n=12,this._reloadAfterRefusal(v);case 12:return t.a(2)}},t,this,[[1,11]])})),function(t){return g.apply(this,arguments)})},{key:"_reloadAfterRefusal",value:(h=Tn(yn().m(function t(e){return yn().w(function(t){for(;;)switch(t.n){case 0:if(!(e instanceof T.h)){t.n=2;break}return t.n=1,this.loadTransfers();case 1:this.renderTransfers(),this.updateSummary();case 2:return t.a(2)}},t,this)})),function(t){return h.apply(this,arguments)})},{key:"skipTransfer",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,ee.O)("bill-paid-".concat(t),n,function(){return e._skipTransfer(t)})}},{key:"_skipTransfer",value:(d=Tn(yn().m(function t(e){var n,a,r,o,s,u,d=this;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=this.transfers.find(function(t){return t.id===e})){t.n=1;break}return t.a(2);case 1:return t.n=2,(0,l.ZD)((0,i.Tl)("budget","Skip this payment and advance to the next due date?"));case 2:if(t.v){t.n=3;break}return t.a(2);case 3:return t.p=3,t.n=4,(0,T.n)("/apps/budget/api/bills/".concat(e,"/skip"),{method:"POST",body:{dueDate:n.nextDueDate||n.next_due_date||null},errorMessage:(0,i.Tl)("budget","Failed to skip transfer")});case 4:return r=t.v,o={transferId:e,previousNextDueDate:null!==(a=r.previousNextDueDate)&&void 0!==a?a:null,action:"skip"},this._undoData=o,t.n=5,this.loadTransfers();case 5:this.renderTransfers(),this.updateSummary(),s=(0,c.JC)((0,i.Tl)("budget","Payment skipped. Advanced to next due date."),function(){return d.undoSkipTransfer(o)},function(){(0,Qe.LB)(o),d._dropUndo(o)}),(0,Qe.to)(o,"transfer-".concat(e),o.previousNextDueDate,s),t.n=7;break;case 6:return t.p=6,u=t.v,console.error("Failed to skip transfer:",u),(0,c.Qg)(u.message||(0,i.Tl)("budget","Failed to skip transfer")),t.n=7,this._reloadAfterRefusal(u);case 7:return t.a(2)}},t,this,[[3,6]])})),function(t){return d.apply(this,arguments)})},{key:"_dropUndo",value:function(t){t.spent=!0,this._undoData===t&&(this._undoData=null)}},{key:"undoSkipTransfer",value:(r=Tn(yn().m(function t(){var e,n,a,r,o=arguments;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:if((e=o.length>0&&void 0!==o[0]?o[0]:this._undoData)&&!e.spent&&"skip"===e.action){t.n=1;break}return t.a(2);case 1:return e.spent=!0,t.p=2,n=e.transferId,a=e.previousNextDueDate,t.n=3,(0,T.n)("/apps/budget/api/bills/".concat(n,"/undo-skip"),{method:"POST",body:{previousNextDueDate:a}});case 3:return(0,Qe.Ib)(e),this._undoData===e&&(this._undoData=null),t.n=4,this.loadTransfers();case 4:this.renderTransfers(),this.updateSummary(),(0,c.Te)((0,i.Tl)("budget","Action undone")),t.n=6;break;case 5:t.p=5,r=t.v,(0,Qe.LB)(e),console.error("Failed to undo skip:",r),(0,c.Qg)((0,i.Tl)("budget","Failed to undo action: {message}",{message:r.message}));case 6:return t.a(2)}},t,this,[[2,5]])})),function(){return r.apply(this,arguments)})},{key:"markTransferUnpaid",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,ee.O)("bill-paid-".concat(t),n,function(){return e._markTransferUnpaid(t)})}},{key:"_markTransferUnpaid",value:(a=Tn(yn().m(function t(e){var n,a,r,o,s;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:return r=this.transfers.find(function(t){return t.id===e}),o=(0,ln.h)(r),!!r&&null!==(n=null!==(a=r.autoPayEnabled)&&void 0!==a?a:r.auto_pay_enabled)&&void 0!==n&&n&&(o+="\n\n"+(0,i.Tl)("budget","Auto-pay is on for this bill — it may pay it again on the next run. Disable auto-pay first if the payment should not recur.")),t.n=1,(0,l.ZD)(o,{destructive:!0});case 1:if(t.v){t.n=2;break}return t.a(2);case 2:return t.p=2,t.n=3,(0,ln.E)(e,(0,i.Tl)("budget","Failed to mark transfer as unpaid"));case 3:if(t.v){t.n=4;break}return t.a(2);case 4:return t.n=5,this.loadTransfers();case 5:this.renderTransfers(),this.updateSummary(),(0,c.Te)((0,i.Tl)("budget","Payment reverted — the transfer is marked as unpaid.")),t.n=7;break;case 6:return t.p=6,s=t.v,console.error("Failed to mark transfer as unpaid:",s),(0,c.Qg)(s.message||(0,i.Tl)("budget","Failed to mark transfer as unpaid")),t.n=7,this._reloadAfterRefusal(s);case 7:return t.a(2)}},t,this,[[2,6]])})),function(t){return a.apply(this,arguments)})},{key:"amountTypeBadge",value:function(t){var e={statement:(0,i.Tl)("budget","Statement"),current_balance:(0,i.Tl)("budget","Full balance"),minimum_payment:(0,i.Tl)("budget","Minimum")};return e[t]?'').concat(e[t],""):""}},{key:"formatFrequency",value:function(t){return{weekly:(0,i.Tl)("budget","Weekly"),biweekly:(0,i.Tl)("budget","Bi-Weekly"),"semi-monthly":(0,i.Tl)("budget","Semi-Monthly"),monthly:(0,i.Tl)("budget","Monthly"),quarterly:(0,i.Tl)("budget","Quarterly"),"semi-annually":(0,i.Tl)("budget","Semi-Annually"),yearly:(0,i.Tl)("budget","Yearly"),"one-time":(0,i.Tl)("budget","One-Time")}[t]||t}},{key:"loadTransferTagSets",value:(n=Tn(yn().m(function t(e){var n,a,r,o,c,l,u,d,h,g,p,f,m,v=arguments;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=v.length>1&&void 0!==v[1]?v[1]:null,a=document.getElementById("transfer-tags-container")){t.n=1;break}return t.a(2);case 1:return t.p=1,o=e&&(!(null!==(r=this.categories)&&void 0!==r&&r.length)||this.categories.some(function(t){return String(t.id)===String(e)})),t.n=2,Promise.all([(0,T.n)("/apps/budget/api/tags/global").catch(function(){return[]}),o?(0,T.n)("/apps/budget/api/tag-sets?categoryId=".concat(e)).catch(function(){return[]}):Promise.resolve([])]);case 2:if(c=t.v,l=fn(c,2),u=l[0],d=l[1],h=(null==n?void 0:n.tagIds)||[],g=(0,ne.g)(u||[],h),p=(0,ne.s)(d||[],h),0!==g.length||0!==p.length){t.n=3;break}return a.innerHTML="",t.a(2);case 3:f="",g.length>0&&(f+='\n
\n \n
\n ').concat(g.map(function(t){return'\n \n ")}).join(""),"\n
\n
\n ")),p.forEach(function(t){f+='\n
\n \n
\n ').concat(t.tags&&t.tags.length>0?t.tags.map(function(e){return'\n \n ")}).join(""):''.concat((0,i.Tl)("budget","No tags defined"),""),"\n
\n
\n ")}),a.innerHTML=f,a.querySelectorAll(".transfer-tag-checkbox").forEach(function(t){t.addEventListener("change",function(t){var e=t.target.dataset.tagSetId;t.target.checked&&"global"!==e&&a.querySelectorAll('.transfer-tag-checkbox[data-tag-set-id="'.concat(e,'"]')).forEach(function(e){e!==t.target&&(e.checked=!1,e.closest(".tag-option").querySelector(".tag-badge").style.opacity="0.5")}),t.target.closest(".tag-option").querySelector(".tag-badge").style.opacity=t.target.checked?"1":"0.5"})}),t.n=5;break;case 4:t.p=4,m=t.v,console.error("Failed to load tag sets:",m),a.innerHTML="";case 5:return t.a(2)}},t,this,[[1,4]])})),function(t){return n.apply(this,arguments)})},{key:"getSelectedTagIds",value:function(){var t=document.getElementById("transfer-tags-container");return t?Array.from(t.querySelectorAll(".transfer-tag-checkbox:checked")).map(function(t){return parseInt(t.value)}):[]}},{key:"detectTransfers",value:(e=Tn(yn().m(function t(){var e,n;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.getElementById("detect-transfers-btn")){t.n=1;break}return t.a(2);case 1:return e.disabled=!0,e.innerHTML=' '.concat((0,i.Tl)("budget","Detecting...")),t.p=2,t.n=3,(0,T.n)("/apps/budget/api/bills/detect?months=6&transfers=true");case 3:if((n=t.v)&&0!==n.length){t.n=4;break}return(0,c.I9)((0,i.Tl)("budget","No recurring transactions detected")),t.a(2);case 4:this.renderDetectedTransfers(n),document.getElementById("detected-transfers-panel").style.display="flex",t.n=6;break;case 5:t.p=5,t.v,(0,c.Qg)((0,i.Tl)("budget","Failed to detect recurring transfers"));case 6:return t.p=6,e.disabled=!1,e.innerHTML=' '.concat((0,i.Tl)("budget","Find Transfers")),t.f(6);case 7:return t.a(2)}},t,this,[[2,5,6,7]])})),function(){return e.apply(this,arguments)})},{key:"renderDetectedTransfers",value:function(t){var e=this,n=document.getElementById("detected-transfers-list");if(n){var a=(0,k.HB)(this.accounts),r=a.map(function(t){return'")}).join("");n.innerHTML=t.map(function(t,n){var c=t.confidence>=.8?"high":t.confidence>=.5?"medium":"low",l=Math.round(100*t.confidence),u=a.find(function(e){return e.id===t.accountId}),d=u?u.name:(0,i.Tl)("budget","Unknown");return'\n
\n
\n =.7?"checked":"",'>\n
\n
\n \n
\n ').concat(o.vv(t.amount,(0,k.$S)(e.accounts,t.accountId),e.settings),'\n ').concat(t.frequency,'\n ').concat((0,i.Tl)("budget","{percent}% confidence",{percent:l}),"\n ").concat((0,i.Tl)("budget","From: {account}",{account:d}),'\n
\n
\n \n \n
\n
\n
\n ")}).join(""),t.forEach(function(t,e){var r=n.querySelector('.detected-dest-account[data-index="'.concat(e,'"]')),i=t.suggestedDestinationAccountId;r&&i&&a.some(function(t){return t.id===i})&&(r.value=String(i))}),this._detectedTransfers=t}}},{key:"addSelectedDetectedTransfers",value:function(){var t=this;return(0,ee.O)("transfers-add-detected",document.getElementById("add-detected-transfers-btn"),function(){return t._addSelectedDetectedTransfers()})}},{key:"_addSelectedDetectedTransfers",value:(t=Tn(yn().m(function t(){var e,n,a,r,o,s,l,u,d,h,g;return yn().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.querySelectorAll('#detected-transfers-list input[type="checkbox"]:checked'),0!==(n=Array.from(e).map(function(t){return parseInt(t.id.replace("detected-transfer-",""))})).length){t.n=1;break}return(0,c.I9)((0,i.Tl)("budget","Please select at least one transfer to add")),t.a(2);case 1:a=[],r=dn(n),t.p=2,r.s();case 3:if((o=r.n()).done){t.n=7;break}if(s=o.value,l=document.querySelector('.detected-dest-account[data-index="'.concat(s,'"]')),u=l?parseInt(l.value):null){t.n=4;break}return(0,c.I9)((0,i.Tl)("budget","Please select a destination account for all selected transfers")),t.a(2);case 4:if(d=this._detectedTransfers[s],u!==d.accountId){t.n=5;break}return(0,c.I9)((0,i.Tl)("budget","Source and destination accounts must be different")),t.a(2);case 5:a.push(gn(gn({},d),{},{isTransfer:!0,destinationAccountId:u}));case 6:t.n=3;break;case 7:t.n=9;break;case 8:t.p=8,g=t.v,r.e(g);case 9:return t.p=9,r.f(),t.f(9);case 10:return t.p=10,t.n=11,(0,T.n)("/apps/budget/api/bills/create-from-detected",{method:"POST",body:{bills:a}});case 11:return h=t.v,document.getElementById("detected-transfers-panel").style.display="none",(0,c.Te)((0,i.zw)("budget","%n transfer added successfully","%n transfers added successfully",h.created)),t.n=12,this.loadTransfersView();case 12:t.n=14;break;case 13:t.p=13,t.v,(0,c.Qg)((0,i.Tl)("budget","Failed to add selected transfers"));case 14:return t.a(2)}},t,this,[[10,13],[2,8,9,10]])})),function(){return t.apply(this,arguments)})}]);var t,e,n,a,r,d,h,g,p,f,m,v,y,E,x}(),Sn=n(586),Cn="whats_new_seen";function In(t,e){for(var n=String(t).split(".").map(function(t){return parseInt(t,10)||0}),a=String(e).split(".").map(function(t){return parseInt(t,10)||0}),r=0;r0}).slice(0,3):[]}function Mn(t,e){return An(t,e).slice(0,3)}function Dn(){var t;return(null===(t=document.getElementById("app-content"))||void 0===t?void 0:t.dataset.appVersion)||""}const Bn=JSON.parse('[{"version":"3.3.0","title":"Calendar months in Category Details, and import and receipt fixes","items":["Category Details can show calendar months instead of budget periods.","CSV statements that leave empty cells off, such as Fortuneo\'s, now import every row.","Receipt scanning works with current Claude models.","Tags on a new transfer are saved, so savings goals count them.","Rules can add category tags."],"link":"https://github.com/otherworld-dev/Budget/blob/main/budget/CHANGELOG.md"},{"version":"3.2.0","title":"Category icons, receipt items sorted by your rules, and Monero","items":["Pick an icon for each category from about 60 in the category form.","Receipts split into items file each line under a category from your rules, and Remember saves a rule for next time.","Every amount box takes a decimal comma, such as 12,50, in any browser.","Monero (XMR) is in the currency list, with daily rates.","Repair Data can ignore a duplicate you have checked, so it stops coming back on every scan.","Category Details says when its bars are budget months rather than calendar months."],"link":"https://github.com/otherworld-dev/Budget/blob/main/budget/CHANGELOG.md"},{"version":"3.1.0","title":"Your own colours, and bills that are only paid once","items":["Pick the colours for money in and money out under Settings > Colours, including a colour-blind friendly preset. Amounts, budget bars, charts and PDF exports all follow them.","A transaction\'s menu has Link to bill, which files a payment you entered yourself under one of your bills, so it shows in Bills by Month.","Mark Paid asks before paying anything twice. When a bill already has a payment for its date you can use that payment, and a double click only counts once.","Bills by Month shows each payment in the month it was paid and the due date it paid, and counts a payment made either side of New Year once.","Importing a CSV again with the columns mapped differently no longer adds it a second time, even after you have edited a payee.","Repair Data finds more payments that older versions recorded twice.","The Transactions list keeps its headings and page controls in view, and works better on a laptop or a phone."],"link":"https://github.com/otherworld-dev/Budget/blob/main/budget/CHANGELOG.md"},{"version":"3.0.0","title":"Budget 3.0, the first release out of beta","items":["Budget is out of beta. 3.0 is the first release considered stable, every part of the app was reviewed and tested ahead of it, upgrading from 2.x included, so the beta warning has gone. Making a backup from Settings every now and then is still a good idea.","There is now an Android app, Budget Companion, on Google Play. Photograph a receipt and your own server reads it (when receipt scanning is set up), add a transaction by hand when there is no receipt, and check your balances, what is left of this month\'s budget and the bills due. Anything you enter without a signal is sent once you are back online.","An import folder: drop a bank statement into a folder in your Files and it is imported in the background, or held for you to check first. It is set up under Settings.","Statements can be imported straight from Excel and LibreOffice (.xls, .xlsx and .ods), and exports from Firefly III, YNAB, Actual Budget, Mint and Monarch Money can be brought across.","Sharing has a Full control level as well as Read only and Read & Write, and the Budget page has a Ready to Assign card, with weekly, quarterly and yearly budgets measured over the month.","The Transactions page works on a phone, the sidebar matches the rest of Nextcloud and the app opens faster.","Someone new to Budget gets a getting started checklist, and can try it out with sample data first."],"link":"https://github.com/otherworld-dev/Budget/blob/main/budget/CHANGELOG.md","links":[{"url":"https://play.google.com/store/apps/details?id=dev.otherworld.budget","text":"Get Budget Companion on Google Play"}]},{"version":"2.54.0","title":"Skipping transfers and a projected balance","items":["Transfers can now be skipped the same as bills, the due date moves on one cycle and Undo puts it back.","Pick an account in the Bills Calendar\'s Account filter and a Projected balance row shows what it should hold at the end of each month for the rest of the year.","Paid bills show the date they were paid as well as when they are next due.","A payment marked paid with no transaction behind it can be dismissed, rather than being listed for 60 days.","The import review warns about rows with no description, since import rules cannot categorise them."],"link":"https://github.com/otherworld-dev/Budget/blob/main/budget/CHANGELOG.md"}]');function Ln(t){return Ln="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ln(t)}function Pn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,r,i,o,s=[],c=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(s.push(a.value),s.length!==e);c=!0);}catch(t){l=!0,r=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return On(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?On(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function On(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n3?(r=p===a)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),s=u,c=p;(e=s<2?t:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),g(s,c)):h.n=c:h.v=c);try{if(l=2,i){if(s||(r="next"),e=i[r]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=t}else if((e=(d=h.n<0)?c:n.call(a,h))!==o)break}catch(e){i=t,s=1,c=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),l}var o={};function s(){}function c(){}function l(){}e=Object.getPrototypeOf;var u=[][a]?e(e([][a]())):(Rn(e={},a,function(){return this}),e),d=l.prototype=s.prototype=Object.create(u);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Rn(t,r,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,Rn(d,"constructor",l),Rn(l,"constructor",c),c.displayName="GeneratorFunction",Rn(l,r,"GeneratorFunction"),Rn(d),Rn(d,r,"Generator"),Rn(d,a,function(){return this}),Rn(d,"toString",function(){return"[object Generator]"}),(Fn=function(){return{w:i,m:h}})()}function Rn(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}Rn=function(t,e,n,a){function i(e,n){Rn(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},Rn(t,e,n,a)}function Nn(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function jn(t){return function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){Nn(i,a,r,o,s,"next",t)}function s(t){Nn(i,a,r,o,s,"throw",t)}o(void 0)})}}function Hn(t,e){for(var n=0;n0)){t.n=3;break}return t.n=3,(0,l.so)(r);case 3:return t.p=3,t.n=4,(0,T.n)("/apps/budget/api/settings/".concat(Cn),{method:"PUT",body:{value:n}});case 4:this.app.settings[Cn]=n,t.n=6;break;case 5:t.p=5,i=t.v,console.error("Failed to record the seen release notes:",i);case 6:return t.a(2)}},t,this,[[3,5]])})),function(){return e.apply(this,arguments)})},{key:"setupWhatsNewButton",value:function(){var t=document.getElementById("help-whats-new-btn");if(t){var e=Mn(Bn,Dn());t.style.display=0===e.length?"none":"",t.dataset.bound||(t.dataset.bound="1",t.addEventListener("click",function(){var t=Mn(Bn,Dn());t.length>0&&(0,l.so)(t)}))}}},{key:"renderDocLinks",value:function(){var t=document.getElementById("help-docs-grid");t&&(t.innerHTML=Object.entries(qn).filter(function(t){return"help"!==Pn(t,1)[0]}).map(function(t){var e=Pn(t,2)[1];return'\n \n ').concat(e.title(),'\n ').concat(e.summary(),"\n \n ")}).join(""))}},{key:"setupShortcutsButton",value:function(){var t=this,e=document.getElementById("help-view-shortcuts-btn");e&&!e.dataset.bound&&(e.dataset.bound="1",e.addEventListener("click",function(){return t.app.keyboardShortcuts.openShortcuts()}))}},{key:"setupReportIssueButton",value:function(){this.bindExternalLink("help-report-issue-btn","https://github.com/otherworld-dev/budget/issues"),this.bindExternalLink("help-docs-site-btn",Un),this.bindExternalLink("help-sponsor-github-btn",Gn),this.bindExternalLink("help-donate-paypal-btn",Zn)}},{key:"bindExternalLink",value:function(t,e){var n=document.getElementById(t);n&&!n.dataset.bound&&(n.dataset.bound="1",n.addEventListener("click",function(){return window.open(e,"_blank","noopener")}))}},{key:"setupQuickAddUrlCopy",value:function(){var t=document.getElementById("copy-quick-add-url"),e=document.getElementById("quick-add-url");t&&e&&!this.quickAddCopyBound&&(this.quickAddCopyBound=!0,t.addEventListener("click",function(){navigator.clipboard.writeText(e.value).then(function(){(0,c.Te)((0,i.Tl)("budget","URL copied to clipboard"))}).catch(function(){e.select(),document.execCommand("copy"),(0,c.Te)((0,i.Tl)("budget","URL copied to clipboard"))})}))}},{key:"loadSystemInfo",value:(t=jn(Fn().m(function t(){var e,n,a,r,o,l,u,d,h,g,p;return Fn().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=document.getElementById("system-info-content")){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,(0,T.n)("/apps/budget/api/setup/system-info",{errorMessage:"Failed to load"});case 2:a=t.v,r="".concat((null===(n=navigator.userAgent.match(/(?:Firefox|Chrome|Safari|Edge)\/[\d.]+/))||void 0===n?void 0:n[0])||navigator.userAgent.substring(0,50)),o=window.budgetDiagnostics||{errors:[],failedRequests:[]},l=[["Budget Version",a.appVersion],["Nextcloud Version",a.nextcloudVersion],["PHP Version",a.phpVersion],["Database",a.database],["Browser",r],["Accounts",a.accounts],["Transactions",a.transactions],["Categories",a.categories],["Rules","".concat(a.activeRules," active / ").concat(a.rules," total")],["Bills",a.bills],["Bank Sync",a.bankSyncConnections>0?"".concat(a.bankSyncConnections," connection(s)"):"None"],["Sharing",a.sharingOut>0||a.sharingIn>0?"".concat(a.sharingOut," outgoing, ").concat(a.sharingIn," incoming"):"None"],["Screen","".concat(window.screen.width,"x").concat(window.screen.height," (viewport: ").concat(window.innerWidth,"x").concat(window.innerHeight,")")]],u=''.concat(l.map(function(t){var e=Pn(t,2),n=e[0],a=e[1];return'")}).join(""),"
'.concat((0,s.ZD)(n),'').concat((0,s.ZD)(a),"
"),o.failedRequests.length>0&&(u+='

'.concat((0,i.Tl)("budget","Failed API Requests")," (").concat(o.failedRequests.length,")

"),u+='
'.concat(o.failedRequests.map(function(t){return'
'.concat((0,s.ZD)(t.time.substring(11,19))," ").concat((0,s.ZD)(t.method)," ").concat((0,s.ZD)(t.url)," → ").concat((0,s.ZD)(t.status),"
")}).join(""),"
")),o.errors.length>0&&(u+='

'.concat((0,i.Tl)("budget","JavaScript Errors")," (").concat(o.errors.length,")

"),u+='
'.concat(o.errors.map(function(t){return'
'.concat((0,s.ZD)(t.time.substring(11,19))," ").concat((0,s.ZD)(t.message)).concat(t.source?(0,s.ZD)(" ("+t.source+":"+t.line+")"):"","
")}).join(""),"
")),0===o.failedRequests.length&&(u+='

✔ '.concat((0,i.Tl)("budget","No failed API requests this session"),"

")),0===o.errors.length&&(u+='

✔ '.concat((0,i.Tl)("budget","No JavaScript errors this session"),"

")),a.serverLogs&&a.serverLogs.length>0?(d={0:"DEBUG",1:"INFO",2:"WARN",3:"ERROR",4:"FATAL"},u+='

'.concat((0,i.Tl)("budget","Server Logs (Budget)")," (").concat(a.serverLogs.length,")

"),u+='
'.concat(a.serverLogs.map(function(t){return'
').concat((0,s.ZD)(t.time.substring(11,19))," [").concat((0,s.ZD)(d[t.level]||t.level),"] ").concat((0,s.ZD)(t.message),"
")}).join(""),"
")):void 0!==a.serverLogs&&(u+='

✔ '.concat((0,i.Tl)("budget","No server errors logged"),"

")),e.innerHTML=u,h=l.map(function(t){var e=Pn(t,2),n=e[0],a=e[1];return"".concat(n,": ").concat(a)}).join("\n"),h+="\n\nFailed API Requests: "+(0===o.failedRequests.length?"None":o.failedRequests.length),o.failedRequests.length>0&&(h+="\n"+o.failedRequests.map(function(t){return" ".concat(t.time.substring(11,19)," ").concat(t.method," ").concat(t.url," → ").concat(t.status)}).join("\n")),h+="\nJavaScript Errors: "+(0===o.errors.length?"None":o.errors.length),o.errors.length>0&&(h+="\n"+o.errors.map(function(t){return" ".concat(t.time.substring(11,19)," ").concat(t.message).concat(t.source?" ("+t.source+":"+t.line+")":"")}).join("\n")),void 0!==a.serverLogs&&(g={0:"DEBUG",1:"INFO",2:"WARN",3:"ERROR",4:"FATAL"},h+="\nServer Logs: "+(0===a.serverLogs.length?"None":a.serverLogs.length),a.serverLogs.length>0&&(h+="\n"+a.serverLogs.map(function(t){return" ".concat(t.time.substring(11,19)," [").concat(g[t.level]||t.level,"] ").concat(t.message)}).join("\n"))),e.dataset.plaintext=h,(p=document.getElementById("copy-system-info-btn"))&&(p.onclick=function(){navigator.clipboard.writeText(e.dataset.plaintext).then(function(){(0,c.Te)((0,i.Tl)("budget","Copied to clipboard"))}).catch(function(){var t=document.createElement("textarea");t.value=e.dataset.plaintext,document.body.appendChild(t),t.select(),document.execCommand("copy"),t.remove(),(0,c.Te)((0,i.Tl)("budget","Copied to clipboard"))})}),t.n=4;break;case 3:t.p=3,t.v,e.innerHTML="

".concat((0,i.Tl)("budget","Failed to load system info"),"

");case 4:return t.a(2)}},t,null,[[1,3]])})),function(){return t.apply(this,arguments)})}]);var t,e}(),Qn=["leftAlone"];function $n(t,e,n){return(e=ra(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Kn(t,e){if(null==t)return{};var n,a,r=function(t,e){if(null==t)return{};var n={};for(var a in t)if({}.hasOwnProperty.call(t,a)){if(-1!==e.indexOf(a))continue;n[a]=t[a]}return n}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(a=0;a3?(r=p===a)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),s=u,c=p;(e=s<2?t:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),g(s,c)):h.n=c:h.v=c);try{if(l=2,i){if(s||(r="next"),e=i[r]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=t}else if((e=(d=h.n<0)?c:n.call(a,h))!==o)break}catch(e){i=t,s=1,c=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),l}var o={};function s(){}function c(){}function l(){}e=Object.getPrototypeOf;var u=[][a]?e(e([][a]())):(ta(e={},a,function(){return this}),e),d=l.prototype=s.prototype=Object.create(u);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,ta(t,r,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,ta(d,"constructor",l),ta(l,"constructor",c),c.displayName="GeneratorFunction",ta(l,r,"GeneratorFunction"),ta(d),ta(d,r,"Generator"),ta(d,a,function(){return this}),ta(d,"toString",function(){return"[object Generator]"}),(Jn=function(){return{w:i,m:h}})()}function ta(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}ta=function(t,e,n,a){function i(e,n){ta(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},ta(t,e,n,a)}function ea(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function na(t){return function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){ea(i,a,r,o,s,"next",t)}function s(t){ea(i,a,r,o,s,"throw",t)}o(void 0)})}}function aa(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,a=Array(e);n0});if(0===e.length)return"";if(1===e.length){var n=ia(e[0],2),a=n[0],r=n[1];return(0,i.zw)("budget","{folder} already holds a file. It stays where it is: only files added from now on are imported.","{folder} already holds %n files. They stay where they are: only files added from now on are imported.",r,{folder:a},{escape:!1})}return(0,i.Tl)("budget","Files already in {folders} stay where they are: only files added from now on are imported.",{folders:e.map(function(t){return ia(t,1)[0]}).join(", ")},void 0,{escape:!1})}var da=function(){return function(t,e){return e&&aa(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(e){var n=e.getAccounts;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.getAccounts=n,this.folders=[],this.templates=[],this.bound=!1},[{key:"load",value:(o=na(Jn().m(function t(){var e,n,a,r,i;return Jn().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,Promise.all([(0,T.n)(la),(0,T.n)("/apps/budget/api/import-templates")]);case 1:e=t.v,n=ia(e,2),a=n[0],r=n[1],this.folders=(null==a?void 0:a.folders)||[],this.templates=Array.isArray(r)?r:[],t.n=3;break;case 2:t.p=2,i=t.v,console.error("Failed to load import folders:",i),this.folders=[];case 3:this.fillPickers(),this.render(),this.bind();case 4:return t.a(2)}},t,this,[[0,2]])})),function(){return o.apply(this,arguments)})},{key:"refresh",value:(r=na(Jn().m(function t(){var e,n;return Jn().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,(0,T.n)(la);case 1:e=t.v,this.folders=(null==e?void 0:e.folders)||[],this.render(),t.n=3;break;case 2:t.p=2,n=t.v,console.error("Failed to reload import folders:",n);case 3:return t.a(2)}},t,this,[[0,2]])})),function(){return r.apply(this,arguments)})},{key:"accounts",value:function(t){return(0,k.FG)(this.getAccounts()||[],t?[t]:[])}},{key:"accountOptions",value:function(t,e){t.replaceChildren.apply(t,Xn(this.accounts(e).map(function(t){return new Option(t.name,String(t.id))}))),null!=e&&(t.value=String(e))}},{key:"modeOptions",value:function(t,e){t.replaceChildren(new Option((0,i.Tl)("budget","Import automatically"),"auto"),new Option((0,i.Tl)("budget","Hold for review"),"review")),t.value="review"===e?"review":"auto"}},{key:"templateOptions",value:function(t,e){t.replaceChildren.apply(t,[new Option((0,i.Tl)("budget","None (OFX, QIF and camt files only)"),"")].concat(Xn(this.templates.map(function(t){return new Option("".concat(t.name," (").concat(String(t.format||"csv").toUpperCase(),")"),String(t.id))})))),t.value=e?String(e):""}},{key:"fillPickers",value:function(){var t=document.getElementById("import-folder-account"),e=document.getElementById("import-folder-template");t&&this.accountOptions(t),e&&this.templateOptions(e)}},{key:"render",value:function(){var t=this,e=document.getElementById("import-folders-list"),n=document.getElementById("import-folders-table"),a=document.getElementById("import-folders-empty");e&&(e.replaceChildren.apply(e,Xn(this.folders.map(function(e){return t.row(e)}))),n&&(n.hidden=0===this.folders.length),a&&(a.hidden=this.folders.length>0))}},{key:"row",value:function(t){var e=document.createElement("tr");e.dataset.id=String(t.id);var n=document.createElement("th");n.scope="row",n.textContent=t.name;var a=document.createElement("select");a.dataset.field="accountId",a.setAttribute("aria-label",(0,i.Tl)("budget","Account for {folder}",{folder:t.name},void 0,{escape:!1})),this.accountOptions(a,t.accountId);var r=document.createElement("select");r.dataset.field="templateId",r.setAttribute("aria-label",(0,i.Tl)("budget","Import template for {folder}",{folder:t.name},void 0,{escape:!1})),this.templateOptions(r,t.templateId);var o=document.createElement("select");o.dataset.field="mode",o.setAttribute("aria-label",(0,i.Tl)("budget","When a file arrives in {folder}",{folder:t.name},void 0,{escape:!1})),this.modeOptions(o,t.mode);var s=document.createElement("input");s.type="checkbox",s.dataset.field="enabled",s.checked=!!t.enabled,s.setAttribute("aria-label",(0,i.Tl)("budget","Import files dropped into {folder}",{folder:t.name},void 0,{escape:!1}));var c=document.createElement("button");c.type="button",c.className="icon-delete",c.setAttribute("aria-label",(0,i.Tl)("budget","Remove {folder}",{folder:t.name},void 0,{escape:!1})),c.title=(0,i.Tl)("budget","Remove");for(var l=0,u=[n,a,r,o,s,c];l0&&u.push((0,i.zw)("budget","%n file imported","%n files imported",n)),l>0&&u.push((0,i.zw)("budget","%n file ready to review","%n files ready to review",l)),r>0&&u.push((0,i.zw)("budget","%n file could not be imported","%n files could not be imported",r)),s>0&&u.push((0,i.zw)("budget","%n file still uploading or waiting its turn","%n files still uploading or waiting their turn",s)),u.length?u.join(", "):(0,i.Tl)("budget","Nothing to import")}}]);var t,e,n,a,r,o}();function ha(t){return ha="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ha(t)}function ga(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,r,i,o,s=[],c=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(a=i.call(n)).done)&&(s.push(a.value),s.length!==e);c=!0);}catch(t){l=!0,r=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return pa(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pa(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pa(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n3?(r=p===a)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=g&&((r=n<2&&ga||a>p)&&(i[4]=n,i[5]=a,h.n=p,s=0))}if(r||n>1)return o;throw d=!0,a}return function(r,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&g(u,p),s=u,c=p;(e=s<2?t:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),g(s,c)):h.n=c:h.v=c);try{if(l=2,i){if(s||(r="next"),e=i[r]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),s=1);i=t}else if((e=(d=h.n<0)?c:n.call(a,h))!==o)break}catch(e){i=t,s=1,c=e}finally{l=1}}return{value:e,done:d}}}(n,r,i),!0),l}var o={};function s(){}function c(){}function l(){}e=Object.getPrototypeOf;var u=[][a]?e(e([][a]())):(ma(e={},a,function(){return this}),e),d=l.prototype=s.prototype=Object.create(u);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,ma(t,r,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,ma(d,"constructor",l),ma(l,"constructor",c),c.displayName="GeneratorFunction",ma(l,r,"GeneratorFunction"),ma(d),ma(d,r,"Generator"),ma(d,a,function(){return this}),ma(d,"toString",function(){return"[object Generator]"}),(fa=function(){return{w:i,m:h}})()}function ma(t,e,n,a){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}ma=function(t,e,n,a){function i(e,n){ma(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!a,configurable:!a,writable:!a}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},ma(t,e,n,a)}function va(t,e,n,a,r,i,o){try{var s=t[i](o),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(a,r)}function ya(t){return function(){var e=this,n=arguments;return new Promise(function(a,r){var i=t.apply(e,n);function o(t){va(i,a,r,o,s,"next",t)}function s(t){va(i,a,r,o,s,"throw",t)}o(void 0)})}}function ba(t,e){for(var n=0;n0&&void 0!==g[0]?g[0]:null)||{provider:document.getElementById("setting-ocr-provider").value,endpoint:document.getElementById("setting-ocr-endpoint").value.trim(),model:document.getElementById("setting-ocr-model").value.trim()},e||""!==(a=document.getElementById("setting-ocr-api-key").value).trim()&&(n.apiKey=a),t.p=1,t.n=2,(0,T.n)("/apps/budget/api/admin/settings",{method:"PUT",body:{ocr:n},errorMessage:(0,i.Tl)("budget","Failed to save admin settings")});case 2:d=t.v,this.ocrState={apiKeySet:!(null===(r=d.ocr)||void 0===r||!r.apiKeySet),nextcloudAiAvailable:!(null===(o=d.ocr)||void 0===o||!o.nextcloudAiAvailable),relayBillingBase:(null===(s=d.ocr)||void 0===s?void 0:s.relayBillingBase)||(null===(l=this.ocrState)||void 0===l?void 0:l.relayBillingBase)||"https://api.otherworld.dev/billing"},document.getElementById("setting-ocr-api-key").value="",this.renderOcrFields(),(0,c.Te)(null!==(u=d.ocr)&&void 0!==u&&u.configured?(0,i.Tl)("budget","Receipt scanning is on"):(0,i.Tl)("budget","Receipt scanning settings saved")),t.n=4;break;case 3:t.p=3,h=t.v,(0,c.Qg)(h.message||(0,i.Tl)("budget","Failed to save admin settings"));case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return s.apply(this,arguments)})},{key:"populateSettings",value:(o=ya(fa().m(function t(e){return fa().w(function(t){for(;;)switch(t.n){case 0:Object.keys(e).forEach(function(t){var n=document.getElementById("setting-".concat(t.replace(/_/g,"-")));if(n){var a=e[t];"checkbox"===n.type?n.checked="true"===a||!0===a:n.value=a}}),this.syncAmountColourControls();case 1:return t.a(2)}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"setupFolderPicker",value:function(t,e,n,a){var r=document.getElementById(t),i=document.getElementById(e);r&&i&&!r.dataset.bound&&(r.dataset.bound="1",r.addEventListener("click",function(){var t=i.value.trim()||a;OC.dialogs.filepicker(n,function(t){i.value=String(t||"").replace(/^\/+|\/+$/g,""),i.dispatchEvent(new Event("change",{bubbles:!0}))},!1,"httpd/unix-directory",!0,OC.dialogs.FILEPICKER_TYPE_CHOOSE,"/"+t)}))}},{key:"setupReceiptFolderPicker",value:function(){this.setupFolderPicker("setting-receipt-folder-browse","setting-receipt-folder",(0,i.Tl)("budget","Select receipts folder"),"Budget/Receipts")}},{key:"setupImportFolderPicker",value:function(){this.setupFolderPicker("setting-import-folder-browse","setting-import-folder",(0,i.Tl)("budget","Select import folder"),"Budget/Import")}},{key:"setupAutoSave",value:function(){var e=this,n=document.getElementById("settings-view");n&&!n.dataset.autosaveBound&&(n.dataset.autosaveBound="1",n.addEventListener("change",function(n){if(n.target.closest(".amount-color-picker"))e.onAmountColourPickerChange();else{var a=n.target.closest(".setting-input");a&&(t.PREVIEW_INPUTS.includes(a.id)&&e.updateNumberFormatPreview(),"setting-amount-color-scheme"===a.id&&e.syncAmountColourControls(),e.saveSetting(a))}}),n.addEventListener("input",function(t){t.target.closest(".amount-color-picker")&&(e.updateAmountColourPreview(),e.updateAmountColourWarnings())}))}},{key:"setupJumpList",value:function(){var t=document.querySelector(".settings-jump");t&&!t.dataset.bound&&(t.dataset.bound="1",t.addEventListener("click",function(t){var e=t.target.closest("button[data-target]"),n=e&&document.getElementById(e.dataset.target);if(n){n.scrollIntoView({behavior:"smooth",block:"start"});var a=n.querySelector("h3");a&&(a.setAttribute("tabindex","-1"),a.focus({preventScroll:!0}))}}))}},{key:"settingEntry",value:function(t){return[t.id.replace("setting-","").replace(/-/g,"_"),"checkbox"===t.type?t.checked?"true":"false":t.value]}},{key:"saveSetting",value:function(t){var e=this,n=ga(this.settingEntry(t),1)[0];this.savesInFlight=this.savesInFlight||{};var a=this.savesInFlight[n];if(a)return a.element=t,a.again=!0,a.promise;var r={element:t,again:!1};return this.savesInFlight[n]=r,r.promise=ya(fa().m(function t(){var a,i,o,s,c;return fa().w(function(t){for(;;)switch(t.p=t.n){case 0:t.p=0,a=!0;case 1:if(!a&&!r.again){t.n=4;break}if(o=e.settingEntry(r.element),s=ga(o,2),c=s[1],a||c!==String(null===(i=e.settings)||void 0===i?void 0:i[n])){t.n=2;break}return t.a(3,4);case 2:return a=!1,r.again=!1,t.n=3,e.sendSetting(r.element,r);case 3:t.n=1;break;case 4:return t.p=4,delete e.savesInFlight[n],t.f(4);case 5:return t.a(2)}},t,null,[[0,,4,5]])}))(),r.promise}},{key:"sendSetting",value:(r=ya(fa().m(function t(e,n){var a,r,o,s,l,u,d,h,g,p,f,m,v;return fa().w(function(t){for(;;)switch(t.p=t.n){case 0:return a=this.settingEntry(e),r=ga(a,2),o=r[0],s=r[1],l=e.closest(".setting-item")||e.parentElement,t.p=1,t.n=2,(0,T.n)("/apps/budget/api/settings",{method:"PUT",body:wa({},o,s),errorMessage:(0,i.Tl)("budget","Failed to save settings")});case 2:h=t.v,g=null!==(u=null==h||null===(d=h.settings)||void 0===d?void 0:d[o])&&void 0!==u?u:s,n.again||"checkbox"===e.type||g===s||(e.value=g),this.settings[o]=g,this.applySettingSideEffects(wa({},o,g)),this.flashSaved(l),(p="import_folder"===o?ua(null==h?void 0:h.importFolderLeftAlone):"")&&(0,c.cf)(p),t.n=5;break;case 3:if(t.p=3,v=t.v,console.error("Error saving setting:",o,v),(0,c.Qg)(v.message||(0,i.Tl)("budget","Failed to save settings")),!n.again){t.n=4;break}return t.a(2);case 4:void 0!==(m=null===(f=this.settings)||void 0===f?void 0:f[o])&&("checkbox"===e.type?e.checked="true"===m||!0===m:e.value=m,"amount_color_custom"===o&&this.syncAmountColourControls());case 5:return t.a(2)}},t,this,[[1,3]])})),function(t,e){return r.apply(this,arguments)})},{key:"applySettingSideEffects",value:function(t){this.updateAccountFormDefaults(t),("amount_color_scheme"in t||"amount_color_custom"in t)&&(0,g.ET)(this.settings.amount_color_scheme,this.settings.amount_color_custom),("date_format"in t||"first_day_of_week"in t)&&(0,u.c6)(this.app.settings)}},{key:"flashSaved",value:function(t){if(t){var e=t.querySelector(":scope > .setting-saved");e||((e=document.createElement("span")).className="setting-saved",e.setAttribute("role","status"),t.appendChild(e)),e.textContent=(0,i.Tl)("budget","Saved"),e.classList.add("visible"),clearTimeout(e._timer),e._timer=setTimeout(function(){return e.classList.remove("visible")},2e3)}}},{key:"saveSettings",value:(a=ya(fa().m(function t(){var e,n;return fa().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,e=this.gatherSettings(),t.n=1,(0,T.n)("/apps/budget/api/settings",{method:"PUT",body:e});case 1:(0,c.Te)((0,i.Tl)("budget","Settings saved successfully")),Object.assign(this.settings,e),this.updateAccountFormDefaults(e),(0,u.c6)(this.app.settings),this.app.reloadCurrentView&&this.app.reloadCurrentView(),t.n=3;break;case 2:t.p=2,n=t.v,console.error("Error saving settings:",n),(0,c.Qg)((0,i.Tl)("budget","Failed to save settings"));case 3:return t.a(2)}},t,this,[[0,2]])})),function(){return a.apply(this,arguments)})},{key:"gatherSettings",value:function(){var t=document.querySelectorAll(".setting-input"),e={};return t.forEach(function(t){var n=t.id.replace("setting-","").replace(/-/g,"_");"checkbox"===t.type?e[n]=t.checked?"true":"false":e[n]=t.value}),e}},{key:"resetSettings",value:(n=ya(fa().m(function t(){var e,n;return fa().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.n=1,(0,l.ZD)((0,i.Tl)("budget","Are you sure you want to reset all settings to defaults? This action cannot be undone."),{destructive:!0});case 1:if(t.v){t.n=2;break}return t.a(2);case 2:return t.p=2,t.n=3,(0,T.n)("/apps/budget/api/settings/reset",{method:"POST"});case 3:return e=t.v,t.n=4,this.populateSettings(e.defaults);case 4:Object.assign(this.settings,e.defaults),this.applySettingSideEffects(e.defaults),this.updateNumberFormatPreview(),(0,c.Te)((0,i.Tl)("budget","Settings reset to defaults")),t.n=6;break;case 5:t.p=5,n=t.v,console.error("Error resetting settings:",n),(0,c.Qg)((0,i.Tl)("budget","Failed to reset settings"));case 6:return t.a(2)}},t,this,[[2,5]])})),function(){return n.apply(this,arguments)})},{key:"updateNumberFormatPreview",value:function(){var t,e,n,a,r,i=parseInt((null===(t=document.getElementById("setting-number-format-decimals"))||void 0===t?void 0:t.value)||"2"),o=(null===(e=document.getElementById("setting-number-format-decimal-sep"))||void 0===e?void 0:e.value)||".",s=null!==(n=null===(a=document.getElementById("setting-number-format-thousands-sep"))||void 0===a?void 0:a.value)&&void 0!==n?n:",",c={USD:"$",CAD:"C$",MXN:"MX$",BRL:"R$",ARS:"AR$",CLP:"CL$",COP:"CO$",PEN:"S/",EUR:"€",GBP:"£",CHF:"CHF",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"zł",CZK:"Kč",HUF:"Ft",RON:"lei",UAH:"₴",ISK:"kr",RUB:"₽",BYN:"Br",TRY:"₺",JPY:"¥",CNY:"¥",KRW:"₩",INR:"₹",IDR:"Rp",THB:"฿",PHP:"₱",MYR:"RM",VND:"₫",TWD:"NT$",SGD:"S$",HKD:"HK$",PKR:"Rs",BDT:"৳",AUD:"A$",NZD:"NZ$",AED:"AED",SAR:"SAR",QAR:"QAR",JOD:"JOD",ILS:"₪",EGP:"E£",NGN:"₦",KES:"KSh",ZAR:"R"}[(null===(r=document.getElementById("setting-default-currency"))||void 0===r?void 0:r.value)||"USD"]||"$",l=1234.56.toFixed(i).split("."),u=c+l[0].replace(/\B(?=(\d{3})+(?!\d))/g,s)+(i>0?o+l[1]:""),d=document.getElementById("number-format-preview");d&&(d.textContent=u)}},{key:"readAmountColourPickers",value:function(){for(var e={},n=0,a=Object.entries(t.AMOUNT_COLOUR_PICKERS);n