From 78153c2aa4dcec09f051504dd8443f1acc74ef55 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 28 Oct 2023 17:17:09 +0200 Subject: [PATCH] Update meta files for new release. --- .ci/php-cs-fixer/composer.lock | 12 +-- .../Model/Currency/IndexController.php | 21 +++++ .../Upgrade/UpgradeCurrencyPreferences.php | 21 +++++ .../TransactionCurrency/CreateController.php | 21 +++++ .../TransactionCurrency/DeleteController.php | 21 +++++ .../TransactionCurrency/EditController.php | 21 +++++ .../TransactionCurrency/IndexController.php | 21 +++++ .../Currency/CurrencyRepository.php | 21 +++++ .../Currency/CurrencyRepositoryInterface.php | 21 +++++ app/Support/Amount.php | 17 +--- app/Transformers/BillTransformer.php | 84 ++++++++++--------- app/Transformers/V2/BillTransformer.php | 2 + changelog.md | 28 +++---- ...10_21_113213_add_currency_pivot_tables.php | 21 +++++ package-lock.json | 18 ++-- public/build/assets/create-1321af8a.js | 1 + public/build/assets/create-baf83427.js | 1 - ...oard-daa2fdbe.js => dashboard-42661760.js} | 6 +- ...54502.js => load-translations-87b32220.js} | 8 +- public/build/manifest.json | 18 ++-- public/v2/i18n/ca_ES.json | 6 +- public/v2/i18n/es_ES.json | 6 +- public/v2/i18n/fr_FR.json | 6 +- public/v2/i18n/it_IT.json | 2 +- public/v2/i18n/ja_JP.json | 6 +- public/v2/i18n/pt_BR.json | 6 +- .../assets/v2/api/v2/model/currency/get.js | 35 ++++++++ .../assets/v2/api/v2/model/piggy-bank/get.js | 2 +- .../v2/api/v2/model/subscription/get.js | 2 +- .../assets/v2/api/v2/model/transaction/get.js | 2 +- .../assets/v2/pages/dashboard/piggies.js | 2 +- resources/assets/v2/pages/dashboard/sankey.js | 2 +- .../v2/pages/dashboard/subscriptions.js | 2 +- .../assets/v2/pages/transactions/create.js | 36 +++++++- .../transactions/shared/create-empty-split.js | 7 ++ .../transactions/shared/parse-from-entries.js | 1 + .../views/v2/transactions/create.blade.php | 25 ++---- routes/api.php | 42 +++++----- .../NavigationCustomEndOfPeriodTest.php | 21 +++++ 39 files changed, 433 insertions(+), 162 deletions(-) create mode 100644 public/build/assets/create-1321af8a.js delete mode 100644 public/build/assets/create-baf83427.js rename public/build/assets/{dashboard-daa2fdbe.js => dashboard-42661760.js} (96%) rename public/build/assets/{load-translations-9a154502.js => load-translations-87b32220.js} (88%) create mode 100644 resources/assets/v2/api/v2/model/currency/get.js diff --git a/.ci/php-cs-fixer/composer.lock b/.ci/php-cs-fixer/composer.lock index f97e8f97ee..e68e86b2d3 100644 --- a/.ci/php-cs-fixer/composer.lock +++ b/.ci/php-cs-fixer/composer.lock @@ -226,16 +226,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.36.0", + "version": "v3.37.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "e889301f276c6ce2c391d6aafae9a162e785b064" + "reference": "d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/e889301f276c6ce2c391d6aafae9a162e785b064", - "reference": "e889301f276c6ce2c391d6aafae9a162e785b064", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b", + "reference": "d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b", "shasum": "" }, "require": { @@ -307,7 +307,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.36.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.37.0" }, "funding": [ { @@ -315,7 +315,7 @@ "type": "github" } ], - "time": "2023-10-27T10:12:29+00:00" + "time": "2023-10-28T14:49:50+00:00" }, { "name": "psr/container", diff --git a/app/Api/V2/Controllers/Model/Currency/IndexController.php b/app/Api/V2/Controllers/Model/Currency/IndexController.php index 0e71ad2d27..e9ceca34d3 100644 --- a/app/Api/V2/Controllers/Model/Currency/IndexController.php +++ b/app/Api/V2/Controllers/Model/Currency/IndexController.php @@ -1,4 +1,25 @@ . + */ + declare(strict_types=1); namespace FireflyIII\Api\V2\Controllers\Model\Currency; diff --git a/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php b/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php index b6ee8c2a1c..b78ff5c57b 100644 --- a/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php +++ b/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php @@ -1,5 +1,26 @@ . + */ + declare(strict_types=1); namespace FireflyIII\Console\Commands\Upgrade; diff --git a/app/Http/Controllers/TransactionCurrency/CreateController.php b/app/Http/Controllers/TransactionCurrency/CreateController.php index 8742e45765..c3be3b01f2 100644 --- a/app/Http/Controllers/TransactionCurrency/CreateController.php +++ b/app/Http/Controllers/TransactionCurrency/CreateController.php @@ -1,5 +1,26 @@ . + */ + declare(strict_types=1); namespace FireflyIII\Http\Controllers\TransactionCurrency; diff --git a/app/Http/Controllers/TransactionCurrency/DeleteController.php b/app/Http/Controllers/TransactionCurrency/DeleteController.php index 00d36900dd..28190f5f49 100644 --- a/app/Http/Controllers/TransactionCurrency/DeleteController.php +++ b/app/Http/Controllers/TransactionCurrency/DeleteController.php @@ -1,5 +1,26 @@ . + */ + declare(strict_types=1); namespace FireflyIII\Http\Controllers\TransactionCurrency; diff --git a/app/Http/Controllers/TransactionCurrency/EditController.php b/app/Http/Controllers/TransactionCurrency/EditController.php index 8a38de1fd2..46f3e56272 100644 --- a/app/Http/Controllers/TransactionCurrency/EditController.php +++ b/app/Http/Controllers/TransactionCurrency/EditController.php @@ -1,5 +1,26 @@ . + */ + declare(strict_types=1); namespace FireflyIII\Http\Controllers\TransactionCurrency; diff --git a/app/Http/Controllers/TransactionCurrency/IndexController.php b/app/Http/Controllers/TransactionCurrency/IndexController.php index 35b943e445..d3e00e8952 100644 --- a/app/Http/Controllers/TransactionCurrency/IndexController.php +++ b/app/Http/Controllers/TransactionCurrency/IndexController.php @@ -1,5 +1,26 @@ . + */ + declare(strict_types=1); namespace FireflyIII\Http\Controllers\TransactionCurrency; diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.php index 12efef6f58..99c8763d6a 100644 --- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php +++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php @@ -1,5 +1,26 @@ . + */ + declare(strict_types=1); namespace FireflyIII\Repositories\UserGroups\Currency; diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php b/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php index 05b9699fe6..d81a11752c 100644 --- a/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php +++ b/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php @@ -1,5 +1,26 @@ . + */ + declare(strict_types=1); namespace FireflyIII\Repositories\UserGroups\Currency; diff --git a/app/Support/Amount.php b/app/Support/Amount.php index f5f44aafd1..cef4fbb730 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -126,25 +126,12 @@ class Amount /** * @param User $user - * + * @deprecated use getDefaultCurrencyByUserGroup instead. * @return TransactionCurrency */ public function getDefaultCurrencyByUser(User $user): TransactionCurrency { - $cache = new CacheProperties(); - $cache->addProperty('getDefaultCurrency'); - $cache->addProperty($user->id); - if ($cache->has()) { - return $cache->get(); - } - $default = $user->currencies()->where('user_default', true)->first(); - if (null === $default) { - $default = $this->getSystemCurrency(); - $user->currencies()->sync([$default->id => ['user_default' => true]]); - } - $cache->store($default); - - return $default; + return $this->getDefaultCurrencyByUserGroup($user->userGroup); } /** diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php index 97196f272c..b84222281f 100644 --- a/app/Transformers/BillTransformer.php +++ b/app/Transformers/BillTransformer.php @@ -57,11 +57,12 @@ class BillTransformer extends AbstractTransformer */ public function transform(Bill $bill): array { - $paidData = $this->paidData($bill); - $payDates = $this->payDates($bill); - $currency = $bill->transactionCurrency; - $notes = $this->repository->getNoteText($bill); - $notes = '' === $notes ? null : $notes; + $paidData = $this->paidData($bill); + $lastPaidDate = $this->getLastPaidDate($paidData); + $payDates = $this->payDates($bill, $lastPaidDate); + $currency = $bill->transactionCurrency; + $notes = $this->repository->getNoteText($bill); + $notes = '' === $notes ? null : $notes; $this->repository->setUser($bill->user); $objectGroupId = null; @@ -86,8 +87,8 @@ class BillTransformer extends AbstractTransformer $payDatesFormatted[] = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'))->toAtomString(); } $nextExpectedMatch = null; - if (null !== $paidData['next_expected_match']) { - $nextExpectedMatch = Carbon::createFromFormat('!Y-m-d', $paidData['next_expected_match'], config('app.timezone'))->toAtomString(); + if (null !== ($payDates[0] ?? null)) { + $nextExpectedMatch = Carbon::createFromFormat('!Y-m-d', $payDates[0], config('app.timezone'))->toAtomString(); } $nextExpectedMatchDiff = trans('firefly.not_expected_period'); // converting back and forth is bad code but OK. @@ -182,31 +183,6 @@ class BillTransformer extends AbstractTransformer $lastPaidDate = $this->lastPaidDate($set, $start); app('log')->debug(sprintf('Result of lastPaidDate is %s', $lastPaidDate->format('Y-m-d'))); - /* - * The next expected match (nextMatch) is, initially, the bill's date. - */ - $nextMatch = clone $bill->date; - /* - * Diff in months (or other period) between bill start and last paid date or $start. - */ - $steps = app('navigation')->diffInPeriods($bill->repeat_freq, $bill->skip, $start, $nextMatch); - $nextMatch = app('navigation')->addPeriod($nextMatch, $bill->repeat_freq, $steps); - - if ($nextMatch->lt($lastPaidDate)) { - /* - * Add another period because it's before the last paid date - */ - app('log')->debug('Because the last paid date was before our next expected match, add another period.'); - $nextMatch = app('navigation')->addPeriod($nextMatch, $bill->repeat_freq, $bill->skip); - } - - if ($nextMatch->isSameDay($lastPaidDate)) { - /* - * Add another period because it's the same day as the last paid date. - */ - app('log')->debug('Because the last paid date was on the same day as our next expected match, add another day.'); - $nextMatch = app('navigation')->addPeriod($nextMatch, $bill->repeat_freq, $bill->skip); - } /* * At this point the "next match" is exactly after the last time the bill was paid. */ @@ -219,11 +195,8 @@ class BillTransformer extends AbstractTransformer ]; } - app('log')->debug(sprintf('Next match: %s', $nextMatch->toIso8601String())); - return [ - 'paid_dates' => $result, - 'next_expected_match' => $nextMatch->format('Y-m-d'), + 'paid_dates' => $result ]; } @@ -253,12 +226,13 @@ class BillTransformer extends AbstractTransformer /** * @param Bill $bill + * @param Carbon $lastPaidDate * * @return array */ - protected function payDates(Bill $bill): array + protected function payDates(Bill $bill, ?Carbon $lastPaidDate): array { - app('log')->debug(sprintf('Now in payDates() for bill #%d', $bill->id)); + app('log')->debug(sprintf('Now in payDates(#%d, "%s")', $bill->id, $lastPaidDate?->format('Y-m-d'))); if (null === $this->parameters->get('start') || null === $this->parameters->get('end')) { app('log')->debug('No start or end date, give empty array.'); @@ -303,7 +277,11 @@ class BillTransformer extends AbstractTransformer } app('log')->debug(sprintf('Next expected match is %s', $nextExpectedMatch->format('Y-m-d'))); // add to set, if the date is ON or after the start parameter - if ($nextExpectedMatch->gte($this->parameters->get('start'))) { + // AND date is after last paid date + if ($nextExpectedMatch->gte($this->parameters->get('start')) + && (null === $lastPaidDate || $nextExpectedMatch->gt($lastPaidDate)) + ) { + app('log')->debug('Add date to set.'); $set->push(clone $nextExpectedMatch); } @@ -315,7 +293,7 @@ class BillTransformer extends AbstractTransformer $loop++; - if ($loop > 4) { + if ($loop > 12) { break; } } @@ -359,4 +337,30 @@ class BillTransformer extends AbstractTransformer app('log')->debug(sprintf('Number of steps is %d, result is %s', $steps, $result->format('Y-m-d'))); return $result; } + + /** + * @param array $paidData + * + * @return Carbon|null + */ + private function getLastPaidDate(array $paidData): ?Carbon + { + app('log')->debug('getLastPaidDate()'); + $return = null; + foreach ($paidData['paid_dates'] as $entry) { + if (null !== $return) { + $current = Carbon::createFromFormat('!Y-m-d', $entry['date'], config('app.timezone')); + if ($current->gt($return)) { + $return = clone $current; + } + app('log')->debug(sprintf('Last paid date is: %s', $return->format('Y-m-d'))); + } + if (null === $return) { + $return = Carbon::createFromFormat('!Y-m-d', $entry['date'], config('app.timezone')); + app('log')->debug(sprintf('Last paid date is: %s', $return->format('Y-m-d'))); + } + } + app('log')->debug(sprintf('Last paid date is: "%s"', $return?->format('Y-m-d'))); + return $return; + } } diff --git a/app/Transformers/V2/BillTransformer.php b/app/Transformers/V2/BillTransformer.php index 5d0ec63965..f5b87e21fe 100644 --- a/app/Transformers/V2/BillTransformer.php +++ b/app/Transformers/V2/BillTransformer.php @@ -358,6 +358,8 @@ class BillTransformer extends AbstractTransformer * Given a bill and a date, this method will tell you at which moment this bill expects its next * transaction. Whether or not it is there already, is not relevant. * + * TODO this method is bad compared to the v1 one. + * * @param Bill $bill * @param Carbon $date * diff --git a/changelog.md b/changelog.md index ae59582ee3..191a048581 100644 --- a/changelog.md +++ b/changelog.md @@ -3,40 +3,36 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## 6.0.28 - 2023-10-28 +## 6.0.28 - 2023-10-29 ### Added -- #8076 Clone and edit button -- #7204 ability to +- [Issue 8076](https://github.com/firefly-iii/firefly-iii/issues/8076) Added a "Clone and edit"-button +- [Issue 7204](https://github.com/firefly-iii/firefly-iii/issues/7204) Added the ability to customize the URL protocol types Firefly III accepts +- [Issue 8098](https://github.com/firefly-iii/firefly-iii/issues/8098) More tests in the navigation class, thanks @tonicospinelli! ### Changed -- New actions for GitHub -- Currencies are now linked to users, and can be enabled per user -- Refactored upgrade commands +- Refactored the Actions of GitHub +- The transaction currencies are now linked to users, and can be enabled per user +- A few upgrade commands are refactored - You can no longer edit vital parts of reconciled transactions ### Deprecated - Remove old v3 layout. -### Removed - -- Initial release. - ### Fixed - Bad math in the order of piggy banks -- #8084 @JoSchrader fixed an issue with a duplicate button - -### Security - -- Initial release. +- [Issue 8084](https://github.com/firefly-iii/firefly-iii/issues/8084) @JoSchrader fixed an issue with a duplicate button +- [Issue 8103](https://github.com/firefly-iii/firefly-iii/issues/8103) Bulk edit would not accept transaction descriptions longer than 255 characters +- [Issue 8099](https://github.com/firefly-iii/firefly-iii/issues/8099) The bill index would never skip the number of periods you indicated +- [Issue 8069](https://github.com/firefly-iii/firefly-iii/issues/8069) Rule descriptions would always "1" as description. Thanks @Maxco10! ### API -- Initial release. +- API will no longer accept changes to amount and account fields for reconciled transactions ## v6.0.27 - 2023-10-16 diff --git a/database/migrations/2023_10_21_113213_add_currency_pivot_tables.php b/database/migrations/2023_10_21_113213_add_currency_pivot_tables.php index cf8cda85a7..213a714df6 100644 --- a/database/migrations/2023_10_21_113213_add_currency_pivot_tables.php +++ b/database/migrations/2023_10_21_113213_add_currency_pivot_tables.php @@ -1,5 +1,26 @@ . + */ + declare(strict_types=1); use Illuminate\Database\Migrations\Migration; diff --git a/package-lock.json b/package-lock.json index 32a140e1b9..c7653edb49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -452,9 +452,9 @@ "dev": true }, "node_modules/axios": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.5.1.tgz", - "integrity": "sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.0.tgz", + "integrity": "sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg==", "dev": true, "dependencies": { "follow-redirects": "^1.15.0", @@ -498,9 +498,9 @@ } }, "node_modules/bootstrap5-autocomplete": { - "version": "1.1.22", - "resolved": "https://registry.npmjs.org/bootstrap5-autocomplete/-/bootstrap5-autocomplete-1.1.22.tgz", - "integrity": "sha512-vn4/+j/MmupcfQB9dwoGFadyk3OorxZh2Eyo8YVSBiaJBcaM1u+FYl0lgOCHQWRqN3MXqM4YCebo8xiyFIW/fw==" + "version": "1.1.23", + "resolved": "https://registry.npmjs.org/bootstrap5-autocomplete/-/bootstrap5-autocomplete-1.1.23.tgz", + "integrity": "sha512-jmqk7muFampKGPNzp6ABCAZWB38rfRpUyqx1vqn4Wssj88X1xODQGI+hnPAPGfePIjMLEK0Xhd1Is4kva1PUrg==" }, "node_modules/braces": { "version": "3.0.2", @@ -932,9 +932,9 @@ } }, "node_modules/sass": { - "version": "1.69.4", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.4.tgz", - "integrity": "sha512-+qEreVhqAy8o++aQfCJwp0sklr2xyEzkm9Pp/Igu9wNPoe7EZEQ8X/MBvvXggI2ql607cxKg/RKOwDj6pp2XDA==", + "version": "1.69.5", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.5.tgz", + "integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==", "dev": true, "dependencies": { "chokidar": ">=3.0.0 <4.0.0", diff --git a/public/build/assets/create-1321af8a.js b/public/build/assets/create-1321af8a.js new file mode 100644 index 0000000000..5b6df91c7a --- /dev/null +++ b/public/build/assets/create-1321af8a.js @@ -0,0 +1 @@ +var q=Object.defineProperty;var H=(n,e,t)=>e in n?q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var C=(n,e,t)=>(H(n,typeof e!="symbol"?e+"":e,t),t);import{x as P,w as M,J as j,z as R,I as z,A as $,y as V}from"./load-translations-87b32220.js";function A(){return{id:"",name:""}}function B(){let e=P(new Date,"yyyy-MM-dd HH:mm");return{description:"",amount:"",currency_code:"EUR",source_account:A(),destination_account:A(),date:e}}function W(n,e){let t=[];for(let s in n)if(n.hasOwnProperty(s)){const i=n[s];let o={};o.description=i.description,o.source_name=i.source_account.name,o.destination_name=i.destination_account.name,o.amount=i.amount,o.date=i.date,o.currency_code=i.currency_code,i.source_account.id.toString()!==""&&(o.source_id=i.source_account.id),i.destination_account.id.toString()!==""&&(o.destination_id=i.destination_account.id),o.type=e,t.push(o)}return t}const T={showAllSuggestions:!1,suggestionsThreshold:1,maximumItems:0,autoselectFirst:!0,ignoreEnter:!1,updateOnSelect:!1,highlightTyped:!1,highlightClass:"",fullWidth:!1,fixed:!1,fuzzy:!1,startsWith:!1,preventBrowserAutocomplete:!1,itemClass:"",activeClasses:["bg-primary","text-white"],labelField:"label",valueField:"value",searchFields:["label"],queryParam:"query",items:[],source:null,hiddenInput:!1,hiddenValue:"",clearControl:"",datalist:"",server:"",serverMethod:"GET",serverParams:{},serverDataKey:"data",fetchOptions:{},liveServer:!1,noCache:!0,debounceTime:300,notFoundMessage:"",onRenderItem:(n,e,t)=>e,onSelectItem:(n,e)=>{},onServerResponse:(n,e)=>n.json(),onChange:(n,e)=>{},onBeforeFetch:n=>{},onAfterFetch:n=>{}},x="is-loading",L="is-active",p="show",_="next",b="prev",g=new WeakMap;let k=0,v=0;function U(n,e=300){let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>{n.apply(this,s)},e)}}function G(n){return n.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function y(n){return n?G(n.toString()).toLowerCase():""}function K(n,e){if(n.indexOf(e)>=0)return!0;let t=0;for(let s=0;se+"‍").join("")}class I{constructor(e,t={}){C(this,"handleEvent",e=>{["scroll","resize"].includes(e.type)?(this._timer&&window.cancelAnimationFrame(this._timer),this._timer=window.requestAnimationFrame(()=>{this[`on${e.type}`](e)})):this[`on${e.type}`](e)});if(!(e instanceof HTMLElement)){console.error("Invalid element",e);return}g.set(e,this),k++,v++,this._searchInput=e,this._configure(t),this._preventInput=!1,this._keyboardNavigation=!1,this._searchFunc=U(()=>{this._loadFromServer(!0)},this._config.debounceTime),this._configureSearchInput(),this._configureDropElement(),this._config.fixed&&(document.addEventListener("scroll",this,!0),window.addEventListener("resize",this));const s=this._getClearControl();s&&s.addEventListener("click",this),["focus","change","blur","input","keydown"].forEach(i=>{this._searchInput.addEventListener(i,this)}),["mousemove","mouseleave"].forEach(i=>{this._dropElement.addEventListener(i,this)}),this._fetchData()}static init(e="input.autocomplete",t={}){document.querySelectorAll(e).forEach(i=>{this.getOrCreateInstance(i,t)})}static getInstance(e){return g.has(e)?g.get(e):null}static getOrCreateInstance(e,t={}){return this.getInstance(e)||new this(e,t)}dispose(){v--,["focus","change","blur","input","keydown"].forEach(t=>{this._searchInput.removeEventListener(t,this)}),["mousemove","mouseleave"].forEach(t=>{this._dropElement.removeEventListener(t,this)});const e=this._getClearControl();e&&e.removeEventListener("click",this),this._config.fixed&&v<=0&&(document.removeEventListener("scroll",this,!0),window.removeEventListener("resize",this)),this._dropElement.parentElement.removeChild(this._dropElement),g.delete(this._searchInput)}_getClearControl(){if(this._config.clearControl)return document.querySelector(this._config.clearControl)}_configure(e={}){this._config=Object.assign({},T);const t={...e,...this._searchInput.dataset},s=i=>["true","false","1","0",!0,!1].includes(i)&&!!JSON.parse(i);for(const[i,o]of Object.entries(T)){if(t[i]===void 0)continue;const a=t[i];switch(typeof o){case"number":this._config[i]=parseInt(a);break;case"boolean":this._config[i]=s(a);break;case"string":this._config[i]=a.toString();break;case"object":if(Array.isArray(o))if(typeof a=="string"){const r=a.includes("|")?"|":",";this._config[i]=a.split(r)}else this._config[i]=a;else this._config[i]=typeof a=="string"?JSON.parse(a):a;break;case"function":this._config[i]=typeof a=="string"?window[a]:a;break;default:this._config[i]=a;break}}}_configureSearchInput(){if(this._searchInput.autocomplete="off",this._searchInput.spellcheck=!1,w(this._searchInput,{"aria-autocomplete":"list","aria-haspopup":"menu","aria-expanded":"false",role:"combobox"}),this._searchInput.id&&this._config.preventBrowserAutocomplete){const e=document.querySelector(`[for="${this._searchInput.id}"]`);e&&X(e)}this._hiddenInput=null,this._config.hiddenInput&&(this._hiddenInput=document.createElement("input"),this._hiddenInput.type="hidden",this._hiddenInput.value=this._config.hiddenValue,this._hiddenInput.name=this._searchInput.name,this._searchInput.name="_"+this._searchInput.name,D(this._searchInput,this._hiddenInput))}_configureDropElement(){this._dropElement=document.createElement("ul"),this._dropElement.id="ac-menu-"+k,this._dropElement.classList.add("dropdown-menu","autocomplete-menu","p-0"),this._dropElement.style.maxHeight="280px",this._config.fullWidth||(this._dropElement.style.maxWidth="360px"),this._config.fixed&&(this._dropElement.style.position="fixed"),this._dropElement.style.overflowY="auto",this._dropElement.style.overscrollBehavior="contain",this._dropElement.style.textAlign="unset",D(this._searchInput,this._dropElement),this._searchInput.setAttribute("aria-controls",this._dropElement.id)}onclick(e){e.target.matches(this._config.clearControl)&&this.clear()}oninput(e){this._preventInput||(this._hiddenInput&&(this._hiddenInput.value=null),this.showOrSearch())}onchange(e){const t=this._searchInput.value,s=Object.values(this._items).find(i=>i.label===t);this._config.onChange(s,this)}onblur(e){this.hideSuggestions()}onfocus(e){this.showOrSearch()}onkeydown(e){switch(e.keyCode||e.key){case 13:case"Enter":if(this.isDropdownVisible()){const s=this.getSelection();s&&s.click(),(s||!this._config.ignoreEnter)&&e.preventDefault()}break;case 38:case"ArrowUp":e.preventDefault(),this._keyboardNavigation=!0,this._moveSelection(b);break;case 40:case"ArrowDown":e.preventDefault(),this._keyboardNavigation=!0,this.isDropdownVisible()?this._moveSelection(_):this.showOrSearch(!1);break;case 27:case"Escape":this.isDropdownVisible()&&(this._searchInput.focus(),this.hideSuggestions());break}}onmousemove(e){this._keyboardNavigation=!1}onmouseleave(e){this.removeSelection()}onscroll(e){this._positionMenu()}onresize(e){this._positionMenu()}getConfig(e=null){return e!==null?this._config[e]:this._config}setConfig(e,t){this._config[e]=t}setData(e){this._items={},this._addItems(e)}enable(){this._searchInput.setAttribute("disabled","")}disable(){this._searchInput.removeAttribute("disabled")}isDisabled(){return this._searchInput.hasAttribute("disabled")||this._searchInput.disabled||this._searchInput.hasAttribute("readonly")}isDropdownVisible(){return this._dropElement.classList.contains(p)}clear(){this._searchInput.value="",this._hiddenInput&&(this._hiddenInput.value="")}getSelection(){return this._dropElement.querySelector("a."+L)}removeSelection(){const e=this.getSelection();e&&e.classList.remove(...this._activeClasses())}_activeClasses(){return[...this._config.activeClasses,L]}_isItemEnabled(e){if(e.style.display==="none")return!1;const t=e.firstElementChild;return t.tagName==="A"&&!t.classList.contains("disabled")}_moveSelection(e=_,t=null){const s=this.getSelection();if(s){const i=e===_?"nextSibling":"previousSibling";t=s.parentNode;do t=t[i];while(t&&!this._isItemEnabled(t));t?(s.classList.remove(...this._activeClasses()),e===b?t.parentNode.scrollTop=t.offsetTop-t.parentNode.offsetTop:t.offsetTop>t.parentNode.offsetHeight-t.offsetHeight&&(t.parentNode.scrollTop+=t.offsetHeight)):s&&(t=s.parentElement)}else{if(e===b)return t;if(!t)for(t=this._dropElement.firstChild;t&&!this._isItemEnabled(t);)t=t.nextSibling}if(t){const i=t.querySelector("a");i.classList.add(...this._activeClasses()),this._searchInput.setAttribute("aria-activedescendant",i.id),this._config.updateOnSelect&&(this._searchInput.value=i.dataset.label)}else this._searchInput.setAttribute("aria-activedescendant","");return t}_shouldShow(){return this.isDisabled()?!1:this._searchInput.value.length>=this._config.suggestionsThreshold}showOrSearch(e=!0){if(e&&!this._shouldShow()){this.hideSuggestions();return}this._config.liveServer?this._searchFunc():this._config.source?this._config.source(this._searchInput.value,t=>{this.setData(t),this._showSuggestions()}):this._showSuggestions()}_createGroup(e){const t=this._createLi(),s=document.createElement("span");return t.append(s),s.classList.add("dropdown-header","text-truncate"),s.innerHTML=e,t}_createItem(e,t){let s=t.label;if(this._config.highlightTyped){const a=y(s).indexOf(e);a!==-1&&(s=s.substring(0,a)+`${s.substring(a,a+e.length)}`+s.substring(a+e.length,s.length))}s=this._config.onRenderItem(t,s,this);const i=this._createLi(),o=document.createElement("a");if(i.append(o),o.id=this._dropElement.id+"-"+this._dropElement.children.length,o.classList.add("dropdown-item","text-truncate"),this._config.itemClass&&o.classList.add(...this._config.itemClass.split(" ")),o.setAttribute("data-value",t.value),o.setAttribute("data-label",t.label),o.setAttribute("tabindex","-1"),o.setAttribute("role","menuitem"),o.setAttribute("href","#"),o.innerHTML=s,t.data)for(const[a,r]of Object.entries(t.data))o.dataset[a]=r;return o.addEventListener("mouseenter",a=>{this._keyboardNavigation||(this.removeSelection(),i.querySelector("a").classList.add(...this._activeClasses()))}),o.addEventListener("mousedown",a=>{a.preventDefault()}),o.addEventListener("click",a=>{a.preventDefault(),this._preventInput=!0,this._searchInput.value=J(t.label),this._hiddenInput&&(this._hiddenInput.value=t.value),this._config.onSelectItem(t,this),this.hideSuggestions(),this._preventInput=!1}),i}_showSuggestions(){if(document.activeElement!=this._searchInput)return;const e=y(this._searchInput.value);this._dropElement.innerHTML="";const t=Object.keys(this._items);let s=0,i=null;const o=[];for(let a=0;a0&&this._config.searchFields.forEach(d=>{const f=y(c[d]);let m=!1;if(this._config.fuzzy)m=K(f,e);else{const E=f.indexOf(e);m=this._config.startsWith?E===0:E>=0}m&&(l=!0)});const N=l||e.length===0;if(h||l){if(s++,c.group&&!o.includes(c.group)){const f=this._createGroup(c.group);this._dropElement.appendChild(f),o.push(c.group)}const d=this._createItem(e,c);if(!i&&N&&(i=d),this._dropElement.appendChild(d),this._config.maximumItems>0&&s>=this._config.maximumItems)break}}if(i&&this._config.autoselectFirst&&(this.removeSelection(),this._moveSelection(_,i)),s===0)if(this._config.notFoundMessage){const a=this._createLi();a.innerHTML=`${this._config.notFoundMessage}`,this._dropElement.appendChild(a),this._showDropdown()}else this.hideSuggestions();else this._showDropdown()}_createLi(){const e=document.createElement("li");return e.setAttribute("role","presentation"),e}_showDropdown(){this._dropElement.classList.add(p),this._dropElement.setAttribute("role","menu"),w(this._searchInput,{"aria-expanded":"true"}),this._positionMenu()}toggleSuggestions(e=!0){this._dropElement.classList.contains(p)?this.hideSuggestions():this.showOrSearch(e)}hideSuggestions(){this._dropElement.classList.remove(p),w(this._searchInput,{"aria-expanded":"false"}),this.removeSelection()}getInput(){return this._searchInput}getDropMenu(){return this._dropElement}_positionMenu(){const e=window.getComputedStyle(this._searchInput),t=this._searchInput.getBoundingClientRect(),s=e.direction==="rtl",i=this._config.fullWidth,o=this._config.fixed;let a=null,r=null;o&&(a=t.x,r=t.y+t.height,s&&!i&&(a-=this._dropElement.offsetWidth-t.width)),this._dropElement.style.transform="unset",i&&(this._dropElement.style.width=this._searchInput.offsetWidth+"px"),a!==null&&(this._dropElement.style.left=a+"px"),r!==null&&(this._dropElement.style.top=r+"px");const c=this._dropElement.getBoundingClientRect(),h=window.innerHeight;if(c.y+c.height>h){const l=i?t.height+4:t.height;this._dropElement.style.transform="translateY(calc(-100.1% - "+l+"px))"}}_fetchData(){this._items={},this._addItems(this._config.items);const e=this._config.datalist;if(e){const t=document.querySelector(`#${e}`);if(t){const s=Array.from(t.children).map(i=>{const o=i.getAttribute("value")??i.innerHTML.toLowerCase(),a=i.innerHTML;return{value:o,label:a}});this._addItems(s)}else console.error(`Datalist not found ${e}`)}this._setHiddenVal(),this._config.server&&!this._config.liveServer&&this._loadFromServer()}_setHiddenVal(){if(this._config.hiddenInput&&!this._config.hiddenValue)for(const[e,t]of Object.entries(this._items))t.label==this._searchInput.value&&(this._hiddenInput.value=e)}_addItems(e){const t=Object.keys(e);for(let s=0;sc.group=o.group),this._addItems(o.items);continue}const a=typeof o=="string"?o:o.label,r=typeof o!="object"?{}:o;r.label=o[this._config.labelField]??a,r.value=o[this._config.valueField]??i,r.label&&(this._items[r.value]=r)}}_loadFromServer(e=!1){this._abortController&&this._abortController.abort(),this._abortController=new AbortController;let t=this._searchInput.dataset.serverParams||{};typeof t=="string"&&(t=JSON.parse(t));const s=Object.assign({},this._config.serverParams,t);if(s[this._config.queryParam]=this._searchInput.value,this._config.noCache&&(s.t=Date.now()),s.related){const r=document.getElementById(s.related);if(r){s.related=r.value;const c=r.getAttribute("name");c&&(s[c]=r.value)}}const i=new URLSearchParams(s);let o=this._config.server,a=Object.assign(this._config.fetchOptions,{method:this._config.serverMethod||"GET",signal:this._abortController.signal});a.method==="POST"?a.body=i:o+="?"+i.toString(),this._searchInput.classList.add(x),this._config.onBeforeFetch(this),fetch(o,a).then(r=>this._config.onServerResponse(r,this)).then(r=>{const c=r[this._config.serverDataKey]||r;this.setData(c),this._setHiddenVal(),this._abortController=null,e&&this._showSuggestions()}).catch(r=>{r.name==="AbortError"||this._abortController.signal.aborted||console.error(r)}).finally(r=>{this._searchInput.classList.remove(x),this._config.onAfterFetch(this)})}}class Y{post(e){let t="/api/v2/transactions";return M.post(t,e)}}class Q{list(e){return M.get("/api/v2/currencies",{params:e})}}let u;const S={description:"/api/v2/autocomplete/transaction-descriptions",account:"/api/v2/autocomplete/accounts"};let Z=function(){return{count:0,totalAmount:0,transactionType:"unknown",showSuccessMessage:!1,showErrorMessage:!1,entries:[],loadingCurrencies:!0,defaultCurrency:{},enabledCurrencies:[],nativeCurrencies:[],foreignCurrencies:[],filters:{source:[],destination:[]},errorMessageText:"",detectTransactionType(){const n=this.entries[0].source_account.type??"unknown",e=this.entries[0].destination_account.type??"unknown";if(n==="unknown"&&e==="unknown"){this.transactionType="unknown",console.warn("Cannot infer transaction type from two unknown accounts.");return}if(n===e&&["Asset account","Loan","Debt","Mortgage"].includes(n)){this.transactionType="transfer",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(n==="Asset account"&&["Expense account","Debt","Loan","Mortgage"].includes(e)){this.transactionType="withdrawal",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(n==="Asset account"&&e==="unknown"){this.transactionType="withdrawal",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(["Debt","Loan","Mortgage"].includes(n)&&e==="Expense account"){this.transactionType="withdrawal",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(n==="Revenue account"&&["Asset account","Debt","Loan","Mortgage"].includes(e)){this.transactionType="deposit",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(["Debt","Loan","Mortgage"].includes(n)&&e==="Asset account"){this.transactionType="deposit",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}console.warn('Unknown account combination between "'+n+'" and "'+e+'".')},selectSourceAccount(n,e){const t=parseInt(e._searchInput.attributes["data-index"].value);document.querySelector("#form")._x_dataStack[0].$data.entries[t].source_account={id:n.id,name:n.name,type:n.type},console.log("Changed source account into a known "+n.type.toLowerCase())},changedAmount(n){const e=parseInt(n.target.dataset.index);this.entries[e].amount=parseFloat(n.target.value),this.totalAmount=0;for(let t in this.entries)this.entries.hasOwnProperty(t)&&(this.totalAmount=this.totalAmount+parseFloat(this.entries[t].amount));console.log("Changed amount to "+this.totalAmount)},selectDestAccount(n,e){const t=parseInt(e._searchInput.attributes["data-index"].value);document.querySelector("#form")._x_dataStack[0].$data.entries[t].destination_account={id:n.id,name:n.name,type:n.type},console.log("Changed destination account into a known "+n.type.toLowerCase())},loadCurrencies(){console.log("Loading user currencies."),new Q().list({}).then(e=>{for(let t in e.data.data)if(e.data.data.hasOwnProperty(t)){let s=e.data.data[t];if(s.attributes.enabled){let i={id:s.id,name:s.attributes.name,code:s.attributes.code,default:s.attributes.default,symbol:s.attributes.symbol,decimal_places:s.attributes.decimal_places};i.default&&(this.defaultCurrency=i),this.enabledCurrencies.push(i)}}this.loadingCurrencies=!1,console.log(this.enabledCurrencies)})},changeSourceAccount(n,e){if(typeof n>"u"){const t=parseInt(e._searchInput.attributes["data-index"].value);if(document.querySelector("#form")._x_dataStack[0].$data.entries[t].source_account.name===e._searchInput.value){console.warn('Ignore hallucinated source account name change to "'+e._searchInput.value+'"');return}document.querySelector("#form")._x_dataStack[0].$data.entries[t].source_account={name:e._searchInput.value},console.log('Changed source account into a unknown account called "'+e._searchInput.value+'"')}},changeDestAccount(n,e){if(typeof n>"u"){const t=parseInt(e._searchInput.attributes["data-index"].value);if(document.querySelector("#form")._x_dataStack[0].$data.entries[t].destination_account.name===e._searchInput.value){console.warn('Ignore hallucinated destination account name change to "'+e._searchInput.value+'"');return}document.querySelector("#form")._x_dataStack[0].$data.entries[t].destination_account={name:e._searchInput.value},console.log('Changed destination account into a unknown account called "'+e._searchInput.value+'"')}},showError:!1,showSuccess:!1,addedSplit(){console.log("addedSplit"),I.init("input.ac-source",{server:S.account,serverParams:{types:this.filters.source},fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}},hiddenInput:!0,preventBrowserAutocomplete:!0,highlightTyped:!0,liveServer:!0,onChange:this.changeSourceAccount,onSelectItem:this.selectSourceAccount,onRenderItem:function(n,e,t){return n.name_with_balance+'
'+u.t("firefly.account_type_"+n.type)+""}}),I.init("input.ac-dest",{server:S.account,serverParams:{types:this.filters.destination},fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}},hiddenInput:!0,preventBrowserAutocomplete:!0,liveServer:!0,highlightTyped:!0,onSelectItem:this.selectDestAccount,onChange:this.changeDestAccount,onRenderItem:function(n,e,t){return n.name_with_balance+'
'+u.t("firefly.account_type_"+n.type)+""}}),this.filters.destination=[],I.init("input.ac-description",{server:S.description,fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}},valueField:"id",labelField:"description",highlightTyped:!0,onSelectItem:console.log})},init(){Promise.all([R("language","en_US")]).then(n=>{u=new z;const e=n[0].replace("-","_");u.locale=e,$(u,e).then(()=>{this.addSplit()})}),this.loadCurrencies(),this.filters.source=["Asset account","Loan","Debt","Mortgage","Revenue account"],this.filters.destination=["Expense account","Loan","Debt","Mortgage","Asset account"]},submitTransaction(){this.detectTransactionType();let n=W(this.entries,this.transactionType),e={group_title:null,fire_webhooks:!1,apply_rules:!1,transactions:n};n.length>1&&(e.group_title=n[0].description);let t=new Y;console.log(e),t.post(e).then(s=>{this.showSuccessMessage=!0,console.log(s),window.location="transactions/show/"+s.data.data.id+"?transaction_group_id="+s.data.data.id+"&message=created"}).catch(s=>{this.showErrorMessage=!0,this.errorMessageText=s.response.data.message})},addSplit(){this.entries.push(B())},removeSplit(n){this.entries.splice(n,1),document.querySelector("#split-0-tab").click()},formattedTotalAmount(){return V(this.totalAmount,"EUR")}}},O={transactions:Z,dates:j};function F(){Object.keys(O).forEach(n=>{console.log(`Loading page component "${n}"`);let e=O[n]();Alpine.data(n,()=>e)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),F()});window.bootstrapped&&(console.log("Loaded through window variable."),F()); diff --git a/public/build/assets/create-baf83427.js b/public/build/assets/create-baf83427.js deleted file mode 100644 index b1cd642430..0000000000 --- a/public/build/assets/create-baf83427.js +++ /dev/null @@ -1 +0,0 @@ -var N=Object.defineProperty;var q=(n,e,t)=>e in n?N(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var C=(n,e,t)=>(q(n,typeof e!="symbol"?e+"":e,t),t);import{x as H,w as P,J as j,z as R,I as z,A as $,y as V}from"./load-translations-9a154502.js";function A(){return{id:"",name:""}}function B(){let e=H(new Date,"yyyy-MM-dd HH:mm");return{description:"",amount:"",source_account:A(),destination_account:A(),date:e}}function W(n,e){let t=[];for(let s in n)if(n.hasOwnProperty(s)){const i=n[s];let o={};o.description=i.description,o.source_name=i.source_account.name,o.destination_name=i.destination_account.name,o.amount=i.amount,o.date=i.date,i.source_account.id.toString()!==""&&(o.source_id=i.source_account.id),i.destination_account.id.toString()!==""&&(o.destination_id=i.destination_account.id),o.type=e,t.push(o)}return t}const T={showAllSuggestions:!1,suggestionsThreshold:1,maximumItems:0,autoselectFirst:!0,ignoreEnter:!1,updateOnSelect:!1,highlightTyped:!1,highlightClass:"",fullWidth:!1,fixed:!1,fuzzy:!1,startsWith:!1,preventBrowserAutocomplete:!1,itemClass:"",activeClasses:["bg-primary","text-white"],labelField:"label",valueField:"value",searchFields:["label"],queryParam:"query",items:[],source:null,hiddenInput:!1,hiddenValue:"",clearControl:"",datalist:"",server:"",serverMethod:"GET",serverParams:{},serverDataKey:"data",fetchOptions:{},liveServer:!1,noCache:!0,debounceTime:300,notFoundMessage:"",onRenderItem:(n,e,t)=>e,onSelectItem:(n,e)=>{},onServerResponse:(n,e)=>n.json(),onChange:(n,e)=>{}},x="is-loading",L="is-active",f="show",_="next",v="prev",g=new WeakMap;let k=0,b=0;function U(n,e=300){let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>{n.apply(this,s)},e)}}function G(n){return n.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function y(n){return n?G(n.toString()).toLowerCase():""}function K(n,e){if(n.indexOf(e)>=0)return!0;let t=0;for(let s=0;se+"‍").join("")}class I{constructor(e,t={}){C(this,"handleEvent",e=>{["scroll","resize"].includes(e.type)?(this._timer&&window.cancelAnimationFrame(this._timer),this._timer=window.requestAnimationFrame(()=>{this[`on${e.type}`](e)})):this[`on${e.type}`](e)});if(!(e instanceof HTMLElement)){console.error("Invalid element",e);return}g.set(e,this),k++,b++,this._searchInput=e,this._configure(t),this._preventInput=!1,this._keyboardNavigation=!1,this._searchFunc=U(()=>{this._loadFromServer(!0)},this._config.debounceTime),this._configureSearchInput(),this._configureDropElement(),this._config.fixed&&(document.addEventListener("scroll",this,!0),window.addEventListener("resize",this));const s=this._getClearControl();s&&s.addEventListener("click",this),["focus","change","blur","input","keydown"].forEach(i=>{this._searchInput.addEventListener(i,this)}),["mousemove","mouseleave"].forEach(i=>{this._dropElement.addEventListener(i,this)}),this._fetchData()}static init(e="input.autocomplete",t={}){document.querySelectorAll(e).forEach(i=>{this.getOrCreateInstance(i,t)})}static getInstance(e){return g.has(e)?g.get(e):null}static getOrCreateInstance(e,t={}){return this.getInstance(e)||new this(e,t)}dispose(){b--,["focus","change","blur","input","keydown"].forEach(t=>{this._searchInput.removeEventListener(t,this)}),["mousemove","mouseleave"].forEach(t=>{this._dropElement.removeEventListener(t,this)});const e=this._getClearControl();e&&e.removeEventListener("click",this),this._config.fixed&&b<=0&&(document.removeEventListener("scroll",this,!0),window.removeEventListener("resize",this)),this._dropElement.parentElement.removeChild(this._dropElement),g.delete(this._searchInput)}_getClearControl(){if(this._config.clearControl)return document.querySelector(this._config.clearControl)}_configure(e={}){this._config=Object.assign({},T);const t={...e,...this._searchInput.dataset},s=i=>["true","false","1","0",!0,!1].includes(i)&&!!JSON.parse(i);for(const[i,o]of Object.entries(T)){if(t[i]===void 0)continue;const a=t[i];switch(typeof o){case"number":this._config[i]=parseInt(a);break;case"boolean":this._config[i]=s(a);break;case"string":this._config[i]=a.toString();break;case"object":if(Array.isArray(o))if(typeof a=="string"){const r=a.includes("|")?"|":",";this._config[i]=a.split(r)}else this._config[i]=a;else this._config[i]=typeof a=="string"?JSON.parse(a):a;break;case"function":this._config[i]=typeof a=="string"?window[a]:a;break;default:this._config[i]=a;break}}}_configureSearchInput(){if(this._searchInput.autocomplete="off",this._searchInput.spellcheck=!1,w(this._searchInput,{"aria-autocomplete":"list","aria-haspopup":"menu","aria-expanded":"false",role:"combobox"}),this._searchInput.id&&this._config.preventBrowserAutocomplete){const e=document.querySelector(`[for="${this._searchInput.id}"]`);e&&X(e)}this._hiddenInput=null,this._config.hiddenInput&&(this._hiddenInput=document.createElement("input"),this._hiddenInput.type="hidden",this._hiddenInput.value=this._config.hiddenValue,this._hiddenInput.name=this._searchInput.name,this._searchInput.name="_"+this._searchInput.name,D(this._searchInput,this._hiddenInput))}_configureDropElement(){this._dropElement=document.createElement("ul"),this._dropElement.id="ac-menu-"+k,this._dropElement.classList.add("dropdown-menu","autocomplete-menu","p-0"),this._dropElement.style.maxHeight="280px",this._config.fullWidth||(this._dropElement.style.maxWidth="360px"),this._config.fixed&&(this._dropElement.style.position="fixed"),this._dropElement.style.overflowY="auto",this._dropElement.style.overscrollBehavior="contain",this._dropElement.style.textAlign="unset",D(this._searchInput,this._dropElement),this._searchInput.setAttribute("aria-controls",this._dropElement.id)}onclick(e){e.target.matches(this._config.clearControl)&&this.clear()}oninput(e){this._preventInput||(this._hiddenInput&&(this._hiddenInput.value=null),this.showOrSearch())}onchange(e){const t=this._searchInput.value,s=Object.values(this._items).find(i=>i.label===t);this._config.onChange(s,this)}onblur(e){this.hideSuggestions()}onfocus(e){this.showOrSearch()}onkeydown(e){switch(e.keyCode||e.key){case 13:case"Enter":if(this.isDropdownVisible()){const s=this.getSelection();s&&s.click(),(s||!this._config.ignoreEnter)&&e.preventDefault()}break;case 38:case"ArrowUp":e.preventDefault(),this._keyboardNavigation=!0,this._moveSelection(v);break;case 40:case"ArrowDown":e.preventDefault(),this._keyboardNavigation=!0,this.isDropdownVisible()?this._moveSelection(_):this.showOrSearch(!1);break;case 27:case"Escape":this.isDropdownVisible()&&(this._searchInput.focus(),this.hideSuggestions());break}}onmousemove(e){this._keyboardNavigation=!1}onmouseleave(e){this.removeSelection()}onscroll(e){this._positionMenu()}onresize(e){this._positionMenu()}getConfig(e=null){return e!==null?this._config[e]:this._config}setConfig(e,t){this._config[e]=t}setData(e){this._items={},this._addItems(e)}enable(){this._searchInput.setAttribute("disabled","")}disable(){this._searchInput.removeAttribute("disabled")}isDisabled(){return this._searchInput.hasAttribute("disabled")||this._searchInput.disabled||this._searchInput.hasAttribute("readonly")}isDropdownVisible(){return this._dropElement.classList.contains(f)}clear(){this._searchInput.value="",this._hiddenInput&&(this._hiddenInput.value="")}getSelection(){return this._dropElement.querySelector("a."+L)}removeSelection(){const e=this.getSelection();e&&e.classList.remove(...this._activeClasses())}_activeClasses(){return[...this._config.activeClasses,L]}_isItemEnabled(e){if(e.style.display==="none")return!1;const t=e.firstElementChild;return t.tagName==="A"&&!t.classList.contains("disabled")}_moveSelection(e=_,t=null){const s=this.getSelection();if(s){const i=e===_?"nextSibling":"previousSibling";t=s.parentNode;do t=t[i];while(t&&!this._isItemEnabled(t));t?(s.classList.remove(...this._activeClasses()),e===v?t.parentNode.scrollTop=t.offsetTop-t.parentNode.offsetTop:t.offsetTop>t.parentNode.offsetHeight-t.offsetHeight&&(t.parentNode.scrollTop+=t.offsetHeight)):s&&(t=s.parentElement)}else{if(e===v)return t;if(!t)for(t=this._dropElement.firstChild;t&&!this._isItemEnabled(t);)t=t.nextSibling}if(t){const i=t.querySelector("a");i.classList.add(...this._activeClasses()),this._searchInput.setAttribute("aria-activedescendant",i.id),this._config.updateOnSelect&&(this._searchInput.value=i.dataset.label)}else this._searchInput.setAttribute("aria-activedescendant","");return t}_shouldShow(){return this.isDisabled()?!1:this._searchInput.value.length>=this._config.suggestionsThreshold}showOrSearch(e=!0){if(e&&!this._shouldShow()){this.hideSuggestions();return}this._config.liveServer?this._searchFunc():this._config.source?this._config.source(this._searchInput.value,t=>{this.setData(t),this._showSuggestions()}):this._showSuggestions()}_createGroup(e){const t=this._createLi(),s=document.createElement("span");return t.append(s),s.classList.add("dropdown-header","text-truncate"),s.innerHTML=e,t}_createItem(e,t){let s=t.label;if(this._config.highlightTyped){const a=y(s).indexOf(e);s=s.substring(0,a)+`${s.substring(a,a+e.length)}`+s.substring(a+e.length,s.length)}s=this._config.onRenderItem(t,s,this);const i=this._createLi(),o=document.createElement("a");if(i.append(o),o.id=this._dropElement.id+"-"+this._dropElement.children.length,o.classList.add("dropdown-item","text-truncate"),this._config.itemClass&&o.classList.add(...this._config.itemClass.split(" ")),o.setAttribute("data-value",t.value),o.setAttribute("data-label",t.label),o.setAttribute("tabindex","-1"),o.setAttribute("role","menuitem"),o.setAttribute("href","#"),o.innerHTML=s,t.data)for(const[a,r]of Object.entries(t.data))o.dataset[a]=r;return o.addEventListener("mouseenter",a=>{this._keyboardNavigation||(this.removeSelection(),i.querySelector("a").classList.add(...this._activeClasses()))}),o.addEventListener("mousedown",a=>{a.preventDefault()}),o.addEventListener("click",a=>{a.preventDefault(),this._preventInput=!0,this._searchInput.value=J(t.label),this._hiddenInput&&(this._hiddenInput.value=t.value),this._config.onSelectItem(t,this),this.hideSuggestions(),this._preventInput=!1}),i}_showSuggestions(){if(document.activeElement!=this._searchInput)return;const e=y(this._searchInput.value);this._dropElement.innerHTML="";const t=Object.keys(this._items);let s=0,i=null;const o=[];for(let a=0;a0&&this._config.searchFields.forEach(d=>{const p=y(c[d]);let m=!1;if(this._config.fuzzy)m=K(p,e);else{const E=p.indexOf(e);m=this._config.startsWith?E===0:E>=0}m&&(l=!0)});const F=l||e.length===0;if(u||l){if(s++,c.group&&!o.includes(c.group)){const p=this._createGroup(c.group);this._dropElement.appendChild(p),o.push(c.group)}const d=this._createItem(e,c);if(!i&&F&&(i=d),this._dropElement.appendChild(d),this._config.maximumItems>0&&s>=this._config.maximumItems)break}}if(i&&this._config.autoselectFirst&&(this.removeSelection(),this._moveSelection(_,i)),s===0)if(this._config.notFoundMessage){const a=this._createLi();a.innerHTML=`${this._config.notFoundMessage}`,this._dropElement.appendChild(a),this._showDropdown()}else this.hideSuggestions();else this._showDropdown()}_createLi(){const e=document.createElement("li");return e.setAttribute("role","presentation"),e}_showDropdown(){this._dropElement.classList.add(f),this._dropElement.setAttribute("role","menu"),w(this._searchInput,{"aria-expanded":"true"}),this._positionMenu()}toggleSuggestions(e=!0){this._dropElement.classList.contains(f)?this.hideSuggestions():this.showOrSearch(e)}hideSuggestions(){this._dropElement.classList.remove(f),w(this._searchInput,{"aria-expanded":"false"}),this.removeSelection()}getInput(){return this._searchInput}getDropMenu(){return this._dropElement}_positionMenu(){const e=window.getComputedStyle(this._searchInput),t=this._searchInput.getBoundingClientRect(),s=e.direction==="rtl",i=this._config.fullWidth,o=this._config.fixed;let a=null,r=null;o&&(a=t.x,r=t.y+t.height,s&&!i&&(a-=this._dropElement.offsetWidth-t.width)),this._dropElement.style.transform="unset",i&&(this._dropElement.style.width=this._searchInput.offsetWidth+"px"),a!==null&&(this._dropElement.style.left=a+"px"),r!==null&&(this._dropElement.style.top=r+"px");const c=this._dropElement.getBoundingClientRect(),u=window.innerHeight;if(c.y+c.height>u){const l=i?t.height+4:t.height;this._dropElement.style.transform="translateY(calc(-100.1% - "+l+"px))"}}_fetchData(){this._items={},this._addItems(this._config.items);const e=this._config.datalist;if(e){const t=document.querySelector(`#${e}`);if(t){const s=Array.from(t.children).map(i=>{const o=i.getAttribute("value")??i.innerHTML.toLowerCase(),a=i.innerHTML;return{value:o,label:a}});this._addItems(s)}else console.error(`Datalist not found ${e}`)}this._setHiddenVal(),this._config.server&&!this._config.liveServer&&this._loadFromServer()}_setHiddenVal(){if(this._config.hiddenInput&&!this._config.hiddenValue)for(const[e,t]of Object.entries(this._items))t.label==this._searchInput.value&&(this._hiddenInput.value=e)}_addItems(e){const t=Object.keys(e);for(let s=0;sc.group=o.group),this._addItems(o.items);continue}const a=typeof o=="string"?o:o.label,r=typeof o!="object"?{}:o;r.label=o[this._config.labelField]??a,r.value=o[this._config.valueField]??i,r.label&&(this._items[r.value]=r)}}_loadFromServer(e=!1){this._abortController&&this._abortController.abort(),this._abortController=new AbortController;let t=this._searchInput.dataset.serverParams||{};typeof t=="string"&&(t=JSON.parse(t));const s=Object.assign({},this._config.serverParams,t);if(s[this._config.queryParam]=this._searchInput.value,this._config.noCache&&(s.t=Date.now()),s.related){const r=document.getElementById(s.related);if(r){s.related=r.value;const c=r.getAttribute("name");c&&(s[c]=r.value)}}const i=new URLSearchParams(s);let o=this._config.server,a=Object.assign(this._config.fetchOptions,{method:this._config.serverMethod||"GET",signal:this._abortController.signal});a.method==="POST"?a.body=i:o+="?"+i.toString(),this._searchInput.classList.add(x),fetch(o,a).then(r=>this._config.onServerResponse(r,this)).then(r=>{const c=r[this._config.serverDataKey]||r;this.setData(c),this._setHiddenVal(),this._abortController=null,e&&this._showSuggestions()}).catch(r=>{r.name==="AbortError"||this._abortController.signal.aborted||console.error(r)}).finally(r=>{this._searchInput.classList.remove(x)})}}class Y{post(e){let t="/api/v2/transactions";return P.post(t,e)}}let h;const S={description:"/api/v2/autocomplete/transaction-descriptions",account:"/api/v2/autocomplete/accounts"};let Q=function(){return{count:0,totalAmount:0,transactionType:"unknown",showSuccessMessage:!1,showErrorMessage:!1,entries:[],filters:{source:[],destination:[]},detectTransactionType(){const n=this.entries[0].source_account.type??"unknown",e=this.entries[0].destination_account.type??"unknown";if(n==="unknown"&&e==="unknown"){this.transactionType="unknown",console.warn("Cannot infer transaction type from two unknown accounts.");return}if(n===e&&["Asset account","Loan","Debt","Mortgage"].includes(n)){this.transactionType="transfer",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(n==="Asset account"&&["Expense account","Debt","Loan","Mortgage"].includes(e)){this.transactionType="withdrawal",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(n==="Asset account"&&e==="unknown"){this.transactionType="withdrawal",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(["Debt","Loan","Mortgage"].includes(n)&&e==="Expense account"){this.transactionType="withdrawal",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(n==="Revenue account"&&["Asset account","Debt","Loan","Mortgage"].includes(e)){this.transactionType="deposit",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}if(["Debt","Loan","Mortgage"].includes(n)&&e==="Asset account"){this.transactionType="deposit",console.log('Transaction type is detected to be "'+this.transactionType+'".');return}console.warn('Unknown account combination between "'+n+'" and "'+e+'".')},selectSourceAccount(n,e){const t=parseInt(e._searchInput.attributes["data-index"].value);document.querySelector("#form")._x_dataStack[0].$data.entries[t].source_account={id:n.id,name:n.name,type:n.type},console.log("Changed source account into a known "+n.type.toLowerCase())},changedAmount(n){const e=parseInt(n.target.dataset.index);this.entries[e].amount=parseFloat(n.target.value),this.totalAmount=0;for(let t in this.entries)this.entries.hasOwnProperty(t)&&(this.totalAmount=this.totalAmount+parseFloat(this.entries[t].amount));console.log("Changed amount to "+this.totalAmount)},selectDestAccount(n,e){const t=parseInt(e._searchInput.attributes["data-index"].value);document.querySelector("#form")._x_dataStack[0].$data.entries[t].destination_account={id:n.id,name:n.name,type:n.type},console.log("Changed destination account into a known "+n.type.toLowerCase())},changeSourceAccount(n,e){if(typeof n>"u"){const t=parseInt(e._searchInput.attributes["data-index"].value);if(document.querySelector("#form")._x_dataStack[0].$data.entries[t].source_account.name===e._searchInput.value){console.warn('Ignore hallucinated source account name change to "'+e._searchInput.value+'"');return}document.querySelector("#form")._x_dataStack[0].$data.entries[t].source_account={name:e._searchInput.value},console.log('Changed source account into a unknown account called "'+e._searchInput.value+'"')}},changeDestAccount(n,e){if(typeof n>"u"){const t=parseInt(e._searchInput.attributes["data-index"].value);if(document.querySelector("#form")._x_dataStack[0].$data.entries[t].destination_account.name===e._searchInput.value){console.warn('Ignore hallucinated destination account name change to "'+e._searchInput.value+'"');return}document.querySelector("#form")._x_dataStack[0].$data.entries[t].destination_account={name:e._searchInput.value},console.log('Changed destination account into a unknown account called "'+e._searchInput.value+'"')}},showError:!1,showSuccess:!1,addedSplit(){console.log("addedSplit"),I.init("input.ac-source",{server:S.account,serverParams:{types:this.filters.source},fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}},hiddenInput:!0,preventBrowserAutocomplete:!0,highlightTyped:!0,liveServer:!0,onChange:this.changeSourceAccount,onSelectItem:this.selectSourceAccount,onRenderItem:function(n,e,t){return n.name_with_balance+'
'+h.t("firefly.account_type_"+n.type)+""}}),I.init("input.ac-dest",{server:S.account,serverParams:{types:this.filters.destination},fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}},hiddenInput:!0,preventBrowserAutocomplete:!0,liveServer:!0,highlightTyped:!0,onSelectItem:this.selectDestAccount,onChange:this.changeDestAccount,onRenderItem:function(n,e,t){return n.name_with_balance+'
'+h.t("firefly.account_type_"+n.type)+""}}),this.filters.destination=[],I.init("input.ac-description",{server:S.description,fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}},valueField:"id",labelField:"description",highlightTyped:!0,onSelectItem:console.log})},init(){Promise.all([R("language","en_US")]).then(n=>{h=new z;const e=n[0].replace("-","_");h.locale=e,$(h,e).then(()=>{this.addSplit()})}),this.filters.source=["Asset account","Loan","Debt","Mortgage","Revenue account"],this.filters.destination=["Expense account","Loan","Debt","Mortgage","Asset account"]},submitTransaction(){this.detectTransactionType();let n=W(this.entries,this.transactionType),e={group_title:null,fire_webhooks:!1,apply_rules:!1,transactions:n};n.length>1&&(e.group_title=n[0].description);let t=new Y;console.log(e),t.post(e).then(s=>{this.showSuccessMessage=!0,console.log(s),window.location="transactions/show/"+s.data.data.id+"?transaction_group_id="+s.data.data.id+"&message=created"}).catch(s=>{this.showErrorMessage=!0,console.error(s)})},addSplit(){this.entries.push(B())},removeSplit(n){this.entries.splice(n,1),document.querySelector("#split-0-tab").click()},formattedTotalAmount(){return V(this.totalAmount,"EUR")}}},O={transactions:Q,dates:j};function M(){Object.keys(O).forEach(n=>{console.log(`Loading page component "${n}"`);let e=O[n]();Alpine.data(n,()=>e)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),M()});window.bootstrapped&&(console.log("Loaded through window variable."),M()); diff --git a/public/build/assets/dashboard-daa2fdbe.js b/public/build/assets/dashboard-42661760.js similarity index 96% rename from public/build/assets/dashboard-daa2fdbe.js rename to public/build/assets/dashboard-42661760.js index 08df6f886b..f275765ec7 100644 --- a/public/build/assets/dashboard-daa2fdbe.js +++ b/public/build/assets/dashboard-42661760.js @@ -1,4 +1,4 @@ -var Sa=Object.defineProperty;var Oa=(n,t,e)=>t in n?Sa(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var k=(n,t,e)=>(Oa(n,typeof t!="symbol"?t+"":t,e),e);import{r as z,a as ai,t as wt,s as Yi,g as ji,b as ls,c as mr,d as j,e as br,f as yr,_ as an,h as Aa,i as Ui,j as _r,k as La,l as Ra,m as xr,n as Fa,o as Os,p as Ia,q as As,u as Ea,v as za,w as vt,x as J,y as V,z as bt,P as Ba,I as li,A as ci,B as Na,C as Wa,D as Ha,E as Va,F as Ls,G as Ya,H as ja,J as Ua}from"./load-translations-9a154502.js";var $a=36e5;function qa(n,t){z(2,arguments);var e=wt(t);return ai(n,e*$a)}var Xa=864e5;function Ka(n,t){z(2,arguments);var e=Yi(n),i=Yi(t),s=e.getTime()-ji(e),o=i.getTime()-ji(i);return Math.round((s-o)/Xa)}var Ga=6e4;function Qa(n,t){z(2,arguments);var e=wt(t);return ai(n,e*Ga)}function Za(n,t){z(2,arguments);var e=wt(t),i=e*3;return ls(n,i)}function Ja(n,t){z(2,arguments);var e=wt(t);return ai(n,e*1e3)}function tl(n,t){z(2,arguments);var e=wt(t),i=e*7;return mr(n,i)}function el(n,t){z(2,arguments);var e=wt(t);return ls(n,e*12)}function tn(n,t){z(2,arguments);var e=j(n),i=j(t),s=e.getTime()-i.getTime();return s<0?-1:s>0?1:s}var ui=6e4,hi=36e5,nl=1e3;function il(n,t){z(2,arguments);var e=j(n),i=j(t),s=e.getFullYear()-i.getFullYear(),o=e.getMonth()-i.getMonth();return s*12+o}function sl(n,t){z(2,arguments);var e=j(n),i=j(t);return e.getFullYear()-i.getFullYear()}function Rs(n,t){var e=n.getFullYear()-t.getFullYear()||n.getMonth()-t.getMonth()||n.getDate()-t.getDate()||n.getHours()-t.getHours()||n.getMinutes()-t.getMinutes()||n.getSeconds()-t.getSeconds()||n.getMilliseconds()-t.getMilliseconds();return e<0?-1:e>0?1:e}function vr(n,t){z(2,arguments);var e=j(n),i=j(t),s=Rs(e,i),o=Math.abs(Ka(e,i));e.setDate(e.getDate()-s*o);var r=+(Rs(e,i)===-s),a=s*(o-r);return a===0?0:a}function di(n,t){return z(2,arguments),j(n).getTime()-j(t).getTime()}var Fs={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},ol="trunc";function bn(n){return n?Fs[n]:Fs[ol]}function rl(n,t,e){z(2,arguments);var i=di(n,t)/hi;return bn(e==null?void 0:e.roundingMethod)(i)}function al(n,t,e){z(2,arguments);var i=di(n,t)/ui;return bn(e==null?void 0:e.roundingMethod)(i)}function ll(n){z(1,arguments);var t=j(n);return br(t).getTime()===yr(t).getTime()}function wr(n,t){z(2,arguments);var e=j(n),i=j(t),s=tn(e,i),o=Math.abs(il(e,i)),r;if(o<1)r=0;else{e.getMonth()===1&&e.getDate()>27&&e.setDate(30),e.setMonth(e.getMonth()-s*o);var a=tn(e,i)===-s;ll(j(n))&&o===1&&tn(n,i)===1&&(a=!1),r=s*(o-Number(a))}return r===0?0:r}function cl(n,t,e){z(2,arguments);var i=wr(n,t)/3;return bn(e==null?void 0:e.roundingMethod)(i)}function ul(n,t,e){z(2,arguments);var i=di(n,t)/1e3;return bn(e==null?void 0:e.roundingMethod)(i)}function hl(n,t,e){z(2,arguments);var i=vr(n,t)/7;return bn(e==null?void 0:e.roundingMethod)(i)}function dl(n,t){z(2,arguments);var e=j(n),i=j(t),s=tn(e,i),o=Math.abs(sl(e,i));e.setFullYear(1584),i.setFullYear(1584);var r=tn(e,i)===-s,a=s*(o-Number(r));return a===0?0:a}function fl(n){z(1,arguments);var t=j(n);return t.setSeconds(0,0),t}function gl(n){z(1,arguments);var t=j(n),e=t.getFullYear();return t.setFullYear(e+1,0,0),t.setHours(23,59,59,999),t}function pl(n){z(1,arguments);var t=j(n);return t.setMinutes(59,59,999),t}function ml(n){z(1,arguments);var t=j(n);return t.setSeconds(59,999),t}function bl(n){z(1,arguments);var t=j(n);return t.setMilliseconds(999),t}function yl(n,t){if(n==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}function Is(n,t){(t==null||t>n.length)&&(t=n.length);for(var e=0,i=new Array(t);e=n.length?{done:!0}:{done:!1,value:n[i++]}},e:function(c){throw c},f:s}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +var Sa=Object.defineProperty;var Oa=(n,t,e)=>t in n?Sa(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var k=(n,t,e)=>(Oa(n,typeof t!="symbol"?t+"":t,e),e);import{r as z,a as ai,t as wt,s as Yi,g as ji,b as ls,c as mr,d as j,e as br,f as yr,_ as an,h as Aa,i as Ui,j as _r,k as La,l as Ra,m as xr,n as Fa,o as Os,p as Ia,q as As,u as Ea,v as za,w as vt,x as J,y as V,z as bt,P as Ba,I as li,A as ci,B as Na,C as Wa,D as Ha,E as Va,F as Ls,G as Ya,H as ja,J as Ua}from"./load-translations-87b32220.js";var $a=36e5;function qa(n,t){z(2,arguments);var e=wt(t);return ai(n,e*$a)}var Xa=864e5;function Ka(n,t){z(2,arguments);var e=Yi(n),i=Yi(t),s=e.getTime()-ji(e),o=i.getTime()-ji(i);return Math.round((s-o)/Xa)}var Ga=6e4;function Qa(n,t){z(2,arguments);var e=wt(t);return ai(n,e*Ga)}function Za(n,t){z(2,arguments);var e=wt(t),i=e*3;return ls(n,i)}function Ja(n,t){z(2,arguments);var e=wt(t);return ai(n,e*1e3)}function tl(n,t){z(2,arguments);var e=wt(t),i=e*7;return mr(n,i)}function el(n,t){z(2,arguments);var e=wt(t);return ls(n,e*12)}function tn(n,t){z(2,arguments);var e=j(n),i=j(t),s=e.getTime()-i.getTime();return s<0?-1:s>0?1:s}var ui=6e4,hi=36e5,nl=1e3;function il(n,t){z(2,arguments);var e=j(n),i=j(t),s=e.getFullYear()-i.getFullYear(),o=e.getMonth()-i.getMonth();return s*12+o}function sl(n,t){z(2,arguments);var e=j(n),i=j(t);return e.getFullYear()-i.getFullYear()}function Rs(n,t){var e=n.getFullYear()-t.getFullYear()||n.getMonth()-t.getMonth()||n.getDate()-t.getDate()||n.getHours()-t.getHours()||n.getMinutes()-t.getMinutes()||n.getSeconds()-t.getSeconds()||n.getMilliseconds()-t.getMilliseconds();return e<0?-1:e>0?1:e}function vr(n,t){z(2,arguments);var e=j(n),i=j(t),s=Rs(e,i),o=Math.abs(Ka(e,i));e.setDate(e.getDate()-s*o);var r=+(Rs(e,i)===-s),a=s*(o-r);return a===0?0:a}function di(n,t){return z(2,arguments),j(n).getTime()-j(t).getTime()}var Fs={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},ol="trunc";function bn(n){return n?Fs[n]:Fs[ol]}function rl(n,t,e){z(2,arguments);var i=di(n,t)/hi;return bn(e==null?void 0:e.roundingMethod)(i)}function al(n,t,e){z(2,arguments);var i=di(n,t)/ui;return bn(e==null?void 0:e.roundingMethod)(i)}function ll(n){z(1,arguments);var t=j(n);return br(t).getTime()===yr(t).getTime()}function wr(n,t){z(2,arguments);var e=j(n),i=j(t),s=tn(e,i),o=Math.abs(il(e,i)),r;if(o<1)r=0;else{e.getMonth()===1&&e.getDate()>27&&e.setDate(30),e.setMonth(e.getMonth()-s*o);var a=tn(e,i)===-s;ll(j(n))&&o===1&&tn(n,i)===1&&(a=!1),r=s*(o-Number(a))}return r===0?0:r}function cl(n,t,e){z(2,arguments);var i=wr(n,t)/3;return bn(e==null?void 0:e.roundingMethod)(i)}function ul(n,t,e){z(2,arguments);var i=di(n,t)/1e3;return bn(e==null?void 0:e.roundingMethod)(i)}function hl(n,t,e){z(2,arguments);var i=vr(n,t)/7;return bn(e==null?void 0:e.roundingMethod)(i)}function dl(n,t){z(2,arguments);var e=j(n),i=j(t),s=tn(e,i),o=Math.abs(sl(e,i));e.setFullYear(1584),i.setFullYear(1584);var r=tn(e,i)===-s,a=s*(o-Number(r));return a===0?0:a}function fl(n){z(1,arguments);var t=j(n);return t.setSeconds(0,0),t}function gl(n){z(1,arguments);var t=j(n),e=t.getFullYear();return t.setFullYear(e+1,0,0),t.setHours(23,59,59,999),t}function pl(n){z(1,arguments);var t=j(n);return t.setMinutes(59,59,999),t}function ml(n){z(1,arguments);var t=j(n);return t.setSeconds(59,999),t}function bl(n){z(1,arguments);var t=j(n);return t.setMilliseconds(999),t}function yl(n,t){if(n==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}function Is(n,t){(t==null||t>n.length)&&(t=n.length);for(var e=0,i=new Array(t);e=n.length?{done:!0}:{done:!1,value:n[i++]}},e:function(c){throw c},f:s}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,r=!1,a;return{s:function(){e=e.call(n)},n:function(){var c=e.next();return o=c.done,c},e:function(c){r=!0,a=c},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(r)throw a}}}}function D(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function $i(n,t){return $i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,s){return i.__proto__=s,i},$i(n,t)}function B(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),t&&$i(n,t)}function Gn(n){return Gn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Gn(n)}function xl(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function vl(n,t){if(t&&(an(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return D(n)}function N(n){var t=xl();return function(){var i=Gn(n),s;if(t){var o=Gn(this).constructor;s=Reflect.construct(i,arguments,o)}else s=i.apply(this,arguments);return vl(this,s)}}function I(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function wl(n,t){if(an(n)!=="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t||"default");if(an(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function Mr(n){var t=wl(n,"string");return an(t)==="symbol"?t:String(t)}function zs(n,t){for(var e=0;e0,i=e?t:1-t,s;if(i<=50)s=n||100;else{var o=i+50,r=Math.floor(o/100)*100,a=n>=o%100;s=n+r-(a?100:0)}return e?s:1-s}function Dr(n){return n%400===0||n%4===0&&n%100!==0}var Dl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r0}},{key:"set",value:function(s,o,r){var a=s.getUTCFullYear();if(r.isTwoDigitYear){var l=Pr(r.year,a);return s.setUTCFullYear(l,0,1),s.setUTCHours(0,0,0,0),s}var c=!("era"in o)||o.era===1?r.year:1-r.year;return s.setUTCFullYear(c,0,1),s.setUTCHours(0,0,0,0),s}}]),e}(Y),Tl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r0}},{key:"set",value:function(s,o,r,a){var l=Aa(s,a);if(r.isTwoDigitYear){var c=Pr(r.year,l);return s.setUTCFullYear(c,0,a.firstWeekContainsDate),s.setUTCHours(0,0,0,0),Ui(s,a)}var u=!("era"in o)||o.era===1?r.year:1-r.year;return s.setUTCFullYear(u,0,a.firstWeekContainsDate),s.setUTCHours(0,0,0,0),Ui(s,a)}}]),e}(Y),Sl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=1&&o<=4}},{key:"set",value:function(s,o,r){return s.setUTCMonth((r-1)*3,1),s.setUTCHours(0,0,0,0),s}}]),e}(Y),Ll=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=1&&o<=4}},{key:"set",value:function(s,o,r){return s.setUTCMonth((r-1)*3,1),s.setUTCHours(0,0,0,0),s}}]),e}(Y),Rl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=0&&o<=11}},{key:"set",value:function(s,o,r){return s.setUTCMonth(r,1),s.setUTCHours(0,0,0,0),s}}]),e}(Y),Fl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=0&&o<=11}},{key:"set",value:function(s,o,r){return s.setUTCMonth(r,1),s.setUTCHours(0,0,0,0),s}}]),e}(Y);function Il(n,t,e){z(2,arguments);var i=j(n),s=wt(t),o=La(i,e)-s;return i.setUTCDate(i.getUTCDate()-o*7),i}var El=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=1&&o<=53}},{key:"set",value:function(s,o,r,a){return Ui(Il(s,r,a),a)}}]),e}(Y);function zl(n,t){z(2,arguments);var e=j(n),i=wt(t),s=Ra(e)-i;return e.setUTCDate(e.getUTCDate()-s*7),e}var Bl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=1&&o<=53}},{key:"set",value:function(s,o,r){return _r(zl(s,r))}}]),e}(Y),Nl=[31,28,31,30,31,30,31,31,30,31,30,31],Wl=[31,29,31,30,31,30,31,31,30,31,30,31],Hl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=1&&o<=Wl[l]:o>=1&&o<=Nl[l]}},{key:"set",value:function(s,o,r){return s.setUTCDate(r),s.setUTCHours(0,0,0,0),s}}]),e}(Y),Vl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=1&&o<=366:o>=1&&o<=365}},{key:"set",value:function(s,o,r){return s.setUTCMonth(0,r),s.setUTCHours(0,0,0,0),s}}]),e}(Y);function us(n,t,e){var i,s,o,r,a,l,c,u;z(2,arguments);var h=xr(),d=wt((i=(s=(o=(r=e==null?void 0:e.weekStartsOn)!==null&&r!==void 0?r:e==null||(a=e.locale)===null||a===void 0||(l=a.options)===null||l===void 0?void 0:l.weekStartsOn)!==null&&o!==void 0?o:h.weekStartsOn)!==null&&s!==void 0?s:(c=h.locale)===null||c===void 0||(u=c.options)===null||u===void 0?void 0:u.weekStartsOn)!==null&&i!==void 0?i:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var f=j(n),g=wt(t),p=f.getUTCDay(),m=g%7,b=(m+7)%7,y=(b=0&&o<=6}},{key:"set",value:function(s,o,r,a){return s=us(s,r,a),s.setUTCHours(0,0,0,0),s}}]),e}(Y),jl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=0&&o<=6}},{key:"set",value:function(s,o,r,a){return s=us(s,r,a),s.setUTCHours(0,0,0,0),s}}]),e}(Y),Ul=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=0&&o<=6}},{key:"set",value:function(s,o,r,a){return s=us(s,r,a),s.setUTCHours(0,0,0,0),s}}]),e}(Y);function $l(n,t){z(2,arguments);var e=wt(t);e%7===0&&(e=e-7);var i=1,s=j(n),o=s.getUTCDay(),r=e%7,a=(r+7)%7,l=(a=1&&o<=7}},{key:"set",value:function(s,o,r){return s=$l(s,r),s.setUTCHours(0,0,0,0),s}}]),e}(Y),Xl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=1&&o<=12}},{key:"set",value:function(s,o,r){var a=s.getUTCHours()>=12;return a&&r<12?s.setUTCHours(r+12,0,0,0):!a&&r===12?s.setUTCHours(0,0,0,0):s.setUTCHours(r,0,0,0),s}}]),e}(Y),Zl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=0&&o<=23}},{key:"set",value:function(s,o,r){return s.setUTCHours(r,0,0,0),s}}]),e}(Y),Jl=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=0&&o<=11}},{key:"set",value:function(s,o,r){var a=s.getUTCHours()>=12;return a&&r<12?s.setUTCHours(r+12,0,0,0):s.setUTCHours(r,0,0,0),s}}]),e}(Y),tc=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=1&&o<=24}},{key:"set",value:function(s,o,r){var a=r<=24?r%24:r;return s.setUTCHours(a,0,0,0),s}}]),e}(Y),ec=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=0&&o<=59}},{key:"set",value:function(s,o,r){return s.setUTCMinutes(r,0,0),s}}]),e}(Y),nc=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=0&&o<=59}},{key:"set",value:function(s,o,r){return s.setUTCSeconds(r,0),s}}]),e}(Y),ic=function(n){B(e,n);var t=N(e);function e(){var i;I(this,e);for(var s=arguments.length,o=new Array(s),r=0;r=1&&A<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var O=wt((g=(p=(m=(b=i==null?void 0:i.weekStartsOn)!==null&&b!==void 0?b:i==null||(y=i.locale)===null||y===void 0||(x=y.options)===null||x===void 0?void 0:x.weekStartsOn)!==null&&m!==void 0?m:M.weekStartsOn)!==null&&p!==void 0?p:(v=M.locale)===null||v===void 0||(_=v.options)===null||_===void 0?void 0:_.weekStartsOn)!==null&&g!==void 0?g:0);if(!(O>=0&&O<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(C==="")return w===""?j(e):new Date(NaN);var R={firstWeekContainsDate:A,weekStartsOn:O,locale:T},st=[new Cl],gt=C.match(uc).map(function(ct){var q=ct[0];if(q in Os){var St=Os[q];return St(ct,T.formatLong)}return ct}).join("").match(cc),W=[],U=Es(gt),Q;try{var Mt=function(){var q=Q.value;!(i!=null&&i.useAdditionalWeekYearTokens)&&Ia(q)&&As(q,C,n),!(i!=null&&i.useAdditionalDayOfYearTokens)&&Ea(q)&&As(q,C,n);var St=q[0],wn=lc[St];if(wn){var Ds=wn.incompatibleTokens;if(Array.isArray(Ds)){var Ts=W.find(function(Ss){return Ds.includes(Ss.token)||Ss.token===St});if(Ts)throw new RangeError("The format string mustn't contain `".concat(Ts.fullToken,"` and `").concat(q,"` at the same time"))}else if(wn.incompatibleTokens==="*"&&W.length>0)throw new RangeError("The format string mustn't contain `".concat(q,"` and any other token at the same time"));W.push({token:St,fullToken:q});var xi=wn.run(w,q,T.match,R);if(!xi)return{v:new Date(NaN)};st.push(xi.setter),w=xi.rest}else{if(St.match(gc))throw new RangeError("Format string contains an unescaped latin alphabet character `"+St+"`");if(q==="''"?q="'":St==="'"&&(q=mc(q)),w.indexOf(q)===0)w=w.slice(q.length);else return{v:new Date(NaN)}}};for(U.s();!(Q=U.n()).done;){var lt=Mt();if(an(lt)==="object")return lt.v}}catch(ct){U.e(ct)}finally{U.f()}if(w.length>0&&fc.test(w))return new Date(NaN);var Kt=st.map(function(ct){return ct.priority}).sort(function(ct,q){return q-ct}).filter(function(ct,q,St){return St.indexOf(ct)===q}).map(function(ct){return st.filter(function(q){return q.priority===ct}).sort(function(q,St){return St.subPriority-q.subPriority})}).map(function(ct){return ct[0]}),Gt=j(e);if(isNaN(Gt.getTime()))return new Date(NaN);var Tt=za(Gt,ji(Gt)),Qt={},Rt=Es(Kt),Zt;try{for(Rt.s();!(Zt=Rt.n()).done;){var Jt=Zt.value;if(!Jt.validate(Tt,R))return new Date(NaN);var vn=Jt.set(Tt,Qt,R);Array.isArray(vn)?(Tt=vn[0],yl(Qt,vn[1])):Tt=vn}}catch(ct){Rt.e(ct)}finally{Rt.f()}return Tt}function mc(n){return n.match(hc)[1].replace(dc,"'")}function bc(n){z(1,arguments);var t=j(n);return t.setMinutes(0,0,0),t}function yc(n){z(1,arguments);var t=j(n);return t.setMilliseconds(0),t}function _c(n,t){var e;z(1,arguments);var i=wt((e=t==null?void 0:t.additionalDigits)!==null&&e!==void 0?e:2);if(i!==2&&i!==1&&i!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(!(typeof n=="string"||Object.prototype.toString.call(n)==="[object String]"))return new Date(NaN);var s=Mc(n),o;if(s.date){var r=kc(s.date,i);o=Cc(r.restDateString,r.year)}if(!o||isNaN(o.getTime()))return new Date(NaN);var a=o.getTime(),l=0,c;if(s.time&&(l=Pc(s.time),isNaN(l)))return new Date(NaN);if(s.timezone){if(c=Dc(s.timezone),isNaN(c))return new Date(NaN)}else{var u=new Date(a+l),h=new Date(0);return h.setFullYear(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()),h.setHours(u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds()),h}return new Date(a+l+c)}var Mn={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},xc=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,vc=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,wc=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Mc(n){var t={},e=n.split(Mn.dateTimeDelimiter),i;if(e.length>2)return t;if(/:/.test(e[0])?i=e[0]:(t.date=e[0],i=e[1],Mn.timeZoneDelimiter.test(t.date)&&(t.date=n.split(Mn.timeZoneDelimiter)[0],i=n.substr(t.date.length,n.length))),i){var s=Mn.timezone.exec(i);s?(t.time=i.replace(s[1],""),t.timezone=s[1]):t.time=i}return t}function kc(n,t){var e=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=n.match(e);if(!i)return{year:NaN,restDateString:""};var s=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:o===null?s:o*100,restDateString:n.slice((i[1]||i[2]).length)}}function Cc(n,t){if(t===null)return new Date(NaN);var e=n.match(xc);if(!e)return new Date(NaN);var i=!!e[4],s=Be(e[1]),o=Be(e[2])-1,r=Be(e[3]),a=Be(e[4]),l=Be(e[5])-1;if(i)return Lc(t,a,l)?Tc(t,a,l):new Date(NaN);var c=new Date(0);return!Oc(t,o,r)||!Ac(t,s)?new Date(NaN):(c.setUTCFullYear(t,o,Math.max(s,r)),c)}function Be(n){return n?parseInt(n):1}function Pc(n){var t=n.match(vc);if(!t)return NaN;var e=vi(t[1]),i=vi(t[2]),s=vi(t[3]);return Rc(e,i,s)?e*hi+i*ui+s*1e3:NaN}function vi(n){return n&&parseFloat(n.replace(",","."))||0}function Dc(n){if(n==="Z")return 0;var t=n.match(wc);if(!t)return 0;var e=t[1]==="+"?-1:1,i=parseInt(t[2]),s=t[3]&&parseInt(t[3])||0;return Fc(i,s)?e*(i*hi+s*ui):NaN}function Tc(n,t,e){var i=new Date(0);i.setUTCFullYear(n,0,4);var s=i.getUTCDay()||7,o=(t-1)*7+e+1-s;return i.setUTCDate(i.getUTCDate()+o),i}var Sc=[31,null,31,30,31,30,31,31,30,31,30,31];function Tr(n){return n%400===0||n%4===0&&n%100!==0}function Oc(n,t,e){return t>=0&&t<=11&&e>=1&&e<=(Sc[t]||(Tr(n)?29:28))}function Ac(n,t){return t>=1&&t<=(Tr(n)?366:365)}function Lc(n,t,e){return t>=1&&t<=53&&e>=0&&e<=6}function Rc(n,t,e){return n===24?t===0&&e===0:e>=0&&e<60&&t>=0&&t<60&&n>=0&&n<25}function Fc(n,t){return t>=0&&t<=59}class Ic{get(t,e,i){return vt.get("/api/v2/summary/basic",{params:{start:t,end:e,code:i}})}}function Nt(n,t,e){const i=J(t,"y-MM-dd")+"_"+J(e,"y-MM-dd")+"_"+n;return console.log("getCacheKey: "+i),String(i)}let wi=!1;const Ec=()=>({balanceBox:{amounts:[],subtitles:[]},billBox:{paid:[],unpaid:[]},leftBox:{left:[],perDay:[]},netBox:{net:[]},autoConversion:!1,loading:!1,boxData:null,boxOptions:null,getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt("dashboard-boxes-data",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){this.boxData=s,this.generateOptions(this.boxData);return}new Ic().get(J(n,"yyyy-MM-dd"),J(t,"yyyy-MM-dd"),null).then(r=>{this.boxData=r.data,window.store.set(e,r.data),this.generateOptions(this.boxData)})},generateOptions(n){this.balanceBox={amounts:[],subtitles:[]},this.billBox={paid:[],unpaid:[]},this.leftBox={left:[],perDay:[]},this.netBox={net:[]};let t={};for(const e in n)if(n.hasOwnProperty(e)){const i=n[e];if(!i.hasOwnProperty("key"))continue;let s=i.key;if(this.autoConversion){if(s.startsWith("balance-in-native")){this.balanceBox.amounts.push(V(i.value,i.currency_code)),t.hasOwnProperty(i.currency_code)||(t[i.currency_code]="");continue}if(s.startsWith("spent-in-native")){t.hasOwnProperty(i.currency_code)||(t[i.currency_code]=""),t[i.currency_code]=t[i.currency_code]+V(i.value,i.currency_code);continue}if(s.startsWith("earned-in-native")){t.hasOwnProperty(i.currency_code)||(t[i.currency_code]=""),t[i.currency_code]=V(i.value,i.currency_code)+" + "+t[i.currency_code];continue}if(s.startsWith("bills-unpaid-in-native")){this.billBox.unpaid.push(V(i.value,i.currency_code));continue}if(s.startsWith("bills-paid-in-native")){this.billBox.paid.push(V(i.value,i.currency_code));continue}if(s.startsWith("left-to-spend-in-native")){this.leftBox.left.push(V(i.value,i.currency_code));continue}if(s.startsWith("left-per-day-to-spend-in-native")){this.leftBox.perDay.push(V(i.value,i.currency_code));continue}if(s.startsWith("net-worth-in-native")){this.netBox.net.push(V(i.value,i.currency_code));continue}}if(!this.autoConversion&&!s.endsWith("native")){if(s.startsWith("balance-in-")){this.balanceBox.amounts.push(V(i.value,i.currency_code));continue}if(s.startsWith("spent-in-")){t.hasOwnProperty(i.currency_code)||(t[i.currency_code]=""),t[i.currency_code]=t[i.currency_code]+V(i.value,i.currency_code);continue}if(s.startsWith("earned-in-")){t.hasOwnProperty(i.currency_code)||(t[i.currency_code]=""),t[i.currency_code]=V(i.value,i.currency_code)+" + "+t[i.currency_code];continue}if(s.startsWith("bills-unpaid-in-")){this.billBox.unpaid.push(V(i.value,i.currency_code));continue}if(s.startsWith("bills-paid-in-")){this.billBox.paid.push(V(i.value,i.currency_code));continue}if(s.startsWith("left-to-spend-in-")){this.leftBox.left.push(V(i.value,i.currency_code));continue}if(s.startsWith("left-per-day-to-spend-in-")){this.leftBox.perDay.push(V(i.value,i.currency_code));continue}s.startsWith("net-worth-in-")&&this.netBox.net.push(V(i.value,i.currency_code))}}for(let e in t)t.hasOwnProperty(e)&&this.balanceBox.subtitles.push(t[e]);this.loading=!1},loadBoxes(){if(this.loading!==!0){if(this.loading=!0,this.boxData===null){this.getFreshData();return}this.generateOptions(this.boxData),this.loading=!1}},init(){Promise.all([bt("viewRange"),bt("autoConversion",!1)]).then(n=>{wi=!0,this.autoConversion=n[1],this.loadBoxes()}),window.store.observe("end",()=>{wi&&(this.boxData=null,this.loadBoxes())}),window.store.observe("autoConversion",n=>{wi&&(this.autoConversion=n,this.loadBoxes())})}});class zc{put(t,e){let i="/api/v1/preferences/"+t;return vt.put(i,{data:e})}}function Bc(n,t=null){window.store.set(n,t),new zc().put(n,t).then(i=>{}).catch(()=>{new Ba().post(n,t).then(s=>{})})}let Nc=class{dashboard(t,e){let i=J(t,"y-MM-dd"),s=J(e,"y-MM-dd");return vt.get("/api/v2/chart/account/dashboard",{params:{start:i,end:s}})}expense(t,e){let i=J(t,"y-MM-dd"),s=J(e,"y-MM-dd");return vt.get("/api/v2/chart/account/expense-dashboard",{params:{start:i,end:s}})}},Bs=class{get(t,e){let i={date:J(e,"y-MM-dd").slice(0,10)};return e?vt.get("/api/v2/accounts/"+t,{params:i}):vt.get("/api/v2/accounts/"+t)}transactions(t,e){const i={page:e.page??1};return e.hasOwnProperty("start")&&(i.start=J(e.start,"y-MM-dd")),e.hasOwnProperty("end")&&(i.end=J(e.end,"y-MM-dd")),vt.get("/api/v2/accounts/"+t+"/transactions",{params:i})}};/*! * @kurkle/color v0.3.2 * https://github.com/kurkle/color#readme @@ -16,13 +16,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho * Released under the MIT License */class Th{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const o=e.listeners[s],r=e.duration;o.forEach(a=>a({chart:t,initial:e.initial,numSteps:r,currentStep:Math.min(i-e.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=Br.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const o=i.items;let r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>i.duration&&(i.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(s.draw(),this._notify(s,i,t,"progress")),o.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}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((i,s)=>Math.max(i,s._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 i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Yt=new Th;const ro="transparent",Sh={boolean(n,t,e){return e>.5?t:n},color(n,t,e){const i=Ae(n||ro),s=i.valid&&Ae(t||ro);return s&&s.valid?s.mix(i,e).hexString():t},number(n,t,e){return n+(t-n)*e}};class Oh{constructor(t,e,i,s){const o=e[i];s=Tn([t.to,s,o,t.from]);const r=Tn([t.from,o,s]);this._active=!0,this._fn=t.fn||Sh[t.type||typeof r],this._easing=sn[t.easing]||sn.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=i,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],o=i-this._start,r=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=Tn([t.to,e,s,t.from]),this._from=Tn([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,o=this._from,r=this._loop,a=this._to;let l;if(this._active=o!==a&&(r||e1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[s]=this._fn(o,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,i)=>{t.push({res:e,rej:i})})}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let s=0;s{const o=t[s];if(!F(o))return;const r={};for(const a of e)r[a]=o[a];(K(o.properties)&&o.properties||[s]).forEach(a=>{(a===s||!i.has(a))&&i.set(a,r)})})}_animateOptions(t,e){const i=e.options,s=Lh(t,i);if(!s)return[];const o=this._createAnimations(s,i);return i.$shared&&Ah(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,e){const i=this._properties,s=[],o=t.$animations||(t.$animations={}),r=Object.keys(e),a=Date.now();let l;for(l=r.length-1;l>=0;--l){const c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){s.push(...this._animateOptions(t,e));continue}const u=e[c];let h=o[c];const d=i.get(c);if(h)if(d&&h.active()){h.update(d,u,a);continue}else h.cancel();if(!d||!d.duration){t[c]=u;continue}o[c]=h=new Oh(d,t,c,u),s.push(h)}return s}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}const i=this._createAnimations(t,e);if(i.length)return Yt.add(this._chart,i),!0}}function Ah(n,t){const e=[],i=Object.keys(t);for(let s=0;s0||!e&&o<0)return s.index}return null}function ho(n,t){const{chart:e,_cachedMeta:i}=n,s=e._stacks||(e._stacks={}),{iScale:o,vScale:r,index:a}=i,l=o.axis,c=r.axis,u=Eh(o,r,i),h=t.length;let d;for(let f=0;fe[i].axis===t).shift()}function Nh(n,t){return he(n,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function Wh(n,t,e){return he(n,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function Ne(n,t){const e=n.controller.index,i=n.vScale&&n.vScale.axis;if(i){t=t||n._parsed;for(const s of t){const o=s._stacks;if(!o||o[i]===void 0||o[i][e]===void 0)return;delete o[i][e],o[i]._visualValues!==void 0&&o[i]._visualValues[e]!==void 0&&delete o[i]._visualValues[e]}}}const Pi=n=>n==="reset"||n==="none",fo=(n,t)=>t?n:Object.assign({},n),Hh=(n,t,e)=>n&&!t.hidden&&t._stacked&&{keys:na(e,!0),values:null};class Xt{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=co(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&&Ne(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(h,d,f,g)=>h==="x"?d:h==="r"?g:f,o=e.xAxisID=S(i.xAxisID,Ci(t,"x")),r=e.yAxisID=S(i.yAxisID,Ci(t,"y")),a=e.rAxisID=S(i.rAxisID,Ci(t,"r")),l=e.indexAxis,c=e.iAxisID=s(l,o,r,a),u=e.vAxisID=s(l,r,o,a);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(r),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(c),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&&Xs(this._data,this),t._stacked&&Ne(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(F(e))this._data=Ih(e);else if(i!==e){if(i){Xs(i,this);const s=this._cachedMeta;Ne(s),s._parsed=[]}e&&Object.isExtensible(e)&&Mu(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,i=this.getDataset();let s=!1;this._dataCheck();const o=e._stacked;e._stacked=co(e.vScale,e),e.stack!==i.stack&&(s=!0,Ne(e),e.stack=i.stack),this._resyncElements(t),(s||o!==e._stacked)&&ho(this,e._parsed)}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:i,_data:s}=this,{iScale:o,_stacked:r}=i,a=o.axis;let l=t===0&&e===s.length?!0:i._sorted,c=t>0&&i._parsed[t-1],u,h,d;if(this._parsing===!1)i._parsed=s,i._sorted=!0,d=s;else{K(s[t])?d=this.parseArrayData(i,s,t,e):F(s[t])?d=this.parseObjectData(i,s,t,e):d=this.parsePrimitiveData(i,s,t,e);const f=()=>h[a]===null||c&&h[a]p||h=0;--d)if(!g()){this.updateRangeFromParsed(c,t,f,l);break}}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,o,r;for(s=0,o=e.length;s=0&&tthis.getContext(i,s,e),p=c.resolveNamedOptions(d,f,g,h);return p.$shared&&(p.$shared=l,o[r]=Object.freeze(fo(p,l))),p}_resolveAnimations(t,e,i){const s=this.chart,o=this._cachedDataOpts,r=`animation-${e}`,a=o[r];if(a)return a;let l;if(s.options.animation!==!1){const u=this.chart.config,h=u.datasetAnimationScopeKeys(this._type,e),d=u.getOptionScopes(this.getDataset(),h);l=u.createResolver(d,this.getContext(t,i,e))}const c=new ea(s,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Pi(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),s=this._sharedOptions,o=this.getSharedOptions(i),r=this.includeOptions(e,o)||o!==s;return this.updateSharedOptions(o,e,i),{sharedOptions:o,includeOptions:r}}updateElement(t,e,i,s){Pi(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!Pi(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const o=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"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,i=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const s=i.length,o=e.length,r=Math.min(o,s);r&&this.parse(0,r),o>s?this._insertElements(s,o-s,t):o{for(c.length+=e,a=c.length-1;a>=r;a--)c[a]=c[a-e]};for(l(o),a=t;as-o))}return n._cache.$bar}function Yh(n){const t=n.iScale,e=Vh(t,n.type);let i=t._length,s,o,r,a;const l=()=>{r===32767||r===-32768||(cn(a)&&(i=Math.min(i,Math.abs(r-a)||i)),a=r)};for(s=0,o=e.length;s0?s[n-1]:null,a=nMath.abs(a)&&(l=a,c=r),t[e.axis]=c,t._custom={barStart:l,barEnd:c,start:s,end:o,min:r,max:a}}function ia(n,t,e,i){return K(n)?$h(n,t,e,i):t[e.axis]=e.parse(n,i),t}function go(n,t,e,i){const s=n.iScale,o=n.vScale,r=s.getLabels(),a=s===o,l=[];let c,u,h,d;for(c=e,u=e+i;c=e?1:-1)}function Xh(n){let t,e,i,s,o;return n.horizontal?(t=n.base>n.x,e="left",i="right"):(t=n.basel.controller.options.grouped),o=i.options.stacked,r=[],a=l=>{const c=l.controller.getParsed(e),u=c&&c[l.vScale.axis];if(H(u)||isNaN(u))return!0};for(const l of s)if(!(e!==void 0&&a(l))&&((o===!1||r.indexOf(l.stack)===-1||o===void 0&&l.stack===void 0)&&r.push(l.stack),l.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const s=this._getStacks(t,i),o=e!==void 0?s.indexOf(e):-1;return o===-1?s.length-1:o}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,s=[];let o,r;for(o=0,r=e.data.length;ohn(x,a,l,!0)?1:Math.max(v,v*e,_,_*e),g=(x,v,_)=>hn(x,a,l,!0)?-1:Math.min(v,v*e,_,_*e),p=f(0,c,h),m=f(at,u,d),b=g(tt,c,h),y=g(tt+at,u,d);i=(p-b)/2,s=(m-y)/2,o=-(p+b)/2,r=-(m+y)/2}return{ratioX:i,ratioY:s,offsetX:o,offsetY:r}}class Le extends Xt{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 i=this.getDataset().data,s=this._cachedMeta;if(this._parsing===!1)s._parsed=i;else{let o=l=>+i[l];if(F(i[t])){const{key:l="value"}=this._parsing;o=c=>+ce(i[c],l)}let r,a;for(r=t,a=t+e;r0&&!isNaN(t)?G*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],o=_n(e._parsed[t],i.options.locale);return{label:s[t]||"",value:o}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,o,r,a,l;if(!t){for(s=0,o=i.data.datasets.length;st!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),k(Le,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return e.labels.map((o,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}}});class jn extends Xt{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:o}=e,r=this.chart._animationsDisabled;let{start:a,count:l}=Pu(e,s,r);this._drawStart=a,this._drawCount=l,Du(e)&&(a=0,l=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!o._decimated,i.points=s;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:c},t),this.updateElements(s,a,l,t)}updateElements(t,e,i,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:u,includeOptions:h}=this._getSharedOptions(e,s),d=r.axis,f=a.axis,{spanGaps:g,segment:p}=this.options,m=un(g)?g:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||s==="none",y=e+i,x=t.length;let v=e>0&&this.getParsed(e-1);for(let _=0;_=y){C.skip=!0;continue}const M=this.getParsed(_),T=H(M[f]),A=C[d]=r.getPixelForValue(M[d],_),O=C[f]=o||T?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,M,l):M[f],_);C.skip=isNaN(A)||isNaN(O)||T,C.stop=_>0&&Math.abs(M[d]-v[d])>m,p&&(C.parsed=M,C.raw=c.data[_]),h&&(C.options=u||this.resolveDataElementOptions(_,w.active?"active":s)),b||this.updateElement(w,_,C,s),v=M}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const o=s[0].size(this.resolveDataElementOptions(0)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}k(jn,"id","line"),k(jn,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),k(jn,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class Un extends Xt{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],o=_n(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:o}}parseObjectData(t,e,i,s){return ih.bind(this)(t,e,i,s)}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((i,s)=>{const o=this.getParsed(s).r;!isNaN(o)&&this.chart.getDataVisibility(s)&&(oe.max&&(e.max=o))}),e}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(s/2,0),r=Math.max(i.cutoutPercentage?o/100*i.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,i,s){const o=s==="reset",r=this.chart,l=r.options.animation,c=this._cachedMeta.rScale,u=c.xCenter,h=c.yCenter,d=c.getIndexAngle(0)-.5*tt;let f=d,g;const p=360/this.countVisibleElements();for(g=0;g{!isNaN(this.getParsed(s).r)&&this.chart.getDataVisibility(s)&&e++}),e}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?At(this.resolveDataElementOptions(t,e).angle||i):0}}k(Un,"id","polarArea"),k(Un,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),k(Un,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return e.labels.map((o,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class Qi extends Le{}k(Qi,"id","pie"),k(Qi,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});function ge(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Ms{constructor(t){k(this,"options");this.options=t||{}}static override(t){Object.assign(Ms.prototype,t)}init(){}formats(){return ge()}parse(){return ge()}format(){return ge()}add(){return ge()}diff(){return ge()}startOf(){return ge()}endOf(){return ge()}}var sa={_date:Ms};function Jh(n,t,e,i){const{controller:s,data:o,_sorted:r}=n,a=s._cachedMeta.iScale;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const l=a._reversePixels?vu:xe;if(i){if(s._sharedOptions){const c=o[0],u=typeof c.getRange=="function"&&c.getRange(t);if(u){const h=l(o,t,e-u),d=l(o,t,e+u);return{lo:h.lo,hi:d.hi}}}}else return l(o,t,e)}return{lo:0,hi:o.length-1}}function xn(n,t,e,i,s){const o=n.getSortedVisibleDatasetMetas(),r=e[t];for(let a=0,l=o.length;a{l[r](t[e],s)&&(o.push({element:l,datasetIndex:c,index:u}),a=a||l.inRange(t.x,t.y,s))}),i&&!a?[]:o}var id={evaluateInteractionItems:xn,modes:{index(n,t,e,i){const s=be(t,n),o=e.axis||"x",r=e.includeInvisible||!1,a=e.intersect?Ti(n,s,o,i,r):Si(n,s,o,!1,i,r),l=[];return a.length?(n.getSortedVisibleDatasetMetas().forEach(c=>{const u=a[0].index,h=c.data[u];h&&!h.skip&&l.push({element:h,datasetIndex:c.index,index:u})}),l):[]},dataset(n,t,e,i){const s=be(t,n),o=e.axis||"xy",r=e.includeInvisible||!1;let a=e.intersect?Ti(n,s,o,i,r):Si(n,s,o,!1,i,r);if(a.length>0){const l=a[0].datasetIndex,c=n.getDatasetMeta(l).data;a=[];for(let u=0;ue.pos===t)}function yo(n,t){return n.filter(e=>oa.indexOf(e.pos)===-1&&e.box.axis===t)}function He(n,t){return n.sort((e,i)=>{const s=t?i:e,o=t?e:i;return s.weight===o.weight?s.index-o.index:s.weight-o.weight})}function sd(n){const t=[];let e,i,s,o,r,a;for(e=0,i=(n||[]).length;ec.box.fullSize),!0),i=He(We(t,"left"),!0),s=He(We(t,"right")),o=He(We(t,"top"),!0),r=He(We(t,"bottom")),a=yo(t,"x"),l=yo(t,"y");return{fullSize:e,leftAndTop:i.concat(o),rightAndBottom:s.concat(l).concat(r).concat(a),chartArea:We(t,"chartArea"),vertical:i.concat(s).concat(l),horizontal:o.concat(r).concat(a)}}function _o(n,t,e,i){return Math.max(n[e],t[e])+Math.max(n[i],t[i])}function ra(n,t){n.top=Math.max(n.top,t.top),n.left=Math.max(n.left,t.left),n.bottom=Math.max(n.bottom,t.bottom),n.right=Math.max(n.right,t.right)}function ld(n,t,e,i){const{pos:s,box:o}=e,r=n.maxPadding;if(!F(s)){e.size&&(n[s]-=e.size);const h=i[e.stack]||{size:0,count:1};h.size=Math.max(h.size,e.horizontal?o.height:o.width),e.size=h.size/h.count,n[s]+=e.size}o.getPadding&&ra(r,o.getPadding());const a=Math.max(0,t.outerWidth-_o(r,n,"left","right")),l=Math.max(0,t.outerHeight-_o(r,n,"top","bottom")),c=a!==n.w,u=l!==n.h;return n.w=a,n.h=l,e.horizontal?{same:c,other:u}:{same:u,other:c}}function cd(n){const t=n.maxPadding;function e(i){const s=Math.max(t[i]-n[i],0);return n[i]+=s,s}n.y+=e("top"),n.x+=e("left"),e("right"),e("bottom")}function ud(n,t){const e=t.maxPadding;function i(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{o[r]=Math.max(t[r],e[r])}),o}return i(n?["left","right"]:["top","bottom"])}function Qe(n,t,e,i){const s=[];let o,r,a,l,c,u;for(o=0,r=n.length,c=0;o{typeof p.beforeLayout=="function"&&p.beforeLayout()});const u=l.reduce((p,m)=>m.box.options&&m.box.options.display===!1?p:p+1,0)||1,h=Object.freeze({outerWidth:t,outerHeight:e,padding:s,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/u,hBoxMaxHeight:r/2}),d=Object.assign({},s);ra(d,yt(i));const f=Object.assign({maxPadding:d,w:o,h:r,x:s.left,y:s.top},s),g=rd(l.concat(c),h);Qe(a.fullSize,f,h,g),Qe(l,f,h,g),Qe(c,f,h,g)&&Qe(l,f,h,g),cd(f),xo(a.leftAndTop,f,h,g),f.x+=f.w,f.y+=f.h,xo(a.rightAndBottom,f,h,g),n.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},$(a.chartArea,p=>{const m=p.box;Object.assign(m,n.chartArea),m.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}};class aa{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,s){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,s?Math.floor(e/s):i)}}isAttached(t){return!0}updateConfig(t){}}class hd extends aa{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const $n="$chartjs",dd={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},vo=n=>n===null||n==="";function fd(n,t){const e=n.style,i=n.getAttribute("height"),s=n.getAttribute("width");if(n[$n]={initial:{height:i,width:s,style:{display:e.display,height:e.height,width:e.width}}},e.display=e.display||"block",e.boxSizing=e.boxSizing||"border-box",vo(s)){const o=no(n,"width");o!==void 0&&(n.width=o)}if(vo(i))if(n.style.height==="")n.height=n.width/(t||2);else{const o=no(n,"height");o!==void 0&&(n.height=o)}return n}const la=bh?{passive:!0}:!1;function gd(n,t,e){n.addEventListener(t,e,la)}function pd(n,t,e){n.canvas.removeEventListener(t,e,la)}function md(n,t){const e=dd[n.type]||n.type,{x:i,y:s}=be(n,t);return{type:e,chart:t,native:n,x:i!==void 0?i:null,y:s!==void 0?s:null}}function ii(n,t){for(const e of n)if(e===t||e.contains(t))return!0}function bd(n,t,e){const i=n.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||ii(a.addedNodes,i),r=r&&!ii(a.removedNodes,i);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}function yd(n,t,e){const i=n.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||ii(a.removedNodes,i),r=r&&!ii(a.addedNodes,i);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}const fn=new Map;let wo=0;function ca(){const n=window.devicePixelRatio;n!==wo&&(wo=n,fn.forEach((t,e)=>{e.currentDevicePixelRatio!==n&&t()}))}function _d(n,t){fn.size||window.addEventListener("resize",ca),fn.set(n,t)}function xd(n){fn.delete(n),fn.size||window.removeEventListener("resize",ca)}function vd(n,t,e){const i=n.canvas,s=i&&ws(i);if(!s)return;const o=Nr((a,l)=>{const c=s.clientWidth;e(a,l),c{const l=a[0],c=l.contentRect.width,u=l.contentRect.height;c===0&&u===0||o(c,u)});return r.observe(s),_d(n,o),r}function Oi(n,t,e){e&&e.disconnect(),t==="resize"&&xd(n)}function wd(n,t,e){const i=n.canvas,s=Nr(o=>{n.ctx!==null&&e(md(o,n))},n);return gd(i,t,s),s}class Md extends aa{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(fd(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[$n])return!1;const i=e[$n].initial;["height","width"].forEach(o=>{const r=i[o];H(r)?e.removeAttribute(o):e.setAttribute(o,r)});const s=i.style||{};return Object.keys(s).forEach(o=>{e.style[o]=s[o]}),e.width=e.width,delete e[$n],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),r={attach:bd,detach:yd,resize:vd}[e]||wd;s[e]=r(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];if(!s)return;({attach:Oi,detach:Oi,resize:Oi}[e]||pd)(t,e,s),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return mh(t,e,i,s)}isAttached(t){const e=ws(t);return!!(e&&e.isConnected)}}function kd(n){return!Kr()||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas?hd:Md}class Lt{constructor(){k(this,"x");k(this,"y");k(this,"active",!1);k(this,"options");k(this,"$animations")}tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return un(this.x)&&un(this.y)}getProps(t,e){const i=this.$animations;if(!e||!i)return this;const s={};return t.forEach(o=>{s[o]=i[o]&&i[o].active()?i[o]._to:this[o]}),s}}k(Lt,"defaults",{}),k(Lt,"defaultRoutes");function Cd(n,t){const e=n.options.ticks,i=Pd(n),s=Math.min(e.maxTicksLimit||i,i),o=e.major.enabled?Td(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>s)return Sd(t,c,o,r/s),c;const u=Dd(o,t,s);if(r>0){let h,d;const f=r>1?Math.round((l-a)/(r-1)):null;for(Ln(t,c,u,H(f)?0:a-f,a),h=0,d=r-1;hs)return l}return Math.max(s,1)}function Td(n){const t=[];let e,i;for(e=0,i=n.length;en==="left"?"right":n==="right"?"left":n,Mo=(n,t,e)=>t==="top"||t==="left"?n[t]+e:n[t]-e,ko=(n,t)=>Math.min(t||n,n);function Co(n,t){const e=[],i=n.length/t,s=n.length;let o=0;for(;or+a)))return l}function Rd(n,t){$(n,e=>{const i=e.gc,s=i.length/2;let o;if(s>t){for(o=0;oi?i:e,i=s&&e>i?e:i,{min:Pt(e,Pt(i,e)),max:Pt(i,Pt(e,i))}}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(){X(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=qu(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a=o||i<=1||!this.isHorizontal()){this.labelRotation=s;return}const u=this._getLabelSizes(),h=u.widest.width,d=u.highest.height,f=ft(this.chart.width-h,0,this.maxWidth);a=t.offset?this.maxWidth/i:f/(i-1),h+6>a&&(a=f/(i-(t.offset?.5:1)),l=this.maxHeight-Ve(t.grid)-e.padding-Po(t.title,this.chart.options.font),c=Math.sqrt(h*h+d*d),r=ps(Math.min(Math.asin(ft((u.highest.height+6)/a,-1,1)),Math.asin(ft(l/c,-1,1))-Math.asin(ft(d/c,-1,1)))),r=Math.max(s,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){X(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){X(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const l=Po(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ve(o)+l):(t.height=this.maxHeight,t.width=Ve(o)+l),i.display&&this.ticks.length){const{first:c,last:u,widest:h,highest:d}=this._getLabelSizes(),f=i.padding*2,g=At(this.labelRotation),p=Math.cos(g),m=Math.sin(g);if(a){const b=i.mirror?0:m*h.width+p*d.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{const b=i.mirror?0:p*h.width+m*d.height;t.width=Math.min(this.maxWidth,t.width+b+f)}this._calculatePadding(c,u,m,p)}}this._handleMargins(),a?(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,i,s){const{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const u=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let d=0,f=0;l?c?(d=s*t.width,f=i*e.height):(d=i*t.height,f=s*e.width):o==="start"?f=e.width:o==="end"?d=t.width:o!=="inner"&&(d=t.width/2,f=e.width/2),this.paddingLeft=Math.max((d-u+r)*this.width/(this.width-u),0),this.paddingRight=Math.max((f-h+r)*this.width/(this.width-h),0)}else{let u=e.height/2,h=t.height/2;o==="start"?(u=0,h=t.height):o==="end"&&(u=e.height,h=0),this.paddingTop=u+r,this.paddingBottom=h+r}}_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(){X(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,i;for(e=0,i=t.length;e({width:r[T]||0,height:a[T]||0});return{first:M(0),last:M(e-1),widest:M(w),highest:M(C),widths:r,heights:a}}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 xu(this._alignToPixels?fe(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&&ta*s?a/i:l/s:l*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:o,position:r,border:a}=s,l=o.offset,c=this.isHorizontal(),h=this.ticks.length+(l?1:0),d=Ve(o),f=[],g=a.setContext(this.getContext()),p=g.display?g.width:0,m=p/2,b=function(U){return fe(i,U,p)};let y,x,v,_,w,C,M,T,A,O,R,st;if(r==="top")y=b(this.bottom),C=this.bottom-d,T=y-m,O=b(t.top)+m,st=t.bottom;else if(r==="bottom")y=b(this.top),O=t.top,st=b(t.bottom)-m,C=y+m,T=this.top+d;else if(r==="left")y=b(this.right),w=this.right-d,M=y-m,A=b(t.left)+m,R=t.right;else if(r==="right")y=b(this.left),A=t.left,R=b(t.right)-m,w=y+m,M=this.left+d;else if(e==="x"){if(r==="center")y=b((t.top+t.bottom)/2+.5);else if(F(r)){const U=Object.keys(r)[0],Q=r[U];y=b(this.chart.scales[U].getPixelForValue(Q))}O=t.top,st=t.bottom,C=y+m,T=C+d}else if(e==="y"){if(r==="center")y=b((t.left+t.right)/2);else if(F(r)){const U=Object.keys(r)[0],Q=r[U];y=b(this.chart.scales[U].getPixelForValue(Q))}w=y-m,M=w-d,A=t.left,R=t.right}const gt=S(s.ticks.maxTicksLimit,h),W=Math.max(1,Math.ceil(h/gt));for(x=0;xo.value===t);return s>=0?e.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(l,c,u)=>{!u.width||!u.color||(i.save(),i.lineWidth=u.width,i.strokeStyle=u.color,i.setLineDash(u.borderDash||[]),i.lineDashOffset=u.borderDashOffset,i.beginPath(),i.moveTo(l.x,l.y),i.lineTo(c.x,c.y),i.stroke(),i.restore())};if(e.display)for(o=0,r=s.length;o{this.draw(o)}}]:[{z:i,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let o,r;for(o=0,r=e.length;o{const i=e.split("."),s=i.pop(),o=[n].concat(i).join("."),r=t[e].split("."),a=r.pop(),l=r.join(".");nt.route(o,s,l,a)})}function Wd(n){return"id"in n&&"defaults"in n}class Hd{constructor(){this.controllers=new Rn(Xt,"datasets",!0),this.elements=new Rn(Lt,"elements"),this.plugins=new Rn(Object,"plugins"),this.scales=new Rn(ke,"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,i){[...e].forEach(s=>{const o=i||this._getRegistryForType(s);i||o.isForType(s)||o===this.plugins&&s.id?this._exec(t,o,s):$(s,r=>{const a=i||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,e,i){const s=gs(t);X(i["before"+s],[],i),e[t](i),X(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;eo.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function Yd(n){const t={},e=[],i=Object.keys(It.plugins.items);for(let o=0;o1&&Do(n[0].toLowerCase());if(i)return i}throw new Error(`Cannot determine type of '${n}' axis. Please provide 'axis' or 'position' option.`)}function To(n,t,e){if(e[t+"AxisID"]===n)return{axis:t}}function Gd(n,t){if(t.data&&t.data.datasets){const e=t.data.datasets.filter(i=>i.xAxisID===n||i.yAxisID===n);if(e.length)return To(n,"x",e[0])||To(n,"y",e[0])}return{}}function Qd(n,t){const e=Me[n.type]||{scales:{}},i=t.scales||{},s=Zi(n.type,t),o=Object.create(null);return Object.keys(i).forEach(r=>{const a=i[r];if(!F(a))return console.error(`Invalid scale configuration for scale: ${r}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);const l=Ji(r,a,Gd(r,n),nt.scales[a.type]),c=Xd(l,s),u=e.scales||{};o[r]=en(Object.create(null),[{axis:l},a,u[l],u[c]])}),n.data.datasets.forEach(r=>{const a=r.type||n.type,l=r.indexAxis||Zi(a,t),u=(Me[a]||{}).scales||{};Object.keys(u).forEach(h=>{const d=qd(h,l),f=r[d+"AxisID"]||d;o[f]=o[f]||Object.create(null),en(o[f],[{axis:d},i[f],u[h]])})}),Object.keys(o).forEach(r=>{const a=o[r];en(a,[nt.scales[a.type],nt.scale])}),o}function ua(n){const t=n.options||(n.options={});t.plugins=S(t.plugins,{}),t.scales=Qd(n,t)}function ha(n){return n=n||{},n.datasets=n.datasets||[],n.labels=n.labels||[],n}function Zd(n){return n=n||{},n.data=ha(n.data),ua(n),n}const So=new Map,da=new Set;function Fn(n,t){let e=So.get(n);return e||(e=t(),So.set(n,e),da.add(e)),e}const Ye=(n,t,e)=>{const i=ce(t,e);i!==void 0&&n.add(i)};class Jd{constructor(t){this._config=Zd(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=ha(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(),ua(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Fn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return Fn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return Fn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id,i=this.type;return Fn(`${i}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return(!s||e)&&(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:o}=this,r=this._cachedScopes(t,i),a=r.get(e);if(a)return a;const l=new Set;e.forEach(u=>{t&&(l.add(t),u.forEach(h=>Ye(l,t,h))),u.forEach(h=>Ye(l,s,h)),u.forEach(h=>Ye(l,Me[o]||{},h)),u.forEach(h=>Ye(l,nt,h)),u.forEach(h=>Ye(l,Ki,h))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),da.has(e)&&r.set(e,c),c}chartOptionScopes(){const{options:t,type:e}=this;return[t,Me[e]||{},nt.datasets[e]||{},{type:e},nt,Ki]}resolveNamedOptions(t,e,i,s=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=Oo(this._resolverCache,t,s);let l=r;if(ef(r,e)){o.$shared=!1,i=ue(i)?i():i;const c=this.createResolver(t,i,a);l=Ee(r,i,c)}for(const c of e)o[c]=l[c];return o}createResolver(t,e,i=[""],s){const{resolver:o}=Oo(this._resolverCache,t,i);return F(e)?Ee(o,e,void 0,s):o}}function Oo(n,t,e){let i=n.get(t);i||(i=new Map,n.set(t,i));const s=e.join();let o=i.get(s);return o||(o={resolver:_s(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},i.set(s,o)),o}const tf=n=>F(n)&&Object.getOwnPropertyNames(n).reduce((t,e)=>t||ue(n[e]),!1);function ef(n,t){const{isScriptable:e,isIndexable:i}=jr(n);for(const s of t){const o=e(s),r=i(s),a=(r||o)&&n[s];if(o&&(ue(a)||tf(a))||r&&K(a))return!0}return!1}var nf="4.4.0";const sf=["top","bottom","left","right","chartArea"];function Ao(n,t){return n==="top"||n==="bottom"||sf.indexOf(n)===-1&&t==="x"}function Lo(n,t){return function(e,i){return e[n]===i[n]?e[t]-i[t]:e[n]-i[n]}}function Ro(n){const t=n.chart,e=t.options.animation;t.notifyPlugins("afterRender"),X(e&&e.onComplete,[n],t)}function of(n){const t=n.chart,e=t.options.animation;X(e&&e.onProgress,[n],t)}function fa(n){return Kr()&&typeof n=="string"?n=document.getElementById(n):n&&n.length&&(n=n[0]),n&&n.canvas&&(n=n.canvas),n}const qn={},Fo=n=>{const t=fa(n);return Object.values(qn).filter(e=>e.canvas===t).pop()};function rf(n,t,e){const i=Object.keys(n);for(const s of i){const o=+s;if(o>=t){const r=n[s];delete n[s],(e>0||o>t)&&(n[o+e]=r)}}}function af(n,t,e,i){return!e||n.type==="mouseout"?null:i?t:n}function In(n,t,e){return n.options.clip?n[e]:t[e]}function lf(n,t){const{xScale:e,yScale:i}=n;return e&&i?{left:In(e,t,"left"),right:In(e,t,"right"),top:In(i,t,"top"),bottom:In(i,t,"bottom")}:t}class mt{static register(...t){It.add(...t),Io()}static unregister(...t){It.remove(...t),Io()}constructor(t,e){const i=this.config=new Jd(e),s=fa(t),o=Fo(s);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 r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||kd(s)),this.platform.updateConfig(i);const a=this.platform.acquireContext(s,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,u=l&&l.width;if(this.id=lu(),this.ctx=a,this.canvas=l,this.width=u,this.height=c,this._options=r,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 Vd,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=ku(h=>this.update(h),r.resizeDelay||0),this._dataChanges=[],qn[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}Yt.listen(this,"complete",Ro),Yt.listen(this,"progress",of),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:o}=this;return H(t)?e&&o?o:s?i/s: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():eo(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Zs(this.canvas,this.ctx),this}stop(){return Yt.stop(this),this}resize(t,e){Yt.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,o=i.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,t,e,o),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,eo(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),X(i.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const e=this.options.scales||{};$(e,(i,s)=>{i.id=s})}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce((r,a)=>(r[a]=!1,r),{});let o=[];e&&(o=o.concat(Object.keys(e).map(r=>{const a=e[r],l=Ji(r,a),c=l==="r",u=l==="x";return{options:a,dposition:c?"chartArea":u?"bottom":"left",dtype:c?"radialLinear":u?"category":"linear"}}))),$(o,r=>{const a=r.options,l=a.id,c=Ji(l,a),u=S(a.type,r.dtype);(a.position===void 0||Ao(a.position,c)!==Ao(r.dposition))&&(a.position=r.dposition),s[l]=!0;let h=null;if(l in i&&i[l].type===u)h=i[l];else{const d=It.getScale(u);h=new d({id:l,type:u,ctx:this.ctx,chart:this}),i[h.id]=h}h.init(a,t)}),$(s,(r,a)=>{r||delete i[a]}),$(i,r=>{se.configure(this,r,r.options),se.addBox(this,r)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort((s,o)=>s.index-o.index),i>e){for(let s=e;se.length&&delete this._stacks,t.forEach((i,s)=>{e.filter(o=>o===i._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,u=this.data.datasets.length;c{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Lo("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){$(this.scales,t=>{se.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);(!js(e,i)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:o}of e){const r=i==="_removeElements"?-o:o;rf(t,s,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),s=i(0);for(let o=1;oo.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;se.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],$(this.boxes,s=>{i&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,i=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,o=lf(t,this.chartArea),r={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",r)!==!1&&(s&&gi(e,{left:i.left===!1?0:o.left-i.left,right:i.right===!1?this.width:o.right+i.right,top:i.top===!1?0:o.top-i.top,bottom:i.bottom===!1?this.height:o.bottom+i.bottom}),t.controller.draw(),s&&pi(e),r.cancelable=!1,this.notifyPlugins("afterDatasetDraw",r))}isPointInArea(t){return qt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,s){const o=id.modes[e];return typeof o=="function"?o(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter(o=>o&&o._dataset===e).pop();return s||(s={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},i.push(s)),s}getContext(){return this.$context||(this.$context=he(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return typeof i.hidden=="boolean"?!i.hidden:!e.hidden}setDatasetVisibility(t,e){const i=this.getDatasetMeta(t);i.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,s);cn(e)?(o.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),r.update(o,{visible:i}),this.update(a=>a.datasetIndex===t?s: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(),Yt.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,r),t[o]=r},s=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};$(this.options.events,o=>i(o,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(l,c)=>{e.addEventListener(this,l,c),t[l]=c},s=(l,c)=>{t[l]&&(e.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)};let r;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",o),i("detach",r)};r=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():r()}unbindEvents(){$(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},$(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let o,r,a,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),a=0,l=t.length;a{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!Zn(i,e)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,i){const s=this.options.hover,o=(l,c)=>l.filter(u=>!c.some(h=>u.datasetIndex===h.datasetIndex&&u.index===h.index)),r=o(e,t),a=i?t:o(t,e);r.length&&this.updateHoverStyle(r,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",i,s)===!1)return;const o=this._handleEvent(t,e,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(o||i.changed)&&this.render(),this}_handleEvent(t,e,i){const{_active:s=[],options:o}=this,r=e,a=this._getActiveElements(t,s,i,r),l=gu(t),c=af(t,this._lastEvent,i,l);i&&(this._lastEvent=null,X(o.onHover,[t,a,this],this),l&&X(o.onClick,[t,a,this],this));const u=!Zn(a,s);return(u||e)&&(this._active=a,this._updateHoverStyles(a,s,e)),this._lastEvent=c,u}_getActiveElements(t,e,i,s){if(t.type==="mouseout")return[];if(!i)return e;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}k(mt,"defaults",nt),k(mt,"instances",qn),k(mt,"overrides",Me),k(mt,"registry",It),k(mt,"version",nf),k(mt,"getChart",Fo);function Io(){return $(mt.instances,n=>n._plugins.invalidate())}function cf(n,t,e){const{startAngle:i,pixelMargin:s,x:o,y:r,outerRadius:a,innerRadius:l}=t;let c=s/a;n.beginPath(),n.arc(o,r,a,i-c,e+c),l>s?(c=s/l,n.arc(o,r,l,e+c,i-c,!0)):n.arc(o,r,s,e+at,i-at),n.closePath(),n.clip()}function uf(n){return ys(n,["outerStart","outerEnd","innerStart","innerEnd"])}function hf(n,t,e,i){const s=uf(n.options.borderRadius),o=(e-t)/2,r=Math.min(o,i*t/2),a=l=>{const c=(e-Math.min(o,l))*i/2;return ft(l,0,Math.min(o,c))};return{outerStart:a(s.outerStart),outerEnd:a(s.outerEnd),innerStart:ft(s.innerStart,0,r),innerEnd:ft(s.innerEnd,0,r)}}function Pe(n,t,e,i){return{x:e+n*Math.cos(t),y:i+n*Math.sin(t)}}function si(n,t,e,i,s,o){const{x:r,y:a,startAngle:l,pixelMargin:c,innerRadius:u}=t,h=Math.max(t.outerRadius+i+e-c,0),d=u>0?u+i+e+c:0;let f=0;const g=s-l;if(i){const W=u>0?u-i:0,U=h>0?h-i:0,Q=(W+U)/2,Mt=Q!==0?g*Q/(Q+i):g;f=(g-Mt)/2}const p=Math.max(.001,g*h-e/tt)/h,m=(g-p)/2,b=l+m+f,y=s-m-f,{outerStart:x,outerEnd:v,innerStart:_,innerEnd:w}=hf(t,d,h,y-b),C=h-x,M=h-v,T=b+x/C,A=y-v/M,O=d+_,R=d+w,st=b+_/O,gt=y-w/R;if(n.beginPath(),o){const W=(T+A)/2;if(n.arc(r,a,h,T,W),n.arc(r,a,h,W,A),v>0){const lt=Pe(M,A,r,a);n.arc(lt.x,lt.y,v,A,y+at)}const U=Pe(R,y,r,a);if(n.lineTo(U.x,U.y),w>0){const lt=Pe(R,gt,r,a);n.arc(lt.x,lt.y,w,y+at,gt+Math.PI)}const Q=(y-w/d+(b+_/d))/2;if(n.arc(r,a,d,y-w/d,Q,!0),n.arc(r,a,d,Q,b+_/d,!0),_>0){const lt=Pe(O,st,r,a);n.arc(lt.x,lt.y,_,st+Math.PI,b-at)}const Mt=Pe(C,b,r,a);if(n.lineTo(Mt.x,Mt.y),x>0){const lt=Pe(C,T,r,a);n.arc(lt.x,lt.y,x,b-at,T)}}else{n.moveTo(r,a);const W=Math.cos(T)*h+r,U=Math.sin(T)*h+a;n.lineTo(W,U);const Q=Math.cos(A)*h+r,Mt=Math.sin(A)*h+a;n.lineTo(Q,Mt)}n.closePath()}function df(n,t,e,i,s){const{fullCircles:o,startAngle:r,circumference:a}=t;let l=t.endAngle;if(o){si(n,t,e,i,l,s);for(let c=0;c=G||hn(r,l,c),m=$t(a,u+f,h+f);return p&&m}getCenterPoint(e){const{x:i,y:s,startAngle:o,endAngle:r,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:c,spacing:u}=this.options,h=(o+r)/2,d=(a+l+u+c)/2;return{x:i+Math.cos(h)*d,y:s+Math.sin(h)*d}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){const{options:i,circumference:s}=this,o=(i.offset||0)/4,r=(i.spacing||0)/2,a=i.circular;if(this.pixelMargin=i.borderAlign==="inner"?.33:0,this.fullCircles=s>G?Math.floor(s/G):0,s===0||this.innerRadius<0||this.outerRadius<0)return;e.save();const l=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(l)*o,Math.sin(l)*o);const c=1-Math.sin(Math.min(tt,s||0)),u=o*c;e.fillStyle=i.backgroundColor,e.strokeStyle=i.borderColor,df(e,this,u,r,a),ff(e,this,u,r,a),e.restore()}}k(Ze,"id","arc"),k(Ze,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0}),k(Ze,"defaultRoutes",{backgroundColor:"backgroundColor"}),k(Ze,"descriptors",{_scriptable:!0,_indexable:e=>e!=="borderDash"});function ga(n,t,e=t){n.lineCap=S(e.borderCapStyle,t.borderCapStyle),n.setLineDash(S(e.borderDash,t.borderDash)),n.lineDashOffset=S(e.borderDashOffset,t.borderDashOffset),n.lineJoin=S(e.borderJoinStyle,t.borderJoinStyle),n.lineWidth=S(e.borderWidth,t.borderWidth),n.strokeStyle=S(e.borderColor,t.borderColor)}function gf(n,t,e){n.lineTo(e.x,e.y)}function pf(n){return n.stepped?Bu:n.tension||n.cubicInterpolationMode==="monotone"?Nu:gf}function pa(n,t,e={}){const i=n.length,{start:s=0,end:o=i-1}=e,{start:r,end:a}=t,l=Math.max(s,r),c=Math.min(o,a),u=sa&&o>a;return{count:i,start:l,loop:t.loop,ilen:c(r+(c?a-v:v))%o,x=()=>{p!==m&&(n.lineTo(u,m),n.lineTo(u,p),n.lineTo(u,b))};for(l&&(f=s[y(0)],n.moveTo(f.x,f.y)),d=0;d<=a;++d){if(f=s[y(d)],f.skip)continue;const v=f.x,_=f.y,w=v|0;w===g?(_m&&(m=_),u=(h*u+v)/++h):(x(),n.lineTo(v,_),g=w,h=0,p=m=_),b=_}x()}function ts(n){const t=n.options,e=t.borderDash&&t.borderDash.length;return!n._decimated&&!n._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?bf:mf}function yf(n){return n.stepped?yh:n.tension||n.cubicInterpolationMode==="monotone"?_h:ye}function _f(n,t,e,i){let s=t._path;s||(s=t._path=new Path2D,t.path(s,e,i)&&s.closePath()),ga(n,t.options),n.stroke(s)}function xf(n,t,e,i){const{segments:s,options:o}=t,r=ts(t);for(const a of s)ga(n,o,a.style),n.beginPath(),r(n,t,a,{start:e,end:e+i-1})&&n.closePath(),n.stroke()}const vf=typeof Path2D=="function";function wf(n,t,e,i){vf&&!t.options.segment?_f(n,t,e,i):xf(n,t,e,i)}class oe extends Lt{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 i=this.options;if((i.tension||i.cubicInterpolationMode==="monotone")&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;uh(this._points,i,t,s,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=Ch(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,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],o=this.points,r=ta(this,{property:e,start:s,end:s});if(!r.length)return;const a=[],l=yf(i);let c,u;for(c=0,u=r.length;ct!=="borderDash"&&t!=="fill"});function Eo(n,t,e,i){const s=n.options,{[e]:o}=n.getProps([e],i);return Math.abs(t-o)n.replace("rgb(","rgba(").replace(")",", 0.5)"));function ba(n){return es[n%es.length]}function ya(n){return zo[n%zo.length]}function Tf(n,t){return n.borderColor=ba(t),n.backgroundColor=ya(t),++t}function Sf(n,t){return n.backgroundColor=n.data.map(()=>ba(t++)),t}function Of(n,t){return n.backgroundColor=n.data.map(()=>ya(t++)),t}function Af(n){let t=0;return(e,i)=>{const s=n.getDatasetMeta(i).controller;s instanceof Le?t=Sf(e,t):s instanceof Un?t=Of(e,t):s&&(t=Tf(e,t))}}function Bo(n){let t;for(t in n)if(n[t].borderColor||n[t].backgroundColor)return!0;return!1}function Lf(n){return n&&(n.borderColor||n.backgroundColor)}var Rf={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(n,t,e){if(!e.enabled)return;const{data:{datasets:i},options:s}=n.config,{elements:o}=s;if(!e.forceOverride&&(Bo(i)||Lf(s)||o&&Bo(o)))return;const r=Af(n);i.forEach(r)}};function Ff(n,t,e){const i=n.segments,s=n.points,o=t.points,r=[];for(const a of i){let{start:l,end:c}=a;c=ks(l,c,s);const u=ns(e,s[l],s[c],a.loop);if(!t.segments){r.push({source:a,target:u,start:s[l],end:s[c]});continue}const h=ta(t,u);for(const d of h){const f=ns(e,o[d.start],o[d.end],d.loop),g=Jr(a,s,f);for(const p of g)r.push({source:p,target:d,start:{[e]:No(u,f,"start",Math.max)},end:{[e]:No(u,f,"end",Math.min)}})}}return r}function ns(n,t,e,i){if(i)return;let s=t[n],o=e[n];return n==="angle"&&(s=Dt(s),o=Dt(o)),{property:n,start:s,end:o}}function If(n,t){const{x:e=null,y:i=null}=n||{},s=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=ks(r,a,s);const l=s[r],c=s[a];i!==null?(o.push({x:l.x,y:i}),o.push({x:c.x,y:i})):e!==null&&(o.push({x:e,y:l.y}),o.push({x:e,y:c.y}))}),o}function ks(n,t,e){for(;t>n;t--){const i=e[t];if(!isNaN(i.x)&&!isNaN(i.y))break}return t}function No(n,t,e,i){return n&&t?i(n[e],t[e]):n?n[e]:t?t[e]:0}function _a(n,t){let e=[],i=!1;return K(n)?(i=!0,e=n):e=If(n,t),e.length?new oe({points:e,options:{tension:0},_loop:i,_fullLoop:i}):null}function Wo(n){return n&&n.fill!==!1}function Ef(n,t,e){let s=n[t].fill;const o=[t];let r;if(!e)return s;for(;s!==!1&&o.indexOf(s)===-1;){if(!et(s))return s;if(r=n[s],!r)return!1;if(r.visible)return s;o.push(s),s=r.fill}return!1}function zf(n,t,e){const i=Hf(n);if(F(i))return isNaN(i.value)?!1:i;let s=parseFloat(i);return et(s)&&Math.floor(s)===s?Bf(i[0],t,s,e):["origin","start","end","stack","shape"].indexOf(i)>=0&&i}function Bf(n,t,e,i){return(n==="-"||n==="+")&&(e=t+e),e===t||e<0||e>=i?!1:e}function Nf(n,t){let e=null;return n==="start"?e=t.bottom:n==="end"?e=t.top:F(n)?e=t.getPixelForValue(n.value):t.getBasePixel&&(e=t.getBasePixel()),e}function Wf(n,t,e){let i;return n==="start"?i=e:n==="end"?i=t.options.reverse?t.min:t.max:F(n)?i=n.value:i=t.getBaseValue(),i}function Hf(n){const t=n.options,e=t.fill;let i=S(e&&e.target,e);return i===void 0&&(i=!!t.backgroundColor),i===!1||i===null?!1:i===!0?"origin":i}function Vf(n){const{scale:t,index:e,line:i}=n,s=[],o=i.segments,r=i.points,a=Yf(t,e);a.push(_a({x:null,y:t.bottom},i));for(let l=0;l=0;--r){const a=s[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),i&&a.fill&&Ri(n.ctx,a,o))}},beforeDatasetsDraw(n,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;const i=n.getSortedVisibleDatasetMetas();for(let s=i.length-1;s>=0;--s){const o=i[s].$filler;Wo(o)&&Ri(n.ctx,o,n.chartArea)}},beforeDatasetDraw(n,t,e){const i=t.meta.$filler;!Wo(i)||e.drawTime!=="beforeDatasetDraw"||Ri(n.ctx,i,n.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const jo=(n,t)=>{let{boxHeight:e=t,boxWidth:i=t}=n;return n.usePointStyle&&(e=Math.min(e,t),i=n.pointStyleWidth||Math.min(i,t)),{boxWidth:i,boxHeight:e,itemHeight:Math.max(t,e)}},tg=(n,t)=>n!==null&&t!==null&&n.datasetIndex===t.datasetIndex&&n.index===t.index;class Uo extends Lt{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,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,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=X(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(i=>t.filter(i,this.chart.data))),t.sort&&(e=e.sort((i,s)=>t.sort(i,s,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}const i=t.labels,s=ut(i.font),o=s.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=jo(i,o);let c,u;e.font=s.string,this.isHorizontal()?(c=this.maxWidth,u=this._fitRows(r,o,a,l)+10):(u=this.maxHeight,c=this._fitCols(r,s,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],u=s+a;let h=t;o.textAlign="left",o.textBaseline="middle";let d=-1,f=-u;return this.legendItems.forEach((g,p)=>{const m=i+e/2+o.measureText(g.text).width;(p===0||c[c.length-1]+m+2*a>r)&&(h+=u,c[c.length-(p>0?0:1)]=0,f+=u,d++),l[p]={left:0,top:f,row:d,width:m,height:s},c[c.length-1]+=m+a}),h}_fitCols(t,e,i,s){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],u=r-t;let h=a,d=0,f=0,g=0,p=0;return this.legendItems.forEach((m,b)=>{const{itemWidth:y,itemHeight:x}=eg(i,e,o,m,s);b>0&&f+x+2*a>u&&(h+=d+a,c.push({width:d,height:f}),g+=d+a,p++,d=f=0),l[b]={left:g,top:f,col:p,width:y,height:x},d=Math.max(d,y),f+=x+a}),h+=d,c.push({width:d,height:f}),h}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,r=Fe(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=kt(i,this.left+s,this.right-this.lineWidths[a]);for(const c of e)a!==c.row&&(a=c.row,l=kt(i,this.left+s,this.right-this.lineWidths[a])),c.top+=this.top+t+s,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+s}else{let a=0,l=kt(i,this.top+t+s,this.bottom-this.columnSizes[a].height);for(const c of e)c.col!==a&&(a=c.col,l=kt(i,this.top+t+s,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+s,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;gi(t,this),this._draw(),pi(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:o,labels:r}=t,a=nt.color,l=Fe(t.rtl,this.left,this.width),c=ut(r.font),{padding:u}=r,h=c.size,d=h/2;let f;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:g,boxHeight:p,itemHeight:m}=jo(r,h),b=function(w,C,M){if(isNaN(g)||g<=0||isNaN(p)||p<0)return;s.save();const T=S(M.lineWidth,1);if(s.fillStyle=S(M.fillStyle,a),s.lineCap=S(M.lineCap,"butt"),s.lineDashOffset=S(M.lineDashOffset,0),s.lineJoin=S(M.lineJoin,"miter"),s.lineWidth=T,s.strokeStyle=S(M.strokeStyle,a),s.setLineDash(S(M.lineDash,[])),r.usePointStyle){const A={radius:p*Math.SQRT2/2,pointStyle:M.pointStyle,rotation:M.rotation,borderWidth:T},O=l.xPlus(w,g/2),R=C+d;Vr(s,A,O,R,r.pointStyleWidth&&g)}else{const A=C+Math.max((h-p)/2,0),O=l.leftForLtr(w,g),R=ve(M.borderRadius);s.beginPath(),Object.values(R).some(st=>st!==0)?dn(s,{x:O,y:A,w:g,h:p,radius:R}):s.rect(O,A,g,p),s.fill(),T!==0&&s.stroke()}s.restore()},y=function(w,C,M){Ie(s,M.text,w,C+m/2,c,{strikethrough:M.hidden,textAlign:l.textAlign(M.textAlign)})},x=this.isHorizontal(),v=this._computeTitleHeight();x?f={x:kt(o,this.left+u,this.right-i[0]),y:this.top+u+v,line:0}:f={x:this.left+u,y:kt(o,this.top+v+u,this.bottom-e[0].height),line:0},Gr(this.ctx,t.textDirection);const _=m+u;this.legendItems.forEach((w,C)=>{s.strokeStyle=w.fontColor,s.fillStyle=w.fontColor;const M=s.measureText(w.text).width,T=l.textAlign(w.textAlign||(w.textAlign=r.textAlign)),A=g+d+M;let O=f.x,R=f.y;l.setWidth(this.width),x?C>0&&O+A+u>this.right&&(R=f.y+=_,f.line++,O=f.x=kt(o,this.left+u,this.right-i[f.line])):C>0&&R+_>this.bottom&&(O=f.x=O+e[f.line].width+u,f.line++,R=f.y=kt(o,this.top+v+u,this.bottom-e[f.line].height));const st=l.x(O);if(b(st,R,w),O=Cu(T,O+g+d,x?O+A:this.right,t.rtl),y(l.x(O),R,w),x)f.x+=A+u;else if(typeof w.text!="string"){const gt=c.lineHeight;f.y+=va(w,gt)+u}else f.y+=_}),Qr(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=ut(e.font),s=yt(e.padding);if(!e.display)return;const o=Fe(t.rtl,this.left,this.width),r=this.ctx,a=e.position,l=i.size/2,c=s.top+l;let u,h=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),u=this.top+c,h=kt(t.align,h,this.right-d);else{const g=this.columnSizes.reduce((p,m)=>Math.max(p,m.height),0);u=c+kt(t.align,this.top,this.bottom-g-t.labels.padding-this._computeTitleHeight())}const f=kt(a,h,h+d);r.textAlign=o.textAlign(Wr(a)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,Ie(r,e.text,f,u,i)}_computeTitleHeight(){const t=this.options.title,e=ut(t.font),i=yt(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,o;if($t(t,this.left,this.right)&&$t(e,this.top,this.bottom)){for(o=this.legendHitBoxes,i=0;io.length>r.length?o:r)),t+e.size/2+i.measureText(s).width}function ig(n,t,e){let i=n;return typeof t.text!="string"&&(i=va(t,e)),i}function va(n,t){const e=n.text?n.text.length:0;return t*e}function sg(n,t){return!!((n==="mousemove"||n==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(n==="click"||n==="mouseup"))}var og={id:"legend",_element:Uo,start(n,t,e){const i=n.legend=new Uo({ctx:n.ctx,options:e,chart:n});se.configure(n,i,e),se.addBox(n,i)},stop(n){se.removeBox(n,n.legend),delete n.legend},beforeUpdate(n,t,e){const i=n.legend;se.configure(n,i,e),i.options=e},afterUpdate(n){const t=n.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(n,t){t.replay||n.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(n,t,e){const i=t.datasetIndex,s=e.chart;s.isDatasetVisible(i)?(s.hide(i),t.hidden=!0):(s.show(i),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:n=>n.chart.options.color,boxWidth:40,padding:10,generateLabels(n){const t=n.data.datasets,{labels:{usePointStyle:e,pointStyle:i,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=n.legend.options;return n._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(e?0:void 0),u=yt(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(u.width+u.height)/4,strokeStyle:c.borderColor,pointStyle:i||c.pointStyle,rotation:c.rotation,textAlign:s||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:n=>n.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:n=>!n.startsWith("on"),labels:{_scriptable:n=>!["generateLabels","filter","sort"].includes(n)}}};const Je={average(n){if(!n.length)return!1;let t,e,i=0,s=0,o=0;for(t=0,e=n.length;t-1?n.split(` -`):n}function rg(n,t){const{element:e,datasetIndex:i,index:s}=t,o=n.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:n,label:r,parsed:o.getParsed(s),raw:n.data.datasets[i].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:e}}function $o(n,t){const e=n.chart.ctx,{body:i,footer:s,title:o}=n,{boxWidth:r,boxHeight:a}=t,l=ut(t.bodyFont),c=ut(t.titleFont),u=ut(t.footerFont),h=o.length,d=s.length,f=i.length,g=yt(t.padding);let p=g.height,m=0,b=i.reduce((v,_)=>v+_.before.length+_.lines.length+_.after.length,0);if(b+=n.beforeBody.length+n.afterBody.length,h&&(p+=h*c.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),b){const v=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;p+=f*v+(b-f)*l.lineHeight+(b-1)*t.bodySpacing}d&&(p+=t.footerMarginTop+d*u.lineHeight+(d-1)*t.footerSpacing);let y=0;const x=function(v){m=Math.max(m,e.measureText(v).width+y)};return e.save(),e.font=c.string,$(n.title,x),e.font=l.string,$(n.beforeBody.concat(n.afterBody),x),y=t.displayColors?r+2+t.boxPadding:0,$(i,v=>{$(v.before,x),$(v.lines,x),$(v.after,x)}),y=0,e.font=u.string,$(n.footer,x),e.restore(),m+=g.width,{width:m,height:p}}function ag(n,t){const{y:e,height:i}=t;return en.height-i/2?"bottom":"center"}function lg(n,t,e,i){const{x:s,width:o}=i,r=e.caretSize+e.caretPadding;if(n==="left"&&s+o+r>t.width||n==="right"&&s-o-r<0)return!0}function cg(n,t,e,i){const{x:s,width:o}=e,{width:r,chartArea:{left:a,right:l}}=n;let c="center";return i==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),lg(c,n,t,e)&&(c="center"),c}function qo(n,t,e){const i=e.yAlign||t.yAlign||ag(n,e);return{xAlign:e.xAlign||t.xAlign||cg(n,t,e,i),yAlign:i}}function ug(n,t){let{x:e,width:i}=n;return t==="right"?e-=i:t==="center"&&(e-=i/2),e}function hg(n,t,e){let{y:i,height:s}=n;return t==="top"?i+=e:t==="bottom"?i-=s+e:i-=s/2,i}function Xo(n,t,e,i){const{caretSize:s,caretPadding:o,cornerRadius:r}=n,{xAlign:a,yAlign:l}=e,c=s+o,{topLeft:u,topRight:h,bottomLeft:d,bottomRight:f}=ve(r);let g=ug(t,a);const p=hg(t,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(u,d)+s:a==="right"&&(g+=Math.max(h,f)+s),{x:ft(g,0,i.width-t.width),y:ft(p,0,i.height-t.height)}}function En(n,t,e){const i=yt(e.padding);return t==="center"?n.x+n.width/2:t==="right"?n.x+n.width-i.right:n.x+i.left}function Ko(n){return Ft([],jt(n))}function dg(n,t,e){return he(n,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Go(n,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?n.override(e):n}const wa={beforeTitle:Wt,title(n){if(n.length>0){const t=n[0],e=t.chart.data.labels,i=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex"u"?wa[t].call(e,i):s}class is extends Lt{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,o=new ea(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=dg(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:i}=e,s=_t(i,"beforeTitle",this,t),o=_t(i,"title",this,t),r=_t(i,"afterTitle",this,t);let a=[];return a=Ft(a,jt(s)),a=Ft(a,jt(o)),a=Ft(a,jt(r)),a}getBeforeBody(t,e){return Ko(_t(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,s=[];return $(t,o=>{const r={before:[],lines:[],after:[]},a=Go(i,o);Ft(r.before,jt(_t(a,"beforeLabel",this,o))),Ft(r.lines,_t(a,"label",this,o)),Ft(r.after,jt(_t(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,e){return Ko(_t(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,s=_t(i,"beforeFooter",this,t),o=_t(i,"footer",this,t),r=_t(i,"afterFooter",this,t);let a=[];return a=Ft(a,jt(s)),a=Ft(a,jt(o)),a=Ft(a,jt(r)),a}_createItems(t){const e=this._active,i=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=e.length;lt.filter(u,h,d,i))),t.itemSort&&(a=a.sort((u,h)=>t.itemSort(u,h,i))),$(a,u=>{const h=Go(t.callbacks,u);s.push(_t(h,"labelColor",this,u)),o.push(_t(h,"labelPointStyle",this,u)),r.push(_t(h,"labelTextColor",this,u))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=Je[i.position].call(this,s,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const l=this._size=$o(this,i),c=Object.assign({},a,l),u=qo(this.chart,i,c),h=Xo(i,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,o={opacity:1,x:h.x,y:h.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const o=this.getCaretPosition(t,i,s);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=i,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:h}=ve(a),{x:d,y:f}=t,{width:g,height:p}=e;let m,b,y,x,v,_;return o==="center"?(v=f+p/2,s==="left"?(m=d,b=m-r,x=v+r,_=v-r):(m=d+g,b=m+r,x=v-r,_=v+r),y=m):(s==="left"?b=d+Math.max(l,u)+r:s==="right"?b=d+g-Math.max(c,h)-r:b=this.caretX,o==="top"?(x=f,v=x-r,m=b-r,y=b+r):(x=f+p,v=x+r,m=b+r,y=b-r),_=x),{x1:m,x2:b,x3:y,y1:x,y2:v,y3:_}}drawTitle(t,e,i){const s=this.title,o=s.length;let r,a,l;if(o){const c=Fe(i.rtl,this.x,this.width);for(t.x=En(this,i.titleAlign,i),e.textAlign=c.textAlign(i.titleAlign),e.textBaseline="middle",r=ut(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=r.string,l=0;ly!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,dn(t,{x:p,y:g,w:c,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),dn(t,{x:m,y:g+1,w:c-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(p,g,c,l),t.strokeRect(p,g,c,l),t.fillStyle=r.backgroundColor,t.fillRect(m,g+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=i,h=ut(i.bodyFont);let d=h.lineHeight,f=0;const g=Fe(i.rtl,this.x,this.width),p=function(M){e.fillText(M,g.x(t.x+f),t.y+d/2),t.y+=d+o},m=g.textAlign(r);let b,y,x,v,_,w,C;for(e.textAlign=r,e.textBaseline="middle",e.font=h.string,t.x=En(this,m,i),e.fillStyle=i.bodyColor,$(this.beforeBody,p),f=a&&m!=="right"?r==="center"?c/2+u:c+2+u:0,v=0,w=s.length;v0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const r=Je[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=$o(this,t),l=Object.assign({},r,this._size),c=qo(e,t,l),u=Xo(t,l,c,e);(s._to!==u.x||o._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const r=yt(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,e),Gr(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),Qr(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Zn(i,s),r=this._positionChanged(s,e);(o||r)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,i),a=this._positionChanged(r,t),l=e||!Zn(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,i,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return e;const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,e){const{caretX:i,caretY:s,options:o}=this,r=Je[o.position].call(this,t,e);return r!==!1&&(i!==r.x||s!==r.y)}}k(is,"positioners",Je);var fg={id:"tooltip",_element:is,positioners:Je,afterInit(n,t,e){e&&(n.tooltip=new is({chart:n,options:e}))},beforeUpdate(n,t,e){n.tooltip&&n.tooltip.initialize(e)},reset(n,t,e){n.tooltip&&n.tooltip.initialize(e)},afterDraw(n){const t=n.tooltip;if(t&&t._willRender()){const e={tooltip:t};if(n.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(n.ctx),n.notifyPlugins("afterTooltipDraw",e)}},afterEvent(n,t){if(n.tooltip){const e=t.replay;n.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.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:(n,t)=>t.bodyFont.size,boxWidth:(n,t)=>t.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:wa},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:n=>n!=="filter"&&n!=="itemSort"&&n!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const gg=(n,t,e,i)=>(typeof t=="string"?(e=n.push(t)-1,i.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function pg(n,t,e,i){const s=n.indexOf(t);if(s===-1)return gg(n,t,e,i);const o=n.lastIndexOf(t);return s!==o?e:s}const mg=(n,t)=>n===null?null:ft(Math.round(n),0,t);function Qo(n){const t=this.getLabels();return n>=0&&ne.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}k(ss,"id","category"),k(ss,"defaults",{ticks:{callback:Qo}});function bg(n,t){const e=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:u,maxDigits:h,includeBounds:d}=n,f=o||1,g=u-1,{min:p,max:m}=t,b=!H(r),y=!H(a),x=!H(c),v=(m-p)/(h+1);let _=$s((m-p)/g/f)*f,w,C,M,T;if(_<1e-14&&!b&&!y)return[{value:p},{value:m}];T=Math.ceil(m/_)-Math.floor(p/_),T>g&&(_=$s(T*_/g/f)*f),H(l)||(w=Math.pow(10,l),_=Math.ceil(_*w)/w),s==="ticks"?(C=Math.floor(p/_)*_,M=Math.ceil(m/_)*_):(C=p,M=m),b&&y&&o&&yu((a-r)/o,_/1e3)?(T=Math.round(Math.min((a-r)/_,u)),_=(a-r)/T,C=r,M=a):x?(C=b?r:C,M=y?a:M,T=c-1,_=(M-C)/T):(T=(M-C)/_,nn(T,Math.round(T),_/1e3)?T=Math.round(T):T=Math.ceil(T));const A=Math.max(qs(_),qs(C));w=Math.pow(10,H(l)?A:l),C=Math.round(C*w)/w,M=Math.round(M*w)/w;let O=0;for(b&&(d&&C!==r?(e.push({value:r}),Ca)break;e.push({value:R})}return y&&d&&M!==a?e.length&&nn(e[e.length-1].value,a,Zo(a,v,n))?e[e.length-1].value=a:e.push({value:a}):(!y||M===a)&&e.push({value:M}),e}function Zo(n,t,{horizontal:e,minRotation:i}){const s=At(i),o=(e?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+n).length;return Math.min(t/o,r)}class oi extends ke{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 H(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:o}=this;const r=l=>s=e?s:l,a=l=>o=i?o:l;if(t){const l=Bt(s),c=Bt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:i}=t,s;return i?(s=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,s>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${i} would result generating up to ${s} ticks. Limiting to 1000.`),s=1e3)):(s=this.computeTickLimit(),e=e||11),e&&(s=Math.min(e,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s={maxTicks:i,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:e.includeBounds!==!1},o=this._range||this,r=bg(s,o);return t.bounds==="ticks"&&Fr(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,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-e)/Math.max(t.length-1,1)/2;e-=s,i+=s}this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return _n(t,this.chart.options.locale,this.options.ticks.format)}}class os extends oi{determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=et(t)?t:0,this.max=et(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=At(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}k(os,"id","linear"),k(os,"defaults",{ticks:{callback:fi.formatters.numeric}});const gn=n=>Math.floor(ie(n)),pe=(n,t)=>Math.pow(10,gn(n)+t);function Jo(n){return n/Math.pow(10,gn(n))===1}function tr(n,t,e){const i=Math.pow(10,e),s=Math.floor(n/i);return Math.ceil(t/i)-s}function yg(n,t){const e=t-n;let i=gn(e);for(;tr(n,t,i)>10;)i++;for(;tr(n,t,i)<10;)i--;return Math.min(i,gn(n))}function _g(n,{min:t,max:e}){t=Pt(n.min,t);const i=[],s=gn(t);let o=yg(t,e),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((t-l)*r)/r,u=Math.floor((t-l)/a/10)*a*10;let h=Math.floor((c-u)/Math.pow(10,o)),d=Pt(n.min,Math.round((l+u+h*Math.pow(10,o))*r)/r);for(;d=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,r=o>=0?1:r),d=Math.round((l+u+h*Math.pow(10,o))*r)/r;const f=Pt(n.max,d);return i.push({value:f,major:Jo(f),significand:h}),i}class er extends ke{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const i=oi.prototype.parse.apply(this,[t,e]);if(i===0){this._zero=!0;return}return et(i)&&i>0?i:null}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=et(t)?Math.max(0,t):null,this.max=et(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!et(this._userMin)&&(this.min=t===pe(this.min,0)?pe(this.min,-1):pe(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const o=a=>i=t?i:a,r=a=>s=e?s:a;i===s&&(i<=0?(o(1),r(10)):(o(pe(i,-1)),r(pe(s,1)))),i<=0&&o(pe(s,-1)),s<=0&&r(pe(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e={min:this._userMin,max:this._userMax},i=_g(e,this);return t.bounds==="ticks"&&Fr(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}getLabelForValue(t){return t===void 0?"0":_n(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=ie(t),this._valueRange=ie(this.max)-ie(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(ie(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}k(er,"id","logarithmic"),k(er,"defaults",{ticks:{callback:fi.formatters.logarithmic,major:{enabled:!0}}});function rs(n){const t=n.ticks;if(t.display&&n.display){const e=yt(t.backdropPadding);return S(t.font&&t.font.size,nt.font.size)+e.height}return 0}function xg(n,t,e){return e=K(e)?e:[e],{w:zu(n,t.string,e),h:e.length*t.lineHeight}}function nr(n,t,e,i,s){return n===i||n===s?{start:t-e/2,end:t+e/2}:ns?{start:t-e,end:t}:{start:t,end:t+e}}function vg(n){const t={l:n.left+n._padding.left,r:n.right-n._padding.right,t:n.top+n._padding.top,b:n.bottom-n._padding.bottom},e=Object.assign({},t),i=[],s=[],o=n._pointLabels.length,r=n.options.pointLabels,a=r.centerPointLabels?tt/o:0;for(let l=0;lt.r&&(a=(i.end-t.r)/o,n.r=Math.max(n.r,t.r+a)),s.startt.b&&(l=(s.end-t.b)/r,n.b=Math.max(n.b,t.b+l))}function Mg(n,t,e){const i=n.drawingArea,{extra:s,additionalAngle:o,padding:r,size:a}=e,l=n.getPointPosition(t,i+s+r,o),c=Math.round(ps(Dt(l.angle+at))),u=Tg(l.y,a.h,c),h=Pg(c),d=Dg(l.x,a.w,h);return{visible:!0,x:l.x,y:u,textAlign:h,left:d,top:u,right:d+a.w,bottom:u+a.h}}function kg(n,t){if(!t)return!0;const{left:e,top:i,right:s,bottom:o}=n;return!(qt({x:e,y:i},t)||qt({x:e,y:o},t)||qt({x:s,y:i},t)||qt({x:s,y:o},t))}function Cg(n,t,e){const i=[],s=n._pointLabels.length,o=n.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:rs(o)/2,additionalAngle:r?tt/s:0};let c;for(let u=0;u270||e<90)&&(n-=t),n}function Sg(n,t,e){const{left:i,top:s,right:o,bottom:r}=e,{backdropColor:a}=t;if(!H(a)){const l=ve(t.borderRadius),c=yt(t.backdropPadding);n.fillStyle=a;const u=i-c.left,h=s-c.top,d=o-i+c.width,f=r-s+c.height;Object.values(l).some(g=>g!==0)?(n.beginPath(),dn(n,{x:u,y:h,w:d,h:f,radius:l}),n.fill()):n.fillRect(u,h,d,f)}}function Og(n,t){const{ctx:e,options:{pointLabels:i}}=n;for(let s=t-1;s>=0;s--){const o=n._pointLabelItems[s];if(!o.visible)continue;const r=i.setContext(n.getPointLabelContext(s));Sg(e,r,o);const a=ut(r.font),{x:l,y:c,textAlign:u}=o;Ie(e,n._pointLabels[s],l,c+a.lineHeight/2,a,{color:r.color,textAlign:u,textBaseline:"middle"})}}function Ma(n,t,e,i){const{ctx:s}=n;if(e)s.arc(n.xCenter,n.yCenter,t,0,G);else{let o=n.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let r=1;r{const s=X(this.options.pointLabels.callback,[e,i],this);return s||s===0?s:""}).filter((e,i)=>this.chart.getDataVisibility(i))}fit(){const t=this.options;t.display&&t.pointLabels.display?vg(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,s))}getIndexAngle(t){const e=G/(this._pointLabels.length||1),i=this.options.startAngle||0;return Dt(t*e+At(i))}getDistanceFromCenterForValue(t){if(H(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(H(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t{if(h!==0){l=this.getDistanceFromCenterForValue(u.value);const d=this.getContext(h),f=s.setContext(d),g=o.setContext(d);Ag(this,f,l,r,g)}}),i.display){for(t.save(),a=r-1;a>=0;a--){const u=i.setContext(this.getPointLabelContext(a)),{color:h,lineWidth:d}=u;!d||!h||(t.lineWidth=d,t.strokeStyle=h,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,l=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&!e.reverse)return;const c=i.setContext(this.getContext(l)),u=ut(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=u.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const h=yt(c.backdropPadding);t.fillRect(-r/2-h.left,-o-u.size/2-h.top,r+h.width,u.size+h.height)}Ie(t,a.label,0,-o,u,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}k(zn,"id","radialLinear"),k(zn,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:fi.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),k(zn,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),k(zn,"descriptors",{angleLines:{_fallback:"grid"}});const bi={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},xt=Object.keys(bi);function ir(n,t){return n-t}function sr(n,t){if(H(t))return null;const e=n._adapter,{parser:i,round:s,isoWeekday:o}=n._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),et(r)||(r=typeof i=="string"?e.parse(r,i):e.parse(r)),r===null?null:(s&&(r=s==="week"&&(un(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,s)),+r)}function or(n,t,e,i){const s=xt.length;for(let o=xt.indexOf(n);o=xt.indexOf(e);o--){const r=xt[o];if(bi[r].common&&n._adapter.diff(s,i,r)>=t-1)return r}return xt[e?xt.indexOf(e):0]}function Fg(n){for(let t=xt.indexOf(n)+1,e=xt.length;t=t?e[i]:e[s];n[o]=!0}}function Ig(n,t,e,i){const s=n._adapter,o=+s.startOf(t[0].value,i),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,i))l=e[a],l>=0&&(t[l].major=!0);return t}function ar(n,t,e){const i=[],s={},o=t.length;let r,a;for(r=0;r+t.value))}initOffsets(t=[]){let e=0,i=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?e=1-s:e=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;e=ft(e,0,r),i=ft(i,0,r),this._offsets={start:e,end:i,factor:1/(e+1+i)}}_generate(){const t=this._adapter,e=this.min,i=this.max,s=this.options,o=s.time,r=o.unit||or(o.minUnit,e,i,this._getLabelCapacity(e)),a=S(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=un(l)||l===!0,u={};let h=e,d,f;if(c&&(h=+t.startOf(h,"isoWeek",l)),h=+t.startOf(h,c?"day":r),t.diff(i,e,r)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+r);const g=s.ticks.source==="data"&&this.getDataTimestamps();for(d=h,f=0;d+p)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const s=this.options.time.displayFormats,o=this._unit,r=e||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,i,s){const o=this.options,r=o.ticks.callback;if(r)return X(r,[t,e,i],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],h=c&&a[c],d=i[e],f=c&&h&&d&&d.major;return this._adapter.format(t,s||(f?h:u))}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,i;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(e=0,i=s.length;e=n[i].pos&&t<=n[s].pos&&({lo:i,hi:s}=xe(n,"pos",t)),{pos:o,time:a}=n[i],{pos:r,time:l}=n[s]):(t>=n[i].time&&t<=n[s].time&&({lo:i,hi:s}=xe(n,"time",t)),{time:o,pos:a}=n[i],{time:r,pos:l}=n[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class lr extends pn{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=Bn(e,this.min),this._tableRange=Bn(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],o=[];let r,a,l,c,u;for(r=0,a=t.length;r=e&&c<=i&&s.push(c);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(r=0,a=s.length;rs-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return e.length&&i.length?t=this.normalize(e.concat(i)):t=e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(Bn(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return Bn(this._table,i*this._tableRange+this._minPos,!0)}}k(lr,"id","timeseries"),k(lr,"defaults",pn.defaults);function yi(n){return n==="sankey"?{type:"sankey",data:{datasets:[]},options:{animations:!1}}:n==="pie"?{type:"pie",data:{datasets:[]}}:n==="column"?{type:"bar",data:{labels:[],datasets:[]},options:{plugins:{tooltip:{callbacks:{label:function(t){let e=t.dataset.currency_code;return V(t.raw,e)}}}},maintainAspectRatio:!1,scales:{}}}:n==="line"?{options:{plugins:{tooltip:{callbacks:{label:function(t){let e=t.dataset.currency_code;return V(t.raw,e)}}}},maintainAspectRatio:!1,scales:{x:{type:"time",time:{tooltipFormat:"PP"}}}},type:"line",data:{labels:[],datasets:[]}}:{}}let ri=new dt("#36a2eb"),Re=new dt("#ff6384"),mn=new dt("#4bc0c0"),ka=new dt("#ff9f40"),Eg=new dt("#9966ff"),zg=new dt("#ffcd56"),Bg=new dt("#c9cbcf"),cr=0;window.theme==="dark"&&(Re.darken(.3).desaturate(.3),mn.darken(.3).desaturate(.3),ri.darken(.3).desaturate(.3),ka.darken(.3).desaturate(.3));let Fi=[Re,ka,ri,mn,Eg,zg,Bg,mn];function De(n,t){let e={borderColor:Re.rgbString(),backgroundColor:Re.rgbString()},i;switch(n){default:let o=Math.floor(cr/2)%Fi.length;i=new dt(Fi[o].rgbString()),i.lighten(.38),e={borderColor:Fi[o].hexString(),backgroundColor:i.hexString()};break;case"spent":i=new dt(ri.rgbString()),i.lighten(.38),e={borderColor:ri.rgbString(),backgroundColor:i.rgbString()};break;case"left":i=new dt(mn.rgbString()),i.lighten(.38),e={borderColor:mn.rgbString(),backgroundColor:i.rgbString()};break;case"overspent":i=new dt(Re.rgbString()),i.lighten(.22),e={borderColor:Re.rgbString(),backgroundColor:i.rgbString()};break}return cr++,t==="border"?e.borderColor:t==="background"?e.backgroundColor:"#FF0000"}let me=[],je=null,Ii=null,Ei=!1;const Ng=()=>({loading:!1,loadingAccounts:!1,accountList:[],autoConversion:!1,chartOptions:null,switchAutoConversion(){this.autoConversion=!this.autoConversion,Bc("autoConversion",this.autoConversion)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt("dashboard-accounts-chart",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){console.log(s),this.drawChart(this.generateOptions(s)),this.loading=!1;return}new Nc().dashboard(n,t,null).then(r=>{this.chartData=r.data,window.store.set(e,r.data),console.log(r.data),this.drawChart(this.generateOptions(this.chartData)),this.loading=!1})},generateOptions(n){me=[];let t=yi("line");for(let e=0;e0){this.loadingAccounts=!1;return}const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt("dashboard-accounts-data",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){this.accountList=s,this.loadingAccounts=!1;return}const o=10;let r=0,a=0,l=[];Promise.all([bt("frontpageAccounts")]).then(c=>{r=c[0].length;for(let u in c[0]){let h=c[0];if(h.hasOwnProperty(u)){let d=h[u];new Bs().get(d,new Date(window.store.get("end"))).then(f=>{let g=f.data.data;const p={page:1,start:new Date(window.store.get("start")),end:new Date(window.store.get("end"))};new Bs().transactions(g.id,p).then(m=>{let b=[];for(let y=0;y=o);y++){let x=m.data.data[y],v={title:x.attributes.group_title===null?"":x.attributes.group_title,id:x.id,transactions:[]};for(let _=0;_y.order-x.order),this.accountList=l,this.loadingAccounts=!1,window.store.set(e,l))})})}}})},init(){Promise.all([bt("viewRange","1M"),bt("autoConversion",!1),bt("language","en_US")]).then(n=>{this.autoConversion=n[1],Ei=!0,this.loadChart(),this.loadAccounts()}),window.store.observe("end",()=>{Ei&&(Ii=null,this.accountList=[],this.loadChart(),this.loadAccounts())}),window.store.observe("autoConversion",()=>{Ei&&(this.loadChart(),this.loadAccounts())})}});let Wg=class{dashboard(t,e){let i=J(t,"y-MM-dd"),s=J(e,"y-MM-dd");return vt.get("/api/v2/chart/budget/dashboard",{params:{start:i,end:s}})}},Ue=[],Nn=null,te=null,zi=!1,Te;const Hg=()=>({loading:!1,autoConversion:!1,loadChart(){if(this.loading!==!0){if(this.loading=!0,te!==null){this.drawChart(this.generateOptions(te)),this.loading=!1;return}this.getFreshData()}},drawChart(n){if(Nn!==null){Nn.data.datasets=n.data.datasets,Nn.update();return}Nn=new mt(document.querySelector("#budget-chart"),n)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt("dashboard-budgets-chart",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){te=s,this.drawChart(this.generateOptions(te)),this.loading=!1;return}new Wg().dashboard(n,t,null).then(r=>{te=r.data,this.drawChart(this.generateOptions(te)),window.store.set(e,te),this.loading=!1})},generateOptions(n){Ue=[];let t=yi("column");t.options.locale=window.store.get("locale").replace("_","-"),t.options.plugins={tooltip:{callbacks:{title:function(e){return e.label},label:function(e){let i=e.dataset.label||"";return i&&(i+=": "),i+" "+V(e.parsed.y,Ue[e.parsed.x]??"EUR")}}}},t.data={labels:[],datasets:[{label:Te.t("firefly.spent"),data:[],borderWidth:1,stack:1,backgroundColor:De("spent","background"),borderColor:De("spent","border")},{label:Te.t("firefly.left"),data:[],borderWidth:1,stack:1,backgroundColor:De("left","background"),borderColor:De("left","border")},{label:Te.t("firefly.overspent"),data:[],borderWidth:1,stack:1,backgroundColor:De("overspent","background"),borderColor:De("overspent","border")}]};for(const e in n)if(n.hasOwnProperty(e)){let i=n[e],s=i.label+" ("+i.currency_code+")";t.data.labels.push(s),this.autoConversion&&(Ue.push(i.native_currency_code),t.data.datasets[0].data.push(parseFloat(i.native_entries.spent)*-1),t.data.datasets[1].data.push(parseFloat(i.native_entries.left)),t.data.datasets[2].data.push(parseFloat(i.native_entries.overspent))),this.autoConversion||(Ue.push(i.currency_code),t.data.datasets[0].data.push(parseFloat(i.entries.spent)*-1),t.data.datasets[1].data.push(parseFloat(i.entries.left)),t.data.datasets[2].data.push(parseFloat(i.entries.overspent)))}return t.options.scales={y:{ticks:{callback:function(e){return V(e,Ue[0]??"EUR")}}}},t},init(){Promise.all([bt("autoConversion",!1),bt("language","en_US")]).then(n=>{Te=new li;const t=n[1].replace("-","_");Te.locale=t,ci(Te,t).then(()=>{this.autoConversion=n[0],zi=!0,this.loading===!1&&this.loadChart()})}),window.store.observe("end",()=>{zi&&this.loading===!1&&(te=null,this.loadChart())}),window.store.observe("autoConversion",n=>{zi&&(this.autoConversion=n,this.loading===!1&&this.loadChart())})}});class Vg{dashboard(t,e){let i=J(t,"y-MM-dd"),s=J(e,"y-MM-dd");return vt.get("/api/v2/chart/category/dashboard",{params:{start:i,end:s}})}}let ur=[],$e=null,Se=null,Bi=!1;const Yg=()=>({loading:!1,autoConversion:!1,generateOptions(n){ur=[];let t=yi("column"),e={};for(const s in n)if(n.hasOwnProperty(s)){let o=n[s],r=o.currency_code;this.autoConversion&&(r=o.native_currency_code),e.hasOwnProperty(r)||(e[r]={name:r,yAxisID:"",data:{}},ur.push(r))}for(const s in n)if(n.hasOwnProperty(s)){let o=n[s],r=o.currency_code;this.autoConversion&&(r=o.native_currency_code);for(const a in e)if(e.hasOwnProperty(a)){let l=0;r===a&&(l=parseFloat(o.amount),""+o.currency_code,this.autoConversion&&(l=parseFloat(o.native_amount),""+o.native_currency_code)),e[a].data.hasOwnProperty(o.label)&&(e[a].data[o.label]=e[a].data[o.label]+l),e[a].data.hasOwnProperty(o.label)||(e[a].data[o.label]=l)}t.data.labels.includes(o.label)||t.data.labels.push(o.label)}let i=0;for(const s in e){let o="y"+s,r={label:s,currency_code:s,yAxisID:o,data:[]};for(const a in e[s].data)r.data.push(e[s].data[a]);t.data.datasets.push(r),t.options.scales.hasOwnProperty(o)||(t.options.scales[o]={beginAtZero:!0,type:"linear",position:i===1?"right":"left",ticks:{callback:function(a,l,c){return V(a,s)}}},i++)}return t},drawChart(n){if($e!==null){$e.options=n.options,$e.data=n.data,$e.update();return}$e=new mt(document.querySelector("#category-chart"),n)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt("dashboard-categories-chart",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){Se=s,this.drawChart(this.generateOptions(Se)),this.loading=!1;return}new Vg().dashboard(n,t,null).then(r=>{Se=r.data,this.drawChart(this.generateOptions(r.data)),window.store.set(e,Se),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,Se!==null){this.drawChart(this.generateOptions(Se)),this.loading=!1;return}this.getFreshData()}},init(){Promise.all([bt("autoConversion",!1)]).then(n=>{this.autoConversion=n[0],Bi=!0,this.loadChart()}),window.store.observe("end",()=>{Bi&&(this.chartData=null,this.loadChart())}),window.store.observe("autoConversion",n=>{Bi&&(this.autoConversion=n,this.loadChart())})}});let jg=class{get(t){return vt.get("/api/v2/transactions",{params:t})}};/*! +`):n}function rg(n,t){const{element:e,datasetIndex:i,index:s}=t,o=n.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:n,label:r,parsed:o.getParsed(s),raw:n.data.datasets[i].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:e}}function $o(n,t){const e=n.chart.ctx,{body:i,footer:s,title:o}=n,{boxWidth:r,boxHeight:a}=t,l=ut(t.bodyFont),c=ut(t.titleFont),u=ut(t.footerFont),h=o.length,d=s.length,f=i.length,g=yt(t.padding);let p=g.height,m=0,b=i.reduce((v,_)=>v+_.before.length+_.lines.length+_.after.length,0);if(b+=n.beforeBody.length+n.afterBody.length,h&&(p+=h*c.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),b){const v=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;p+=f*v+(b-f)*l.lineHeight+(b-1)*t.bodySpacing}d&&(p+=t.footerMarginTop+d*u.lineHeight+(d-1)*t.footerSpacing);let y=0;const x=function(v){m=Math.max(m,e.measureText(v).width+y)};return e.save(),e.font=c.string,$(n.title,x),e.font=l.string,$(n.beforeBody.concat(n.afterBody),x),y=t.displayColors?r+2+t.boxPadding:0,$(i,v=>{$(v.before,x),$(v.lines,x),$(v.after,x)}),y=0,e.font=u.string,$(n.footer,x),e.restore(),m+=g.width,{width:m,height:p}}function ag(n,t){const{y:e,height:i}=t;return en.height-i/2?"bottom":"center"}function lg(n,t,e,i){const{x:s,width:o}=i,r=e.caretSize+e.caretPadding;if(n==="left"&&s+o+r>t.width||n==="right"&&s-o-r<0)return!0}function cg(n,t,e,i){const{x:s,width:o}=e,{width:r,chartArea:{left:a,right:l}}=n;let c="center";return i==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),lg(c,n,t,e)&&(c="center"),c}function qo(n,t,e){const i=e.yAlign||t.yAlign||ag(n,e);return{xAlign:e.xAlign||t.xAlign||cg(n,t,e,i),yAlign:i}}function ug(n,t){let{x:e,width:i}=n;return t==="right"?e-=i:t==="center"&&(e-=i/2),e}function hg(n,t,e){let{y:i,height:s}=n;return t==="top"?i+=e:t==="bottom"?i-=s+e:i-=s/2,i}function Xo(n,t,e,i){const{caretSize:s,caretPadding:o,cornerRadius:r}=n,{xAlign:a,yAlign:l}=e,c=s+o,{topLeft:u,topRight:h,bottomLeft:d,bottomRight:f}=ve(r);let g=ug(t,a);const p=hg(t,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(u,d)+s:a==="right"&&(g+=Math.max(h,f)+s),{x:ft(g,0,i.width-t.width),y:ft(p,0,i.height-t.height)}}function En(n,t,e){const i=yt(e.padding);return t==="center"?n.x+n.width/2:t==="right"?n.x+n.width-i.right:n.x+i.left}function Ko(n){return Ft([],jt(n))}function dg(n,t,e){return he(n,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Go(n,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?n.override(e):n}const wa={beforeTitle:Wt,title(n){if(n.length>0){const t=n[0],e=t.chart.data.labels,i=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex"u"?wa[t].call(e,i):s}class is extends Lt{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,o=new ea(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=dg(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:i}=e,s=_t(i,"beforeTitle",this,t),o=_t(i,"title",this,t),r=_t(i,"afterTitle",this,t);let a=[];return a=Ft(a,jt(s)),a=Ft(a,jt(o)),a=Ft(a,jt(r)),a}getBeforeBody(t,e){return Ko(_t(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,s=[];return $(t,o=>{const r={before:[],lines:[],after:[]},a=Go(i,o);Ft(r.before,jt(_t(a,"beforeLabel",this,o))),Ft(r.lines,_t(a,"label",this,o)),Ft(r.after,jt(_t(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,e){return Ko(_t(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,s=_t(i,"beforeFooter",this,t),o=_t(i,"footer",this,t),r=_t(i,"afterFooter",this,t);let a=[];return a=Ft(a,jt(s)),a=Ft(a,jt(o)),a=Ft(a,jt(r)),a}_createItems(t){const e=this._active,i=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=e.length;lt.filter(u,h,d,i))),t.itemSort&&(a=a.sort((u,h)=>t.itemSort(u,h,i))),$(a,u=>{const h=Go(t.callbacks,u);s.push(_t(h,"labelColor",this,u)),o.push(_t(h,"labelPointStyle",this,u)),r.push(_t(h,"labelTextColor",this,u))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=Je[i.position].call(this,s,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const l=this._size=$o(this,i),c=Object.assign({},a,l),u=qo(this.chart,i,c),h=Xo(i,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,o={opacity:1,x:h.x,y:h.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const o=this.getCaretPosition(t,i,s);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=i,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:h}=ve(a),{x:d,y:f}=t,{width:g,height:p}=e;let m,b,y,x,v,_;return o==="center"?(v=f+p/2,s==="left"?(m=d,b=m-r,x=v+r,_=v-r):(m=d+g,b=m+r,x=v-r,_=v+r),y=m):(s==="left"?b=d+Math.max(l,u)+r:s==="right"?b=d+g-Math.max(c,h)-r:b=this.caretX,o==="top"?(x=f,v=x-r,m=b-r,y=b+r):(x=f+p,v=x+r,m=b+r,y=b-r),_=x),{x1:m,x2:b,x3:y,y1:x,y2:v,y3:_}}drawTitle(t,e,i){const s=this.title,o=s.length;let r,a,l;if(o){const c=Fe(i.rtl,this.x,this.width);for(t.x=En(this,i.titleAlign,i),e.textAlign=c.textAlign(i.titleAlign),e.textBaseline="middle",r=ut(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=r.string,l=0;ly!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,dn(t,{x:p,y:g,w:c,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),dn(t,{x:m,y:g+1,w:c-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(p,g,c,l),t.strokeRect(p,g,c,l),t.fillStyle=r.backgroundColor,t.fillRect(m,g+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=i,h=ut(i.bodyFont);let d=h.lineHeight,f=0;const g=Fe(i.rtl,this.x,this.width),p=function(M){e.fillText(M,g.x(t.x+f),t.y+d/2),t.y+=d+o},m=g.textAlign(r);let b,y,x,v,_,w,C;for(e.textAlign=r,e.textBaseline="middle",e.font=h.string,t.x=En(this,m,i),e.fillStyle=i.bodyColor,$(this.beforeBody,p),f=a&&m!=="right"?r==="center"?c/2+u:c+2+u:0,v=0,w=s.length;v0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const r=Je[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=$o(this,t),l=Object.assign({},r,this._size),c=qo(e,t,l),u=Xo(t,l,c,e);(s._to!==u.x||o._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const r=yt(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,e),Gr(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),Qr(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Zn(i,s),r=this._positionChanged(s,e);(o||r)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,i),a=this._positionChanged(r,t),l=e||!Zn(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,i,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return e;const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,e){const{caretX:i,caretY:s,options:o}=this,r=Je[o.position].call(this,t,e);return r!==!1&&(i!==r.x||s!==r.y)}}k(is,"positioners",Je);var fg={id:"tooltip",_element:is,positioners:Je,afterInit(n,t,e){e&&(n.tooltip=new is({chart:n,options:e}))},beforeUpdate(n,t,e){n.tooltip&&n.tooltip.initialize(e)},reset(n,t,e){n.tooltip&&n.tooltip.initialize(e)},afterDraw(n){const t=n.tooltip;if(t&&t._willRender()){const e={tooltip:t};if(n.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(n.ctx),n.notifyPlugins("afterTooltipDraw",e)}},afterEvent(n,t){if(n.tooltip){const e=t.replay;n.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.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:(n,t)=>t.bodyFont.size,boxWidth:(n,t)=>t.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:wa},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:n=>n!=="filter"&&n!=="itemSort"&&n!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const gg=(n,t,e,i)=>(typeof t=="string"?(e=n.push(t)-1,i.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function pg(n,t,e,i){const s=n.indexOf(t);if(s===-1)return gg(n,t,e,i);const o=n.lastIndexOf(t);return s!==o?e:s}const mg=(n,t)=>n===null?null:ft(Math.round(n),0,t);function Qo(n){const t=this.getLabels();return n>=0&&ne.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}k(ss,"id","category"),k(ss,"defaults",{ticks:{callback:Qo}});function bg(n,t){const e=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:u,maxDigits:h,includeBounds:d}=n,f=o||1,g=u-1,{min:p,max:m}=t,b=!H(r),y=!H(a),x=!H(c),v=(m-p)/(h+1);let _=$s((m-p)/g/f)*f,w,C,M,T;if(_<1e-14&&!b&&!y)return[{value:p},{value:m}];T=Math.ceil(m/_)-Math.floor(p/_),T>g&&(_=$s(T*_/g/f)*f),H(l)||(w=Math.pow(10,l),_=Math.ceil(_*w)/w),s==="ticks"?(C=Math.floor(p/_)*_,M=Math.ceil(m/_)*_):(C=p,M=m),b&&y&&o&&yu((a-r)/o,_/1e3)?(T=Math.round(Math.min((a-r)/_,u)),_=(a-r)/T,C=r,M=a):x?(C=b?r:C,M=y?a:M,T=c-1,_=(M-C)/T):(T=(M-C)/_,nn(T,Math.round(T),_/1e3)?T=Math.round(T):T=Math.ceil(T));const A=Math.max(qs(_),qs(C));w=Math.pow(10,H(l)?A:l),C=Math.round(C*w)/w,M=Math.round(M*w)/w;let O=0;for(b&&(d&&C!==r?(e.push({value:r}),Ca)break;e.push({value:R})}return y&&d&&M!==a?e.length&&nn(e[e.length-1].value,a,Zo(a,v,n))?e[e.length-1].value=a:e.push({value:a}):(!y||M===a)&&e.push({value:M}),e}function Zo(n,t,{horizontal:e,minRotation:i}){const s=At(i),o=(e?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+n).length;return Math.min(t/o,r)}class oi extends ke{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 H(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:o}=this;const r=l=>s=e?s:l,a=l=>o=i?o:l;if(t){const l=Bt(s),c=Bt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:i}=t,s;return i?(s=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,s>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${i} would result generating up to ${s} ticks. Limiting to 1000.`),s=1e3)):(s=this.computeTickLimit(),e=e||11),e&&(s=Math.min(e,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s={maxTicks:i,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:e.includeBounds!==!1},o=this._range||this,r=bg(s,o);return t.bounds==="ticks"&&Fr(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,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-e)/Math.max(t.length-1,1)/2;e-=s,i+=s}this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return _n(t,this.chart.options.locale,this.options.ticks.format)}}class os extends oi{determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=et(t)?t:0,this.max=et(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=At(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}k(os,"id","linear"),k(os,"defaults",{ticks:{callback:fi.formatters.numeric}});const gn=n=>Math.floor(ie(n)),pe=(n,t)=>Math.pow(10,gn(n)+t);function Jo(n){return n/Math.pow(10,gn(n))===1}function tr(n,t,e){const i=Math.pow(10,e),s=Math.floor(n/i);return Math.ceil(t/i)-s}function yg(n,t){const e=t-n;let i=gn(e);for(;tr(n,t,i)>10;)i++;for(;tr(n,t,i)<10;)i--;return Math.min(i,gn(n))}function _g(n,{min:t,max:e}){t=Pt(n.min,t);const i=[],s=gn(t);let o=yg(t,e),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((t-l)*r)/r,u=Math.floor((t-l)/a/10)*a*10;let h=Math.floor((c-u)/Math.pow(10,o)),d=Pt(n.min,Math.round((l+u+h*Math.pow(10,o))*r)/r);for(;d=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,r=o>=0?1:r),d=Math.round((l+u+h*Math.pow(10,o))*r)/r;const f=Pt(n.max,d);return i.push({value:f,major:Jo(f),significand:h}),i}class er extends ke{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const i=oi.prototype.parse.apply(this,[t,e]);if(i===0){this._zero=!0;return}return et(i)&&i>0?i:null}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=et(t)?Math.max(0,t):null,this.max=et(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!et(this._userMin)&&(this.min=t===pe(this.min,0)?pe(this.min,-1):pe(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const o=a=>i=t?i:a,r=a=>s=e?s:a;i===s&&(i<=0?(o(1),r(10)):(o(pe(i,-1)),r(pe(s,1)))),i<=0&&o(pe(s,-1)),s<=0&&r(pe(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e={min:this._userMin,max:this._userMax},i=_g(e,this);return t.bounds==="ticks"&&Fr(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}getLabelForValue(t){return t===void 0?"0":_n(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=ie(t),this._valueRange=ie(this.max)-ie(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(ie(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}k(er,"id","logarithmic"),k(er,"defaults",{ticks:{callback:fi.formatters.logarithmic,major:{enabled:!0}}});function rs(n){const t=n.ticks;if(t.display&&n.display){const e=yt(t.backdropPadding);return S(t.font&&t.font.size,nt.font.size)+e.height}return 0}function xg(n,t,e){return e=K(e)?e:[e],{w:zu(n,t.string,e),h:e.length*t.lineHeight}}function nr(n,t,e,i,s){return n===i||n===s?{start:t-e/2,end:t+e/2}:ns?{start:t-e,end:t}:{start:t,end:t+e}}function vg(n){const t={l:n.left+n._padding.left,r:n.right-n._padding.right,t:n.top+n._padding.top,b:n.bottom-n._padding.bottom},e=Object.assign({},t),i=[],s=[],o=n._pointLabels.length,r=n.options.pointLabels,a=r.centerPointLabels?tt/o:0;for(let l=0;lt.r&&(a=(i.end-t.r)/o,n.r=Math.max(n.r,t.r+a)),s.startt.b&&(l=(s.end-t.b)/r,n.b=Math.max(n.b,t.b+l))}function Mg(n,t,e){const i=n.drawingArea,{extra:s,additionalAngle:o,padding:r,size:a}=e,l=n.getPointPosition(t,i+s+r,o),c=Math.round(ps(Dt(l.angle+at))),u=Tg(l.y,a.h,c),h=Pg(c),d=Dg(l.x,a.w,h);return{visible:!0,x:l.x,y:u,textAlign:h,left:d,top:u,right:d+a.w,bottom:u+a.h}}function kg(n,t){if(!t)return!0;const{left:e,top:i,right:s,bottom:o}=n;return!(qt({x:e,y:i},t)||qt({x:e,y:o},t)||qt({x:s,y:i},t)||qt({x:s,y:o},t))}function Cg(n,t,e){const i=[],s=n._pointLabels.length,o=n.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:rs(o)/2,additionalAngle:r?tt/s:0};let c;for(let u=0;u270||e<90)&&(n-=t),n}function Sg(n,t,e){const{left:i,top:s,right:o,bottom:r}=e,{backdropColor:a}=t;if(!H(a)){const l=ve(t.borderRadius),c=yt(t.backdropPadding);n.fillStyle=a;const u=i-c.left,h=s-c.top,d=o-i+c.width,f=r-s+c.height;Object.values(l).some(g=>g!==0)?(n.beginPath(),dn(n,{x:u,y:h,w:d,h:f,radius:l}),n.fill()):n.fillRect(u,h,d,f)}}function Og(n,t){const{ctx:e,options:{pointLabels:i}}=n;for(let s=t-1;s>=0;s--){const o=n._pointLabelItems[s];if(!o.visible)continue;const r=i.setContext(n.getPointLabelContext(s));Sg(e,r,o);const a=ut(r.font),{x:l,y:c,textAlign:u}=o;Ie(e,n._pointLabels[s],l,c+a.lineHeight/2,a,{color:r.color,textAlign:u,textBaseline:"middle"})}}function Ma(n,t,e,i){const{ctx:s}=n;if(e)s.arc(n.xCenter,n.yCenter,t,0,G);else{let o=n.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let r=1;r{const s=X(this.options.pointLabels.callback,[e,i],this);return s||s===0?s:""}).filter((e,i)=>this.chart.getDataVisibility(i))}fit(){const t=this.options;t.display&&t.pointLabels.display?vg(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,s))}getIndexAngle(t){const e=G/(this._pointLabels.length||1),i=this.options.startAngle||0;return Dt(t*e+At(i))}getDistanceFromCenterForValue(t){if(H(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(H(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t{if(h!==0){l=this.getDistanceFromCenterForValue(u.value);const d=this.getContext(h),f=s.setContext(d),g=o.setContext(d);Ag(this,f,l,r,g)}}),i.display){for(t.save(),a=r-1;a>=0;a--){const u=i.setContext(this.getPointLabelContext(a)),{color:h,lineWidth:d}=u;!d||!h||(t.lineWidth=d,t.strokeStyle=h,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,l=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&!e.reverse)return;const c=i.setContext(this.getContext(l)),u=ut(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=u.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const h=yt(c.backdropPadding);t.fillRect(-r/2-h.left,-o-u.size/2-h.top,r+h.width,u.size+h.height)}Ie(t,a.label,0,-o,u,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}k(zn,"id","radialLinear"),k(zn,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:fi.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),k(zn,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),k(zn,"descriptors",{angleLines:{_fallback:"grid"}});const bi={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},xt=Object.keys(bi);function ir(n,t){return n-t}function sr(n,t){if(H(t))return null;const e=n._adapter,{parser:i,round:s,isoWeekday:o}=n._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),et(r)||(r=typeof i=="string"?e.parse(r,i):e.parse(r)),r===null?null:(s&&(r=s==="week"&&(un(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,s)),+r)}function or(n,t,e,i){const s=xt.length;for(let o=xt.indexOf(n);o=xt.indexOf(e);o--){const r=xt[o];if(bi[r].common&&n._adapter.diff(s,i,r)>=t-1)return r}return xt[e?xt.indexOf(e):0]}function Fg(n){for(let t=xt.indexOf(n)+1,e=xt.length;t=t?e[i]:e[s];n[o]=!0}}function Ig(n,t,e,i){const s=n._adapter,o=+s.startOf(t[0].value,i),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,i))l=e[a],l>=0&&(t[l].major=!0);return t}function ar(n,t,e){const i=[],s={},o=t.length;let r,a;for(r=0;r+t.value))}initOffsets(t=[]){let e=0,i=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?e=1-s:e=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;e=ft(e,0,r),i=ft(i,0,r),this._offsets={start:e,end:i,factor:1/(e+1+i)}}_generate(){const t=this._adapter,e=this.min,i=this.max,s=this.options,o=s.time,r=o.unit||or(o.minUnit,e,i,this._getLabelCapacity(e)),a=S(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=un(l)||l===!0,u={};let h=e,d,f;if(c&&(h=+t.startOf(h,"isoWeek",l)),h=+t.startOf(h,c?"day":r),t.diff(i,e,r)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+r);const g=s.ticks.source==="data"&&this.getDataTimestamps();for(d=h,f=0;d+p)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const s=this.options.time.displayFormats,o=this._unit,r=e||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,i,s){const o=this.options,r=o.ticks.callback;if(r)return X(r,[t,e,i],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],h=c&&a[c],d=i[e],f=c&&h&&d&&d.major;return this._adapter.format(t,s||(f?h:u))}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,i;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(e=0,i=s.length;e=n[i].pos&&t<=n[s].pos&&({lo:i,hi:s}=xe(n,"pos",t)),{pos:o,time:a}=n[i],{pos:r,time:l}=n[s]):(t>=n[i].time&&t<=n[s].time&&({lo:i,hi:s}=xe(n,"time",t)),{time:o,pos:a}=n[i],{time:r,pos:l}=n[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class lr extends pn{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=Bn(e,this.min),this._tableRange=Bn(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],o=[];let r,a,l,c,u;for(r=0,a=t.length;r=e&&c<=i&&s.push(c);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(r=0,a=s.length;rs-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return e.length&&i.length?t=this.normalize(e.concat(i)):t=e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(Bn(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return Bn(this._table,i*this._tableRange+this._minPos,!0)}}k(lr,"id","timeseries"),k(lr,"defaults",pn.defaults);function yi(n){return n==="sankey"?{type:"sankey",data:{datasets:[]},options:{animations:!1}}:n==="pie"?{type:"pie",data:{datasets:[]}}:n==="column"?{type:"bar",data:{labels:[],datasets:[]},options:{plugins:{tooltip:{callbacks:{label:function(t){let e=t.dataset.currency_code;return V(t.raw,e)}}}},maintainAspectRatio:!1,scales:{}}}:n==="line"?{options:{plugins:{tooltip:{callbacks:{label:function(t){let e=t.dataset.currency_code;return V(t.raw,e)}}}},maintainAspectRatio:!1,scales:{x:{type:"time",time:{tooltipFormat:"PP"}}}},type:"line",data:{labels:[],datasets:[]}}:{}}let ri=new dt("#36a2eb"),Re=new dt("#ff6384"),mn=new dt("#4bc0c0"),ka=new dt("#ff9f40"),Eg=new dt("#9966ff"),zg=new dt("#ffcd56"),Bg=new dt("#c9cbcf"),cr=0;window.theme==="dark"&&(Re.darken(.3).desaturate(.3),mn.darken(.3).desaturate(.3),ri.darken(.3).desaturate(.3),ka.darken(.3).desaturate(.3));let Fi=[Re,ka,ri,mn,Eg,zg,Bg,mn];function De(n,t){let e={borderColor:Re.rgbString(),backgroundColor:Re.rgbString()},i;switch(n){default:let o=Math.floor(cr/2)%Fi.length;i=new dt(Fi[o].rgbString()),i.lighten(.38),e={borderColor:Fi[o].hexString(),backgroundColor:i.hexString()};break;case"spent":i=new dt(ri.rgbString()),i.lighten(.38),e={borderColor:ri.rgbString(),backgroundColor:i.rgbString()};break;case"left":i=new dt(mn.rgbString()),i.lighten(.38),e={borderColor:mn.rgbString(),backgroundColor:i.rgbString()};break;case"overspent":i=new dt(Re.rgbString()),i.lighten(.22),e={borderColor:Re.rgbString(),backgroundColor:i.rgbString()};break}return cr++,t==="border"?e.borderColor:t==="background"?e.backgroundColor:"#FF0000"}let me=[],je=null,Ii=null,Ei=!1;const Ng=()=>({loading:!1,loadingAccounts:!1,accountList:[],autoConversion:!1,chartOptions:null,switchAutoConversion(){this.autoConversion=!this.autoConversion,Bc("autoConversion",this.autoConversion)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt("dashboard-accounts-chart",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){console.log(s),this.drawChart(this.generateOptions(s)),this.loading=!1;return}new Nc().dashboard(n,t,null).then(r=>{this.chartData=r.data,window.store.set(e,r.data),console.log(r.data),this.drawChart(this.generateOptions(this.chartData)),this.loading=!1})},generateOptions(n){me=[];let t=yi("line");for(let e=0;e0){this.loadingAccounts=!1;return}const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt("dashboard-accounts-data",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){this.accountList=s,this.loadingAccounts=!1;return}const o=10;let r=0,a=0,l=[];Promise.all([bt("frontpageAccounts")]).then(c=>{r=c[0].length;for(let u in c[0]){let h=c[0];if(h.hasOwnProperty(u)){let d=h[u];new Bs().get(d,new Date(window.store.get("end"))).then(f=>{let g=f.data.data;const p={page:1,start:new Date(window.store.get("start")),end:new Date(window.store.get("end"))};new Bs().transactions(g.id,p).then(m=>{let b=[];for(let y=0;y=o);y++){let x=m.data.data[y],v={title:x.attributes.group_title===null?"":x.attributes.group_title,id:x.id,transactions:[]};for(let _=0;_y.order-x.order),this.accountList=l,this.loadingAccounts=!1,window.store.set(e,l))})})}}})},init(){Promise.all([bt("viewRange","1M"),bt("autoConversion",!1),bt("language","en_US")]).then(n=>{this.autoConversion=n[1],Ei=!0,this.loadChart(),this.loadAccounts()}),window.store.observe("end",()=>{Ei&&(Ii=null,this.accountList=[],this.loadChart(),this.loadAccounts())}),window.store.observe("autoConversion",()=>{Ei&&(this.loadChart(),this.loadAccounts())})}});let Wg=class{dashboard(t,e){let i=J(t,"y-MM-dd"),s=J(e,"y-MM-dd");return vt.get("/api/v2/chart/budget/dashboard",{params:{start:i,end:s}})}},Ue=[],Nn=null,te=null,zi=!1,Te;const Hg=()=>({loading:!1,autoConversion:!1,loadChart(){if(this.loading!==!0){if(this.loading=!0,te!==null){this.drawChart(this.generateOptions(te)),this.loading=!1;return}this.getFreshData()}},drawChart(n){if(Nn!==null){Nn.data.datasets=n.data.datasets,Nn.update();return}Nn=new mt(document.querySelector("#budget-chart"),n)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt("dashboard-budgets-chart",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){te=s,this.drawChart(this.generateOptions(te)),this.loading=!1;return}new Wg().dashboard(n,t,null).then(r=>{te=r.data,this.drawChart(this.generateOptions(te)),window.store.set(e,te),this.loading=!1})},generateOptions(n){Ue=[];let t=yi("column");t.options.locale=window.store.get("locale").replace("_","-"),t.options.plugins={tooltip:{callbacks:{title:function(e){return e.label},label:function(e){let i=e.dataset.label||"";return i&&(i+=": "),i+" "+V(e.parsed.y,Ue[e.parsed.x]??"EUR")}}}},t.data={labels:[],datasets:[{label:Te.t("firefly.spent"),data:[],borderWidth:1,stack:1,backgroundColor:De("spent","background"),borderColor:De("spent","border")},{label:Te.t("firefly.left"),data:[],borderWidth:1,stack:1,backgroundColor:De("left","background"),borderColor:De("left","border")},{label:Te.t("firefly.overspent"),data:[],borderWidth:1,stack:1,backgroundColor:De("overspent","background"),borderColor:De("overspent","border")}]};for(const e in n)if(n.hasOwnProperty(e)){let i=n[e],s=i.label+" ("+i.currency_code+")";t.data.labels.push(s),this.autoConversion&&(Ue.push(i.native_currency_code),t.data.datasets[0].data.push(parseFloat(i.native_entries.spent)*-1),t.data.datasets[1].data.push(parseFloat(i.native_entries.left)),t.data.datasets[2].data.push(parseFloat(i.native_entries.overspent))),this.autoConversion||(Ue.push(i.currency_code),t.data.datasets[0].data.push(parseFloat(i.entries.spent)*-1),t.data.datasets[1].data.push(parseFloat(i.entries.left)),t.data.datasets[2].data.push(parseFloat(i.entries.overspent)))}return t.options.scales={y:{ticks:{callback:function(e){return V(e,Ue[0]??"EUR")}}}},t},init(){Promise.all([bt("autoConversion",!1),bt("language","en_US")]).then(n=>{Te=new li;const t=n[1].replace("-","_");Te.locale=t,ci(Te,t).then(()=>{this.autoConversion=n[0],zi=!0,this.loading===!1&&this.loadChart()})}),window.store.observe("end",()=>{zi&&this.loading===!1&&(te=null,this.loadChart())}),window.store.observe("autoConversion",n=>{zi&&(this.autoConversion=n,this.loading===!1&&this.loadChart())})}});class Vg{dashboard(t,e){let i=J(t,"y-MM-dd"),s=J(e,"y-MM-dd");return vt.get("/api/v2/chart/category/dashboard",{params:{start:i,end:s}})}}let ur=[],$e=null,Se=null,Bi=!1;const Yg=()=>({loading:!1,autoConversion:!1,generateOptions(n){ur=[];let t=yi("column"),e={};for(const s in n)if(n.hasOwnProperty(s)){let o=n[s],r=o.currency_code;this.autoConversion&&(r=o.native_currency_code),e.hasOwnProperty(r)||(e[r]={name:r,yAxisID:"",data:{}},ur.push(r))}for(const s in n)if(n.hasOwnProperty(s)){let o=n[s],r=o.currency_code;this.autoConversion&&(r=o.native_currency_code);for(const a in e)if(e.hasOwnProperty(a)){let l=0;r===a&&(l=parseFloat(o.amount),""+o.currency_code,this.autoConversion&&(l=parseFloat(o.native_amount),""+o.native_currency_code)),e[a].data.hasOwnProperty(o.label)&&(e[a].data[o.label]=e[a].data[o.label]+l),e[a].data.hasOwnProperty(o.label)||(e[a].data[o.label]=l)}t.data.labels.includes(o.label)||t.data.labels.push(o.label)}let i=0;for(const s in e){let o="y"+s,r={label:s,currency_code:s,yAxisID:o,data:[]};for(const a in e[s].data)r.data.push(e[s].data[a]);t.data.datasets.push(r),t.options.scales.hasOwnProperty(o)||(t.options.scales[o]={beginAtZero:!0,type:"linear",position:i===1?"right":"left",ticks:{callback:function(a,l,c){return V(a,s)}}},i++)}return t},drawChart(n){if($e!==null){$e.options=n.options,$e.data=n.data,$e.update();return}$e=new mt(document.querySelector("#category-chart"),n)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt("dashboard-categories-chart",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){Se=s,this.drawChart(this.generateOptions(Se)),this.loading=!1;return}new Vg().dashboard(n,t,null).then(r=>{Se=r.data,this.drawChart(this.generateOptions(r.data)),window.store.set(e,Se),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,Se!==null){this.drawChart(this.generateOptions(Se)),this.loading=!1;return}this.getFreshData()}},init(){Promise.all([bt("autoConversion",!1)]).then(n=>{this.autoConversion=n[0],Bi=!0,this.loadChart()}),window.store.observe("end",()=>{Bi&&(this.chartData=null,this.loadChart())}),window.store.observe("autoConversion",n=>{Bi&&(this.autoConversion=n,this.loadChart())})}});let jg=class{list(t){return vt.get("/api/v2/transactions",{params:t})}};/*! * chartjs-chart-sankey v0.12.0 * https://github.com/kurkle/chartjs-chart-sankey#readme * (c) 2022 Jukka Kurkela * Released under the MIT license */function Ug(n){const t=[],e=K(n)?n:H(n)?[]:[n];for(;e.length;){const i=e.pop();typeof i=="string"?t.unshift.apply(t,i.split(` -`)):Array.isArray(i)?e.push.apply(e,i):H(e)||t.unshift(""+i)}return t}function Ni(n){return!n||["min","max"].indexOf(n)===-1?"max":n}const ae=n=>n!==void 0;function $g(n,t){const e=new Set(t.map(r=>r.to)),i=new Set(t.map(r=>r.from)),s=new Set([...n.keys()]);let o=0;for(;s.size;){const r=qg([...s],e);for(const a of r){const l=n.get(a);ae(l.x)||(l.x=o),s.delete(a)}s.size&&(e.clear(),t.filter(a=>s.has(a.from)).forEach(a=>e.add(a.to)),o++)}return[...n.keys()].filter(r=>!i.has(r)).forEach(r=>{const a=n.get(r);a.column||(a.x=o)}),o}function qg(n,t){const e=n.filter(i=>!t.has(i));return e.length?e:n.slice(0,1)}const Xg=(n,t)=>n.x!==t.x?n.x-t.x:n.y-t.y;let Wn=-1;function Kg(){return Wn=Wn<100?Wn+1:0,Wn}function as(n,t,e=Kg()){let i=0;for(const s of n)s.node._visited!==e&&(s.node._visited=e,i+=s.node[t].length+as(s.node[t],t,e));return i}const Ca=n=>(t,e)=>as(t.node[n],n)-as(e.node[n],n)||t.node[n].length-e.node[n].length;function Cs(n,t){n.from.sort(Ca("from"));for(const e of n.from){const i=e.node;ae(i.y)||(i.y=t,Cs(i,t)),t=Math.max(i.y+i.out,t)}return t}function _e(n,t){n.to.sort(Ca("to"));for(const e of n.to){const i=e.node;ae(i.y)||(i.y=t,_e(i,t)),t=Math.max(i.y+i.in,t)}return t}function qe(n,t){return ae(n.y)?n.y:(n.y=t,t)}function Gg(n,t){const e=n.filter(u=>u.x===0),i=n.filter(u=>u.x===t),s=e.filter(u=>!ae(u.y)),o=i.filter(u=>!ae(u.y)),r=n.filter(u=>u.x>0&&u.xMath.max(u,h.y+h.out||0),0),l=i.reduce((u,h)=>Math.max(u,h.y+h.in||0),0),c=0;return a>=l?(s.forEach(u=>{a=qe(u,a),a=Math.max(a+u.out,_e(u,a))}),o.forEach(u=>{l=qe(u,l),l=Math.max(l+u.in,_e(u,l))})):(o.forEach(u=>{l=qe(u,l),l=Math.max(l+u.in,_e(u,l))}),s.forEach(u=>{a=qe(u,a),a=Math.max(a+u.out,_e(u,a))})),r.forEach(u=>{let h=n.filter(d=>d.x===u.x&&ae(d.y)).reduce((d,f)=>Math.max(d,f.y+Math.max(f.in,f.out)),0);h=qe(u,h),h=Math.max(h+u.in,Cs(u,h)),h=Math.max(h+u.out,_e(u,h)),c=Math.max(c,h)}),Math.max(a,l,c)}function Qg(n,t){n.sort((r,a)=>Math.max(a.in,a.out)-Math.max(r.in,r.out));const e=n[0];e.y=0;const i=Cs(e,0),s=_e(e,0),o=Gg(n,t);return Math.max(i,s,o)}function Zg(n,t){let e=0,i=0;for(let s=0;s<=t;s++){let o=i;const r=n.filter(a=>a.x===s).sort((a,l)=>a.priority-l.priority);i=r[0].to.filter(a=>a.node.x>s+1).reduce((a,l)=>a+l.flow,0)||0;for(const a of r)a.y=o,o+=Math.max(a.out,a.in);e=Math.max(o,e)}return e}function Jg(n,t){let e=1,i=0,s=0,o=0;const r=[];n.sort(Xg);for(const a of n){if(a.y){if(a.x===0)r.push(a.y);else{for(i!==a.x&&(i=a.x,s=0),e=s+1;ea.y);e++);s=e}a.y+=e*t,e++}o=Math.max(o,a.y+Math.max(a.in,a.out))}return o}function tp(n,t){n.forEach(e=>{const i=Math[t](e.in||e.out,e.out||e.in),s=il.node.y+l.node.out/2-(c.node.y+c.node.out/2)).forEach((l,c)=>{s?l.addY=c*(i-l.flow)/(a-1):(l.addY=r,r+=l.flow)}),r=0,a=e.to.length,e.to.sort((l,c)=>l.node.y+l.node.in/2-(c.node.y+c.node.in/2)).forEach((l,c)=>{o?l.addY=c*(i-l.flow)/(a-1):(l.addY=r,r+=l.flow)})})}function ep(n,t,e,i){const s=[...n.values()],o=$g(n,t),a=(e?Zg(s,o):Qg(s,o))*.03,l=Jg(s,a);return tp(s,i),{maxX:o,maxY:l}}function np(n){const t=new Map;for(let i=0;is.flow-i.flow;return[...t.values()].forEach(i=>{i.from=i.from.sort(e),i.from.forEach(s=>{s.node=t.get(s.key)}),i.to=i.to.sort(e),i.to.forEach(s=>{s.node=t.get(s.key)})}),t}function hr(n,t,e){for(const i of n)if(i.key===t&&i.index===e)return i.addY;return 0}class _i extends Xt{parseObjectData(t,e,i,s){const{from:o="from",to:r="to",flow:a="flow"}=this.options.parsing,l=e.map(({[o]:y,[r]:x,[a]:v})=>({from:y,to:x,flow:v})),{xScale:c,yScale:u}=t,h=[],d=this._nodes=np(l),{column:f,priority:g,size:p}=this.getDataset();if(g)for(const y of d.values())y.key in g&&(y.priority=g[y.key]);if(f)for(const y of d.values())y.key in f&&(y.column=!0,y.x=f[y.key]);const{maxX:m,maxY:b}=ep(d,l,!!g,Ni(p));this._maxX=m,this._maxY=b;for(let y=0,x=l.length;y1){const d=c-u*l/2+h;for(let f=0;fn.type==="data"?(n.parsed._custom.x-n.parsed.x)*200:void 0,delay:n=>n.type==="data"?n.parsed.x*500+n.dataIndex*20:void 0},colors:{type:"color",properties:["colorFrom","colorTo"]}},transitions:{hide:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],to:"transparent"}}},show:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],from:"transparent"}}}}};_i.overrides={interaction:{mode:"nearest",intersect:!0},datasets:{clip:!1,parsing:!0},plugins:{tooltip:{callbacks:{title(){return""},label(n){const t=n.dataset.data[n.dataIndex];return t.from+" -> "+t.to+": "+t.flow}}},legend:{display:!1}},scales:{x:{type:"linear",bounds:"data",display:!1,min:0,offset:!1},y:{type:"linear",bounds:"data",display:!1,min:0,reverse:!0,offset:!1}},layout:{padding:{top:3,left:3,right:13,bottom:3}}};const dr=(n,t,e,i)=>n({x:n.x+e*(t.x-n.x),y:n.y+e*(t.y-n.y)});function ip(n,{x:t,x2:e,options:i}){let s;i.colorMode==="from"?s=Ae(i.colorFrom).alpha(.5).rgbString():i.colorMode==="to"?s=Ae(i.colorTo).alpha(.5).rgbString():(s=n.createLinearGradient(t,0,e,0),s.addColorStop(0,Ae(i.colorFrom).alpha(.5).rgbString()),s.addColorStop(1,Ae(i.colorTo).alpha(.5).rgbString())),n.fillStyle=s,n.strokeStyle=s,n.lineWidth=.5}class Ps extends Lt{constructor(t){super(),this.options=void 0,this.x=void 0,this.y=void 0,this.x2=void 0,this.y2=void 0,this.height=void 0,t&&Object.assign(this,t)}draw(t){const e=this,{x:i,x2:s,y:o,y2:r,height:a,progress:l}=e,{cp1:c,cp2:u}=dr(i,o,s,r);l!==0&&(t.save(),l<1&&(t.beginPath(),t.rect(i,Math.min(o,r),(s-i)*l+1,Math.abs(r-o)+a+1),t.clip()),ip(t,e),t.beginPath(),t.moveTo(i,o),t.bezierCurveTo(c.x,c.y,u.x,u.y,s,r),t.lineTo(s,r+a),t.bezierCurveTo(u.x,u.y+a,c.x,c.y+a,i,o+a),t.lineTo(i,o),t.stroke(),t.closePath(),t.fill(),t.restore())}inRange(t,e,i){const{x:s,y:o,x2:r,y2:a,height:l}=this.getProps(["x","y","x2","y2","height"],i);if(tr)return!1;const{cp1:c,cp2:u}=dr(s,o,r,a),h=(t-s)/(r-s),d={x:s,y:o},f={x:r,y:a},g=Oe(d,c,h),p=Oe(c,u,h),m=Oe(u,f,h),b=Oe(g,p,h),y=Oe(p,m,h),x=Oe(b,y,h).y;return e>=x&&e<=x+l}inXRange(t,e){const{x:i,x2:s}=this.getProps(["x","x2"],e);return t>=i&&t<=s}inYRange(t,e){const{y:i,y2:s,height:o}=this.getProps(["y","y2","height"],e),r=Math.min(i,s),a=Math.max(i,s)+o;return t>=r&&t<=a}getCenterPoint(t){const{x:e,y:i,x2:s,y2:o,height:r}=this.getProps(["x","y","x2","y2","height"],t);return{x:(e+s)/2,y:(i+o+r)/2}}tooltipPosition(t){return this.getCenterPoint(t)}getRange(t){return t==="x"?this.width/2:this.height/2}}Ps.id="flow";Ps.defaults={colorFrom:"red",colorTo:"green",colorMode:"gradient",hoverColorFrom:(n,t)=>on(t.colorFrom),hoverColorTo:(n,t)=>on(t.colorTo)};mt.register({SankeyController:_i,Flow:Ps});const fr="dashboard-sankey-data";let pt,Wi=!1,Hn=null,Ht=[],ht=!1,L={category:null,unknown_category:null,in:null,out:null,unknown_source:null,unknown_dest:null,unknown_account:null,expense_account:null,revenue_account:null,budget:null,unknown_budget:null,all_money:null};const gr=function(n){return n.includes(L.revenue_account)?"forestgreen":n.includes("("+L.in+",")?"green":n.includes(L.budget)||n.includes(L.unknown_budget)?"Orchid":n.includes("("+L.out+",")?"MediumOrchid":n.includes(L.all_money)?"blue":"red"};function Xe(n,t,e,i){if(n==="category"&&t!==null&&e==="in")return L.category+' "'+t+'" ('+L.in+(ht?", "+i+")":")");if(n==="category"&&t===null&&e==="in")return L.unknown_category+" ("+L.in+(ht?", "+i+")":")");if(n==="category"&&t!==null&&e==="out")return L.category+' "'+t+'" ('+L.out+(ht?", "+i+")":")");if(n==="category"&&t===null&&e==="out")return L.unknown_category+" ("+L.out+(ht?", "+i+")":")");if(n==="account"&&t===null&&e==="in")return L.unknown_source+(ht?" ("+i+")":"");if(n==="account"&&t!==null&&e==="in")return L.revenue_account+'"'+t+'"'+(ht?" ("+i+")":"");if(n==="account"&&t===null&&e==="out")return L.unknown_dest+(ht?" ("+i+")":"");if(n==="account"&&t!==null&&e==="out")return L.expense_account+' "'+t+'"'+(ht?" ("+i+")":"");if(n==="budget"&&t!==null)return L.budget+' "'+t+'"'+(ht?" ("+i+")":"");if(n==="budget"&&t===null)return L.unknown_budget+(ht?" ("+i+")":"");console.error('Cannot handle: type:"'+n+'", dir: "'+e+'"')}function Ke(n,t,e){if(n==="category"&&t!==null)return L.category+' "'+t+'"'+(ht?" ("+e+")":"");if(n==="category"&&t===null)return L.unknown_category+(ht?" ("+e+")":"");if(n==="account"&&t===null)return L.unknown_account+(ht?" ("+e+")":"");if(n==="account"&&t!==null)return t+(ht?" ("+e+")":"");if(n==="budget"&&t!==null)return L.budget+' "'+t+'"'+(ht?" ("+e+")":"");if(n==="budget"&&t===null)return L.unknown_budget+(ht?" ("+e+")":"");console.error('Cannot handle: type:"'+n+'"')}const sp=()=>({loading:!1,autoConversion:!1,generateOptions(){let n=yi("sankey"),t={},e={};for(let s in Ht)if(Ht.hasOwnProperty(s)){let o=Ht[s];for(let r in o.attributes.transactions)if(o.attributes.transactions.hasOwnProperty(r)){let a=o.attributes.transactions[r],l=this.autoConversion?a.native_currency_code:a.currency_code,c=this.autoConversion?parseFloat(a.native_amount):parseFloat(a.amount),u;if(a.type==="deposit"){let h=Xe("category",a.category_name,"in",l),d=Xe("account",a.source_name,"in",l);e[h]=Ke("category",a.category_name,l),e[d]=Ke("account",a.source_name,l),u=d+"-"+h+"-"+l,t.hasOwnProperty(u)||(t[u]={from:d,to:h,amount:0}),t[u].amount+=c,u=h+"-"+L.all_money+"-"+l,t.hasOwnProperty(u)||(t[u]={from:h,to:L.all_money+(this.autoConversion?" ("+l+")":""),amount:0}),t[u].amount+=c}if(a.type==="withdrawal"){let h=Xe("budget",a.budget_name,"out",l);e[h]=Ke("budget",a.budget_name,l),u=L.all_money+"-"+h+"-"+l,t.hasOwnProperty(u)||(t[u]={from:L.all_money+(this.autoConversion?" ("+l+")":""),to:h,amount:0}),t[u].amount+=c;let d=Xe("category",a.category_name,"out",l);e[d]=Ke("category",a.category_name,l),u=h+"-"+d+"-"+l,t.hasOwnProperty(u)||(t[u]={from:h,to:d,amount:0}),t[u].amount+=c;let f=Xe("account",a.destination_name,"out",l);e[f]=Ke("account",a.destination_name,l),u=d+"-"+f+"-"+l,t.hasOwnProperty(u)||(t[u]={from:d,to:f,amount:0}),t[u].amount+=c}}}let i={label:"Firefly III dashboard sankey chart",data:[],colorFrom:s=>gr(s.dataset.data[s.dataIndex]?s.dataset.data[s.dataIndex].from:""),colorTo:s=>gr(s.dataset.data[s.dataIndex]?s.dataset.data[s.dataIndex].to:""),colorMode:"gradient",labels:e,size:"min"};for(let s in t)if(t.hasOwnProperty(s)){let o=t[s];i.data.push({from:o.from,to:o.to,flow:o.amount})}return n.data.datasets.push(i),n},drawChart(n){if(Hn!==null){Hn.data.datasets=n.data.datasets,Hn.update();return}Hn=new mt(document.querySelector("#sankey-chart"),n)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt(fr,n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){Ht=s,this.drawChart(this.generateOptions()),this.loading=!1;return}let o={start:J(n,"y-MM-dd"),end:J(t,"y-MM-dd"),type:"withdrawal,deposit",page:1};this.downloadTransactions(o)},downloadTransactions(n){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),i=Nt(fr,t,e);new jg().get(n).then(o=>{if(Ht=[...Ht,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>n.page){n.page++,this.downloadTransactions(n);return}window.store.set(i,Ht),this.drawChart(this.generateOptions()),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,Ht.length!==0){this.drawChart(this.generateOptions()),this.loading=!1;return}this.getFreshData()}},init(){Ht=[],Promise.all([bt("autoConversion",!1),bt("language","en_US")]).then(n=>{this.autoConversion=n[0],ht=n[0],pt=new li;const t=n[1].replace("-","_");pt.locale=t,ci(pt,t).then(()=>{L.all_money=pt.t("firefly.all_money"),L.category=pt.t("firefly.category"),L.in=pt.t("firefly.money_flowing_in"),L.out=pt.t("firefly.money_flowing_out"),L.unknown_category=pt.t("firefly.unknown_category_plain"),L.unknown_source=pt.t("firefly.unknown_source_plain"),L.unknown_dest=pt.t("firefly.unknown_dest_plain"),L.unknown_account=pt.t("firefly.unknown_any_plain"),L.unknown_budget=pt.t("firefly.unknown_budget_plain"),L.expense_account=pt.t("firefly.expense_account"),L.revenue_account=pt.t("firefly.revenue_account"),L.budget=pt.t("firefly.budget"),Wi=!0,this.loadChart()})}),window.store.observe("end",()=>{Wi&&(this.transactions=[],this.loadChart())}),window.store.observe("autoConversion",n=>{Wi&&(this.autoConversion=n,this.loadChart())})}});let op=class{get(t){return vt.get("/api/v2/subscriptions",{params:t})}paid(t){return vt.get("/api/v2/subscriptions/sum/paid",{params:t})}unpaid(t){return vt.get("/api/v2/subscriptions/sum/unpaid",{params:t})}},Hi=!1,ee,Ct={};function Pa(n){return new op().get(n).then(e=>{let i=e.data.data;for(let s in i)if(i.hasOwnProperty(s)){let o=i[s];if(o.attributes.active&&o.attributes.pay_dates.length>0){let r=o.attributes.object_group_id===null?0:o.attributes.object_group_id,a=o.attributes.object_group_title===null?ee.t("firefly.default_group_title_name_plain"):o.attributes.object_group_title,l=o.attributes.object_group_order===null?0:o.attributes.object_group_order;Ct.hasOwnProperty(r)||(Ct[r]={id:r,title:a,order:l,payment_info:{},bills:[]});let c={id:o.id,name:o.attributes.name,amount_min:o.attributes.amount_min,amount_max:o.attributes.amount_max,amount:(parseFloat(o.attributes.amount_max)+parseFloat(o.attributes.amount_min))/2,currency_code:o.attributes.currency_code,native_amount_min:o.attributes.native_amount_min,native_amount_max:o.attributes.native_amount_max,native_amount:(parseFloat(o.attributes.native_amount_max)+parseFloat(o.attributes.native_amount_min))/2,native_currency_code:o.attributes.native_currency_code,transactions:[],pay_dates:o.attributes.pay_dates,paid:o.attributes.paid_dates.length>0};c.expected_amount=n.autoConversion?V(c.native_amount,c.native_currency_code):V(c.amount,c.currency_code),c.expected_times=ee.t("firefly.subscr_expected_x_times",{times:o.attributes.pay_dates.length,amount:c.expected_amount});for(let u in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(u)){const h=o.attributes.paid_dates[u];let d=100;n.autoConversion&&(d=Math.round(-100+parseFloat(h.native_amount)*-1/parseFloat(c.native_amount)*100)),n.autoConversion||(d=Math.round(-100+parseFloat(h.amount)*-1/parseFloat(c.amount)*100));let f={amount:n.autoConversion?V(h.native_amount,h.native_currency_code):V(h.amount,h.currency_code),percentage:d,date:J(new Date(h.date),"PP"),foreign_amount:null};h.foreign_currency_code!==null&&(f.foreign_amount=n.autoConversion?h.foreign_native_amount:h.foreign_amount,f.foreign_currency_code=n.autoConversion?h.native_currency_code:h.foreign_currency_code),c.transactions.push(f)}if(Ct[r].bills.push(c),o.attributes.paid_dates.length===0){const u=o.attributes.pay_dates.length*c.amount,h=o.attributes.pay_dates.length*c.native_amount;Ct[r].payment_info.hasOwnProperty(c.currency_code)||(Ct[r].payment_info[c.currency_code]={currency_code:c.currency_code,paid:0,unpaid:0,native_currency_code:c.native_currency_code,native_paid:0,native_unpaid:0}),Ct[r].payment_info[c.currency_code].unpaid+=u,Ct[r].payment_info[c.currency_code].native_unpaid+=h}if(o.attributes.paid_dates.length>0){for(let u in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(u)){let h=o.attributes.paid_dates[u];Ct[r].payment_info.hasOwnProperty(h.currency_code)||(Ct[r].payment_info[h.currency_code]={currency_code:c.currency_code,paid:0,unpaid:0,native_currency_code:c.native_currency_code,native_paid:0,native_unpaid:0});const d=parseFloat(h.amount)*-1,f=parseFloat(h.native_amount)*-1;Ct[r].payment_info[h.currency_code].paid+=d,Ct[r].payment_info[h.currency_code].native_paid+=f}}}}return parseInt(e.data.meta.pagination.total_pages)>n.page?(n.page++,Pa(n)):Promise.resolve()})}const rp=()=>({loading:!1,autoConversion:!1,subscriptions:[],startSubscriptions(){this.loading=!0;let n=new Date(window.store.get("start")),t=new Date(window.store.get("end"));console.log("here we are");const e=window.store.get("cacheValid");let i=window.store.get(Nt("subscriptions-data-dashboard",n,t));e&&typeof i<"u",Ct={},this.subscriptions=[],console.log("cache is invalid, must download");let s={start:J(n,"y-MM-dd"),end:J(t,"y-MM-dd"),autoConversion:this.autoConversion,page:1};Pa(s).then(()=>{console.log("Done with download!");let o=Object.values(Ct);for(let r in o)if(o.hasOwnProperty(r)){let a=o[r];const l=Object.keys(a.payment_info);a.col_size=l.length===1?"col-6 offset-3":"col-6",a.chart_width=l.length===1?"50%":"100%",a.payment_length=l.length,this.subscriptions.push(a)}this.loading=!1})},drawPieChart(n,t,e){let i="#pie_"+n+"_"+e.currency_code;const s=this.autoConversion?e.native_unpaid:e.unpaid,o=this.autoConversion?e.native_paid:e.paid,r=this.autoConversion?e.native_currency_code:e.currency_code,l={type:"doughnut",data:{labels:[ee.t("firefly.paid"),ee.t("firefly.unpaid")],datasets:[{label:ee.t("firefly.subscriptions_in_group",{title:t}),data:[o,s],backgroundColor:["rgb(54, 162, 235)","rgb(255, 99, 132)"],hoverOffset:4}]},options:{plugins:{tooltip:{callbacks:{label:function(u){return u.dataset.label+": "+V(u.raw,r)}}}}}};var c=mt.getChart(document.querySelector(i));typeof c<"u"&&c.destroy(),new mt(document.querySelector(i),l)},init(){console.log("subscriptions init"),Promise.all([bt("autoConversion",!1),bt("language","en_US")]).then(n=>{console.log("subscriptions after promises"),this.autoConversion=n[0],Hi=!0,ee=new li;const t=n[1].replace("-","_");ee.locale=t,ci(ee,t).then(()=>{this.loading===!1&&this.startSubscriptions()})}),window.store.observe("end",()=>{Hi&&(console.log("subscriptions observe end"),this.loading===!1&&this.startSubscriptions())}),window.store.observe("autoConversion",n=>{Hi&&(console.log("subscriptions observe autoConversion"),this.autoConversion=n,this.loading===!1&&this.startSubscriptions())})}});class ap{get(t){return vt.get("/api/v2/piggy-banks",{params:t})}}let Vt={},Vi=!1,Vn;const pr="dashboard-piggies-data",lp=()=>({loading:!1,autoConversion:!1,sankeyGrouping:"account",piggies:[],getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt(pr,n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){Vt=s,this.parsePiggies(),this.loading=!1;return}let o={start:J(n,"y-MM-dd"),end:J(t,"y-MM-dd"),page:1};this.downloadPiggyBanks(o)},downloadPiggyBanks(n){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),i=Nt(pr,t,e);new ap().get(n).then(o=>{if(Vt=[...Vt,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>n.page){n.page++,this.downloadPiggyBanks(n);return}window.store.set(i,Vt),this.parsePiggies(),this.loading=!1})},parsePiggies(){let n=[];for(let t in Vt)if(Vt.hasOwnProperty(t)){let e=Vt[t];if(e.attributes.percentage>=100||e.attributes.percentage===0)continue;let i=e.object_group_title??Vn.t("firefly.default_group_title_name_plain");n.hasOwnProperty(i)||(n[i]={id:e.object_group_id??0,title:i,order:e.object_group_order??0,piggies:[]});let s={id:e.id,name:e.attributes.name,percentage:parseInt(e.attributes.percentage),amount:this.autoConversion?e.attributes.native_current_amount:e.attributes.current_amount,left_to_save:this.autoConversion?e.attributes.native_left_to_save:e.attributes.left_to_save,target_amount:this.autoConversion?e.attributes.native_target_amount:e.attributes.target_amount,save_per_month:this.autoConversion?e.attributes.native_save_per_month:e.attributes.save_per_month,currency_code:this.autoConversion?e.attributes.native_currency_code:e.attributes.currency_code};n[i].piggies.push(s)}this.piggies=Object.values(n)},loadPiggyBanks(){if(this.loading!==!0){if(this.loading=!0,this.piggies.length!==0){this.parsePiggies(),this.loading=!1;return}this.getFreshData()}},init(){Vt=[],Promise.all([bt("autoConversion",!1),bt("language","en_US")]).then(n=>{Vn=new li;const t=n[1].replace("-","_");Vn.locale=t,ci(Vn,t).then(()=>{Vi=!0,this.autoConversion=n[0],this.loadPiggyBanks()})}),window.store.observe("end",()=>{Vi&&(Vt=[],this.loadPiggyBanks())}),window.store.observe("autoConversion",n=>{Vi&&(this.autoConversion=n,this.loadPiggyBanks())})}});/*! +`)):Array.isArray(i)?e.push.apply(e,i):H(e)||t.unshift(""+i)}return t}function Ni(n){return!n||["min","max"].indexOf(n)===-1?"max":n}const ae=n=>n!==void 0;function $g(n,t){const e=new Set(t.map(r=>r.to)),i=new Set(t.map(r=>r.from)),s=new Set([...n.keys()]);let o=0;for(;s.size;){const r=qg([...s],e);for(const a of r){const l=n.get(a);ae(l.x)||(l.x=o),s.delete(a)}s.size&&(e.clear(),t.filter(a=>s.has(a.from)).forEach(a=>e.add(a.to)),o++)}return[...n.keys()].filter(r=>!i.has(r)).forEach(r=>{const a=n.get(r);a.column||(a.x=o)}),o}function qg(n,t){const e=n.filter(i=>!t.has(i));return e.length?e:n.slice(0,1)}const Xg=(n,t)=>n.x!==t.x?n.x-t.x:n.y-t.y;let Wn=-1;function Kg(){return Wn=Wn<100?Wn+1:0,Wn}function as(n,t,e=Kg()){let i=0;for(const s of n)s.node._visited!==e&&(s.node._visited=e,i+=s.node[t].length+as(s.node[t],t,e));return i}const Ca=n=>(t,e)=>as(t.node[n],n)-as(e.node[n],n)||t.node[n].length-e.node[n].length;function Cs(n,t){n.from.sort(Ca("from"));for(const e of n.from){const i=e.node;ae(i.y)||(i.y=t,Cs(i,t)),t=Math.max(i.y+i.out,t)}return t}function _e(n,t){n.to.sort(Ca("to"));for(const e of n.to){const i=e.node;ae(i.y)||(i.y=t,_e(i,t)),t=Math.max(i.y+i.in,t)}return t}function qe(n,t){return ae(n.y)?n.y:(n.y=t,t)}function Gg(n,t){const e=n.filter(u=>u.x===0),i=n.filter(u=>u.x===t),s=e.filter(u=>!ae(u.y)),o=i.filter(u=>!ae(u.y)),r=n.filter(u=>u.x>0&&u.xMath.max(u,h.y+h.out||0),0),l=i.reduce((u,h)=>Math.max(u,h.y+h.in||0),0),c=0;return a>=l?(s.forEach(u=>{a=qe(u,a),a=Math.max(a+u.out,_e(u,a))}),o.forEach(u=>{l=qe(u,l),l=Math.max(l+u.in,_e(u,l))})):(o.forEach(u=>{l=qe(u,l),l=Math.max(l+u.in,_e(u,l))}),s.forEach(u=>{a=qe(u,a),a=Math.max(a+u.out,_e(u,a))})),r.forEach(u=>{let h=n.filter(d=>d.x===u.x&&ae(d.y)).reduce((d,f)=>Math.max(d,f.y+Math.max(f.in,f.out)),0);h=qe(u,h),h=Math.max(h+u.in,Cs(u,h)),h=Math.max(h+u.out,_e(u,h)),c=Math.max(c,h)}),Math.max(a,l,c)}function Qg(n,t){n.sort((r,a)=>Math.max(a.in,a.out)-Math.max(r.in,r.out));const e=n[0];e.y=0;const i=Cs(e,0),s=_e(e,0),o=Gg(n,t);return Math.max(i,s,o)}function Zg(n,t){let e=0,i=0;for(let s=0;s<=t;s++){let o=i;const r=n.filter(a=>a.x===s).sort((a,l)=>a.priority-l.priority);i=r[0].to.filter(a=>a.node.x>s+1).reduce((a,l)=>a+l.flow,0)||0;for(const a of r)a.y=o,o+=Math.max(a.out,a.in);e=Math.max(o,e)}return e}function Jg(n,t){let e=1,i=0,s=0,o=0;const r=[];n.sort(Xg);for(const a of n){if(a.y){if(a.x===0)r.push(a.y);else{for(i!==a.x&&(i=a.x,s=0),e=s+1;ea.y);e++);s=e}a.y+=e*t,e++}o=Math.max(o,a.y+Math.max(a.in,a.out))}return o}function tp(n,t){n.forEach(e=>{const i=Math[t](e.in||e.out,e.out||e.in),s=il.node.y+l.node.out/2-(c.node.y+c.node.out/2)).forEach((l,c)=>{s?l.addY=c*(i-l.flow)/(a-1):(l.addY=r,r+=l.flow)}),r=0,a=e.to.length,e.to.sort((l,c)=>l.node.y+l.node.in/2-(c.node.y+c.node.in/2)).forEach((l,c)=>{o?l.addY=c*(i-l.flow)/(a-1):(l.addY=r,r+=l.flow)})})}function ep(n,t,e,i){const s=[...n.values()],o=$g(n,t),a=(e?Zg(s,o):Qg(s,o))*.03,l=Jg(s,a);return tp(s,i),{maxX:o,maxY:l}}function np(n){const t=new Map;for(let i=0;is.flow-i.flow;return[...t.values()].forEach(i=>{i.from=i.from.sort(e),i.from.forEach(s=>{s.node=t.get(s.key)}),i.to=i.to.sort(e),i.to.forEach(s=>{s.node=t.get(s.key)})}),t}function hr(n,t,e){for(const i of n)if(i.key===t&&i.index===e)return i.addY;return 0}class _i extends Xt{parseObjectData(t,e,i,s){const{from:o="from",to:r="to",flow:a="flow"}=this.options.parsing,l=e.map(({[o]:y,[r]:x,[a]:v})=>({from:y,to:x,flow:v})),{xScale:c,yScale:u}=t,h=[],d=this._nodes=np(l),{column:f,priority:g,size:p}=this.getDataset();if(g)for(const y of d.values())y.key in g&&(y.priority=g[y.key]);if(f)for(const y of d.values())y.key in f&&(y.column=!0,y.x=f[y.key]);const{maxX:m,maxY:b}=ep(d,l,!!g,Ni(p));this._maxX=m,this._maxY=b;for(let y=0,x=l.length;y1){const d=c-u*l/2+h;for(let f=0;fn.type==="data"?(n.parsed._custom.x-n.parsed.x)*200:void 0,delay:n=>n.type==="data"?n.parsed.x*500+n.dataIndex*20:void 0},colors:{type:"color",properties:["colorFrom","colorTo"]}},transitions:{hide:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],to:"transparent"}}},show:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],from:"transparent"}}}}};_i.overrides={interaction:{mode:"nearest",intersect:!0},datasets:{clip:!1,parsing:!0},plugins:{tooltip:{callbacks:{title(){return""},label(n){const t=n.dataset.data[n.dataIndex];return t.from+" -> "+t.to+": "+t.flow}}},legend:{display:!1}},scales:{x:{type:"linear",bounds:"data",display:!1,min:0,offset:!1},y:{type:"linear",bounds:"data",display:!1,min:0,reverse:!0,offset:!1}},layout:{padding:{top:3,left:3,right:13,bottom:3}}};const dr=(n,t,e,i)=>n({x:n.x+e*(t.x-n.x),y:n.y+e*(t.y-n.y)});function ip(n,{x:t,x2:e,options:i}){let s;i.colorMode==="from"?s=Ae(i.colorFrom).alpha(.5).rgbString():i.colorMode==="to"?s=Ae(i.colorTo).alpha(.5).rgbString():(s=n.createLinearGradient(t,0,e,0),s.addColorStop(0,Ae(i.colorFrom).alpha(.5).rgbString()),s.addColorStop(1,Ae(i.colorTo).alpha(.5).rgbString())),n.fillStyle=s,n.strokeStyle=s,n.lineWidth=.5}class Ps extends Lt{constructor(t){super(),this.options=void 0,this.x=void 0,this.y=void 0,this.x2=void 0,this.y2=void 0,this.height=void 0,t&&Object.assign(this,t)}draw(t){const e=this,{x:i,x2:s,y:o,y2:r,height:a,progress:l}=e,{cp1:c,cp2:u}=dr(i,o,s,r);l!==0&&(t.save(),l<1&&(t.beginPath(),t.rect(i,Math.min(o,r),(s-i)*l+1,Math.abs(r-o)+a+1),t.clip()),ip(t,e),t.beginPath(),t.moveTo(i,o),t.bezierCurveTo(c.x,c.y,u.x,u.y,s,r),t.lineTo(s,r+a),t.bezierCurveTo(u.x,u.y+a,c.x,c.y+a,i,o+a),t.lineTo(i,o),t.stroke(),t.closePath(),t.fill(),t.restore())}inRange(t,e,i){const{x:s,y:o,x2:r,y2:a,height:l}=this.getProps(["x","y","x2","y2","height"],i);if(tr)return!1;const{cp1:c,cp2:u}=dr(s,o,r,a),h=(t-s)/(r-s),d={x:s,y:o},f={x:r,y:a},g=Oe(d,c,h),p=Oe(c,u,h),m=Oe(u,f,h),b=Oe(g,p,h),y=Oe(p,m,h),x=Oe(b,y,h).y;return e>=x&&e<=x+l}inXRange(t,e){const{x:i,x2:s}=this.getProps(["x","x2"],e);return t>=i&&t<=s}inYRange(t,e){const{y:i,y2:s,height:o}=this.getProps(["y","y2","height"],e),r=Math.min(i,s),a=Math.max(i,s)+o;return t>=r&&t<=a}getCenterPoint(t){const{x:e,y:i,x2:s,y2:o,height:r}=this.getProps(["x","y","x2","y2","height"],t);return{x:(e+s)/2,y:(i+o+r)/2}}tooltipPosition(t){return this.getCenterPoint(t)}getRange(t){return t==="x"?this.width/2:this.height/2}}Ps.id="flow";Ps.defaults={colorFrom:"red",colorTo:"green",colorMode:"gradient",hoverColorFrom:(n,t)=>on(t.colorFrom),hoverColorTo:(n,t)=>on(t.colorTo)};mt.register({SankeyController:_i,Flow:Ps});const fr="dashboard-sankey-data";let pt,Wi=!1,Hn=null,Ht=[],ht=!1,L={category:null,unknown_category:null,in:null,out:null,unknown_source:null,unknown_dest:null,unknown_account:null,expense_account:null,revenue_account:null,budget:null,unknown_budget:null,all_money:null};const gr=function(n){return n.includes(L.revenue_account)?"forestgreen":n.includes("("+L.in+",")?"green":n.includes(L.budget)||n.includes(L.unknown_budget)?"Orchid":n.includes("("+L.out+",")?"MediumOrchid":n.includes(L.all_money)?"blue":"red"};function Xe(n,t,e,i){if(n==="category"&&t!==null&&e==="in")return L.category+' "'+t+'" ('+L.in+(ht?", "+i+")":")");if(n==="category"&&t===null&&e==="in")return L.unknown_category+" ("+L.in+(ht?", "+i+")":")");if(n==="category"&&t!==null&&e==="out")return L.category+' "'+t+'" ('+L.out+(ht?", "+i+")":")");if(n==="category"&&t===null&&e==="out")return L.unknown_category+" ("+L.out+(ht?", "+i+")":")");if(n==="account"&&t===null&&e==="in")return L.unknown_source+(ht?" ("+i+")":"");if(n==="account"&&t!==null&&e==="in")return L.revenue_account+'"'+t+'"'+(ht?" ("+i+")":"");if(n==="account"&&t===null&&e==="out")return L.unknown_dest+(ht?" ("+i+")":"");if(n==="account"&&t!==null&&e==="out")return L.expense_account+' "'+t+'"'+(ht?" ("+i+")":"");if(n==="budget"&&t!==null)return L.budget+' "'+t+'"'+(ht?" ("+i+")":"");if(n==="budget"&&t===null)return L.unknown_budget+(ht?" ("+i+")":"");console.error('Cannot handle: type:"'+n+'", dir: "'+e+'"')}function Ke(n,t,e){if(n==="category"&&t!==null)return L.category+' "'+t+'"'+(ht?" ("+e+")":"");if(n==="category"&&t===null)return L.unknown_category+(ht?" ("+e+")":"");if(n==="account"&&t===null)return L.unknown_account+(ht?" ("+e+")":"");if(n==="account"&&t!==null)return t+(ht?" ("+e+")":"");if(n==="budget"&&t!==null)return L.budget+' "'+t+'"'+(ht?" ("+e+")":"");if(n==="budget"&&t===null)return L.unknown_budget+(ht?" ("+e+")":"");console.error('Cannot handle: type:"'+n+'"')}const sp=()=>({loading:!1,autoConversion:!1,generateOptions(){let n=yi("sankey"),t={},e={};for(let s in Ht)if(Ht.hasOwnProperty(s)){let o=Ht[s];for(let r in o.attributes.transactions)if(o.attributes.transactions.hasOwnProperty(r)){let a=o.attributes.transactions[r],l=this.autoConversion?a.native_currency_code:a.currency_code,c=this.autoConversion?parseFloat(a.native_amount):parseFloat(a.amount),u;if(a.type==="deposit"){let h=Xe("category",a.category_name,"in",l),d=Xe("account",a.source_name,"in",l);e[h]=Ke("category",a.category_name,l),e[d]=Ke("account",a.source_name,l),u=d+"-"+h+"-"+l,t.hasOwnProperty(u)||(t[u]={from:d,to:h,amount:0}),t[u].amount+=c,u=h+"-"+L.all_money+"-"+l,t.hasOwnProperty(u)||(t[u]={from:h,to:L.all_money+(this.autoConversion?" ("+l+")":""),amount:0}),t[u].amount+=c}if(a.type==="withdrawal"){let h=Xe("budget",a.budget_name,"out",l);e[h]=Ke("budget",a.budget_name,l),u=L.all_money+"-"+h+"-"+l,t.hasOwnProperty(u)||(t[u]={from:L.all_money+(this.autoConversion?" ("+l+")":""),to:h,amount:0}),t[u].amount+=c;let d=Xe("category",a.category_name,"out",l);e[d]=Ke("category",a.category_name,l),u=h+"-"+d+"-"+l,t.hasOwnProperty(u)||(t[u]={from:h,to:d,amount:0}),t[u].amount+=c;let f=Xe("account",a.destination_name,"out",l);e[f]=Ke("account",a.destination_name,l),u=d+"-"+f+"-"+l,t.hasOwnProperty(u)||(t[u]={from:d,to:f,amount:0}),t[u].amount+=c}}}let i={label:"Firefly III dashboard sankey chart",data:[],colorFrom:s=>gr(s.dataset.data[s.dataIndex]?s.dataset.data[s.dataIndex].from:""),colorTo:s=>gr(s.dataset.data[s.dataIndex]?s.dataset.data[s.dataIndex].to:""),colorMode:"gradient",labels:e,size:"min"};for(let s in t)if(t.hasOwnProperty(s)){let o=t[s];i.data.push({from:o.from,to:o.to,flow:o.amount})}return n.data.datasets.push(i),n},drawChart(n){if(Hn!==null){Hn.data.datasets=n.data.datasets,Hn.update();return}Hn=new mt(document.querySelector("#sankey-chart"),n)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt(fr,n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){Ht=s,this.drawChart(this.generateOptions()),this.loading=!1;return}let o={start:J(n,"y-MM-dd"),end:J(t,"y-MM-dd"),type:"withdrawal,deposit",page:1};this.downloadTransactions(o)},downloadTransactions(n){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),i=Nt(fr,t,e);new jg().list(n).then(o=>{if(Ht=[...Ht,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>n.page){n.page++,this.downloadTransactions(n);return}window.store.set(i,Ht),this.drawChart(this.generateOptions()),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,Ht.length!==0){this.drawChart(this.generateOptions()),this.loading=!1;return}this.getFreshData()}},init(){Ht=[],Promise.all([bt("autoConversion",!1),bt("language","en_US")]).then(n=>{this.autoConversion=n[0],ht=n[0],pt=new li;const t=n[1].replace("-","_");pt.locale=t,ci(pt,t).then(()=>{L.all_money=pt.t("firefly.all_money"),L.category=pt.t("firefly.category"),L.in=pt.t("firefly.money_flowing_in"),L.out=pt.t("firefly.money_flowing_out"),L.unknown_category=pt.t("firefly.unknown_category_plain"),L.unknown_source=pt.t("firefly.unknown_source_plain"),L.unknown_dest=pt.t("firefly.unknown_dest_plain"),L.unknown_account=pt.t("firefly.unknown_any_plain"),L.unknown_budget=pt.t("firefly.unknown_budget_plain"),L.expense_account=pt.t("firefly.expense_account"),L.revenue_account=pt.t("firefly.revenue_account"),L.budget=pt.t("firefly.budget"),Wi=!0,this.loadChart()})}),window.store.observe("end",()=>{Wi&&(this.transactions=[],this.loadChart())}),window.store.observe("autoConversion",n=>{Wi&&(this.autoConversion=n,this.loadChart())})}});let op=class{list(t){return vt.get("/api/v2/subscriptions",{params:t})}paid(t){return vt.get("/api/v2/subscriptions/sum/paid",{params:t})}unpaid(t){return vt.get("/api/v2/subscriptions/sum/unpaid",{params:t})}},Hi=!1,ee,Ct={};function Pa(n){return new op().list(n).then(e=>{let i=e.data.data;for(let s in i)if(i.hasOwnProperty(s)){let o=i[s];if(o.attributes.active&&o.attributes.pay_dates.length>0){let r=o.attributes.object_group_id===null?0:o.attributes.object_group_id,a=o.attributes.object_group_title===null?ee.t("firefly.default_group_title_name_plain"):o.attributes.object_group_title,l=o.attributes.object_group_order===null?0:o.attributes.object_group_order;Ct.hasOwnProperty(r)||(Ct[r]={id:r,title:a,order:l,payment_info:{},bills:[]});let c={id:o.id,name:o.attributes.name,amount_min:o.attributes.amount_min,amount_max:o.attributes.amount_max,amount:(parseFloat(o.attributes.amount_max)+parseFloat(o.attributes.amount_min))/2,currency_code:o.attributes.currency_code,native_amount_min:o.attributes.native_amount_min,native_amount_max:o.attributes.native_amount_max,native_amount:(parseFloat(o.attributes.native_amount_max)+parseFloat(o.attributes.native_amount_min))/2,native_currency_code:o.attributes.native_currency_code,transactions:[],pay_dates:o.attributes.pay_dates,paid:o.attributes.paid_dates.length>0};c.expected_amount=n.autoConversion?V(c.native_amount,c.native_currency_code):V(c.amount,c.currency_code),c.expected_times=ee.t("firefly.subscr_expected_x_times",{times:o.attributes.pay_dates.length,amount:c.expected_amount});for(let u in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(u)){const h=o.attributes.paid_dates[u];let d=100;n.autoConversion&&(d=Math.round(-100+parseFloat(h.native_amount)*-1/parseFloat(c.native_amount)*100)),n.autoConversion||(d=Math.round(-100+parseFloat(h.amount)*-1/parseFloat(c.amount)*100));let f={amount:n.autoConversion?V(h.native_amount,h.native_currency_code):V(h.amount,h.currency_code),percentage:d,date:J(new Date(h.date),"PP"),foreign_amount:null};h.foreign_currency_code!==null&&(f.foreign_amount=n.autoConversion?h.foreign_native_amount:h.foreign_amount,f.foreign_currency_code=n.autoConversion?h.native_currency_code:h.foreign_currency_code),c.transactions.push(f)}if(Ct[r].bills.push(c),o.attributes.paid_dates.length===0){const u=o.attributes.pay_dates.length*c.amount,h=o.attributes.pay_dates.length*c.native_amount;Ct[r].payment_info.hasOwnProperty(c.currency_code)||(Ct[r].payment_info[c.currency_code]={currency_code:c.currency_code,paid:0,unpaid:0,native_currency_code:c.native_currency_code,native_paid:0,native_unpaid:0}),Ct[r].payment_info[c.currency_code].unpaid+=u,Ct[r].payment_info[c.currency_code].native_unpaid+=h}if(o.attributes.paid_dates.length>0){for(let u in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(u)){let h=o.attributes.paid_dates[u];Ct[r].payment_info.hasOwnProperty(h.currency_code)||(Ct[r].payment_info[h.currency_code]={currency_code:c.currency_code,paid:0,unpaid:0,native_currency_code:c.native_currency_code,native_paid:0,native_unpaid:0});const d=parseFloat(h.amount)*-1,f=parseFloat(h.native_amount)*-1;Ct[r].payment_info[h.currency_code].paid+=d,Ct[r].payment_info[h.currency_code].native_paid+=f}}}}return parseInt(e.data.meta.pagination.total_pages)>n.page?(n.page++,Pa(n)):Promise.resolve()})}const rp=()=>({loading:!1,autoConversion:!1,subscriptions:[],startSubscriptions(){this.loading=!0;let n=new Date(window.store.get("start")),t=new Date(window.store.get("end"));console.log("here we are");const e=window.store.get("cacheValid");let i=window.store.get(Nt("subscriptions-data-dashboard",n,t));e&&typeof i<"u",Ct={},this.subscriptions=[],console.log("cache is invalid, must download");let s={start:J(n,"y-MM-dd"),end:J(t,"y-MM-dd"),autoConversion:this.autoConversion,page:1};Pa(s).then(()=>{console.log("Done with download!");let o=Object.values(Ct);for(let r in o)if(o.hasOwnProperty(r)){let a=o[r];const l=Object.keys(a.payment_info);a.col_size=l.length===1?"col-6 offset-3":"col-6",a.chart_width=l.length===1?"50%":"100%",a.payment_length=l.length,this.subscriptions.push(a)}this.loading=!1})},drawPieChart(n,t,e){let i="#pie_"+n+"_"+e.currency_code;const s=this.autoConversion?e.native_unpaid:e.unpaid,o=this.autoConversion?e.native_paid:e.paid,r=this.autoConversion?e.native_currency_code:e.currency_code,l={type:"doughnut",data:{labels:[ee.t("firefly.paid"),ee.t("firefly.unpaid")],datasets:[{label:ee.t("firefly.subscriptions_in_group",{title:t}),data:[o,s],backgroundColor:["rgb(54, 162, 235)","rgb(255, 99, 132)"],hoverOffset:4}]},options:{plugins:{tooltip:{callbacks:{label:function(u){return u.dataset.label+": "+V(u.raw,r)}}}}}};var c=mt.getChart(document.querySelector(i));typeof c<"u"&&c.destroy(),new mt(document.querySelector(i),l)},init(){console.log("subscriptions init"),Promise.all([bt("autoConversion",!1),bt("language","en_US")]).then(n=>{console.log("subscriptions after promises"),this.autoConversion=n[0],Hi=!0,ee=new li;const t=n[1].replace("-","_");ee.locale=t,ci(ee,t).then(()=>{this.loading===!1&&this.startSubscriptions()})}),window.store.observe("end",()=>{Hi&&(console.log("subscriptions observe end"),this.loading===!1&&this.startSubscriptions())}),window.store.observe("autoConversion",n=>{Hi&&(console.log("subscriptions observe autoConversion"),this.autoConversion=n,this.loading===!1&&this.startSubscriptions())})}});class ap{list(t){return vt.get("/api/v2/piggy-banks",{params:t})}}let Vt={},Vi=!1,Vn;const pr="dashboard-piggies-data",lp=()=>({loading:!1,autoConversion:!1,sankeyGrouping:"account",piggies:[],getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Nt(pr,n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){Vt=s,this.parsePiggies(),this.loading=!1;return}let o={start:J(n,"y-MM-dd"),end:J(t,"y-MM-dd"),page:1};this.downloadPiggyBanks(o)},downloadPiggyBanks(n){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),i=Nt(pr,t,e);new ap().list(n).then(o=>{if(Vt=[...Vt,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>n.page){n.page++,this.downloadPiggyBanks(n);return}window.store.set(i,Vt),this.parsePiggies(),this.loading=!1})},parsePiggies(){let n=[];for(let t in Vt)if(Vt.hasOwnProperty(t)){let e=Vt[t];if(e.attributes.percentage>=100||e.attributes.percentage===0)continue;let i=e.object_group_title??Vn.t("firefly.default_group_title_name_plain");n.hasOwnProperty(i)||(n[i]={id:e.object_group_id??0,title:i,order:e.object_group_order??0,piggies:[]});let s={id:e.id,name:e.attributes.name,percentage:parseInt(e.attributes.percentage),amount:this.autoConversion?e.attributes.native_current_amount:e.attributes.current_amount,left_to_save:this.autoConversion?e.attributes.native_left_to_save:e.attributes.left_to_save,target_amount:this.autoConversion?e.attributes.native_target_amount:e.attributes.target_amount,save_per_month:this.autoConversion?e.attributes.native_save_per_month:e.attributes.save_per_month,currency_code:this.autoConversion?e.attributes.native_currency_code:e.attributes.currency_code};n[i].piggies.push(s)}this.piggies=Object.values(n)},loadPiggyBanks(){if(this.loading!==!0){if(this.loading=!0,this.piggies.length!==0){this.parsePiggies(),this.loading=!1;return}this.getFreshData()}},init(){Vt=[],Promise.all([bt("autoConversion",!1),bt("language","en_US")]).then(n=>{Vn=new li;const t=n[1].replace("-","_");Vn.locale=t,ci(Vn,t).then(()=>{Vi=!0,this.autoConversion=n[0],this.loadPiggyBanks()})}),window.store.observe("end",()=>{Vi&&(Vt=[],this.loadPiggyBanks())}),window.store.observe("autoConversion",n=>{Vi&&(this.autoConversion=n,this.loadPiggyBanks())})}});/*! * chartjs-adapter-date-fns v3.0.0 * https://www.chartjs.org * (c) 2022 chartjs-adapter-date-fns Contributors diff --git a/public/build/assets/load-translations-9a154502.js b/public/build/assets/load-translations-87b32220.js similarity index 88% rename from public/build/assets/load-translations-9a154502.js rename to public/build/assets/load-translations-87b32220.js index 4f53dc6dd5..dc6fdafd0c 100644 --- a/public/build/assets/load-translations-9a154502.js +++ b/public/build/assets/load-translations-87b32220.js @@ -1,18 +1,18 @@ function bind$4(t,e){return function(){return t.apply(e,arguments)}}const{toString:toString$7}=Object.prototype,{getPrototypeOf}=Object,kindOf=(t=>e=>{const a=toString$7.call(e);return t[a]||(t[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),kindOfTest=t=>(t=t.toLowerCase(),e=>kindOf(e)===t),typeOfTest=t=>e=>typeof e===t,{isArray:isArray$c}=Array,isUndefined=typeOfTest("undefined");function isBuffer$3(t){return t!==null&&!isUndefined(t)&&t.constructor!==null&&!isUndefined(t.constructor)&&isFunction$5(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const isArrayBuffer=kindOfTest("ArrayBuffer");function isArrayBufferView(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&isArrayBuffer(t.buffer),e}const isString$1=typeOfTest("string"),isFunction$5=typeOfTest("function"),isNumber=typeOfTest("number"),isObject$b=t=>t!==null&&typeof t=="object",isBoolean=t=>t===!0||t===!1,isPlainObject=t=>{if(kindOf(t)!=="object")return!1;const e=getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},isDate$1=kindOfTest("Date"),isFile=kindOfTest("File"),isBlob=kindOfTest("Blob"),isFileList=kindOfTest("FileList"),isStream=t=>isObject$b(t)&&isFunction$5(t.pipe),isFormData=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||isFunction$5(t.append)&&((e=kindOf(t))==="formdata"||e==="object"&&isFunction$5(t.toString)&&t.toString()==="[object FormData]"))},isURLSearchParams=kindOfTest("URLSearchParams"),trim$2=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function forEach(t,e,{allOwnKeys:a=!1}={}){if(t===null||typeof t>"u")return;let r,n;if(typeof t!="object"&&(t=[t]),isArray$c(t))for(r=0,n=t.length;r0;)if(n=a[r],e===n.toLowerCase())return n;return null}const _global=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),isContextDefined=t=>!isUndefined(t)&&t!==_global;function merge(){const{caseless:t}=isContextDefined(this)&&this||{},e={},a=(r,n)=>{const i=t&&findKey$1(e,n)||n;isPlainObject(e[i])&&isPlainObject(r)?e[i]=merge(e[i],r):isPlainObject(r)?e[i]=merge({},r):isArray$c(r)?e[i]=r.slice():e[i]=r};for(let r=0,n=arguments.length;r(forEach(e,(n,i)=>{a&&isFunction$5(n)?t[i]=bind$4(n,a):t[i]=n},{allOwnKeys:r}),t),stripBOM=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),inherits=(t,e,a,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),a&&Object.assign(t.prototype,a)},toFlatObject=(t,e,a,r)=>{let n,i,o;const s={};if(e=e||{},t==null)return e;do{for(n=Object.getOwnPropertyNames(t),i=n.length;i-- >0;)o=n[i],(!r||r(o,t,e))&&!s[o]&&(e[o]=t[o],s[o]=!0);t=a!==!1&&getPrototypeOf(t)}while(t&&(!a||a(t,e))&&t!==Object.prototype);return e},endsWith=(t,e,a)=>{t=String(t),(a===void 0||a>t.length)&&(a=t.length),a-=e.length;const r=t.indexOf(e,a);return r!==-1&&r===a},toArray=t=>{if(!t)return null;if(isArray$c(t))return t;let e=t.length;if(!isNumber(e))return null;const a=new Array(e);for(;e-- >0;)a[e]=t[e];return a},isTypedArray$3=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&getPrototypeOf(Uint8Array)),forEachEntry=(t,e)=>{const r=(t&&t[Symbol.iterator]).call(t);let n;for(;(n=r.next())&&!n.done;){const i=n.value;e.call(t,i[0],i[1])}},matchAll=(t,e)=>{let a;const r=[];for(;(a=t.exec(e))!==null;)r.push(a);return r},isHTMLForm=kindOfTest("HTMLFormElement"),toCamelCase=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,r,n){return r.toUpperCase()+n}),hasOwnProperty$c=(({hasOwnProperty:t})=>(e,a)=>t.call(e,a))(Object.prototype),isRegExp=kindOfTest("RegExp"),reduceDescriptors=(t,e)=>{const a=Object.getOwnPropertyDescriptors(t),r={};forEach(a,(n,i)=>{let o;(o=e(n,i,t))!==!1&&(r[i]=o||n)}),Object.defineProperties(t,r)},freezeMethods=t=>{reduceDescriptors(t,(e,a)=>{if(isFunction$5(t)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const r=t[a];if(isFunction$5(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},toObjectSet=(t,e)=>{const a={},r=n=>{n.forEach(i=>{a[i]=!0})};return isArray$c(t)?r(t):r(String(t).split(e)),a},noop$3=()=>{},toFiniteNumber=(t,e)=>(t=+t,Number.isFinite(t)?t:e),ALPHA="abcdefghijklmnopqrstuvwxyz",DIGIT="0123456789",ALPHABET={DIGIT,ALPHA,ALPHA_DIGIT:ALPHA+ALPHA.toUpperCase()+DIGIT},generateString=(t=16,e=ALPHABET.ALPHA_DIGIT)=>{let a="";const{length:r}=e;for(;t--;)a+=e[Math.random()*r|0];return a};function isSpecCompliantForm(t){return!!(t&&isFunction$5(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const toJSONObject=t=>{const e=new Array(10),a=(r,n)=>{if(isObject$b(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[n]=r;const i=isArray$c(r)?[]:{};return forEach(r,(o,s)=>{const u=a(o,n+1);!isUndefined(u)&&(i[s]=u)}),e[n]=void 0,i}}return r};return a(t,0)},isAsyncFn=kindOfTest("AsyncFunction"),isThenable=t=>t&&(isObject$b(t)||isFunction$5(t))&&isFunction$5(t.then)&&isFunction$5(t.catch),utils={isArray:isArray$c,isArrayBuffer,isBuffer:isBuffer$3,isFormData,isArrayBufferView,isString:isString$1,isNumber,isBoolean,isObject:isObject$b,isPlainObject,isUndefined,isDate:isDate$1,isFile,isBlob,isRegExp,isFunction:isFunction$5,isStream,isURLSearchParams,isTypedArray:isTypedArray$3,isFileList,forEach,merge,extend,trim:trim$2,stripBOM,inherits,toFlatObject,kindOf,kindOfTest,endsWith,toArray,forEachEntry,matchAll,isHTMLForm,hasOwnProperty:hasOwnProperty$c,hasOwnProp:hasOwnProperty$c,reduceDescriptors,freezeMethods,toObjectSet,toCamelCase,noop:noop$3,toFiniteNumber,findKey:findKey$1,global:_global,isContextDefined,ALPHABET,generateString,isSpecCompliantForm,toJSONObject,isAsyncFn,isThenable};function AxiosError(t,e,a,r,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),a&&(this.config=a),r&&(this.request=r),n&&(this.response=n)}utils.inherits(AxiosError,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:utils.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const prototype$1=AxiosError.prototype,descriptors={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{descriptors[t]={value:t}});Object.defineProperties(AxiosError,descriptors);Object.defineProperty(prototype$1,"isAxiosError",{value:!0});AxiosError.from=(t,e,a,r,n,i)=>{const o=Object.create(prototype$1);return utils.toFlatObject(t,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError"),AxiosError.call(o,t.message,e,a,r,n),o.cause=t,o.name=t.name,i&&Object.assign(o,i),o};const httpAdapter=null;function isVisitable(t){return utils.isPlainObject(t)||utils.isArray(t)}function removeBrackets(t){return utils.endsWith(t,"[]")?t.slice(0,-2):t}function renderKey(t,e,a){return t?t.concat(e).map(function(n,i){return n=removeBrackets(n),!a&&i?"["+n+"]":n}).join(a?".":""):e}function isFlatArray(t){return utils.isArray(t)&&!t.some(isVisitable)}const predicates=utils.toFlatObject(utils,{},null,function(e){return/^is[A-Z]/.test(e)});function toFormData(t,e,a){if(!utils.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,a=utils.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(O,M){return!utils.isUndefined(M[O])});const r=a.metaTokens,n=a.visitor||l,i=a.dots,o=a.indexes,u=(a.Blob||typeof Blob<"u"&&Blob)&&utils.isSpecCompliantForm(e);if(!utils.isFunction(n))throw new TypeError("visitor must be a function");function c(T){if(T===null)return"";if(utils.isDate(T))return T.toISOString();if(!u&&utils.isBlob(T))throw new AxiosError("Blob is not supported. Use a Buffer instead.");return utils.isArrayBuffer(T)||utils.isTypedArray(T)?u&&typeof Blob=="function"?new Blob([T]):Buffer.from(T):T}function l(T,O,M){let C=T;if(T&&!M&&typeof T=="object"){if(utils.endsWith(O,"{}"))O=r?O:O.slice(0,-2),T=JSON.stringify(T);else if(utils.isArray(T)&&isFlatArray(T)||(utils.isFileList(T)||utils.endsWith(O,"[]"))&&(C=utils.toArray(T)))return O=removeBrackets(O),C.forEach(function(L,D){!(utils.isUndefined(L)||L===null)&&e.append(o===!0?renderKey([O],D,i):o===null?O:O+"[]",c(L))}),!1}return isVisitable(T)?!0:(e.append(renderKey(M,O,i),c(T)),!1)}const p=[],v=Object.assign(predicates,{defaultVisitor:l,convertValue:c,isVisitable});function S(T,O){if(!utils.isUndefined(T)){if(p.indexOf(T)!==-1)throw Error("Circular reference detected in "+O.join("."));p.push(T),utils.forEach(T,function(C,w){(!(utils.isUndefined(C)||C===null)&&n.call(e,C,utils.isString(w)?w.trim():w,O,v))===!0&&S(C,O?O.concat(w):[w])}),p.pop()}}if(!utils.isObject(t))throw new TypeError("data must be an object");return S(t),e}function encode$1(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function AxiosURLSearchParams(t,e){this._pairs=[],t&&toFormData(t,this,e)}const prototype=AxiosURLSearchParams.prototype;prototype.append=function(e,a){this._pairs.push([e,a])};prototype.toString=function(e){const a=e?function(r){return e.call(this,r,encode$1)}:encode$1;return this._pairs.map(function(n){return a(n[0])+"="+a(n[1])},"").join("&")};function encode(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function buildURL(t,e,a){if(!e)return t;const r=a&&a.encode||encode,n=a&&a.serialize;let i;if(n?i=n(e,a):i=utils.isURLSearchParams(e)?e.toString():new AxiosURLSearchParams(e,a).toString(r),i){const o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+i}return t}class InterceptorManager{constructor(){this.handlers=[]}use(e,a,r){return this.handlers.push({fulfilled:e,rejected:a,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){utils.forEach(this.handlers,function(r){r!==null&&e(r)})}}const InterceptorManager$1=InterceptorManager,transitionalDefaults={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},URLSearchParams$1=typeof URLSearchParams<"u"?URLSearchParams:AxiosURLSearchParams,FormData$1=typeof FormData<"u"?FormData:null,Blob$1=typeof Blob<"u"?Blob:null,isStandardBrowserEnv=(()=>{let t;return typeof navigator<"u"&&((t=navigator.product)==="ReactNative"||t==="NativeScript"||t==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),isStandardBrowserWebWorkerEnv=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),platform={isBrowser:!0,classes:{URLSearchParams:URLSearchParams$1,FormData:FormData$1,Blob:Blob$1},isStandardBrowserEnv,isStandardBrowserWebWorkerEnv,protocols:["http","https","file","blob","url","data"]};function toURLEncodedForm(t,e){return toFormData(t,new platform.classes.URLSearchParams,Object.assign({visitor:function(a,r,n,i){return platform.isNode&&utils.isBuffer(a)?(this.append(r,a.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function parsePropPath(t){return utils.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function arrayToObject(t){const e={},a=Object.keys(t);let r;const n=a.length;let i;for(r=0;r=a.length;return o=!o&&utils.isArray(n)?n.length:o,u?(utils.hasOwnProp(n,o)?n[o]=[n[o],r]:n[o]=r,!s):((!n[o]||!utils.isObject(n[o]))&&(n[o]=[]),e(a,r,n[o],i)&&utils.isArray(n[o])&&(n[o]=arrayToObject(n[o])),!s)}if(utils.isFormData(t)&&utils.isFunction(t.entries)){const a={};return utils.forEachEntry(t,(r,n)=>{e(parsePropPath(r),n,a,0)}),a}return null}function stringifySafely(t,e,a){if(utils.isString(t))try{return(e||JSON.parse)(t),utils.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(a||JSON.stringify)(t)}const defaults={transitional:transitionalDefaults,adapter:["xhr","http"],transformRequest:[function(e,a){const r=a.getContentType()||"",n=r.indexOf("application/json")>-1,i=utils.isObject(e);if(i&&utils.isHTMLForm(e)&&(e=new FormData(e)),utils.isFormData(e))return n&&n?JSON.stringify(formDataToJSON(e)):e;if(utils.isArrayBuffer(e)||utils.isBuffer(e)||utils.isStream(e)||utils.isFile(e)||utils.isBlob(e))return e;if(utils.isArrayBufferView(e))return e.buffer;if(utils.isURLSearchParams(e))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return toURLEncodedForm(e,this.formSerializer).toString();if((s=utils.isFileList(e))||r.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return toFormData(s?{"files[]":e}:e,u&&new u,this.formSerializer)}}return i||n?(a.setContentType("application/json",!1),stringifySafely(e)):e}],transformResponse:[function(e){const a=this.transitional||defaults.transitional,r=a&&a.forcedJSONParsing,n=this.responseType==="json";if(e&&utils.isString(e)&&(r&&!this.responseType||n)){const o=!(a&&a.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(s){if(o)throw s.name==="SyntaxError"?AxiosError.from(s,AxiosError.ERR_BAD_RESPONSE,this,null,this.response):s}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:platform.classes.FormData,Blob:platform.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};utils.forEach(["delete","get","head","post","put","patch"],t=>{defaults.headers[t]={}});const defaults$1=defaults,ignoreDuplicateOf=utils.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),parseHeaders=t=>{const e={};let a,r,n;return t&&t.split(` `).forEach(function(o){n=o.indexOf(":"),a=o.substring(0,n).trim().toLowerCase(),r=o.substring(n+1).trim(),!(!a||e[a]&&ignoreDuplicateOf[a])&&(a==="set-cookie"?e[a]?e[a].push(r):e[a]=[r]:e[a]=e[a]?e[a]+", "+r:r)}),e},$internals=Symbol("internals");function normalizeHeader(t){return t&&String(t).trim().toLowerCase()}function normalizeValue(t){return t===!1||t==null?t:utils.isArray(t)?t.map(normalizeValue):String(t)}function parseTokens(t){const e=Object.create(null),a=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=a.exec(t);)e[r[1]]=r[2];return e}const isValidHeaderName=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function matchHeaderValue(t,e,a,r,n){if(utils.isFunction(r))return r.call(this,e,a);if(n&&(e=a),!!utils.isString(e)){if(utils.isString(r))return e.indexOf(r)!==-1;if(utils.isRegExp(r))return r.test(e)}}function formatHeader(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,a,r)=>a.toUpperCase()+r)}function buildAccessors(t,e){const a=utils.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+a,{value:function(n,i,o){return this[r].call(this,e,n,i,o)},configurable:!0})})}class AxiosHeaders{constructor(e){e&&this.set(e)}set(e,a,r){const n=this;function i(s,u,c){const l=normalizeHeader(u);if(!l)throw new Error("header name must be a non-empty string");const p=utils.findKey(n,l);(!p||n[p]===void 0||c===!0||c===void 0&&n[p]!==!1)&&(n[p||u]=normalizeValue(s))}const o=(s,u)=>utils.forEach(s,(c,l)=>i(c,l,u));return utils.isPlainObject(e)||e instanceof this.constructor?o(e,a):utils.isString(e)&&(e=e.trim())&&!isValidHeaderName(e)?o(parseHeaders(e),a):e!=null&&i(a,e,r),this}get(e,a){if(e=normalizeHeader(e),e){const r=utils.findKey(this,e);if(r){const n=this[r];if(!a)return n;if(a===!0)return parseTokens(n);if(utils.isFunction(a))return a.call(this,n,r);if(utils.isRegExp(a))return a.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,a){if(e=normalizeHeader(e),e){const r=utils.findKey(this,e);return!!(r&&this[r]!==void 0&&(!a||matchHeaderValue(this,this[r],r,a)))}return!1}delete(e,a){const r=this;let n=!1;function i(o){if(o=normalizeHeader(o),o){const s=utils.findKey(r,o);s&&(!a||matchHeaderValue(r,r[s],s,a))&&(delete r[s],n=!0)}}return utils.isArray(e)?e.forEach(i):i(e),n}clear(e){const a=Object.keys(this);let r=a.length,n=!1;for(;r--;){const i=a[r];(!e||matchHeaderValue(this,this[i],i,e,!0))&&(delete this[i],n=!0)}return n}normalize(e){const a=this,r={};return utils.forEach(this,(n,i)=>{const o=utils.findKey(r,i);if(o){a[o]=normalizeValue(n),delete a[i];return}const s=e?formatHeader(i):String(i).trim();s!==i&&delete a[i],a[s]=normalizeValue(n),r[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const a=Object.create(null);return utils.forEach(this,(r,n)=>{r!=null&&r!==!1&&(a[n]=e&&utils.isArray(r)?r.join(", "):r)}),a}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,a])=>e+": "+a).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...a){const r=new this(e);return a.forEach(n=>r.set(n)),r}static accessor(e){const r=(this[$internals]=this[$internals]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=normalizeHeader(o);r[s]||(buildAccessors(n,o),r[s]=!0)}return utils.isArray(e)?e.forEach(i):i(e),this}}AxiosHeaders.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);utils.reduceDescriptors(AxiosHeaders.prototype,({value:t},e)=>{let a=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[a]=r}}});utils.freezeMethods(AxiosHeaders);const AxiosHeaders$1=AxiosHeaders;function transformData(t,e){const a=this||defaults$1,r=e||a,n=AxiosHeaders$1.from(r.headers);let i=r.data;return utils.forEach(t,function(s){i=s.call(a,i,n.normalize(),e?e.status:void 0)}),n.normalize(),i}function isCancel(t){return!!(t&&t.__CANCEL__)}function CanceledError(t,e,a){AxiosError.call(this,t??"canceled",AxiosError.ERR_CANCELED,e,a),this.name="CanceledError"}utils.inherits(CanceledError,AxiosError,{__CANCEL__:!0});function settle(t,e,a){const r=a.config.validateStatus;!a.status||!r||r(a.status)?t(a):e(new AxiosError("Request failed with status code "+a.status,[AxiosError.ERR_BAD_REQUEST,AxiosError.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}const cookies=platform.isStandardBrowserEnv?function(){return{write:function(a,r,n,i,o,s){const u=[];u.push(a+"="+encodeURIComponent(r)),utils.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),utils.isString(i)&&u.push("path="+i),utils.isString(o)&&u.push("domain="+o),s===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(a){const r=document.cookie.match(new RegExp("(^|;\\s*)("+a+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(a){this.write(a,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function isAbsoluteURL(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function combineURLs(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}function buildFullPath(t,e){return t&&!isAbsoluteURL(e)?combineURLs(t,e):e}const isURLSameOrigin=platform.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),a=document.createElement("a");let r;function n(i){let o=i;return e&&(a.setAttribute("href",o),o=a.href),a.setAttribute("href",o),{href:a.href,protocol:a.protocol?a.protocol.replace(/:$/,""):"",host:a.host,search:a.search?a.search.replace(/^\?/,""):"",hash:a.hash?a.hash.replace(/^#/,""):"",hostname:a.hostname,port:a.port,pathname:a.pathname.charAt(0)==="/"?a.pathname:"/"+a.pathname}}return r=n(window.location.href),function(o){const s=utils.isString(o)?n(o):o;return s.protocol===r.protocol&&s.host===r.host}}():function(){return function(){return!0}}();function parseProtocol(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function speedometer(t,e){t=t||10;const a=new Array(t),r=new Array(t);let n=0,i=0,o;return e=e!==void 0?e:1e3,function(u){const c=Date.now(),l=r[i];o||(o=c),a[n]=u,r[n]=c;let p=i,v=0;for(;p!==n;)v+=a[p++],p=p%t;if(n=(n+1)%t,n===i&&(i=(i+1)%t),c-o{const i=n.loaded,o=n.lengthComputable?n.total:void 0,s=i-a,u=r(s),c=i<=o;a=i;const l={loaded:i,total:o,progress:o?i/o:void 0,bytes:s,rate:u||void 0,estimated:u&&o&&c?(o-i)/u:void 0,event:n};l[e?"download":"upload"]=!0,t(l)}}const isXHRAdapterSupported=typeof XMLHttpRequest<"u",xhrAdapter=isXHRAdapterSupported&&function(t){return new Promise(function(a,r){let n=t.data;const i=AxiosHeaders$1.from(t.headers).normalize(),o=t.responseType;let s;function u(){t.cancelToken&&t.cancelToken.unsubscribe(s),t.signal&&t.signal.removeEventListener("abort",s)}let c;utils.isFormData(n)&&(platform.isStandardBrowserEnv||platform.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.getContentType(/^\s*multipart\/form-data/)?utils.isString(c=i.getContentType())&&i.setContentType(c.replace(/^\s*(multipart\/form-data);+/,"$1")):i.setContentType("multipart/form-data"));let l=new XMLHttpRequest;if(t.auth){const T=t.auth.username||"",O=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";i.set("Authorization","Basic "+btoa(T+":"+O))}const p=buildFullPath(t.baseURL,t.url);l.open(t.method.toUpperCase(),buildURL(p,t.params,t.paramsSerializer),!0),l.timeout=t.timeout;function v(){if(!l)return;const T=AxiosHeaders$1.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders()),M={data:!o||o==="text"||o==="json"?l.responseText:l.response,status:l.status,statusText:l.statusText,headers:T,config:t,request:l};settle(function(w){a(w),u()},function(w){r(w),u()},M),l=null}if("onloadend"in l?l.onloadend=v:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(v)},l.onabort=function(){l&&(r(new AxiosError("Request aborted",AxiosError.ECONNABORTED,t,l)),l=null)},l.onerror=function(){r(new AxiosError("Network Error",AxiosError.ERR_NETWORK,t,l)),l=null},l.ontimeout=function(){let O=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";const M=t.transitional||transitionalDefaults;t.timeoutErrorMessage&&(O=t.timeoutErrorMessage),r(new AxiosError(O,M.clarifyTimeoutError?AxiosError.ETIMEDOUT:AxiosError.ECONNABORTED,t,l)),l=null},platform.isStandardBrowserEnv){const T=(t.withCredentials||isURLSameOrigin(p))&&t.xsrfCookieName&&cookies.read(t.xsrfCookieName);T&&i.set(t.xsrfHeaderName,T)}n===void 0&&i.setContentType(null),"setRequestHeader"in l&&utils.forEach(i.toJSON(),function(O,M){l.setRequestHeader(M,O)}),utils.isUndefined(t.withCredentials)||(l.withCredentials=!!t.withCredentials),o&&o!=="json"&&(l.responseType=t.responseType),typeof t.onDownloadProgress=="function"&&l.addEventListener("progress",progressEventReducer(t.onDownloadProgress,!0)),typeof t.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",progressEventReducer(t.onUploadProgress)),(t.cancelToken||t.signal)&&(s=T=>{l&&(r(!T||T.type?new CanceledError(null,t,l):T),l.abort(),l=null)},t.cancelToken&&t.cancelToken.subscribe(s),t.signal&&(t.signal.aborted?s():t.signal.addEventListener("abort",s)));const S=parseProtocol(p);if(S&&platform.protocols.indexOf(S)===-1){r(new AxiosError("Unsupported protocol "+S+":",AxiosError.ERR_BAD_REQUEST,t));return}l.send(n||null)})},knownAdapters={http:httpAdapter,xhr:xhrAdapter};utils.forEach(knownAdapters,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const renderReason=t=>`- ${t}`,isResolvedHandle=t=>utils.isFunction(t)||t===null||t===!1,adapters={getAdapter:t=>{t=utils.isArray(t)?t:[t];const{length:e}=t;let a,r;const n={};for(let i=0;i`adapter ${s} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since : +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...a){const r=new this(e);return a.forEach(n=>r.set(n)),r}static accessor(e){const r=(this[$internals]=this[$internals]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=normalizeHeader(o);r[s]||(buildAccessors(n,o),r[s]=!0)}return utils.isArray(e)?e.forEach(i):i(e),this}}AxiosHeaders.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);utils.reduceDescriptors(AxiosHeaders.prototype,({value:t},e)=>{let a=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[a]=r}}});utils.freezeMethods(AxiosHeaders);const AxiosHeaders$1=AxiosHeaders;function transformData(t,e){const a=this||defaults$1,r=e||a,n=AxiosHeaders$1.from(r.headers);let i=r.data;return utils.forEach(t,function(s){i=s.call(a,i,n.normalize(),e?e.status:void 0)}),n.normalize(),i}function isCancel(t){return!!(t&&t.__CANCEL__)}function CanceledError(t,e,a){AxiosError.call(this,t??"canceled",AxiosError.ERR_CANCELED,e,a),this.name="CanceledError"}utils.inherits(CanceledError,AxiosError,{__CANCEL__:!0});function settle(t,e,a){const r=a.config.validateStatus;!a.status||!r||r(a.status)?t(a):e(new AxiosError("Request failed with status code "+a.status,[AxiosError.ERR_BAD_REQUEST,AxiosError.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}const cookies=platform.isStandardBrowserEnv?function(){return{write:function(a,r,n,i,o,s){const u=[];u.push(a+"="+encodeURIComponent(r)),utils.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),utils.isString(i)&&u.push("path="+i),utils.isString(o)&&u.push("domain="+o),s===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(a){const r=document.cookie.match(new RegExp("(^|;\\s*)("+a+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(a){this.write(a,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function isAbsoluteURL(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function combineURLs(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}function buildFullPath(t,e){return t&&!isAbsoluteURL(e)?combineURLs(t,e):e}const isURLSameOrigin=platform.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),a=document.createElement("a");let r;function n(i){let o=i;return e&&(a.setAttribute("href",o),o=a.href),a.setAttribute("href",o),{href:a.href,protocol:a.protocol?a.protocol.replace(/:$/,""):"",host:a.host,search:a.search?a.search.replace(/^\?/,""):"",hash:a.hash?a.hash.replace(/^#/,""):"",hostname:a.hostname,port:a.port,pathname:a.pathname.charAt(0)==="/"?a.pathname:"/"+a.pathname}}return r=n(window.location.href),function(o){const s=utils.isString(o)?n(o):o;return s.protocol===r.protocol&&s.host===r.host}}():function(){return function(){return!0}}();function parseProtocol(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function speedometer(t,e){t=t||10;const a=new Array(t),r=new Array(t);let n=0,i=0,o;return e=e!==void 0?e:1e3,function(u){const c=Date.now(),l=r[i];o||(o=c),a[n]=u,r[n]=c;let p=i,v=0;for(;p!==n;)v+=a[p++],p=p%t;if(n=(n+1)%t,n===i&&(i=(i+1)%t),c-o{const i=n.loaded,o=n.lengthComputable?n.total:void 0,s=i-a,u=r(s),c=i<=o;a=i;const l={loaded:i,total:o,progress:o?i/o:void 0,bytes:s,rate:u||void 0,estimated:u&&o&&c?(o-i)/u:void 0,event:n};l[e?"download":"upload"]=!0,t(l)}}const isXHRAdapterSupported=typeof XMLHttpRequest<"u",xhrAdapter=isXHRAdapterSupported&&function(t){return new Promise(function(a,r){let n=t.data;const i=AxiosHeaders$1.from(t.headers).normalize(),o=t.responseType;let s;function u(){t.cancelToken&&t.cancelToken.unsubscribe(s),t.signal&&t.signal.removeEventListener("abort",s)}let c;utils.isFormData(n)&&(platform.isStandardBrowserEnv||platform.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.getContentType(/^\s*multipart\/form-data/)?utils.isString(c=i.getContentType())&&i.setContentType(c.replace(/^\s*(multipart\/form-data);+/,"$1")):i.setContentType("multipart/form-data"));let l=new XMLHttpRequest;if(t.auth){const T=t.auth.username||"",O=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";i.set("Authorization","Basic "+btoa(T+":"+O))}const p=buildFullPath(t.baseURL,t.url);l.open(t.method.toUpperCase(),buildURL(p,t.params,t.paramsSerializer),!0),l.timeout=t.timeout;function v(){if(!l)return;const T=AxiosHeaders$1.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders()),M={data:!o||o==="text"||o==="json"?l.responseText:l.response,status:l.status,statusText:l.statusText,headers:T,config:t,request:l};settle(function(w){a(w),u()},function(w){r(w),u()},M),l=null}if("onloadend"in l?l.onloadend=v:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(v)},l.onabort=function(){l&&(r(new AxiosError("Request aborted",AxiosError.ECONNABORTED,t,l)),l=null)},l.onerror=function(){r(new AxiosError("Network Error",AxiosError.ERR_NETWORK,t,l)),l=null},l.ontimeout=function(){let O=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";const M=t.transitional||transitionalDefaults;t.timeoutErrorMessage&&(O=t.timeoutErrorMessage),r(new AxiosError(O,M.clarifyTimeoutError?AxiosError.ETIMEDOUT:AxiosError.ECONNABORTED,t,l)),l=null},platform.isStandardBrowserEnv){const T=isURLSameOrigin(p)&&t.xsrfCookieName&&cookies.read(t.xsrfCookieName);T&&i.set(t.xsrfHeaderName,T)}n===void 0&&i.setContentType(null),"setRequestHeader"in l&&utils.forEach(i.toJSON(),function(O,M){l.setRequestHeader(M,O)}),utils.isUndefined(t.withCredentials)||(l.withCredentials=!!t.withCredentials),o&&o!=="json"&&(l.responseType=t.responseType),typeof t.onDownloadProgress=="function"&&l.addEventListener("progress",progressEventReducer(t.onDownloadProgress,!0)),typeof t.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",progressEventReducer(t.onUploadProgress)),(t.cancelToken||t.signal)&&(s=T=>{l&&(r(!T||T.type?new CanceledError(null,t,l):T),l.abort(),l=null)},t.cancelToken&&t.cancelToken.subscribe(s),t.signal&&(t.signal.aborted?s():t.signal.addEventListener("abort",s)));const S=parseProtocol(p);if(S&&platform.protocols.indexOf(S)===-1){r(new AxiosError("Unsupported protocol "+S+":",AxiosError.ERR_BAD_REQUEST,t));return}l.send(n||null)})},knownAdapters={http:httpAdapter,xhr:xhrAdapter};utils.forEach(knownAdapters,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const renderReason=t=>`- ${t}`,isResolvedHandle=t=>utils.isFunction(t)||t===null||t===!1,adapters={getAdapter:t=>{t=utils.isArray(t)?t:[t];const{length:e}=t;let a,r;const n={};for(let i=0;i`adapter ${s} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since : `+i.map(renderReason).join(` -`):" "+renderReason(i[0]):"as no adapter specified";throw new AxiosError("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r},adapters:knownAdapters};function throwIfCancellationRequested(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new CanceledError(null,t)}function dispatchRequest(t){return throwIfCancellationRequested(t),t.headers=AxiosHeaders$1.from(t.headers),t.data=transformData.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),adapters.getAdapter(t.adapter||defaults$1.adapter)(t).then(function(r){return throwIfCancellationRequested(t),r.data=transformData.call(t,t.transformResponse,r),r.headers=AxiosHeaders$1.from(r.headers),r},function(r){return isCancel(r)||(throwIfCancellationRequested(t),r&&r.response&&(r.response.data=transformData.call(t,t.transformResponse,r.response),r.response.headers=AxiosHeaders$1.from(r.response.headers))),Promise.reject(r)})}const headersToObject=t=>t instanceof AxiosHeaders$1?t.toJSON():t;function mergeConfig(t,e){e=e||{};const a={};function r(c,l,p){return utils.isPlainObject(c)&&utils.isPlainObject(l)?utils.merge.call({caseless:p},c,l):utils.isPlainObject(l)?utils.merge({},l):utils.isArray(l)?l.slice():l}function n(c,l,p){if(utils.isUndefined(l)){if(!utils.isUndefined(c))return r(void 0,c,p)}else return r(c,l,p)}function i(c,l){if(!utils.isUndefined(l))return r(void 0,l)}function o(c,l){if(utils.isUndefined(l)){if(!utils.isUndefined(c))return r(void 0,c)}else return r(void 0,l)}function s(c,l,p){if(p in e)return r(c,l);if(p in t)return r(void 0,c)}const u={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(c,l)=>n(headersToObject(c),headersToObject(l),!0)};return utils.forEach(Object.keys(Object.assign({},t,e)),function(l){const p=u[l]||n,v=p(t[l],e[l],l);utils.isUndefined(v)&&p!==s||(a[l]=v)}),a}const VERSION$1="1.5.1",validators$1={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{validators$1[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const deprecatedWarnings={};validators$1.transitional=function(e,a,r){function n(i,o){return"[Axios v"+VERSION$1+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new AxiosError(n(o," has been removed"+(a?" in "+a:"")),AxiosError.ERR_DEPRECATED);return a&&!deprecatedWarnings[o]&&(deprecatedWarnings[o]=!0,console.warn(n(o," has been deprecated since v"+a+" and will be removed in the near future"))),e?e(i,o,s):!0}};function assertOptions(t,e,a){if(typeof t!="object")throw new AxiosError("options must be an object",AxiosError.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let n=r.length;for(;n-- >0;){const i=r[n],o=e[i];if(o){const s=t[i],u=s===void 0||o(s,i,t);if(u!==!0)throw new AxiosError("option "+i+" must be "+u,AxiosError.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new AxiosError("Unknown option "+i,AxiosError.ERR_BAD_OPTION)}}const validator={assertOptions,validators:validators$1},validators=validator.validators;class Axios{constructor(e){this.defaults=e,this.interceptors={request:new InterceptorManager$1,response:new InterceptorManager$1}}request(e,a){typeof e=="string"?(a=a||{},a.url=e):a=e||{},a=mergeConfig(this.defaults,a);const{transitional:r,paramsSerializer:n,headers:i}=a;r!==void 0&&validator.assertOptions(r,{silentJSONParsing:validators.transitional(validators.boolean),forcedJSONParsing:validators.transitional(validators.boolean),clarifyTimeoutError:validators.transitional(validators.boolean)},!1),n!=null&&(utils.isFunction(n)?a.paramsSerializer={serialize:n}:validator.assertOptions(n,{encode:validators.function,serialize:validators.function},!0)),a.method=(a.method||this.defaults.method||"get").toLowerCase();let o=i&&utils.merge(i.common,i[a.method]);i&&utils.forEach(["delete","get","head","post","put","patch","common"],T=>{delete i[T]}),a.headers=AxiosHeaders$1.concat(o,i);const s=[];let u=!0;this.interceptors.request.forEach(function(O){typeof O.runWhen=="function"&&O.runWhen(a)===!1||(u=u&&O.synchronous,s.unshift(O.fulfilled,O.rejected))});const c=[];this.interceptors.response.forEach(function(O){c.push(O.fulfilled,O.rejected)});let l,p=0,v;if(!u){const T=[dispatchRequest.bind(this),void 0];for(T.unshift.apply(T,s),T.push.apply(T,c),v=T.length,l=Promise.resolve(a);p{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](n);r._listeners=null}),this.promise.then=n=>{let i;const o=new Promise(s=>{r.subscribe(s),i=s}).then(n);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,s){r.reason||(r.reason=new CanceledError(i,o,s),a(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const a=this._listeners.indexOf(e);a!==-1&&this._listeners.splice(a,1)}static source(){let e;return{token:new CancelToken(function(n){e=n}),cancel:e}}}const CancelToken$1=CancelToken;function spread(t){return function(a){return t.apply(null,a)}}function isAxiosError(t){return utils.isObject(t)&&t.isAxiosError===!0}const HttpStatusCode={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(HttpStatusCode).forEach(([t,e])=>{HttpStatusCode[e]=t});const HttpStatusCode$1=HttpStatusCode;function createInstance(t){const e=new Axios$1(t),a=bind$4(Axios$1.prototype.request,e);return utils.extend(a,Axios$1.prototype,e,{allOwnKeys:!0}),utils.extend(a,e,null,{allOwnKeys:!0}),a.create=function(n){return createInstance(mergeConfig(t,n))},a}const axios=createInstance(defaults$1);axios.Axios=Axios$1;axios.CanceledError=CanceledError;axios.CancelToken=CancelToken$1;axios.isCancel=isCancel;axios.VERSION=VERSION$1;axios.toFormData=toFormData;axios.AxiosError=AxiosError;axios.Cancel=axios.CanceledError;axios.all=function(e){return Promise.all(e)};axios.spread=spread;axios.isAxiosError=isAxiosError;axios.mergeConfig=mergeConfig;axios.AxiosHeaders=AxiosHeaders$1;axios.formToJSON=t=>formDataToJSON(utils.isHTMLForm(t)?new FormData(t):t);axios.getAdapter=adapters.getAdapter;axios.HttpStatusCode=HttpStatusCode$1;axios.default=axios;const axios$1=axios;var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var assign=make_assign(),create$2=make_create(),trim$1=make_trim(),Global$5=typeof window<"u"?window:commonjsGlobal,util$7={assign,create:create$2,trim:trim$1,bind:bind$3,slice:slice$2,each:each$8,map,pluck:pluck$1,isList:isList$1,isFunction:isFunction$4,isObject:isObject$a,Global:Global$5};function make_assign(){return Object.assign?Object.assign:function(e,a,r,n){for(var i=1;i"u"?null:console;if(t){var e=t.warn?t.warn:t.log;e.apply(t,arguments)}}function createStore(t,e,a){a||(a=""),t&&!isList(t)&&(t=[t]),e&&!isList(e)&&(e=[e]);var r=a?"__storejs_"+a+"_":"",n=a?new RegExp("^"+r):null,i=/^[a-zA-Z0-9_\-]*$/;if(!i.test(a))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var o={_namespacePrefix:r,_namespaceRegexp:n,_testStorage:function(u){try{var c="__storejs__test__";u.write(c,c);var l=u.read(c)===c;return u.remove(c),l}catch{return!1}},_assignPluginFnProp:function(u,c){var l=this[c];this[c]=function(){var v=slice$1(arguments,0),S=this;function T(){if(l)return each$7(arguments,function(M,C){v[C]=M}),l.apply(S,v)}var O=[T].concat(v);return u.apply(S,O)}},_serialize:function(u){return JSON.stringify(u)},_deserialize:function(u,c){if(!u)return c;var l="";try{l=JSON.parse(u)}catch{l=u}return l!==void 0?l:c},_addStorage:function(u){this.enabled||this._testStorage(u)&&(this.storage=u,this.enabled=!0)},_addPlugin:function(u){var c=this;if(isList(u)){each$7(u,function(v){c._addPlugin(v)});return}var l=pluck(this.plugins,function(v){return u===v});if(!l){if(this.plugins.push(u),!isFunction$3(u))throw new Error("Plugins must be function values that return objects");var p=u.call(this);if(!isObject$9(p))throw new Error("Plugins must return an object of function properties");each$7(p,function(v,S){if(!isFunction$3(v))throw new Error("Bad plugin property: "+S+" from plugin "+u.name+". Plugins should only return functions.");c._assignPluginFnProp(v,S)})}},addStorage:function(u){_warn("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(u)}},s=create$1(o,storeAPI,{plugins:[]});return s.raw={},each$7(s,function(u,c){isFunction$3(u)&&(s.raw[c]=bind$2(s,u))}),each$7(t,function(u){s._addStorage(u)}),each$7(e,function(u){s._addPlugin(u)}),s}var util$5=util$7,Global$4=util$5.Global,localStorage_1={name:"localStorage",read:read$6,write:write$6,each:each$6,remove:remove$5,clearAll:clearAll$5};function localStorage(){return Global$4.localStorage}function read$6(t){return localStorage().getItem(t)}function write$6(t,e){return localStorage().setItem(t,e)}function each$6(t){for(var e=localStorage().length-1;e>=0;e--){var a=localStorage().key(e);t(read$6(a),a)}}function remove$5(t){return localStorage().removeItem(t)}function clearAll$5(){return localStorage().clear()}var util$4=util$7,Global$3=util$4.Global,oldFFGlobalStorage={name:"oldFF-globalStorage",read:read$5,write:write$5,each:each$5,remove:remove$4,clearAll:clearAll$4},globalStorage=Global$3.globalStorage;function read$5(t){return globalStorage[t]}function write$5(t,e){globalStorage[t]=e}function each$5(t){for(var e=globalStorage.length-1;e>=0;e--){var a=globalStorage.key(e);t(globalStorage[a],a)}}function remove$4(t){return globalStorage.removeItem(t)}function clearAll$4(){each$5(function(t,e){delete globalStorage[t]})}var util$3=util$7,Global$2=util$3.Global,oldIEUserDataStorage={name:"oldIE-userDataStorage",write:write$4,read:read$4,each:each$4,remove:remove$3,clearAll:clearAll$3},storageName="storejs",doc$1=Global$2.document,_withStorageEl=_makeIEStorageElFunction(),disable=(Global$2.navigator?Global$2.navigator.userAgent:"").match(/ (MSIE 8|MSIE 9|MSIE 10)\./);function write$4(t,e){if(!disable){var a=fixKey(t);_withStorageEl(function(r){r.setAttribute(a,e),r.save(storageName)})}}function read$4(t){if(!disable){var e=fixKey(t),a=null;return _withStorageEl(function(r){a=r.getAttribute(e)}),a}}function each$4(t){_withStorageEl(function(e){for(var a=e.XMLDocument.documentElement.attributes,r=a.length-1;r>=0;r--){var n=a[r];t(e.getAttribute(n.name),n.name)}})}function remove$3(t){var e=fixKey(t);_withStorageEl(function(a){a.removeAttribute(e),a.save(storageName)})}function clearAll$3(){_withStorageEl(function(t){var e=t.XMLDocument.documentElement.attributes;t.load(storageName);for(var a=e.length-1;a>=0;a--)t.removeAttribute(e[a].name);t.save(storageName)})}var forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function fixKey(t){return t.replace(/^\d/,"___$&").replace(forbiddenCharsRegex,"___")}function _makeIEStorageElFunction(){if(!doc$1||!doc$1.documentElement||!doc$1.documentElement.addBehavior)return null;var t="script",e,a,r;try{a=new ActiveXObject("htmlfile"),a.open(),a.write("<"+t+">document.w=window'),a.close(),e=a.w.frames[0].document,r=e.createElement("div")}catch{r=doc$1.createElement("div"),e=doc$1.body}return function(n){var i=[].slice.call(arguments,0);i.unshift(r),e.appendChild(r),r.addBehavior("#default#userData"),r.load(storageName),n.apply(this,i),e.removeChild(r)}}var util$2=util$7,Global$1=util$2.Global,trim=util$2.trim,cookieStorage={name:"cookieStorage",read:read$3,write:write$3,each:each$3,remove:remove$2,clearAll:clearAll$2},doc=Global$1.document;function read$3(t){if(!t||!_has(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(doc.cookie.replace(new RegExp(e),"$1"))}function each$3(t){for(var e=doc.cookie.split(/; ?/g),a=e.length-1;a>=0;a--)if(trim(e[a])){var r=e[a].split("="),n=unescape(r[0]),i=unescape(r[1]);t(i,n)}}function write$3(t,e){t&&(doc.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/")}function remove$2(t){!t||!_has(t)||(doc.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function clearAll$2(){each$3(function(t,e){remove$2(e)})}function _has(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(doc.cookie)}var util$1=util$7,Global=util$1.Global,sessionStorage_1={name:"sessionStorage",read:read$2,write:write$2,each:each$2,remove:remove$1,clearAll:clearAll$1};function sessionStorage(){return Global.sessionStorage}function read$2(t){return sessionStorage().getItem(t)}function write$2(t,e){return sessionStorage().setItem(t,e)}function each$2(t){for(var e=sessionStorage().length-1;e>=0;e--){var a=sessionStorage().key(e);t(read$2(a),a)}}function remove$1(t){return sessionStorage().removeItem(t)}function clearAll$1(){return sessionStorage().clear()}var memoryStorage_1={name:"memoryStorage",read:read$1,write:write$1,each:each$1,remove,clearAll},memoryStorage={};function read$1(t){return memoryStorage[t]}function write$1(t,e){memoryStorage[t]=e}function each$1(t){for(var e in memoryStorage)memoryStorage.hasOwnProperty(e)&&t(memoryStorage[e],e)}function remove(t){delete memoryStorage[t]}function clearAll(t){memoryStorage={}}var all=[localStorage_1,oldFFGlobalStorage,oldIEUserDataStorage,cookieStorage,sessionStorage_1,memoryStorage_1],json2$1={},hasRequiredJson2;function requireJson2(){return hasRequiredJson2||(hasRequiredJson2=1,typeof JSON!="object"&&(JSON={}),function(){var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;function f(t){return t<10?"0"+t:t}function this_value(){return this.valueOf()}typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value);var gap,indent,meta,rep;function quote(t){return rx_escapable.lastIndex=0,rx_escapable.test(t)?'"'+t.replace(rx_escapable,function(e){var a=meta[e];return typeof a=="string"?a:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function str(t,e){var a,r,n,i,o=gap,s,u=e[t];switch(u&&typeof u=="object"&&typeof u.toJSON=="function"&&(u=u.toJSON(t)),typeof rep=="function"&&(u=rep.call(e,t,u)),typeof u){case"string":return quote(u);case"number":return isFinite(u)?String(u):"null";case"boolean":case"null":return String(u);case"object":if(!u)return"null";if(gap+=indent,s=[],Object.prototype.toString.apply(u)==="[object Array]"){for(i=u.length,a=0;at instanceof AxiosHeaders$1?t.toJSON():t;function mergeConfig(t,e){e=e||{};const a={};function r(c,l,p){return utils.isPlainObject(c)&&utils.isPlainObject(l)?utils.merge.call({caseless:p},c,l):utils.isPlainObject(l)?utils.merge({},l):utils.isArray(l)?l.slice():l}function n(c,l,p){if(utils.isUndefined(l)){if(!utils.isUndefined(c))return r(void 0,c,p)}else return r(c,l,p)}function i(c,l){if(!utils.isUndefined(l))return r(void 0,l)}function o(c,l){if(utils.isUndefined(l)){if(!utils.isUndefined(c))return r(void 0,c)}else return r(void 0,l)}function s(c,l,p){if(p in e)return r(c,l);if(p in t)return r(void 0,c)}const u={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(c,l)=>n(headersToObject(c),headersToObject(l),!0)};return utils.forEach(Object.keys(Object.assign({},t,e)),function(l){const p=u[l]||n,v=p(t[l],e[l],l);utils.isUndefined(v)&&p!==s||(a[l]=v)}),a}const VERSION$1="1.6.0",validators$1={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{validators$1[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const deprecatedWarnings={};validators$1.transitional=function(e,a,r){function n(i,o){return"[Axios v"+VERSION$1+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new AxiosError(n(o," has been removed"+(a?" in "+a:"")),AxiosError.ERR_DEPRECATED);return a&&!deprecatedWarnings[o]&&(deprecatedWarnings[o]=!0,console.warn(n(o," has been deprecated since v"+a+" and will be removed in the near future"))),e?e(i,o,s):!0}};function assertOptions(t,e,a){if(typeof t!="object")throw new AxiosError("options must be an object",AxiosError.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let n=r.length;for(;n-- >0;){const i=r[n],o=e[i];if(o){const s=t[i],u=s===void 0||o(s,i,t);if(u!==!0)throw new AxiosError("option "+i+" must be "+u,AxiosError.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new AxiosError("Unknown option "+i,AxiosError.ERR_BAD_OPTION)}}const validator={assertOptions,validators:validators$1},validators=validator.validators;class Axios{constructor(e){this.defaults=e,this.interceptors={request:new InterceptorManager$1,response:new InterceptorManager$1}}request(e,a){typeof e=="string"?(a=a||{},a.url=e):a=e||{},a=mergeConfig(this.defaults,a);const{transitional:r,paramsSerializer:n,headers:i}=a;r!==void 0&&validator.assertOptions(r,{silentJSONParsing:validators.transitional(validators.boolean),forcedJSONParsing:validators.transitional(validators.boolean),clarifyTimeoutError:validators.transitional(validators.boolean)},!1),n!=null&&(utils.isFunction(n)?a.paramsSerializer={serialize:n}:validator.assertOptions(n,{encode:validators.function,serialize:validators.function},!0)),a.method=(a.method||this.defaults.method||"get").toLowerCase();let o=i&&utils.merge(i.common,i[a.method]);i&&utils.forEach(["delete","get","head","post","put","patch","common"],T=>{delete i[T]}),a.headers=AxiosHeaders$1.concat(o,i);const s=[];let u=!0;this.interceptors.request.forEach(function(O){typeof O.runWhen=="function"&&O.runWhen(a)===!1||(u=u&&O.synchronous,s.unshift(O.fulfilled,O.rejected))});const c=[];this.interceptors.response.forEach(function(O){c.push(O.fulfilled,O.rejected)});let l,p=0,v;if(!u){const T=[dispatchRequest.bind(this),void 0];for(T.unshift.apply(T,s),T.push.apply(T,c),v=T.length,l=Promise.resolve(a);p{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](n);r._listeners=null}),this.promise.then=n=>{let i;const o=new Promise(s=>{r.subscribe(s),i=s}).then(n);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,s){r.reason||(r.reason=new CanceledError(i,o,s),a(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const a=this._listeners.indexOf(e);a!==-1&&this._listeners.splice(a,1)}static source(){let e;return{token:new CancelToken(function(n){e=n}),cancel:e}}}const CancelToken$1=CancelToken;function spread(t){return function(a){return t.apply(null,a)}}function isAxiosError(t){return utils.isObject(t)&&t.isAxiosError===!0}const HttpStatusCode={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(HttpStatusCode).forEach(([t,e])=>{HttpStatusCode[e]=t});const HttpStatusCode$1=HttpStatusCode;function createInstance(t){const e=new Axios$1(t),a=bind$4(Axios$1.prototype.request,e);return utils.extend(a,Axios$1.prototype,e,{allOwnKeys:!0}),utils.extend(a,e,null,{allOwnKeys:!0}),a.create=function(n){return createInstance(mergeConfig(t,n))},a}const axios=createInstance(defaults$1);axios.Axios=Axios$1;axios.CanceledError=CanceledError;axios.CancelToken=CancelToken$1;axios.isCancel=isCancel;axios.VERSION=VERSION$1;axios.toFormData=toFormData;axios.AxiosError=AxiosError;axios.Cancel=axios.CanceledError;axios.all=function(e){return Promise.all(e)};axios.spread=spread;axios.isAxiosError=isAxiosError;axios.mergeConfig=mergeConfig;axios.AxiosHeaders=AxiosHeaders$1;axios.formToJSON=t=>formDataToJSON(utils.isHTMLForm(t)?new FormData(t):t);axios.getAdapter=adapters.getAdapter;axios.HttpStatusCode=HttpStatusCode$1;axios.default=axios;const axios$1=axios;var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var assign=make_assign(),create$2=make_create(),trim$1=make_trim(),Global$5=typeof window<"u"?window:commonjsGlobal,util$7={assign,create:create$2,trim:trim$1,bind:bind$3,slice:slice$2,each:each$8,map,pluck:pluck$1,isList:isList$1,isFunction:isFunction$4,isObject:isObject$a,Global:Global$5};function make_assign(){return Object.assign?Object.assign:function(e,a,r,n){for(var i=1;i"u"?null:console;if(t){var e=t.warn?t.warn:t.log;e.apply(t,arguments)}}function createStore(t,e,a){a||(a=""),t&&!isList(t)&&(t=[t]),e&&!isList(e)&&(e=[e]);var r=a?"__storejs_"+a+"_":"",n=a?new RegExp("^"+r):null,i=/^[a-zA-Z0-9_\-]*$/;if(!i.test(a))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var o={_namespacePrefix:r,_namespaceRegexp:n,_testStorage:function(u){try{var c="__storejs__test__";u.write(c,c);var l=u.read(c)===c;return u.remove(c),l}catch{return!1}},_assignPluginFnProp:function(u,c){var l=this[c];this[c]=function(){var v=slice$1(arguments,0),S=this;function T(){if(l)return each$7(arguments,function(M,C){v[C]=M}),l.apply(S,v)}var O=[T].concat(v);return u.apply(S,O)}},_serialize:function(u){return JSON.stringify(u)},_deserialize:function(u,c){if(!u)return c;var l="";try{l=JSON.parse(u)}catch{l=u}return l!==void 0?l:c},_addStorage:function(u){this.enabled||this._testStorage(u)&&(this.storage=u,this.enabled=!0)},_addPlugin:function(u){var c=this;if(isList(u)){each$7(u,function(v){c._addPlugin(v)});return}var l=pluck(this.plugins,function(v){return u===v});if(!l){if(this.plugins.push(u),!isFunction$3(u))throw new Error("Plugins must be function values that return objects");var p=u.call(this);if(!isObject$9(p))throw new Error("Plugins must return an object of function properties");each$7(p,function(v,S){if(!isFunction$3(v))throw new Error("Bad plugin property: "+S+" from plugin "+u.name+". Plugins should only return functions.");c._assignPluginFnProp(v,S)})}},addStorage:function(u){_warn("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(u)}},s=create$1(o,storeAPI,{plugins:[]});return s.raw={},each$7(s,function(u,c){isFunction$3(u)&&(s.raw[c]=bind$2(s,u))}),each$7(t,function(u){s._addStorage(u)}),each$7(e,function(u){s._addPlugin(u)}),s}var util$5=util$7,Global$4=util$5.Global,localStorage_1={name:"localStorage",read:read$6,write:write$6,each:each$6,remove:remove$5,clearAll:clearAll$5};function localStorage(){return Global$4.localStorage}function read$6(t){return localStorage().getItem(t)}function write$6(t,e){return localStorage().setItem(t,e)}function each$6(t){for(var e=localStorage().length-1;e>=0;e--){var a=localStorage().key(e);t(read$6(a),a)}}function remove$5(t){return localStorage().removeItem(t)}function clearAll$5(){return localStorage().clear()}var util$4=util$7,Global$3=util$4.Global,oldFFGlobalStorage={name:"oldFF-globalStorage",read:read$5,write:write$5,each:each$5,remove:remove$4,clearAll:clearAll$4},globalStorage=Global$3.globalStorage;function read$5(t){return globalStorage[t]}function write$5(t,e){globalStorage[t]=e}function each$5(t){for(var e=globalStorage.length-1;e>=0;e--){var a=globalStorage.key(e);t(globalStorage[a],a)}}function remove$4(t){return globalStorage.removeItem(t)}function clearAll$4(){each$5(function(t,e){delete globalStorage[t]})}var util$3=util$7,Global$2=util$3.Global,oldIEUserDataStorage={name:"oldIE-userDataStorage",write:write$4,read:read$4,each:each$4,remove:remove$3,clearAll:clearAll$3},storageName="storejs",doc$1=Global$2.document,_withStorageEl=_makeIEStorageElFunction(),disable=(Global$2.navigator?Global$2.navigator.userAgent:"").match(/ (MSIE 8|MSIE 9|MSIE 10)\./);function write$4(t,e){if(!disable){var a=fixKey(t);_withStorageEl(function(r){r.setAttribute(a,e),r.save(storageName)})}}function read$4(t){if(!disable){var e=fixKey(t),a=null;return _withStorageEl(function(r){a=r.getAttribute(e)}),a}}function each$4(t){_withStorageEl(function(e){for(var a=e.XMLDocument.documentElement.attributes,r=a.length-1;r>=0;r--){var n=a[r];t(e.getAttribute(n.name),n.name)}})}function remove$3(t){var e=fixKey(t);_withStorageEl(function(a){a.removeAttribute(e),a.save(storageName)})}function clearAll$3(){_withStorageEl(function(t){var e=t.XMLDocument.documentElement.attributes;t.load(storageName);for(var a=e.length-1;a>=0;a--)t.removeAttribute(e[a].name);t.save(storageName)})}var forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function fixKey(t){return t.replace(/^\d/,"___$&").replace(forbiddenCharsRegex,"___")}function _makeIEStorageElFunction(){if(!doc$1||!doc$1.documentElement||!doc$1.documentElement.addBehavior)return null;var t="script",e,a,r;try{a=new ActiveXObject("htmlfile"),a.open(),a.write("<"+t+">document.w=window'),a.close(),e=a.w.frames[0].document,r=e.createElement("div")}catch{r=doc$1.createElement("div"),e=doc$1.body}return function(n){var i=[].slice.call(arguments,0);i.unshift(r),e.appendChild(r),r.addBehavior("#default#userData"),r.load(storageName),n.apply(this,i),e.removeChild(r)}}var util$2=util$7,Global$1=util$2.Global,trim=util$2.trim,cookieStorage={name:"cookieStorage",read:read$3,write:write$3,each:each$3,remove:remove$2,clearAll:clearAll$2},doc=Global$1.document;function read$3(t){if(!t||!_has(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(doc.cookie.replace(new RegExp(e),"$1"))}function each$3(t){for(var e=doc.cookie.split(/; ?/g),a=e.length-1;a>=0;a--)if(trim(e[a])){var r=e[a].split("="),n=unescape(r[0]),i=unescape(r[1]);t(i,n)}}function write$3(t,e){t&&(doc.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/")}function remove$2(t){!t||!_has(t)||(doc.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function clearAll$2(){each$3(function(t,e){remove$2(e)})}function _has(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(doc.cookie)}var util$1=util$7,Global=util$1.Global,sessionStorage_1={name:"sessionStorage",read:read$2,write:write$2,each:each$2,remove:remove$1,clearAll:clearAll$1};function sessionStorage(){return Global.sessionStorage}function read$2(t){return sessionStorage().getItem(t)}function write$2(t,e){return sessionStorage().setItem(t,e)}function each$2(t){for(var e=sessionStorage().length-1;e>=0;e--){var a=sessionStorage().key(e);t(read$2(a),a)}}function remove$1(t){return sessionStorage().removeItem(t)}function clearAll$1(){return sessionStorage().clear()}var memoryStorage_1={name:"memoryStorage",read:read$1,write:write$1,each:each$1,remove,clearAll},memoryStorage={};function read$1(t){return memoryStorage[t]}function write$1(t,e){memoryStorage[t]=e}function each$1(t){for(var e in memoryStorage)memoryStorage.hasOwnProperty(e)&&t(memoryStorage[e],e)}function remove(t){delete memoryStorage[t]}function clearAll(t){memoryStorage={}}var all=[localStorage_1,oldFFGlobalStorage,oldIEUserDataStorage,cookieStorage,sessionStorage_1,memoryStorage_1],json2$1={},hasRequiredJson2;function requireJson2(){return hasRequiredJson2||(hasRequiredJson2=1,typeof JSON!="object"&&(JSON={}),function(){var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;function f(t){return t<10?"0"+t:t}function this_value(){return this.valueOf()}typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value);var gap,indent,meta,rep;function quote(t){return rx_escapable.lastIndex=0,rx_escapable.test(t)?'"'+t.replace(rx_escapable,function(e){var a=meta[e];return typeof a=="string"?a:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function str(t,e){var a,r,n,i,o=gap,s,u=e[t];switch(u&&typeof u=="object"&&typeof u.toJSON=="function"&&(u=u.toJSON(t)),typeof rep=="function"&&(u=rep.call(e,t,u)),typeof u){case"string":return quote(u);case"number":return isFinite(u)?String(u):"null";case"boolean":case"null":return String(u);case"object":if(!u)return"null";if(gap+=indent,s=[],Object.prototype.toString.apply(u)==="[object Array]"){for(i=u.length,a=0;alastFlushedIndex&&queue.splice(e,1)}function queueFlush(){!flushing&&!flushPending&&(flushPending=!0,queueMicrotask(flushJobs))}function flushJobs(){flushPending=!1,flushing=!0;for(let t=0;tt.effect(e,{scheduler:a=>{shouldSchedule?scheduler(a):a()}}),raw=t.raw}function overrideEffect(t){effect$3=t}function elementBoundEffect(t){let e=()=>{};return[r=>{let n=effect$3(r);return t._x_effects||(t._x_effects=new Set,t._x_runEffects=()=>{t._x_effects.forEach(i=>i())}),t._x_effects.add(n),e=()=>{n!==void 0&&(t._x_effects.delete(n),release(n))},n},()=>{e()}]}function dispatch(t,e,a={}){t.dispatchEvent(new CustomEvent(e,{detail:a,bubbles:!0,composed:!0,cancelable:!0}))}function walk(t,e){if(typeof ShadowRoot=="function"&&t instanceof ShadowRoot){Array.from(t.children).forEach(n=>walk(n,e));return}let a=!1;if(e(t,()=>a=!0),a)return;let r=t.firstElementChild;for(;r;)walk(r,e),r=r.nextElementSibling}function warn(t,...e){console.warn(`Alpine Warning: ${t}`,...e)}var started=!1;function start$1(){started&&warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),started=!0,document.body||warn("Unable to initialize. Trying to load Alpine before `` is available. Did you forget to add `defer` in Alpine's `