@rfc0/patty 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +214 -2
  3. package/dist/adapters/access-tokens.js +7 -0
  4. package/dist/adapters/accounts.js +37 -0
  5. package/dist/adapters/auth.js +11 -0
  6. package/dist/adapters/bills.js +32 -0
  7. package/dist/adapters/budgets.js +29 -0
  8. package/dist/adapters/categories.js +32 -0
  9. package/dist/adapters/client-grants.js +7 -0
  10. package/dist/adapters/credit-cards.js +33 -0
  11. package/dist/adapters/currencies.js +2 -0
  12. package/dist/adapters/currency-rates.js +18 -0
  13. package/dist/adapters/dashboards.js +43 -0
  14. package/dist/adapters/demo.js +13 -0
  15. package/dist/adapters/instance-settings.js +7 -0
  16. package/dist/adapters/invites.js +7 -0
  17. package/dist/adapters/recurring.js +55 -0
  18. package/dist/adapters/sessions.js +7 -0
  19. package/dist/adapters/settings.js +4 -0
  20. package/dist/adapters/setup-codes.js +7 -0
  21. package/dist/adapters/tags.js +9 -0
  22. package/dist/adapters/transactions.js +95 -0
  23. package/dist/adapters/users.js +7 -0
  24. package/dist/common/build-version.js +5 -0
  25. package/dist/common/errors.js +118 -0
  26. package/dist/common/net.js +71 -0
  27. package/dist/common/result.js +7 -0
  28. package/dist/composition/auth.js +106 -0
  29. package/dist/composition/boot.js +27 -0
  30. package/dist/composition/cli.js +86 -0
  31. package/dist/composition/demo/seed.js +92 -0
  32. package/dist/composition/demo/shell.js +107 -0
  33. package/dist/composition/export.js +89 -0
  34. package/dist/composition/http.js +110 -0
  35. package/dist/composition/import.js +55 -0
  36. package/dist/composition/lazy-modules.js +2 -0
  37. package/dist/composition/runtime.js +115 -0
  38. package/dist/composition/sign-in/interpreter.js +154 -0
  39. package/dist/composition/sign-in/server.js +36 -0
  40. package/dist/composition/sign-in/wiring.js +23 -0
  41. package/dist/composition/stdio.js +69 -0
  42. package/dist/config.js +136 -0
  43. package/dist/controllers/account/account.js +88 -0
  44. package/dist/controllers/account/transaction.js +119 -0
  45. package/dist/controllers/account/transfer.js +34 -0
  46. package/dist/controllers/aggregate.js +40 -0
  47. package/dist/controllers/auth/access-tokens.js +61 -0
  48. package/dist/controllers/auth/grants.js +136 -0
  49. package/dist/controllers/auth/key-export.js +20 -0
  50. package/dist/controllers/auth/owner.js +80 -0
  51. package/dist/controllers/auth/password.js +35 -0
  52. package/dist/controllers/auth/session.js +50 -0
  53. package/dist/controllers/auth/step-up.js +8 -0
  54. package/dist/controllers/auth/users.js +183 -0
  55. package/dist/controllers/budgets.js +87 -0
  56. package/dist/controllers/categories.js +67 -0
  57. package/dist/controllers/correlations.js +112 -0
  58. package/dist/controllers/credit-card/bill.js +105 -0
  59. package/dist/controllers/credit-card/credit-card.js +129 -0
  60. package/dist/controllers/credit-card/transaction.js +181 -0
  61. package/dist/controllers/currencies.js +1 -0
  62. package/dist/controllers/currency-rates.js +40 -0
  63. package/dist/controllers/dashboards.js +68 -0
  64. package/dist/controllers/demo/seed.js +31 -0
  65. package/dist/controllers/demo/tour.js +12 -0
  66. package/dist/controllers/deps.js +6 -0
  67. package/dist/controllers/instance.js +6 -0
  68. package/dist/controllers/merchants.js +12 -0
  69. package/dist/controllers/recurring.js +70 -0
  70. package/dist/controllers/resolve.js +37 -0
  71. package/dist/controllers/settings.js +47 -0
  72. package/dist/controllers/status.js +19 -0
  73. package/dist/controllers/summary.js +21 -0
  74. package/dist/controllers/tags.js +19 -0
  75. package/dist/controllers/transaction/bulk.js +6 -0
  76. package/dist/controllers/transaction/core.js +49 -0
  77. package/dist/controllers/transaction/read.js +28 -0
  78. package/dist/diplomat/auth/credentials.js +58 -0
  79. package/dist/diplomat/auth/sign-in-store.js +18 -0
  80. package/dist/diplomat/cli/commands/auth.js +100 -0
  81. package/dist/diplomat/cli/commands/db.js +72 -0
  82. package/dist/diplomat/cli/commands/demo.js +68 -0
  83. package/dist/diplomat/cli/commands/key.js +119 -0
  84. package/dist/diplomat/cli/commands/login.js +151 -0
  85. package/dist/diplomat/cli/commands/setup.js +132 -0
  86. package/dist/diplomat/cli/commands/users.js +123 -0
  87. package/dist/diplomat/cli/commands.js +61 -0
  88. package/dist/diplomat/cli/export-file.js +37 -0
  89. package/dist/diplomat/cli/import-file.js +44 -0
  90. package/dist/diplomat/cli/io.js +61 -0
  91. package/dist/diplomat/cli/key-export-approval.js +37 -0
  92. package/dist/diplomat/cli/messages.js +96 -0
  93. package/dist/diplomat/cli/prompt.js +74 -0
  94. package/dist/diplomat/cli/terminal.js +81 -0
  95. package/dist/diplomat/client-config/clients.js +150 -0
  96. package/dist/diplomat/client-config/merge.js +41 -0
  97. package/dist/diplomat/db/bootstrap.js +98 -0
  98. package/dist/diplomat/db/database-files.js +147 -0
  99. package/dist/diplomat/db/driver.js +167 -0
  100. package/dist/diplomat/db/effects.js +101 -0
  101. package/dist/diplomat/db/engine.js +9 -0
  102. package/dist/diplomat/db/export.js +22 -0
  103. package/dist/diplomat/db/file-lock.js +82 -0
  104. package/dist/diplomat/db/key-lock.js +14 -0
  105. package/dist/diplomat/db/locale-cache.js +23 -0
  106. package/dist/diplomat/db/migration-barrier.js +57 -0
  107. package/dist/diplomat/db/migration-journal.js +18 -0
  108. package/dist/diplomat/db/migration-lock.js +15 -0
  109. package/dist/diplomat/db/migrations.js +11 -0
  110. package/dist/diplomat/db/present.js +17 -0
  111. package/dist/diplomat/db/queries/aggregate-whitelist.js +35 -0
  112. package/dist/diplomat/db/queries/filters.js +59 -0
  113. package/dist/diplomat/db/queries/fts.js +18 -0
  114. package/dist/diplomat/db/queries/scope.js +8 -0
  115. package/dist/diplomat/db/queries/transaction-select.js +26 -0
  116. package/dist/diplomat/db/queries/tx-predicates.js +13 -0
  117. package/dist/diplomat/db/repos/access-tokens.js +27 -0
  118. package/dist/diplomat/db/repos/accounts.js +91 -0
  119. package/dist/diplomat/db/repos/bills.js +93 -0
  120. package/dist/diplomat/db/repos/budgets.js +72 -0
  121. package/dist/diplomat/db/repos/categories.js +53 -0
  122. package/dist/diplomat/db/repos/client-grants.js +67 -0
  123. package/dist/diplomat/db/repos/correlations.js +66 -0
  124. package/dist/diplomat/db/repos/credit-cards.js +67 -0
  125. package/dist/diplomat/db/repos/currencies.js +8 -0
  126. package/dist/diplomat/db/repos/currency-rates.js +40 -0
  127. package/dist/diplomat/db/repos/dashboards.js +123 -0
  128. package/dist/diplomat/db/repos/health.js +12 -0
  129. package/dist/diplomat/db/repos/instance-settings.js +14 -0
  130. package/dist/diplomat/db/repos/instance.js +58 -0
  131. package/dist/diplomat/db/repos/invites.js +43 -0
  132. package/dist/diplomat/db/repos/merchants.js +121 -0
  133. package/dist/diplomat/db/repos/recurring.js +29 -0
  134. package/dist/diplomat/db/repos/sessions.js +19 -0
  135. package/dist/diplomat/db/repos/settings.js +41 -0
  136. package/dist/diplomat/db/repos/setup-codes.js +28 -0
  137. package/dist/diplomat/db/repos/sub-categories.js +67 -0
  138. package/dist/diplomat/db/repos/tags.js +51 -0
  139. package/dist/diplomat/db/repos/transaction-tags.js +57 -0
  140. package/dist/diplomat/db/repos/transactions.js +163 -0
  141. package/dist/diplomat/db/repos/users.js +47 -0
  142. package/dist/diplomat/db/safety-copy.js +87 -0
  143. package/dist/diplomat/db/schema.js +348 -0
  144. package/dist/diplomat/db/seed/categories.js +112 -0
  145. package/dist/diplomat/db/seed/currencies.js +9 -0
  146. package/dist/diplomat/db/seed/demo/br.js +98 -0
  147. package/dist/diplomat/db/seed/demo/co.js +89 -0
  148. package/dist/diplomat/db/seed/demo/index.js +12 -0
  149. package/dist/diplomat/db/seed/demo/mx.js +90 -0
  150. package/dist/diplomat/db/seed/demo/shared.js +39 -0
  151. package/dist/diplomat/db/seed/demo/us.js +90 -0
  152. package/dist/diplomat/db/seed/merchant-rules.js +188 -0
  153. package/dist/diplomat/db/sqlite-errors.js +40 -0
  154. package/dist/diplomat/db/tenancy-integrity.js +45 -0
  155. package/dist/diplomat/db/version-guard.js +16 -0
  156. package/dist/diplomat/http/auth-pages.js +41 -0
  157. package/dist/diplomat/http/auth-paths.js +46 -0
  158. package/dist/diplomat/http/bearer.js +15 -0
  159. package/dist/diplomat/http/connect-pages.js +51 -0
  160. package/dist/diplomat/http/context.js +17 -0
  161. package/dist/diplomat/http/cookies.js +27 -0
  162. package/dist/diplomat/http/form-pages.js +38 -0
  163. package/dist/diplomat/http/hooks/auth.js +106 -0
  164. package/dist/diplomat/http/hooks/demo-marker.js +59 -0
  165. package/dist/diplomat/http/openapi.js +73 -0
  166. package/dist/diplomat/http/principal.js +1 -0
  167. package/dist/diplomat/http/rate-limiter.js +78 -0
  168. package/dist/diplomat/http/remedy.js +26 -0
  169. package/dist/diplomat/http/respond.js +50 -0
  170. package/dist/diplomat/http/routes/account.js +226 -0
  171. package/dist/diplomat/http/routes/aggregate.js +28 -0
  172. package/dist/diplomat/http/routes/auth.js +105 -0
  173. package/dist/diplomat/http/routes/budget.js +34 -0
  174. package/dist/diplomat/http/routes/category.js +109 -0
  175. package/dist/diplomat/http/routes/connect.js +124 -0
  176. package/dist/diplomat/http/routes/credit-card.js +263 -0
  177. package/dist/diplomat/http/routes/currency-rates.js +60 -0
  178. package/dist/diplomat/http/routes/currency.js +16 -0
  179. package/dist/diplomat/http/routes/dashboard.js +93 -0
  180. package/dist/diplomat/http/routes/invite.js +63 -0
  181. package/dist/diplomat/http/routes/recurring.js +65 -0
  182. package/dist/diplomat/http/routes/settings.js +38 -0
  183. package/dist/diplomat/http/routes/summary.js +23 -0
  184. package/dist/diplomat/http/routes/system.js +29 -0
  185. package/dist/diplomat/http/routes/tag.js +51 -0
  186. package/dist/diplomat/http/routes/tokens.js +72 -0
  187. package/dist/diplomat/http/routes/transaction.js +55 -0
  188. package/dist/diplomat/http/routes/transfer.js +35 -0
  189. package/dist/diplomat/http/routes/ui.js +110 -0
  190. package/dist/diplomat/http/routes/users.js +156 -0
  191. package/dist/diplomat/http/routes/well-known.js +26 -0
  192. package/dist/diplomat/http/routes.js +85 -0
  193. package/dist/diplomat/http/session.js +34 -0
  194. package/dist/diplomat/http/token-pages.js +75 -0
  195. package/dist/diplomat/http/ui-files.js +21 -0
  196. package/dist/diplomat/http/user-pages.js +93 -0
  197. package/dist/diplomat/mcp/annotations.js +8 -0
  198. package/dist/diplomat/mcp/auth-info.js +20 -0
  199. package/dist/diplomat/mcp/context.js +14 -0
  200. package/dist/diplomat/mcp/definition.js +3 -0
  201. package/dist/diplomat/mcp/gate.js +15 -0
  202. package/dist/diplomat/mcp/instructions.js +19 -0
  203. package/dist/diplomat/mcp/prompts.js +125 -0
  204. package/dist/diplomat/mcp/register.js +12 -0
  205. package/dist/diplomat/mcp/remedy.js +17 -0
  206. package/dist/diplomat/mcp/resources.js +93 -0
  207. package/dist/diplomat/mcp/respond.js +20 -0
  208. package/dist/diplomat/mcp/route.js +62 -0
  209. package/dist/diplomat/mcp/scopes.js +53 -0
  210. package/dist/diplomat/mcp/server.js +26 -0
  211. package/dist/diplomat/mcp/shared.js +5 -0
  212. package/dist/diplomat/mcp/stdio-session.js +94 -0
  213. package/dist/diplomat/mcp/stdio.js +23 -0
  214. package/dist/diplomat/mcp/tool-name.js +59 -0
  215. package/dist/diplomat/mcp/tools/account.js +218 -0
  216. package/dist/diplomat/mcp/tools/aggregate.js +32 -0
  217. package/dist/diplomat/mcp/tools/budget.js +99 -0
  218. package/dist/diplomat/mcp/tools/category.js +103 -0
  219. package/dist/diplomat/mcp/tools/correlations.js +70 -0
  220. package/dist/diplomat/mcp/tools/credit-card.js +239 -0
  221. package/dist/diplomat/mcp/tools/currency-rates.js +62 -0
  222. package/dist/diplomat/mcp/tools/dashboard.js +75 -0
  223. package/dist/diplomat/mcp/tools/index.js +31 -0
  224. package/dist/diplomat/mcp/tools/recurring.js +62 -0
  225. package/dist/diplomat/mcp/tools/summary.js +30 -0
  226. package/dist/diplomat/mcp/tools/system.js +83 -0
  227. package/dist/diplomat/mcp/tools/tag.js +48 -0
  228. package/dist/diplomat/mcp/tools/transaction.js +53 -0
  229. package/dist/diplomat/mcp/tools/transfer.js +28 -0
  230. package/dist/diplomat/mcp/tour.js +87 -0
  231. package/dist/logic/account.js +79 -0
  232. package/dist/logic/aggregate.js +37 -0
  233. package/dist/logic/auth/bearer.js +35 -0
  234. package/dist/logic/auth/grant.js +126 -0
  235. package/dist/logic/auth/key-export.js +10 -0
  236. package/dist/logic/auth/keychain.js +3 -0
  237. package/dist/logic/auth/message.js +22 -0
  238. package/dist/logic/auth/origin.js +57 -0
  239. package/dist/logic/auth/owner.js +22 -0
  240. package/dist/logic/auth/password.js +3 -0
  241. package/dist/logic/auth/redact.js +25 -0
  242. package/dist/logic/auth/revoke.js +28 -0
  243. package/dist/logic/auth/scope.js +17 -0
  244. package/dist/logic/auth/session.js +30 -0
  245. package/dist/logic/auth/sign-in-flow.js +305 -0
  246. package/dist/logic/auth/time.js +2 -0
  247. package/dist/logic/auth/token.js +74 -0
  248. package/dist/logic/auth/user-plans.js +84 -0
  249. package/dist/logic/auth/users.js +78 -0
  250. package/dist/logic/balance.js +2 -0
  251. package/dist/logic/bill.js +74 -0
  252. package/dist/logic/budget.js +78 -0
  253. package/dist/logic/category.js +37 -0
  254. package/dist/logic/classify.js +21 -0
  255. package/dist/logic/correlations.js +147 -0
  256. package/dist/logic/credit-card.js +2 -0
  257. package/dist/logic/currency-rate.js +69 -0
  258. package/dist/logic/dashboard.js +40 -0
  259. package/dist/logic/demo/database.js +30 -0
  260. package/dist/logic/demo/plan.js +308 -0
  261. package/dist/logic/demo/tour.js +33 -0
  262. package/dist/logic/export-destination.js +12 -0
  263. package/dist/logic/key-import.js +15 -0
  264. package/dist/logic/locale.js +5 -0
  265. package/dist/logic/localize.js +12 -0
  266. package/dist/logic/merchant.js +31 -0
  267. package/dist/logic/migration.js +1 -0
  268. package/dist/logic/money.js +12 -0
  269. package/dist/logic/period.js +45 -0
  270. package/dist/logic/persistence.js +48 -0
  271. package/dist/logic/recurring.js +51 -0
  272. package/dist/logic/resolve.js +44 -0
  273. package/dist/logic/summary.js +29 -0
  274. package/dist/logic/tag.js +13 -0
  275. package/dist/logic/transaction.js +197 -0
  276. package/dist/main.js +42 -0
  277. package/dist/models/account.js +197 -0
  278. package/dist/models/aggregate.js +61 -0
  279. package/dist/models/auth/bearer.js +11 -0
  280. package/dist/models/auth/entity.js +17 -0
  281. package/dist/models/auth/errors.js +42 -0
  282. package/dist/models/auth/grant.js +58 -0
  283. package/dist/models/auth/key-export.js +11 -0
  284. package/dist/models/auth/message.js +50 -0
  285. package/dist/models/auth/mode.js +7 -0
  286. package/dist/models/auth/origin.js +16 -0
  287. package/dist/models/auth/owner.js +36 -0
  288. package/dist/models/auth/password.js +24 -0
  289. package/dist/models/auth/principal.js +26 -0
  290. package/dist/models/auth/redact.js +4 -0
  291. package/dist/models/auth/scope.js +9 -0
  292. package/dist/models/auth/session.js +19 -0
  293. package/dist/models/auth/sign-in-flow.js +102 -0
  294. package/dist/models/auth/sign-in.js +41 -0
  295. package/dist/models/auth/time.js +5 -0
  296. package/dist/models/auth/token.js +50 -0
  297. package/dist/models/auth/users.js +52 -0
  298. package/dist/models/bill.js +55 -0
  299. package/dist/models/budget.js +106 -0
  300. package/dist/models/category.js +52 -0
  301. package/dist/models/client-config.js +18 -0
  302. package/dist/models/correlations.js +215 -0
  303. package/dist/models/credit-card.js +156 -0
  304. package/dist/models/currency-rate.js +83 -0
  305. package/dist/models/dashboard.js +54 -0
  306. package/dist/models/database.js +16 -0
  307. package/dist/models/date.js +8 -0
  308. package/dist/models/demo/core.js +58 -0
  309. package/dist/models/demo/tour.js +41 -0
  310. package/dist/models/encryption-key.js +2 -0
  311. package/dist/models/error.js +13 -0
  312. package/dist/models/export.js +9 -0
  313. package/dist/models/id.js +2 -0
  314. package/dist/models/instance.js +7 -0
  315. package/dist/models/key-import.js +6 -0
  316. package/dist/models/locale.js +25 -0
  317. package/dist/models/merchant.js +12 -0
  318. package/dist/models/money.js +14 -0
  319. package/dist/models/package.js +12 -0
  320. package/dist/models/page.js +56 -0
  321. package/dist/models/persistence.js +1 -0
  322. package/dist/models/prompts.js +5 -0
  323. package/dist/models/recurring.js +54 -0
  324. package/dist/models/remedy.js +17 -0
  325. package/dist/models/resolution.js +1 -0
  326. package/dist/models/startup.js +7 -0
  327. package/dist/models/summary.js +24 -0
  328. package/dist/models/tag.js +14 -0
  329. package/dist/models/tenancy.js +10 -0
  330. package/dist/models/transaction-tag.js +6 -0
  331. package/dist/models/transaction.js +275 -0
  332. package/dist/wire/db/access-tokens.js +1 -0
  333. package/dist/wire/db/accounts.js +7 -0
  334. package/dist/wire/db/aggregate.js +16 -0
  335. package/dist/wire/db/bills.js +14 -0
  336. package/dist/wire/db/budgets.js +33 -0
  337. package/dist/wire/db/categories.js +14 -0
  338. package/dist/wire/db/client-grants.js +1 -0
  339. package/dist/wire/db/correlations.js +49 -0
  340. package/dist/wire/db/credit-cards.js +1 -0
  341. package/dist/wire/db/currencies.js +1 -0
  342. package/dist/wire/db/currency-rates.js +1 -0
  343. package/dist/wire/db/dashboards.js +1 -0
  344. package/dist/wire/db/instance-settings.js +1 -0
  345. package/dist/wire/db/invites.js +1 -0
  346. package/dist/wire/db/merchants.js +18 -0
  347. package/dist/wire/db/recurring.js +19 -0
  348. package/dist/wire/db/sessions.js +1 -0
  349. package/dist/wire/db/settings.js +1 -0
  350. package/dist/wire/db/setup-codes.js +1 -0
  351. package/dist/wire/db/tags.js +1 -0
  352. package/dist/wire/db/tenancy.js +1 -0
  353. package/dist/wire/db/transactions.js +89 -0
  354. package/dist/wire/db/users.js +1 -0
  355. package/dist/wire/in/accounts.js +26 -0
  356. package/dist/wire/in/aggregate.js +10 -0
  357. package/dist/wire/in/auth.js +107 -0
  358. package/dist/wire/in/bills.js +11 -0
  359. package/dist/wire/in/budgets.js +11 -0
  360. package/dist/wire/in/categories.js +9 -0
  361. package/dist/wire/in/cli.js +106 -0
  362. package/dist/wire/in/coerce.js +6 -0
  363. package/dist/wire/in/common.js +17 -0
  364. package/dist/wire/in/credit-cards.js +16 -0
  365. package/dist/wire/in/currency-rates.js +8 -0
  366. package/dist/wire/in/period.js +7 -0
  367. package/dist/wire/in/recurring.js +6 -0
  368. package/dist/wire/in/settings.js +5 -0
  369. package/dist/wire/in/summary.js +5 -0
  370. package/dist/wire/in/tags.js +2 -0
  371. package/dist/wire/in/transactions.js +31 -0
  372. package/dist/wire/out/bills.js +9 -0
  373. package/dist/wire/out/budgets.js +10 -0
  374. package/dist/wire/out/client-config.js +2 -0
  375. package/dist/wire/out/common.js +4 -0
  376. package/dist/wire/out/credit-cards.js +15 -0
  377. package/dist/wire/out/currency-rates.js +11 -0
  378. package/dist/wire/out/errors.js +58 -0
  379. package/dist/wire/out/recurring.js +6 -0
  380. package/dist/wire/out/status.js +10 -0
  381. package/dist/wire/out/summary.js +9 -0
  382. package/dist/wire/out/transactions.js +52 -0
  383. package/drizzle/0000_futuristic_umar.sql +124 -0
  384. package/drizzle/0001_fts5_search.sql +23 -0
  385. package/drizzle/0002_rename_graph_to_history.sql +7 -0
  386. package/drizzle/0003_lyrical_hairball.sql +2 -0
  387. package/drizzle/0004_misty_ikaris.sql +7 -0
  388. package/drizzle/0005_credit-liability-accounts.sql +14 -0
  389. package/drizzle/0006_smart_aqueduct.sql +1 -0
  390. package/drizzle/0007_add_dashboards.sql +5 -0
  391. package/drizzle/0008_yummy_madripoor.sql +1 -0
  392. package/drizzle/0009_version_groundwork.sql +9 -0
  393. package/drizzle/0010_category_merchant_association_cascade.sql +16 -0
  394. package/drizzle/0011_dashboard_id_normalization.sql +16 -0
  395. package/drizzle/0012_hot_the_spike.sql +12 -0
  396. package/drizzle/0013_recurring_rules_merchant.sql +1 -0
  397. package/drizzle/0014_dashboard_source_discriminator.sql +17 -0
  398. package/drizzle/0015_currencies_decimals.sql +1 -0
  399. package/drizzle/0016_unusual_zaran.sql +13 -0
  400. package/drizzle/0017_premium_blur.sql +1 -0
  401. package/drizzle/0018_auth_identity.sql +39 -0
  402. package/drizzle/0019_access_tokens.sql +16 -0
  403. package/drizzle/0020_stdio_sign_in.sql +27 -0
  404. package/drizzle/0021_tenancy_data.sql +289 -0
  405. package/drizzle/0022_user_management.sql +17 -0
  406. package/drizzle/0023_instance_settings_row.sql +2 -0
  407. package/drizzle/0024_credentials_changed_at.sql +2 -0
  408. package/drizzle/0025_instance_kind.sql +2 -0
  409. package/drizzle/0026_demo_seeded_at.sql +2 -0
  410. package/drizzle/0027_demo_country.sql +2 -0
  411. package/drizzle/0028_reset_sign_ins.sql +2 -0
  412. package/drizzle/meta/0000_snapshot.json +894 -0
  413. package/drizzle/meta/0003_snapshot.json +910 -0
  414. package/drizzle/meta/0004_snapshot.json +951 -0
  415. package/drizzle/meta/0005_snapshot.json +991 -0
  416. package/drizzle/meta/0006_snapshot.json +998 -0
  417. package/drizzle/meta/0007_snapshot.json +1029 -0
  418. package/drizzle/meta/0008_snapshot.json +1049 -0
  419. package/drizzle/meta/0009_snapshot.json +1121 -0
  420. package/drizzle/meta/0010_snapshot.json +1121 -0
  421. package/drizzle/meta/0011_snapshot.json +1136 -0
  422. package/drizzle/meta/0012_snapshot.json +1227 -0
  423. package/drizzle/meta/0013_snapshot.json +1247 -0
  424. package/drizzle/meta/0014_snapshot.json +1267 -0
  425. package/drizzle/meta/0015_snapshot.json +1275 -0
  426. package/drizzle/meta/0016_snapshot.json +1371 -0
  427. package/drizzle/meta/0017_snapshot.json +1392 -0
  428. package/drizzle/meta/0018_snapshot.json +1603 -0
  429. package/drizzle/meta/0019_snapshot.json +1713 -0
  430. package/drizzle/meta/0020_snapshot.json +1904 -0
  431. package/drizzle/meta/0021_snapshot.json +2186 -0
  432. package/drizzle/meta/0022_snapshot.json +2311 -0
  433. package/drizzle/meta/0023_snapshot.json +2311 -0
  434. package/drizzle/meta/0024_snapshot.json +2318 -0
  435. package/drizzle/meta/0025_snapshot.json +2326 -0
  436. package/drizzle/meta/0026_snapshot.json +2333 -0
  437. package/drizzle/meta/0027_snapshot.json +2340 -0
  438. package/drizzle/meta/0028_snapshot.json +2340 -0
  439. package/drizzle/meta/_journal.json +209 -0
  440. package/package.json +106 -4
  441. package/skills/dashboard-building/SKILL.md +201 -0
  442. package/skills/patty-tour/SKILL.md +34 -0
  443. package/ui/app.css +758 -0
  444. package/ui/app.js +493 -0
  445. package/ui/connect-result.html +16 -0
  446. package/ui/connect.html +53 -0
  447. package/ui/dashboards/accounts.html +3189 -0
  448. package/ui/dashboards/budget.html +1716 -0
  449. package/ui/dashboards/cards.html +4032 -0
  450. package/ui/dashboards/categories.html +4694 -0
  451. package/ui/dashboards/comparative.html +2464 -0
  452. package/ui/dashboards/dashboards.html +839 -0
  453. package/ui/dashboards/overview.html +2405 -0
  454. package/ui/dashboards/pending.html +2973 -0
  455. package/ui/dashboards/projections.html +2517 -0
  456. package/ui/dashboards/tags.html +1365 -0
  457. package/ui/invite.html +44 -0
  458. package/ui/login.html +26 -0
  459. package/ui/money.js +175 -0
  460. package/ui/setup.html +29 -0
  461. package/ui/shell.html +96 -0
  462. package/ui/token-created.html +24 -0
  463. package/ui/tokens.html +58 -0
  464. package/ui/user-invited.html +27 -0
  465. package/ui/users.html +60 -0
@@ -0,0 +1,1365 @@
1
+ <style>
2
+ /* Dashboard Panel Containers (base: ui/app.css, #164) */
3
+ .panel {
4
+ backdrop-filter: blur(20px);
5
+ -webkit-backdrop-filter: blur(20px);
6
+ border-radius: 20px;
7
+ padding: 1.75rem;
8
+ position: relative;
9
+ margin-bottom: 2rem;
10
+ overflow: hidden;
11
+ }
12
+
13
+ /* Loading Spinner Overlay (.loading-overlay/.spinner base: ui/app.css, #164) */
14
+ .loading-overlay {
15
+ right: 0; bottom: 0;
16
+ backdrop-filter: blur(5px);
17
+ opacity: 0;
18
+ pointer-events: none;
19
+ transition: opacity 0.3s ease;
20
+ }
21
+
22
+ .loading-overlay.active {
23
+ opacity: 1;
24
+ pointer-events: auto;
25
+ }
26
+
27
+ .spinner {
28
+ border: 3px solid rgba(255,255,255,0.05);
29
+ }
30
+
31
+ /* Shared Header Rows inside panels */
32
+ .panel-header-row {
33
+ display: flex;
34
+ justify-content: space-between;
35
+ align-items: center;
36
+ margin-bottom: 1.5rem;
37
+ border-bottom: 1px solid rgba(255,255,255,0.04);
38
+ padding-bottom: 1rem;
39
+ }
40
+
41
+ .panel-title {
42
+ font-size: 1.05rem;
43
+ font-weight: 700;
44
+ color: #fff;
45
+ display: flex;
46
+ align-items: center;
47
+ gap: 0.5rem;
48
+ }
49
+
50
+ .panel-title i {
51
+ color: var(--accent-primary);
52
+ }
53
+
54
+ /* Premium Buttons (base: ui/app.css, #164) */
55
+ .btn-action-primary {
56
+ border-radius: 8px;
57
+ padding: 0.5rem 1.25rem;
58
+ font-family: 'Plus Jakarta Sans', sans-serif;
59
+ font-size: 0.82rem;
60
+ font-weight: 700;
61
+ display: inline-flex;
62
+ box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
63
+ }
64
+
65
+ .btn-action-primary:hover {
66
+ background: var(--accent-secondary);
67
+ transform: translateY(-1px);
68
+ box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
69
+ }
70
+
71
+ /* Collapsible Form Styling */
72
+ .panel-form-inline {
73
+ background: rgba(255,255,255,0.02);
74
+ border: 1px solid rgba(255,255,255,0.04);
75
+ border-radius: 12px;
76
+ padding: 1.25rem;
77
+ margin-bottom: 1.5rem;
78
+ transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
79
+ overflow: hidden;
80
+ }
81
+
82
+ .panel-form-inline.hidden {
83
+ display: none;
84
+ }
85
+
86
+ .form-row {
87
+ display: flex;
88
+ align-items: flex-end;
89
+ gap: 1rem;
90
+ flex-wrap: wrap;
91
+ }
92
+
93
+ .form-group {
94
+ display: flex;
95
+ flex-direction: column;
96
+ gap: 6px;
97
+ }
98
+
99
+ .form-label {
100
+ font-size: 0.72rem;
101
+ font-weight: 700;
102
+ text-transform: uppercase;
103
+ letter-spacing: 0.5px;
104
+ color: var(--text-muted);
105
+ }
106
+
107
+ /* base: ui/app.css (#164) */
108
+ .form-control {
109
+ background: rgba(255, 255, 255, 0.03);
110
+ padding: 0.55rem 0.75rem;
111
+ font-family: 'Plus Jakarta Sans', sans-serif;
112
+ font-size: 0.85rem;
113
+ }
114
+
115
+ .form-control:focus {
116
+ outline: none;
117
+ background: rgba(255, 255, 255, 0.05);
118
+ box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
119
+ }
120
+
121
+ /* Toast Notifications (.toast-container/.toast base: ui/app.css, #164) */
122
+ .toast-container {
123
+ bottom: 24px;
124
+ right: 24px;
125
+ gap: 8px;
126
+ z-index: 1100;
127
+ }
128
+
129
+ .toast {
130
+ background: #0d0f1a;
131
+ padding: 0.85rem 1.25rem;
132
+ font-size: 0.82rem;
133
+ font-weight: 600;
134
+ box-shadow: 0 10px 25px rgba(0,0,0,0.5);
135
+ transform: translateY(20px);
136
+ opacity: 0;
137
+ animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
138
+ max-width: 320px;
139
+ }
140
+
141
+ .toast.error {
142
+ border-left: 3px solid var(--expense-color);
143
+ }
144
+
145
+ .toast.error i {
146
+ color: var(--expense-color);
147
+ }
148
+
149
+ .toast.success {
150
+ border-left: 3px solid var(--income-color);
151
+ }
152
+
153
+ .toast.success i {
154
+ color: var(--income-color);
155
+ }
156
+
157
+ @keyframes fadeInUp {
158
+ to { opacity: 1; transform: translateY(0); }
159
+ }
160
+ @keyframes fadeOut {
161
+ to { opacity: 0; transform: translateY(20px); }
162
+ }
163
+
164
+ /* Premium Tag Capsules Grid layout */
165
+ .tags-grid-container {
166
+ display: grid;
167
+ grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
168
+ gap: 1.25rem;
169
+ padding: 0.5rem 0;
170
+ position: relative;
171
+ }
172
+
173
+ .tag-pill-card {
174
+ background: rgba(255, 255, 255, 0.03);
175
+ border: 1px solid var(--panel-border);
176
+ border-radius: 12px;
177
+ padding: 0.85rem 1rem;
178
+ display: flex;
179
+ align-items: center;
180
+ justify-content: space-between;
181
+ transition: var(--transition-smooth);
182
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
183
+ }
184
+
185
+ .tag-pill-card:hover {
186
+ background: rgba(255, 255, 255, 0.06);
187
+ border-color: rgba(255, 255, 255, 0.12);
188
+ transform: translateY(-2px);
189
+ box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
190
+ }
191
+
192
+ .tag-pill-info {
193
+ display: flex;
194
+ align-items: center;
195
+ gap: 0.6rem;
196
+ min-width: 0;
197
+ }
198
+
199
+ .tag-pill-info i {
200
+ color: var(--accent-primary);
201
+ font-size: 0.95rem;
202
+ flex-shrink: 0;
203
+ }
204
+
205
+ .tag-pill-name {
206
+ font-size: 0.88rem;
207
+ font-weight: 600;
208
+ color: var(--text-main);
209
+ white-space: nowrap;
210
+ overflow: hidden;
211
+ text-overflow: ellipsis;
212
+ }
213
+
214
+ .btn-tag-delete {
215
+ background: transparent;
216
+ border: none;
217
+ color: var(--text-muted);
218
+ cursor: pointer;
219
+ padding: 0.25rem;
220
+ border-radius: 6px;
221
+ font-size: 0.85rem;
222
+ transition: var(--transition-smooth);
223
+ display: flex;
224
+ align-items: center;
225
+ justify-content: center;
226
+ flex-shrink: 0;
227
+ }
228
+
229
+ .btn-tag-delete:hover {
230
+ color: var(--expense-color);
231
+ background: rgba(244, 63, 94, 0.1);
232
+ }
233
+
234
+ .empty-tags-message {
235
+ text-align: center;
236
+ padding: 3rem 0;
237
+ color: var(--text-dark);
238
+ font-style: italic;
239
+ font-size: 0.88rem;
240
+ grid-column: 1 / -1;
241
+ }
242
+
243
+ /* Custom Select component styling */
244
+ .select-container-custom {
245
+ position: relative;
246
+ display: inline-block;
247
+ min-width: 120px;
248
+ user-select: none;
249
+ }
250
+
251
+ .select-trigger-custom {
252
+ background: rgba(255, 255, 255, 0.05);
253
+ border: 1px solid var(--panel-border);
254
+ color: var(--text-main);
255
+ padding: 0.5rem 2.2rem 0.5rem 0.75rem;
256
+ border-radius: 8px;
257
+ cursor: pointer;
258
+ font-size: 0.85rem;
259
+ font-weight: 600;
260
+ display: flex;
261
+ align-items: center;
262
+ justify-content: space-between;
263
+ transition: var(--transition-smooth);
264
+ min-height: 36px;
265
+ box-sizing: border-box;
266
+ }
267
+
268
+ .select-trigger-custom:hover {
269
+ border-color: rgba(255, 255, 255, 0.15);
270
+ background: rgba(255, 255, 255, 0.08);
271
+ }
272
+
273
+ .select-container-custom.open .select-trigger-custom {
274
+ border-color: var(--accent-primary);
275
+ box-shadow: 0 0 0 2px var(--accent-primary-glow);
276
+ }
277
+
278
+ .select-trigger-custom::after {
279
+ content: '\f078';
280
+ font-family: 'Font Awesome 6 Free';
281
+ font-weight: 900;
282
+ font-size: 0.7rem;
283
+ color: var(--text-muted);
284
+ position: absolute;
285
+ right: 12px;
286
+ transition: transform 0.3s ease;
287
+ }
288
+
289
+ .select-container-custom.open .select-trigger-custom::after {
290
+ transform: rotate(180deg);
291
+ color: var(--accent-primary);
292
+ }
293
+
294
+ .select-options-custom {
295
+ display: none;
296
+ position: absolute;
297
+ top: calc(100% + 6px);
298
+ left: 0;
299
+ width: 100%;
300
+ background: rgba(22, 22, 34, 0.98); /* Opaque dark background to prevent bleed-through */
301
+ border: 1px solid var(--panel-border);
302
+ border-radius: 12px;
303
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
304
+ z-index: 1000;
305
+ max-height: 250px;
306
+ overflow-y: auto;
307
+ padding: 4px;
308
+ backdrop-filter: blur(20px);
309
+ box-sizing: border-box;
310
+ animation: selectFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
311
+ }
312
+
313
+ @keyframes selectFadeIn {
314
+ from { opacity: 0; transform: translateY(-8px); }
315
+ to { opacity: 1; transform: translateY(0); }
316
+ }
317
+
318
+ .select-container-custom.open .select-options-custom {
319
+ display: block;
320
+ }
321
+
322
+ .select-option-custom {
323
+ padding: 0.5rem 0.75rem;
324
+ color: var(--text-muted); /* Highly readable text color on dark backgrounds */
325
+ font-size: 0.82rem;
326
+ font-weight: 500;
327
+ border-radius: 6px;
328
+ cursor: pointer;
329
+ transition: var(--transition-smooth);
330
+ }
331
+
332
+ .select-option-custom:hover {
333
+ background: rgba(255, 255, 255, 0.08);
334
+ color: #fff;
335
+ }
336
+
337
+ .select-option-custom.selected {
338
+ background: var(--accent-primary-glow);
339
+ color: var(--accent-primary);
340
+ font-weight: 700;
341
+ }
342
+
343
+ .select-options-custom::-webkit-scrollbar {
344
+ width: 6px;
345
+ }
346
+ .select-options-custom::-webkit-scrollbar-track {
347
+ background: transparent;
348
+ }
349
+ .select-options-custom::-webkit-scrollbar-thumb {
350
+ background: rgba(255, 255, 255, 0.1);
351
+ border-radius: 3px;
352
+ }
353
+ </style>
354
+
355
+ <header>
356
+ <div class="header-title-area">
357
+ <h1><i class="fa-solid fa-tag"></i> <span data-i18n="tags_title">Gerenciar Tags</span></h1>
358
+ <p data-i18n="tags_subtitle">Gerencie as tags utilizadas para rotular e categorizar suas transações</p>
359
+ </div>
360
+ </header>
361
+
362
+ <section class="panel">
363
+ <div class="loading-overlay" id="list-loading">
364
+ <div class="spinner"></div>
365
+ </div>
366
+
367
+ <div class="panel-header-row">
368
+ <div class="panel-title">
369
+ <i class="fa-solid fa-tags"></i> <span data-i18n="panel_title_tags">Tags Ativas</span>
370
+ </div>
371
+ <button type="button" class="btn-action-primary" onclick="toggleAddTagForm()">
372
+ <i class="fa-solid fa-plus"></i> <span data-i18n="btn_new_tag">Nova Tag</span>
373
+ </button>
374
+ </div>
375
+
376
+ <!-- Form: Create New Tag (Hidden/Inline) -->
377
+ <div id="add-tag-form-container" class="panel-form-inline hidden">
378
+ <form id="tag-form" onsubmit="handleCreateTag(event)">
379
+ <div class="form-row" style="display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap;">
380
+ <div class="form-group" style="flex: 2; min-width: 250px; display: flex; flex-direction: column; gap: 6px;">
381
+ <label class="form-label" for="tag-name" data-i18n="label_tag_name">Nome da Tag</label>
382
+ <input type="text" id="tag-name" class="form-control" placeholder="Ex: trabalho, viagem, reembolso" style="height: 38px; box-sizing: border-box;" required>
383
+ </div>
384
+ <div style="display: flex; gap: 0.5rem; height: 38px; align-items: center;">
385
+ <button type="submit" class="btn-action-primary" style="height: 38px; padding: 0 1.25rem;" data-i18n="btn_save">Salvar</button>
386
+ <button type="button" class="btn-action-primary" style="height: 38px; padding: 0 1.25rem; background: rgba(255, 255, 255, 0.05); color: var(--text-muted);" onclick="toggleAddTagForm()" data-i18n="btn_cancel">Cancelar</button>
387
+ </div>
388
+ </div>
389
+ </form>
390
+ </div>
391
+
392
+ <!-- Grid displaying the tags list -->
393
+ <div class="tags-grid-container" id="tags-list">
394
+ <!-- Populated dynamically -->
395
+ </div>
396
+ </section>
397
+
398
+ <div class="toast-container" id="toast-container"></div>
399
+
400
+ <script>
401
+ // State variables
402
+ var tagsList = [];
403
+
404
+ // Elements
405
+ var listLoading = document.getElementById('list-loading');
406
+ var tagsListContainer = document.getElementById('tags-list');
407
+
408
+ // Toast Helper
409
+ function showToast(message, type = "success") {
410
+ const container = document.getElementById('toast-container');
411
+ const toast = document.createElement('div');
412
+ toast.className = `toast ${type}`;
413
+ toast.innerHTML = `
414
+ <i class="fa-solid ${type === 'success' ? 'fa-circle-check' : 'fa-circle-exclamation'}"></i>
415
+ <span>${escapeHtml(message)}</span>
416
+ `;
417
+ container.appendChild(toast);
418
+
419
+ setTimeout(() => {
420
+ toast.style.animation = "fadeOut 0.4s ease forwards";
421
+ setTimeout(() => toast.remove(), 400);
422
+ }, 3500);
423
+ }
424
+
425
+ // Fetch all tags from API
426
+ async function loadTagsData() {
427
+ listLoading.classList.add('active');
428
+ try {
429
+ const res = await fetch('/api/tags');
430
+ if (res.ok) {
431
+ tagsList = await res.json();
432
+ tagsList.sort((a, b) => a.name.localeCompare(b.name));
433
+ } else {
434
+ showToast("Erro ao carregar lista de tags.", "error");
435
+ }
436
+ renderTagsList();
437
+ } catch (err) {
438
+ console.error("Error loading tags:", err);
439
+ showToast("Erro de rede ao carregar tags.", "error");
440
+ } finally {
441
+ listLoading.classList.remove('active');
442
+ }
443
+ }
444
+
445
+ // Render tags grid
446
+ function renderTagsList() {
447
+ tagsListContainer.innerHTML = '';
448
+
449
+ if (tagsList.length === 0) {
450
+ tagsListContainer.innerHTML = `
451
+ <div class="empty-tags-message" data-i18n="empty_tags_message">
452
+ Nenhuma tag cadastrada.
453
+ </div>
454
+ `;
455
+ return;
456
+ }
457
+
458
+ tagsList.forEach(tag => {
459
+ const card = document.createElement('div');
460
+ card.className = 'tag-pill-card';
461
+ card.id = `tag-${tag.id}`;
462
+ card.innerHTML = `
463
+ <div class="tag-pill-info">
464
+ <i class="fa-solid fa-tag"></i>
465
+ <span class="tag-pill-name" title="${escapeHtml(tag.name)}">${escapeHtml(tag.name)}</span>
466
+ </div>
467
+ <button type="button" class="btn-tag-delete" title="Excluir tag" onclick="handleDeleteTag('${tag.id}', '${escapeJsAttr(tag.name)}')">
468
+ <i class="fa-solid fa-xmark"></i>
469
+ </button>
470
+ `;
471
+ tagsListContainer.appendChild(card);
472
+ });
473
+ }
474
+
475
+ // Toggle New Tag Form visibility
476
+ function toggleAddTagForm() {
477
+ const container = document.getElementById('add-tag-form-container');
478
+ container.classList.toggle('hidden');
479
+ if (!container.classList.contains('hidden')) {
480
+ document.getElementById('tag-form').reset();
481
+ document.getElementById('tag-name').focus();
482
+ }
483
+ }
484
+
485
+ // Handle Form Submission (Create tag)
486
+ async function handleCreateTag(event) {
487
+ event.preventDefault();
488
+ const inputName = document.getElementById('tag-name');
489
+ const name = inputName.value.trim();
490
+
491
+ if (!name) {
492
+ showToast("Digite o nome da tag.", "error");
493
+ return;
494
+ }
495
+
496
+ listLoading.classList.add('active');
497
+ try {
498
+ const res = await fetch('/api/tags', {
499
+ method: 'POST',
500
+ headers: { 'Content-Type': 'application/json' },
501
+ body: JSON.stringify({ name })
502
+ });
503
+
504
+ if (res.ok) {
505
+ showToast(t('toast_success_tag_created').replace('{name}', name));
506
+ toggleAddTagForm();
507
+ await loadTagsData();
508
+ } else {
509
+ const errData = await res.json();
510
+ let errMsg = "Erro ao criar tag.";
511
+ if (errData.error?.code === 'duplicate' || res.status === 409) {
512
+ errMsg = "Esta tag já existe.";
513
+ }
514
+ showToast(errMsg, "error");
515
+ }
516
+ } catch (err) {
517
+ console.error("Error creating tag:", err);
518
+ showToast("Erro de rede ao criar tag.", "error");
519
+ } finally {
520
+ listLoading.classList.remove('active');
521
+ }
522
+ }
523
+
524
+ // Handle Delete Tag
525
+ async function handleDeleteTag(id, name) {
526
+ if (!confirm(t('confirm_delete_tag').replace('{name}', name))) {
527
+ return;
528
+ }
529
+
530
+ listLoading.classList.add('active');
531
+ try {
532
+ const res = await fetch(`/api/tags/${id}`, {
533
+ method: 'DELETE'
534
+ });
535
+
536
+ if (res.ok) {
537
+ showToast(t('toast_success_tag_deleted').replace('{name}', name));
538
+ await loadTagsData();
539
+ } else {
540
+ showToast("Erro ao excluir tag.", "error");
541
+ }
542
+ } catch (err) {
543
+ console.error("Error deleting tag:", err);
544
+ showToast("Erro de rede ao excluir tag.", "error");
545
+ } finally {
546
+ listLoading.classList.remove('active');
547
+ }
548
+ }
549
+
550
+ // Simple HTML Escaping helper
551
+ function escapeHtml(str) {
552
+ return str
553
+ .replace(/&/g, "&amp;")
554
+ .replace(/</g, "&lt;")
555
+ .replace(/>/g, "&gt;")
556
+ .replace(/"/g, "&quot;")
557
+ .replace(/'/g, "&#039;");
558
+ }
559
+
560
+ // Escapes a value for safe embedding as a single-quoted JS string literal *inside* an
561
+ // HTML attribute (e.g. onclick="fn('${escapeJsAttr(value)}')"). escapeHtml() alone is not
562
+ // enough here: the browser HTML-decodes the attribute before the JS parser reads it, so an
563
+ // HTML-escaped quote round-trips back into a real quote and still breaks out of the string.
564
+ // Escaping backslash+quote for the JS layer first, then HTML-escaping the result for the
565
+ // attribute layer, survives that decode step correctly for both layers.
566
+ function escapeJsAttr(str) {
567
+ if (!str) return '';
568
+ return escapeHtml(String(str).replace(/\\/g, '\\\\').replace(/'/g, "\\'"));
569
+ }
570
+
571
+ // Initialize page
572
+
573
+ // Translation engine and dictionaries
574
+ var TRANSLATIONS = {
575
+ en: {
576
+ // Sidebar Menu
577
+ tooltip_overview: "Overview",
578
+ tooltip_pending: "Pending",
579
+ tooltip_comparative: "Comparative",
580
+ tooltip_projections: "Projections",
581
+ tooltip_accounts: "Bank Accounts",
582
+ tooltip_cards: "Credit Cards",
583
+ menu_categories: "Categories",
584
+ menu_dashboards: "Dashboards",
585
+
586
+ // Month names
587
+ january: "January", february: "February", march: "March", april: "April", may: "May", june: "June",
588
+ july: "July", august: "August", september: "September", october: "October", november: "November", december: "December",
589
+
590
+ // General UI terms
591
+ reference_label: "Reference:",
592
+ day_sun: "Sun", day_mon: "Mon", day_tue: "Tue", day_wed: "Wed", day_thu: "Thu", day_fri: "Fri", day_sat: "Sat",
593
+ paid: "Paid", unpaid: "Unpaid", active: "Active", inactive: "Inactive",
594
+
595
+ // Overview Dashboard
596
+ overview_title: "Overview",
597
+ overview_subtitle: "Monthly financial summary, calendar, and quick shortcuts",
598
+ accounts_balance: "Accounts Balance",
599
+ expenses_month: "Expenses this Month",
600
+ card_bills: "Credit Card Bills",
601
+ incomes_month: "Incomes this Month",
602
+ final_projection: "Final Projection:",
603
+ recent_transactions: "Recent Transactions",
604
+ due_calendar: "Daily Flow & Dues",
605
+ expenses_distribution: "Expenses Distribution",
606
+ quick_shortcuts: "Quick Shortcuts",
607
+ new_transaction: "New Transaction",
608
+ new_transfer: "New Transfer",
609
+ new_category: "New Category",
610
+ new_card: "New Card",
611
+ new_account: "New Account",
612
+ no_expenses_month: "No expenses recorded this month.",
613
+ no_recent_transactions: "No recent transactions found.",
614
+ no_dues_period: "No transactions due in this period.",
615
+ income: "Income",
616
+ expense: "Expense",
617
+ paid_reconciled: "Paid / Reconciled",
618
+
619
+ // Projections / Heatmap Dashboard
620
+ projections_title: "Recurring & Installment Projections",
621
+ projections_subtitle: "Advanced visual mapping and projection of active recurrences and installments for the next months",
622
+ projection_label: "Projection:",
623
+ months_3: "3 Months",
624
+ months_6: "6 Months",
625
+ months_9: "9 Months",
626
+ months_12: "12 Months",
627
+ heatmap_income_title: "Recurrent / Installment Incomes",
628
+ heatmap_expense_title: "Recurrent / Installment Expenses",
629
+ total: "Total",
630
+ no_recurrent_incomes: "No active recurrent or installment incomes in the selected semester.",
631
+ no_recurrent_expenses: "No active recurrent or installment expenses in the selected semester.",
632
+ modal_details_title: "Projection Breakdown",
633
+ modal_details_subtitle: "Details of projected transactions for the category and month",
634
+ col_date: "Date",
635
+ col_desc: "Description",
636
+ col_value: "Value",
637
+ col_status: "Status",
638
+ btn_close: "Close",
639
+
640
+ // Comparative Dashboard
641
+ comparative_title: "Comparative Dashboard",
642
+ comparative_subtitle: "Analysis and comparison of monthly incomes vs expenses, and category limits",
643
+ month_summary_title: "Month Summary",
644
+ cat_spending_title: "Spending by Category",
645
+ card_limits_title: "Category Budgets & Limits",
646
+ col_category: "Category",
647
+ col_limit: "Budget Limit",
648
+ col_spent: "Spent",
649
+ col_status_limit: "Status",
650
+ col_percentage: "Percentage",
651
+ within_limit: "Within Limit",
652
+ exceeded: "Exceeded",
653
+ reception: "Incomes",
654
+ deduction: "Expenses",
655
+ net_balance: "Net Balance",
656
+ performance: "Financial Health",
657
+ no_spending_month: "No category spend recorded this month.",
658
+
659
+ // Accounts Dashboard
660
+ accounts_title: "Bank Accounts",
661
+ accounts_subtitle: "Manage accounts, checking balances, and reviewing statements",
662
+ active_account_statement: "Account Statement",
663
+ btn_new_transaction: "New Transaction",
664
+ btn_new_transfer: "New Transfer",
665
+ search_description_placeholder: "Type to search...",
666
+ filter_type_label: "Type",
667
+ filter_type_all: "All",
668
+ filter_type_income: "Incomes",
669
+ filter_type_expense: "Expenses",
670
+ col_actions: "Actions",
671
+ action_confirm: "Confirm",
672
+ action_edit: "Edit",
673
+ action_delete: "Delete",
674
+ no_transactions_account: "No transactions recorded for this account in the selected month.",
675
+ confirm_delete_title: "Are you sure you want to permanently delete this transaction?",
676
+ modal_new_tx_title: "New Transaction",
677
+ modal_new_transfer_title: "New Transfer",
678
+ label_account: "Account",
679
+ label_description: "Description",
680
+ label_value: "Value",
681
+ label_date: "Date",
682
+ label_category: "Category / Subcategory",
683
+ label_type: "Type",
684
+ label_status: "Status",
685
+ status_pending: "Pending",
686
+ status_confirmed: "Paid / Confirmed",
687
+ btn_cancel: "Cancel",
688
+ btn_save: "Save",
689
+ label_origin: "Origin Account",
690
+ label_destination: "Destination Account",
691
+
692
+ // Pending Dashboard
693
+ pending_title: "Pending Transactions",
694
+ pending_subtitle: "Monitoring and quick confirmation of pending or future transactions",
695
+ pending_kpi_total: "Total Pending",
696
+ pending_kpi_incomes: "Pending Incomes",
697
+ pending_kpi_expenses: "Pending Expenses",
698
+ pending_chart_incomes: "Pending Incomes Trend",
699
+ pending_chart_expenses: "Pending Expenses Trend",
700
+ btn_confirm: "Confirm",
701
+ btn_edit: "Edit",
702
+ btn_delete: "Delete",
703
+ no_pending_transactions: "No pending transactions found for this period.",
704
+ toast_success_confirm: "Transaction confirmed successfully!",
705
+
706
+ // Categories Dashboard
707
+ categories_title: "Category Management",
708
+ categories_subtitle: "Visualize, search, and manage categories and subcategories in a clean tree list",
709
+ btn_new_category: "New Category",
710
+ search_category_placeholder: "Search categories...",
711
+ col_type: "Type",
712
+ col_actions_cat: "Actions",
713
+ subcategories_label: "Subcategories",
714
+ no_subcategories: "No subcategories registered.",
715
+ modal_new_cat_title: "New Category",
716
+ modal_new_subcat_title: "New Subcategory",
717
+ label_name: "Name",
718
+ label_color: "Color",
719
+ label_parent_category: "Parent Category (Read-Only)",
720
+ toast_success_cat: "Category created successfully!",
721
+ toast_success_subcat: "Subcategory created successfully!",
722
+
723
+ // Cards Dashboard
724
+ cards_title: "Credit Cards",
725
+ cards_subtitle: "Manage credit cards, credit limits, and statement history",
726
+ card_bill_details: "Card Bill Details",
727
+ btn_pay_bill: "Pay Bill",
728
+ btn_revert_payment: "Revert Payment",
729
+ bill_status: "Bill Status:",
730
+ status_open: "Open",
731
+ status_closed: "Closed",
732
+ status_paid: "Paid",
733
+ no_card_transactions: "No transactions recorded for this card bill in the selected cycle.",
734
+
735
+ // Dashboards Manager Dashboard
736
+ dashboards_title: "Dashboards Monitor",
737
+ dashboards_subtitle: "List, view source, and upload patty dashboards",
738
+ col_dashboard: "Dashboard",
739
+ col_last_update: "Last Updated",
740
+ btn_view_source: "View Source",
741
+ btn_download: "Download",
742
+ upload_new_dashboard: "Upload New Dashboard",
743
+ placeholder_dashboard_name: "Dashboard Name (e.g. pending)",
744
+ upload_instructions: "Select or drop HTML file here to upload",
745
+ btn_upload: "Upload",
746
+ modal_source_title: "HTML Source Code",
747
+
748
+ // Tags Management
749
+ menu_tags: "Tags",
750
+ tags_title: "Tag Management",
751
+ tags_subtitle: "Manage tags to label and organize your transactions",
752
+ panel_title_tags: "Active Tags",
753
+ btn_new_tag: "New Tag",
754
+ label_tag_name: "Tag Name",
755
+ placeholder_tag_name: "E.g. work, travel, refund",
756
+ empty_tags_message: "No tags registered.",
757
+ btn_save: "Save",
758
+ btn_cancel: "Cancel",
759
+ toast_success_tag_created: 'Tag "{name}" created successfully!',
760
+ toast_success_tag_deleted: 'Tag "{name}" deleted successfully!',
761
+ confirm_delete_tag: 'Are you sure you want to delete tag "{name}"?\n(This action will remove the tag from all linked transactions)'
762
+ },
763
+ pt: {
764
+ // Sidebar Menu
765
+ tooltip_overview: "Visão Geral",
766
+ tooltip_pending: "Pendentes",
767
+ tooltip_comparative: "Comparativo",
768
+ tooltip_projections: "Projeções",
769
+ tooltip_accounts: "Contas Bancárias",
770
+ tooltip_cards: "Cartões de Crédito",
771
+ menu_categories: "Categorias",
772
+ menu_dashboards: "Dashboards",
773
+
774
+ // Month names
775
+ january: "Janeiro", february: "Fevereiro", march: "Março", april: "Abril", may: "Maio", june: "Junho",
776
+ july: "Julho", august: "Agosto", september: "Setembro", october: "Outubro", november: "Novembro", december: "Dezembro",
777
+
778
+ // General UI terms
779
+ reference_label: "Referência:",
780
+ day_sun: "Dom", day_mon: "Seg", day_tue: "Ter", day_wed: "Qua", day_thu: "Qui", day_fri: "Sex", day_sat: "Sáb",
781
+ paid: "Pago", unpaid: "Não Pago", active: "Ativo", inactive: "Inativo",
782
+
783
+ // Overview Dashboard
784
+ overview_title: "Visão Geral",
785
+ overview_subtitle: "Consolidado financeiro mensal, calendário e atalhos rápidos",
786
+ accounts_balance: "Saldo em Contas",
787
+ expenses_month: "Despesas do Mês",
788
+ card_bills: "Faturas de Cartão",
789
+ incomes_month: "Receitas do Mês",
790
+ final_projection: "Projeção Final:",
791
+ recent_transactions: "Lançamentos Recentes",
792
+ due_calendar: "Fluxo Diário",
793
+ expenses_distribution: "Distribuição de Despesas",
794
+ quick_shortcuts: "Atalhos Rápidos",
795
+ new_transaction: "Novo Lançamento",
796
+ new_transfer: "Nova Transferência",
797
+ new_category: "Nova Categoria",
798
+ new_card: "Novo Cartão",
799
+ new_account: "Nova Conta",
800
+ no_expenses_month: "Sem despesas registradas neste mês.",
801
+ no_recent_transactions: "Nenhuma transação recente encontrada.",
802
+ no_dues_period: "Sem vencimentos neste período.",
803
+ income: "Receita",
804
+ expense: "Despesa",
805
+ paid_reconciled: "Pago / Conciliado",
806
+
807
+ // Projections / Heatmap Dashboard
808
+ projections_title: "Projeção de Recorrências e Parcelas",
809
+ projections_subtitle: "Mapeamento visual avançado e projeção de recorrências e parcelas ativas para os próximos meses",
810
+ projection_label: "Projeção:",
811
+ months_3: "3 Meses",
812
+ months_6: "6 Meses",
813
+ months_9: "9 Meses",
814
+ months_12: "12 Meses",
815
+ heatmap_income_title: "Receitas Recorrentes / Parceladas",
816
+ heatmap_expense_title: "Despesas Recorrentes / Parceladas",
817
+ total: "Total",
818
+ no_recurrent_incomes: "Nenhuma receita recorrente/parcelada ativa no semestre.",
819
+ no_recurrent_expenses: "Nenhuma despesa recorrente/parcelada ativa no semestre.",
820
+ modal_details_title: "Detalhamento de Projeções",
821
+ modal_details_subtitle: "Detalhes das transações projetadas para a categoria e mês",
822
+ col_date: "Data",
823
+ col_desc: "Descrição",
824
+ col_value: "Valor",
825
+ col_status: "Status",
826
+ btn_close: "Fechar",
827
+
828
+ // Comparative Dashboard
829
+ comparative_title: "Dashboard Comparativo",
830
+ comparative_subtitle: "Análise e comparação mensal de receitas vs despesas e limites por categoria",
831
+ month_summary_title: "Resumo do Mês",
832
+ cat_spending_title: "Gastos por Categoria",
833
+ card_limits_title: "Orçamentos e Limites de Categorias",
834
+ col_category: "Categoria",
835
+ col_limit: "Limite de Orçamento",
836
+ col_spent: "Gasto",
837
+ col_status_limit: "Status",
838
+ col_percentage: "Porcentagem",
839
+ within_limit: "Dentro do Limite",
840
+ exceeded: "Excedido",
841
+ reception: "Receitas",
842
+ deduction: "Despesas",
843
+ net_balance: "Saldo Líquido",
844
+ performance: "Saúde Financeira",
845
+ no_spending_month: "Sem despesas registradas por categoria neste mês.",
846
+
847
+ // Accounts Dashboard
848
+ accounts_title: "Minhas Contas",
849
+ accounts_subtitle: "Gerencie contas, consulte saldos e revise extratos",
850
+ active_account_statement: "Extrato de Conta",
851
+ btn_new_transaction: "Novo Lançamento",
852
+ btn_new_transfer: "Nova Transferência",
853
+ search_description_placeholder: "Digite para filtrar...",
854
+ filter_type_label: "Tipo",
855
+ filter_type_all: "Todos",
856
+ filter_type_income: "Receitas",
857
+ filter_type_expense: "Despesas",
858
+ col_actions: "Ações",
859
+ action_confirm: "Confirmar",
860
+ action_edit: "Editar",
861
+ action_delete: "Excluir",
862
+ no_transactions_account: "Nenhum lançamento nesta conta para o mês selecionado.",
863
+ confirm_delete_title: "Deseja excluir definitivamente a transação?",
864
+ modal_new_tx_title: "Novo Lançamento",
865
+ modal_new_transfer_title: "Nova Transferência",
866
+ label_account: "Conta",
867
+ label_description: "Descrição",
868
+ label_value: "Valor",
869
+ label_date: "Data",
870
+ label_category: "Categoria / Subcategoria",
871
+ label_type: "Tipo",
872
+ label_status: "Status",
873
+ status_pending: "Pendente",
874
+ status_confirmed: "Pago / Confirmado",
875
+ btn_cancel: "Cancelar",
876
+ btn_save: "Salvar",
877
+ label_origin: "Conta Origem",
878
+ label_destination: "Conta Destino",
879
+
880
+ // Pending Dashboard
881
+ pending_title: "Transações Pendentes",
882
+ pending_subtitle: "Monitoramento e confirmação rápida de lançamentos pendentes ou futuros",
883
+ pending_kpi_total: "Total Pendente",
884
+ pending_kpi_incomes: "Receitas Pendentes",
885
+ pending_kpi_expenses: "Despesas Pendentes",
886
+ pending_chart_incomes: "Tendência de Receitas Pendentes",
887
+ pending_chart_expenses: "Tendência de Despesas Pendentes",
888
+ btn_confirm: "Confirmar",
889
+ btn_edit: "Editar",
890
+ btn_delete: "Excluir",
891
+ no_pending_transactions: "Nenhuma transação pendente encontrada para este período.",
892
+ toast_success_confirm: "Transação confirmada com sucesso!",
893
+
894
+ // Categories Dashboard
895
+ categories_title: "Gerenciamento de Categorias",
896
+ categories_subtitle: "Visualize, pesquise e gerencie categorias e subcategorias em árvore",
897
+ btn_new_category: "Nova Categoria",
898
+ search_category_placeholder: "Pesquisar categorias...",
899
+ col_type: "Tipo",
900
+ col_actions_cat: "Ações",
901
+ subcategories_label: "Subcategorias",
902
+ no_subcategories: "Nenhuma subcategoria cadastrada.",
903
+ modal_new_cat_title: "Nova Categoria",
904
+ modal_new_subcat_title: "Nova Subcategoria",
905
+ label_name: "Nome",
906
+ label_color: "Cor",
907
+ label_parent_category: "Categoria Pai (Somente Leitura)",
908
+ toast_success_cat: "Categoria criada com sucesso!",
909
+ toast_success_subcat: "Subcategoria criada com sucesso!",
910
+
911
+ // Cards Dashboard
912
+ cards_title: "Cartões de Crédito",
913
+ cards_subtitle: "Gerencie cartões de crédito, limites e histórico de faturas",
914
+ card_bill_details: "Detalhamento de Fatura",
915
+ btn_pay_bill: "Pagar Fatura",
916
+ btn_revert_payment: "Estornar Pagamento",
917
+ bill_status: "Status da Fatura:",
918
+ status_open: "Aberta",
919
+ status_closed: "Fechada",
920
+ status_paid: "Paga",
921
+ no_card_transactions: "Nenhuma transação registrada nesta fatura para o ciclo selecionado.",
922
+
923
+ // Dashboards Manager Dashboard
924
+ dashboards_title: "Monitor de Dashboards",
925
+ dashboards_subtitle: "Liste, visualize o código fonte e envie dashboards para o servidor do patty",
926
+ col_dashboard: "Dashboard",
927
+ col_last_update: "Última Atualização",
928
+ btn_view_source: "Ver Código",
929
+ btn_download: "Baixar HTML",
930
+ upload_new_dashboard: "Enviar Novo Dashboard",
931
+ placeholder_dashboard_name: "Nome do Dashboard (ex: pending)",
932
+ upload_instructions: "Selecione ou solte o arquivo HTML aqui para upload",
933
+ btn_upload: "Fazer Upload",
934
+ modal_source_title: "Código Fonte HTML",
935
+
936
+ // Tags Management
937
+ menu_tags: "Tags",
938
+ tags_title: "Gerenciar Tags",
939
+ tags_subtitle: "Gerencie as tags utilizadas para rotular e categorizar suas transações",
940
+ panel_title_tags: "Tags Ativas",
941
+ btn_new_tag: "Nova Tag",
942
+ label_tag_name: "Nome da Tag",
943
+ placeholder_tag_name: "Ex: trabalho, viagem, reembolso",
944
+ empty_tags_message: "Nenhuma tag cadastrada.",
945
+ btn_save: "Salvar",
946
+ btn_cancel: "Cancelar",
947
+ toast_success_tag_created: 'Tag "{name}" criada com sucesso!',
948
+ toast_success_tag_deleted: 'Tag "{name}" excluída com sucesso!',
949
+ confirm_delete_tag: 'Deseja realmente excluir a tag "{name}"?\n(Esta ação removerá a tag de todas as transações vinculadas)'
950
+ },
951
+ es: {
952
+ // Sidebar Menu
953
+ tooltip_overview: "Vista General",
954
+ tooltip_pending: "Pendientes",
955
+ tooltip_comparative: "Comparativo",
956
+ tooltip_projections: "Proyecciones",
957
+ tooltip_accounts: "Cuentas Bancárias",
958
+ tooltip_cards: "Tarjetas de Crédito",
959
+ menu_categories: "Categorías",
960
+ menu_dashboards: "Dashboards",
961
+
962
+ // Month names
963
+ january: "Enero", february: "Febrero", march: "Marzo", april: "Abril", may: "Mayo", june: "Junio",
964
+ july: "Julio", august: "Agosto", september: "Septiembre", october: "Octubre", november: "Noviembre", december: "Diciembre",
965
+
966
+ // General UI terms
967
+ reference_label: "Referencia:",
968
+ day_sun: "Dom", day_mon: "Lun", day_tue: "Mar", day_wed: "Mié", day_thu: "Jue", day_fri: "Vie", day_sat: "Sáb",
969
+ paid: "Pagado", unpaid: "No Pagado", active: "Activo", inactive: "Inactivo",
970
+
971
+ // Overview Dashboard
972
+ overview_title: "Vista General",
973
+ overview_subtitle: "Resumen financiero mensual, calendario y accesos rápidos",
974
+ accounts_balance: "Saldo en Cuentas",
975
+ expenses_month: "Gastos del Mes",
976
+ card_bills: "Facturas de Tarjeta",
977
+ incomes_month: "Ingresos del Mes",
978
+ final_projection: "Proyección Final:",
979
+ recent_transactions: "Transacciones Recientes",
980
+ due_calendar: "Calendario de Pagos",
981
+ expenses_distribution: "Distribución de Gastos",
982
+ quick_shortcuts: "Accesos Rápidos",
983
+ new_transaction: "Nueva Transacción",
984
+ new_transfer: "Nueva Transferencia",
985
+ new_category: "Nueva Categoría",
986
+ new_card: "Nueva Tarjeta",
987
+ new_account: "Nueva Cuenta",
988
+ no_expenses_month: "No hay gastos registrados este mes.",
989
+ no_recent_transactions: "No se encontraron transacciones recientes.",
990
+ no_dues_period: "Sin vencimientos en este período.",
991
+ income: "Ingreso",
992
+ expense: "Gasto",
993
+ paid_reconciled: "Pagado / Conciliado",
994
+
995
+ // Projections / Heatmap Dashboard
996
+ projections_title: "Proyección de Recurrencias y Cuotas",
997
+ projections_subtitle: "Mapeo visual avanzado y proyección de recurrencias y cuotas activas para los próximos meses",
998
+ projection_label: "Proyección:",
999
+ months_3: "3 Meses",
1000
+ months_6: "6 Meses",
1001
+ months_9: "9 Meses",
1002
+ months_12: "12 Meses",
1003
+ heatmap_income_title: "Ingresos Recurrentes / Cuotas",
1004
+ heatmap_expense_title: "Gastos Recurrentes / Cuotas",
1005
+ total: "Total",
1006
+ no_recurrent_incomes: "Ningún ingreso recurrente o en cuotas activo en el semestre seleccionado.",
1007
+ no_recurrent_expenses: "Ningún gasto recurrente o en cuotas activo en el semestre seleccionado.",
1008
+ modal_details_title: "Detalle de Proyecciones",
1009
+ modal_details_subtitle: "Detalles de transacciones proyectadas para la categoría y mes",
1010
+ col_date: "Fecha",
1011
+ col_desc: "Descripción",
1012
+ col_value: "Valor",
1013
+ col_status: "Estado",
1014
+ btn_close: "Cerrar",
1015
+
1016
+ // Comparative Dashboard
1017
+ comparative_title: "Dashboard Comparativo",
1018
+ comparative_subtitle: "Análisis y comparación mensual de ingresos vs gastos y límites por categoría",
1019
+ month_summary_title: "Resumen del Mes",
1020
+ cat_spending_title: "Gastos por Categoría",
1021
+ card_limits_title: "Presupuestos y Límites de Categorías",
1022
+ col_category: "Categoría",
1023
+ col_limit: "Límite de Presupuesto",
1024
+ col_spent: "Gastado",
1025
+ col_status_limit: "Estado",
1026
+ col_percentage: "Porcentaje",
1027
+ within_limit: "Dentro del Límite",
1028
+ exceeded: "Excedido",
1029
+ reception: "Ingresos",
1030
+ deduction: "Gastos",
1031
+ net_balance: "Saldo Neto",
1032
+ performance: "Salud Financiera",
1033
+ no_spending_month: "No hay gastos registrados por categoría este mes.",
1034
+
1035
+ // Accounts Dashboard
1036
+ accounts_title: "Cuentas Bancarias",
1037
+ accounts_subtitle: "Administre cuentas, consulte saldos y revise extractos",
1038
+ active_account_statement: "Extracto de Cuenta",
1039
+ btn_new_transaction: "Nueva Transacción",
1040
+ btn_new_transfer: "Nueva Transferencia",
1041
+ search_description_placeholder: "Escriba para filtrar...",
1042
+ filter_type_label: "Tipo",
1043
+ filter_type_all: "Todos",
1044
+ filter_type_income: "Ingresos",
1045
+ filter_type_expense: "Gastos",
1046
+ col_actions: "Acciones",
1047
+ action_confirm: "Confirmar",
1048
+ action_edit: "Editar",
1049
+ action_delete: "Eliminar",
1050
+ no_transactions_account: "No hay transacciones registradas en esta cuenta en el mes seleccionado.",
1051
+ confirm_delete_title: "¿Está seguro de eliminar definitivamente esta transacción?",
1052
+ modal_new_tx_title: "Nueva Transacción",
1053
+ modal_new_transfer_title: "Nueva Transferencia",
1054
+ label_account: "Cuenta",
1055
+ label_description: "Descripción",
1056
+ label_value: "Valor",
1057
+ label_date: "Fecha",
1058
+ label_category: "Categoría / Subcategoría",
1059
+ label_type: "Tipo",
1060
+ label_status: "Estado",
1061
+ status_pending: "Pendiente",
1062
+ status_confirmed: "Pagado / Confirmado",
1063
+ btn_cancel: "Cancelar",
1064
+ btn_save: "Guardar",
1065
+ label_origin: "Cuenta Origen",
1066
+ label_destination: "Cuenta Destino",
1067
+
1068
+ // Pending Dashboard
1069
+ pending_title: "Transacciones Pendientes",
1070
+ pending_subtitle: "Monitoreo y confirmación rápida de transacciones pendientes o futuras",
1071
+ pending_kpi_total: "Total Pendiente",
1072
+ pending_kpi_incomes: "Ingresos Pendientes",
1073
+ pending_kpi_expenses: "Gastos Pendientes",
1074
+ pending_chart_incomes: "Tendencia de Ingresos Pendientes",
1075
+ pending_chart_expenses: "Tendencia de Gastos Pendientes",
1076
+ btn_confirm: "Confirmar",
1077
+ btn_edit: "Editar",
1078
+ btn_delete: "Eliminar",
1079
+ no_pending_transactions: "No se encontraron transacciones pendientes en este período.",
1080
+ toast_success_confirm: "¡Transacción confirmada con éxito!",
1081
+
1082
+ // Categories Dashboard
1083
+ categories_title: "Gestión de Categorías",
1084
+ categories_subtitle: "Visualice, busque y gestione categorías y subcategorías en árbol",
1085
+ btn_new_category: "Nueva Categoría",
1086
+ search_category_placeholder: "Buscar categorías...",
1087
+ col_type: "Tipo",
1088
+ col_actions_cat: "Acciones",
1089
+ subcategories_label: "Subcategorías",
1090
+ no_subcategories: "Ninguna subcategoría registrada.",
1091
+ modal_new_cat_title: "Nueva Categoría",
1092
+ modal_new_subcat_title: "Nueva Subcategoría",
1093
+ label_name: "Nombre",
1094
+ label_color: "Color",
1095
+ label_parent_category: "Categoría Padre (Solo Lectura)",
1096
+ toast_success_cat: "¡Categoría creada con éxito!",
1097
+ toast_success_subcat: "¡Subcategoría creada con éxito!",
1098
+
1099
+ // Cards Dashboard
1100
+ cards_title: "Tarjetas de Crédito",
1101
+ cards_subtitle: "Gestione tarjetas de crédito, límites y facturas",
1102
+ card_bill_details: "Detalle de Factura",
1103
+ btn_pay_bill: "Pagar Factura",
1104
+ btn_revert_payment: "Revertir Pago",
1105
+ bill_status: "Estado de la Factura:",
1106
+ status_open: "Abierta",
1107
+ status_closed: "Cerrada",
1108
+ status_paid: "Pagada",
1109
+ no_card_transactions: "Ninguna transacción registrada en esta factura para el ciclo seleccionado.",
1110
+
1111
+ // Dashboards Manager Dashboard
1112
+ dashboards_title: "Gestor de Dashboards",
1113
+ dashboards_subtitle: "Liste, vea el código fuente y suba dashboards al servidor de patty",
1114
+ col_dashboard: "Dashboard",
1115
+ col_last_update: "Última Actualización",
1116
+ btn_view_source: "Ver Código",
1117
+ btn_download: "Descargar HTML",
1118
+ upload_new_dashboard: "Subir Nuevo Dashboard",
1119
+ placeholder_dashboard_name: "Nombre del Dashboard (ej: pending)",
1120
+ upload_instructions: "Seleccione o arrastre el archivo HTML aquí para subir",
1121
+ btn_upload: "Subir Dashboard",
1122
+ modal_source_title: "Código Fuente HTML",
1123
+
1124
+ // Tags Management
1125
+ menu_tags: "Etiquetas",
1126
+ tags_title: "Administrar Etiquetas",
1127
+ tags_subtitle: "Administre las etiquetas utilizadas para etiquetar y organizar sus transacciones",
1128
+ panel_title_tags: "Etiquetas Activas",
1129
+ btn_new_tag: "Nueva Etiqueta",
1130
+ label_tag_name: "Nombre de la Etiqueta",
1131
+ placeholder_tag_name: "Ej: trabajo, viaje, reembolso",
1132
+ empty_tags_message: "No hay etiquetas registradas.",
1133
+ btn_save: "Guardar",
1134
+ btn_cancel: "Cancelar",
1135
+ toast_success_tag_created: '¡Etiqueta "{name}" creada con éxito!',
1136
+ toast_success_tag_deleted: '¡Etiqueta "{name}" eliminada con éxito!',
1137
+ confirm_delete_tag: '¿Realmente deseja eliminar la etiqueta "{name}"?\n(Esta acción eliminará la etiqueta de todas las transacciones vinculadas)'
1138
+ }
1139
+ };
1140
+
1141
+ var currentLocale = 'en'; // English as default
1142
+
1143
+ // Helper to translate in JS
1144
+ function t(key) {
1145
+ const tDict = TRANSLATIONS[currentLocale] || TRANSLATIONS['en'];
1146
+ return tDict[key] || key;
1147
+ }
1148
+
1149
+ async function checkLocale() {
1150
+ try {
1151
+ const res = await fetch('/api/status');
1152
+ if (res.ok) {
1153
+ const data = await res.json();
1154
+ if (data.locale && TRANSLATIONS[data.locale]) {
1155
+ currentLocale = data.locale;
1156
+ }
1157
+ }
1158
+ } catch (err) {
1159
+ console.error("Failed to read locale preferences:", err);
1160
+ }
1161
+ translatePage();
1162
+ }
1163
+
1164
+ function translatePage() {
1165
+ const tDict = TRANSLATIONS[currentLocale] || TRANSLATIONS['en'];
1166
+
1167
+ // 1. Static texts
1168
+ document.querySelectorAll('[data-i18n]').forEach(el => {
1169
+ const key = el.getAttribute('data-i18n');
1170
+ if (tDict[key]) {
1171
+ const icon = el.querySelector('i');
1172
+ if (icon) {
1173
+ const iconOuter = icon.outerHTML;
1174
+ el.innerHTML = iconOuter + ' ' + tDict[key];
1175
+ } else {
1176
+ el.textContent = tDict[key];
1177
+ }
1178
+ }
1179
+ });
1180
+
1181
+ // 2. Placeholders
1182
+ document.querySelectorAll('[data-i18n-placeholder]').forEach(el => {
1183
+ const key = el.getAttribute('data-i18n-placeholder');
1184
+ if (tDict[key]) {
1185
+ el.placeholder = tDict[key];
1186
+ }
1187
+ });
1188
+
1189
+ // 3. Tooltips
1190
+ document.querySelectorAll('[data-i18n-tooltip]').forEach(el => {
1191
+ const key = el.getAttribute('data-i18n-tooltip');
1192
+ if (tDict[key]) {
1193
+ el.setAttribute('data-tooltip', tDict[key]);
1194
+ }
1195
+ });
1196
+
1197
+ // 4. Document title translation
1198
+ if (tDict['overview_title'] && document.title.includes("Overview") || document.title.includes("Visão")) {
1199
+ // dynamic title update fallback if needed
1200
+ }
1201
+
1202
+ // 5. Translate select months
1203
+ const monthSelects = [
1204
+ document.getElementById('month-select'),
1205
+ document.getElementById('start-month-select')
1206
+ ];
1207
+ monthSelects.forEach(monthSelect => {
1208
+ if (monthSelect) {
1209
+ const monthKeys = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
1210
+ Array.from(monthSelect.options).forEach((opt, idx) => {
1211
+ const key = monthKeys[idx];
1212
+ if (tDict[key]) {
1213
+ opt.textContent = tDict[key];
1214
+ }
1215
+ });
1216
+ }
1217
+ });
1218
+
1219
+ // 6. Translate projection months select options (3, 6, 9, 12 months)
1220
+ const hmSelect = document.getElementById('heatmap-months-select');
1221
+ if (hmSelect) {
1222
+ Array.from(hmSelect.options).forEach(opt => {
1223
+ const val = opt.value;
1224
+ const key = `months_${val}`;
1225
+ if (tDict[key]) {
1226
+ opt.textContent = tDict[key];
1227
+ }
1228
+ });
1229
+ }
1230
+
1231
+ // Automatically initialize/refresh custom selects on all pages
1232
+ if (typeof initCustomSelects === 'function') {
1233
+ initCustomSelects();
1234
+ }
1235
+ }
1236
+
1237
+ // Custom Select Component implementation
1238
+ function initCustomSelects() {
1239
+ document.querySelectorAll('select.select-custom').forEach(select => {
1240
+ if (select.nextElementSibling && select.nextElementSibling.classList.contains('select-container-custom')) {
1241
+ // Already initialized, just sync selected value
1242
+ const container = select.nextElementSibling;
1243
+ const triggerSpan = container.querySelector('.select-trigger-custom span');
1244
+ const selectedOpt = select.options[select.selectedIndex];
1245
+ if (selectedOpt && triggerSpan) {
1246
+ triggerSpan.textContent = selectedOpt.textContent;
1247
+ }
1248
+ return;
1249
+ }
1250
+ select.style.display = 'none';
1251
+ const container = document.createElement('div');
1252
+ container.className = 'select-container-custom';
1253
+
1254
+ // Match specific element custom min-widths
1255
+ if (select.id === 'heatmap-months-select') {
1256
+ container.style.minWidth = '110px';
1257
+ } else if (select.id === 'year-select') {
1258
+ container.style.minWidth = '90px';
1259
+ } else if (select.id === 'filter-type') {
1260
+ container.style.minWidth = '130px';
1261
+ }
1262
+
1263
+ const trigger = document.createElement('div');
1264
+ trigger.className = 'select-trigger-custom';
1265
+ const triggerSpan = document.createElement('span');
1266
+ trigger.appendChild(triggerSpan);
1267
+ container.appendChild(trigger);
1268
+ const optionsContainer = document.createElement('div');
1269
+ optionsContainer.className = 'select-options-custom';
1270
+ container.appendChild(optionsContainer);
1271
+
1272
+ function syncSelected() {
1273
+ const selectedOpt = select.options[select.selectedIndex] || select.options[0];
1274
+ if (selectedOpt) {
1275
+ triggerSpan.textContent = selectedOpt.textContent;
1276
+ Array.from(optionsContainer.children).forEach(child => {
1277
+ if (child.getAttribute('data-value') === select.value) {
1278
+ child.classList.add('selected');
1279
+ } else {
1280
+ child.classList.remove('selected');
1281
+ }
1282
+ });
1283
+ }
1284
+ }
1285
+
1286
+ function populateOptions() {
1287
+ optionsContainer.innerHTML = '';
1288
+ Array.from(select.options).forEach(opt => {
1289
+ const optDiv = document.createElement('div');
1290
+ optDiv.className = 'select-option-custom';
1291
+ optDiv.textContent = opt.textContent;
1292
+ optDiv.setAttribute('data-value', opt.value);
1293
+ optDiv.addEventListener('click', (e) => {
1294
+ e.stopPropagation();
1295
+ select.value = opt.value;
1296
+ select.dispatchEvent(new Event('change'));
1297
+ syncSelected();
1298
+ container.classList.remove('open');
1299
+ });
1300
+ optionsContainer.appendChild(optDiv);
1301
+ });
1302
+ }
1303
+
1304
+ populateOptions();
1305
+ syncSelected();
1306
+
1307
+ trigger.addEventListener('click', (e) => {
1308
+ e.stopPropagation();
1309
+ const isOpen = container.classList.contains('open');
1310
+ document.querySelectorAll('.select-container-custom').forEach(el => {
1311
+ el.classList.remove('open');
1312
+ });
1313
+ if (!isOpen) {
1314
+ populateOptions();
1315
+ syncSelected();
1316
+ container.classList.add('open');
1317
+ setTimeout(() => {
1318
+ const selectedEl = optionsContainer.querySelector('.select-option-custom.selected');
1319
+ if (selectedEl) {
1320
+ const itemHeight = selectedEl.offsetHeight || 36;
1321
+ optionsContainer.scrollTop = Math.max(0, selectedEl.offsetTop - itemHeight);
1322
+ }
1323
+ }, 10);
1324
+ }
1325
+ });
1326
+
1327
+ select.parentNode.insertBefore(container, select.nextSibling);
1328
+ select.addEventListener('change', syncSelected);
1329
+
1330
+ // Watch for dynamic options updates
1331
+ const observer = new MutationObserver(() => {
1332
+ syncSelected();
1333
+ });
1334
+ observer.observe(select, { childList: true, subtree: true });
1335
+
1336
+ setTimeout(syncSelected, 200);
1337
+ setTimeout(syncSelected, 1000);
1338
+ });
1339
+
1340
+ // Global click listener to close options dropdowns when clicking outside
1341
+ if (!window.customSelectGlobalBound) {
1342
+ window.customSelectGlobalBound = true;
1343
+ document.addEventListener('click', () => {
1344
+ document.querySelectorAll('.select-container-custom').forEach(el => {
1345
+ el.classList.remove('open');
1346
+ });
1347
+ });
1348
+ }
1349
+ }
1350
+
1351
+ loadTagsData();
1352
+ checkLocale();
1353
+
1354
+ // ADR-027 Live-update listener
1355
+ window.onAppDataChanged = function(entities) {
1356
+ var affected = entities.some(function(tag) {
1357
+ return ['tag'].indexOf(tag) !== -1;
1358
+ });
1359
+ if (affected) {
1360
+ console.log("tags refetching due to entity change:", entities);
1361
+ loadTagsData();
1362
+ }
1363
+ };
1364
+
1365
+ </script>