From 1f774e0d71d087c359d30b20ccb7d48578090f40 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 13:48:09 +0000 Subject: [PATCH] Auto commit for release 'develop' on 2024-01-28 --- .../Autocomplete/CategoryController.php | 2 +- composer.lock | 121 +++++++++-------- package-lock.json | 30 ++-- ...{create-622680a3.js => create-9d9f2d53.js} | 2 +- ...9f82.js => create-empty-split-9cc18e2d.js} | 2 +- ...oard-14a83ee8.js => dashboard-4c2936a0.js} | 2 +- .../{edit-65e334e0.js => edit-acae2aeb.js} | 2 +- ...y-0f129d93.js => format-money-e4c435dc.js} | 2 +- .../{get-851d8544.js => get-5236bc21.js} | 2 +- .../{get-d03e8e57.js => get-95250f8d.js} | 2 +- .../{index-f5d59159.js => index-f915662d.js} | 2 +- ...js => parse-downloaded-splits-c0536134.js} | 2 +- .../{show-83afe744.js => show-25e4fff8.js} | 2 +- ...lice-errors-into-transactions-cc4832b4.js} | 2 +- public/build/assets/vendor-76961a66.js | 54 ++++++++ public/build/assets/vendor-baac879b.js | 53 -------- public/build/manifest.json | 128 +++++++++--------- public/v1/js/create_transaction.js | 2 +- public/v1/js/edit_transaction.js | 2 +- public/v1/js/profile.js | 2 +- public/v1/js/webhooks/create.js | 2 +- public/v1/js/webhooks/edit.js | 2 +- public/v1/js/webhooks/index.js | 2 +- public/v1/js/webhooks/show.js | 2 +- public/v2/i18n/ca_ES.json | 4 +- public/v2/i18n/zh_CN.json | 8 +- resources/lang/ca_ES/firefly.php | 6 +- resources/lang/el_GR/firefly.php | 20 +-- resources/lang/zh_CN/email.php | 2 +- resources/lang/zh_CN/errors.php | 2 +- resources/lang/zh_CN/firefly.php | 44 +++--- resources/lang/zh_CN/intro.php | 2 +- resources/lang/zh_CN/rules.php | 4 +- resources/lang/zh_CN/validation.php | 12 +- 34 files changed, 265 insertions(+), 263 deletions(-) rename public/build/assets/{create-622680a3.js => create-9d9f2d53.js} (97%) rename public/build/assets/{create-empty-split-16bf9f82.js => create-empty-split-9cc18e2d.js} (93%) rename public/build/assets/{dashboard-14a83ee8.js => dashboard-4c2936a0.js} (98%) rename public/build/assets/{edit-65e334e0.js => edit-acae2aeb.js} (95%) rename public/build/assets/{format-money-0f129d93.js => format-money-e4c435dc.js} (99%) rename public/build/assets/{get-851d8544.js => get-5236bc21.js} (66%) rename public/build/assets/{get-d03e8e57.js => get-95250f8d.js} (81%) rename public/build/assets/{index-f5d59159.js => index-f915662d.js} (90%) rename public/build/assets/{parse-downloaded-splits-109be2c7.js => parse-downloaded-splits-c0536134.js} (91%) rename public/build/assets/{show-83afe744.js => show-25e4fff8.js} (98%) rename public/build/assets/{splice-errors-into-transactions-cc245990.js => splice-errors-into-transactions-cc4832b4.js} (98%) create mode 100644 public/build/assets/vendor-76961a66.js delete mode 100644 public/build/assets/vendor-baac879b.js diff --git a/app/Api/V1/Controllers/Autocomplete/CategoryController.php b/app/Api/V1/Controllers/Autocomplete/CategoryController.php index 68883a77c3..1baea11df7 100644 --- a/app/Api/V1/Controllers/Autocomplete/CategoryController.php +++ b/app/Api/V1/Controllers/Autocomplete/CategoryController.php @@ -46,7 +46,7 @@ class CategoryController extends Controller $this->middleware( function ($request, $next) { /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); $this->repository = app(CategoryRepositoryInterface::class); $this->repository->setUser($user); diff --git a/composer.lock b/composer.lock index 33a3cd2d9e..60b0f30f84 100644 --- a/composer.lock +++ b/composer.lock @@ -542,16 +542,16 @@ }, { "name": "doctrine/dbal", - "version": "3.7.3", + "version": "3.8.0", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "ce594cbc39a4866c544f1a970d285ff0548221ad" + "reference": "d244f2e6e6bf32bff5174e6729b57214923ecec9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/ce594cbc39a4866c544f1a970d285ff0548221ad", - "reference": "ce594cbc39a4866c544f1a970d285ff0548221ad", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/d244f2e6e6bf32bff5174e6729b57214923ecec9", + "reference": "d244f2e6e6bf32bff5174e6729b57214923ecec9", "shasum": "" }, "require": { @@ -635,7 +635,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.7.3" + "source": "https://github.com/doctrine/dbal/tree/3.8.0" }, "funding": [ { @@ -651,7 +651,7 @@ "type": "tidelift" } ], - "time": "2024-01-21T07:53:09+00:00" + "time": "2024-01-25T21:44:02+00:00" }, { "name": "doctrine/deprecations", @@ -2014,16 +2014,16 @@ }, { "name": "laravel/framework", - "version": "v10.41.0", + "version": "v10.42.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "da31969bd35e6ee0bbcd9e876f88952dc754b012" + "reference": "fef1aff874a6749c44f8e142e5764eab8cb96890" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/da31969bd35e6ee0bbcd9e876f88952dc754b012", - "reference": "da31969bd35e6ee0bbcd9e876f88952dc754b012", + "url": "https://api.github.com/repos/laravel/framework/zipball/fef1aff874a6749c44f8e142e5764eab8cb96890", + "reference": "fef1aff874a6749c44f8e142e5764eab8cb96890", "shasum": "" }, "require": { @@ -2215,20 +2215,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-01-16T15:23:58+00:00" + "time": "2024-01-23T15:07:56+00:00" }, { "name": "laravel/passport", - "version": "v11.10.1", + "version": "v11.10.2", "source": { "type": "git", "url": "https://github.com/laravel/passport.git", - "reference": "e1a651481cabff0ba174aaefbdc04a59e6a096ec" + "reference": "27a4f34aaf8b360eb64f53eb9c555ee50d565560" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/passport/zipball/e1a651481cabff0ba174aaefbdc04a59e6a096ec", - "reference": "e1a651481cabff0ba174aaefbdc04a59e6a096ec", + "url": "https://api.github.com/repos/laravel/passport/zipball/27a4f34aaf8b360eb64f53eb9c555ee50d565560", + "reference": "27a4f34aaf8b360eb64f53eb9c555ee50d565560", "shasum": "" }, "require": { @@ -2293,7 +2293,7 @@ "issues": "https://github.com/laravel/passport/issues", "source": "https://github.com/laravel/passport" }, - "time": "2024-01-10T14:44:24+00:00" + "time": "2024-01-17T14:57:00+00:00" }, { "name": "laravel/prompts", @@ -3075,16 +3075,16 @@ }, { "name": "league/flysystem", - "version": "3.23.0", + "version": "3.23.1", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "d4ad81e2b67396e33dc9d7e54ec74ccf73151dcc" + "reference": "199e1aebbe3e62bd39f4d4fc8c61ce0b3786197e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/d4ad81e2b67396e33dc9d7e54ec74ccf73151dcc", - "reference": "d4ad81e2b67396e33dc9d7e54ec74ccf73151dcc", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/199e1aebbe3e62bd39f4d4fc8c61ce0b3786197e", + "reference": "199e1aebbe3e62bd39f4d4fc8c61ce0b3786197e", "shasum": "" }, "require": { @@ -3149,7 +3149,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.23.0" + "source": "https://github.com/thephpleague/flysystem/tree/3.23.1" }, "funding": [ { @@ -3161,20 +3161,20 @@ "type": "github" } ], - "time": "2023-12-04T10:16:17+00:00" + "time": "2024-01-26T18:42:03+00:00" }, { "name": "league/flysystem-local", - "version": "3.23.0", + "version": "3.23.1", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-local.git", - "reference": "5cf046ba5f059460e86a997c504dd781a39a109b" + "reference": "b884d2bf9b53bb4804a56d2df4902bb51e253f00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/5cf046ba5f059460e86a997c504dd781a39a109b", - "reference": "5cf046ba5f059460e86a997c504dd781a39a109b", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/b884d2bf9b53bb4804a56d2df4902bb51e253f00", + "reference": "b884d2bf9b53bb4804a56d2df4902bb51e253f00", "shasum": "" }, "require": { @@ -3209,7 +3209,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem-local/issues", - "source": "https://github.com/thephpleague/flysystem-local/tree/3.23.0" + "source": "https://github.com/thephpleague/flysystem-local/tree/3.23.1" }, "funding": [ { @@ -3221,7 +3221,7 @@ "type": "github" } ], - "time": "2023-12-04T10:14:46+00:00" + "time": "2024-01-26T18:25:23+00:00" }, { "name": "league/fractal", @@ -3768,16 +3768,16 @@ }, { "name": "nesbot/carbon", - "version": "2.72.1", + "version": "2.72.2", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "2b3b3db0a2d0556a177392ff1a3bf5608fa09f78" + "reference": "3e7edc41b58d65509baeb0d4a14c8fa41d627130" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/2b3b3db0a2d0556a177392ff1a3bf5608fa09f78", - "reference": "2b3b3db0a2d0556a177392ff1a3bf5608fa09f78", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/3e7edc41b58d65509baeb0d4a14c8fa41d627130", + "reference": "3e7edc41b58d65509baeb0d4a14c8fa41d627130", "shasum": "" }, "require": { @@ -3871,35 +3871,35 @@ "type": "tidelift" } ], - "time": "2023-12-08T23:47:49+00:00" + "time": "2024-01-19T00:21:53+00:00" }, { "name": "nette/schema", - "version": "v1.2.5", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/nette/schema.git", - "reference": "0462f0166e823aad657c9224d0f849ecac1ba10a" + "reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/0462f0166e823aad657c9224d0f849ecac1ba10a", - "reference": "0462f0166e823aad657c9224d0f849ecac1ba10a", + "url": "https://api.github.com/repos/nette/schema/zipball/a6d3a6d1f545f01ef38e60f375d1cf1f4de98188", + "reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188", "shasum": "" }, "require": { - "nette/utils": "^2.5.7 || ^3.1.5 || ^4.0", - "php": "7.1 - 8.3" + "nette/utils": "^4.0", + "php": "8.1 - 8.3" }, "require-dev": { - "nette/tester": "^2.3 || ^2.4", + "nette/tester": "^2.4", "phpstan/phpstan-nette": "^1.0", - "tracy/tracy": "^2.7" + "tracy/tracy": "^2.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -3931,9 +3931,9 @@ ], "support": { "issues": "https://github.com/nette/schema/issues", - "source": "https://github.com/nette/schema/tree/v1.2.5" + "source": "https://github.com/nette/schema/tree/v1.3.0" }, - "time": "2023-10-05T20:37:59+00:00" + "time": "2023-12-11T11:54:22+00:00" }, { "name": "nette/utils", @@ -10165,16 +10165,16 @@ }, { "name": "phpmyadmin/sql-parser", - "version": "5.8.2", + "version": "5.9.0", "source": { "type": "git", "url": "https://github.com/phpmyadmin/sql-parser.git", - "reference": "f1720ae19abe6294cb5599594a8a57bc3c8cc287" + "reference": "011fa18a4e55591fac6545a821921dd1d61c6984" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/f1720ae19abe6294cb5599594a8a57bc3c8cc287", - "reference": "f1720ae19abe6294cb5599594a8a57bc3c8cc287", + "url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/011fa18a4e55591fac6545a821921dd1d61c6984", + "reference": "011fa18a4e55591fac6545a821921dd1d61c6984", "shasum": "" }, "require": { @@ -10205,6 +10205,7 @@ "bin": [ "bin/highlight-query", "bin/lint-query", + "bin/sql-parser", "bin/tokenize-query" ], "type": "library", @@ -10248,7 +10249,7 @@ "type": "other" } ], - "time": "2023-09-19T12:34:29+00:00" + "time": "2024-01-20T20:34:02+00:00" }, { "name": "phpstan/extension-installer", @@ -10343,16 +10344,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.56", + "version": "1.10.57", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "27816a01aea996191ee14d010f325434c0ee76fa" + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/27816a01aea996191ee14d010f325434c0ee76fa", - "reference": "27816a01aea996191ee14d010f325434c0ee76fa", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e", + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e", "shasum": "" }, "require": { @@ -10401,7 +10402,7 @@ "type": "tidelift" } ], - "time": "2024-01-15T10:43:00+00:00" + "time": "2024-01-24T11:51:34+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -10823,16 +10824,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.8", + "version": "10.5.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "08f4fa74d5fbfff1ef22abffee47aaedcaea227e" + "reference": "0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/08f4fa74d5fbfff1ef22abffee47aaedcaea227e", - "reference": "08f4fa74d5fbfff1ef22abffee47aaedcaea227e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe", + "reference": "0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe", "shasum": "" }, "require": { @@ -10904,7 +10905,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.8" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.9" }, "funding": [ { @@ -10920,7 +10921,7 @@ "type": "tidelift" } ], - "time": "2024-01-19T07:07:27+00:00" + "time": "2024-01-22T14:35:40+00:00" }, { "name": "sebastian/cli-parser", diff --git a/package-lock.json b/package-lock.json index 178066c2ec..63a5db1658 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,9 +31,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.23.8", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.8.tgz", - "integrity": "sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.9.tgz", + "integrity": "sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw==", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -430,9 +430,9 @@ "integrity": "sha512-oJ4F3TnvpXaQwZJNF3ZK+kLPHKarDmJjJ6jyzVNDKH9md1dptjC7lWR//jrGuLdek/U6iltWxqAnYOu8gCiOvA==" }, "node_modules/alpinejs": { - "version": "3.13.4", - "resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.13.4.tgz", - "integrity": "sha512-+miZp8LXMfZKqi6L0m5TA2fk5Tr2dvxFJ3I0dL78Dz90gTXpdHu4Qhv7PJsRmTGRUWjbYh2e+3DYrB4it2DEHQ==", + "version": "3.13.5", + "resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.13.5.tgz", + "integrity": "sha512-1d2XeNGN+Zn7j4mUAKXtAgdc4/rLeadyTMWeJGXF5DzwawPBxwTiBhFFm6w/Ei8eJxUZeyNWWSD9zknfdz1kEw==", "dependencies": { "@vue/reactivity": "~3.1.1" } @@ -457,9 +457,9 @@ "dev": true }, "node_modules/axios": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz", - "integrity": "sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", + "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", "dev": true, "dependencies": { "follow-redirects": "^1.15.4", @@ -719,9 +719,9 @@ } }, "node_modules/i18next": { - "version": "23.7.18", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.7.18.tgz", - "integrity": "sha512-b9N2KjRCYQNlUvE1Kc83g8knyUkL5NiZQOp9BsTR/v/LXk6Fzz+doOzTg2/826XK28mCgBkYLNAtixjE58qpCw==", + "version": "23.8.0", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.8.0.tgz", + "integrity": "sha512-1H+39doU9dQZrRprpnZ2aZetbX9I1N3bM/YGHN/ZkMJ//wJqrxDEqgI5mmSsh/rglsFBiNxI6UtFZfUO2A6XbA==", "funding": [ { "type": "individual", @@ -765,9 +765,9 @@ } }, "node_modules/immutable": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.4.tgz", - "integrity": "sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.5.tgz", + "integrity": "sha512-8eabxkth9gZatlwl5TBuJnCsoTADlL6ftEr7A4qgdaTsPyreilDSnUk57SO+jfKcNtxPa22U5KK6DSeAYhpBJw==", "dev": true }, "node_modules/is-binary-path": { diff --git a/public/build/assets/create-622680a3.js b/public/build/assets/create-9d9f2d53.js similarity index 97% rename from public/build/assets/create-622680a3.js rename to public/build/assets/create-9d9f2d53.js index dc1a116503..3bfd3315ea 100644 --- a/public/build/assets/create-622680a3.js +++ b/public/build/assets/create-9d9f2d53.js @@ -1 +1 @@ -import{a as m,d as y,f as d}from"./format-money-0f129d93.js";import{d as w,c as b}from"./create-empty-split-16bf9f82.js";import{l as v,a as C,b as T,c as _,p as E,d as P,s as L,e as c,f as S,g as D,h as A,i as x,j as k,k as h,m as p}from"./splice-errors-into-transactions-cc245990.js";import{l,i as r,m as B}from"./vendor-baac879b.js";import"./get-d03e8e57.js";class M{post(t){let s="/api/v2/transactions";return m.post(s,t)}}let n=[],u=[];document.addEventListener("location-remove",e=>{u[e.detail.index].remove()});function O(e){let t=0;if(document.querySelector("#form")._x_dataStack[0].$data.entries[t].hasLocation===!1){u[t]=new l.marker(e.latlng,{draggable:!0}),u[t].on("dragend",U),u[t].addTo(n[t]);const i=new CustomEvent("location-set",{detail:{latitude:e.latlng.lat,longitude:e.latlng.lng,index:t,zoomLevel:n[t].getZoom()}});document.dispatchEvent(i)}}function F(e){let t=0;const s=new CustomEvent("location-zoom",{detail:{index:t,zoomLevel:n[t].getZoom()}});document.dispatchEvent(s)}function U(e){let t=e.target,s=t.getLatLng();t.setLatLng(new l.LatLng(s.lat,s.lng),{draggable:"true"});const i=new CustomEvent("location-move",{detail:{latitude:s.lat,longitude:s.lng,index:0}});document.dispatchEvent(i)}function z(e){if(e>0){console.warn("Corwardly refuse to add a map on split #"+(e+1));return}if(typeof n[e]>"u"){let t=document.getElementById("location_map");t&&(n[e]=l.map(t).setView([t.dataset.latitude,t.dataset.longitude],t.dataset.zoomLevel),l.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png",{maxZoom:19,attribution:'© OpenStreetMap'}).addTo(n[e]),n[e].on("click",O),n[e].on("zoomend",F))}}const a=k();let I=function(){return{entries:[],formStates:{loadingCurrencies:!0,loadingBudgets:!0,loadingPiggyBanks:!0,loadingSubscriptions:!0,isSubmitting:!1,returnHereButton:!1,saveAsNewButton:!1,resetButton:!0,rulesButton:!0,webhooksButton:!0},formBehaviour:{formType:"create",foreignCurrencyEnabled:!0},formData:{defaultCurrency:null,enabledCurrencies:[],nativeCurrencies:[],foreignCurrencies:[],budgets:[],piggyBanks:[],subscriptions:[]},groupProperties:{transactionType:"unknown",title:null,id:null,totalAmount:0},notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},filters:{source:[],destination:[]},changedDateTime(e){console.warn("changedDateTime, event is not used")},changedDescription(e){console.warn("changedDescription, event is not used")},changedDestinationAccount(e){this.detectTransactionType()},changedSourceAccount(e){this.detectTransactionType()},detectTransactionType(){const e=this.entries[0].source_account.type??"unknown",t=this.entries[0].destination_account.type??"unknown";if(e==="unknown"&&t==="unknown"){this.groupProperties.transactionType="unknown",console.warn("Cannot infer transaction type from two unknown accounts.");return}if(e===t&&["Asset account","Loan","Debt","Mortgage"].includes(e)){this.groupProperties.transactionType="transfer",console.log('Transaction type is detected to be "'+this.groupProperties.transactionType+'".'),console.log("filter down currencies for transfer."),this.filterNativeCurrencies(this.entries[0].source_account.currency_code),this.filterForeignCurrencies(this.entries[0].destination_account.currency_code);return}if(e==="Asset account"&&["Expense account","Debt","Loan","Mortgage"].includes(t)){this.groupProperties.transactionType="withdrawal",console.log('[a] Transaction type is detected to be "'+this.groupProperties.transactionType+'".'),this.filterNativeCurrencies(this.entries[0].source_account.currency_code);return}if(e==="Asset account"&&t==="unknown"){this.groupProperties.transactionType="withdrawal",console.log('[b] Transaction type is detected to be "'+this.groupProperties.transactionType+'".'),console.log(this.entries[0].source_account),this.filterNativeCurrencies(this.entries[0].source_account.currency_code);return}if(["Debt","Loan","Mortgage"].includes(e)&&t==="Expense account"){this.groupProperties.transactionType="withdrawal",console.log('[c] Transaction type is detected to be "'+this.groupProperties.transactionType+'".'),this.filterNativeCurrencies(this.entries[0].source_account.currency_code);return}if(e==="Revenue account"&&["Asset account","Debt","Loan","Mortgage"].includes(t)){this.groupProperties.transactionType="deposit",console.log('Transaction type is detected to be "'+this.groupProperties.transactionType+'".');return}if(["Debt","Loan","Mortgage"].includes(e)&&t==="Asset account"){this.groupProperties.transactionType="deposit",console.log('Transaction type is detected to be "'+this.groupProperties.transactionType+'".');return}console.warn('Unknown account combination between "'+e+'" and "'+t+'".')},formattedTotalAmount(){return this.entries.length===0?d(this.groupProperties.totalAmount,"EUR"):d(this.groupProperties.totalAmount,this.entries[0].currency_code??"EUR")},filterForeignCurrencies(e){let t=[],s;for(let i in this.formData.enabledCurrencies)if(this.formData.enabledCurrencies.hasOwnProperty(i)){let o=this.formData.enabledCurrencies[i];o.code===e&&(s=o)}t.push(s),this.formData.foreignCurrencies=t,t.length===1&&t[0].code===this.entries[0].source_account.currency_code&&(console.log("Foreign currency is same as source currency. Disable foreign amount."),this.formBehaviour.foreignCurrencyEnabled=!1),t.length===1&&t[0].code!==this.entries[0].source_account.currency_code&&(console.log("Foreign currency is NOT same as source currency. Enable foreign amount."),this.formBehaviour.foreignCurrencyEnabled=!0);for(let i in this.entries)this.entries.hasOwnProperty(i)&&(this.entries[i].foreign_currency_code=e)},filterNativeCurrencies(e){let t=[],s;for(let i in this.formData.enabledCurrencies)if(this.formData.enabledCurrencies.hasOwnProperty(i)){let o=this.formData.enabledCurrencies[i];o.code===e&&(s=o)}t.push(s),this.formData.nativeCurrencies=t;for(let i in this.entries)this.entries.hasOwnProperty(i)&&(this.entries[i].currency_code=e)},changedAmount(e){const t=parseInt(e.target.dataset.index);this.entries[t].amount=parseFloat(e.target.value),this.groupProperties.totalAmount=0;for(let s in this.entries)this.entries.hasOwnProperty(s)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[s].amount))},addedSplit(){},processUpload(e){this.showMessageOrRedirectUser()},processUploadError(e){this.notifications.success.show=!1,this.notifications.wait.show=!1,this.notifications.error.show=!0,this.formStates.isSubmitting=!1,this.notifications.error.text=r.t("firefly.errors_upload"),console.error(e)},init(){this.addSplit(),v().then(e=>{this.formStates.loadingCurrencies=!1,this.formData.defaultCurrency=e.defaultCurrency,this.formData.enabledCurrencies=e.enabledCurrencies,this.formData.nativeCurrencies=e.nativeCurrencies,this.formData.foreignCurrencies=e.foreignCurrencies}),C().then(e=>{this.formData.budgets=e,this.formStates.loadingBudgets=!1}),T().then(e=>{this.formData.piggyBanks=e,this.formStates.loadingPiggyBanks=!1}),_().then(e=>{this.formData.subscriptions=e,this.formStates.loadingSubscriptions=!1}),document.addEventListener("upload-success",e=>{this.processUpload(e),document.querySelectorAll("input[type=file]").value=""}),document.addEventListener("upload-error",e=>{this.processUploadError(e)}),document.addEventListener("location-move",e=>{this.entries[e.detail.index].latitude=e.detail.latitude,this.entries[e.detail.index].longitude=e.detail.longitude}),document.addEventListener("location-set",e=>{this.entries[e.detail.index].hasLocation=!0,this.entries[e.detail.index].latitude=e.detail.latitude,this.entries[e.detail.index].longitude=e.detail.longitude,this.entries[e.detail.index].zoomLevel=e.detail.zoomLevel}),document.addEventListener("location-zoom",e=>{this.entries[e.detail.index].hasLocation=!0,this.entries[e.detail.index].zoomLevel=e.detail.zoomLevel}),this.filters.source=["Asset account","Loan","Debt","Mortgage","Revenue account"],this.filters.destination=["Expense account","Loan","Debt","Mortgage","Asset account"]},submitTransaction(){this.notifications.error.show=!1,this.notifications.success.show=!1,this.notifications.wait.show=!1;for(let i in this.entries)this.entries.hasOwnProperty(i)&&(this.entries[i].errors=w());this.formStates.isSubmitting=!0,this.detectTransactionType();let e=E(this.entries,null,this.groupProperties.transactionType),t={group_title:this.groupProperties.title,fire_webhooks:this.formStates.webhooksButton,apply_rules:this.formStates.rulesButton,transactions:e};this.groupProperties.title===null&&e.length>1&&(t.group_title=e[0].description);let s=new M;console.log(t),s.post(t).then(i=>{const o=i.data.data;if(this.groupProperties.id=parseInt(o.id),this.groupProperties.title=o.attributes.group_title??o.attributes.transactions[0].description,P(this.groupProperties.id,o.attributes.transactions)>0){this.notifications.wait.show=!0,this.notifications.wait.text=r.t("firefly.wait_attachments");return}this.showMessageOrRedirectUser()}).catch(i=>{this.submitting=!1,console.log(i),typeof i.response<"u"&&this.parseErrors(i.response.data)})},showMessageOrRedirectUser(){if(this.notifications.error.show=!1,this.notifications.success.show=!1,this.notifications.wait.show=!1,this.formStates.returnHereButton){this.notifications.success.show=!0,this.notifications.success.url="transactions/show/"+this.groupProperties.id,this.notifications.success.text=r.t("firefly.stored_journal_js",{description:this.groupProperties.title}),this.formStates.resetButton&&(this.entries=[],this.addSplit(),this.groupProperties.totalAmount=0);return}window.location="transactions/show/"+this.groupProperties.id+"?transaction_group_id="+this.groupProperties.id+"&message=created"},parseErrors(e){this.notifications.error.show=!0,this.notifications.success.show=!1,this.notifications.wait.show=!1,this.formStates.isSubmitting=!1,this.notifications.error.text=r.t("firefly.errors_submission_v2",{errorMessage:e.message}),e.hasOwnProperty("errors")&&(this.entries=L(e.errors,this.entries))},addSplit(){this.entries.push(b()),setTimeout(()=>{B.init("select.ac-tags",{allowClear:!0,server:a.tag,liveServer:!0,clearEnd:!0,allowNew:!0,notFoundMessage:r.t("firefly.nothing_found"),noCache:!0,fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}}});const e=this.entries.length-1;z(e);const t=function(s,i,o){return s.name_with_balance+'
'+r.t("firefly.account_type_"+s.type)+""};c({selector:"input.ac-source",serverUrl:a.account,onChange:S,onSelectItem:D,hiddenValue:this.entries[e].source_account.alpine_name}),c({selector:"input.ac-dest",serverUrl:a.account,filters:this.filters.destination,onRenderItem:t,onChange:A,onSelectItem:x}),c({selector:"input.ac-category",serverUrl:a.category,valueField:"id",labelField:"name",onChange:h,onSelectItem:h}),c({selector:"input.ac-description",serverUrl:a.description,valueField:"id",labelField:"description",onChange:p,onSelectItem:p})},150)},removeSplit(e){this.entries.splice(e,1),document.querySelector("#split-0-tab").click()},clearLocation(e){e.preventDefault();const t=e.currentTarget,s=parseInt(t.attributes["data-index"].value);this.entries[s].hasLocation=!1,this.entries[s].latitude=null,this.entries[s].longitude=null,this.entries[s].zoomLevel=null;const i=new CustomEvent("location-remove",{detail:{index:s}});return document.dispatchEvent(i),!1}}},f={transactions:I,dates:y};function g(){Object.keys(f).forEach(e=>{console.log(`Loading page component "${e}"`);let t=f[e]();Alpine.data(e,()=>t)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),g()});window.bootstrapped&&(console.log("Loaded through window variable."),g()); +import{a as m,d as y,f as d}from"./format-money-e4c435dc.js";import{d as w,c as b}from"./create-empty-split-9cc18e2d.js";import{l as v,a as C,b as T,c as _,p as E,d as P,s as L,e as c,f as S,g as D,h as A,i as x,j as k,k as h,m as p}from"./splice-errors-into-transactions-cc4832b4.js";import{l,i as r,m as B}from"./vendor-76961a66.js";import"./get-95250f8d.js";class M{post(t){let s="/api/v2/transactions";return m.post(s,t)}}let n=[],u=[];document.addEventListener("location-remove",e=>{u[e.detail.index].remove()});function O(e){let t=0;if(document.querySelector("#form")._x_dataStack[0].$data.entries[t].hasLocation===!1){u[t]=new l.marker(e.latlng,{draggable:!0}),u[t].on("dragend",U),u[t].addTo(n[t]);const i=new CustomEvent("location-set",{detail:{latitude:e.latlng.lat,longitude:e.latlng.lng,index:t,zoomLevel:n[t].getZoom()}});document.dispatchEvent(i)}}function F(e){let t=0;const s=new CustomEvent("location-zoom",{detail:{index:t,zoomLevel:n[t].getZoom()}});document.dispatchEvent(s)}function U(e){let t=e.target,s=t.getLatLng();t.setLatLng(new l.LatLng(s.lat,s.lng),{draggable:"true"});const i=new CustomEvent("location-move",{detail:{latitude:s.lat,longitude:s.lng,index:0}});document.dispatchEvent(i)}function z(e){if(e>0){console.warn("Corwardly refuse to add a map on split #"+(e+1));return}if(typeof n[e]>"u"){let t=document.getElementById("location_map");t&&(n[e]=l.map(t).setView([t.dataset.latitude,t.dataset.longitude],t.dataset.zoomLevel),l.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png",{maxZoom:19,attribution:'© OpenStreetMap'}).addTo(n[e]),n[e].on("click",O),n[e].on("zoomend",F))}}const a=k();let I=function(){return{entries:[],formStates:{loadingCurrencies:!0,loadingBudgets:!0,loadingPiggyBanks:!0,loadingSubscriptions:!0,isSubmitting:!1,returnHereButton:!1,saveAsNewButton:!1,resetButton:!0,rulesButton:!0,webhooksButton:!0},formBehaviour:{formType:"create",foreignCurrencyEnabled:!0},formData:{defaultCurrency:null,enabledCurrencies:[],nativeCurrencies:[],foreignCurrencies:[],budgets:[],piggyBanks:[],subscriptions:[]},groupProperties:{transactionType:"unknown",title:null,id:null,totalAmount:0},notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},filters:{source:[],destination:[]},changedDateTime(e){console.warn("changedDateTime, event is not used")},changedDescription(e){console.warn("changedDescription, event is not used")},changedDestinationAccount(e){this.detectTransactionType()},changedSourceAccount(e){this.detectTransactionType()},detectTransactionType(){const e=this.entries[0].source_account.type??"unknown",t=this.entries[0].destination_account.type??"unknown";if(e==="unknown"&&t==="unknown"){this.groupProperties.transactionType="unknown",console.warn("Cannot infer transaction type from two unknown accounts.");return}if(e===t&&["Asset account","Loan","Debt","Mortgage"].includes(e)){this.groupProperties.transactionType="transfer",console.log('Transaction type is detected to be "'+this.groupProperties.transactionType+'".'),console.log("filter down currencies for transfer."),this.filterNativeCurrencies(this.entries[0].source_account.currency_code),this.filterForeignCurrencies(this.entries[0].destination_account.currency_code);return}if(e==="Asset account"&&["Expense account","Debt","Loan","Mortgage"].includes(t)){this.groupProperties.transactionType="withdrawal",console.log('[a] Transaction type is detected to be "'+this.groupProperties.transactionType+'".'),this.filterNativeCurrencies(this.entries[0].source_account.currency_code);return}if(e==="Asset account"&&t==="unknown"){this.groupProperties.transactionType="withdrawal",console.log('[b] Transaction type is detected to be "'+this.groupProperties.transactionType+'".'),console.log(this.entries[0].source_account),this.filterNativeCurrencies(this.entries[0].source_account.currency_code);return}if(["Debt","Loan","Mortgage"].includes(e)&&t==="Expense account"){this.groupProperties.transactionType="withdrawal",console.log('[c] Transaction type is detected to be "'+this.groupProperties.transactionType+'".'),this.filterNativeCurrencies(this.entries[0].source_account.currency_code);return}if(e==="Revenue account"&&["Asset account","Debt","Loan","Mortgage"].includes(t)){this.groupProperties.transactionType="deposit",console.log('Transaction type is detected to be "'+this.groupProperties.transactionType+'".');return}if(["Debt","Loan","Mortgage"].includes(e)&&t==="Asset account"){this.groupProperties.transactionType="deposit",console.log('Transaction type is detected to be "'+this.groupProperties.transactionType+'".');return}console.warn('Unknown account combination between "'+e+'" and "'+t+'".')},formattedTotalAmount(){return this.entries.length===0?d(this.groupProperties.totalAmount,"EUR"):d(this.groupProperties.totalAmount,this.entries[0].currency_code??"EUR")},filterForeignCurrencies(e){let t=[],s;for(let i in this.formData.enabledCurrencies)if(this.formData.enabledCurrencies.hasOwnProperty(i)){let o=this.formData.enabledCurrencies[i];o.code===e&&(s=o)}t.push(s),this.formData.foreignCurrencies=t,t.length===1&&t[0].code===this.entries[0].source_account.currency_code&&(console.log("Foreign currency is same as source currency. Disable foreign amount."),this.formBehaviour.foreignCurrencyEnabled=!1),t.length===1&&t[0].code!==this.entries[0].source_account.currency_code&&(console.log("Foreign currency is NOT same as source currency. Enable foreign amount."),this.formBehaviour.foreignCurrencyEnabled=!0);for(let i in this.entries)this.entries.hasOwnProperty(i)&&(this.entries[i].foreign_currency_code=e)},filterNativeCurrencies(e){let t=[],s;for(let i in this.formData.enabledCurrencies)if(this.formData.enabledCurrencies.hasOwnProperty(i)){let o=this.formData.enabledCurrencies[i];o.code===e&&(s=o)}t.push(s),this.formData.nativeCurrencies=t;for(let i in this.entries)this.entries.hasOwnProperty(i)&&(this.entries[i].currency_code=e)},changedAmount(e){const t=parseInt(e.target.dataset.index);this.entries[t].amount=parseFloat(e.target.value),this.groupProperties.totalAmount=0;for(let s in this.entries)this.entries.hasOwnProperty(s)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[s].amount))},addedSplit(){},processUpload(e){this.showMessageOrRedirectUser()},processUploadError(e){this.notifications.success.show=!1,this.notifications.wait.show=!1,this.notifications.error.show=!0,this.formStates.isSubmitting=!1,this.notifications.error.text=r.t("firefly.errors_upload"),console.error(e)},init(){this.addSplit(),v().then(e=>{this.formStates.loadingCurrencies=!1,this.formData.defaultCurrency=e.defaultCurrency,this.formData.enabledCurrencies=e.enabledCurrencies,this.formData.nativeCurrencies=e.nativeCurrencies,this.formData.foreignCurrencies=e.foreignCurrencies}),C().then(e=>{this.formData.budgets=e,this.formStates.loadingBudgets=!1}),T().then(e=>{this.formData.piggyBanks=e,this.formStates.loadingPiggyBanks=!1}),_().then(e=>{this.formData.subscriptions=e,this.formStates.loadingSubscriptions=!1}),document.addEventListener("upload-success",e=>{this.processUpload(e),document.querySelectorAll("input[type=file]").value=""}),document.addEventListener("upload-error",e=>{this.processUploadError(e)}),document.addEventListener("location-move",e=>{this.entries[e.detail.index].latitude=e.detail.latitude,this.entries[e.detail.index].longitude=e.detail.longitude}),document.addEventListener("location-set",e=>{this.entries[e.detail.index].hasLocation=!0,this.entries[e.detail.index].latitude=e.detail.latitude,this.entries[e.detail.index].longitude=e.detail.longitude,this.entries[e.detail.index].zoomLevel=e.detail.zoomLevel}),document.addEventListener("location-zoom",e=>{this.entries[e.detail.index].hasLocation=!0,this.entries[e.detail.index].zoomLevel=e.detail.zoomLevel}),this.filters.source=["Asset account","Loan","Debt","Mortgage","Revenue account"],this.filters.destination=["Expense account","Loan","Debt","Mortgage","Asset account"]},submitTransaction(){this.notifications.error.show=!1,this.notifications.success.show=!1,this.notifications.wait.show=!1;for(let i in this.entries)this.entries.hasOwnProperty(i)&&(this.entries[i].errors=w());this.formStates.isSubmitting=!0,this.detectTransactionType();let e=E(this.entries,null,this.groupProperties.transactionType),t={group_title:this.groupProperties.title,fire_webhooks:this.formStates.webhooksButton,apply_rules:this.formStates.rulesButton,transactions:e};this.groupProperties.title===null&&e.length>1&&(t.group_title=e[0].description);let s=new M;console.log(t),s.post(t).then(i=>{const o=i.data.data;if(this.groupProperties.id=parseInt(o.id),this.groupProperties.title=o.attributes.group_title??o.attributes.transactions[0].description,P(this.groupProperties.id,o.attributes.transactions)>0){this.notifications.wait.show=!0,this.notifications.wait.text=r.t("firefly.wait_attachments");return}this.showMessageOrRedirectUser()}).catch(i=>{this.submitting=!1,console.log(i),typeof i.response<"u"&&this.parseErrors(i.response.data)})},showMessageOrRedirectUser(){if(this.notifications.error.show=!1,this.notifications.success.show=!1,this.notifications.wait.show=!1,this.formStates.returnHereButton){this.notifications.success.show=!0,this.notifications.success.url="transactions/show/"+this.groupProperties.id,this.notifications.success.text=r.t("firefly.stored_journal_js",{description:this.groupProperties.title}),this.formStates.resetButton&&(this.entries=[],this.addSplit(),this.groupProperties.totalAmount=0);return}window.location="transactions/show/"+this.groupProperties.id+"?transaction_group_id="+this.groupProperties.id+"&message=created"},parseErrors(e){this.notifications.error.show=!0,this.notifications.success.show=!1,this.notifications.wait.show=!1,this.formStates.isSubmitting=!1,this.notifications.error.text=r.t("firefly.errors_submission_v2",{errorMessage:e.message}),e.hasOwnProperty("errors")&&(this.entries=L(e.errors,this.entries))},addSplit(){this.entries.push(b()),setTimeout(()=>{B.init("select.ac-tags",{allowClear:!0,server:a.tag,liveServer:!0,clearEnd:!0,allowNew:!0,notFoundMessage:r.t("firefly.nothing_found"),noCache:!0,fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}}});const e=this.entries.length-1;z(e);const t=function(s,i,o){return s.name_with_balance+'
'+r.t("firefly.account_type_"+s.type)+""};c({selector:"input.ac-source",serverUrl:a.account,onChange:S,onSelectItem:D,hiddenValue:this.entries[e].source_account.alpine_name}),c({selector:"input.ac-dest",serverUrl:a.account,filters:this.filters.destination,onRenderItem:t,onChange:A,onSelectItem:x}),c({selector:"input.ac-category",serverUrl:a.category,valueField:"id",labelField:"name",onChange:h,onSelectItem:h}),c({selector:"input.ac-description",serverUrl:a.description,valueField:"id",labelField:"description",onChange:p,onSelectItem:p})},150)},removeSplit(e){this.entries.splice(e,1),document.querySelector("#split-0-tab").click()},clearLocation(e){e.preventDefault();const t=e.currentTarget,s=parseInt(t.attributes["data-index"].value);this.entries[s].hasLocation=!1,this.entries[s].latitude=null,this.entries[s].longitude=null,this.entries[s].zoomLevel=null;const i=new CustomEvent("location-remove",{detail:{index:s}});return document.dispatchEvent(i),!1}}},f={transactions:I,dates:y};function g(){Object.keys(f).forEach(e=>{console.log(`Loading page component "${e}"`);let t=f[e]();Alpine.data(e,()=>t)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),g()});window.bootstrapped&&(console.log("Loaded through window variable."),g()); diff --git a/public/build/assets/create-empty-split-16bf9f82.js b/public/build/assets/create-empty-split-9cc18e2d.js similarity index 93% rename from public/build/assets/create-empty-split-16bf9f82.js rename to public/build/assets/create-empty-split-9cc18e2d.js index c3619f627e..5dea5e34eb 100644 --- a/public/build/assets/create-empty-split-16bf9f82.js +++ b/public/build/assets/create-empty-split-9cc18e2d.js @@ -1 +1 @@ -import{f as n}from"./vendor-baac879b.js";function e(){return{id:"",name:"",alpine_name:""}}function o(){return{description:[],amount:[],currency_code:[],foreign_amount:[],foreign_currency_code:[],source_account:[],destination_account:[],budget_id:[],category_name:[],piggy_bank_id:[],bill_id:[],tags:[],notes:[],internal_reference:[],external_url:[],latitude:[],longitude:[],zoom_level:[],date:[],interest_date:[],book_date:[],process_date:[],due_date:[],payment_date:[],invoice_date:[]}}function d(){let t=n(new Date,"yyyy-MM-dd HH:mm");return{description:"",amount:"",currency_code:"EUR",foreign_amount:"",foreign_currency_code:"",source_account:e(),destination_account:e(),budget_id:null,category_name:"",piggy_bank_id:null,bill_id:null,tags:[],notes:"",internal_reference:"",external_url:"",hasLocation:!1,latitude:null,longitude:null,zoomLevel:null,date:t,interest_date:"",book_date:"",process_date:"",due_date:"",payment_date:"",invoice_date:"",errors:o()}}export{d as c,o as d}; +import{f as n}from"./vendor-76961a66.js";function e(){return{id:"",name:"",alpine_name:""}}function o(){return{description:[],amount:[],currency_code:[],foreign_amount:[],foreign_currency_code:[],source_account:[],destination_account:[],budget_id:[],category_name:[],piggy_bank_id:[],bill_id:[],tags:[],notes:[],internal_reference:[],external_url:[],latitude:[],longitude:[],zoom_level:[],date:[],interest_date:[],book_date:[],process_date:[],due_date:[],payment_date:[],invoice_date:[]}}function d(){let t=n(new Date,"yyyy-MM-dd HH:mm");return{description:"",amount:"",currency_code:"EUR",foreign_amount:"",foreign_currency_code:"",source_account:e(),destination_account:e(),budget_id:null,category_name:"",piggy_bank_id:null,bill_id:null,tags:[],notes:"",internal_reference:"",external_url:"",hasLocation:!1,latitude:null,longitude:null,zoomLevel:null,date:t,interest_date:"",book_date:"",process_date:"",due_date:"",payment_date:"",invoice_date:"",errors:o()}}export{d as c,o as d}; diff --git a/public/build/assets/dashboard-14a83ee8.js b/public/build/assets/dashboard-4c2936a0.js similarity index 98% rename from public/build/assets/dashboard-14a83ee8.js rename to public/build/assets/dashboard-4c2936a0.js index cbb5fe9947..c34ad52be4 100644 --- a/public/build/assets/dashboard-14a83ee8.js +++ b/public/build/assets/dashboard-4c2936a0.js @@ -1 +1 @@ -import{a as O,f,g as v,P as bt,d as wt}from"./format-money-0f129d93.js";import{f as g,C as m,a as S,i as p,S as vt,F as mt,L as Ct,b as kt,A as Pt,B as Dt,T as xt,P as Ot,c as Mt,d as Ft,p as St,e as At,g as Bt,h as jt,j as Wt,k as It}from"./vendor-baac879b.js";import{G as $t}from"./get-851d8544.js";import{G as Vt,a as Kt}from"./get-d03e8e57.js";class Lt{get(e,n,a){return O.get("/api/v2/summary/basic",{params:{start:e,end:n,code:a}})}}function P(t,e,n){const a=g(e,"y-MM-dd")+"_"+g(n,"y-MM-dd")+"_"+t;return console.log("getCacheKey: "+a),String(a)}let U=!1;const Et=()=>({balanceBox:{amounts:[],subtitles:[]},billBox:{paid:[],unpaid:[]},leftBox:{left:[],perDay:[]},netBox:{net:[]},autoConversion:!1,loading:!1,boxData:null,boxOptions:null,getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-boxes-data",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){this.boxData=r,this.generateOptions(this.boxData);return}new Lt().get(g(t,"yyyy-MM-dd"),g(e,"yyyy-MM-dd"),null).then(i=>{this.boxData=i.data,window.store.set(n,i.data),this.generateOptions(this.boxData)})},generateOptions(t){this.balanceBox={amounts:[],subtitles:[]},this.billBox={paid:[],unpaid:[]},this.leftBox={left:[],perDay:[]},this.netBox={net:[]};let e={};for(const n in t)if(t.hasOwnProperty(n)){const a=t[n];if(!a.hasOwnProperty("key"))continue;let r=a.key;if(this.autoConversion){if(r.startsWith("balance-in-native")){this.balanceBox.amounts.push(f(a.value,a.currency_code)),e.hasOwnProperty(a.currency_code)||(e[a.currency_code]="");continue}if(r.startsWith("spent-in-native")){e.hasOwnProperty(a.currency_code)||(e[a.currency_code]=""),e[a.currency_code]=e[a.currency_code]+f(a.value,a.currency_code);continue}if(r.startsWith("earned-in-native")){e.hasOwnProperty(a.currency_code)||(e[a.currency_code]=""),e[a.currency_code]=f(a.value,a.currency_code)+" + "+e[a.currency_code];continue}if(r.startsWith("bills-unpaid-in-native")){this.billBox.unpaid.push(f(a.value,a.currency_code));continue}if(r.startsWith("bills-paid-in-native")){this.billBox.paid.push(f(a.value,a.currency_code));continue}if(r.startsWith("left-to-spend-in-native")){this.leftBox.left.push(f(a.value,a.currency_code));continue}if(r.startsWith("left-per-day-to-spend-in-native")){this.leftBox.perDay.push(f(a.value,a.currency_code));continue}if(r.startsWith("net-worth-in-native")){this.netBox.net.push(f(a.value,a.currency_code));continue}}if(!this.autoConversion&&!r.endsWith("native")){if(r.startsWith("balance-in-")){this.balanceBox.amounts.push(f(a.value,a.currency_code));continue}if(r.startsWith("spent-in-")){e.hasOwnProperty(a.currency_code)||(e[a.currency_code]=""),e[a.currency_code]=e[a.currency_code]+f(a.value,a.currency_code);continue}if(r.startsWith("earned-in-")){e.hasOwnProperty(a.currency_code)||(e[a.currency_code]=""),e[a.currency_code]=f(a.value,a.currency_code)+" + "+e[a.currency_code];continue}if(r.startsWith("bills-unpaid-in-")){this.billBox.unpaid.push(f(a.value,a.currency_code));continue}if(r.startsWith("bills-paid-in-")){this.billBox.paid.push(f(a.value,a.currency_code));continue}if(r.startsWith("left-to-spend-in-")){this.leftBox.left.push(f(a.value,a.currency_code));continue}if(r.startsWith("left-per-day-to-spend-in-")){this.leftBox.perDay.push(f(a.value,a.currency_code));continue}r.startsWith("net-worth-in-")&&this.netBox.net.push(f(a.value,a.currency_code))}}for(let n in e)e.hasOwnProperty(n)&&this.balanceBox.subtitles.push(e[n]);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([v("viewRange"),v("autoConversion",!1)]).then(t=>{U=!0,this.autoConversion=t[1],this.loadBoxes()}),window.store.observe("end",()=>{U&&(this.boxData=null,this.loadBoxes())}),window.store.observe("autoConversion",t=>{U&&(this.autoConversion=t,this.loadBoxes())})}});class Gt{put(e,n){let a="/api/v1/preferences/"+e;return O.put(a,{data:n})}}function Tt(t,e=null){window.store.set(t,e),new Gt().put(t,e).then(a=>{}).catch(()=>{new bt().post(t,e).then(r=>{})})}let Rt=class{dashboard(e,n){let a=g(e,"y-MM-dd"),r=g(n,"y-MM-dd");return O.get("/api/v2/chart/account/dashboard",{params:{start:a,end:r}})}expense(e,n){let a=g(e,"y-MM-dd"),r=g(n,"y-MM-dd");return O.get("/api/v2/chart/account/expense-dashboard",{params:{start:a,end:r}})}};class st{get(e,n){let a={date:g(n,"y-MM-dd").slice(0,10)};return n?O.get("/api/v2/accounts/"+e,{params:a}):O.get("/api/v2/accounts/"+e)}transactions(e,n){const a={page:n.page??1};return n.hasOwnProperty("start")&&(a.start=g(n.start,"y-MM-dd")),n.hasOwnProperty("end")&&(a.end=g(n.end,"y-MM-dd")),O.get("/api/v2/accounts/"+e+"/transactions",{params:a})}}function N(t){return t==="sankey"?{type:"sankey",data:{datasets:[]},options:{animations:!1}}:t==="pie"?{type:"pie",data:{datasets:[]}}:t==="column"?{type:"bar",data:{labels:[],datasets:[]},options:{plugins:{tooltip:{callbacks:{label:function(e){let n=e.dataset.currency_code;return f(e.raw,n)}}}},maintainAspectRatio:!1,scales:{}}}:t==="line"?{options:{plugins:{tooltip:{callbacks:{label:function(e){let n=e.dataset.currency_code;return f(e.raw,n)}}}},maintainAspectRatio:!1,scales:{x:{type:"time",time:{tooltipFormat:"PP"}}}},type:"line",data:{labels:[],datasets:[]}}:{}}let q=new m("#36a2eb"),I=new m("#ff6384"),G=new m("#4bc0c0"),ft=new m("#ff9f40"),qt=new m("#9966ff"),Nt=new m("#ffcd56"),Yt=new m("#c9cbcf"),lt=0;window.theme==="dark"&&(I.darken(.3).desaturate(.3),G.darken(.3).desaturate(.3),q.darken(.3).desaturate(.3),ft.darken(.3).desaturate(.3));let z=[I,ft,q,G,qt,Nt,Yt,G];function j(t,e){let n={borderColor:I.rgbString(),backgroundColor:I.rgbString()},a;switch(t){default:let o=Math.floor(lt/2)%z.length;a=new m(z[o].rgbString()),a.lighten(.38),n={borderColor:z[o].hexString(),backgroundColor:a.hexString()};break;case"spent":a=new m(q.rgbString()),a.lighten(.38),n={borderColor:q.rgbString(),backgroundColor:a.rgbString()};break;case"left":a=new m(G.rgbString()),a.lighten(.38),n={borderColor:G.rgbString(),backgroundColor:a.rgbString()};break;case"overspent":a=new m(I.rgbString()),a.lighten(.22),n={borderColor:I.rgbString(),backgroundColor:a.rgbString()};break}return lt++,e==="border"?n.borderColor:e==="background"?n.backgroundColor:"#FF0000"}let A=[],$=null,H=null,J=!1;const Ut=()=>({loading:!1,loadingAccounts:!1,accountList:[],autoConversion:!1,chartOptions:null,switchAutoConversion(){this.autoConversion=!this.autoConversion,Tt("autoConversion",this.autoConversion)},getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-accounts-chart",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){console.log(r),this.drawChart(this.generateOptions(r)),this.loading=!1;return}new Rt().dashboard(t,e,null).then(i=>{this.chartData=i.data,window.store.set(n,i.data),console.log(i.data),this.drawChart(this.generateOptions(this.chartData)),this.loading=!1})},generateOptions(t){A=[];let e=N("line");for(let n=0;n0){this.loadingAccounts=!1;return}const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-accounts-data",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){this.accountList=r,this.loadingAccounts=!1;return}const o=10;let i=0,l=0,u=[];Promise.all([v("frontpageAccounts")]).then(d=>{i=d[0].length;for(let h in d[0]){let c=d[0];if(c.hasOwnProperty(h)){let _=c[h];new st().get(_,new Date(window.store.get("end"))).then(w=>{let C=w.data.data;const yt={page:1,start:new Date(window.store.get("start")),end:new Date(window.store.get("end"))};new st().transactions(C.id,yt).then(at=>{let nt=[];for(let B=0;B=o);B++){let M=at.data.data[B],rt={title:M.attributes.group_title===null?"":M.attributes.group_title,id:M.id,transactions:[]};for(let Y=0;YB.order-M.order),this.accountList=u,this.loadingAccounts=!1,window.store.set(n,u))})})}}})},init(){Promise.all([v("viewRange","1M"),v("autoConversion",!1),v("language","en_US")]).then(t=>{this.autoConversion=t[1],J=!0,this.loadChart(),this.loadAccounts()}),window.store.observe("end",()=>{J&&(H=null,this.accountList=[],this.loadChart(),this.loadAccounts())}),window.store.observe("autoConversion",()=>{J&&(this.loadChart(),this.loadAccounts())})}});let zt=class{dashboard(e,n){let a=g(e,"y-MM-dd"),r=g(n,"y-MM-dd");return O.get("/api/v2/chart/budget/dashboard",{params:{start:a,end:r}})}},V=[],T=null,F=null,Z=!1;const Ht=()=>({loading:!1,autoConversion:!1,loadChart(){if(this.loading!==!0){if(this.loading=!0,F!==null){this.drawChart(this.generateOptions(F)),this.loading=!1;return}this.getFreshData()}},drawChart(t){if(T!==null){T.data.datasets=t.data.datasets,T.update();return}T=new S(document.querySelector("#budget-chart"),t)},getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-budgets-chart",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){F=r,this.drawChart(this.generateOptions(F)),this.loading=!1;return}new zt().dashboard(t,e,null).then(i=>{F=i.data,this.drawChart(this.generateOptions(F)),window.store.set(n,F),this.loading=!1})},generateOptions(t){V=[];let e=N("column");e.options.locale=window.store.get("locale").replace("_","-"),e.options.plugins={tooltip:{callbacks:{title:function(n){return n.label},label:function(n){let a=n.dataset.label||"";return a&&(a+=": "),a+" "+f(n.parsed.y,V[n.parsed.x]??"EUR")}}}},e.data={labels:[],datasets:[{label:p.t("firefly.spent"),data:[],borderWidth:1,stack:1,backgroundColor:j("spent","background"),borderColor:j("spent","border")},{label:p.t("firefly.left"),data:[],borderWidth:1,stack:1,backgroundColor:j("left","background"),borderColor:j("left","border")},{label:p.t("firefly.overspent"),data:[],borderWidth:1,stack:1,backgroundColor:j("overspent","background"),borderColor:j("overspent","border")}]};for(const n in t)if(t.hasOwnProperty(n)){let a=t[n],r=a.label+" ("+a.currency_code+")";e.data.labels.push(r),this.autoConversion&&(V.push(a.native_currency_code),e.data.datasets[0].data.push(parseFloat(a.native_entries.spent)*-1),e.data.datasets[1].data.push(parseFloat(a.native_entries.left)),e.data.datasets[2].data.push(parseFloat(a.native_entries.overspent))),this.autoConversion||(V.push(a.currency_code),e.data.datasets[0].data.push(parseFloat(a.entries.spent)*-1),e.data.datasets[1].data.push(parseFloat(a.entries.left)),e.data.datasets[2].data.push(parseFloat(a.entries.overspent)))}return e.options.scales={y:{ticks:{callback:function(n){return f(n,V[0]??"EUR")}}}},e},init(){Promise.all([v("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],Z=!0,this.loading===!1&&this.loadChart()}),window.store.observe("end",()=>{Z&&this.loading===!1&&(F=null,this.loadChart())}),window.store.observe("autoConversion",t=>{Z&&(this.autoConversion=t,this.loading===!1&&this.loadChart())})}});class Jt{dashboard(e,n){let a=g(e,"y-MM-dd"),r=g(n,"y-MM-dd");return O.get("/api/v2/chart/category/dashboard",{params:{start:a,end:r}})}}let ut=[],K=null,W=null,Q=!1;const Zt=()=>({loading:!1,autoConversion:!1,generateOptions(t){ut=[];let e=N("column"),n={};for(const r in t)if(t.hasOwnProperty(r)){let o=t[r],i=o.currency_code;this.autoConversion&&(i=o.native_currency_code),n.hasOwnProperty(i)||(n[i]={name:i,yAxisID:"",data:{}},ut.push(i))}for(const r in t)if(t.hasOwnProperty(r)){let o=t[r],i=o.currency_code;this.autoConversion&&(i=o.native_currency_code);for(const l in n)if(n.hasOwnProperty(l)){let u=0;i===l&&(u=parseFloat(o.amount),""+o.currency_code,this.autoConversion&&(u=parseFloat(o.native_amount),""+o.native_currency_code)),n[l].data.hasOwnProperty(o.label)&&(n[l].data[o.label]=n[l].data[o.label]+u),n[l].data.hasOwnProperty(o.label)||(n[l].data[o.label]=u)}e.data.labels.includes(o.label)||e.data.labels.push(o.label)}let a=0;for(const r in n){let o="y"+r,i={label:r,currency_code:r,yAxisID:o,data:[]};for(const l in n[r].data)i.data.push(n[r].data[l]);e.data.datasets.push(i),e.options.scales.hasOwnProperty(o)||(e.options.scales[o]={beginAtZero:!0,type:"linear",position:a===1?"right":"left",ticks:{callback:function(l,u,d){return f(l,r)}}},a++)}return e},drawChart(t){if(K!==null){K.options=t.options,K.data=t.data,K.update();return}K=new S(document.querySelector("#category-chart"),t)},getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-categories-chart",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){W=r,this.drawChart(this.generateOptions(W)),this.loading=!1;return}new Jt().dashboard(t,e,null).then(i=>{W=i.data,this.drawChart(this.generateOptions(i.data)),window.store.set(n,W),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,W!==null){this.drawChart(this.generateOptions(W)),this.loading=!1;return}this.getFreshData()}},init(){Promise.all([v("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],Q=!0,this.loadChart()}),window.store.observe("end",()=>{Q&&(this.chartData=null,this.loadChart())}),window.store.observe("autoConversion",t=>{Q&&(this.autoConversion=t,this.loadChart())})}});S.register({SankeyController:vt,Flow:mt});const ct="dashboard-sankey-data";let X=!1,R=null,D=[],y=!1,s={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 dt=function(t){return t.includes(s.revenue_account)?"forestgreen":t.includes("("+s.in+",")?"green":t.includes(s.budget)||t.includes(s.unknown_budget)?"Orchid":t.includes("("+s.out+",")?"MediumOrchid":t.includes(s.all_money)?"blue":"red"};function L(t,e,n,a){if(t==="category"&&e!==null&&n==="in")return s.category+' "'+e+'" ('+s.in+(y?", "+a+")":")");if(t==="category"&&e===null&&n==="in")return s.unknown_category+" ("+s.in+(y?", "+a+")":")");if(t==="category"&&e!==null&&n==="out")return s.category+' "'+e+'" ('+s.out+(y?", "+a+")":")");if(t==="category"&&e===null&&n==="out")return s.unknown_category+" ("+s.out+(y?", "+a+")":")");if(t==="account"&&e===null&&n==="in")return s.unknown_source+(y?" ("+a+")":"");if(t==="account"&&e!==null&&n==="in")return s.revenue_account+'"'+e+'"'+(y?" ("+a+")":"");if(t==="account"&&e===null&&n==="out")return s.unknown_dest+(y?" ("+a+")":"");if(t==="account"&&e!==null&&n==="out")return s.expense_account+' "'+e+'"'+(y?" ("+a+")":"");if(t==="budget"&&e!==null)return s.budget+' "'+e+'"'+(y?" ("+a+")":"");if(t==="budget"&&e===null)return s.unknown_budget+(y?" ("+a+")":"");console.error('Cannot handle: type:"'+t+'", dir: "'+n+'"')}function E(t,e,n){if(t==="category"&&e!==null)return s.category+' "'+e+'"'+(y?" ("+n+")":"");if(t==="category"&&e===null)return s.unknown_category+(y?" ("+n+")":"");if(t==="account"&&e===null)return s.unknown_account+(y?" ("+n+")":"");if(t==="account"&&e!==null)return e+(y?" ("+n+")":"");if(t==="budget"&&e!==null)return s.budget+' "'+e+'"'+(y?" ("+n+")":"");if(t==="budget"&&e===null)return s.unknown_budget+(y?" ("+n+")":"");console.error('Cannot handle: type:"'+t+'"')}const Qt=()=>({loading:!1,autoConversion:!1,generateOptions(){let t=N("sankey"),e={},n={};for(let r in D)if(D.hasOwnProperty(r)){let o=D[r];for(let i in o.attributes.transactions)if(o.attributes.transactions.hasOwnProperty(i)){let l=o.attributes.transactions[i],u=this.autoConversion?l.native_currency_code:l.currency_code,d=this.autoConversion?parseFloat(l.native_amount):parseFloat(l.amount),h;if(l.type==="deposit"){let c=L("category",l.category_name,"in",u),_=L("account",l.source_name,"in",u);n[c]=E("category",l.category_name,u),n[_]=E("account",l.source_name,u),h=_+"-"+c+"-"+u,e.hasOwnProperty(h)||(e[h]={from:_,to:c,amount:0}),e[h].amount+=d,h=c+"-"+s.all_money+"-"+u,e.hasOwnProperty(h)||(e[h]={from:c,to:s.all_money+(this.autoConversion?" ("+u+")":""),amount:0}),e[h].amount+=d}if(l.type==="withdrawal"){let c=L("budget",l.budget_name,"out",u);n[c]=E("budget",l.budget_name,u),h=s.all_money+"-"+c+"-"+u,e.hasOwnProperty(h)||(e[h]={from:s.all_money+(this.autoConversion?" ("+u+")":""),to:c,amount:0}),e[h].amount+=d;let _=L("category",l.category_name,"out",u);n[_]=E("category",l.category_name,u),h=c+"-"+_+"-"+u,e.hasOwnProperty(h)||(e[h]={from:c,to:_,amount:0}),e[h].amount+=d;let w=L("account",l.destination_name,"out",u);n[w]=E("account",l.destination_name,u),h=_+"-"+w+"-"+u,e.hasOwnProperty(h)||(e[h]={from:_,to:w,amount:0}),e[h].amount+=d}}}let a={label:"Firefly III dashboard sankey chart",data:[],colorFrom:r=>dt(r.dataset.data[r.dataIndex]?r.dataset.data[r.dataIndex].from:""),colorTo:r=>dt(r.dataset.data[r.dataIndex]?r.dataset.data[r.dataIndex].to:""),colorMode:"gradient",labels:n,size:"min"};for(let r in e)if(e.hasOwnProperty(r)){let o=e[r];a.data.push({from:o.from,to:o.to,flow:o.amount})}return t.data.datasets.push(a),t},drawChart(t){if(R!==null){R.data.datasets=t.data.datasets,R.update();return}R=new S(document.querySelector("#sankey-chart"),t)},getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P(ct,t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){D=r,this.drawChart(this.generateOptions()),this.loading=!1;return}let o={start:g(t,"y-MM-dd"),end:g(e,"y-MM-dd"),type:"withdrawal,deposit",page:1};this.downloadTransactions(o)},downloadTransactions(t){const e=new Date(window.store.get("start")),n=new Date(window.store.get("end")),a=P(ct,e,n);new $t().list(t).then(o=>{if(D=[...D,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>t.page){t.page++,this.downloadTransactions(t);return}window.store.set(a,D),this.drawChart(this.generateOptions()),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,D.length!==0){this.drawChart(this.generateOptions()),this.loading=!1;return}this.getFreshData()}},init(){D=[],Promise.all([v("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],y=t[0],s.all_money=p.t("firefly.all_money"),s.category=p.t("firefly.category"),s.in=p.t("firefly.money_flowing_in"),s.out=p.t("firefly.money_flowing_out"),s.unknown_category=p.t("firefly.unknown_category_plain"),s.unknown_source=p.t("firefly.unknown_source_plain"),s.unknown_dest=p.t("firefly.unknown_dest_plain"),s.unknown_account=p.t("firefly.unknown_any_plain"),s.unknown_budget=p.t("firefly.unknown_budget_plain"),s.expense_account=p.t("firefly.expense_account"),s.revenue_account=p.t("firefly.revenue_account"),s.budget=p.t("firefly.budget"),X=!0,this.loadChart()}),window.store.observe("end",()=>{X&&(this.transactions=[],this.loadChart())}),window.store.observe("autoConversion",t=>{X&&(this.autoConversion=t,this.loadChart())})}});let tt=!1,b={};function gt(t){return new Vt().list(t).then(n=>{let a=n.data.data;for(let r in a)if(a.hasOwnProperty(r)){let o=a[r];if(o.attributes.active&&o.attributes.pay_dates.length>0){let i=o.attributes.object_group_id===null?0:o.attributes.object_group_id,l=o.attributes.object_group_title===null?p.t("firefly.default_group_title_name_plain"):o.attributes.object_group_title,u=o.attributes.object_group_order===null?0:o.attributes.object_group_order;b.hasOwnProperty(i)||(b[i]={id:i,title:l,order:u,payment_info:{},bills:[]});let d={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};d.expected_amount=t.autoConversion?f(d.native_amount,d.native_currency_code):f(d.amount,d.currency_code),d.expected_times=p.t("firefly.subscr_expected_x_times",{times:o.attributes.pay_dates.length,amount:d.expected_amount});for(let h in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(h)){const c=o.attributes.paid_dates[h];let _=100;t.autoConversion&&(_=Math.round(-100+parseFloat(c.native_amount)*-1/parseFloat(d.native_amount)*100)),t.autoConversion||(_=Math.round(-100+parseFloat(c.amount)*-1/parseFloat(d.amount)*100));let w={amount:t.autoConversion?f(c.native_amount,c.native_currency_code):f(c.amount,c.currency_code),percentage:_,date:g(new Date(c.date),"PP"),foreign_amount:null};c.foreign_currency_code!==null&&(w.foreign_amount=t.autoConversion?c.foreign_native_amount:c.foreign_amount,w.foreign_currency_code=t.autoConversion?c.native_currency_code:c.foreign_currency_code),d.transactions.push(w)}if(b[i].bills.push(d),o.attributes.paid_dates.length===0){const h=o.attributes.pay_dates.length*d.amount,c=o.attributes.pay_dates.length*d.native_amount;b[i].payment_info.hasOwnProperty(d.currency_code)||(b[i].payment_info[d.currency_code]={currency_code:d.currency_code,paid:0,unpaid:0,native_currency_code:d.native_currency_code,native_paid:0,native_unpaid:0}),b[i].payment_info[d.currency_code].unpaid+=h,b[i].payment_info[d.currency_code].native_unpaid+=c}if(o.attributes.paid_dates.length>0){for(let h in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(h)){let c=o.attributes.paid_dates[h];b[i].payment_info.hasOwnProperty(c.currency_code)||(b[i].payment_info[c.currency_code]={currency_code:d.currency_code,paid:0,unpaid:0,native_currency_code:d.native_currency_code,native_paid:0,native_unpaid:0});const _=parseFloat(c.amount)*-1,w=parseFloat(c.native_amount)*-1;b[i].payment_info[c.currency_code].paid+=_,b[i].payment_info[c.currency_code].native_paid+=w}}}}return parseInt(n.data.meta.pagination.total_pages)>t.page?(t.page++,gt(t)):Promise.resolve()})}const Xt=()=>({loading:!1,autoConversion:!1,subscriptions:[],startSubscriptions(){this.loading=!0;let t=new Date(window.store.get("start")),e=new Date(window.store.get("end"));const n=window.store.get("cacheValid");let a=window.store.get(P("subscriptions-data-dashboard",t,e));n&&typeof a<"u",b={},this.subscriptions=[];let r={start:g(t,"y-MM-dd"),end:g(e,"y-MM-dd"),autoConversion:this.autoConversion,page:1};gt(r).then(()=>{let o=Object.values(b);for(let i in o)if(o.hasOwnProperty(i)){let l=o[i];const u=Object.keys(l.payment_info);l.col_size=u.length===1?"col-6 offset-3":"col-6",l.chart_width=u.length===1?"50%":"100%",l.payment_length=u.length,this.subscriptions.push(l)}this.loading=!1})},drawPieChart(t,e,n){let a="#pie_"+t+"_"+n.currency_code;const r=this.autoConversion?n.native_unpaid:n.unpaid,o=this.autoConversion?n.native_paid:n.paid,i=this.autoConversion?n.native_currency_code:n.currency_code,u={type:"doughnut",data:{labels:[p.t("firefly.paid"),p.t("firefly.unpaid")],datasets:[{label:p.t("firefly.subscriptions_in_group",{title:e}),data:[o,r],backgroundColor:["rgb(54, 162, 235)","rgb(255, 99, 132)"],hoverOffset:4}]},options:{plugins:{tooltip:{callbacks:{label:function(h){return h.dataset.label+": "+f(h.raw,i)}}}}}};var d=S.getChart(document.querySelector(a));typeof d<"u"&&d.destroy(),new S(document.querySelector(a),u)},init(){Promise.all([v("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],tt=!0,this.loading===!1&&this.startSubscriptions()}),window.store.observe("end",()=>{tt&&this.loading===!1&&this.startSubscriptions()}),window.store.observe("autoConversion",t=>{tt&&(this.autoConversion=t,this.loading===!1&&this.startSubscriptions())})}});let x={},et=!1;const ht="dashboard-piggies-data",te=()=>({loading:!1,autoConversion:!1,sankeyGrouping:"account",piggies:[],getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P(ht,t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){x=r,this.parsePiggies(),this.loading=!1;return}let o={start:g(t,"y-MM-dd"),end:g(e,"y-MM-dd"),page:1};this.downloadPiggyBanks(o)},downloadPiggyBanks(t){const e=new Date(window.store.get("start")),n=new Date(window.store.get("end")),a=P(ht,e,n);new Kt().list(t).then(o=>{if(x=[...x,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>t.page){t.page++,this.downloadPiggyBanks(t);return}window.store.set(a,x),this.parsePiggies(),this.loading=!1})},parsePiggies(){let t=[];for(let e in x)if(x.hasOwnProperty(e)){let n=x[e];if(n.attributes.percentage>=100||n.attributes.percentage===0)continue;let a=n.object_group_title??p.t("firefly.default_group_title_name_plain");t.hasOwnProperty(a)||(t[a]={id:n.object_group_id??0,title:a,order:n.object_group_order??0,piggies:[]});let r={id:n.id,name:n.attributes.name,percentage:parseInt(n.attributes.percentage),amount:this.autoConversion?n.attributes.native_current_amount:n.attributes.current_amount,left_to_save:this.autoConversion?n.attributes.native_left_to_save:n.attributes.left_to_save,target_amount:this.autoConversion?n.attributes.native_target_amount:n.attributes.target_amount,save_per_month:this.autoConversion?n.attributes.native_save_per_month:n.attributes.save_per_month,currency_code:this.autoConversion?n.attributes.native_currency_code:n.attributes.currency_code};t[a].piggies.push(r)}this.piggies=Object.values(t)},loadPiggyBanks(){if(this.loading!==!0){if(this.loading=!0,this.piggies.length!==0){this.parsePiggies(),this.loading=!1;return}this.getFreshData()}},init(){x=[],Promise.all([v("autoConversion",!1)]).then(t=>{et=!0,this.autoConversion=t[0],this.loadPiggyBanks()}),window.store.observe("end",()=>{et&&(x=[],this.loadPiggyBanks())}),window.store.observe("autoConversion",t=>{et&&(this.autoConversion=t,this.loadPiggyBanks())})}});S.register({LineController:Ct,LineElement:kt,ArcElement:Pt,BarController:Dt,TimeScale:xt,PieController:Ot,BarElement:Mt,Filler:Ft,Colors:St,LinearScale:At,CategoryScale:Bt,PointElement:jt,Tooltip:Wt,Legend:It});const pt={dates:wt,boxes:Et,accounts:Ut,budgets:Ht,categories:Zt,sankey:Qt,subscriptions:Xt,piggies:te};function _t(t){Object.keys(t).forEach(e=>{let n=t[e]();Alpine.data(e,()=>n)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),_t(pt)});window.bootstrapped&&(console.log("Loaded through window variable."),_t(pt)); +import{a as O,f,g as v,P as bt,d as wt}from"./format-money-e4c435dc.js";import{f as g,C as m,a as S,i as p,S as vt,F as mt,L as Ct,b as kt,A as Pt,B as Dt,T as xt,P as Ot,c as Mt,d as Ft,p as St,e as At,g as Bt,h as jt,j as Wt,k as It}from"./vendor-76961a66.js";import{G as $t}from"./get-5236bc21.js";import{G as Vt,a as Kt}from"./get-95250f8d.js";class Lt{get(e,n,a){return O.get("/api/v2/summary/basic",{params:{start:e,end:n,code:a}})}}function P(t,e,n){const a=g(e,"y-MM-dd")+"_"+g(n,"y-MM-dd")+"_"+t;return console.log("getCacheKey: "+a),String(a)}let U=!1;const Et=()=>({balanceBox:{amounts:[],subtitles:[]},billBox:{paid:[],unpaid:[]},leftBox:{left:[],perDay:[]},netBox:{net:[]},autoConversion:!1,loading:!1,boxData:null,boxOptions:null,getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-boxes-data",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){this.boxData=r,this.generateOptions(this.boxData);return}new Lt().get(g(t,"yyyy-MM-dd"),g(e,"yyyy-MM-dd"),null).then(i=>{this.boxData=i.data,window.store.set(n,i.data),this.generateOptions(this.boxData)})},generateOptions(t){this.balanceBox={amounts:[],subtitles:[]},this.billBox={paid:[],unpaid:[]},this.leftBox={left:[],perDay:[]},this.netBox={net:[]};let e={};for(const n in t)if(t.hasOwnProperty(n)){const a=t[n];if(!a.hasOwnProperty("key"))continue;let r=a.key;if(this.autoConversion){if(r.startsWith("balance-in-native")){this.balanceBox.amounts.push(f(a.value,a.currency_code)),e.hasOwnProperty(a.currency_code)||(e[a.currency_code]="");continue}if(r.startsWith("spent-in-native")){e.hasOwnProperty(a.currency_code)||(e[a.currency_code]=""),e[a.currency_code]=e[a.currency_code]+f(a.value,a.currency_code);continue}if(r.startsWith("earned-in-native")){e.hasOwnProperty(a.currency_code)||(e[a.currency_code]=""),e[a.currency_code]=f(a.value,a.currency_code)+" + "+e[a.currency_code];continue}if(r.startsWith("bills-unpaid-in-native")){this.billBox.unpaid.push(f(a.value,a.currency_code));continue}if(r.startsWith("bills-paid-in-native")){this.billBox.paid.push(f(a.value,a.currency_code));continue}if(r.startsWith("left-to-spend-in-native")){this.leftBox.left.push(f(a.value,a.currency_code));continue}if(r.startsWith("left-per-day-to-spend-in-native")){this.leftBox.perDay.push(f(a.value,a.currency_code));continue}if(r.startsWith("net-worth-in-native")){this.netBox.net.push(f(a.value,a.currency_code));continue}}if(!this.autoConversion&&!r.endsWith("native")){if(r.startsWith("balance-in-")){this.balanceBox.amounts.push(f(a.value,a.currency_code));continue}if(r.startsWith("spent-in-")){e.hasOwnProperty(a.currency_code)||(e[a.currency_code]=""),e[a.currency_code]=e[a.currency_code]+f(a.value,a.currency_code);continue}if(r.startsWith("earned-in-")){e.hasOwnProperty(a.currency_code)||(e[a.currency_code]=""),e[a.currency_code]=f(a.value,a.currency_code)+" + "+e[a.currency_code];continue}if(r.startsWith("bills-unpaid-in-")){this.billBox.unpaid.push(f(a.value,a.currency_code));continue}if(r.startsWith("bills-paid-in-")){this.billBox.paid.push(f(a.value,a.currency_code));continue}if(r.startsWith("left-to-spend-in-")){this.leftBox.left.push(f(a.value,a.currency_code));continue}if(r.startsWith("left-per-day-to-spend-in-")){this.leftBox.perDay.push(f(a.value,a.currency_code));continue}r.startsWith("net-worth-in-")&&this.netBox.net.push(f(a.value,a.currency_code))}}for(let n in e)e.hasOwnProperty(n)&&this.balanceBox.subtitles.push(e[n]);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([v("viewRange"),v("autoConversion",!1)]).then(t=>{U=!0,this.autoConversion=t[1],this.loadBoxes()}),window.store.observe("end",()=>{U&&(this.boxData=null,this.loadBoxes())}),window.store.observe("autoConversion",t=>{U&&(this.autoConversion=t,this.loadBoxes())})}});class Gt{put(e,n){let a="/api/v1/preferences/"+e;return O.put(a,{data:n})}}function Tt(t,e=null){window.store.set(t,e),new Gt().put(t,e).then(a=>{}).catch(()=>{new bt().post(t,e).then(r=>{})})}let Rt=class{dashboard(e,n){let a=g(e,"y-MM-dd"),r=g(n,"y-MM-dd");return O.get("/api/v2/chart/account/dashboard",{params:{start:a,end:r}})}expense(e,n){let a=g(e,"y-MM-dd"),r=g(n,"y-MM-dd");return O.get("/api/v2/chart/account/expense-dashboard",{params:{start:a,end:r}})}};class st{get(e,n){let a={date:g(n,"y-MM-dd").slice(0,10)};return n?O.get("/api/v2/accounts/"+e,{params:a}):O.get("/api/v2/accounts/"+e)}transactions(e,n){const a={page:n.page??1};return n.hasOwnProperty("start")&&(a.start=g(n.start,"y-MM-dd")),n.hasOwnProperty("end")&&(a.end=g(n.end,"y-MM-dd")),O.get("/api/v2/accounts/"+e+"/transactions",{params:a})}}function N(t){return t==="sankey"?{type:"sankey",data:{datasets:[]},options:{animations:!1}}:t==="pie"?{type:"pie",data:{datasets:[]}}:t==="column"?{type:"bar",data:{labels:[],datasets:[]},options:{plugins:{tooltip:{callbacks:{label:function(e){let n=e.dataset.currency_code;return f(e.raw,n)}}}},maintainAspectRatio:!1,scales:{}}}:t==="line"?{options:{plugins:{tooltip:{callbacks:{label:function(e){let n=e.dataset.currency_code;return f(e.raw,n)}}}},maintainAspectRatio:!1,scales:{x:{type:"time",time:{tooltipFormat:"PP"}}}},type:"line",data:{labels:[],datasets:[]}}:{}}let q=new m("#36a2eb"),I=new m("#ff6384"),G=new m("#4bc0c0"),ft=new m("#ff9f40"),qt=new m("#9966ff"),Nt=new m("#ffcd56"),Yt=new m("#c9cbcf"),lt=0;window.theme==="dark"&&(I.darken(.3).desaturate(.3),G.darken(.3).desaturate(.3),q.darken(.3).desaturate(.3),ft.darken(.3).desaturate(.3));let z=[I,ft,q,G,qt,Nt,Yt,G];function j(t,e){let n={borderColor:I.rgbString(),backgroundColor:I.rgbString()},a;switch(t){default:let o=Math.floor(lt/2)%z.length;a=new m(z[o].rgbString()),a.lighten(.38),n={borderColor:z[o].hexString(),backgroundColor:a.hexString()};break;case"spent":a=new m(q.rgbString()),a.lighten(.38),n={borderColor:q.rgbString(),backgroundColor:a.rgbString()};break;case"left":a=new m(G.rgbString()),a.lighten(.38),n={borderColor:G.rgbString(),backgroundColor:a.rgbString()};break;case"overspent":a=new m(I.rgbString()),a.lighten(.22),n={borderColor:I.rgbString(),backgroundColor:a.rgbString()};break}return lt++,e==="border"?n.borderColor:e==="background"?n.backgroundColor:"#FF0000"}let A=[],$=null,H=null,J=!1;const Ut=()=>({loading:!1,loadingAccounts:!1,accountList:[],autoConversion:!1,chartOptions:null,switchAutoConversion(){this.autoConversion=!this.autoConversion,Tt("autoConversion",this.autoConversion)},getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-accounts-chart",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){console.log(r),this.drawChart(this.generateOptions(r)),this.loading=!1;return}new Rt().dashboard(t,e,null).then(i=>{this.chartData=i.data,window.store.set(n,i.data),console.log(i.data),this.drawChart(this.generateOptions(this.chartData)),this.loading=!1})},generateOptions(t){A=[];let e=N("line");for(let n=0;n0){this.loadingAccounts=!1;return}const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-accounts-data",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){this.accountList=r,this.loadingAccounts=!1;return}const o=10;let i=0,l=0,u=[];Promise.all([v("frontpageAccounts")]).then(d=>{i=d[0].length;for(let h in d[0]){let c=d[0];if(c.hasOwnProperty(h)){let _=c[h];new st().get(_,new Date(window.store.get("end"))).then(w=>{let C=w.data.data;const yt={page:1,start:new Date(window.store.get("start")),end:new Date(window.store.get("end"))};new st().transactions(C.id,yt).then(at=>{let nt=[];for(let B=0;B=o);B++){let M=at.data.data[B],rt={title:M.attributes.group_title===null?"":M.attributes.group_title,id:M.id,transactions:[]};for(let Y=0;YB.order-M.order),this.accountList=u,this.loadingAccounts=!1,window.store.set(n,u))})})}}})},init(){Promise.all([v("viewRange","1M"),v("autoConversion",!1),v("language","en_US")]).then(t=>{this.autoConversion=t[1],J=!0,this.loadChart(),this.loadAccounts()}),window.store.observe("end",()=>{J&&(H=null,this.accountList=[],this.loadChart(),this.loadAccounts())}),window.store.observe("autoConversion",()=>{J&&(this.loadChart(),this.loadAccounts())})}});let zt=class{dashboard(e,n){let a=g(e,"y-MM-dd"),r=g(n,"y-MM-dd");return O.get("/api/v2/chart/budget/dashboard",{params:{start:a,end:r}})}},V=[],T=null,F=null,Z=!1;const Ht=()=>({loading:!1,autoConversion:!1,loadChart(){if(this.loading!==!0){if(this.loading=!0,F!==null){this.drawChart(this.generateOptions(F)),this.loading=!1;return}this.getFreshData()}},drawChart(t){if(T!==null){T.data.datasets=t.data.datasets,T.update();return}T=new S(document.querySelector("#budget-chart"),t)},getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-budgets-chart",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){F=r,this.drawChart(this.generateOptions(F)),this.loading=!1;return}new zt().dashboard(t,e,null).then(i=>{F=i.data,this.drawChart(this.generateOptions(F)),window.store.set(n,F),this.loading=!1})},generateOptions(t){V=[];let e=N("column");e.options.locale=window.store.get("locale").replace("_","-"),e.options.plugins={tooltip:{callbacks:{title:function(n){return n.label},label:function(n){let a=n.dataset.label||"";return a&&(a+=": "),a+" "+f(n.parsed.y,V[n.parsed.x]??"EUR")}}}},e.data={labels:[],datasets:[{label:p.t("firefly.spent"),data:[],borderWidth:1,stack:1,backgroundColor:j("spent","background"),borderColor:j("spent","border")},{label:p.t("firefly.left"),data:[],borderWidth:1,stack:1,backgroundColor:j("left","background"),borderColor:j("left","border")},{label:p.t("firefly.overspent"),data:[],borderWidth:1,stack:1,backgroundColor:j("overspent","background"),borderColor:j("overspent","border")}]};for(const n in t)if(t.hasOwnProperty(n)){let a=t[n],r=a.label+" ("+a.currency_code+")";e.data.labels.push(r),this.autoConversion&&(V.push(a.native_currency_code),e.data.datasets[0].data.push(parseFloat(a.native_entries.spent)*-1),e.data.datasets[1].data.push(parseFloat(a.native_entries.left)),e.data.datasets[2].data.push(parseFloat(a.native_entries.overspent))),this.autoConversion||(V.push(a.currency_code),e.data.datasets[0].data.push(parseFloat(a.entries.spent)*-1),e.data.datasets[1].data.push(parseFloat(a.entries.left)),e.data.datasets[2].data.push(parseFloat(a.entries.overspent)))}return e.options.scales={y:{ticks:{callback:function(n){return f(n,V[0]??"EUR")}}}},e},init(){Promise.all([v("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],Z=!0,this.loading===!1&&this.loadChart()}),window.store.observe("end",()=>{Z&&this.loading===!1&&(F=null,this.loadChart())}),window.store.observe("autoConversion",t=>{Z&&(this.autoConversion=t,this.loading===!1&&this.loadChart())})}});class Jt{dashboard(e,n){let a=g(e,"y-MM-dd"),r=g(n,"y-MM-dd");return O.get("/api/v2/chart/category/dashboard",{params:{start:a,end:r}})}}let ut=[],K=null,W=null,Q=!1;const Zt=()=>({loading:!1,autoConversion:!1,generateOptions(t){ut=[];let e=N("column"),n={};for(const r in t)if(t.hasOwnProperty(r)){let o=t[r],i=o.currency_code;this.autoConversion&&(i=o.native_currency_code),n.hasOwnProperty(i)||(n[i]={name:i,yAxisID:"",data:{}},ut.push(i))}for(const r in t)if(t.hasOwnProperty(r)){let o=t[r],i=o.currency_code;this.autoConversion&&(i=o.native_currency_code);for(const l in n)if(n.hasOwnProperty(l)){let u=0;i===l&&(u=parseFloat(o.amount),""+o.currency_code,this.autoConversion&&(u=parseFloat(o.native_amount),""+o.native_currency_code)),n[l].data.hasOwnProperty(o.label)&&(n[l].data[o.label]=n[l].data[o.label]+u),n[l].data.hasOwnProperty(o.label)||(n[l].data[o.label]=u)}e.data.labels.includes(o.label)||e.data.labels.push(o.label)}let a=0;for(const r in n){let o="y"+r,i={label:r,currency_code:r,yAxisID:o,data:[]};for(const l in n[r].data)i.data.push(n[r].data[l]);e.data.datasets.push(i),e.options.scales.hasOwnProperty(o)||(e.options.scales[o]={beginAtZero:!0,type:"linear",position:a===1?"right":"left",ticks:{callback:function(l,u,d){return f(l,r)}}},a++)}return e},drawChart(t){if(K!==null){K.options=t.options,K.data=t.data,K.update();return}K=new S(document.querySelector("#category-chart"),t)},getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P("dashboard-categories-chart",t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){W=r,this.drawChart(this.generateOptions(W)),this.loading=!1;return}new Jt().dashboard(t,e,null).then(i=>{W=i.data,this.drawChart(this.generateOptions(i.data)),window.store.set(n,W),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,W!==null){this.drawChart(this.generateOptions(W)),this.loading=!1;return}this.getFreshData()}},init(){Promise.all([v("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],Q=!0,this.loadChart()}),window.store.observe("end",()=>{Q&&(this.chartData=null,this.loadChart())}),window.store.observe("autoConversion",t=>{Q&&(this.autoConversion=t,this.loadChart())})}});S.register({SankeyController:vt,Flow:mt});const ct="dashboard-sankey-data";let X=!1,R=null,D=[],y=!1,s={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 dt=function(t){return t.includes(s.revenue_account)?"forestgreen":t.includes("("+s.in+",")?"green":t.includes(s.budget)||t.includes(s.unknown_budget)?"Orchid":t.includes("("+s.out+",")?"MediumOrchid":t.includes(s.all_money)?"blue":"red"};function L(t,e,n,a){if(t==="category"&&e!==null&&n==="in")return s.category+' "'+e+'" ('+s.in+(y?", "+a+")":")");if(t==="category"&&e===null&&n==="in")return s.unknown_category+" ("+s.in+(y?", "+a+")":")");if(t==="category"&&e!==null&&n==="out")return s.category+' "'+e+'" ('+s.out+(y?", "+a+")":")");if(t==="category"&&e===null&&n==="out")return s.unknown_category+" ("+s.out+(y?", "+a+")":")");if(t==="account"&&e===null&&n==="in")return s.unknown_source+(y?" ("+a+")":"");if(t==="account"&&e!==null&&n==="in")return s.revenue_account+'"'+e+'"'+(y?" ("+a+")":"");if(t==="account"&&e===null&&n==="out")return s.unknown_dest+(y?" ("+a+")":"");if(t==="account"&&e!==null&&n==="out")return s.expense_account+' "'+e+'"'+(y?" ("+a+")":"");if(t==="budget"&&e!==null)return s.budget+' "'+e+'"'+(y?" ("+a+")":"");if(t==="budget"&&e===null)return s.unknown_budget+(y?" ("+a+")":"");console.error('Cannot handle: type:"'+t+'", dir: "'+n+'"')}function E(t,e,n){if(t==="category"&&e!==null)return s.category+' "'+e+'"'+(y?" ("+n+")":"");if(t==="category"&&e===null)return s.unknown_category+(y?" ("+n+")":"");if(t==="account"&&e===null)return s.unknown_account+(y?" ("+n+")":"");if(t==="account"&&e!==null)return e+(y?" ("+n+")":"");if(t==="budget"&&e!==null)return s.budget+' "'+e+'"'+(y?" ("+n+")":"");if(t==="budget"&&e===null)return s.unknown_budget+(y?" ("+n+")":"");console.error('Cannot handle: type:"'+t+'"')}const Qt=()=>({loading:!1,autoConversion:!1,generateOptions(){let t=N("sankey"),e={},n={};for(let r in D)if(D.hasOwnProperty(r)){let o=D[r];for(let i in o.attributes.transactions)if(o.attributes.transactions.hasOwnProperty(i)){let l=o.attributes.transactions[i],u=this.autoConversion?l.native_currency_code:l.currency_code,d=this.autoConversion?parseFloat(l.native_amount):parseFloat(l.amount),h;if(l.type==="deposit"){let c=L("category",l.category_name,"in",u),_=L("account",l.source_name,"in",u);n[c]=E("category",l.category_name,u),n[_]=E("account",l.source_name,u),h=_+"-"+c+"-"+u,e.hasOwnProperty(h)||(e[h]={from:_,to:c,amount:0}),e[h].amount+=d,h=c+"-"+s.all_money+"-"+u,e.hasOwnProperty(h)||(e[h]={from:c,to:s.all_money+(this.autoConversion?" ("+u+")":""),amount:0}),e[h].amount+=d}if(l.type==="withdrawal"){let c=L("budget",l.budget_name,"out",u);n[c]=E("budget",l.budget_name,u),h=s.all_money+"-"+c+"-"+u,e.hasOwnProperty(h)||(e[h]={from:s.all_money+(this.autoConversion?" ("+u+")":""),to:c,amount:0}),e[h].amount+=d;let _=L("category",l.category_name,"out",u);n[_]=E("category",l.category_name,u),h=c+"-"+_+"-"+u,e.hasOwnProperty(h)||(e[h]={from:c,to:_,amount:0}),e[h].amount+=d;let w=L("account",l.destination_name,"out",u);n[w]=E("account",l.destination_name,u),h=_+"-"+w+"-"+u,e.hasOwnProperty(h)||(e[h]={from:_,to:w,amount:0}),e[h].amount+=d}}}let a={label:"Firefly III dashboard sankey chart",data:[],colorFrom:r=>dt(r.dataset.data[r.dataIndex]?r.dataset.data[r.dataIndex].from:""),colorTo:r=>dt(r.dataset.data[r.dataIndex]?r.dataset.data[r.dataIndex].to:""),colorMode:"gradient",labels:n,size:"min"};for(let r in e)if(e.hasOwnProperty(r)){let o=e[r];a.data.push({from:o.from,to:o.to,flow:o.amount})}return t.data.datasets.push(a),t},drawChart(t){if(R!==null){R.data.datasets=t.data.datasets,R.update();return}R=new S(document.querySelector("#sankey-chart"),t)},getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P(ct,t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){D=r,this.drawChart(this.generateOptions()),this.loading=!1;return}let o={start:g(t,"y-MM-dd"),end:g(e,"y-MM-dd"),type:"withdrawal,deposit",page:1};this.downloadTransactions(o)},downloadTransactions(t){const e=new Date(window.store.get("start")),n=new Date(window.store.get("end")),a=P(ct,e,n);new $t().list(t).then(o=>{if(D=[...D,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>t.page){t.page++,this.downloadTransactions(t);return}window.store.set(a,D),this.drawChart(this.generateOptions()),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,D.length!==0){this.drawChart(this.generateOptions()),this.loading=!1;return}this.getFreshData()}},init(){D=[],Promise.all([v("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],y=t[0],s.all_money=p.t("firefly.all_money"),s.category=p.t("firefly.category"),s.in=p.t("firefly.money_flowing_in"),s.out=p.t("firefly.money_flowing_out"),s.unknown_category=p.t("firefly.unknown_category_plain"),s.unknown_source=p.t("firefly.unknown_source_plain"),s.unknown_dest=p.t("firefly.unknown_dest_plain"),s.unknown_account=p.t("firefly.unknown_any_plain"),s.unknown_budget=p.t("firefly.unknown_budget_plain"),s.expense_account=p.t("firefly.expense_account"),s.revenue_account=p.t("firefly.revenue_account"),s.budget=p.t("firefly.budget"),X=!0,this.loadChart()}),window.store.observe("end",()=>{X&&(this.transactions=[],this.loadChart())}),window.store.observe("autoConversion",t=>{X&&(this.autoConversion=t,this.loadChart())})}});let tt=!1,b={};function gt(t){return new Vt().list(t).then(n=>{let a=n.data.data;for(let r in a)if(a.hasOwnProperty(r)){let o=a[r];if(o.attributes.active&&o.attributes.pay_dates.length>0){let i=o.attributes.object_group_id===null?0:o.attributes.object_group_id,l=o.attributes.object_group_title===null?p.t("firefly.default_group_title_name_plain"):o.attributes.object_group_title,u=o.attributes.object_group_order===null?0:o.attributes.object_group_order;b.hasOwnProperty(i)||(b[i]={id:i,title:l,order:u,payment_info:{},bills:[]});let d={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};d.expected_amount=t.autoConversion?f(d.native_amount,d.native_currency_code):f(d.amount,d.currency_code),d.expected_times=p.t("firefly.subscr_expected_x_times",{times:o.attributes.pay_dates.length,amount:d.expected_amount});for(let h in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(h)){const c=o.attributes.paid_dates[h];let _=100;t.autoConversion&&(_=Math.round(-100+parseFloat(c.native_amount)*-1/parseFloat(d.native_amount)*100)),t.autoConversion||(_=Math.round(-100+parseFloat(c.amount)*-1/parseFloat(d.amount)*100));let w={amount:t.autoConversion?f(c.native_amount,c.native_currency_code):f(c.amount,c.currency_code),percentage:_,date:g(new Date(c.date),"PP"),foreign_amount:null};c.foreign_currency_code!==null&&(w.foreign_amount=t.autoConversion?c.foreign_native_amount:c.foreign_amount,w.foreign_currency_code=t.autoConversion?c.native_currency_code:c.foreign_currency_code),d.transactions.push(w)}if(b[i].bills.push(d),o.attributes.paid_dates.length===0){const h=o.attributes.pay_dates.length*d.amount,c=o.attributes.pay_dates.length*d.native_amount;b[i].payment_info.hasOwnProperty(d.currency_code)||(b[i].payment_info[d.currency_code]={currency_code:d.currency_code,paid:0,unpaid:0,native_currency_code:d.native_currency_code,native_paid:0,native_unpaid:0}),b[i].payment_info[d.currency_code].unpaid+=h,b[i].payment_info[d.currency_code].native_unpaid+=c}if(o.attributes.paid_dates.length>0){for(let h in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(h)){let c=o.attributes.paid_dates[h];b[i].payment_info.hasOwnProperty(c.currency_code)||(b[i].payment_info[c.currency_code]={currency_code:d.currency_code,paid:0,unpaid:0,native_currency_code:d.native_currency_code,native_paid:0,native_unpaid:0});const _=parseFloat(c.amount)*-1,w=parseFloat(c.native_amount)*-1;b[i].payment_info[c.currency_code].paid+=_,b[i].payment_info[c.currency_code].native_paid+=w}}}}return parseInt(n.data.meta.pagination.total_pages)>t.page?(t.page++,gt(t)):Promise.resolve()})}const Xt=()=>({loading:!1,autoConversion:!1,subscriptions:[],startSubscriptions(){this.loading=!0;let t=new Date(window.store.get("start")),e=new Date(window.store.get("end"));const n=window.store.get("cacheValid");let a=window.store.get(P("subscriptions-data-dashboard",t,e));n&&typeof a<"u",b={},this.subscriptions=[];let r={start:g(t,"y-MM-dd"),end:g(e,"y-MM-dd"),autoConversion:this.autoConversion,page:1};gt(r).then(()=>{let o=Object.values(b);for(let i in o)if(o.hasOwnProperty(i)){let l=o[i];const u=Object.keys(l.payment_info);l.col_size=u.length===1?"col-6 offset-3":"col-6",l.chart_width=u.length===1?"50%":"100%",l.payment_length=u.length,this.subscriptions.push(l)}this.loading=!1})},drawPieChart(t,e,n){let a="#pie_"+t+"_"+n.currency_code;const r=this.autoConversion?n.native_unpaid:n.unpaid,o=this.autoConversion?n.native_paid:n.paid,i=this.autoConversion?n.native_currency_code:n.currency_code,u={type:"doughnut",data:{labels:[p.t("firefly.paid"),p.t("firefly.unpaid")],datasets:[{label:p.t("firefly.subscriptions_in_group",{title:e}),data:[o,r],backgroundColor:["rgb(54, 162, 235)","rgb(255, 99, 132)"],hoverOffset:4}]},options:{plugins:{tooltip:{callbacks:{label:function(h){return h.dataset.label+": "+f(h.raw,i)}}}}}};var d=S.getChart(document.querySelector(a));typeof d<"u"&&d.destroy(),new S(document.querySelector(a),u)},init(){Promise.all([v("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],tt=!0,this.loading===!1&&this.startSubscriptions()}),window.store.observe("end",()=>{tt&&this.loading===!1&&this.startSubscriptions()}),window.store.observe("autoConversion",t=>{tt&&(this.autoConversion=t,this.loading===!1&&this.startSubscriptions())})}});let x={},et=!1;const ht="dashboard-piggies-data",te=()=>({loading:!1,autoConversion:!1,sankeyGrouping:"account",piggies:[],getFreshData(){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),n=P(ht,t,e),a=window.store.get("cacheValid");let r=window.store.get(n);if(a&&typeof r<"u"){x=r,this.parsePiggies(),this.loading=!1;return}let o={start:g(t,"y-MM-dd"),end:g(e,"y-MM-dd"),page:1};this.downloadPiggyBanks(o)},downloadPiggyBanks(t){const e=new Date(window.store.get("start")),n=new Date(window.store.get("end")),a=P(ht,e,n);new Kt().list(t).then(o=>{if(x=[...x,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>t.page){t.page++,this.downloadPiggyBanks(t);return}window.store.set(a,x),this.parsePiggies(),this.loading=!1})},parsePiggies(){let t=[];for(let e in x)if(x.hasOwnProperty(e)){let n=x[e];if(n.attributes.percentage>=100||n.attributes.percentage===0)continue;let a=n.object_group_title??p.t("firefly.default_group_title_name_plain");t.hasOwnProperty(a)||(t[a]={id:n.object_group_id??0,title:a,order:n.object_group_order??0,piggies:[]});let r={id:n.id,name:n.attributes.name,percentage:parseInt(n.attributes.percentage),amount:this.autoConversion?n.attributes.native_current_amount:n.attributes.current_amount,left_to_save:this.autoConversion?n.attributes.native_left_to_save:n.attributes.left_to_save,target_amount:this.autoConversion?n.attributes.native_target_amount:n.attributes.target_amount,save_per_month:this.autoConversion?n.attributes.native_save_per_month:n.attributes.save_per_month,currency_code:this.autoConversion?n.attributes.native_currency_code:n.attributes.currency_code};t[a].piggies.push(r)}this.piggies=Object.values(t)},loadPiggyBanks(){if(this.loading!==!0){if(this.loading=!0,this.piggies.length!==0){this.parsePiggies(),this.loading=!1;return}this.getFreshData()}},init(){x=[],Promise.all([v("autoConversion",!1)]).then(t=>{et=!0,this.autoConversion=t[0],this.loadPiggyBanks()}),window.store.observe("end",()=>{et&&(x=[],this.loadPiggyBanks())}),window.store.observe("autoConversion",t=>{et&&(this.autoConversion=t,this.loadPiggyBanks())})}});S.register({LineController:Ct,LineElement:kt,ArcElement:Pt,BarController:Dt,TimeScale:xt,PieController:Ot,BarElement:Mt,Filler:Ft,Colors:St,LinearScale:At,CategoryScale:Bt,PointElement:jt,Tooltip:Wt,Legend:It});const pt={dates:wt,boxes:Et,accounts:Ut,budgets:Ht,categories:Zt,sankey:Qt,subscriptions:Xt,piggies:te};function _t(t){Object.keys(t).forEach(e=>{let n=t[e]();Alpine.data(e,()=>n)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),_t(pt)});window.bootstrapped&&(console.log("Loaded through window variable."),_t(pt)); diff --git a/public/build/assets/edit-65e334e0.js b/public/build/assets/edit-acae2aeb.js similarity index 95% rename from public/build/assets/edit-65e334e0.js rename to public/build/assets/edit-acae2aeb.js index e3b724c880..15d597a28b 100644 --- a/public/build/assets/edit-65e334e0.js +++ b/public/build/assets/edit-acae2aeb.js @@ -1 +1 @@ -import{a as p,d as f,f as l}from"./format-money-0f129d93.js";import{G as g}from"./get-851d8544.js";import{p as m}from"./parse-downloaded-splits-109be2c7.js";import{p as w,d as y,e as a,f as b,g as S,h as P,i as v,l as C,a as A,b as _,c as E,s as D,j as T,k as u,m as c}from"./splice-errors-into-transactions-cc245990.js";import{i as r,m as x}from"./vendor-baac879b.js";import{d as B}from"./create-empty-split-16bf9f82.js";import"./get-d03e8e57.js";class L{put(s,o){let e="/api/v2/transactions/"+parseInt(o.id);return p.put(e,s)}}const n=T();let I=function(){return{entries:[],originals:[],formStates:{loadingCurrencies:!0,loadingBudgets:!0,loadingPiggyBanks:!0,loadingSubscriptions:!0,isSubmitting:!1,returnHereButton:!1,saveAsNewButton:!1,resetButton:!0,rulesButton:!0,webhooksButton:!0},formBehaviour:{formType:"edit",foreignCurrencyEnabled:!0},formData:{defaultCurrency:null,enabledCurrencies:[],nativeCurrencies:[],foreignCurrencies:[],budgets:[],piggyBanks:[],subscriptions:[]},groupProperties:{transactionType:"unknown",title:null,editTitle:null,id:null,totalAmount:0},notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},submitTransaction(){this.notifications.error.show=!1,this.notifications.success.show=!1,this.notifications.wait.show=!1;for(let e in this.entries)this.entries.hasOwnProperty(e)&&(this.entries[e].errors=B());this.formStates.isSubmitting=!0;let t=w(this.entries,this.originals,this.groupProperties.transactionType),s={group_title:this.groupProperties.editTitle,fire_webhooks:this.formStates.webhooksButton,apply_rules:this.formStates.rulesButton,transactions:t};this.groupProperties.title===null&&t.length>1&&(s.group_title=t[0].description);let o=new L;console.log(s),o.put(s,{id:this.groupProperties.id}).then(e=>{const i=e.data.data;if(this.groupProperties.id=parseInt(i.id),this.groupProperties.title=i.attributes.group_title??i.attributes.transactions[0].description,y(this.groupProperties.id,i.attributes.transactions)>0){this.notifications.wait.show=!0,this.notifications.wait.text=r.t("firefly.wait_attachments");return}this.showMessageOrRedirectUser()}).catch(e=>{this.submitting=!1,console.log(e),typeof e.response<"u"&&this.parseErrors(e.response.data)})},filters:{source:[],destination:[]},addedSplit(){setTimeout(()=>{const t=function(s,o,e){return s.name_with_balance+'
'+r.t("firefly.account_type_"+s.type)+""};a({selector:"input.ac-source",serverUrl:n.account,filters:this.filters.source,onRenderItem:t,onChange:b,onSelectItem:S}),a({selector:"input.ac-dest",serverUrl:n.account,filters:this.filters.destination,onRenderItem:t,onChange:P,onSelectItem:v}),a({selector:"input.ac-category",serverUrl:n.category,valueField:"id",labelField:"name",onChange:u,onSelectItem:u}),a({selector:"input.ac-description",serverUrl:n.description,valueField:"id",labelField:"description",onChange:c,onSelectItem:c})},250)},changedDateTime(t){console.warn("changedDateTime, event is not used")},changedDescription(t){console.warn("changedDescription, event is not used")},changedDestinationAccount(t){console.warn("changedDestinationAccount, event is not used")},changedSourceAccount(t){console.warn("changedSourceAccount, event is not used")},formattedTotalAmount(){return this.entries.length===0?l(this.groupProperties.totalAmount,"EUR"):l(this.groupProperties.totalAmount,this.entries[0].currency_code??"EUR")},getTags(t){return console.log("at get tags "+t),console.log(this.entries[t].tags),this.entries[t].tags??[]},getTransactionGroup(){this.entries=[];const t=window.location.href.split("/"),s=parseInt(t[t.length-1]);new g().show(s,{}).then(e=>{const i=e.data.data;this.groupProperties.id=parseInt(i.id),this.groupProperties.transactionType=i.attributes.transactions[0].type.toLowerCase(),this.groupProperties.title=i.attributes.title??i.attributes.transactions[0].description,this.entries=m(i.attributes.transactions,parseInt(i.id)),this.notifications.wait.show=!1}).then(()=>{this.groupProperties.totalAmount=0;for(let e in this.entries)this.entries.hasOwnProperty(e)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[e].amount),this.filters.source.push(this.entries[e].source_account.type),this.filters.destination.push(this.entries[e].destination_account.type));console.log(this.filters),setTimeout(()=>{x.init("select.ac-tags",{allowClear:!0,server:n.tag,liveServer:!0,clearEnd:!0,allowNew:!0,notFoundMessage:r.t("firefly.nothing_found"),noCache:!0,fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}}})},150)})},init(){this.notifications.wait.show=!0,this.notifications.wait.text=r.t("firefly.wait_loading_transaction"),this.getTransactionGroup(),C().then(t=>{this.formStates.loadingCurrencies=!1,this.formData.defaultCurrency=t.defaultCurrency,this.formData.enabledCurrencies=t.enabledCurrencies,this.formData.nativeCurrencies=t.nativeCurrencies,this.formData.foreignCurrencies=t.foreignCurrencies}),A().then(t=>{this.formData.budgets=t,this.formStates.loadingBudgets=!1}),_().then(t=>{this.formData.piggyBanks=t,this.formStates.loadingPiggyBanks=!1}),E().then(t=>{this.formData.subscriptions=t,this.formStates.loadingSubscriptions=!1}),document.addEventListener("upload-success",t=>{this.processUpload(t),document.querySelectorAll("input[type=file]").value=""}),document.addEventListener("upload-error",t=>{this.processUploadError(t)}),document.addEventListener("location-move",t=>{this.entries[t.detail.index].latitude=t.detail.latitude,this.entries[t.detail.index].longitude=t.detail.longitude}),document.addEventListener("location-set",t=>{this.entries[t.detail.index].hasLocation=!0,this.entries[t.detail.index].latitude=t.detail.latitude,this.entries[t.detail.index].longitude=t.detail.longitude,this.entries[t.detail.index].zoomLevel=t.detail.zoomLevel}),document.addEventListener("location-zoom",t=>{this.entries[t.detail.index].hasLocation=!0,this.entries[t.detail.index].zoomLevel=t.detail.zoomLevel})},changedAmount(t){const s=parseInt(t.target.dataset.index);this.entries[s].amount=parseFloat(t.target.value),this.groupProperties.totalAmount=0;for(let o in this.entries)this.entries.hasOwnProperty(o)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[o].amount))},showMessageOrRedirectUser(){if(this.notifications.error.show=!1,this.notifications.success.show=!1,this.notifications.wait.show=!1,this.formStates.returnHereButton){this.notifications.success.show=!0,this.notifications.success.url="transactions/show/"+this.groupProperties.id,this.notifications.success.text=r.t("firefly.updated_journal_js",{description:this.groupProperties.title});return}window.location="transactions/show/"+this.groupProperties.id+"?transaction_group_id="+this.groupProperties.id+"&message=updated"},parseErrors(t){this.notifications.error.show=!0,this.notifications.success.show=!1,this.notifications.wait.show=!1,this.formStates.isSubmitting=!1,this.notifications.error.text=r.t("firefly.errors_submission_v2",{errorMessage:t.message}),t.hasOwnProperty("errors")&&(this.entries=D(t.errors,this.entries))},processUpload(t){this.showMessageOrRedirectUser()},processUploadError(t){this.notifications.success.show=!1,this.notifications.wait.show=!1,this.notifications.error.show=!0,this.formStates.isSubmitting=!1,this.notifications.error.text=r.t("firefly.errors_upload"),console.error(t)}}},h={transactions:I,dates:f};function d(){Object.keys(h).forEach(t=>{console.log(`Loading page component "${t}"`);let s=h[t]();Alpine.data(t,()=>s)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),d()});window.bootstrapped&&(console.log("Loaded through window variable."),d()); +import{a as p,d as f,f as l}from"./format-money-e4c435dc.js";import{G as g}from"./get-5236bc21.js";import{p as m}from"./parse-downloaded-splits-c0536134.js";import{p as w,d as y,e as a,f as b,g as S,h as P,i as v,l as C,a as A,b as _,c as E,s as D,j as T,k as u,m as c}from"./splice-errors-into-transactions-cc4832b4.js";import{i as r,m as x}from"./vendor-76961a66.js";import{d as B}from"./create-empty-split-9cc18e2d.js";import"./get-95250f8d.js";class L{put(s,o){let e="/api/v2/transactions/"+parseInt(o.id);return p.put(e,s)}}const n=T();let I=function(){return{entries:[],originals:[],formStates:{loadingCurrencies:!0,loadingBudgets:!0,loadingPiggyBanks:!0,loadingSubscriptions:!0,isSubmitting:!1,returnHereButton:!1,saveAsNewButton:!1,resetButton:!0,rulesButton:!0,webhooksButton:!0},formBehaviour:{formType:"edit",foreignCurrencyEnabled:!0},formData:{defaultCurrency:null,enabledCurrencies:[],nativeCurrencies:[],foreignCurrencies:[],budgets:[],piggyBanks:[],subscriptions:[]},groupProperties:{transactionType:"unknown",title:null,editTitle:null,id:null,totalAmount:0},notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},submitTransaction(){this.notifications.error.show=!1,this.notifications.success.show=!1,this.notifications.wait.show=!1;for(let e in this.entries)this.entries.hasOwnProperty(e)&&(this.entries[e].errors=B());this.formStates.isSubmitting=!0;let t=w(this.entries,this.originals,this.groupProperties.transactionType),s={group_title:this.groupProperties.editTitle,fire_webhooks:this.formStates.webhooksButton,apply_rules:this.formStates.rulesButton,transactions:t};this.groupProperties.title===null&&t.length>1&&(s.group_title=t[0].description);let o=new L;console.log(s),o.put(s,{id:this.groupProperties.id}).then(e=>{const i=e.data.data;if(this.groupProperties.id=parseInt(i.id),this.groupProperties.title=i.attributes.group_title??i.attributes.transactions[0].description,y(this.groupProperties.id,i.attributes.transactions)>0){this.notifications.wait.show=!0,this.notifications.wait.text=r.t("firefly.wait_attachments");return}this.showMessageOrRedirectUser()}).catch(e=>{this.submitting=!1,console.log(e),typeof e.response<"u"&&this.parseErrors(e.response.data)})},filters:{source:[],destination:[]},addedSplit(){setTimeout(()=>{const t=function(s,o,e){return s.name_with_balance+'
'+r.t("firefly.account_type_"+s.type)+""};a({selector:"input.ac-source",serverUrl:n.account,filters:this.filters.source,onRenderItem:t,onChange:b,onSelectItem:S}),a({selector:"input.ac-dest",serverUrl:n.account,filters:this.filters.destination,onRenderItem:t,onChange:P,onSelectItem:v}),a({selector:"input.ac-category",serverUrl:n.category,valueField:"id",labelField:"name",onChange:u,onSelectItem:u}),a({selector:"input.ac-description",serverUrl:n.description,valueField:"id",labelField:"description",onChange:c,onSelectItem:c})},250)},changedDateTime(t){console.warn("changedDateTime, event is not used")},changedDescription(t){console.warn("changedDescription, event is not used")},changedDestinationAccount(t){console.warn("changedDestinationAccount, event is not used")},changedSourceAccount(t){console.warn("changedSourceAccount, event is not used")},formattedTotalAmount(){return this.entries.length===0?l(this.groupProperties.totalAmount,"EUR"):l(this.groupProperties.totalAmount,this.entries[0].currency_code??"EUR")},getTags(t){return console.log("at get tags "+t),console.log(this.entries[t].tags),this.entries[t].tags??[]},getTransactionGroup(){this.entries=[];const t=window.location.href.split("/"),s=parseInt(t[t.length-1]);new g().show(s,{}).then(e=>{const i=e.data.data;this.groupProperties.id=parseInt(i.id),this.groupProperties.transactionType=i.attributes.transactions[0].type.toLowerCase(),this.groupProperties.title=i.attributes.title??i.attributes.transactions[0].description,this.entries=m(i.attributes.transactions,parseInt(i.id)),this.notifications.wait.show=!1}).then(()=>{this.groupProperties.totalAmount=0;for(let e in this.entries)this.entries.hasOwnProperty(e)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[e].amount),this.filters.source.push(this.entries[e].source_account.type),this.filters.destination.push(this.entries[e].destination_account.type));console.log(this.filters),setTimeout(()=>{x.init("select.ac-tags",{allowClear:!0,server:n.tag,liveServer:!0,clearEnd:!0,allowNew:!0,notFoundMessage:r.t("firefly.nothing_found"),noCache:!0,fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}}})},150)})},init(){this.notifications.wait.show=!0,this.notifications.wait.text=r.t("firefly.wait_loading_transaction"),this.getTransactionGroup(),C().then(t=>{this.formStates.loadingCurrencies=!1,this.formData.defaultCurrency=t.defaultCurrency,this.formData.enabledCurrencies=t.enabledCurrencies,this.formData.nativeCurrencies=t.nativeCurrencies,this.formData.foreignCurrencies=t.foreignCurrencies}),A().then(t=>{this.formData.budgets=t,this.formStates.loadingBudgets=!1}),_().then(t=>{this.formData.piggyBanks=t,this.formStates.loadingPiggyBanks=!1}),E().then(t=>{this.formData.subscriptions=t,this.formStates.loadingSubscriptions=!1}),document.addEventListener("upload-success",t=>{this.processUpload(t),document.querySelectorAll("input[type=file]").value=""}),document.addEventListener("upload-error",t=>{this.processUploadError(t)}),document.addEventListener("location-move",t=>{this.entries[t.detail.index].latitude=t.detail.latitude,this.entries[t.detail.index].longitude=t.detail.longitude}),document.addEventListener("location-set",t=>{this.entries[t.detail.index].hasLocation=!0,this.entries[t.detail.index].latitude=t.detail.latitude,this.entries[t.detail.index].longitude=t.detail.longitude,this.entries[t.detail.index].zoomLevel=t.detail.zoomLevel}),document.addEventListener("location-zoom",t=>{this.entries[t.detail.index].hasLocation=!0,this.entries[t.detail.index].zoomLevel=t.detail.zoomLevel})},changedAmount(t){const s=parseInt(t.target.dataset.index);this.entries[s].amount=parseFloat(t.target.value),this.groupProperties.totalAmount=0;for(let o in this.entries)this.entries.hasOwnProperty(o)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[o].amount))},showMessageOrRedirectUser(){if(this.notifications.error.show=!1,this.notifications.success.show=!1,this.notifications.wait.show=!1,this.formStates.returnHereButton){this.notifications.success.show=!0,this.notifications.success.url="transactions/show/"+this.groupProperties.id,this.notifications.success.text=r.t("firefly.updated_journal_js",{description:this.groupProperties.title});return}window.location="transactions/show/"+this.groupProperties.id+"?transaction_group_id="+this.groupProperties.id+"&message=updated"},parseErrors(t){this.notifications.error.show=!0,this.notifications.success.show=!1,this.notifications.wait.show=!1,this.formStates.isSubmitting=!1,this.notifications.error.text=r.t("firefly.errors_submission_v2",{errorMessage:t.message}),t.hasOwnProperty("errors")&&(this.entries=D(t.errors,this.entries))},processUpload(t){this.showMessageOrRedirectUser()},processUploadError(t){this.notifications.success.show=!1,this.notifications.wait.show=!1,this.notifications.error.show=!0,this.formStates.isSubmitting=!1,this.notifications.error.text=r.t("firefly.errors_upload"),console.error(t)}}},h={transactions:I,dates:f};function d(){Object.keys(h).forEach(t=>{console.log(`Loading page component "${t}"`);let s=h[t]();Alpine.data(t,()=>s)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),d()});window.bootstrapped&&(console.log("Loaded through window variable."),d()); diff --git a/public/build/assets/format-money-0f129d93.js b/public/build/assets/format-money-e4c435dc.js similarity index 99% rename from public/build/assets/format-money-0f129d93.js rename to public/build/assets/format-money-e4c435dc.js index 426839cce9..34894d7d9c 100644 --- a/public/build/assets/format-money-0f129d93.js +++ b/public/build/assets/format-money-e4c435dc.js @@ -1 +1 @@ -import{o as y,s as d,q as l,r as p,t as _,u as c,v as b,w as N,x as P,y as v,z as g,i as C,D as B,E as x,G as O,H as o,I as E,J as T,f as L,K as S,M as W,N as I,O as U,Q as q,R as Q,U as V,V as Y,W as $,X as j,Y as z,Z as X,_ as F,$ as G,a0 as H,a1 as J,a2 as K,a3 as Z,a4 as ee,a5 as te,a6 as ae,a7 as se,a8 as ne,a9 as re,aa as le,ab as de,ac as oe,ad as ie,ae as ue,af as ge,ag as ce,ah as we,ai as he,aj as ye}from"./vendor-baac879b.js";const k="/",h=y.create({baseURL:k,withCredentials:!0});y.defaults.withCredentials=!0;y.defaults.baseURL=k;class R{getByName(e){return h.get("/api/v1/preferences/"+e)}getByNameNow(e){return h.get("/api/v1/preferences/"+e)}postByName(e,a){return h.post("/api/v1/preferences",{name:e,data:a})}}class A{post(e,a){let s="/api/v1/preferences";return h.post(s,{name:e,data:a})}}function fe(t,e=null){return new R().getByName(t).then(s=>Promise.resolve(M(t,s))).catch(()=>{new A().post(t,e).then(i=>Promise.resolve(M(t,i)))})}function M(t,e){return e.data.data.attributes.data}function w(t,e=null){const a=window.store.get("cacheValid");if(a&&window.hasOwnProperty(t))return Promise.resolve(window[t]);const s=window.store.get(t);return a&&typeof s<"u"?Promise.resolve(s):new R().getByName(t).then(u=>Promise.resolve(m(t,u))).catch(()=>{new A().post(t,e).then(n=>Promise.resolve(m(t,n)))})}function m(t,e){let a=e.data.data.attributes.data;return window.store.set(t,a),a}function be(t,e){let a,s;switch(t){case"last365":a=d(g(e,365)),s=l(e);break;case"last90":a=d(g(e,90)),s=l(e);break;case"last30":a=d(g(e,30)),s=l(e);break;case"last7":a=d(g(e,7)),s=l(e);break;case"YTD":a=v(e),s=l(e);break;case"QTD":a=p(e),s=l(e);break;case"MTD":a=c(e),s=l(e);break;case"1D":a=d(e),s=l(e);break;case"1W":a=d(N(e,{weekStartsOn:1})),s=l(P(e,{weekStartsOn:1}));break;case"1M":a=d(c(e)),s=l(b(e));break;case"3M":a=d(p(e)),s=l(_(e));break;case"6M":e.getMonth()<=5&&(a=new Date(e),a.setMonth(0),a.setDate(1),a=d(a),s=new Date(e),s.setMonth(5),s.setDate(30),s=l(a)),e.getMonth()>5&&(a=new Date(e),a.setMonth(6),a.setDate(1),a=d(a),s=new Date(e),s.setMonth(11),s.setDate(31),s=l(a));break;case"1Y":a=new Date(e),a.setMonth(0),a.setDate(1),a=d(a),s=new Date(e),s.setMonth(11),s.setDate(31),s=l(s);break}return{start:a,end:s}}let D=!1;function pe(t){if(D===!1){const e=t.replace("-","_");D=!0;const a=7*24*60*60*1e3;return console.log('Will load language "'+e+'"'),C.use(B).init({load:"languageOnly",fallbackLng:"en",lng:e,debug:!1,backend:{backends:[x,O],backendOptions:[{load:"languageOnly",expirationTime:a},{loadPath:"./v2/i18n/{{lng}}.json"}]}})}return console.warn("Loading translations skipped."),Promise.resolve()}o.addPlugin(E);window.bootstrapped=!1;window.store=o;fe("lastActivity").then(t=>{const e=o.get("lastActivity");o.set("cacheValid",e===t),o.set("lastActivity",t),console.log("Server value: "+t),console.log("Local value: "+e),console.log("Cache valid: "+(e===t))}).then(()=>{Promise.all([w("viewRange"),w("darkMode"),w("locale"),w("language")]).then(t=>{if(!o.get("start")||!o.get("end")){const e=be(t[0],new Date);o.set("start",e.start),o.set("end",e.end)}window.__localeId__=t[2],o.set("language",t[3]),o.set("locale",t[3]),pe(t[3]).then(()=>{const e=new Event("firefly-iii-bootstrapped");document.dispatchEvent(e),window.bootstrapped=!0})})});window.axios=y;window.axios.defaults.headers.common["X-Requested-With"]="XMLHttpRequest";window.Alpine=T;const f={bg:S,cs:W,da:I,de:U,el:q,enGB:Q,enUS:V,es:Y,ca:$,fi:j,fr:z,hu:X,id:F,it:G,ja:H,ko:J,nb:K,nn:Z,nl:ee,pl:te,ptBR:ae,pt:se,ro:ne,ru:re,sk:le,sl:de,sv:oe,tr:ie,uk:ue,vi:ge,zhTW:ce,zhCN:we};function r(t,e="PP"){let a=window.__localeId__.replace("_","");return L(t,e,{locale:f[a]??f[a.slice(0,2)]??f.enUS})}const me=()=>({range:{start:null,end:null},defaultRange:{start:null,end:null},language:"en_US",init(){this.range={start:new Date(window.store.get("start")),end:new Date(window.store.get("end"))},this.defaultRange={start:new Date(window.store.get("start")),end:new Date(window.store.get("end"))},this.language=window.store.get("language"),this.locale=window.store.get("locale"),this.locale=this.locale==="equal"?this.language:this.locale,window.__localeId__=this.language,this.buildDateRange(),window.store.observe("start",t=>{this.range.start=new Date(t)}),window.store.observe("end",t=>{this.range.end=new Date(t),this.buildDateRange()})},buildDateRange(){let t=this.getNextRange(),e=this.getPrevRange(),a=this.lastDays(7),s=this.lastDays(30),i=this.mtd(),u=this.ytd(),n=document.getElementsByClassName("daterange-holder")[0];n.textContent=r(this.range.start)+" - "+r(this.range.end),n.setAttribute("data-start",r(this.range.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(this.range.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-current")[0],n.textContent=r(this.defaultRange.start)+" - "+r(this.defaultRange.end),n.setAttribute("data-start",r(this.defaultRange.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(this.defaultRange.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-next")[0],n.textContent=r(t.start)+" - "+r(t.end),n.setAttribute("data-start",r(t.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(t.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-prev")[0],n.textContent=r(e.start)+" - "+r(e.end),n.setAttribute("data-start",r(e.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(e.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-7d")[0],n.setAttribute("data-start",r(a.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(a.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-90d")[0],n.setAttribute("data-start",r(s.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(s.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-mtd")[0],n.setAttribute("data-start",r(i.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(i.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-ytd")[0],n.setAttribute("data-start",r(u.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(u.end,"yyyy-MM-dd"))},getNextRange(){let t=c(this.range.start),e=he(t,1),a=b(e);return{start:e,end:a}},getPrevRange(){let t=c(this.range.start),e=ye(t,1),a=b(e);return{start:e,end:a}},ytd(){let t=new Date;return{start:v(this.range.start),end:t}},mtd(){let t=new Date;return{start:c(this.range.start),end:t}},lastDays(t){let e=new Date;return{start:g(e,t),end:e}},changeDateRange(t){t.preventDefault();let e=t.currentTarget,a=new Date(e.getAttribute("data-start")),s=new Date(e.getAttribute("data-end"));return window.store.set("start",a),window.store.set("end",s),!1}});function De(t,e){let a=window.__localeId__.replace("_","-");return Intl.NumberFormat(a,{style:"currency",currency:e}).format(t)}export{A as P,h as a,me as d,De as f,w as g}; +import{o as y,s as d,q as l,r as p,t as _,u as c,v as b,w as N,x as P,y as v,z as g,i as C,D as B,E as x,G as O,H as o,I as E,J as T,f as L,K as S,M as W,N as I,O as U,Q as q,R as Q,U as V,V as Y,W as $,X as j,Y as z,Z as X,_ as F,$ as G,a0 as H,a1 as J,a2 as K,a3 as Z,a4 as ee,a5 as te,a6 as ae,a7 as se,a8 as ne,a9 as re,aa as le,ab as de,ac as oe,ad as ie,ae as ue,af as ge,ag as ce,ah as we,ai as he,aj as ye}from"./vendor-76961a66.js";const k="/",h=y.create({baseURL:k,withCredentials:!0});y.defaults.withCredentials=!0;y.defaults.baseURL=k;class R{getByName(e){return h.get("/api/v1/preferences/"+e)}getByNameNow(e){return h.get("/api/v1/preferences/"+e)}postByName(e,a){return h.post("/api/v1/preferences",{name:e,data:a})}}class A{post(e,a){let s="/api/v1/preferences";return h.post(s,{name:e,data:a})}}function fe(t,e=null){return new R().getByName(t).then(s=>Promise.resolve(M(t,s))).catch(()=>{new A().post(t,e).then(i=>Promise.resolve(M(t,i)))})}function M(t,e){return e.data.data.attributes.data}function w(t,e=null){const a=window.store.get("cacheValid");if(a&&window.hasOwnProperty(t))return Promise.resolve(window[t]);const s=window.store.get(t);return a&&typeof s<"u"?Promise.resolve(s):new R().getByName(t).then(u=>Promise.resolve(m(t,u))).catch(()=>{new A().post(t,e).then(n=>Promise.resolve(m(t,n)))})}function m(t,e){let a=e.data.data.attributes.data;return window.store.set(t,a),a}function be(t,e){let a,s;switch(t){case"last365":a=d(g(e,365)),s=l(e);break;case"last90":a=d(g(e,90)),s=l(e);break;case"last30":a=d(g(e,30)),s=l(e);break;case"last7":a=d(g(e,7)),s=l(e);break;case"YTD":a=v(e),s=l(e);break;case"QTD":a=p(e),s=l(e);break;case"MTD":a=c(e),s=l(e);break;case"1D":a=d(e),s=l(e);break;case"1W":a=d(N(e,{weekStartsOn:1})),s=l(P(e,{weekStartsOn:1}));break;case"1M":a=d(c(e)),s=l(b(e));break;case"3M":a=d(p(e)),s=l(_(e));break;case"6M":e.getMonth()<=5&&(a=new Date(e),a.setMonth(0),a.setDate(1),a=d(a),s=new Date(e),s.setMonth(5),s.setDate(30),s=l(a)),e.getMonth()>5&&(a=new Date(e),a.setMonth(6),a.setDate(1),a=d(a),s=new Date(e),s.setMonth(11),s.setDate(31),s=l(a));break;case"1Y":a=new Date(e),a.setMonth(0),a.setDate(1),a=d(a),s=new Date(e),s.setMonth(11),s.setDate(31),s=l(s);break}return{start:a,end:s}}let D=!1;function pe(t){if(D===!1){const e=t.replace("-","_");D=!0;const a=7*24*60*60*1e3;return console.log('Will load language "'+e+'"'),C.use(B).init({load:"languageOnly",fallbackLng:"en",lng:e,debug:!1,backend:{backends:[x,O],backendOptions:[{load:"languageOnly",expirationTime:a},{loadPath:"./v2/i18n/{{lng}}.json"}]}})}return console.warn("Loading translations skipped."),Promise.resolve()}o.addPlugin(E);window.bootstrapped=!1;window.store=o;fe("lastActivity").then(t=>{const e=o.get("lastActivity");o.set("cacheValid",e===t),o.set("lastActivity",t),console.log("Server value: "+t),console.log("Local value: "+e),console.log("Cache valid: "+(e===t))}).then(()=>{Promise.all([w("viewRange"),w("darkMode"),w("locale"),w("language")]).then(t=>{if(!o.get("start")||!o.get("end")){const e=be(t[0],new Date);o.set("start",e.start),o.set("end",e.end)}window.__localeId__=t[2],o.set("language",t[3]),o.set("locale",t[3]),pe(t[3]).then(()=>{const e=new Event("firefly-iii-bootstrapped");document.dispatchEvent(e),window.bootstrapped=!0})})});window.axios=y;window.axios.defaults.headers.common["X-Requested-With"]="XMLHttpRequest";window.Alpine=T;const f={bg:S,cs:W,da:I,de:U,el:q,enGB:Q,enUS:V,es:Y,ca:$,fi:j,fr:z,hu:X,id:F,it:G,ja:H,ko:J,nb:K,nn:Z,nl:ee,pl:te,ptBR:ae,pt:se,ro:ne,ru:re,sk:le,sl:de,sv:oe,tr:ie,uk:ue,vi:ge,zhTW:ce,zhCN:we};function r(t,e="PP"){let a=window.__localeId__.replace("_","");return L(t,e,{locale:f[a]??f[a.slice(0,2)]??f.enUS})}const me=()=>({range:{start:null,end:null},defaultRange:{start:null,end:null},language:"en_US",init(){this.range={start:new Date(window.store.get("start")),end:new Date(window.store.get("end"))},this.defaultRange={start:new Date(window.store.get("start")),end:new Date(window.store.get("end"))},this.language=window.store.get("language"),this.locale=window.store.get("locale"),this.locale=this.locale==="equal"?this.language:this.locale,window.__localeId__=this.language,this.buildDateRange(),window.store.observe("start",t=>{this.range.start=new Date(t)}),window.store.observe("end",t=>{this.range.end=new Date(t),this.buildDateRange()})},buildDateRange(){let t=this.getNextRange(),e=this.getPrevRange(),a=this.lastDays(7),s=this.lastDays(30),i=this.mtd(),u=this.ytd(),n=document.getElementsByClassName("daterange-holder")[0];n.textContent=r(this.range.start)+" - "+r(this.range.end),n.setAttribute("data-start",r(this.range.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(this.range.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-current")[0],n.textContent=r(this.defaultRange.start)+" - "+r(this.defaultRange.end),n.setAttribute("data-start",r(this.defaultRange.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(this.defaultRange.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-next")[0],n.textContent=r(t.start)+" - "+r(t.end),n.setAttribute("data-start",r(t.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(t.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-prev")[0],n.textContent=r(e.start)+" - "+r(e.end),n.setAttribute("data-start",r(e.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(e.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-7d")[0],n.setAttribute("data-start",r(a.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(a.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-90d")[0],n.setAttribute("data-start",r(s.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(s.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-mtd")[0],n.setAttribute("data-start",r(i.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(i.end,"yyyy-MM-dd")),n=document.getElementsByClassName("daterange-ytd")[0],n.setAttribute("data-start",r(u.start,"yyyy-MM-dd")),n.setAttribute("data-end",r(u.end,"yyyy-MM-dd"))},getNextRange(){let t=c(this.range.start),e=he(t,1),a=b(e);return{start:e,end:a}},getPrevRange(){let t=c(this.range.start),e=ye(t,1),a=b(e);return{start:e,end:a}},ytd(){let t=new Date;return{start:v(this.range.start),end:t}},mtd(){let t=new Date;return{start:c(this.range.start),end:t}},lastDays(t){let e=new Date;return{start:g(e,t),end:e}},changeDateRange(t){t.preventDefault();let e=t.currentTarget,a=new Date(e.getAttribute("data-start")),s=new Date(e.getAttribute("data-end"));return window.store.set("start",a),window.store.set("end",s),!1}});function De(t,e){let a=window.__localeId__.replace("_","-");return Intl.NumberFormat(a,{style:"currency",currency:e}).format(t)}export{A as P,h as a,me as d,De as f,w as g}; diff --git a/public/build/assets/get-851d8544.js b/public/build/assets/get-5236bc21.js similarity index 66% rename from public/build/assets/get-851d8544.js rename to public/build/assets/get-5236bc21.js index 3368ce5647..2b1dd4d1cd 100644 --- a/public/build/assets/get-851d8544.js +++ b/public/build/assets/get-5236bc21.js @@ -1 +1 @@ -import{a as s}from"./format-money-0f129d93.js";class p{list(a){return s.get("/api/v2/transactions",{params:a})}show(a,t){return s.get("/api/v2/transactions/"+a,{params:t})}}export{p as G}; +import{a as s}from"./format-money-e4c435dc.js";class p{list(a){return s.get("/api/v2/transactions",{params:a})}show(a,t){return s.get("/api/v2/transactions/"+a,{params:t})}}export{p as G}; diff --git a/public/build/assets/get-d03e8e57.js b/public/build/assets/get-95250f8d.js similarity index 81% rename from public/build/assets/get-d03e8e57.js rename to public/build/assets/get-95250f8d.js index d05542edd8..b403a3a5e5 100644 --- a/public/build/assets/get-d03e8e57.js +++ b/public/build/assets/get-95250f8d.js @@ -1 +1 @@ -import{a as s}from"./format-money-0f129d93.js";let t=class{list(a){return s.get("/api/v2/subscriptions",{params:a})}paid(a){return s.get("/api/v2/subscriptions/sum/paid",{params:a})}unpaid(a){return s.get("/api/v2/subscriptions/sum/unpaid",{params:a})}};class e{list(a){return s.get("/api/v2/piggy-banks",{params:a})}}export{t as G,e as a}; +import{a as s}from"./format-money-e4c435dc.js";let t=class{list(a){return s.get("/api/v2/subscriptions",{params:a})}paid(a){return s.get("/api/v2/subscriptions/sum/paid",{params:a})}unpaid(a){return s.get("/api/v2/subscriptions/sum/unpaid",{params:a})}};class e{list(a){return s.get("/api/v2/piggy-banks",{params:a})}}export{t as G,e as a}; diff --git a/public/build/assets/index-f5d59159.js b/public/build/assets/index-f915662d.js similarity index 90% rename from public/build/assets/index-f5d59159.js rename to public/build/assets/index-f915662d.js index e616cd08fa..b6772b2982 100644 --- a/public/build/assets/index-f5d59159.js +++ b/public/build/assets/index-f915662d.js @@ -1 +1 @@ -import{d as c,f as d}from"./format-money-0f129d93.js";import{f as p,i as n}from"./vendor-baac879b.js";import{G as f}from"./get-851d8544.js";let g=function(){return{notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},transactions:[],totalPages:1,perPage:50,page:1,tableColumns:{description:{enabled:!0},source:{enabled:!0},destination:{enabled:!0},amount:{enabled:!0}},formatMoney(t,i){return d(t,i)},format(t){return p(t,n.t("config.date_time_fns"))},init(){this.notifications.wait.show=!0,this.notifications.wait.text=n.t("firefly.wait_loading_data"),this.getTransactions(this.page)},getTransactions(t){const i=window.location.href.split("/"),a=i[i.length-1];new f().list({page:t,type:a}).then(s=>{this.parseTransactions(s.data.data),this.totalPages=s.data.meta.pagination.total_pages,this.perPage=s.data.meta.pagination.per_page,this.page=s.data.meta.pagination.current_page}).catch(s=>{this.notifications.wait.show=!1,this.notifications.error.show=!0,this.notifications.error.text=s.response.data.message})},parseTransactions(t){for(let i in t)if(t.hasOwnProperty(i)){let a=t[i],o=a.attributes.transactions.length>1,s=!0;for(let r in a.attributes.transactions)if(a.attributes.transactions.hasOwnProperty(r)){let e=a.attributes.transactions[r];e.split=o,e.firstSplit=s,e.group_title=a.attributes.group_title,e.id=a.id,e.created_at=a.attributes.created_at,e.updated_at=a.attributes.updated_at,e.user=a.attributes.user,e.user_group=a.attributes.user_group,s=!1,console.log(e),this.transactions.push(e)}}this.notifications.wait.show=!1}}},l={index:g,dates:c};function u(){Object.keys(l).forEach(t=>{console.log(`Loading page component "${t}"`);let i=l[t]();Alpine.data(t,()=>i)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),u()});window.bootstrapped&&(console.log("Loaded through window variable."),u()); +import{d as c,f as d}from"./format-money-e4c435dc.js";import{f as p,i as n}from"./vendor-76961a66.js";import{G as f}from"./get-5236bc21.js";let g=function(){return{notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},transactions:[],totalPages:1,perPage:50,page:1,tableColumns:{description:{enabled:!0},source:{enabled:!0},destination:{enabled:!0},amount:{enabled:!0}},formatMoney(t,i){return d(t,i)},format(t){return p(t,n.t("config.date_time_fns"))},init(){this.notifications.wait.show=!0,this.notifications.wait.text=n.t("firefly.wait_loading_data"),this.getTransactions(this.page)},getTransactions(t){const i=window.location.href.split("/"),a=i[i.length-1];new f().list({page:t,type:a}).then(s=>{this.parseTransactions(s.data.data),this.totalPages=s.data.meta.pagination.total_pages,this.perPage=s.data.meta.pagination.per_page,this.page=s.data.meta.pagination.current_page}).catch(s=>{this.notifications.wait.show=!1,this.notifications.error.show=!0,this.notifications.error.text=s.response.data.message})},parseTransactions(t){for(let i in t)if(t.hasOwnProperty(i)){let a=t[i],o=a.attributes.transactions.length>1,s=!0;for(let r in a.attributes.transactions)if(a.attributes.transactions.hasOwnProperty(r)){let e=a.attributes.transactions[r];e.split=o,e.firstSplit=s,e.group_title=a.attributes.group_title,e.id=a.id,e.created_at=a.attributes.created_at,e.updated_at=a.attributes.updated_at,e.user=a.attributes.user,e.user_group=a.attributes.user_group,s=!1,console.log(e),this.transactions.push(e)}}this.notifications.wait.show=!1}}},l={index:g,dates:c};function u(){Object.keys(l).forEach(t=>{console.log(`Loading page component "${t}"`);let i=l[t]();Alpine.data(t,()=>i)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),u()});window.bootstrapped&&(console.log("Loaded through window variable."),u()); diff --git a/public/build/assets/parse-downloaded-splits-109be2c7.js b/public/build/assets/parse-downloaded-splits-c0536134.js similarity index 91% rename from public/build/assets/parse-downloaded-splits-109be2c7.js rename to public/build/assets/parse-downloaded-splits-c0536134.js index de5ccf87a8..d9f6680a29 100644 --- a/public/build/assets/parse-downloaded-splits-109be2c7.js +++ b/public/build/assets/parse-downloaded-splits-c0536134.js @@ -1 +1 @@ -import{c as o}from"./create-empty-split-16bf9f82.js";import{f as _}from"./vendor-baac879b.js";function l(a,r){let n=[];for(let i in a)if(a.hasOwnProperty(i)){let e=a[i],t=o();t.transaction_journal_id=e.transaction_journal_id,t.transaction_group_id=r,t.bill_id=e.bill_id,t.bill_name=e.bill_name,t.budget_id=e.budget_id,t.budget_name=e.budget_name,t.category_name=e.category_name,t.category_id=e.category_id,t.piggy_bank_id=e.piggy_bank_id,t.piggy_bank_name=e.piggy_bank_name,t.book_date=e.book_date,t.due_date=e.due_date,t.interest_date=e.interest_date,t.invoice_date=e.invoice_date,t.payment_date=e.payment_date,t.process_date=e.process_date,t.external_url=e.external_url,t.internal_reference=e.internal_reference,t.notes=e.notes,t.tags=e.tags,t.amount=parseFloat(e.amount).toFixed(e.currency_decimal_places),t.currency_code=e.currency_code,e.foreign_amount!==null&&(t.forein_currency_code=e.foreign_currency_code,t.foreign_amount=parseFloat(e.foreign_amount).toFixed(e.foreign_currency_decimal_places)),t.date=_(new Date(e.date),"yyyy-MM-dd HH:mm"),t.description=e.description,t.destination_account={id:e.destination_id,name:e.destination_name,type:e.destination_type,alpine_name:e.destination_name},t.source_account={id:e.source_id,name:e.source_name,type:e.source_type,alpine_name:e.source_name},e.latitude!==null&&(t.hasLocation=!0,t.latitude=e.latitude,t.longitude=e.longitude,t.zoomLevel=e.zoom_level),n.push(t)}return n}export{l as p}; +import{c as o}from"./create-empty-split-9cc18e2d.js";import{f as _}from"./vendor-76961a66.js";function l(a,r){let n=[];for(let i in a)if(a.hasOwnProperty(i)){let e=a[i],t=o();t.transaction_journal_id=e.transaction_journal_id,t.transaction_group_id=r,t.bill_id=e.bill_id,t.bill_name=e.bill_name,t.budget_id=e.budget_id,t.budget_name=e.budget_name,t.category_name=e.category_name,t.category_id=e.category_id,t.piggy_bank_id=e.piggy_bank_id,t.piggy_bank_name=e.piggy_bank_name,t.book_date=e.book_date,t.due_date=e.due_date,t.interest_date=e.interest_date,t.invoice_date=e.invoice_date,t.payment_date=e.payment_date,t.process_date=e.process_date,t.external_url=e.external_url,t.internal_reference=e.internal_reference,t.notes=e.notes,t.tags=e.tags,t.amount=parseFloat(e.amount).toFixed(e.currency_decimal_places),t.currency_code=e.currency_code,e.foreign_amount!==null&&(t.forein_currency_code=e.foreign_currency_code,t.foreign_amount=parseFloat(e.foreign_amount).toFixed(e.foreign_currency_decimal_places)),t.date=_(new Date(e.date),"yyyy-MM-dd HH:mm"),t.description=e.description,t.destination_account={id:e.destination_id,name:e.destination_name,type:e.destination_type,alpine_name:e.destination_name},t.source_account={id:e.source_id,name:e.source_name,type:e.source_type,alpine_name:e.source_name},e.latitude!==null&&(t.hasLocation=!0,t.latitude=e.latitude,t.longitude=e.longitude,t.zoomLevel=e.zoom_level),n.push(t)}return n}export{l as p}; diff --git a/public/build/assets/show-83afe744.js b/public/build/assets/show-25e4fff8.js similarity index 98% rename from public/build/assets/show-83afe744.js rename to public/build/assets/show-25e4fff8.js index 1cb2eeedd7..ecfc85ff32 100644 --- a/public/build/assets/show-83afe744.js +++ b/public/build/assets/show-25e4fff8.js @@ -1 +1 @@ -var y=Object.defineProperty;var w=(i,t,e)=>t in i?y(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var r=(i,t,e)=>(w(i,typeof t!="symbol"?t+"":t,e),e);import{d as v,f as b}from"./format-money-0f129d93.js";import{f as g,i as h}from"./vendor-baac879b.js";import{G as E}from"./get-851d8544.js";import{p as _}from"./parse-downloaded-splits-109be2c7.js";import"./create-empty-split-16bf9f82.js";class l{constructor(t){if(this.constructor===l)throw new Error("It's abstract class");this.context=t}event_show(){this.context.typeElement.hideError(),this.context.typeElement.element.value=this.context.value,this.context.element.dispatchEvent(new CustomEvent("show"))}event_shown(){this.context.element.dispatchEvent(new CustomEvent("shown"))}event_hide(){this.context.element.dispatchEvent(new CustomEvent("hide"))}event_hidden(){this.context.element.dispatchEvent(new CustomEvent("hidden"))}init(){throw new Error("Method `init` not define!")}enable(){throw new Error("Method `enable` not define!")}disable(){throw new Error("Method `disable` not define!")}hide(){throw new Error("Method `hide` not define!")}}class L extends l{init(){this.popover=new bootstrap.Popover(this.context.element,{container:"body",content:this.context.typeElement.create(),html:!0,customClass:"dark-editable",title:this.context.title}),this.context.element.addEventListener("show.bs.popover",()=>{this.event_show()}),this.context.element.addEventListener("shown.bs.popover",()=>{this.event_shown()}),this.context.element.addEventListener("hide.bs.popover",()=>{this.event_hide()}),this.context.element.addEventListener("hidden.bs.popover",()=>{this.event_hidden()}),document.addEventListener("click",t=>{const e=t.target;if(e===this.popover.tip||e===this.context.element)return;let n=e;for(;n=n.parentNode;)if(n===this.popover.tip)return;this.hide()})}enable(){this.popover.enable()}disable(){this.popover.disable()}hide(){this.popover.hide()}}class T extends l{init(){const t=()=>{if(!this.context.disabled){const e=this.context.typeElement.create();this.event_show(),this.context.element.removeEventListener("click",t),this.context.element.innerHTML="",this.context.element.append(e),this.event_shown()}};this.context.element.addEventListener("click",t)}enable(){}disable(){}hide(){this.event_hide(),this.context.element.innerHTML=this.context.value,setTimeout(()=>{this.init(),this.event_hidden()},100)}}class c{constructor(t){r(this,"context",null);r(this,"element",null);r(this,"error",null);r(this,"form",null);r(this,"load",null);r(this,"buttonGroup",null);r(this,"buttons",{success:null,cancel:null});if(this.constructor===c)throw new Error("It's abstract class");this.context=t}create(){throw new Error("Method `create` not define!")}createContainer(t){const e=document.createElement("div");this.element=t,this.error=this.createContainerError(),this.form=this.createContainerForm(),this.load=this.createContainerLoad(),this.buttons.success=this.createButtonSuccess(),this.buttons.cancel=this.createButtonCancel();const n=document.createElement("div");n.classList.add("col-12");const s=document.createElement("label");s.classList.add("visually-hidden"),s.for=t.id,n.append(s,t);const o=document.createElement("div");return o.classList.add("col-12"),this.buttonGroup=this.createButtonGroup(),this.buttonGroup.append(this.buttons.success,this.buttons.cancel),o.append(this.buttonGroup),this.form.append(n,o),e.append(this.error,this.form),e}createButtonGroup(){const t=document.createElement("div");return t.classList.add("btn-group","btn-group-sm"),t}createContainerError(){const t=document.createElement("div");return t.classList.add("text-danger","fst-italic","mb-2","fw-bold"),t.style.display="none",t}createContainerForm(){const t=document.createElement("form");return t.classList.add("row","row-cols-lg-auto","g-3","align-items-center"),t.addEventListener("submit",async e=>{e.preventDefault();const n=this.getValue();if(this.context.send&&this.context.pk&&this.context.url&&this.context.value!==n){this.showLoad();let s;try{const o=await this.ajax(n);o.ok?s=await this.context.success(o,n):s=await this.context.error(o,n)||`${o.status} ${o.statusText}`}catch(o){console.error(o),s=o}s?(this.setError(s),this.showError()):(this.setError(null),this.hideError(),this.context.value=this.getValue(),this.context.modeElement.hide(),this.initText()),this.hideLoad()}else this.context.value=this.getValue(),this.context.modeElement.hide(),this.initText();this.context.element.dispatchEvent(new CustomEvent("save"))}),t}createContainerLoad(){const t=document.createElement("div");t.style.display="none",t.style.position="absolute",t.style.background="white",t.style.width="100%",t.style.height="100%",t.style.top=0,t.style.left=0;const e=document.createElement("div");return e.classList.add("dark-editable-loader"),t.append(e),t}createButton(){const t=document.createElement("button");return t.type="button",t.classList.add("btn","btn-sm"),t.style.color="transparent",t.style.textShadow="0 0 0 white",t}createButtonSuccess(){const t=this.createButton();return t.type="submit",t.classList.add("btn-success"),t.innerHTML="✔",t}createButtonCancel(){const t=this.createButton();t.classList.add("btn-danger");const e=document.createElement("div");return e.innerHTML="✖",t.append(e),t.addEventListener("click",()=>{this.context.modeElement.hide()}),t}hideLoad(){this.load.style.display="none"}showLoad(){this.load.style.display="block"}ajax(t){let e=this.context.url,n,s=!1;console.log(this.context),this.context.options.formType==="journal_description"&&(s=!0,n={transactions:[{transaction_journal_id:this.context.options.journalId,description:t}]}),s===!1&&console.error('Cannot deal with form type "'+this.context.formType+'"');const o={headers:{"Content-Type":"application/json","X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}};return o.method=this.context.ajaxOptions.method,this.context.options.method&&(o.method=this.context.options.method),o.method==="POST"||this.context.options.method==="PUT"?o.body=JSON.stringify(n):e+="?"+new URLSearchParams(form).toString(),fetch(e,o)}async successResponse(t,e){}async errorResponse(t,e){}setError(t){this.error.innerHTML=t}showError(){this.error.style.display="block"}hideError(){this.error&&(this.error.style.display="none")}createElement(t){const e=document.createElement(t);return console.log(e),e.classList.add("form-control"),this.context.required&&(e.required=this.context.required),this.add_focus(e),e}add_focus(t){this.context.element.addEventListener("shown",function(){t.focus()})}initText(){return this.context.value===""?(this.context.element.innerHTML=this.context.emptytext,!0):(this.context.element.innerHTML=this.context.value,!1)}initOptions(){}getValue(){return this.element.value}}class M extends c{create(){const t=this.createElement("input"),e=this.context.element.id+"_input";return t.type=this.context.type,t.id=e,t.autocomplete="off",t.placeholder=this.context.element.innerText,t.classList.add("form-control","form-control-md"),this.createContainer(t)}}class C extends c{create(){const t=this.createElement("textarea");return this.createContainer(t)}}class k extends c{create(){const t=this.createElement("select");return this.context.source.forEach(e=>{const n=document.createElement("option");n.value=e.value,n.innerHTML=e.text,t.append(n)}),this.createContainer(t)}initText(){if(this.context.element.innerHTML=this.context.emptytext,this.context.value!==""&&this.context.source.length>0)for(const t in this.context.source){const e=this.context.source[t];if(e.value==this.context.value)return this.context.element.innerHTML=e.text,!1}return!0}initOptions(){this.context.get_opt("source",[]),typeof this.context.source=="string"&&this.context.source!==""&&(this.context.source=JSON.parse(this.context.source))}}class f extends c{create(){const t=this.createElement("input");return t.type="date",this.createContainer(t)}initText(){return this.value===""?(this.context.element.innerHTML=this.context.emptytext,!0):(this.context.element.innerHTML=moment(this.context.value).format(this.context.viewformat),!1)}initOptions(){this.context.get_opt("format","YYYY-MM-DD"),this.context.get_opt("viewformat","YYYY-MM-DD")}}class D extends f{create(){const t=this.createElement("input");return t.type="datetime-local",this.createContainer(t)}initOptions(){this.context.get_opt("format","YYYY-MM-DD HH:mm"),this.context.get_opt("viewformat","YYYY-MM-DD HH:mm"),this.context.value=moment(this.context.value).format("YYYY-MM-DDTHH:mm")}}class Y{constructor(t,e={}){r(this,"modeElement",null);r(this,"typeElement",null);r(this,"mode",null);r(this,"type",null);r(this,"emptytext",null);r(this,"viewformat",null);r(this,"pk",null);r(this,"name",null);this.element=t,this.options=e,this.init_options(),this.typeElement=this.route_type(),this.typeElement.initOptions(),this.modeElement=this.route_mode(),this.modeElement.init(),this.init_text(),this.init_style(),this.disabled&&this.disable(),this.element.dispatchEvent(new CustomEvent("init"))}get_opt(t,e){var n,s;return this[t]=((n=this.element.dataset)==null?void 0:n[t])??((s=this.options)==null?void 0:s[t])??e}get_opt_bool(t,e){return this.get_opt(t,e),typeof this[t]!="boolean"&&(this[t]==="true"?this[t]=!0:this[t]==="false"?this[t]=!1:this[t]=e),this[t]}init_options(){var t,e,n,s;this.get_opt("value",this.element.innerHTML),this.get_opt("name",this.element.id),this.get_opt("pk",null),this.get_opt("title",""),this.get_opt("type","text"),this.get_opt("emptytext","Empty"),this.get_opt("mode","popup"),this.get_opt("url",null),this.get_opt("ajaxOptions",{}),this.ajaxOptions=Object.assign({method:"POST",dataType:"text"},this.ajaxOptions),this.get_opt_bool("send",!0),this.get_opt_bool("disabled",!1),this.get_opt_bool("required",!1),(t=this.options)!=null&&t.success&&typeof((e=this.options)==null?void 0:e.success)=="function"&&(this.success=this.options.success),(n=this.options)!=null&&n.error&&typeof((s=this.options)==null?void 0:s.error)=="function"&&(this.error=this.options.error)}init_text(){const t="dark-editable-element-empty";this.element.classList.remove(t),this.typeElement.initText()&&this.element.classList.add(t)}init_style(){this.element.classList.add("dark-editable-element")}route_mode(){switch(this.mode){default:throw new Error(`Mode ${this.mode} not found!`);case"popup":return new L(this);case"inline":return new T(this)}}route_type(){if(this.type.prototype instanceof c)return new this.type(this);if(typeof this.type=="string")switch(this.type){case"text":case"password":case"email":case"url":case"tel":case"number":case"range":case"time":return new M(this);case"textarea":return new C(this);case"select":return new k(this);case"date":return new f(this);case"datetime":return new D(this)}throw new Error("Undefined type")}async success(t,e){return await this.typeElement.successResponse(t,e)}async error(t,e){return await this.typeElement.errorResponse(t,e)}enable(){this.disabled=!1,this.element.classList.remove("dark-editable-element-disabled"),this.modeElement.enable()}disable(){this.disabled=!0,this.element.classList.add("dark-editable-element-disabled"),this.modeElement.enable()}setValue(t){this.value=t,this.init_text()}getValue(){return this.value}}function H(i){const t=parseInt(i.dataset.id),e=parseInt(i.dataset.group),n={pk:e,mode:"inline",url:"./api/v2/transactions/"+e,formType:"journal_description",journalId:t,method:"PUT"};new Y(i,n)}let I=function(){return{notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},groupProperties:{id:0,transactionType:"",transactionTypeTranslated:"",title:"",date:new Date},dateFields:["book_date","due_date","interest_date","invoice_date","payment_date","process_date"],metaFields:["external_id","internal_reference","sepa_batch_id","sepa_ct_id","sepa_ct_op","sepa_db","sepa_country","sepa_cc","sepa_ep","sepa_ci","external_url"],amounts:{},entries:[],pageProperties:{},formatMoney(i,t){return console.log("formatting",i,t),t===""&&(t="EUR"),b(i,t)},format(i){return g(i,h.t("config.date_time_fns"))},init(){this.notifications.wait.show=!0,this.notifications.wait.text=h.t("firefly.wait_loading_data");const i=window.location.href.split("/"),t=parseInt(i[i.length-1]);new E().show(t,{}).then(n=>{const s=n.data.data;this.groupProperties.id=parseInt(s.id),this.groupProperties.transactionType=s.attributes.transactions[0].type,this.groupProperties.transactionTypeTranslated=h.t("firefly."+s.attributes.transactions[0].type),this.groupProperties.title=s.attributes.title??s.attributes.transactions[0].description,this.entries=_(s.attributes.transactions,parseInt(s.id)),this.notifications.wait.show=!1}).then(()=>{for(let s in this.entries)if(this.entries.hasOwnProperty(s)){const o=this.entries[s].currency_code,a=this.entries[s].foreign_currency_code;this.amounts[o]===void 0&&(this.amounts[o]=0,this.amounts[o]+=parseFloat(this.entries[s].amount)),a!==null&&a!==""&&this.amounts[a]===void 0&&(this.amounts[a]=0,this.amounts[a]+=parseFloat(this.entries[s].foreign_amount)),parseInt(s)===0&&(this.groupProperties.date=this.entries[s].date)}const n=document.querySelectorAll(".journal_description");for(const s in n)if(n.hasOwnProperty(s)){const o=n[s];o.addEventListener("save",function(a){parseInt(a.currentTarget.dataset.id);const d=parseInt(a.currentTarget.dataset.group),u=parseInt(a.currentTarget.dataset.length),p=a.currentTarget.textContent;console.log(u),u===1&&(document.querySelector('.group_title[data-group="'+d+'"]').textContent=p,document.querySelector('.group_title_title[data-group="'+d+'"]').textContent=p)}),H(o)}}).catch(n=>{this.notifications.error.show=!0,this.notifications.error.text=n.message})}}},m={show:I,dates:v};function x(){Object.keys(m).forEach(i=>{console.log(`Loading page component "${i}"`);let t=m[i]();Alpine.data(i,()=>t)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),x()});window.bootstrapped&&(console.log("Loaded through window variable."),x()); +var y=Object.defineProperty;var w=(i,t,e)=>t in i?y(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var r=(i,t,e)=>(w(i,typeof t!="symbol"?t+"":t,e),e);import{d as v,f as b}from"./format-money-e4c435dc.js";import{f as g,i as h}from"./vendor-76961a66.js";import{G as E}from"./get-5236bc21.js";import{p as _}from"./parse-downloaded-splits-c0536134.js";import"./create-empty-split-9cc18e2d.js";class l{constructor(t){if(this.constructor===l)throw new Error("It's abstract class");this.context=t}event_show(){this.context.typeElement.hideError(),this.context.typeElement.element.value=this.context.value,this.context.element.dispatchEvent(new CustomEvent("show"))}event_shown(){this.context.element.dispatchEvent(new CustomEvent("shown"))}event_hide(){this.context.element.dispatchEvent(new CustomEvent("hide"))}event_hidden(){this.context.element.dispatchEvent(new CustomEvent("hidden"))}init(){throw new Error("Method `init` not define!")}enable(){throw new Error("Method `enable` not define!")}disable(){throw new Error("Method `disable` not define!")}hide(){throw new Error("Method `hide` not define!")}}class L extends l{init(){this.popover=new bootstrap.Popover(this.context.element,{container:"body",content:this.context.typeElement.create(),html:!0,customClass:"dark-editable",title:this.context.title}),this.context.element.addEventListener("show.bs.popover",()=>{this.event_show()}),this.context.element.addEventListener("shown.bs.popover",()=>{this.event_shown()}),this.context.element.addEventListener("hide.bs.popover",()=>{this.event_hide()}),this.context.element.addEventListener("hidden.bs.popover",()=>{this.event_hidden()}),document.addEventListener("click",t=>{const e=t.target;if(e===this.popover.tip||e===this.context.element)return;let n=e;for(;n=n.parentNode;)if(n===this.popover.tip)return;this.hide()})}enable(){this.popover.enable()}disable(){this.popover.disable()}hide(){this.popover.hide()}}class T extends l{init(){const t=()=>{if(!this.context.disabled){const e=this.context.typeElement.create();this.event_show(),this.context.element.removeEventListener("click",t),this.context.element.innerHTML="",this.context.element.append(e),this.event_shown()}};this.context.element.addEventListener("click",t)}enable(){}disable(){}hide(){this.event_hide(),this.context.element.innerHTML=this.context.value,setTimeout(()=>{this.init(),this.event_hidden()},100)}}class c{constructor(t){r(this,"context",null);r(this,"element",null);r(this,"error",null);r(this,"form",null);r(this,"load",null);r(this,"buttonGroup",null);r(this,"buttons",{success:null,cancel:null});if(this.constructor===c)throw new Error("It's abstract class");this.context=t}create(){throw new Error("Method `create` not define!")}createContainer(t){const e=document.createElement("div");this.element=t,this.error=this.createContainerError(),this.form=this.createContainerForm(),this.load=this.createContainerLoad(),this.buttons.success=this.createButtonSuccess(),this.buttons.cancel=this.createButtonCancel();const n=document.createElement("div");n.classList.add("col-12");const s=document.createElement("label");s.classList.add("visually-hidden"),s.for=t.id,n.append(s,t);const o=document.createElement("div");return o.classList.add("col-12"),this.buttonGroup=this.createButtonGroup(),this.buttonGroup.append(this.buttons.success,this.buttons.cancel),o.append(this.buttonGroup),this.form.append(n,o),e.append(this.error,this.form),e}createButtonGroup(){const t=document.createElement("div");return t.classList.add("btn-group","btn-group-sm"),t}createContainerError(){const t=document.createElement("div");return t.classList.add("text-danger","fst-italic","mb-2","fw-bold"),t.style.display="none",t}createContainerForm(){const t=document.createElement("form");return t.classList.add("row","row-cols-lg-auto","g-3","align-items-center"),t.addEventListener("submit",async e=>{e.preventDefault();const n=this.getValue();if(this.context.send&&this.context.pk&&this.context.url&&this.context.value!==n){this.showLoad();let s;try{const o=await this.ajax(n);o.ok?s=await this.context.success(o,n):s=await this.context.error(o,n)||`${o.status} ${o.statusText}`}catch(o){console.error(o),s=o}s?(this.setError(s),this.showError()):(this.setError(null),this.hideError(),this.context.value=this.getValue(),this.context.modeElement.hide(),this.initText()),this.hideLoad()}else this.context.value=this.getValue(),this.context.modeElement.hide(),this.initText();this.context.element.dispatchEvent(new CustomEvent("save"))}),t}createContainerLoad(){const t=document.createElement("div");t.style.display="none",t.style.position="absolute",t.style.background="white",t.style.width="100%",t.style.height="100%",t.style.top=0,t.style.left=0;const e=document.createElement("div");return e.classList.add("dark-editable-loader"),t.append(e),t}createButton(){const t=document.createElement("button");return t.type="button",t.classList.add("btn","btn-sm"),t.style.color="transparent",t.style.textShadow="0 0 0 white",t}createButtonSuccess(){const t=this.createButton();return t.type="submit",t.classList.add("btn-success"),t.innerHTML="✔",t}createButtonCancel(){const t=this.createButton();t.classList.add("btn-danger");const e=document.createElement("div");return e.innerHTML="✖",t.append(e),t.addEventListener("click",()=>{this.context.modeElement.hide()}),t}hideLoad(){this.load.style.display="none"}showLoad(){this.load.style.display="block"}ajax(t){let e=this.context.url,n,s=!1;console.log(this.context),this.context.options.formType==="journal_description"&&(s=!0,n={transactions:[{transaction_journal_id:this.context.options.journalId,description:t}]}),s===!1&&console.error('Cannot deal with form type "'+this.context.formType+'"');const o={headers:{"Content-Type":"application/json","X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}};return o.method=this.context.ajaxOptions.method,this.context.options.method&&(o.method=this.context.options.method),o.method==="POST"||this.context.options.method==="PUT"?o.body=JSON.stringify(n):e+="?"+new URLSearchParams(form).toString(),fetch(e,o)}async successResponse(t,e){}async errorResponse(t,e){}setError(t){this.error.innerHTML=t}showError(){this.error.style.display="block"}hideError(){this.error&&(this.error.style.display="none")}createElement(t){const e=document.createElement(t);return console.log(e),e.classList.add("form-control"),this.context.required&&(e.required=this.context.required),this.add_focus(e),e}add_focus(t){this.context.element.addEventListener("shown",function(){t.focus()})}initText(){return this.context.value===""?(this.context.element.innerHTML=this.context.emptytext,!0):(this.context.element.innerHTML=this.context.value,!1)}initOptions(){}getValue(){return this.element.value}}class M extends c{create(){const t=this.createElement("input"),e=this.context.element.id+"_input";return t.type=this.context.type,t.id=e,t.autocomplete="off",t.placeholder=this.context.element.innerText,t.classList.add("form-control","form-control-md"),this.createContainer(t)}}class C extends c{create(){const t=this.createElement("textarea");return this.createContainer(t)}}class k extends c{create(){const t=this.createElement("select");return this.context.source.forEach(e=>{const n=document.createElement("option");n.value=e.value,n.innerHTML=e.text,t.append(n)}),this.createContainer(t)}initText(){if(this.context.element.innerHTML=this.context.emptytext,this.context.value!==""&&this.context.source.length>0)for(const t in this.context.source){const e=this.context.source[t];if(e.value==this.context.value)return this.context.element.innerHTML=e.text,!1}return!0}initOptions(){this.context.get_opt("source",[]),typeof this.context.source=="string"&&this.context.source!==""&&(this.context.source=JSON.parse(this.context.source))}}class f extends c{create(){const t=this.createElement("input");return t.type="date",this.createContainer(t)}initText(){return this.value===""?(this.context.element.innerHTML=this.context.emptytext,!0):(this.context.element.innerHTML=moment(this.context.value).format(this.context.viewformat),!1)}initOptions(){this.context.get_opt("format","YYYY-MM-DD"),this.context.get_opt("viewformat","YYYY-MM-DD")}}class D extends f{create(){const t=this.createElement("input");return t.type="datetime-local",this.createContainer(t)}initOptions(){this.context.get_opt("format","YYYY-MM-DD HH:mm"),this.context.get_opt("viewformat","YYYY-MM-DD HH:mm"),this.context.value=moment(this.context.value).format("YYYY-MM-DDTHH:mm")}}class Y{constructor(t,e={}){r(this,"modeElement",null);r(this,"typeElement",null);r(this,"mode",null);r(this,"type",null);r(this,"emptytext",null);r(this,"viewformat",null);r(this,"pk",null);r(this,"name",null);this.element=t,this.options=e,this.init_options(),this.typeElement=this.route_type(),this.typeElement.initOptions(),this.modeElement=this.route_mode(),this.modeElement.init(),this.init_text(),this.init_style(),this.disabled&&this.disable(),this.element.dispatchEvent(new CustomEvent("init"))}get_opt(t,e){var n,s;return this[t]=((n=this.element.dataset)==null?void 0:n[t])??((s=this.options)==null?void 0:s[t])??e}get_opt_bool(t,e){return this.get_opt(t,e),typeof this[t]!="boolean"&&(this[t]==="true"?this[t]=!0:this[t]==="false"?this[t]=!1:this[t]=e),this[t]}init_options(){var t,e,n,s;this.get_opt("value",this.element.innerHTML),this.get_opt("name",this.element.id),this.get_opt("pk",null),this.get_opt("title",""),this.get_opt("type","text"),this.get_opt("emptytext","Empty"),this.get_opt("mode","popup"),this.get_opt("url",null),this.get_opt("ajaxOptions",{}),this.ajaxOptions=Object.assign({method:"POST",dataType:"text"},this.ajaxOptions),this.get_opt_bool("send",!0),this.get_opt_bool("disabled",!1),this.get_opt_bool("required",!1),(t=this.options)!=null&&t.success&&typeof((e=this.options)==null?void 0:e.success)=="function"&&(this.success=this.options.success),(n=this.options)!=null&&n.error&&typeof((s=this.options)==null?void 0:s.error)=="function"&&(this.error=this.options.error)}init_text(){const t="dark-editable-element-empty";this.element.classList.remove(t),this.typeElement.initText()&&this.element.classList.add(t)}init_style(){this.element.classList.add("dark-editable-element")}route_mode(){switch(this.mode){default:throw new Error(`Mode ${this.mode} not found!`);case"popup":return new L(this);case"inline":return new T(this)}}route_type(){if(this.type.prototype instanceof c)return new this.type(this);if(typeof this.type=="string")switch(this.type){case"text":case"password":case"email":case"url":case"tel":case"number":case"range":case"time":return new M(this);case"textarea":return new C(this);case"select":return new k(this);case"date":return new f(this);case"datetime":return new D(this)}throw new Error("Undefined type")}async success(t,e){return await this.typeElement.successResponse(t,e)}async error(t,e){return await this.typeElement.errorResponse(t,e)}enable(){this.disabled=!1,this.element.classList.remove("dark-editable-element-disabled"),this.modeElement.enable()}disable(){this.disabled=!0,this.element.classList.add("dark-editable-element-disabled"),this.modeElement.enable()}setValue(t){this.value=t,this.init_text()}getValue(){return this.value}}function H(i){const t=parseInt(i.dataset.id),e=parseInt(i.dataset.group),n={pk:e,mode:"inline",url:"./api/v2/transactions/"+e,formType:"journal_description",journalId:t,method:"PUT"};new Y(i,n)}let I=function(){return{notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},groupProperties:{id:0,transactionType:"",transactionTypeTranslated:"",title:"",date:new Date},dateFields:["book_date","due_date","interest_date","invoice_date","payment_date","process_date"],metaFields:["external_id","internal_reference","sepa_batch_id","sepa_ct_id","sepa_ct_op","sepa_db","sepa_country","sepa_cc","sepa_ep","sepa_ci","external_url"],amounts:{},entries:[],pageProperties:{},formatMoney(i,t){return console.log("formatting",i,t),t===""&&(t="EUR"),b(i,t)},format(i){return g(i,h.t("config.date_time_fns"))},init(){this.notifications.wait.show=!0,this.notifications.wait.text=h.t("firefly.wait_loading_data");const i=window.location.href.split("/"),t=parseInt(i[i.length-1]);new E().show(t,{}).then(n=>{const s=n.data.data;this.groupProperties.id=parseInt(s.id),this.groupProperties.transactionType=s.attributes.transactions[0].type,this.groupProperties.transactionTypeTranslated=h.t("firefly."+s.attributes.transactions[0].type),this.groupProperties.title=s.attributes.title??s.attributes.transactions[0].description,this.entries=_(s.attributes.transactions,parseInt(s.id)),this.notifications.wait.show=!1}).then(()=>{for(let s in this.entries)if(this.entries.hasOwnProperty(s)){const o=this.entries[s].currency_code,a=this.entries[s].foreign_currency_code;this.amounts[o]===void 0&&(this.amounts[o]=0,this.amounts[o]+=parseFloat(this.entries[s].amount)),a!==null&&a!==""&&this.amounts[a]===void 0&&(this.amounts[a]=0,this.amounts[a]+=parseFloat(this.entries[s].foreign_amount)),parseInt(s)===0&&(this.groupProperties.date=this.entries[s].date)}const n=document.querySelectorAll(".journal_description");for(const s in n)if(n.hasOwnProperty(s)){const o=n[s];o.addEventListener("save",function(a){parseInt(a.currentTarget.dataset.id);const d=parseInt(a.currentTarget.dataset.group),u=parseInt(a.currentTarget.dataset.length),p=a.currentTarget.textContent;console.log(u),u===1&&(document.querySelector('.group_title[data-group="'+d+'"]').textContent=p,document.querySelector('.group_title_title[data-group="'+d+'"]').textContent=p)}),H(o)}}).catch(n=>{this.notifications.error.show=!0,this.notifications.error.text=n.message})}}},m={show:I,dates:v};function x(){Object.keys(m).forEach(i=>{console.log(`Loading page component "${i}"`);let t=m[i]();Alpine.data(i,()=>t)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),x()});window.bootstrapped&&(console.log("Loaded through window variable."),x()); diff --git a/public/build/assets/splice-errors-into-transactions-cc245990.js b/public/build/assets/splice-errors-into-transactions-cc4832b4.js similarity index 98% rename from public/build/assets/splice-errors-into-transactions-cc245990.js rename to public/build/assets/splice-errors-into-transactions-cc4832b4.js index 9d98a7246c..f00b7e34b3 100644 --- a/public/build/assets/splice-errors-into-transactions-cc245990.js +++ b/public/build/assets/splice-errors-into-transactions-cc4832b4.js @@ -1 +1 @@ -import{a as l}from"./format-money-0f129d93.js";import{a as p,G as f}from"./get-d03e8e57.js";import{n as m,i as _}from"./vendor-baac879b.js";function x(r,t,a){let n=[];for(let o in r)if(r.hasOwnProperty(o)){const e=r[o];let i=!1,u={};t!==null&&t.hasOwnProperty(o)&&(i=!0,t[o]);let c={};(i&&u.description!==e.description||!i)&&(c.description=e.description),c.source_name=e.source_account.name,c.destination_name=e.destination_account.name,c.amount=e.amount,c.currency_code=e.currency_code,c.date=e.date,c.interest_date=e.interest_date,c.book_date=e.book_date,c.process_date=e.process_date,c.due_date=e.due_date,c.payment_date=e.payment_date,c.invoice_date=e.invoice_date,c.budget_id=e.budget_id,c.category_name=e.category_name,c.piggy_bank_id=e.piggy_bank_id,c.bill_id=e.bill_id,c.tags=e.tags,c.notes=e.notes,c.internal_reference=e.internal_reference,c.external_url=e.external_url,c.store_location=!1,e.hasLocation&&(c.store_location=!0,c.longitude=e.longitude.toString(),c.latitude=e.latitude.toString(),c.zoom_level=e.zoomLevel),typeof e.foreign_currency_code<"u"&&e.foreign_currency_code.toString()!==""&&(c.foreign_currency_code=e.foreign_currency_code,typeof e.foreign_amount<"u"&&e.foreign_amount.toString()!==""&&(c.foreign_amount=e.foreign_amount),(typeof e.foreign_amount>"u"||e.foreign_amount.toString()==="")&&(delete c.foreign_amount,delete c.foreign_currency_code)),typeof e.source_account.id<"u"&&e.source_account.id.toString()!==""&&(c.source_id=e.source_account.id),typeof e.destination_account.id<"u"&&e.destination_account.id.toString()!==""&&(c.destination_id=e.destination_account.id),c.type=a,n.push(c)}return n}let g=class{list(t){return l.get("/api/v2/currencies",{params:t})}};function C(){let r={page:1,limit:1337};return new g().list(r).then(a=>{let n={defaultCurrency:{},nativeCurrencies:[],foreignCurrencies:[],enabledCurrencies:[]};n.foreignCurrencies.push({id:0,name:"(no foreign currency)",code:"",default:!1,symbol:"",decimal_places:2});for(let o in a.data.data)if(a.data.data.hasOwnProperty(o)){let e=a.data.data[o];if(e.attributes.enabled){let i={id:e.id,name:e.attributes.name,code:e.attributes.code,default:e.attributes.default,symbol:e.attributes.symbol,decimal_places:e.attributes.decimal_places};i.default&&(n.defaultCurrency=i),n.enabledCurrencies.push(i),n.nativeCurrencies.push(i),n.foreignCurrencies.push(i)}}return n})}class y{list(t){return l.get("/api/v2/budgets",{params:t})}}function $(){let r={page:1,limit:1337};return new y().list(r).then(a=>{let n=[{id:0,name:"(no budget)"}];for(let o in a.data.data)if(a.data.data.hasOwnProperty(o)){let e=a.data.data[o],i={id:e.id,name:e.attributes.name};n.push(i)}return n})}function O(){let r={page:1,limit:1337};return new p().list(r).then(a=>{let n={0:{id:0,name:"(no group)",order:0,piggyBanks:[{id:0,name:"(no piggy bank)",order:0}]}};for(let o in a.data.data)if(a.data.data.hasOwnProperty(o)){let e=a.data.data[o],i=e.attributes.object_group_id??"0",u=e.attributes.object_group_title??"(no group)",c={id:e.id,name:e.attributes.name,order:e.attributes.order};n.hasOwnProperty(i)||(n[i]={id:i,name:u,order:e.attributes.object_group_order??0,piggyBanks:[]}),n[i].piggyBanks.push(c),n[i].piggyBanks.sort((d,s)=>d.order-s.order)}return Object.keys(n).sort().reduce((o,e)=>(o[e]=n[e],o),{})})}function P(){let r={page:1,limit:1337};return new f().list(r).then(a=>{let n={0:{id:0,name:"(no group)",order:0,subscriptions:[{id:0,name:"(no subscription)",order:0}]}};for(let o in a.data.data)if(a.data.data.hasOwnProperty(o)){let e=a.data.data[o],i=e.attributes.object_group_id??"0",u=e.attributes.object_group_title??"(no group)",c={id:e.id,name:e.attributes.name,order:e.attributes.order};n.hasOwnProperty(i)||(n[i]={id:i,name:u,order:e.attributes.object_group_order??0,subscriptions:[]}),n[i].subscriptions.push(c),n[i].subscriptions.sort((d,s)=>d.order-s.order)}return Object.keys(n).sort().reduce((o,e)=>(o[e]=n[e],o),{})})}function j(){return{description:"/api/v2/autocomplete/transaction-descriptions",account:"/api/v2/autocomplete/accounts",category:"/api/v2/autocomplete/categories",tag:"/api/v2/autocomplete/tags"}}function A(r){const t={server:r.serverUrl,serverParams:{},fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}},hiddenInput:!0,highlightTyped:!0,liveServer:!0};typeof r.filters<"u"&&r.filters.length>0&&(t.serverParams.types=r.filters),typeof r.onRenderItem<"u"&&r.onRenderItem!==null&&(t.onRenderItem=r.onRenderItem),r.valueField&&(t.valueField=r.valueField),r.labelField&&(t.labelField=r.labelField),r.onSelectItem&&(t.onSelectItem=r.onSelectItem),r.onChange&&(t.onChange=r.onChange),r.hiddenValue&&(t.hiddenValue=r.hiddenValue),m.init(r.selector,t)}function q(r,t){const a=parseInt(t._searchInput.attributes["data-index"].value);if(typeof r<"u"&&r.name){document.querySelector("#form")._x_dataStack[0].$data.entries[a].category_name=r.name;return}document.querySelector("#form")._x_dataStack[0].$data.entries[a].category_name=t._searchInput.value}function E(r,t){const a=parseInt(t._searchInput.attributes["data-index"].value);if(typeof r<"u"&&r.description){document.querySelector("#form")._x_dataStack[0].$data.entries[a].description=r.description;return}document.querySelector("#form")._x_dataStack[0].$data.entries[a].description=t._searchInput.value}function B(r,t){if(typeof r>"u"){const a=parseInt(t._searchInput.attributes["data-index"].value);if(document.querySelector("#form")._x_dataStack[0].$data.entries[a].destination_account.name===t._searchInput.value){console.warn('Ignore hallucinated destination account name change to "'+t._searchInput.value+'"');return}document.querySelector("#form")._x_dataStack[0].$data.entries[a].destination_account={name:t._searchInput.value,alpine_name:t._searchInput.value},document.querySelector("#form")._x_dataStack[0].changedDestinationAccount()}}function F(r,t){const a=parseInt(t._searchInput.attributes["data-index"].value);document.querySelector("#form")._x_dataStack[0].$data.entries[a].destination_account={id:r.id,name:r.name,alpine_name:r.name,type:r.type,currency_code:r.currency_code},document.querySelector("#form")._x_dataStack[0].changedDestinationAccount()}function G(r,t){if(typeof r>"u"){const a=parseInt(t._searchInput.attributes["data-index"].value);if(document.querySelector("#form")._x_dataStack[0].$data.entries[a].source_account.name===t._searchInput.value)return;document.querySelector("#form")._x_dataStack[0].$data.entries[a].source_account={name:t._searchInput.value,alpine_name:t._searchInput.value},document.querySelector("#form")._x_dataStack[0].changedSourceAccount()}}function R(r,t){const a=parseInt(t._searchInput.attributes["data-index"].value);document.querySelector("#form")._x_dataStack[0].$data.entries[a].source_account={id:r.id,name:r.name,alpine_name:r.name,type:r.type,currency_code:r.currency_code},document.querySelector("#form")._x_dataStack[0].changedSourceAccount()}class h{post(t,a,n){let o="/api/v1/attachments";return l.post(o,{filename:t,attachable_type:a,attachable_id:n})}upload(t,a){let n="./api/v1/attachments/"+t+"/upload";return axios.post(n,a)}}let b=function(r){let t=r.length,a=0,n=!1;for(const o in r)if(r.hasOwnProperty(o)&&/^0$|^[1-9]\d*$/.test(o)&&o<=4294967294&&n===!1){let e=new h;e.post(r[o].name,"TransactionJournal",r[o].journal).then(i=>{let u=parseInt(i.data.data.id);e.upload(u,r[o].content).then(c=>{if(a++,a===t){const d=new CustomEvent("upload-success",{some:"details"});document.dispatchEvent(d)}}).catch(c=>{console.error("Could not upload"),console.error(c),a++;const d=new CustomEvent("upload-failed",{error:c});document.dispatchEvent(d),n=!0})}).catch(i=>{console.error("Could not create upload."),console.error(i),a++;const u=new CustomEvent("upload-failed",{error:i});document.dispatchEvent(u),n=!0})}};function T(r,t){t=t.reverse();let a=[],n=0,o=[],e=document.querySelectorAll('input[name="attachments[]"]');for(const i in e)if(e.hasOwnProperty(i)&&/^0$|^[1-9]\d*$/.test(i)&&i<=4294967294)for(const u in e[i].files)e[i].files.hasOwnProperty(u)&&/^0$|^[1-9]\d*$/.test(u)&&u<=4294967294&&(a.push({journal:t[i].transaction_journal_id,file:e[i].files[u]}),n++);for(const i in a)a.hasOwnProperty(i)&&/^0$|^[1-9]\d*$/.test(i)&&i<=4294967294&&function(u,c){let d=new FileReader;d.onloadend=function(s){s.target.readyState===FileReader.DONE&&(o.push({name:a[c].file.name,journal:a[c].journal,content:new Blob([s.target.result])}),o.length===n&&b(o))},d.readAsArrayBuffer(u.file)}(a[i],i);return n}function v(r,t,a){let n=[];for(let o in a)a.hasOwnProperty(o)&&n.push(a[o].replace(r,t));return n}function D(r,t){let a,n,o;for(const e in r)if(r.hasOwnProperty(e)){if(e==="group_title"){console.error("Cannot handle error in group title.");continue}if(a=parseInt(e.split(".")[1]),n=e.split(".")[2],o=v(e,n,r[e]),!t.hasOwnProperty(a)){console.error("Cannot handle errors in index #"+a);continue}switch(n){case"currency_code":case"foreign_currency_code":case"category_name":case"piggy_bank_id":case"notes":case"internal_reference":case"external_url":case"latitude":case"longitude":case"zoom_level":case"interest_date":case"book_date":case"process_date":case"due_date":case"payment_date":case"invoice_date":case"amount":case"date":case"budget_id":case"bill_id":case"description":case"tags":t[a].errors[n]=o;break;case"source_name":case"source_id":t[a].errors.source_account=t[a].errors.source_account.concat(o);break;case"type":t[a].errors.source_account=t[a].errors.source_account.concat([_.t("validation.bad_type_source")]),t[a].errors.destination_account=t[a].errors.destination_account.concat([_.t("validation.bad_type_destination")]);break;case"destination_name":case"destination_id":t[a].errors.destination_account=t[a].errors.destination_account.concat(o);break;case"foreign_amount":case"foreign_currency_id":t[a].errors.foreign_amount=t[a].errors.foreign_amount.concat(o);break}typeof t[a]<"u"&&(t[a].errors.source_account=Array.from(new Set(t[a].errors.source_account)),t[a].errors.destination_account=Array.from(new Set(t[a].errors.destination_account)))}return console.log(t[0].errors),t}export{$ as a,O as b,P as c,T as d,A as e,G as f,R as g,B as h,F as i,j,q as k,C as l,E as m,x as p,D as s}; +import{a as l}from"./format-money-e4c435dc.js";import{a as p,G as f}from"./get-95250f8d.js";import{n as m,i as _}from"./vendor-76961a66.js";function x(r,t,a){let n=[];for(let o in r)if(r.hasOwnProperty(o)){const e=r[o];let i=!1,u={};t!==null&&t.hasOwnProperty(o)&&(i=!0,t[o]);let c={};(i&&u.description!==e.description||!i)&&(c.description=e.description),c.source_name=e.source_account.name,c.destination_name=e.destination_account.name,c.amount=e.amount,c.currency_code=e.currency_code,c.date=e.date,c.interest_date=e.interest_date,c.book_date=e.book_date,c.process_date=e.process_date,c.due_date=e.due_date,c.payment_date=e.payment_date,c.invoice_date=e.invoice_date,c.budget_id=e.budget_id,c.category_name=e.category_name,c.piggy_bank_id=e.piggy_bank_id,c.bill_id=e.bill_id,c.tags=e.tags,c.notes=e.notes,c.internal_reference=e.internal_reference,c.external_url=e.external_url,c.store_location=!1,e.hasLocation&&(c.store_location=!0,c.longitude=e.longitude.toString(),c.latitude=e.latitude.toString(),c.zoom_level=e.zoomLevel),typeof e.foreign_currency_code<"u"&&e.foreign_currency_code.toString()!==""&&(c.foreign_currency_code=e.foreign_currency_code,typeof e.foreign_amount<"u"&&e.foreign_amount.toString()!==""&&(c.foreign_amount=e.foreign_amount),(typeof e.foreign_amount>"u"||e.foreign_amount.toString()==="")&&(delete c.foreign_amount,delete c.foreign_currency_code)),typeof e.source_account.id<"u"&&e.source_account.id.toString()!==""&&(c.source_id=e.source_account.id),typeof e.destination_account.id<"u"&&e.destination_account.id.toString()!==""&&(c.destination_id=e.destination_account.id),c.type=a,n.push(c)}return n}let g=class{list(t){return l.get("/api/v2/currencies",{params:t})}};function C(){let r={page:1,limit:1337};return new g().list(r).then(a=>{let n={defaultCurrency:{},nativeCurrencies:[],foreignCurrencies:[],enabledCurrencies:[]};n.foreignCurrencies.push({id:0,name:"(no foreign currency)",code:"",default:!1,symbol:"",decimal_places:2});for(let o in a.data.data)if(a.data.data.hasOwnProperty(o)){let e=a.data.data[o];if(e.attributes.enabled){let i={id:e.id,name:e.attributes.name,code:e.attributes.code,default:e.attributes.default,symbol:e.attributes.symbol,decimal_places:e.attributes.decimal_places};i.default&&(n.defaultCurrency=i),n.enabledCurrencies.push(i),n.nativeCurrencies.push(i),n.foreignCurrencies.push(i)}}return n})}class y{list(t){return l.get("/api/v2/budgets",{params:t})}}function $(){let r={page:1,limit:1337};return new y().list(r).then(a=>{let n=[{id:0,name:"(no budget)"}];for(let o in a.data.data)if(a.data.data.hasOwnProperty(o)){let e=a.data.data[o],i={id:e.id,name:e.attributes.name};n.push(i)}return n})}function O(){let r={page:1,limit:1337};return new p().list(r).then(a=>{let n={0:{id:0,name:"(no group)",order:0,piggyBanks:[{id:0,name:"(no piggy bank)",order:0}]}};for(let o in a.data.data)if(a.data.data.hasOwnProperty(o)){let e=a.data.data[o],i=e.attributes.object_group_id??"0",u=e.attributes.object_group_title??"(no group)",c={id:e.id,name:e.attributes.name,order:e.attributes.order};n.hasOwnProperty(i)||(n[i]={id:i,name:u,order:e.attributes.object_group_order??0,piggyBanks:[]}),n[i].piggyBanks.push(c),n[i].piggyBanks.sort((d,s)=>d.order-s.order)}return Object.keys(n).sort().reduce((o,e)=>(o[e]=n[e],o),{})})}function P(){let r={page:1,limit:1337};return new f().list(r).then(a=>{let n={0:{id:0,name:"(no group)",order:0,subscriptions:[{id:0,name:"(no subscription)",order:0}]}};for(let o in a.data.data)if(a.data.data.hasOwnProperty(o)){let e=a.data.data[o],i=e.attributes.object_group_id??"0",u=e.attributes.object_group_title??"(no group)",c={id:e.id,name:e.attributes.name,order:e.attributes.order};n.hasOwnProperty(i)||(n[i]={id:i,name:u,order:e.attributes.object_group_order??0,subscriptions:[]}),n[i].subscriptions.push(c),n[i].subscriptions.sort((d,s)=>d.order-s.order)}return Object.keys(n).sort().reduce((o,e)=>(o[e]=n[e],o),{})})}function j(){return{description:"/api/v2/autocomplete/transaction-descriptions",account:"/api/v2/autocomplete/accounts",category:"/api/v2/autocomplete/categories",tag:"/api/v2/autocomplete/tags"}}function A(r){const t={server:r.serverUrl,serverParams:{},fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}},hiddenInput:!0,highlightTyped:!0,liveServer:!0};typeof r.filters<"u"&&r.filters.length>0&&(t.serverParams.types=r.filters),typeof r.onRenderItem<"u"&&r.onRenderItem!==null&&(t.onRenderItem=r.onRenderItem),r.valueField&&(t.valueField=r.valueField),r.labelField&&(t.labelField=r.labelField),r.onSelectItem&&(t.onSelectItem=r.onSelectItem),r.onChange&&(t.onChange=r.onChange),r.hiddenValue&&(t.hiddenValue=r.hiddenValue),m.init(r.selector,t)}function q(r,t){const a=parseInt(t._searchInput.attributes["data-index"].value);if(typeof r<"u"&&r.name){document.querySelector("#form")._x_dataStack[0].$data.entries[a].category_name=r.name;return}document.querySelector("#form")._x_dataStack[0].$data.entries[a].category_name=t._searchInput.value}function E(r,t){const a=parseInt(t._searchInput.attributes["data-index"].value);if(typeof r<"u"&&r.description){document.querySelector("#form")._x_dataStack[0].$data.entries[a].description=r.description;return}document.querySelector("#form")._x_dataStack[0].$data.entries[a].description=t._searchInput.value}function B(r,t){if(typeof r>"u"){const a=parseInt(t._searchInput.attributes["data-index"].value);if(document.querySelector("#form")._x_dataStack[0].$data.entries[a].destination_account.name===t._searchInput.value){console.warn('Ignore hallucinated destination account name change to "'+t._searchInput.value+'"');return}document.querySelector("#form")._x_dataStack[0].$data.entries[a].destination_account={name:t._searchInput.value,alpine_name:t._searchInput.value},document.querySelector("#form")._x_dataStack[0].changedDestinationAccount()}}function F(r,t){const a=parseInt(t._searchInput.attributes["data-index"].value);document.querySelector("#form")._x_dataStack[0].$data.entries[a].destination_account={id:r.id,name:r.name,alpine_name:r.name,type:r.type,currency_code:r.currency_code},document.querySelector("#form")._x_dataStack[0].changedDestinationAccount()}function G(r,t){if(typeof r>"u"){const a=parseInt(t._searchInput.attributes["data-index"].value);if(document.querySelector("#form")._x_dataStack[0].$data.entries[a].source_account.name===t._searchInput.value)return;document.querySelector("#form")._x_dataStack[0].$data.entries[a].source_account={name:t._searchInput.value,alpine_name:t._searchInput.value},document.querySelector("#form")._x_dataStack[0].changedSourceAccount()}}function R(r,t){const a=parseInt(t._searchInput.attributes["data-index"].value);document.querySelector("#form")._x_dataStack[0].$data.entries[a].source_account={id:r.id,name:r.name,alpine_name:r.name,type:r.type,currency_code:r.currency_code},document.querySelector("#form")._x_dataStack[0].changedSourceAccount()}class h{post(t,a,n){let o="/api/v1/attachments";return l.post(o,{filename:t,attachable_type:a,attachable_id:n})}upload(t,a){let n="./api/v1/attachments/"+t+"/upload";return axios.post(n,a)}}let b=function(r){let t=r.length,a=0,n=!1;for(const o in r)if(r.hasOwnProperty(o)&&/^0$|^[1-9]\d*$/.test(o)&&o<=4294967294&&n===!1){let e=new h;e.post(r[o].name,"TransactionJournal",r[o].journal).then(i=>{let u=parseInt(i.data.data.id);e.upload(u,r[o].content).then(c=>{if(a++,a===t){const d=new CustomEvent("upload-success",{some:"details"});document.dispatchEvent(d)}}).catch(c=>{console.error("Could not upload"),console.error(c),a++;const d=new CustomEvent("upload-failed",{error:c});document.dispatchEvent(d),n=!0})}).catch(i=>{console.error("Could not create upload."),console.error(i),a++;const u=new CustomEvent("upload-failed",{error:i});document.dispatchEvent(u),n=!0})}};function T(r,t){t=t.reverse();let a=[],n=0,o=[],e=document.querySelectorAll('input[name="attachments[]"]');for(const i in e)if(e.hasOwnProperty(i)&&/^0$|^[1-9]\d*$/.test(i)&&i<=4294967294)for(const u in e[i].files)e[i].files.hasOwnProperty(u)&&/^0$|^[1-9]\d*$/.test(u)&&u<=4294967294&&(a.push({journal:t[i].transaction_journal_id,file:e[i].files[u]}),n++);for(const i in a)a.hasOwnProperty(i)&&/^0$|^[1-9]\d*$/.test(i)&&i<=4294967294&&function(u,c){let d=new FileReader;d.onloadend=function(s){s.target.readyState===FileReader.DONE&&(o.push({name:a[c].file.name,journal:a[c].journal,content:new Blob([s.target.result])}),o.length===n&&b(o))},d.readAsArrayBuffer(u.file)}(a[i],i);return n}function v(r,t,a){let n=[];for(let o in a)a.hasOwnProperty(o)&&n.push(a[o].replace(r,t));return n}function D(r,t){let a,n,o;for(const e in r)if(r.hasOwnProperty(e)){if(e==="group_title"){console.error("Cannot handle error in group title.");continue}if(a=parseInt(e.split(".")[1]),n=e.split(".")[2],o=v(e,n,r[e]),!t.hasOwnProperty(a)){console.error("Cannot handle errors in index #"+a);continue}switch(n){case"currency_code":case"foreign_currency_code":case"category_name":case"piggy_bank_id":case"notes":case"internal_reference":case"external_url":case"latitude":case"longitude":case"zoom_level":case"interest_date":case"book_date":case"process_date":case"due_date":case"payment_date":case"invoice_date":case"amount":case"date":case"budget_id":case"bill_id":case"description":case"tags":t[a].errors[n]=o;break;case"source_name":case"source_id":t[a].errors.source_account=t[a].errors.source_account.concat(o);break;case"type":t[a].errors.source_account=t[a].errors.source_account.concat([_.t("validation.bad_type_source")]),t[a].errors.destination_account=t[a].errors.destination_account.concat([_.t("validation.bad_type_destination")]);break;case"destination_name":case"destination_id":t[a].errors.destination_account=t[a].errors.destination_account.concat(o);break;case"foreign_amount":case"foreign_currency_id":t[a].errors.foreign_amount=t[a].errors.foreign_amount.concat(o);break}typeof t[a]<"u"&&(t[a].errors.source_account=Array.from(new Set(t[a].errors.source_account)),t[a].errors.destination_account=Array.from(new Set(t[a].errors.destination_account)))}return console.log(t[0].errors),t}export{$ as a,O as b,P as c,T as d,A as e,G as f,R as g,B as h,F as i,j,q as k,C as l,E as m,x as p,D as s}; diff --git a/public/build/assets/vendor-76961a66.js b/public/build/assets/vendor-76961a66.js new file mode 100644 index 0000000000..aa9e1e4ded --- /dev/null +++ b/public/build/assets/vendor-76961a66.js @@ -0,0 +1,54 @@ +var ia=Object.defineProperty;var ra=(n,t,e)=>t in n?ia(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var F=(n,t,e)=>(ra(n,typeof t!="symbol"?t+"":t,e),e);function _mergeNamespaces(n,t){for(var e=0;ei[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}function bind$4(n,t){return function(){return n.apply(t,arguments)}}const{toString}=Object.prototype,{getPrototypeOf}=Object,kindOf=(n=>t=>{const e=toString.call(t);return n[e]||(n[e]=e.slice(8,-1).toLowerCase())})(Object.create(null)),kindOfTest=n=>(n=n.toLowerCase(),t=>kindOf(t)===n),typeOfTest=n=>t=>typeof t===n,{isArray:isArray$2}=Array,isUndefined=typeOfTest("undefined");function isBuffer(n){return n!==null&&!isUndefined(n)&&n.constructor!==null&&!isUndefined(n.constructor)&&isFunction$3(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const isArrayBuffer=kindOfTest("ArrayBuffer");function isArrayBufferView(n){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(n):t=n&&n.buffer&&isArrayBuffer(n.buffer),t}const isString$1=typeOfTest("string"),isFunction$3=typeOfTest("function"),isNumber$1=typeOfTest("number"),isObject$4=n=>n!==null&&typeof n=="object",isBoolean=n=>n===!0||n===!1,isPlainObject=n=>{if(kindOf(n)!=="object")return!1;const t=getPrototypeOf(n);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},isDate$1=kindOfTest("Date"),isFile=kindOfTest("File"),isBlob=kindOfTest("Blob"),isFileList=kindOfTest("FileList"),isStream=n=>isObject$4(n)&&isFunction$3(n.pipe),isFormData=n=>{let t;return n&&(typeof FormData=="function"&&n instanceof FormData||isFunction$3(n.append)&&((t=kindOf(n))==="formdata"||t==="object"&&isFunction$3(n.toString)&&n.toString()==="[object FormData]"))},isURLSearchParams=kindOfTest("URLSearchParams"),trim$2=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function forEach(n,t,{allOwnKeys:e=!1}={}){if(n===null||typeof n>"u")return;let i,r;if(typeof n!="object"&&(n=[n]),isArray$2(n))for(i=0,r=n.length;i0;)if(r=e[i],t===r.toLowerCase())return r;return null}const _global=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),isContextDefined=n=>!isUndefined(n)&&n!==_global;function merge$1(){const{caseless:n}=isContextDefined(this)&&this||{},t={},e=(i,r)=>{const a=n&&findKey$1(t,r)||r;isPlainObject(t[a])&&isPlainObject(i)?t[a]=merge$1(t[a],i):isPlainObject(i)?t[a]=merge$1({},i):isArray$2(i)?t[a]=i.slice():t[a]=i};for(let i=0,r=arguments.length;i(forEach(t,(r,a)=>{e&&isFunction$3(r)?n[a]=bind$4(r,e):n[a]=r},{allOwnKeys:i}),n),stripBOM=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),inherits=(n,t,e,i)=>{n.prototype=Object.create(t.prototype,i),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:t.prototype}),e&&Object.assign(n.prototype,e)},toFlatObject=(n,t,e,i)=>{let r,a,o;const l={};if(t=t||{},n==null)return t;do{for(r=Object.getOwnPropertyNames(n),a=r.length;a-- >0;)o=r[a],(!i||i(o,n,t))&&!l[o]&&(t[o]=n[o],l[o]=!0);n=e!==!1&&getPrototypeOf(n)}while(n&&(!e||e(n,t))&&n!==Object.prototype);return t},endsWith=(n,t,e)=>{n=String(n),(e===void 0||e>n.length)&&(e=n.length),e-=t.length;const i=n.indexOf(t,e);return i!==-1&&i===e},toArray=n=>{if(!n)return null;if(isArray$2(n))return n;let t=n.length;if(!isNumber$1(t))return null;const e=new Array(t);for(;t-- >0;)e[t]=n[t];return e},isTypedArray=(n=>t=>n&&t instanceof n)(typeof Uint8Array<"u"&&getPrototypeOf(Uint8Array)),forEachEntry=(n,t)=>{const i=(n&&n[Symbol.iterator]).call(n);let r;for(;(r=i.next())&&!r.done;){const a=r.value;t.call(n,a[0],a[1])}},matchAll=(n,t)=>{let e;const i=[];for(;(e=n.exec(t))!==null;)i.push(e);return i},isHTMLForm=kindOfTest("HTMLFormElement"),toCamelCase=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,i,r){return i.toUpperCase()+r}),hasOwnProperty$1=(({hasOwnProperty:n})=>(t,e)=>n.call(t,e))(Object.prototype),isRegExp=kindOfTest("RegExp"),reduceDescriptors=(n,t)=>{const e=Object.getOwnPropertyDescriptors(n),i={};forEach(e,(r,a)=>{let o;(o=t(r,a,n))!==!1&&(i[a]=o||r)}),Object.defineProperties(n,i)},freezeMethods=n=>{reduceDescriptors(n,(t,e)=>{if(isFunction$3(n)&&["arguments","caller","callee"].indexOf(e)!==-1)return!1;const i=n[e];if(isFunction$3(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+e+"'")})}})},toObjectSet=(n,t)=>{const e={},i=r=>{r.forEach(a=>{e[a]=!0})};return isArray$2(n)?i(n):i(String(n).split(t)),e},noop$3=()=>{},toFiniteNumber=(n,t)=>(n=+n,Number.isFinite(n)?n:t),ALPHA="abcdefghijklmnopqrstuvwxyz",DIGIT="0123456789",ALPHABET={DIGIT,ALPHA,ALPHA_DIGIT:ALPHA+ALPHA.toUpperCase()+DIGIT},generateString=(n=16,t=ALPHABET.ALPHA_DIGIT)=>{let e="";const{length:i}=t;for(;n--;)e+=t[Math.random()*i|0];return e};function isSpecCompliantForm(n){return!!(n&&isFunction$3(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const toJSONObject=n=>{const t=new Array(10),e=(i,r)=>{if(isObject$4(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[r]=i;const a=isArray$2(i)?[]:{};return forEach(i,(o,l)=>{const u=e(o,r+1);!isUndefined(u)&&(a[l]=u)}),t[r]=void 0,a}}return i};return e(n,0)},isAsyncFn=kindOfTest("AsyncFunction"),isThenable=n=>n&&(isObject$4(n)||isFunction$3(n))&&isFunction$3(n.then)&&isFunction$3(n.catch),utils$1={isArray:isArray$2,isArrayBuffer,isBuffer,isFormData,isArrayBufferView,isString:isString$1,isNumber:isNumber$1,isBoolean,isObject:isObject$4,isPlainObject,isUndefined,isDate:isDate$1,isFile,isBlob,isRegExp,isFunction:isFunction$3,isStream,isURLSearchParams,isTypedArray,isFileList,forEach,merge:merge$1,extend,trim:trim$2,stripBOM,inherits,toFlatObject,kindOf,kindOfTest,endsWith,toArray,forEachEntry,matchAll,isHTMLForm,hasOwnProperty:hasOwnProperty$1,hasOwnProp:hasOwnProperty$1,reduceDescriptors,freezeMethods,toObjectSet,toCamelCase,noop:noop$3,toFiniteNumber,findKey:findKey$1,global:_global,isContextDefined,ALPHABET,generateString,isSpecCompliantForm,toJSONObject,isAsyncFn,isThenable};function AxiosError(n,t,e,i,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",t&&(this.code=t),e&&(this.config=e),i&&(this.request=i),r&&(this.response=r)}utils$1.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$1.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const prototype$1=AxiosError.prototype,descriptors$1={};["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(n=>{descriptors$1[n]={value:n}});Object.defineProperties(AxiosError,descriptors$1);Object.defineProperty(prototype$1,"isAxiosError",{value:!0});AxiosError.from=(n,t,e,i,r,a)=>{const o=Object.create(prototype$1);return utils$1.toFlatObject(n,o,function(u){return u!==Error.prototype},l=>l!=="isAxiosError"),AxiosError.call(o,n.message,t,e,i,r),o.cause=n,o.name=n.name,a&&Object.assign(o,a),o};const httpAdapter=null;function isVisitable(n){return utils$1.isPlainObject(n)||utils$1.isArray(n)}function removeBrackets(n){return utils$1.endsWith(n,"[]")?n.slice(0,-2):n}function renderKey(n,t,e){return n?n.concat(t).map(function(r,a){return r=removeBrackets(r),!e&&a?"["+r+"]":r}).join(e?".":""):t}function isFlatArray(n){return utils$1.isArray(n)&&!n.some(isVisitable)}const predicates=utils$1.toFlatObject(utils$1,{},null,function(t){return/^is[A-Z]/.test(t)});function toFormData(n,t,e){if(!utils$1.isObject(n))throw new TypeError("target must be an object");t=t||new FormData,e=utils$1.toFlatObject(e,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,P){return!utils$1.isUndefined(P[v])});const i=e.metaTokens,r=e.visitor||m,a=e.dots,o=e.indexes,u=(e.Blob||typeof Blob<"u"&&Blob)&&utils$1.isSpecCompliantForm(t);if(!utils$1.isFunction(r))throw new TypeError("visitor must be a function");function d(w){if(w===null)return"";if(utils$1.isDate(w))return w.toISOString();if(!u&&utils$1.isBlob(w))throw new AxiosError("Blob is not supported. Use a Buffer instead.");return utils$1.isArrayBuffer(w)||utils$1.isTypedArray(w)?u&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function m(w,v,P){let x=w;if(w&&!P&&typeof w=="object"){if(utils$1.endsWith(v,"{}"))v=i?v:v.slice(0,-2),w=JSON.stringify(w);else if(utils$1.isArray(w)&&isFlatArray(w)||(utils$1.isFileList(w)||utils$1.endsWith(v,"[]"))&&(x=utils$1.toArray(w)))return v=removeBrackets(v),x.forEach(function($,k){!(utils$1.isUndefined($)||$===null)&&t.append(o===!0?renderKey([v],k,a):o===null?v:v+"[]",d($))}),!1}return isVisitable(w)?!0:(t.append(renderKey(P,v,a),d(w)),!1)}const p=[],_=Object.assign(predicates,{defaultVisitor:m,convertValue:d,isVisitable});function y(w,v){if(!utils$1.isUndefined(w)){if(p.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));p.push(w),utils$1.forEach(w,function(x,S){(!(utils$1.isUndefined(x)||x===null)&&r.call(t,x,utils$1.isString(S)?S.trim():S,v,_))===!0&&y(x,v?v.concat(S):[S])}),p.pop()}}if(!utils$1.isObject(n))throw new TypeError("data must be an object");return y(n),t}function encode$1(n){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function AxiosURLSearchParams(n,t){this._pairs=[],n&&toFormData(n,this,t)}const prototype=AxiosURLSearchParams.prototype;prototype.append=function(t,e){this._pairs.push([t,e])};prototype.toString=function(t){const e=t?function(i){return t.call(this,i,encode$1)}:encode$1;return this._pairs.map(function(r){return e(r[0])+"="+e(r[1])},"").join("&")};function encode(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function buildURL(n,t,e){if(!t)return n;const i=e&&e.encode||encode,r=e&&e.serialize;let a;if(r?a=r(t,e):a=utils$1.isURLSearchParams(t)?t.toString():new AxiosURLSearchParams(t,e).toString(i),a){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+a}return n}class InterceptorManager{constructor(){this.handlers=[]}use(t,e,i){return this.handlers.push({fulfilled:t,rejected:e,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){utils$1.forEach(this.handlers,function(i){i!==null&&t(i)})}}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,platform$1={isBrowser:!0,classes:{URLSearchParams:URLSearchParams$1,FormData:FormData$1,Blob:Blob$1},protocols:["http","https","file","blob","url","data"]},hasBrowserEnv=typeof window<"u"&&typeof document<"u",hasStandardBrowserEnv=(n=>hasBrowserEnv&&["ReactNative","NativeScript","NS"].indexOf(n)<0)(typeof navigator<"u"&&navigator.product),hasStandardBrowserWebWorkerEnv=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),utils=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv,hasStandardBrowserEnv,hasStandardBrowserWebWorkerEnv},Symbol.toStringTag,{value:"Module"})),platform={...utils,...platform$1};function toURLEncodedForm(n,t){return toFormData(n,new platform.classes.URLSearchParams,Object.assign({visitor:function(e,i,r,a){return platform.isNode&&utils$1.isBuffer(e)?(this.append(i,e.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function parsePropPath(n){return utils$1.matchAll(/\w+|\[(\w*)]/g,n).map(t=>t[0]==="[]"?"":t[1]||t[0])}function arrayToObject(n){const t={},e=Object.keys(n);let i;const r=e.length;let a;for(i=0;i=e.length;return o=!o&&utils$1.isArray(r)?r.length:o,u?(utils$1.hasOwnProp(r,o)?r[o]=[r[o],i]:r[o]=i,!l):((!r[o]||!utils$1.isObject(r[o]))&&(r[o]=[]),t(e,i,r[o],a)&&utils$1.isArray(r[o])&&(r[o]=arrayToObject(r[o])),!l)}if(utils$1.isFormData(n)&&utils$1.isFunction(n.entries)){const e={};return utils$1.forEachEntry(n,(i,r)=>{t(parsePropPath(i),r,e,0)}),e}return null}function stringifySafely(n,t,e){if(utils$1.isString(n))try{return(t||JSON.parse)(n),utils$1.trim(n)}catch(i){if(i.name!=="SyntaxError")throw i}return(e||JSON.stringify)(n)}const defaults$3={transitional:transitionalDefaults,adapter:["xhr","http"],transformRequest:[function(t,e){const i=e.getContentType()||"",r=i.indexOf("application/json")>-1,a=utils$1.isObject(t);if(a&&utils$1.isHTMLForm(t)&&(t=new FormData(t)),utils$1.isFormData(t))return r?JSON.stringify(formDataToJSON(t)):t;if(utils$1.isArrayBuffer(t)||utils$1.isBuffer(t)||utils$1.isStream(t)||utils$1.isFile(t)||utils$1.isBlob(t))return t;if(utils$1.isArrayBufferView(t))return t.buffer;if(utils$1.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return toURLEncodedForm(t,this.formSerializer).toString();if((l=utils$1.isFileList(t))||i.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return toFormData(l?{"files[]":t}:t,u&&new u,this.formSerializer)}}return a||r?(e.setContentType("application/json",!1),stringifySafely(t)):t}],transformResponse:[function(t){const e=this.transitional||defaults$3.transitional,i=e&&e.forcedJSONParsing,r=this.responseType==="json";if(t&&utils$1.isString(t)&&(i&&!this.responseType||r)){const o=!(e&&e.silentJSONParsing)&&r;try{return JSON.parse(t)}catch(l){if(o)throw l.name==="SyntaxError"?AxiosError.from(l,AxiosError.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:platform.classes.FormData,Blob:platform.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};utils$1.forEach(["delete","get","head","post","put","patch"],n=>{defaults$3.headers[n]={}});const defaults$4=defaults$3,ignoreDuplicateOf=utils$1.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=n=>{const t={};let e,i,r;return n&&n.split(` +`).forEach(function(o){r=o.indexOf(":"),e=o.substring(0,r).trim().toLowerCase(),i=o.substring(r+1).trim(),!(!e||t[e]&&ignoreDuplicateOf[e])&&(e==="set-cookie"?t[e]?t[e].push(i):t[e]=[i]:t[e]=t[e]?t[e]+", "+i:i)}),t},$internals=Symbol("internals");function normalizeHeader(n){return n&&String(n).trim().toLowerCase()}function normalizeValue(n){return n===!1||n==null?n:utils$1.isArray(n)?n.map(normalizeValue):String(n)}function parseTokens(n){const t=Object.create(null),e=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=e.exec(n);)t[i[1]]=i[2];return t}const isValidHeaderName=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function matchHeaderValue(n,t,e,i,r){if(utils$1.isFunction(i))return i.call(this,t,e);if(r&&(t=e),!!utils$1.isString(t)){if(utils$1.isString(i))return t.indexOf(i)!==-1;if(utils$1.isRegExp(i))return i.test(t)}}function formatHeader(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,i)=>e.toUpperCase()+i)}function buildAccessors(n,t){const e=utils$1.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(n,i+e,{value:function(r,a,o){return this[i].call(this,t,r,a,o)},configurable:!0})})}class AxiosHeaders{constructor(t){t&&this.set(t)}set(t,e,i){const r=this;function a(l,u,d){const m=normalizeHeader(u);if(!m)throw new Error("header name must be a non-empty string");const p=utils$1.findKey(r,m);(!p||r[p]===void 0||d===!0||d===void 0&&r[p]!==!1)&&(r[p||u]=normalizeValue(l))}const o=(l,u)=>utils$1.forEach(l,(d,m)=>a(d,m,u));return utils$1.isPlainObject(t)||t instanceof this.constructor?o(t,e):utils$1.isString(t)&&(t=t.trim())&&!isValidHeaderName(t)?o(parseHeaders(t),e):t!=null&&a(e,t,i),this}get(t,e){if(t=normalizeHeader(t),t){const i=utils$1.findKey(this,t);if(i){const r=this[i];if(!e)return r;if(e===!0)return parseTokens(r);if(utils$1.isFunction(e))return e.call(this,r,i);if(utils$1.isRegExp(e))return e.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=normalizeHeader(t),t){const i=utils$1.findKey(this,t);return!!(i&&this[i]!==void 0&&(!e||matchHeaderValue(this,this[i],i,e)))}return!1}delete(t,e){const i=this;let r=!1;function a(o){if(o=normalizeHeader(o),o){const l=utils$1.findKey(i,o);l&&(!e||matchHeaderValue(i,i[l],l,e))&&(delete i[l],r=!0)}}return utils$1.isArray(t)?t.forEach(a):a(t),r}clear(t){const e=Object.keys(this);let i=e.length,r=!1;for(;i--;){const a=e[i];(!t||matchHeaderValue(this,this[a],a,t,!0))&&(delete this[a],r=!0)}return r}normalize(t){const e=this,i={};return utils$1.forEach(this,(r,a)=>{const o=utils$1.findKey(i,a);if(o){e[o]=normalizeValue(r),delete e[a];return}const l=t?formatHeader(a):String(a).trim();l!==a&&delete e[a],e[l]=normalizeValue(r),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return utils$1.forEach(this,(i,r)=>{i!=null&&i!==!1&&(e[r]=t&&utils$1.isArray(i)?i.join(", "):i)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const i=new this(t);return e.forEach(r=>i.set(r)),i}static accessor(t){const i=(this[$internals]=this[$internals]={accessors:{}}).accessors,r=this.prototype;function a(o){const l=normalizeHeader(o);i[l]||(buildAccessors(r,o),i[l]=!0)}return utils$1.isArray(t)?t.forEach(a):a(t),this}}AxiosHeaders.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);utils$1.reduceDescriptors(AxiosHeaders.prototype,({value:n},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>n,set(i){this[e]=i}}});utils$1.freezeMethods(AxiosHeaders);const AxiosHeaders$1=AxiosHeaders;function transformData(n,t){const e=this||defaults$4,i=t||e,r=AxiosHeaders$1.from(i.headers);let a=i.data;return utils$1.forEach(n,function(l){a=l.call(e,a,r.normalize(),t?t.status:void 0)}),r.normalize(),a}function isCancel(n){return!!(n&&n.__CANCEL__)}function CanceledError(n,t,e){AxiosError.call(this,n??"canceled",AxiosError.ERR_CANCELED,t,e),this.name="CanceledError"}utils$1.inherits(CanceledError,AxiosError,{__CANCEL__:!0});function settle(n,t,e){const i=e.config.validateStatus;!e.status||!i||i(e.status)?n(e):t(new AxiosError("Request failed with status code "+e.status,[AxiosError.ERR_BAD_REQUEST,AxiosError.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}const cookies=platform.hasStandardBrowserEnv?{write(n,t,e,i,r,a){const o=[n+"="+encodeURIComponent(t)];utils$1.isNumber(e)&&o.push("expires="+new Date(e).toGMTString()),utils$1.isString(i)&&o.push("path="+i),utils$1.isString(r)&&o.push("domain="+r),a===!0&&o.push("secure"),document.cookie=o.join("; ")},read(n){const t=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function isAbsoluteURL(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function combineURLs(n,t){return t?n.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):n}function buildFullPath(n,t){return n&&!isAbsoluteURL(t)?combineURLs(n,t):t}const isURLSameOrigin=platform.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let i;function r(a){let o=a;return t&&(e.setAttribute("href",o),o=e.href),e.setAttribute("href",o),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:e.pathname.charAt(0)==="/"?e.pathname:"/"+e.pathname}}return i=r(window.location.href),function(o){const l=utils$1.isString(o)?r(o):o;return l.protocol===i.protocol&&l.host===i.host}}():function(){return function(){return!0}}();function parseProtocol(n){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return t&&t[1]||""}function speedometer(n,t){n=n||10;const e=new Array(n),i=new Array(n);let r=0,a=0,o;return t=t!==void 0?t:1e3,function(u){const d=Date.now(),m=i[a];o||(o=d),e[r]=u,i[r]=d;let p=a,_=0;for(;p!==r;)_+=e[p++],p=p%n;if(r=(r+1)%n,r===a&&(a=(a+1)%n),d-o{const a=r.loaded,o=r.lengthComputable?r.total:void 0,l=a-e,u=i(l),d=a<=o;e=a;const m={loaded:a,total:o,progress:o?a/o:void 0,bytes:l,rate:u||void 0,estimated:u&&o&&d?(o-a)/u:void 0,event:r};m[t?"download":"upload"]=!0,n(m)}}const isXHRAdapterSupported=typeof XMLHttpRequest<"u",xhrAdapter=isXHRAdapterSupported&&function(n){return new Promise(function(e,i){let r=n.data;const a=AxiosHeaders$1.from(n.headers).normalize();let{responseType:o,withXSRFToken:l}=n,u;function d(){n.cancelToken&&n.cancelToken.unsubscribe(u),n.signal&&n.signal.removeEventListener("abort",u)}let m;if(utils$1.isFormData(r)){if(platform.hasStandardBrowserEnv||platform.hasStandardBrowserWebWorkerEnv)a.setContentType(!1);else if((m=a.getContentType())!==!1){const[v,...P]=m?m.split(";").map(x=>x.trim()).filter(Boolean):[];a.setContentType([v||"multipart/form-data",...P].join("; "))}}let p=new XMLHttpRequest;if(n.auth){const v=n.auth.username||"",P=n.auth.password?unescape(encodeURIComponent(n.auth.password)):"";a.set("Authorization","Basic "+btoa(v+":"+P))}const _=buildFullPath(n.baseURL,n.url);p.open(n.method.toUpperCase(),buildURL(_,n.params,n.paramsSerializer),!0),p.timeout=n.timeout;function y(){if(!p)return;const v=AxiosHeaders$1.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),x={data:!o||o==="text"||o==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:v,config:n,request:p};settle(function($){e($),d()},function($){i($),d()},x),p=null}if("onloadend"in p?p.onloadend=y:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(y)},p.onabort=function(){p&&(i(new AxiosError("Request aborted",AxiosError.ECONNABORTED,n,p)),p=null)},p.onerror=function(){i(new AxiosError("Network Error",AxiosError.ERR_NETWORK,n,p)),p=null},p.ontimeout=function(){let P=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const x=n.transitional||transitionalDefaults;n.timeoutErrorMessage&&(P=n.timeoutErrorMessage),i(new AxiosError(P,x.clarifyTimeoutError?AxiosError.ETIMEDOUT:AxiosError.ECONNABORTED,n,p)),p=null},platform.hasStandardBrowserEnv&&(l&&utils$1.isFunction(l)&&(l=l(n)),l||l!==!1&&isURLSameOrigin(_))){const v=n.xsrfHeaderName&&n.xsrfCookieName&&cookies.read(n.xsrfCookieName);v&&a.set(n.xsrfHeaderName,v)}r===void 0&&a.setContentType(null),"setRequestHeader"in p&&utils$1.forEach(a.toJSON(),function(P,x){p.setRequestHeader(x,P)}),utils$1.isUndefined(n.withCredentials)||(p.withCredentials=!!n.withCredentials),o&&o!=="json"&&(p.responseType=n.responseType),typeof n.onDownloadProgress=="function"&&p.addEventListener("progress",progressEventReducer(n.onDownloadProgress,!0)),typeof n.onUploadProgress=="function"&&p.upload&&p.upload.addEventListener("progress",progressEventReducer(n.onUploadProgress)),(n.cancelToken||n.signal)&&(u=v=>{p&&(i(!v||v.type?new CanceledError(null,n,p):v),p.abort(),p=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));const w=parseProtocol(_);if(w&&platform.protocols.indexOf(w)===-1){i(new AxiosError("Unsupported protocol "+w+":",AxiosError.ERR_BAD_REQUEST,n));return}p.send(r||null)})},knownAdapters={http:httpAdapter,xhr:xhrAdapter};utils$1.forEach(knownAdapters,(n,t)=>{if(n){try{Object.defineProperty(n,"name",{value:t})}catch{}Object.defineProperty(n,"adapterName",{value:t})}});const renderReason=n=>`- ${n}`,isResolvedHandle=n=>utils$1.isFunction(n)||n===null||n===!1,adapters$1={getAdapter:n=>{n=utils$1.isArray(n)?n:[n];const{length:t}=n;let e,i;const r={};for(let a=0;a`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=t?a.length>1?`since : +`+a.map(renderReason).join(` +`):" "+renderReason(a[0]):"as no adapter specified";throw new AxiosError("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return i},adapters:knownAdapters};function throwIfCancellationRequested(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new CanceledError(null,n)}function dispatchRequest(n){return throwIfCancellationRequested(n),n.headers=AxiosHeaders$1.from(n.headers),n.data=transformData.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),adapters$1.getAdapter(n.adapter||defaults$4.adapter)(n).then(function(i){return throwIfCancellationRequested(n),i.data=transformData.call(n,n.transformResponse,i),i.headers=AxiosHeaders$1.from(i.headers),i},function(i){return isCancel(i)||(throwIfCancellationRequested(n),i&&i.response&&(i.response.data=transformData.call(n,n.transformResponse,i.response),i.response.headers=AxiosHeaders$1.from(i.response.headers))),Promise.reject(i)})}const headersToObject=n=>n instanceof AxiosHeaders$1?n.toJSON():n;function mergeConfig(n,t){t=t||{};const e={};function i(d,m,p){return utils$1.isPlainObject(d)&&utils$1.isPlainObject(m)?utils$1.merge.call({caseless:p},d,m):utils$1.isPlainObject(m)?utils$1.merge({},m):utils$1.isArray(m)?m.slice():m}function r(d,m,p){if(utils$1.isUndefined(m)){if(!utils$1.isUndefined(d))return i(void 0,d,p)}else return i(d,m,p)}function a(d,m){if(!utils$1.isUndefined(m))return i(void 0,m)}function o(d,m){if(utils$1.isUndefined(m)){if(!utils$1.isUndefined(d))return i(void 0,d)}else return i(void 0,m)}function l(d,m,p){if(p in t)return i(d,m);if(p in n)return i(void 0,d)}const u={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken: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:l,headers:(d,m)=>r(headersToObject(d),headersToObject(m),!0)};return utils$1.forEach(Object.keys(Object.assign({},n,t)),function(m){const p=u[m]||r,_=p(n[m],t[m],m);utils$1.isUndefined(_)&&p!==l||(e[m]=_)}),e}const VERSION$1="1.6.7",validators$1={};["object","boolean","number","function","string","symbol"].forEach((n,t)=>{validators$1[n]=function(i){return typeof i===n||"a"+(t<1?"n ":" ")+n}});const deprecatedWarnings={};validators$1.transitional=function(t,e,i){function r(a,o){return"[Axios v"+VERSION$1+"] Transitional option '"+a+"'"+o+(i?". "+i:"")}return(a,o,l)=>{if(t===!1)throw new AxiosError(r(o," has been removed"+(e?" in "+e:"")),AxiosError.ERR_DEPRECATED);return e&&!deprecatedWarnings[o]&&(deprecatedWarnings[o]=!0,console.warn(r(o," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(a,o,l):!0}};function assertOptions(n,t,e){if(typeof n!="object")throw new AxiosError("options must be an object",AxiosError.ERR_BAD_OPTION_VALUE);const i=Object.keys(n);let r=i.length;for(;r-- >0;){const a=i[r],o=t[a];if(o){const l=n[a],u=l===void 0||o(l,a,n);if(u!==!0)throw new AxiosError("option "+a+" must be "+u,AxiosError.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new AxiosError("Unknown option "+a,AxiosError.ERR_BAD_OPTION)}}const validator={assertOptions,validators:validators$1},validators=validator.validators;class Axios{constructor(t){this.defaults=t,this.interceptors={request:new InterceptorManager$1,response:new InterceptorManager$1}}async request(t,e){try{return await this._request(t,e)}catch(i){if(i instanceof Error){let r;Error.captureStackTrace?Error.captureStackTrace(r={}):r=new Error;const a=r.stack?r.stack.replace(/^.+\n/,""):"";i.stack?a&&!String(i.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(i.stack+=` +`+a):i.stack=a}throw i}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=mergeConfig(this.defaults,e);const{transitional:i,paramsSerializer:r,headers:a}=e;i!==void 0&&validator.assertOptions(i,{silentJSONParsing:validators.transitional(validators.boolean),forcedJSONParsing:validators.transitional(validators.boolean),clarifyTimeoutError:validators.transitional(validators.boolean)},!1),r!=null&&(utils$1.isFunction(r)?e.paramsSerializer={serialize:r}:validator.assertOptions(r,{encode:validators.function,serialize:validators.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let o=a&&utils$1.merge(a.common,a[e.method]);a&&utils$1.forEach(["delete","get","head","post","put","patch","common"],w=>{delete a[w]}),e.headers=AxiosHeaders$1.concat(o,a);const l=[];let u=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(e)===!1||(u=u&&v.synchronous,l.unshift(v.fulfilled,v.rejected))});const d=[];this.interceptors.response.forEach(function(v){d.push(v.fulfilled,v.rejected)});let m,p=0,_;if(!u){const w=[dispatchRequest.bind(this),void 0];for(w.unshift.apply(w,l),w.push.apply(w,d),_=w.length,m=Promise.resolve(e);p<_;)m=m.then(w[p++],w[p++]);return m}_=l.length;let y=e;for(p=0;p<_;){const w=l[p++],v=l[p++];try{y=w(y)}catch(P){v.call(this,P);break}}try{m=dispatchRequest.call(this,y)}catch(w){return Promise.reject(w)}for(p=0,_=d.length;p<_;)m=m.then(d[p++],d[p++]);return m}getUri(t){t=mergeConfig(this.defaults,t);const e=buildFullPath(t.baseURL,t.url);return buildURL(e,t.params,t.paramsSerializer)}}utils$1.forEach(["delete","get","head","options"],function(t){Axios.prototype[t]=function(e,i){return this.request(mergeConfig(i||{},{method:t,url:e,data:(i||{}).data}))}});utils$1.forEach(["post","put","patch"],function(t){function e(i){return function(a,o,l){return this.request(mergeConfig(l||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:a,data:o}))}}Axios.prototype[t]=e(),Axios.prototype[t+"Form"]=e(!0)});const Axios$1=Axios;class CancelToken{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(a){e=a});const i=this;this.promise.then(r=>{if(!i._listeners)return;let a=i._listeners.length;for(;a-- >0;)i._listeners[a](r);i._listeners=null}),this.promise.then=r=>{let a;const o=new Promise(l=>{i.subscribe(l),a=l}).then(r);return o.cancel=function(){i.unsubscribe(a)},o},t(function(a,o,l){i.reason||(i.reason=new CanceledError(a,o,l),e(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new CancelToken(function(r){t=r}),cancel:t}}}const CancelToken$1=CancelToken;function spread(n){return function(e){return n.apply(null,e)}}function isAxiosError(n){return utils$1.isObject(n)&&n.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(([n,t])=>{HttpStatusCode[t]=n});const HttpStatusCode$1=HttpStatusCode;function createInstance(n){const t=new Axios$1(n),e=bind$4(Axios$1.prototype.request,t);return utils$1.extend(e,Axios$1.prototype,t,{allOwnKeys:!0}),utils$1.extend(e,t,null,{allOwnKeys:!0}),e.create=function(r){return createInstance(mergeConfig(n,r))},e}const axios=createInstance(defaults$4);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(t){return Promise.all(t)};axios.spread=spread;axios.isAxiosError=isAxiosError;axios.mergeConfig=mergeConfig;axios.AxiosHeaders=AxiosHeaders$1;axios.formToJSON=n=>formDataToJSON(utils$1.isHTMLForm(n)?new FormData(n):n);axios.getAdapter=adapters$1.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(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}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$4,each:each$b,map:map$2,pluck:pluck$1,isList:isList$1,isFunction:isFunction$2,isObject:isObject$3,Global:Global$5};function make_assign(){return Object.assign?Object.assign:function(t,e,i,r){for(var a=1;a"u"?null:console;if(n){var t=n.warn?n.warn:n.log;t.apply(n,arguments)}}function createStore(n,t,e){e||(e=""),n&&!isList(n)&&(n=[n]),t&&!isList(t)&&(t=[t]);var i=e?"__storejs_"+e+"_":"",r=e?new RegExp("^"+i):null,a=/^[a-zA-Z0-9_\-]*$/;if(!a.test(e))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var o={_namespacePrefix:i,_namespaceRegexp:r,_testStorage:function(u){try{var d="__storejs__test__";u.write(d,d);var m=u.read(d)===d;return u.remove(d),m}catch{return!1}},_assignPluginFnProp:function(u,d){var m=this[d];this[d]=function(){var _=slice$3(arguments,0),y=this;function w(){if(m)return each$a(arguments,function(P,x){_[x]=P}),m.apply(y,_)}var v=[w].concat(_);return u.apply(y,v)}},_serialize:function(u){return JSON.stringify(u)},_deserialize:function(u,d){if(!u)return d;var m="";try{m=JSON.parse(u)}catch{m=u}return m!==void 0?m:d},_addStorage:function(u){this.enabled||this._testStorage(u)&&(this.storage=u,this.enabled=!0)},_addPlugin:function(u){var d=this;if(isList(u)){each$a(u,function(_){d._addPlugin(_)});return}var m=pluck(this.plugins,function(_){return u===_});if(!m){if(this.plugins.push(u),!isFunction$1(u))throw new Error("Plugins must be function values that return objects");var p=u.call(this);if(!isObject$2(p))throw new Error("Plugins must return an object of function properties");each$a(p,function(_,y){if(!isFunction$1(_))throw new Error("Bad plugin property: "+y+" from plugin "+u.name+". Plugins should only return functions.");d._assignPluginFnProp(_,y)})}},addStorage:function(u){_warn("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(u)}},l=create$1(o,storeAPI,{plugins:[]});return l.raw={},each$a(l,function(u,d){isFunction$1(u)&&(l.raw[d]=bind$2(l,u))}),each$a(n,function(u){l._addStorage(u)}),each$a(t,function(u){l._addPlugin(u)}),l}var util$5=util$7,Global$4=util$5.Global,localStorage_1={name:"localStorage",read:read$6,write:write$6,each:each$9,remove:remove$5,clearAll:clearAll$5};function localStorage(){return Global$4.localStorage}function read$6(n){return localStorage().getItem(n)}function write$6(n,t){return localStorage().setItem(n,t)}function each$9(n){for(var t=localStorage().length-1;t>=0;t--){var e=localStorage().key(t);n(read$6(e),e)}}function remove$5(n){return localStorage().removeItem(n)}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$8,remove:remove$4,clearAll:clearAll$4},globalStorage=Global$3.globalStorage;function read$5(n){return globalStorage[n]}function write$5(n,t){globalStorage[n]=t}function each$8(n){for(var t=globalStorage.length-1;t>=0;t--){var e=globalStorage.key(t);n(globalStorage[e],e)}}function remove$4(n){return globalStorage.removeItem(n)}function clearAll$4(){each$8(function(n,t){delete globalStorage[n]})}var util$3=util$7,Global$2=util$3.Global,oldIEUserDataStorage={name:"oldIE-userDataStorage",write:write$4,read:read$4,each:each$7,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(n,t){if(!disable){var e=fixKey(n);_withStorageEl(function(i){i.setAttribute(e,t),i.save(storageName)})}}function read$4(n){if(!disable){var t=fixKey(n),e=null;return _withStorageEl(function(i){e=i.getAttribute(t)}),e}}function each$7(n){_withStorageEl(function(t){for(var e=t.XMLDocument.documentElement.attributes,i=e.length-1;i>=0;i--){var r=e[i];n(t.getAttribute(r.name),r.name)}})}function remove$3(n){var t=fixKey(n);_withStorageEl(function(e){e.removeAttribute(t),e.save(storageName)})}function clearAll$3(){_withStorageEl(function(n){var t=n.XMLDocument.documentElement.attributes;n.load(storageName);for(var e=t.length-1;e>=0;e--)n.removeAttribute(t[e].name);n.save(storageName)})}var forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function fixKey(n){return n.replace(/^\d/,"___$&").replace(forbiddenCharsRegex,"___")}function _makeIEStorageElFunction(){if(!doc$1||!doc$1.documentElement||!doc$1.documentElement.addBehavior)return null;var n="script",t,e,i;try{e=new ActiveXObject("htmlfile"),e.open(),e.write("<"+n+">document.w=window'),e.close(),t=e.w.frames[0].document,i=t.createElement("div")}catch{i=doc$1.createElement("div"),t=doc$1.body}return function(r){var a=[].slice.call(arguments,0);a.unshift(i),t.appendChild(i),i.addBehavior("#default#userData"),i.load(storageName),r.apply(this,a),t.removeChild(i)}}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$6,remove:remove$2,clearAll:clearAll$2},doc=Global$1.document;function read$3(n){if(!n||!_has(n))return null;var t="(?:^|.*;\\s*)"+escape(n).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(doc.cookie.replace(new RegExp(t),"$1"))}function each$6(n){for(var t=doc.cookie.split(/; ?/g),e=t.length-1;e>=0;e--)if(trim(t[e])){var i=t[e].split("="),r=unescape(i[0]),a=unescape(i[1]);n(a,r)}}function write$3(n,t){n&&(doc.cookie=escape(n)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/")}function remove$2(n){!n||!_has(n)||(doc.cookie=escape(n)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function clearAll$2(){each$6(function(n,t){remove$2(t)})}function _has(n){return new RegExp("(?:^|;\\s*)"+escape(n).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$5,remove:remove$1,clearAll:clearAll$1};function sessionStorage(){return Global.sessionStorage}function read$2(n){return sessionStorage().getItem(n)}function write$2(n,t){return sessionStorage().setItem(n,t)}function each$5(n){for(var t=sessionStorage().length-1;t>=0;t--){var e=sessionStorage().key(t);n(read$2(e),e)}}function remove$1(n){return sessionStorage().removeItem(n)}function clearAll$1(){return sessionStorage().clear()}var memoryStorage_1={name:"memoryStorage",read:read$1,write:write$1,each:each$4,remove,clearAll},memoryStorage={};function read$1(n){return memoryStorage[n]}function write$1(n,t){memoryStorage[n]=t}function each$4(n){for(var t in memoryStorage)memoryStorage.hasOwnProperty(t)&&n(memoryStorage[t],t)}function remove(n){delete memoryStorage[n]}function clearAll(n){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(n){return n<10?"0"+n:n}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(n){return rx_escapable.lastIndex=0,rx_escapable.test(n)?'"'+n.replace(rx_escapable,function(t){var e=meta[t];return typeof e=="string"?e:"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+n+'"'}function str(n,t){var e,i,r,a,o=gap,l,u=t[n];switch(u&&typeof u=="object"&&typeof u.toJSON=="function"&&(u=u.toJSON(n)),typeof rep=="function"&&(u=rep.call(t,n,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,l=[],Object.prototype.toString.apply(u)==="[object Array]"){for(a=u.length,e=0;elastFlushedIndex&&queue.splice(t,1)}function queueFlush(){!flushing&&!flushPending&&(flushPending=!0,queueMicrotask(flushJobs))}function flushJobs(){flushPending=!1,flushing=!0;for(let n=0;nn.effect(t,{scheduler:e=>{shouldSchedule?scheduler(e):e()}}),raw=n.raw}function overrideEffect(n){effect$3=n}function elementBoundEffect(n){let t=()=>{};return[i=>{let r=effect$3(i);return n._x_effects||(n._x_effects=new Set,n._x_runEffects=()=>{n._x_effects.forEach(a=>a())}),n._x_effects.add(r),t=()=>{r!==void 0&&(n._x_effects.delete(r),release(r))},r},()=>{t()}]}function watch(n,t){let e=!0,i,r=effect$3(()=>{let a=n();JSON.stringify(a),e?i=a:queueMicrotask(()=>{t(a,i),i=a}),e=!1});return()=>release(r)}function dispatch(n,t,e={}){n.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0,cancelable:!0}))}function walk(n,t){if(typeof ShadowRoot=="function"&&n instanceof ShadowRoot){Array.from(n.children).forEach(r=>walk(r,t));return}let e=!1;if(t(n,()=>e=!0),e)return;let i=n.firstElementChild;for(;i;)walk(i,t),i=i.nextElementSibling}function warn(n,...t){console.warn(`Alpine Warning: ${n}`,...t)}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 `