calcsuite-react 1.1.0 → 1.1.2
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.
- package/CHANGELOG.md +13 -0
- package/README.md +3 -0
- package/dist/calcsuite.js +725 -707
- package/dist/settings/SettingsContext.d.ts +3 -1
- package/package.json +1 -1
- package/src/theme.css +4 -4
package/dist/calcsuite.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var ge = (e, t, n) =>
|
|
1
|
+
var pa = Object.defineProperty;
|
|
2
|
+
var ha = (e, t, n) => t in e ? pa(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var ge = (e, t, n) => ha(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsx as o, jsxs as b, Fragment as re } from "react/jsx-runtime";
|
|
5
|
-
import { useState as M, useCallback as ke, useMemo as
|
|
6
|
-
import
|
|
7
|
-
const
|
|
5
|
+
import { useState as M, useCallback as ke, useMemo as X, useContext as fa, createContext as ya, useRef as de, useEffect as Q, Fragment as xn, useSyncExternalStore as ba } from "react";
|
|
6
|
+
import mt from "decimal.js";
|
|
7
|
+
const ga = {
|
|
8
8
|
money: 2,
|
|
9
9
|
rate: 6,
|
|
10
10
|
period: 4,
|
|
@@ -13,7 +13,7 @@ const ba = {
|
|
|
13
13
|
instalment: "none",
|
|
14
14
|
residualAbsorption: "last"
|
|
15
15
|
}, qt = {
|
|
16
|
-
rounding:
|
|
16
|
+
rounding: ga,
|
|
17
17
|
ui: {
|
|
18
18
|
theme: "system",
|
|
19
19
|
accent: "#078DEE",
|
|
@@ -29,7 +29,7 @@ const ba = {
|
|
|
29
29
|
persistence: { driver: "localStorage", namespace: "calcsuite", historyLimit: 100 },
|
|
30
30
|
features: { integrationPanel: !1, beta: !1 }
|
|
31
31
|
};
|
|
32
|
-
function
|
|
32
|
+
function xt(e) {
|
|
33
33
|
return e === "US" ? {
|
|
34
34
|
...qt,
|
|
35
35
|
region: "US",
|
|
@@ -68,13 +68,13 @@ function Nt(e) {
|
|
|
68
68
|
defaults: { tenureUnit: "both", rateType: "floating", maxRatePercent: 50, sipReturnPercent: "12", inflationPercent: "6" }
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
const
|
|
71
|
+
const Xe = xt("IN"), H = mt.clone({
|
|
72
72
|
precision: 40,
|
|
73
|
-
rounding:
|
|
73
|
+
rounding: mt.ROUND_HALF_UP,
|
|
74
74
|
toExpPos: 60,
|
|
75
75
|
toExpNeg: -60,
|
|
76
|
-
modulo:
|
|
77
|
-
}), g = (e) => new H(e),
|
|
76
|
+
modulo: mt.ROUND_DOWN
|
|
77
|
+
}), g = (e) => new H(e), us = (e, t) => g(e).eq(t), ds = (e, t) => g(e).gt(t), ms = (e, t) => g(e).lt(t), ce = (e, t = "1e-9") => e.abs().lt(t), va = {
|
|
78
78
|
HALF_UP: H.ROUND_HALF_UP,
|
|
79
79
|
HALF_EVEN: H.ROUND_HALF_EVEN,
|
|
80
80
|
HALF_DOWN: H.ROUND_HALF_DOWN,
|
|
@@ -83,7 +83,7 @@ const Ze = Nt("IN"), H = ut.clone({
|
|
|
83
83
|
CEIL: H.ROUND_CEIL,
|
|
84
84
|
FLOOR: H.ROUND_FLOOR
|
|
85
85
|
};
|
|
86
|
-
function
|
|
86
|
+
function ka(e) {
|
|
87
87
|
switch (e.numberFormat.grouping) {
|
|
88
88
|
case "indian":
|
|
89
89
|
return "en-IN";
|
|
@@ -98,7 +98,7 @@ function va(e) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
function Sn(e) {
|
|
101
|
-
const t =
|
|
101
|
+
const t = va[e.rounding.mode], n = (l, p = e.numberFormat.decimalPlaces) => g(l).toDecimalPlaces(p, t), a = (l, p) => e.numberFormat.grouping === "plain" ? l.toFixed(p) : new Intl.NumberFormat(ka(e), {
|
|
102
102
|
minimumFractionDigits: e.numberFormat.trimTrailingZeros ? 0 : p,
|
|
103
103
|
maximumFractionDigits: p
|
|
104
104
|
}).format(l), r = (l, p) => l ? e.numberFormat.negativeFormat === "parentheses" ? `(${p})` : `-${p}` : p, s = (l) => {
|
|
@@ -122,67 +122,98 @@ function Sn(e) {
|
|
|
122
122
|
};
|
|
123
123
|
return { settings: e, money: m, moneyParts: d, num: i, pct: (l, p = e.numberFormat.percentPlaces) => `${i(l, p)}%`, compact: u, round: n };
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function pt(e) {
|
|
126
126
|
const t = Math.floor(e / 12), n = e % 12, a = [];
|
|
127
127
|
return t && a.push(`${t} yr`), n && a.push(`${n} mo`), a.join(" ") || "0 mo";
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
|
|
129
|
+
const wa = [
|
|
130
|
+
{ id: "default", label: "Green", main: "#00A76F", light: "#2CCF8E", dark: "#087055", ink: "#06251A" },
|
|
131
|
+
{ id: "cyan", label: "Cyan", main: "#078DEE", light: "#68CDF9", dark: "#0351AB", ink: "#FFFFFF" },
|
|
132
|
+
{ id: "purple", label: "Purple", main: "#7635DC", light: "#B985F4", dark: "#431A9E", ink: "#FFFFFF" },
|
|
133
|
+
{ id: "blue", label: "Blue", main: "#2065D1", light: "#76B0F1", dark: "#103996", ink: "#FFFFFF" },
|
|
134
|
+
{ id: "orange", label: "Orange", main: "#FDA92D", light: "#FED680", dark: "#B66816", ink: "#212B36" },
|
|
135
|
+
{ id: "gray", label: "Gray", main: "#A4AAB3", light: "#CED1D7", dark: "#63686C", ink: "#FFFFFF" }
|
|
136
|
+
], ze = "-apple-system, 'Segoe UI', system-ui, sans-serif", Cn = [
|
|
137
|
+
{ id: "Inter Tight", label: "Inter Tight", stack: `'Inter Tight', ${ze}` },
|
|
138
|
+
{ id: "Public Sans", label: "Public Sans", stack: `'Public Sans', ${ze}` },
|
|
139
|
+
{ id: "system-ui", label: "System UI", stack: `system-ui, ${ze}` },
|
|
140
|
+
{ id: "Georgia", label: "Georgia (serif)", stack: "Georgia, 'Times New Roman', serif" }
|
|
141
|
+
], Na = (e) => {
|
|
142
|
+
var t;
|
|
143
|
+
return ((t = Cn.find((n) => n.id === e)) == null ? void 0 : t.stack) ?? `'${e}', ${ze}`;
|
|
144
|
+
}, Pn = ya(null), Tn = "calcsuite:settings";
|
|
145
|
+
function Qe(e, t) {
|
|
131
146
|
if (t == null) return e;
|
|
132
147
|
const n = Array.isArray(e) ? [...e] : { ...e };
|
|
133
148
|
for (const a of Object.keys(t)) {
|
|
134
149
|
const r = t[a], s = e[a];
|
|
135
|
-
n[a] = r && typeof r == "object" && !Array.isArray(r) && s && typeof s == "object" ?
|
|
150
|
+
n[a] = r && typeof r == "object" && !Array.isArray(r) && s && typeof s == "object" ? Qe(s, r) : r;
|
|
136
151
|
}
|
|
137
152
|
return n;
|
|
138
153
|
}
|
|
139
|
-
function
|
|
154
|
+
function xa(e) {
|
|
155
|
+
const t = e ? Qe(Xe, e) : Xe;
|
|
140
156
|
try {
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
157
|
+
const n = localStorage.getItem(Tn);
|
|
158
|
+
if (n) return Qe(t, JSON.parse(n));
|
|
143
159
|
} catch {
|
|
144
160
|
}
|
|
145
|
-
return
|
|
161
|
+
return t;
|
|
146
162
|
}
|
|
147
|
-
function
|
|
163
|
+
function ht(e) {
|
|
148
164
|
try {
|
|
149
|
-
e.persistence.driver === "localStorage" && localStorage.setItem(
|
|
165
|
+
e.persistence.driver === "localStorage" && localStorage.setItem(Tn, JSON.stringify(e));
|
|
150
166
|
} catch {
|
|
151
167
|
}
|
|
152
168
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
169
|
+
function ps({
|
|
170
|
+
children: e,
|
|
171
|
+
settings: t
|
|
172
|
+
}) {
|
|
173
|
+
const [n, a] = M(() => xa(t)), r = ke((h) => {
|
|
174
|
+
a(h), ht(h);
|
|
175
|
+
}, []), s = ke((h) => a((f) => {
|
|
176
|
+
const y = Qe(f, h);
|
|
177
|
+
return ht(y), y;
|
|
178
|
+
}), []), u = ke((h) => {
|
|
179
|
+
a((f) => {
|
|
180
|
+
const w = { ...xt(h), ui: f.ui, compliance: f.compliance, persistence: f.persistence, features: f.features };
|
|
181
|
+
return ht(w), w;
|
|
163
182
|
});
|
|
164
|
-
}, []),
|
|
165
|
-
var
|
|
166
|
-
const
|
|
167
|
-
return
|
|
168
|
-
}, [
|
|
169
|
-
() => ({ settings:
|
|
170
|
-
[
|
|
183
|
+
}, []), m = ke(() => r(xt(n.region)), [r, n.region]), d = ke((h) => r(h), [r]), i = X(() => Sn(n), [n]), c = X(() => {
|
|
184
|
+
var f;
|
|
185
|
+
const h = n.ui.theme;
|
|
186
|
+
return h === "system" ? (f = window.matchMedia) != null && f.call(window, "(prefers-color-scheme: dark)").matches ? "dark" : "light" : h;
|
|
187
|
+
}, [n.ui.theme]), l = X(
|
|
188
|
+
() => ({ settings: n, fmt: i, update: s, setRegion: u, reset: m, replace: d, resolvedTheme: c }),
|
|
189
|
+
[n, i, s, u, m, d, c]
|
|
190
|
+
), p = X(
|
|
191
|
+
() => ({ display: "contents", "--fc-accent": n.ui.accent, "--fc-font-ui": Na(n.ui.fontFamily) }),
|
|
192
|
+
[n.ui.accent, n.ui.fontFamily]
|
|
171
193
|
);
|
|
172
|
-
return /* @__PURE__ */ o(
|
|
194
|
+
return /* @__PURE__ */ o(Pn.Provider, { value: l, children: /* @__PURE__ */ o(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
"data-fincalc-root": "",
|
|
198
|
+
"data-theme": c === "highContrast" ? "dark" : c,
|
|
199
|
+
"data-density": n.ui.density,
|
|
200
|
+
style: p,
|
|
201
|
+
children: e
|
|
202
|
+
}
|
|
203
|
+
) });
|
|
173
204
|
}
|
|
174
205
|
function ue() {
|
|
175
|
-
const e =
|
|
206
|
+
const e = fa(Pn);
|
|
176
207
|
if (!e) throw new Error("useSettings must be used within SettingsProvider");
|
|
177
208
|
return e;
|
|
178
209
|
}
|
|
179
|
-
let
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
},
|
|
185
|
-
function
|
|
210
|
+
let et = 0;
|
|
211
|
+
const Sa = () => {
|
|
212
|
+
et += 1;
|
|
213
|
+
}, Ca = () => {
|
|
214
|
+
et = Math.max(0, et - 1);
|
|
215
|
+
}, Pa = () => et > 0, Ta = 'a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
216
|
+
function Fa({
|
|
186
217
|
open: e,
|
|
187
218
|
onClose: t,
|
|
188
219
|
children: n,
|
|
@@ -191,11 +222,11 @@ function Ca({
|
|
|
191
222
|
}) {
|
|
192
223
|
const s = de(null), u = de(null), m = ke(() => {
|
|
193
224
|
const h = s.current;
|
|
194
|
-
return h ? Array.from(h.querySelectorAll(
|
|
225
|
+
return h ? Array.from(h.querySelectorAll(Ta)).filter(
|
|
195
226
|
(f) => !f.hasAttribute("disabled") && f.getAttribute("aria-hidden") !== "true"
|
|
196
227
|
) : [];
|
|
197
228
|
}, []), [d, i] = M(e), [c, l] = M(!1);
|
|
198
|
-
|
|
229
|
+
Q(() => {
|
|
199
230
|
if (e)
|
|
200
231
|
i(!0), l(!1);
|
|
201
232
|
else if (d) {
|
|
@@ -205,7 +236,7 @@ function Ca({
|
|
|
205
236
|
}, 210);
|
|
206
237
|
return () => clearTimeout(h);
|
|
207
238
|
}
|
|
208
|
-
}, [e]),
|
|
239
|
+
}, [e]), Q(() => {
|
|
209
240
|
if (!e) return;
|
|
210
241
|
const h = s.current;
|
|
211
242
|
u.current = document.activeElement;
|
|
@@ -215,7 +246,7 @@ function Ca({
|
|
|
215
246
|
document.body.style.overflow = "hidden";
|
|
216
247
|
const w = (k) => {
|
|
217
248
|
if (k.key === "Escape") {
|
|
218
|
-
if (
|
|
249
|
+
if (Pa()) return;
|
|
219
250
|
k.preventDefault(), k.stopImmediatePropagation(), t();
|
|
220
251
|
return;
|
|
221
252
|
}
|
|
@@ -261,17 +292,17 @@ function be(e, t, n, a = !1) {
|
|
|
261
292
|
let m = s.times(u.minus(1)).div(r);
|
|
262
293
|
return a && (m = m.times(r.plus(1))), m;
|
|
263
294
|
}
|
|
264
|
-
function
|
|
295
|
+
function tt(e, t, n) {
|
|
265
296
|
return g(e).times(g(t).plus(1).pow(n));
|
|
266
297
|
}
|
|
267
|
-
function
|
|
298
|
+
function Fn(e, t, n, a = !1) {
|
|
268
299
|
const r = g(t), s = g(e);
|
|
269
300
|
if (ce(r)) return s.times(n);
|
|
270
301
|
const u = r.plus(1).pow(n);
|
|
271
302
|
let m = s.times(g(1).minus(u.pow(-1))).div(r);
|
|
272
303
|
return a && (m = m.times(r.plus(1))), m;
|
|
273
304
|
}
|
|
274
|
-
function
|
|
305
|
+
function Ia(e, t, n) {
|
|
275
306
|
return g(e).div(g(t).plus(1).pow(n));
|
|
276
307
|
}
|
|
277
308
|
function we(e, t, n, a = 0, r = !1) {
|
|
@@ -281,11 +312,11 @@ function we(e, t, n, a = 0, r = !1) {
|
|
|
281
312
|
let m = g(e).times(u).plus(a).times(s).div(u.minus(1));
|
|
282
313
|
return r && (m = m.div(s.plus(1))), m;
|
|
283
314
|
}
|
|
284
|
-
function
|
|
315
|
+
function Ra(e, t, n) {
|
|
285
316
|
const a = g(n), r = g(e), s = g(t);
|
|
286
317
|
return ce(a) ? r.div(s) : H.ln(s.div(s.minus(r.times(a)))).div(H.ln(a.plus(1)));
|
|
287
318
|
}
|
|
288
|
-
function
|
|
319
|
+
function ot(e, t = -0.9999, n = 100, a = 200) {
|
|
289
320
|
let r = g(t), s = g(n), u = e(r), m = e(s);
|
|
290
321
|
if (u.times(m).gt(0)) return null;
|
|
291
322
|
for (let d = 0; d < a; d++) {
|
|
@@ -302,42 +333,42 @@ function At(e, t) {
|
|
|
302
333
|
a = a.plus(g(t[r]).div(n.plus(1).pow(r)));
|
|
303
334
|
return a;
|
|
304
335
|
}
|
|
305
|
-
function
|
|
306
|
-
return
|
|
336
|
+
function In(e) {
|
|
337
|
+
return ot((t) => At(t, e));
|
|
307
338
|
}
|
|
308
|
-
const
|
|
309
|
-
function
|
|
339
|
+
const Ea = (e, t) => (Date.parse(t) - Date.parse(e)) / 864e5;
|
|
340
|
+
function Rn(e, t) {
|
|
310
341
|
const n = g(e), a = t[0].date;
|
|
311
342
|
let r = g(0);
|
|
312
343
|
for (const s of t) {
|
|
313
|
-
const u = g(
|
|
344
|
+
const u = g(Ea(a, s.date)).div(365);
|
|
314
345
|
r = r.plus(g(s.amount).div(n.plus(1).pow(u)));
|
|
315
346
|
}
|
|
316
347
|
return r;
|
|
317
348
|
}
|
|
318
|
-
function
|
|
349
|
+
function En(e) {
|
|
319
350
|
if (e.length < 2) return null;
|
|
320
351
|
const t = [...e].sort((n, a) => Date.parse(n.date) - Date.parse(a.date));
|
|
321
|
-
return
|
|
352
|
+
return ot((n) => Rn(n, t), -0.9999, 100);
|
|
322
353
|
}
|
|
323
|
-
function
|
|
354
|
+
function it(e, t, n) {
|
|
324
355
|
return g(t).div(e).pow(g(1).div(n)).minus(1);
|
|
325
356
|
}
|
|
326
|
-
const
|
|
357
|
+
const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
327
358
|
__proto__: null,
|
|
328
|
-
bisectRate:
|
|
329
|
-
cagr:
|
|
359
|
+
bisectRate: ot,
|
|
360
|
+
cagr: it,
|
|
330
361
|
fvAnnuity: be,
|
|
331
|
-
fvLump:
|
|
332
|
-
irr:
|
|
333
|
-
nper:
|
|
362
|
+
fvLump: tt,
|
|
363
|
+
irr: In,
|
|
364
|
+
nper: Ra,
|
|
334
365
|
npv: At,
|
|
335
366
|
periodic: J,
|
|
336
367
|
pmt: we,
|
|
337
|
-
pvAnnuity:
|
|
338
|
-
pvLump:
|
|
339
|
-
xirr:
|
|
340
|
-
xnpv:
|
|
368
|
+
pvAnnuity: Fn,
|
|
369
|
+
pvLump: Ia,
|
|
370
|
+
xirr: En,
|
|
371
|
+
xnpv: Rn
|
|
341
372
|
}, Symbol.toStringTag, { value: "Module" })), me = {
|
|
342
373
|
IN: {
|
|
343
374
|
region: "IN",
|
|
@@ -374,18 +405,18 @@ class se extends Error {
|
|
|
374
405
|
this.name = "FinCalcError", this.code = n, this.field = r;
|
|
375
406
|
}
|
|
376
407
|
}
|
|
377
|
-
const
|
|
378
|
-
function
|
|
408
|
+
const Ma = 2, te = (e) => e.toDecimalPlaces(Ma, H.ROUND_HALF_UP), St = (e) => e.div(100).div(12);
|
|
409
|
+
function Ct(e, t, n) {
|
|
379
410
|
if (ce(t)) return e.div(n);
|
|
380
411
|
const a = t.plus(1).pow(n);
|
|
381
412
|
return e.times(t).times(a).div(a.minus(1));
|
|
382
413
|
}
|
|
383
|
-
function
|
|
414
|
+
function $a(e, t, n) {
|
|
384
415
|
if (ce(t)) return e.times(n);
|
|
385
416
|
const a = t.plus(1).pow(n);
|
|
386
417
|
return e.times(a.minus(1)).div(t.times(a));
|
|
387
418
|
}
|
|
388
|
-
function
|
|
419
|
+
function Aa(e, t, n) {
|
|
389
420
|
if (ce(t)) return Math.ceil(e.div(n).toNumber());
|
|
390
421
|
const a = e.times(t);
|
|
391
422
|
if (n.lte(a))
|
|
@@ -402,7 +433,7 @@ function Gt(e, t, n, a) {
|
|
|
402
433
|
throw new se("RATE_OUT_OF_RANGE", "Payment is too low to repay this amount.", "payment");
|
|
403
434
|
let r = g(0), s = g(a);
|
|
404
435
|
for (let m = 0; m < 200; m++) {
|
|
405
|
-
const d = r.plus(s).div(2), i =
|
|
436
|
+
const d = r.plus(s).div(2), i = Ct(e, St(d), t);
|
|
406
437
|
if (ce(i.minus(n), "1e-8")) return d;
|
|
407
438
|
i.lt(n) ? r = d : s = d;
|
|
408
439
|
}
|
|
@@ -411,25 +442,25 @@ function Gt(e, t, n, a) {
|
|
|
411
442
|
throw new se("SOLVER_DID_NOT_CONVERGE", "Could not find a rate within the allowed range.", "rate");
|
|
412
443
|
return u;
|
|
413
444
|
}
|
|
414
|
-
function
|
|
445
|
+
function Da(e, t, n, a) {
|
|
415
446
|
const r = [];
|
|
416
447
|
let s = e, u = g(0);
|
|
417
448
|
for (let m = 1; m <= n; m++) {
|
|
418
|
-
const d = s, i =
|
|
449
|
+
const d = s, i = te(d.times(t));
|
|
419
450
|
let c, l;
|
|
420
|
-
if (m === n ? (c = d, l =
|
|
451
|
+
if (m === n ? (c = d, l = te(d.plus(i))) : (l = a, c = l.minus(i), c.gt(d) && (c = d, l = te(d.plus(i)))), s = d.minus(c), u = u.plus(i), r.push({
|
|
421
452
|
month: m,
|
|
422
|
-
openingBalance:
|
|
453
|
+
openingBalance: te(d),
|
|
423
454
|
payment: l,
|
|
424
|
-
principal:
|
|
455
|
+
principal: te(c),
|
|
425
456
|
interest: i,
|
|
426
|
-
closingBalance:
|
|
427
|
-
cumulativeInterest:
|
|
457
|
+
closingBalance: te(s),
|
|
458
|
+
cumulativeInterest: te(u)
|
|
428
459
|
}), s.lte(0)) break;
|
|
429
460
|
}
|
|
430
461
|
return r;
|
|
431
462
|
}
|
|
432
|
-
function
|
|
463
|
+
function La(e) {
|
|
433
464
|
const t = [];
|
|
434
465
|
for (const n of e) {
|
|
435
466
|
const a = Math.ceil(n.month / 12);
|
|
@@ -460,43 +491,43 @@ function Ie(e) {
|
|
|
460
491
|
const k = g(d).div(12);
|
|
461
492
|
if (s === "payment") {
|
|
462
493
|
const S = u.times(m).div(100).times(k);
|
|
463
|
-
i =
|
|
494
|
+
i = te(u.plus(S).div(d));
|
|
464
495
|
} else if (s === "principal")
|
|
465
496
|
u = i.times(d).div(g(1).plus(m.div(100).times(k)));
|
|
466
497
|
else throw s === "tenure" ? new se("MISSING_SOLVE_TARGET", "Flat-rate loans need an explicit tenure.", "tenureMonths") : new se("MISSING_SOLVE_TARGET", "Flat-rate loans need an explicit rate.", "annualRatePct");
|
|
467
498
|
c = Gt(u, d, i, t.maxRatePct), l = "Flat: interest = P × rate × years; EMI = (P + interest) / n";
|
|
468
499
|
} else {
|
|
469
|
-
const k = () =>
|
|
500
|
+
const k = () => St(m);
|
|
470
501
|
switch (s) {
|
|
471
502
|
case "payment":
|
|
472
|
-
i =
|
|
503
|
+
i = te(Ct(u, k(), d)), l = "PMT = P·r·(1+r)^n / ((1+r)^n − 1)";
|
|
473
504
|
break;
|
|
474
505
|
case "principal":
|
|
475
|
-
u =
|
|
506
|
+
u = $a(i, k(), d), l = "P = PMT·((1+r)^n − 1) / (r·(1+r)^n)";
|
|
476
507
|
break;
|
|
477
508
|
case "tenure":
|
|
478
|
-
d =
|
|
509
|
+
d = Aa(u, k(), i), l = "n = ln(PMT / (PMT − P·r)) / ln(1 + r)";
|
|
479
510
|
break;
|
|
480
511
|
case "rate":
|
|
481
512
|
m = Gt(u, d, i, t.maxRatePct), l = "solve r: PMT = P·r·(1+r)^n / ((1+r)^n − 1)";
|
|
482
513
|
break;
|
|
483
514
|
}
|
|
484
515
|
}
|
|
485
|
-
const p =
|
|
516
|
+
const p = St(m), h = n === "flat" ? i : te(Ct(u, p, d)), f = Da(u, p, d, h);
|
|
486
517
|
d = f.length;
|
|
487
518
|
const y = f.reduce((k, S) => k.plus(S.interest), g(0)), w = f.reduce((k, S) => k.plus(S.payment), g(0));
|
|
488
519
|
return {
|
|
489
520
|
solvedFor: s,
|
|
490
521
|
basis: n,
|
|
491
522
|
region: e.region,
|
|
492
|
-
principal:
|
|
523
|
+
principal: te(u),
|
|
493
524
|
annualRatePct: m.toDecimalPlaces(6, H.ROUND_HALF_UP),
|
|
494
525
|
tenureMonths: d,
|
|
495
526
|
payment: h,
|
|
496
|
-
totalInterest:
|
|
497
|
-
totalPayment:
|
|
527
|
+
totalInterest: te(y),
|
|
528
|
+
totalPayment: te(w),
|
|
498
529
|
schedule: f,
|
|
499
|
-
byYear:
|
|
530
|
+
byYear: La(f),
|
|
500
531
|
chart: {
|
|
501
532
|
balance: f.map((k) => k.closingBalance),
|
|
502
533
|
cumulativeInterest: f.map((k) => k.cumulativeInterest)
|
|
@@ -518,7 +549,7 @@ const C = (e, t = 0) => {
|
|
|
518
549
|
tone: n,
|
|
519
550
|
sub: a
|
|
520
551
|
}), U = (e) => e.toDecimalPlaces(2, H.ROUND_HALF_UP);
|
|
521
|
-
function
|
|
552
|
+
function Mn(e, t) {
|
|
522
553
|
const n = /* @__PURE__ */ new Map();
|
|
523
554
|
for (const r of e) {
|
|
524
555
|
const s = Math.ceil(r.month / 12), u = n.get(s);
|
|
@@ -536,7 +567,7 @@ function En(e, t) {
|
|
|
536
567
|
}
|
|
537
568
|
return a;
|
|
538
569
|
}
|
|
539
|
-
const
|
|
570
|
+
const $n = [
|
|
540
571
|
{
|
|
541
572
|
key: "count",
|
|
542
573
|
label: "How many loans",
|
|
@@ -547,19 +578,19 @@ const Mn = [
|
|
|
547
578
|
];
|
|
548
579
|
for (let e = 1; e <= 5; e++) {
|
|
549
580
|
const t = e <= 2, n = t ? void 0 : (a) => C(a.count, 2) >= e;
|
|
550
|
-
|
|
581
|
+
$n.push(
|
|
551
582
|
{ key: `p${e}`, label: `Loan ${e} amount`, kind: "money", prefix: "currency", default: e <= 2 ? "2500000" : "", optional: !t, showIf: n },
|
|
552
583
|
{ key: `r${e}`, label: `Loan ${e} rate`, kind: "percent", suffix: "%", default: e === 1 ? 9 : e === 2 ? 8.65 : "", optional: !t, showIf: n, labelByRegion: {} },
|
|
553
584
|
{ key: `t${e}`, label: `Loan ${e} tenure`, kind: "tenure", default: 240, optional: !t, showIf: n, labelByRegion: { US: `Loan ${e} term` } }
|
|
554
585
|
);
|
|
555
586
|
}
|
|
556
|
-
const
|
|
587
|
+
const Ua = {
|
|
557
588
|
id: "loan.compare",
|
|
558
589
|
group: "loans",
|
|
559
590
|
title: "Compare loans",
|
|
560
591
|
blurb: "Line up 2–5 loans and see which costs least over its full life.",
|
|
561
592
|
keywords: ["compare", "loan", "cheapest", "emi", "best offer"],
|
|
562
|
-
inputs:
|
|
593
|
+
inputs: $n,
|
|
563
594
|
compute(e, t) {
|
|
564
595
|
const n = me[t.region], a = Math.max(2, Math.min(5, C(e.count, 2))), r = [];
|
|
565
596
|
for (let l = 1; l <= a; l++) {
|
|
@@ -597,7 +628,7 @@ const Aa = {
|
|
|
597
628
|
raw: i
|
|
598
629
|
};
|
|
599
630
|
}
|
|
600
|
-
},
|
|
631
|
+
}, Oa = {
|
|
601
632
|
id: "loan.prepay",
|
|
602
633
|
group: "loans",
|
|
603
634
|
title: "Prepayment impact",
|
|
@@ -666,7 +697,7 @@ const Aa = {
|
|
|
666
697
|
schedule: {
|
|
667
698
|
title: "New amortisation",
|
|
668
699
|
columns: ["Month", "Principal", "Interest", "Prepay", "Balance"],
|
|
669
|
-
groups:
|
|
700
|
+
groups: Mn(w, t),
|
|
670
701
|
toneCols: { 1: "principal", 2: "interest" }
|
|
671
702
|
},
|
|
672
703
|
notes: B,
|
|
@@ -681,7 +712,7 @@ const Aa = {
|
|
|
681
712
|
}
|
|
682
713
|
};
|
|
683
714
|
}
|
|
684
|
-
},
|
|
715
|
+
}, Ba = {
|
|
685
716
|
id: "loan.transfer",
|
|
686
717
|
group: "loans",
|
|
687
718
|
title: "Balance transfer",
|
|
@@ -725,7 +756,7 @@ const Aa = {
|
|
|
725
756
|
}
|
|
726
757
|
};
|
|
727
758
|
}
|
|
728
|
-
},
|
|
759
|
+
}, _a = {
|
|
729
760
|
id: "loan.eligibility",
|
|
730
761
|
group: "loans",
|
|
731
762
|
title: "Loan eligibility",
|
|
@@ -766,7 +797,7 @@ const Aa = {
|
|
|
766
797
|
}
|
|
767
798
|
const d = [];
|
|
768
799
|
let i = g(0);
|
|
769
|
-
return u.gt(0) ? i = U(
|
|
800
|
+
return u.gt(0) ? i = U(Fn(u, s, r)) : d.push("Existing obligations already use up the allowed share of income — no additional loan capacity."), {
|
|
770
801
|
primary: v("Eligible loan amount", t.fmt.money(i), "positive"),
|
|
771
802
|
secondary: m,
|
|
772
803
|
formula: t.region === "US" ? "EMI = min(income·frontDTI, income·backDTI − debts); P = PV of that annuity" : "EMI = income·FOIR − existingEMI; P = PV of that annuity",
|
|
@@ -777,7 +808,7 @@ const Aa = {
|
|
|
777
808
|
}
|
|
778
809
|
};
|
|
779
810
|
}
|
|
780
|
-
},
|
|
811
|
+
}, Ha = {
|
|
781
812
|
id: "loan.stepEmi",
|
|
782
813
|
group: "loans",
|
|
783
814
|
title: "Step-up / step-down EMI",
|
|
@@ -794,7 +825,7 @@ const Aa = {
|
|
|
794
825
|
let S = a;
|
|
795
826
|
for (let F = 1; F <= s; F++) S = S.plus(S.times(m)).minus(k.times(d(F)));
|
|
796
827
|
return S;
|
|
797
|
-
}, c = U(
|
|
828
|
+
}, c = U(ot((k) => i(k), 0, a.toNumber(), 200) ?? we(a, m, s)), l = [];
|
|
798
829
|
let p = a, h = g(0), f = c;
|
|
799
830
|
for (let k = 1; k <= s && p.gt("0.005"); k++) {
|
|
800
831
|
const S = U(p.times(m));
|
|
@@ -814,7 +845,7 @@ const Aa = {
|
|
|
814
845
|
schedule: {
|
|
815
846
|
title: "Amortisation",
|
|
816
847
|
columns: ["Month", "Principal", "Interest", n.paymentLabel, "Balance"],
|
|
817
|
-
groups:
|
|
848
|
+
groups: Mn(l, t),
|
|
818
849
|
toneCols: { 1: "principal", 2: "interest" }
|
|
819
850
|
},
|
|
820
851
|
notes: [`EMI changes by ${t.fmt.pct(g(C(e.annualStepPct)))} every 12 months. A step-up starts lower and pays a little more interest than a flat EMI; a step-down does the reverse.`],
|
|
@@ -828,7 +859,7 @@ const Aa = {
|
|
|
828
859
|
}
|
|
829
860
|
};
|
|
830
861
|
}
|
|
831
|
-
},
|
|
862
|
+
}, qa = {
|
|
832
863
|
id: "loan.moratorium",
|
|
833
864
|
group: "loans",
|
|
834
865
|
title: "Moratorium / EMI holiday",
|
|
@@ -883,7 +914,7 @@ const Aa = {
|
|
|
883
914
|
}
|
|
884
915
|
};
|
|
885
916
|
}
|
|
886
|
-
},
|
|
917
|
+
}, Ga = {
|
|
887
918
|
id: "loan.overdraft",
|
|
888
919
|
group: "loans",
|
|
889
920
|
title: "Overdraft / flexi loan",
|
|
@@ -913,7 +944,7 @@ const Aa = {
|
|
|
913
944
|
}
|
|
914
945
|
};
|
|
915
946
|
}
|
|
916
|
-
},
|
|
947
|
+
}, ja = {
|
|
917
948
|
id: "loan.refinance",
|
|
918
949
|
group: "loans",
|
|
919
950
|
title: "Refinance",
|
|
@@ -960,16 +991,16 @@ const Aa = {
|
|
|
960
991
|
}
|
|
961
992
|
};
|
|
962
993
|
}
|
|
963
|
-
},
|
|
964
|
-
Aa,
|
|
965
|
-
Da,
|
|
966
|
-
La,
|
|
994
|
+
}, Va = [
|
|
967
995
|
Ua,
|
|
968
996
|
Oa,
|
|
969
997
|
Ba,
|
|
970
998
|
_a,
|
|
971
|
-
Ha
|
|
972
|
-
|
|
999
|
+
Ha,
|
|
1000
|
+
qa,
|
|
1001
|
+
Ga,
|
|
1002
|
+
ja
|
|
1003
|
+
], st = Xe.defaults.sipReturnPercent, Ya = Xe.defaults.inflationPercent, lt = (e, t) => ({
|
|
973
1004
|
labels: e,
|
|
974
1005
|
series: [{ name: "Value", tone: "accent", points: t, area: !0 }]
|
|
975
1006
|
}), Dt = (e) => ({
|
|
@@ -979,7 +1010,7 @@ const Aa = {
|
|
|
979
1010
|
}), Lt = (e, t) => [
|
|
980
1011
|
{ label: "Invested", value: Number(e), tone: "principal" },
|
|
981
1012
|
{ label: "Gains", value: Number(t), tone: "interest" }
|
|
982
|
-
],
|
|
1013
|
+
], Ka = {
|
|
983
1014
|
id: "invest.sip",
|
|
984
1015
|
group: "invest",
|
|
985
1016
|
title: "SIP Calculator",
|
|
@@ -987,7 +1018,7 @@ const Aa = {
|
|
|
987
1018
|
keywords: ["sip", "systematic investment plan", "mutual fund", "monthly investment", "future value"],
|
|
988
1019
|
inputs: [
|
|
989
1020
|
{ key: "monthlyAmount", label: "Monthly investment", kind: "money", prefix: "currency", default: "10000" },
|
|
990
|
-
{ key: "expectedReturnPct", label: "Expected return", kind: "percent", suffix: "% p.a.", default:
|
|
1021
|
+
{ key: "expectedReturnPct", label: "Expected return", kind: "percent", suffix: "% p.a.", default: st },
|
|
991
1022
|
{ key: "tenure", label: "Investment period", kind: "tenure", default: 120 }
|
|
992
1023
|
],
|
|
993
1024
|
compute(e, t) {
|
|
@@ -1005,7 +1036,7 @@ const Aa = {
|
|
|
1005
1036
|
],
|
|
1006
1037
|
split: Lt(i.toFixed(2), c.toFixed(2)),
|
|
1007
1038
|
schedule: Dt(p),
|
|
1008
|
-
chart:
|
|
1039
|
+
chart: lt(p.map((f) => f.label), h),
|
|
1009
1040
|
formula: "FV = P·[((1+i)^n − 1) / i]·(1+i), i = r/12 (invested at the start of each month)",
|
|
1010
1041
|
notes: ["Returns are assumed constant; actual market returns vary year to year."],
|
|
1011
1042
|
raw: {
|
|
@@ -1016,7 +1047,7 @@ const Aa = {
|
|
|
1016
1047
|
}
|
|
1017
1048
|
};
|
|
1018
1049
|
}
|
|
1019
|
-
},
|
|
1050
|
+
}, Wa = {
|
|
1020
1051
|
id: "invest.stepupSip",
|
|
1021
1052
|
group: "invest",
|
|
1022
1053
|
title: "Step-up SIP Calculator",
|
|
@@ -1025,7 +1056,7 @@ const Aa = {
|
|
|
1025
1056
|
inputs: [
|
|
1026
1057
|
{ key: "monthlyAmount", label: "Initial monthly investment", kind: "money", prefix: "currency", default: "10000" },
|
|
1027
1058
|
{ key: "annualStepPct", label: "Annual step-up", kind: "percent", suffix: "%", default: "10" },
|
|
1028
|
-
{ key: "returnPct", label: "Expected return", kind: "percent", suffix: "% p.a.", default:
|
|
1059
|
+
{ key: "returnPct", label: "Expected return", kind: "percent", suffix: "% p.a.", default: st },
|
|
1029
1060
|
{ key: "tenure", label: "Investment period", kind: "tenure", default: 120 }
|
|
1030
1061
|
],
|
|
1031
1062
|
compute(e, t) {
|
|
@@ -1044,13 +1075,13 @@ const Aa = {
|
|
|
1044
1075
|
],
|
|
1045
1076
|
split: Lt(c.toFixed(2), f.toFixed(2)),
|
|
1046
1077
|
schedule: Dt(p),
|
|
1047
|
-
chart:
|
|
1078
|
+
chart: lt(p.map((y) => y.label), h),
|
|
1048
1079
|
formula: "Monthly simulation; the SIP amount is increased by the step-up % every 12 months",
|
|
1049
1080
|
notes: ["The monthly amount steps up on each yearly anniversary; returns are assumed constant."],
|
|
1050
1081
|
raw: { maturity: i.toFixed(2), invested: c.toFixed(2), gains: f.toFixed(2), finalMonthly: l.toFixed(2) }
|
|
1051
1082
|
};
|
|
1052
1083
|
}
|
|
1053
|
-
},
|
|
1084
|
+
}, za = { annual: 1, semiannual: 2, quarterly: 4, monthly: 12 }, Ja = {
|
|
1054
1085
|
id: "invest.lumpsum",
|
|
1055
1086
|
group: "invest",
|
|
1056
1087
|
title: "Lump Sum Calculator",
|
|
@@ -1058,7 +1089,7 @@ const Aa = {
|
|
|
1058
1089
|
keywords: ["lump sum", "lumpsum", "one time investment", "compound interest", "maturity"],
|
|
1059
1090
|
inputs: [
|
|
1060
1091
|
{ key: "principal", label: "Investment amount", kind: "money", prefix: "currency", default: "100000" },
|
|
1061
|
-
{ key: "ratePct", label: "Expected return", kind: "percent", suffix: "% p.a.", default:
|
|
1092
|
+
{ key: "ratePct", label: "Expected return", kind: "percent", suffix: "% p.a.", default: st },
|
|
1062
1093
|
{ key: "years", label: "Investment period", kind: "years", suffix: "years", default: 10 },
|
|
1063
1094
|
{
|
|
1064
1095
|
key: "compounding",
|
|
@@ -1074,7 +1105,7 @@ const Aa = {
|
|
|
1074
1105
|
}
|
|
1075
1106
|
],
|
|
1076
1107
|
compute(e, t) {
|
|
1077
|
-
const { D: n, fmt: a } = t, r = D(e.principal, "100000"), s = n(C(e.ratePct, Number(t.settings.defaults.sipReturnPercent))), u = Math.max(1, Math.round(C(e.years, 10))), m =
|
|
1108
|
+
const { D: n, fmt: a } = t, r = D(e.principal, "100000"), s = n(C(e.ratePct, Number(t.settings.defaults.sipReturnPercent))), u = Math.max(1, Math.round(C(e.years, 10))), m = za[_(e.compounding, "annual")] ?? 1, d = s.div(100).div(m), i = r.times(d.plus(1).pow(m * u)), c = i.minus(r), l = r.isZero() ? n(0) : it(r, i, u), p = [], h = [];
|
|
1078
1109
|
for (let f = 1; f <= u; f++) {
|
|
1079
1110
|
const y = r.times(d.plus(1).pow(m * f));
|
|
1080
1111
|
p.push({ label: String(f), cells: [a.money(r), a.money(y.minus(r)), a.money(y)] }), h.push(Number(y.toFixed(2)));
|
|
@@ -1088,13 +1119,13 @@ const Aa = {
|
|
|
1088
1119
|
],
|
|
1089
1120
|
split: Lt(r.toFixed(2), c.toFixed(2)),
|
|
1090
1121
|
schedule: Dt(p),
|
|
1091
|
-
chart:
|
|
1122
|
+
chart: lt(p.map((f) => f.label), h),
|
|
1092
1123
|
formula: "A = P·(1 + r/f)^(f·t)",
|
|
1093
1124
|
notes: ["Returns are assumed constant across the whole period."],
|
|
1094
1125
|
raw: { maturity: i.toFixed(2), invested: r.toFixed(2), gains: c.toFixed(2), cagr: l.times(100).toFixed(4) }
|
|
1095
1126
|
};
|
|
1096
1127
|
}
|
|
1097
|
-
},
|
|
1128
|
+
}, Za = 1200, Xa = {
|
|
1098
1129
|
id: "invest.swp",
|
|
1099
1130
|
group: "invest",
|
|
1100
1131
|
title: "SWP Calculator",
|
|
@@ -1107,7 +1138,7 @@ const Aa = {
|
|
|
1107
1138
|
{ key: "tenureMonths", label: "Withdrawal period", kind: "tenure", default: 120, optional: !0 }
|
|
1108
1139
|
],
|
|
1109
1140
|
compute(e, t) {
|
|
1110
|
-
const { D: n, fmt: a } = t, r = D(e.corpus, "5000000"), s = D(e.withdrawalPerMonth, "30000"), u = C(e.expectedReturnPct, 8), m = J(u, 12), d = C(e.tenureMonths, 0), i = d > 0 ? Math.round(d) :
|
|
1141
|
+
const { D: n, fmt: a } = t, r = D(e.corpus, "5000000"), s = D(e.withdrawalPerMonth, "30000"), u = C(e.expectedReturnPct, 8), m = J(u, 12), d = C(e.tenureMonths, 0), i = d > 0 ? Math.round(d) : Za;
|
|
1111
1142
|
let c = r, l = n(0), p = 0;
|
|
1112
1143
|
const h = [], f = [];
|
|
1113
1144
|
let y = r, w = n(0);
|
|
@@ -1133,7 +1164,7 @@ const Aa = {
|
|
|
1133
1164
|
rows: h,
|
|
1134
1165
|
toneCols: { 2: "interest", 3: "principal" }
|
|
1135
1166
|
},
|
|
1136
|
-
chart:
|
|
1167
|
+
chart: lt(h.map((N) => N.label), f),
|
|
1137
1168
|
formula: "Each month: balance = balance·(1 + r/12) − withdrawal",
|
|
1138
1169
|
notes: [
|
|
1139
1170
|
S ? `The corpus is exhausted in month ${p}; the final withdrawal may be partial.` : "The corpus survives the whole withdrawal period; the remaining balance is shown.",
|
|
@@ -1146,7 +1177,7 @@ const Aa = {
|
|
|
1146
1177
|
}
|
|
1147
1178
|
};
|
|
1148
1179
|
}
|
|
1149
|
-
},
|
|
1180
|
+
}, Qa = {
|
|
1150
1181
|
id: "invest.goal",
|
|
1151
1182
|
group: "invest",
|
|
1152
1183
|
title: "Goal SIP Planner",
|
|
@@ -1155,12 +1186,12 @@ const Aa = {
|
|
|
1155
1186
|
inputs: [
|
|
1156
1187
|
{ key: "targetCorpus", label: "Today's cost of goal", kind: "money", prefix: "currency", default: "10000000" },
|
|
1157
1188
|
{ key: "years", label: "Years to goal", kind: "years", suffix: "years", default: 15 },
|
|
1158
|
-
{ key: "expectedReturnPct", label: "Expected return", kind: "percent", suffix: "% p.a.", default:
|
|
1159
|
-
{ key: "inflationPct", label: "Inflation", kind: "percent", suffix: "% p.a.", default:
|
|
1189
|
+
{ key: "expectedReturnPct", label: "Expected return", kind: "percent", suffix: "% p.a.", default: st },
|
|
1190
|
+
{ key: "inflationPct", label: "Inflation", kind: "percent", suffix: "% p.a.", default: Ya },
|
|
1160
1191
|
{ key: "existingSavings", label: "Existing savings", kind: "money", prefix: "currency", default: "0", optional: !0 }
|
|
1161
1192
|
],
|
|
1162
1193
|
compute(e, t) {
|
|
1163
|
-
const { D: n, fmt: a } = t, r = D(e.targetCorpus, "10000000"), s = Math.max(1, Math.round(C(e.years, 15))), u = C(e.expectedReturnPct, Number(t.settings.defaults.sipReturnPercent)), m = n(C(e.inflationPct, Number(t.settings.defaults.inflationPercent))).div(100), d = D(e.existingSavings, "0"), i = s * 12, c = J(u, 12), l = r.times(m.plus(1).pow(s)), p =
|
|
1194
|
+
const { D: n, fmt: a } = t, r = D(e.targetCorpus, "10000000"), s = Math.max(1, Math.round(C(e.years, 15))), u = C(e.expectedReturnPct, Number(t.settings.defaults.sipReturnPercent)), m = n(C(e.inflationPct, Number(t.settings.defaults.inflationPercent))).div(100), d = D(e.existingSavings, "0"), i = s * 12, c = J(u, 12), l = r.times(m.plus(1).pow(s)), p = tt(d, c, i), h = l.minus(p), f = be(1, c, i, !0), y = h.gt(0) ? h.div(f) : n(0), w = y.times(i), k = h.gt(0) ? h.minus(w) : n(0), S = [
|
|
1164
1195
|
`Target grows with ${a.pct(m.times(100))} inflation to ${a.money(l)} in ${s} years.`
|
|
1165
1196
|
];
|
|
1166
1197
|
d.gt(0) && S.push(`Existing savings grow to ${a.money(p)}, reducing what the SIP must fund.`);
|
|
@@ -1184,14 +1215,14 @@ const Aa = {
|
|
|
1184
1215
|
}
|
|
1185
1216
|
};
|
|
1186
1217
|
}
|
|
1187
|
-
},
|
|
1218
|
+
}, er = [Ka, Wa, Ja, Xa, Qa], An = "10% TDS applies on interest above ₹40,000/yr (₹50,000 for senior citizens). Submit Form 15G/15H to waive if income is below the taxable limit.", Oe = (e, t, n) => ({
|
|
1188
1219
|
labels: e,
|
|
1189
1220
|
series: [{ name: n, tone: "accent", points: t, area: !0 }]
|
|
1190
1221
|
}), Be = (e, t, n) => ({
|
|
1191
1222
|
columns: e,
|
|
1192
1223
|
rows: t,
|
|
1193
1224
|
toneCols: { [n]: "interest" }
|
|
1194
|
-
}),
|
|
1225
|
+
}), tr = {
|
|
1195
1226
|
id: "invest.fd",
|
|
1196
1227
|
group: "invest",
|
|
1197
1228
|
title: "Fixed Deposit (FD)",
|
|
@@ -1252,7 +1283,7 @@ const Aa = {
|
|
|
1252
1283
|
formula: i ? "Interest/period = P·(r/f); principal returned at maturity" : "A = P·(1 + r/f)^(f·t)",
|
|
1253
1284
|
notes: [
|
|
1254
1285
|
i ? "Interest is paid out each period; the principal is returned at maturity." : "Interest is reinvested (compounded) and paid with the principal at maturity.",
|
|
1255
|
-
|
|
1286
|
+
An
|
|
1256
1287
|
],
|
|
1257
1288
|
raw: {
|
|
1258
1289
|
maturity: k.toFixed(2),
|
|
@@ -1263,7 +1294,7 @@ const Aa = {
|
|
|
1263
1294
|
}
|
|
1264
1295
|
};
|
|
1265
1296
|
}
|
|
1266
|
-
},
|
|
1297
|
+
}, nr = {
|
|
1267
1298
|
id: "invest.rd",
|
|
1268
1299
|
group: "invest",
|
|
1269
1300
|
title: "Recurring Deposit (RD)",
|
|
@@ -1304,12 +1335,12 @@ const Aa = {
|
|
|
1304
1335
|
schedule: Be(["Year", "Invested", "Interest", "Value"], p, 2),
|
|
1305
1336
|
chart: Oe(p.map((f) => f.label), h, "Value"),
|
|
1306
1337
|
formula: "M = Σ deposit·(1 + r/4)^(quarters remaining)",
|
|
1307
|
-
notes: ["Interest is compounded quarterly, the standard for bank recurring deposits.",
|
|
1338
|
+
notes: ["Interest is compounded quarterly, the standard for bank recurring deposits.", An],
|
|
1308
1339
|
warnings: d,
|
|
1309
1340
|
raw: { maturity: i.toFixed(2), invested: c.toFixed(2), interest: l.toFixed(2) }
|
|
1310
1341
|
};
|
|
1311
1342
|
}
|
|
1312
|
-
},
|
|
1343
|
+
}, ar = {
|
|
1313
1344
|
id: "invest.ppf",
|
|
1314
1345
|
group: "invest",
|
|
1315
1346
|
title: "Public Provident Fund (PPF)",
|
|
@@ -1366,7 +1397,7 @@ const Aa = {
|
|
|
1366
1397
|
raw: { maturity: i.toFixed(2), invested: p.toFixed(2), interest: h.toFixed(2) }
|
|
1367
1398
|
};
|
|
1368
1399
|
}
|
|
1369
|
-
},
|
|
1400
|
+
}, rr = {
|
|
1370
1401
|
id: "invest.nps",
|
|
1371
1402
|
group: "invest",
|
|
1372
1403
|
title: "National Pension System (NPS)",
|
|
@@ -1410,7 +1441,7 @@ const Aa = {
|
|
|
1410
1441
|
}
|
|
1411
1442
|
};
|
|
1412
1443
|
}
|
|
1413
|
-
},
|
|
1444
|
+
}, or = {
|
|
1414
1445
|
id: "invest.epf",
|
|
1415
1446
|
group: "invest",
|
|
1416
1447
|
title: "Employees’ Provident Fund (EPF)",
|
|
@@ -1459,7 +1490,7 @@ const Aa = {
|
|
|
1459
1490
|
raw: { corpus: h.toFixed(2), contributions: f.toFixed(2), interest: k.toFixed(2) }
|
|
1460
1491
|
};
|
|
1461
1492
|
}
|
|
1462
|
-
},
|
|
1493
|
+
}, ir = {
|
|
1463
1494
|
id: "invest.ssy",
|
|
1464
1495
|
group: "invest",
|
|
1465
1496
|
title: "Sukanya Samriddhi Yojana (SSY)",
|
|
@@ -1502,7 +1533,7 @@ const Aa = {
|
|
|
1502
1533
|
raw: { maturity: l.toFixed(2), invested: f.toFixed(2), interest: y.toFixed(2) }
|
|
1503
1534
|
};
|
|
1504
1535
|
}
|
|
1505
|
-
},
|
|
1536
|
+
}, sr = [tr, nr, ar, rr, or, ir], lr = {
|
|
1506
1537
|
id: "invest.401k",
|
|
1507
1538
|
group: "invest",
|
|
1508
1539
|
title: "401(k) with Employer Match",
|
|
@@ -1566,7 +1597,7 @@ const Aa = {
|
|
|
1566
1597
|
}
|
|
1567
1598
|
};
|
|
1568
1599
|
}
|
|
1569
|
-
},
|
|
1600
|
+
}, cr = {
|
|
1570
1601
|
id: "invest.iraCompare",
|
|
1571
1602
|
group: "invest",
|
|
1572
1603
|
title: "Roth vs Traditional IRA",
|
|
@@ -1620,7 +1651,7 @@ const Aa = {
|
|
|
1620
1651
|
}
|
|
1621
1652
|
};
|
|
1622
1653
|
}
|
|
1623
|
-
},
|
|
1654
|
+
}, ur = {
|
|
1624
1655
|
id: "invest.529",
|
|
1625
1656
|
group: "invest",
|
|
1626
1657
|
title: "529 College Savings",
|
|
@@ -1636,7 +1667,7 @@ const Aa = {
|
|
|
1636
1667
|
{ key: "collegeCostInflationPct", label: "College cost inflation", kind: "percent", suffix: "%", default: 5, advanced: !0 }
|
|
1637
1668
|
],
|
|
1638
1669
|
compute(e, t) {
|
|
1639
|
-
const { fmt: n } = t, a = g(C(e.currentSavings)), r = g(C(e.monthlyContribution)), s = Math.max(0, Math.round(C(e.yearsUntilCollege))), u = s * 12, m = J(C(e.expectedReturnPct), 12), d =
|
|
1670
|
+
const { fmt: n } = t, a = g(C(e.currentSavings)), r = g(C(e.monthlyContribution)), s = Math.max(0, Math.round(C(e.yearsUntilCollege))), u = s * 12, m = J(C(e.expectedReturnPct), 12), d = tt(a, m, u), i = be(r, m, u), c = d.plus(i), l = a.plus(r.times(u)), p = c.minus(l), h = [
|
|
1640
1671
|
v("Total invested", n.money(l), "principal"),
|
|
1641
1672
|
v("Investment growth", n.money(p), "interest")
|
|
1642
1673
|
], f = {
|
|
@@ -1650,7 +1681,7 @@ const Aa = {
|
|
|
1650
1681
|
const k = g(C(e.currentAnnualCost)), S = g(C(e.collegeCostInflationPct)).div(100);
|
|
1651
1682
|
let F = g(0);
|
|
1652
1683
|
for (let x = 0; x < 4; x++)
|
|
1653
|
-
F = F.plus(
|
|
1684
|
+
F = F.plus(tt(k, S, s + x));
|
|
1654
1685
|
const N = c.minus(F), P = N.gte(0);
|
|
1655
1686
|
h.push(v("4-year college cost", n.money(F), "default", "inflation-adjusted")), h.push(
|
|
1656
1687
|
v(
|
|
@@ -1675,7 +1706,7 @@ const Aa = {
|
|
|
1675
1706
|
raw: f
|
|
1676
1707
|
};
|
|
1677
1708
|
}
|
|
1678
|
-
},
|
|
1709
|
+
}, dr = [lr, cr, ur], mr = (e) => e === "annual" ? 1 : e === "semiannual" ? 2 : e === "quarterly" ? 4 : 12, ct = (e) => _(e).split(/[, ]+/).map((t) => t.trim()).filter(Boolean).map(Number).filter((t) => Number.isFinite(t)), pr = {
|
|
1679
1710
|
id: "returns.tvm",
|
|
1680
1711
|
group: "returns",
|
|
1681
1712
|
title: "Time value of money (TVM)",
|
|
@@ -1706,7 +1737,7 @@ const Aa = {
|
|
|
1706
1737
|
] }
|
|
1707
1738
|
],
|
|
1708
1739
|
compute(e) {
|
|
1709
|
-
const t = _(e.solveFor, "FV"), n =
|
|
1740
|
+
const t = _(e.solveFor, "FV"), n = mr(_(e.compounding, "monthly")), a = g(C(e.ratePct)).div(100).div(n), r = C(e.n), s = _(e.timing) === "begin", u = g(C(e.pv)), m = g(C(e.pmt)), d = g(C(e.fv)), i = (f, y) => ce(f) ? g(y) : f.plus(1).pow(y).minus(1).div(f).times(s ? f.plus(1) : 1), c = (f, y) => f.plus(1).pow(y);
|
|
1710
1741
|
let l = "Future value", p = g(0), h = "PV·(1+i)^n + PMT·[((1+i)^n − 1)/i]·timing + FV = 0";
|
|
1711
1742
|
if (t === "FV")
|
|
1712
1743
|
p = u.times(c(a, r)).plus(m.times(i(a, r))).neg(), l = "Future value";
|
|
@@ -1743,7 +1774,7 @@ const Aa = {
|
|
|
1743
1774
|
}
|
|
1744
1775
|
return { primary: v(l, p.toDecimalPlaces(2).toString(), "accent"), formula: h, raw: { value: p.toNumber() } };
|
|
1745
1776
|
}
|
|
1746
|
-
},
|
|
1777
|
+
}, hr = {
|
|
1747
1778
|
id: "returns.cagr",
|
|
1748
1779
|
group: "returns",
|
|
1749
1780
|
title: "CAGR",
|
|
@@ -1755,7 +1786,7 @@ const Aa = {
|
|
|
1755
1786
|
{ key: "years", label: "Period", kind: "years", default: "10" }
|
|
1756
1787
|
],
|
|
1757
1788
|
compute(e, t) {
|
|
1758
|
-
const n = t.D(C(e.begin)), a = t.D(C(e.end)), r = C(e.years) || 1, s =
|
|
1789
|
+
const n = t.D(C(e.begin)), a = t.D(C(e.end)), r = C(e.years) || 1, s = it(n, a, r).times(100), u = a.minus(n).div(n).times(100);
|
|
1759
1790
|
return {
|
|
1760
1791
|
primary: v("CAGR", `${t.fmt.num(s, 2)}%`, "accent"),
|
|
1761
1792
|
secondary: [
|
|
@@ -1766,7 +1797,7 @@ const Aa = {
|
|
|
1766
1797
|
raw: { cagr: s.toNumber(), absolute: u.toNumber() }
|
|
1767
1798
|
};
|
|
1768
1799
|
}
|
|
1769
|
-
},
|
|
1800
|
+
}, fr = {
|
|
1770
1801
|
id: "returns.absolute",
|
|
1771
1802
|
group: "returns",
|
|
1772
1803
|
title: "Absolute return",
|
|
@@ -1779,14 +1810,14 @@ const Aa = {
|
|
|
1779
1810
|
],
|
|
1780
1811
|
compute(e, t) {
|
|
1781
1812
|
const n = t.D(C(e.invested)), a = t.D(C(e.current)), r = a.minus(n).div(n).times(100), s = C(e.years), u = [v("Total gain", t.fmt.money(a.minus(n)), a.gte(n) ? "positive" : "negative")];
|
|
1782
|
-
return s > 0 && u.push(v("Annualised (CAGR)", `${t.fmt.num(
|
|
1813
|
+
return s > 0 && u.push(v("Annualised (CAGR)", `${t.fmt.num(it(n, a, s).times(100), 2)}%`)), {
|
|
1783
1814
|
primary: v("Absolute return", `${t.fmt.num(r, 2)}%`, "accent"),
|
|
1784
1815
|
secondary: u,
|
|
1785
1816
|
formula: "Absolute return = (Current − Invested) / Invested",
|
|
1786
1817
|
raw: { absolute: r.toNumber() }
|
|
1787
1818
|
};
|
|
1788
1819
|
}
|
|
1789
|
-
},
|
|
1820
|
+
}, yr = {
|
|
1790
1821
|
id: "returns.xirr",
|
|
1791
1822
|
group: "returns",
|
|
1792
1823
|
title: "XIRR",
|
|
@@ -1802,7 +1833,7 @@ const Aa = {
|
|
|
1802
1833
|
compute(e, t) {
|
|
1803
1834
|
const a = (e.flows ?? []).filter((u) => u.date && u.amount !== "").map((u) => ({ date: u.date, amount: u.amount }));
|
|
1804
1835
|
if (a.length < 2) return { primary: v("XIRR", "—"), warnings: ["Enter at least two dated cashflows."] };
|
|
1805
|
-
const r =
|
|
1836
|
+
const r = En(a);
|
|
1806
1837
|
if (!r) return { primary: v("XIRR", "—"), warnings: ["Need at least one negative and one positive cashflow."] };
|
|
1807
1838
|
const s = r.times(100);
|
|
1808
1839
|
return {
|
|
@@ -1811,7 +1842,7 @@ const Aa = {
|
|
|
1811
1842
|
raw: { xirr: s.toNumber() }
|
|
1812
1843
|
};
|
|
1813
1844
|
}
|
|
1814
|
-
},
|
|
1845
|
+
}, br = {
|
|
1815
1846
|
id: "returns.irr",
|
|
1816
1847
|
group: "returns",
|
|
1817
1848
|
title: "IRR",
|
|
@@ -1819,12 +1850,12 @@ const Aa = {
|
|
|
1819
1850
|
keywords: ["irr", "internal rate of return"],
|
|
1820
1851
|
inputs: [{ key: "series", label: "Cashflows (comma-separated, period 0 first)", kind: "text", default: "-100000, 30000, 40000, 50000, 40000", help: "-100000, 30000, ..." }],
|
|
1821
1852
|
compute(e, t) {
|
|
1822
|
-
const n =
|
|
1853
|
+
const n = ct(_(e.series));
|
|
1823
1854
|
if (n.length < 2) return { primary: v("IRR", "—"), warnings: ["Enter at least two cashflows."] };
|
|
1824
|
-
const a =
|
|
1855
|
+
const a = In(n);
|
|
1825
1856
|
return a ? { primary: v("IRR", `${t.fmt.num(a.times(100), 2)}%`, "accent"), formula: "IRR: rate where NPV = 0", raw: { irr: a.times(100).toNumber() } } : { primary: v("IRR", "—"), warnings: ["No sign change — IRR is undefined for these flows."] };
|
|
1826
1857
|
}
|
|
1827
|
-
},
|
|
1858
|
+
}, gr = {
|
|
1828
1859
|
id: "returns.npv",
|
|
1829
1860
|
group: "returns",
|
|
1830
1861
|
title: "NPV",
|
|
@@ -1835,7 +1866,7 @@ const Aa = {
|
|
|
1835
1866
|
{ key: "series", label: "Cashflows (comma-separated, period 0 first)", kind: "text", default: "-100000, 30000, 40000, 50000, 40000" }
|
|
1836
1867
|
],
|
|
1837
1868
|
compute(e, t) {
|
|
1838
|
-
const n =
|
|
1869
|
+
const n = ct(_(e.series)), a = At(g(C(e.ratePct)).div(100), n);
|
|
1839
1870
|
return {
|
|
1840
1871
|
primary: v("NPV", t.fmt.money(a), a.gte(0) ? "positive" : "negative"),
|
|
1841
1872
|
secondary: [v(a.gte(0) ? "Value-creating" : "Value-destroying", a.gte(0) ? "NPV ≥ 0" : "NPV < 0")],
|
|
@@ -1843,7 +1874,7 @@ const Aa = {
|
|
|
1843
1874
|
raw: { npv: a.toNumber() }
|
|
1844
1875
|
};
|
|
1845
1876
|
}
|
|
1846
|
-
},
|
|
1877
|
+
}, vr = {
|
|
1847
1878
|
id: "returns.mirr",
|
|
1848
1879
|
group: "returns",
|
|
1849
1880
|
title: "MIRR",
|
|
@@ -1855,7 +1886,7 @@ const Aa = {
|
|
|
1855
1886
|
{ key: "reinvestPct", label: "Reinvestment rate", kind: "percent", default: "12" }
|
|
1856
1887
|
],
|
|
1857
1888
|
compute(e, t) {
|
|
1858
|
-
const n =
|
|
1889
|
+
const n = ct(_(e.series)), a = n.length - 1;
|
|
1859
1890
|
if (a < 1) return { primary: v("MIRR", "—"), warnings: ["Enter at least two cashflows."] };
|
|
1860
1891
|
const r = g(C(e.financePct)).div(100), s = g(C(e.reinvestPct)).div(100);
|
|
1861
1892
|
let u = g(0), m = g(0);
|
|
@@ -1865,7 +1896,7 @@ const Aa = {
|
|
|
1865
1896
|
const d = u.div(m.neg()).pow(g(1).div(a)).minus(1).times(100);
|
|
1866
1897
|
return { primary: v("MIRR", `${t.fmt.num(d, 2)}%`, "accent"), formula: "MIRR = (FV(inflows@reinvest) / −PV(outflows@finance))^(1/n) − 1", raw: { mirr: d.toNumber() } };
|
|
1867
1898
|
}
|
|
1868
|
-
},
|
|
1899
|
+
}, kr = {
|
|
1869
1900
|
id: "returns.payback",
|
|
1870
1901
|
group: "returns",
|
|
1871
1902
|
title: "Payback period",
|
|
@@ -1877,7 +1908,7 @@ const Aa = {
|
|
|
1877
1908
|
{ key: "discountPct", label: "Discount rate (for discounted payback)", kind: "percent", default: "0", optional: !0, advanced: !0 }
|
|
1878
1909
|
],
|
|
1879
1910
|
compute(e, t) {
|
|
1880
|
-
const n = t.D(C(e.investment)), a =
|
|
1911
|
+
const n = t.D(C(e.investment)), a = ct(_(e.series)), r = g(C(e.discountPct)).div(100), s = r.gt(0);
|
|
1881
1912
|
let u = g(0), m = 0, d = null;
|
|
1882
1913
|
for (let i = 0; i < a.length; i++) {
|
|
1883
1914
|
const c = s ? g(a[i]).div(r.plus(1).pow(i + 1)) : g(a[i]), l = u;
|
|
@@ -1894,7 +1925,7 @@ const Aa = {
|
|
|
1894
1925
|
raw: { payback: d }
|
|
1895
1926
|
};
|
|
1896
1927
|
}
|
|
1897
|
-
},
|
|
1928
|
+
}, wr = {
|
|
1898
1929
|
id: "returns.realReturn",
|
|
1899
1930
|
group: "returns",
|
|
1900
1931
|
title: "Real (inflation-adjusted) return",
|
|
@@ -1913,7 +1944,7 @@ const Aa = {
|
|
|
1913
1944
|
raw: { real: r.toNumber() }
|
|
1914
1945
|
};
|
|
1915
1946
|
}
|
|
1916
|
-
},
|
|
1947
|
+
}, Nr = {
|
|
1917
1948
|
id: "returns.rule72",
|
|
1918
1949
|
group: "returns",
|
|
1919
1950
|
title: "Rule of 72",
|
|
@@ -1934,17 +1965,17 @@ const Aa = {
|
|
|
1934
1965
|
raw: { approx: a.toNumber(), exact: r.toNumber() }
|
|
1935
1966
|
};
|
|
1936
1967
|
}
|
|
1937
|
-
},
|
|
1938
|
-
ur,
|
|
1939
|
-
dr,
|
|
1940
|
-
mr,
|
|
1968
|
+
}, xr = [
|
|
1941
1969
|
pr,
|
|
1942
1970
|
hr,
|
|
1943
1971
|
fr,
|
|
1944
1972
|
yr,
|
|
1945
1973
|
br,
|
|
1946
1974
|
gr,
|
|
1947
|
-
vr
|
|
1975
|
+
vr,
|
|
1976
|
+
kr,
|
|
1977
|
+
wr,
|
|
1978
|
+
Nr
|
|
1948
1979
|
], Ne = "Estimate for planning only — not tax advice. Verify against current law and your own situation.";
|
|
1949
1980
|
function Ut(e, t, n) {
|
|
1950
1981
|
let a = g(0), r = 0;
|
|
@@ -1962,7 +1993,7 @@ function Ut(e, t, n) {
|
|
|
1962
1993
|
}
|
|
1963
1994
|
return { tax: a, rows: s };
|
|
1964
1995
|
}
|
|
1965
|
-
const
|
|
1996
|
+
const Sr = (e, t) => Ut(e, t, Cr).tax, Cr = { money: (e) => String(e) }, jt = (e, t) => e.gt(t) ? g(t) : e, ut = (e, t) => v(e, t, "positive"), Pr = {
|
|
1966
1997
|
id: "tax.gst",
|
|
1967
1998
|
group: "tax",
|
|
1968
1999
|
title: "GST Calculator",
|
|
@@ -2043,7 +2074,7 @@ const wr = (e, t) => Ut(e, t, Nr).tax, Nr = { money: (e) => String(e) }, jt = (e
|
|
|
2043
2074
|
}
|
|
2044
2075
|
};
|
|
2045
2076
|
}
|
|
2046
|
-
},
|
|
2077
|
+
}, Tr = {
|
|
2047
2078
|
id: "tax.tds",
|
|
2048
2079
|
group: "tax",
|
|
2049
2080
|
title: "TDS on Interest",
|
|
@@ -2077,7 +2108,7 @@ const wr = (e, t) => Ut(e, t, Nr).tax, Nr = { money: (e) => String(e) }, jt = (e
|
|
|
2077
2108
|
), {
|
|
2078
2109
|
primary: v("TDS deducted", n.money(p), p.gt(0) ? "negative" : "positive"),
|
|
2079
2110
|
secondary: [
|
|
2080
|
-
|
|
2111
|
+
ut("Net interest received", n.money(h)),
|
|
2081
2112
|
v("Effective TDS rate", n.pct(f), "accent"),
|
|
2082
2113
|
v("Applicable threshold", n.money(d), "default")
|
|
2083
2114
|
],
|
|
@@ -2090,7 +2121,7 @@ const wr = (e, t) => Ut(e, t, Nr).tax, Nr = { money: (e) => String(e) }, jt = (e
|
|
|
2090
2121
|
"<60": [{ to: 25e4, rate: 0 }, { to: 5e5, rate: 5 }, { to: 1e6, rate: 20 }, { to: 1 / 0, rate: 30 }],
|
|
2091
2122
|
"60-80": [{ to: 3e5, rate: 0 }, { to: 5e5, rate: 5 }, { to: 1e6, rate: 20 }, { to: 1 / 0, rate: 30 }],
|
|
2092
2123
|
"80+": [{ to: 5e5, rate: 0 }, { to: 1e6, rate: 20 }, { to: 1 / 0, rate: 30 }]
|
|
2093
|
-
},
|
|
2124
|
+
}, Fr = [
|
|
2094
2125
|
{ to: 3e5, rate: 0 },
|
|
2095
2126
|
{ to: 7e5, rate: 5 },
|
|
2096
2127
|
{ to: 1e6, rate: 10 },
|
|
@@ -2098,7 +2129,7 @@ const wr = (e, t) => Ut(e, t, Nr).tax, Nr = { money: (e) => String(e) }, jt = (e
|
|
|
2098
2129
|
{ to: 15e5, rate: 20 },
|
|
2099
2130
|
{ to: 1 / 0, rate: 30 }
|
|
2100
2131
|
];
|
|
2101
|
-
function
|
|
2132
|
+
function Ir(e, t, n) {
|
|
2102
2133
|
const r = [
|
|
2103
2134
|
{ threshold: 5e7, rate: 25, prev: 20 },
|
|
2104
2135
|
{ threshold: 2e7, rate: 20, prev: 15 },
|
|
@@ -2110,10 +2141,10 @@ function Pr(e, t, n) {
|
|
|
2110
2141
|
return i.gt(0) ? s.minus(i) : s;
|
|
2111
2142
|
}
|
|
2112
2143
|
function Yt(e, t, n, a, r) {
|
|
2113
|
-
const { tax: s, rows: u } = Ut(e, t, r), m = e.gt(n) ? g(0) : s.lt(a) ? s : g(a), d = s.minus(m), i =
|
|
2144
|
+
const { tax: s, rows: u } = Ut(e, t, r), m = e.gt(n) ? g(0) : s.lt(a) ? s : g(a), d = s.minus(m), i = Ir(e, d, (p) => Sr(g(p), t)), c = d.plus(i).times("0.04"), l = d.plus(i).plus(c);
|
|
2114
2145
|
return { taxable: e, base: s, rebate: m, surcharge: i, cess: c, total: l, rows: u };
|
|
2115
2146
|
}
|
|
2116
|
-
const
|
|
2147
|
+
const Rr = {
|
|
2117
2148
|
id: "tax.incomeIN",
|
|
2118
2149
|
group: "tax",
|
|
2119
2150
|
title: "Income Tax (Old vs New)",
|
|
@@ -2139,7 +2170,7 @@ const Tr = {
|
|
|
2139
2170
|
{ key: "homeLoanInterest", label: "Home loan interest (24b)", kind: "money", prefix: "currency", default: "0", help: "max ₹2L", optional: !0 }
|
|
2140
2171
|
],
|
|
2141
2172
|
compute(e, t) {
|
|
2142
|
-
const { fmt: n } = t, a = D(e.grossIncome, "1200000"), r = _(e.age, "<60"), s = jt(D(e.ded80C, "0"), 15e4), u = D(e.ded80D, "0"), m = D(e.hraExemption, "0"), d = jt(D(e.homeLoanInterest, "0"), 2e5), i = g(5e4).plus(s).plus(u).plus(m).plus(d), c = a.minus(i), l = c.gt(0) ? c : g(0), p = Yt(l, Vt[r] ?? Vt["<60"], 5e5, 12500, n), h = a.minus(75e3), f = h.gt(0) ? h : g(0), y = Yt(f,
|
|
2173
|
+
const { fmt: n } = t, a = D(e.grossIncome, "1200000"), r = _(e.age, "<60"), s = jt(D(e.ded80C, "0"), 15e4), u = D(e.ded80D, "0"), m = D(e.hraExemption, "0"), d = jt(D(e.homeLoanInterest, "0"), 2e5), i = g(5e4).plus(s).plus(u).plus(m).plus(d), c = a.minus(i), l = c.gt(0) ? c : g(0), p = Yt(l, Vt[r] ?? Vt["<60"], 5e5, 12500, n), h = a.minus(75e3), f = h.gt(0) ? h : g(0), y = Yt(f, Fr, 7e5, 25e3, n), w = !y.total.gt(p.total), k = w ? y : p, S = p.total.minus(y.total).abs();
|
|
2143
2174
|
return {
|
|
2144
2175
|
primary: v(
|
|
2145
2176
|
`${w ? "New" : "Old"} regime is cheaper`,
|
|
@@ -2175,7 +2206,7 @@ const Tr = {
|
|
|
2175
2206
|
}
|
|
2176
2207
|
};
|
|
2177
2208
|
}
|
|
2178
|
-
},
|
|
2209
|
+
}, Er = {
|
|
2179
2210
|
id: "tax.capitalGains",
|
|
2180
2211
|
group: "tax",
|
|
2181
2212
|
title: "Capital Gains Tax",
|
|
@@ -2224,7 +2255,7 @@ const Tr = {
|
|
|
2224
2255
|
raw: { gain: d.toFixed(2), tax: h ? null : l.toFixed(2), type: p, isLong: c ? 1 : 0 }
|
|
2225
2256
|
};
|
|
2226
2257
|
}
|
|
2227
|
-
},
|
|
2258
|
+
}, Mr = {
|
|
2228
2259
|
id: "tax.hra",
|
|
2229
2260
|
group: "tax",
|
|
2230
2261
|
title: "HRA Exemption",
|
|
@@ -2244,7 +2275,7 @@ const Tr = {
|
|
|
2244
2275
|
l.lt(h) && (h = l), p.lt(h) && (h = p);
|
|
2245
2276
|
const f = s.minus(h);
|
|
2246
2277
|
return {
|
|
2247
|
-
primary:
|
|
2278
|
+
primary: ut("HRA exempt", n.money(h)),
|
|
2248
2279
|
secondary: [
|
|
2249
2280
|
v("Taxable HRA", n.money(f), "negative"),
|
|
2250
2281
|
v("HRA received", n.money(s), "principal"),
|
|
@@ -2259,7 +2290,7 @@ const Tr = {
|
|
|
2259
2290
|
raw: { exempt: h.toFixed(2), taxable: f.toFixed(2), limitRent: l.toFixed(2), limitPct: p.toFixed(2) }
|
|
2260
2291
|
};
|
|
2261
2292
|
}
|
|
2262
|
-
},
|
|
2293
|
+
}, $r = {
|
|
2263
2294
|
id: "tax.advanceTax",
|
|
2264
2295
|
group: "tax",
|
|
2265
2296
|
title: "Advance Tax Instalments",
|
|
@@ -2300,7 +2331,7 @@ const Tr = {
|
|
|
2300
2331
|
raw: { advanceTaxDue: u.toFixed(2), liability: a.toFixed(2), tdsPaid: r.toFixed(2) }
|
|
2301
2332
|
};
|
|
2302
2333
|
}
|
|
2303
|
-
},
|
|
2334
|
+
}, Ar = {
|
|
2304
2335
|
id: "tax.salesTaxUS",
|
|
2305
2336
|
group: "tax",
|
|
2306
2337
|
title: "Sales Tax",
|
|
@@ -2358,7 +2389,7 @@ const Tr = {
|
|
|
2358
2389
|
{ to: 609350, rate: 35 },
|
|
2359
2390
|
{ to: 1 / 0, rate: 37 }
|
|
2360
2391
|
]
|
|
2361
|
-
},
|
|
2392
|
+
}, Dr = { single: 14600, marriedJoint: 29200, headOfHousehold: 21900 }, Lr = {
|
|
2362
2393
|
id: "tax.incomeUS",
|
|
2363
2394
|
group: "tax",
|
|
2364
2395
|
title: "Federal Income Tax",
|
|
@@ -2398,14 +2429,14 @@ const Tr = {
|
|
|
2398
2429
|
}
|
|
2399
2430
|
],
|
|
2400
2431
|
compute(e, t) {
|
|
2401
|
-
const { fmt: n } = t, a = D(e.grossIncome, "60000"), r = _(e.filingStatus, "single"), s = Kt[r] ?? Kt.single, m = _(e.deductionMode, "standard") === "itemized" ? D(e.itemizedAmount, "0") : g(
|
|
2432
|
+
const { fmt: n } = t, a = D(e.grossIncome, "60000"), r = _(e.filingStatus, "single"), s = Kt[r] ?? Kt.single, m = _(e.deductionMode, "standard") === "itemized" ? D(e.itemizedAmount, "0") : g(Dr[r] ?? 14600), d = a.minus(m), i = d.gt(0) ? d : g(0), { tax: c, rows: l } = Ut(i, s, n), p = a.gt(0) ? c.div(a).times(100) : g(0), h = s.find((w) => i.lte(w.to)) ?? s[s.length - 1], f = i.gt(0) ? h.rate : 0, y = a.minus(c);
|
|
2402
2433
|
return {
|
|
2403
2434
|
primary: v("Federal income tax", n.money(c), "negative"),
|
|
2404
2435
|
secondary: [
|
|
2405
2436
|
v("Taxable income", n.money(i), "principal", `after ${n.money(m)} deduction`),
|
|
2406
2437
|
v("Effective rate", n.pct(p), "accent"),
|
|
2407
2438
|
v("Marginal rate", `${f}%`, "default"),
|
|
2408
|
-
|
|
2439
|
+
ut("After-tax income", n.money(y))
|
|
2409
2440
|
],
|
|
2410
2441
|
schedule: {
|
|
2411
2442
|
title: "Bracket breakdown",
|
|
@@ -2427,7 +2458,7 @@ const Tr = {
|
|
|
2427
2458
|
}
|
|
2428
2459
|
};
|
|
2429
2460
|
}
|
|
2430
|
-
},
|
|
2461
|
+
}, Ur = {
|
|
2431
2462
|
id: "tax.mortgageDeductionUS",
|
|
2432
2463
|
group: "tax",
|
|
2433
2464
|
title: "Mortgage Interest Deduction",
|
|
@@ -2445,7 +2476,7 @@ const Tr = {
|
|
|
2445
2476
|
"Acquisition-debt limit is $750,000 ($375,000 if married filing separately) for loans after 15 Dec 2017. " + Ne
|
|
2446
2477
|
];
|
|
2447
2478
|
return s.gt(u) && i.unshift(`Loan balance exceeds $750k: only ${n.pct(g(u).div(s).times(100))} of the interest is deductible.`), {
|
|
2448
|
-
primary:
|
|
2479
|
+
primary: ut("Estimated tax savings", n.money(d)),
|
|
2449
2480
|
secondary: [
|
|
2450
2481
|
v("Deductible interest", n.money(m), "principal"),
|
|
2451
2482
|
v("Marginal tax rate", n.pct(g(C(e.marginalTaxRatePct, 24))), "accent")
|
|
@@ -2455,22 +2486,22 @@ const Tr = {
|
|
|
2455
2486
|
raw: { savings: d.toFixed(2), deductibleInterest: m.toFixed(2) }
|
|
2456
2487
|
};
|
|
2457
2488
|
}
|
|
2458
|
-
},
|
|
2459
|
-
|
|
2460
|
-
Sr,
|
|
2489
|
+
}, Or = [
|
|
2490
|
+
Pr,
|
|
2461
2491
|
Tr,
|
|
2462
|
-
Fr,
|
|
2463
|
-
Ir,
|
|
2464
2492
|
Rr,
|
|
2465
2493
|
Er,
|
|
2494
|
+
Mr,
|
|
2466
2495
|
$r,
|
|
2467
|
-
Ar
|
|
2496
|
+
Ar,
|
|
2497
|
+
Lr,
|
|
2498
|
+
Ur
|
|
2468
2499
|
], $e = {
|
|
2469
2500
|
length: { m: 1, km: 1e3, cm: 0.01, mm: 1e-3, mi: 1609.344, yd: 0.9144, ft: 0.3048, in: 0.0254 },
|
|
2470
2501
|
area: { sqm: 1, sqft: 0.092903, sqyd: 0.836127, acre: 4046.8564224, hectare: 1e4, bigha: 1337.8, gunta: 101.17, cent: 40.4686 },
|
|
2471
2502
|
weight: { kg: 1, g: 1e-3, mg: 1e-6, lb: 0.45359237, oz: 0.0283495, tonne: 1e3, quintal: 100 },
|
|
2472
2503
|
volume: { l: 1, ml: 1e-3, m3: 1e3, gal_us: 3.785411784, gal_uk: 4.54609, cup: 0.24, pint: 0.473176 }
|
|
2473
|
-
},
|
|
2504
|
+
}, Pt = {
|
|
2474
2505
|
m: "Meters (m)",
|
|
2475
2506
|
km: "Kilometers (km)",
|
|
2476
2507
|
cm: "Centimeters (cm)",
|
|
@@ -2504,10 +2535,10 @@ const Tr = {
|
|
|
2504
2535
|
C: "Celsius (°C)",
|
|
2505
2536
|
F: "Fahrenheit (°F)",
|
|
2506
2537
|
K: "Kelvin (K)"
|
|
2507
|
-
},
|
|
2538
|
+
}, Br = ["C", "F", "K"], Wt = (e) => e.map((t) => ({ value: t, label: Pt[t] ?? t })), Ae = (e, t, n, a) => [
|
|
2508
2539
|
{ key: `${e}From`, label: "From", kind: "select", default: n, options: Wt(t), showIf: (r) => r.category === e },
|
|
2509
2540
|
{ key: `${e}To`, label: "To", kind: "select", default: a, options: Wt(t), showIf: (r) => r.category === e }
|
|
2510
|
-
],
|
|
2541
|
+
], _r = {
|
|
2511
2542
|
id: "tools.units",
|
|
2512
2543
|
group: "tools",
|
|
2513
2544
|
title: "Unit Converter",
|
|
@@ -2532,7 +2563,7 @@ const Tr = {
|
|
|
2532
2563
|
...Ae("area", Object.keys($e.area), "acre", "sqm"),
|
|
2533
2564
|
...Ae("weight", Object.keys($e.weight), "kg", "lb"),
|
|
2534
2565
|
...Ae("volume", Object.keys($e.volume), "l", "gal_us"),
|
|
2535
|
-
...Ae("temperature",
|
|
2566
|
+
...Ae("temperature", Br, "C", "F")
|
|
2536
2567
|
],
|
|
2537
2568
|
compute(e, t) {
|
|
2538
2569
|
const { D: n, fmt: a } = t, r = n(C(e.value, 0)), s = _(e.category, "length"), u = _(e[`${s}From`], ""), m = _(e[`${s}To`], ""), d = [];
|
|
@@ -2544,21 +2575,21 @@ const Tr = {
|
|
|
2544
2575
|
const p = $e[s];
|
|
2545
2576
|
i = r.times(p[u] ?? 1).div(p[m] ?? 1), (u === "bigha" || m === "bigha") && d.push("Bigha is not standardised — its size varies by state; this uses a common ~1337.8 m² value.");
|
|
2546
2577
|
}
|
|
2547
|
-
const c =
|
|
2578
|
+
const c = Pt[u] ?? u, l = Pt[m] ?? m;
|
|
2548
2579
|
return {
|
|
2549
2580
|
primary: v(`${r.toString()} ${c} =`, `${a.num(i, 4)} ${l}`, "accent"),
|
|
2550
2581
|
notes: d,
|
|
2551
2582
|
raw: { result: i.toFixed(6), from: u, to: m, category: s }
|
|
2552
2583
|
};
|
|
2553
2584
|
}
|
|
2554
|
-
}, je = 864e5,
|
|
2585
|
+
}, je = 864e5, ft = (e) => {
|
|
2555
2586
|
if (!e) {
|
|
2556
2587
|
const r = /* @__PURE__ */ new Date();
|
|
2557
2588
|
return new Date(Date.UTC(r.getUTCFullYear(), r.getUTCMonth(), r.getUTCDate()));
|
|
2558
2589
|
}
|
|
2559
2590
|
const [t, n, a] = e.split("-").map(Number);
|
|
2560
2591
|
return new Date(Date.UTC(t, (n || 1) - 1, a || 1));
|
|
2561
|
-
},
|
|
2592
|
+
}, yt = (e, t) => new Date(Date.UTC(e, t, 0)).getUTCDate(), Ve = (e) => e.toISOString().slice(0, 10), Hr = {
|
|
2562
2593
|
id: "tools.dateCalc",
|
|
2563
2594
|
group: "tools",
|
|
2564
2595
|
title: "Date Calculator",
|
|
@@ -2605,15 +2636,15 @@ const Tr = {
|
|
|
2605
2636
|
],
|
|
2606
2637
|
compute(e) {
|
|
2607
2638
|
if (_(e.mode, "difference") === "addSubtract") {
|
|
2608
|
-
const l =
|
|
2639
|
+
const l = ft(_(e.startDate, "")), p = Math.round(C(e.count, 0)), h = _(e.unit, "days"), f = _(e.direction, "add") === "subtract" ? -1 : 1, y = f * p;
|
|
2609
2640
|
let w;
|
|
2610
2641
|
if (h === "days" || h === "weeks")
|
|
2611
2642
|
w = new Date(l.getTime() + y * (h === "weeks" ? 7 : 1) * je);
|
|
2612
2643
|
else if (h === "months") {
|
|
2613
|
-
const S = l.getUTCMonth() + y, F = l.getUTCFullYear() + Math.floor(S / 12), N = (S % 12 + 12) % 12, P = Math.min(l.getUTCDate(),
|
|
2644
|
+
const S = l.getUTCMonth() + y, F = l.getUTCFullYear() + Math.floor(S / 12), N = (S % 12 + 12) % 12, P = Math.min(l.getUTCDate(), yt(F, N + 1));
|
|
2614
2645
|
w = new Date(Date.UTC(F, N, P));
|
|
2615
2646
|
} else {
|
|
2616
|
-
const S = l.getUTCFullYear() + y, F = Math.min(l.getUTCDate(),
|
|
2647
|
+
const S = l.getUTCFullYear() + y, F = Math.min(l.getUTCDate(), yt(S, l.getUTCMonth() + 1));
|
|
2617
2648
|
w = new Date(Date.UTC(S, l.getUTCMonth(), F));
|
|
2618
2649
|
}
|
|
2619
2650
|
const k = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][w.getUTCDay()];
|
|
@@ -2623,10 +2654,10 @@ const Tr = {
|
|
|
2623
2654
|
raw: { resultDate: Ve(w), weekday: k, from: Ve(l) }
|
|
2624
2655
|
};
|
|
2625
2656
|
}
|
|
2626
|
-
let n =
|
|
2657
|
+
let n = ft(_(e.startDate, "")), a = ft(_(e.endDate, "")), r = !1;
|
|
2627
2658
|
a.getTime() < n.getTime() && ([n, a] = [a, n], r = !0);
|
|
2628
2659
|
let s = a.getUTCFullYear() - n.getUTCFullYear(), u = a.getUTCMonth() - n.getUTCMonth(), m = a.getUTCDate() - n.getUTCDate();
|
|
2629
|
-
m < 0 && (u -= 1, m +=
|
|
2660
|
+
m < 0 && (u -= 1, m += yt(a.getUTCFullYear(), a.getUTCMonth())), u < 0 && (s -= 1, u += 12);
|
|
2630
2661
|
const d = Math.round((a.getTime() - n.getTime()) / je);
|
|
2631
2662
|
let i = 0;
|
|
2632
2663
|
for (let l = n.getTime() + je; l <= a.getTime(); l += je) {
|
|
@@ -2645,23 +2676,23 @@ const Tr = {
|
|
|
2645
2676
|
raw: { years: s, months: u, days: m, totalDays: d, weeks: Number((d / 7).toFixed(2)), businessDays: i }
|
|
2646
2677
|
};
|
|
2647
2678
|
}
|
|
2648
|
-
},
|
|
2679
|
+
}, Tt = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"], qr = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"], nt = (e) => e < 20 ? Tt[e] : qr[Math.floor(e / 10)] + (e % 10 ? " " + Tt[e % 10] : ""), Ft = (e) => {
|
|
2649
2680
|
const t = Math.floor(e / 100), n = e % 100, a = [];
|
|
2650
|
-
return t && a.push(
|
|
2651
|
-
},
|
|
2681
|
+
return t && a.push(Tt[t] + " Hundred"), n && a.push(nt(n)), a.join(" ");
|
|
2682
|
+
}, Dn = (e) => {
|
|
2652
2683
|
if (e === 0) return "Zero";
|
|
2653
2684
|
const t = ["", " Thousand", " Million", " Billion", " Trillion"], n = [];
|
|
2654
2685
|
let a = 0;
|
|
2655
2686
|
for (; e > 0 && a < t.length; ) {
|
|
2656
2687
|
const r = e % 1e3;
|
|
2657
|
-
r && n.unshift(
|
|
2688
|
+
r && n.unshift(Ft(r) + t[a]), e = Math.floor(e / 1e3), a++;
|
|
2658
2689
|
}
|
|
2659
2690
|
return n.length ? n.join(" ") : "Zero";
|
|
2660
|
-
},
|
|
2691
|
+
}, Gr = (e) => {
|
|
2661
2692
|
if (e === 0) return "Zero";
|
|
2662
2693
|
const t = Math.floor(e / 1e7), n = Math.floor(e / 1e5) % 100, a = Math.floor(e / 1e3) % 100, r = e % 1e3, s = [];
|
|
2663
|
-
return t && s.push((t <= 999 ?
|
|
2664
|
-
},
|
|
2694
|
+
return t && s.push((t <= 999 ? Ft(t) : Dn(t)) + " Crore"), n && s.push(nt(n) + " Lakh"), a && s.push(nt(a) + " Thousand"), r && s.push(Ft(r)), s.join(" ");
|
|
2695
|
+
}, jr = {
|
|
2665
2696
|
id: "tools.numToWords",
|
|
2666
2697
|
group: "tools",
|
|
2667
2698
|
title: "Number to Words",
|
|
@@ -2683,15 +2714,15 @@ const Tr = {
|
|
|
2683
2714
|
],
|
|
2684
2715
|
compute(e, t) {
|
|
2685
2716
|
const { D: n, fmt: a } = t, r = _(e.scale, "indian"), s = ye(e.cheque, !1), u = n(_(e.amount, "0").replace(/[, ]/g, "") || "0"), m = u.isNegative(), d = u.abs(), i = d.floor(), c = Number(d.minus(i).times(100).toDecimalPlaces(0).toString()), l = Number(i.toString()), p = t.settings.currency.code, h = p === "INR" ? "Rupees" : p === "USD" ? "Dollars" : p, f = p === "INR" ? "Paise" : "Cents";
|
|
2686
|
-
let y = r === "western" ?
|
|
2687
|
-
return c > 0 && (y += ` and ${
|
|
2717
|
+
let y = r === "western" ? Dn(l) : Gr(l);
|
|
2718
|
+
return c > 0 && (y += ` and ${nt(c)} ${f}`), s && (y = `${h} ${y} Only`), m && (y = `Minus ${y}`), {
|
|
2688
2719
|
primary: v("In words", y, "accent"),
|
|
2689
2720
|
secondary: [v("In figures", a.num(u, c > 0 ? 2 : 0))],
|
|
2690
2721
|
notes: ['Words are Title Case with the chosen number scale; the cheque format adds the currency name and "Only".'],
|
|
2691
2722
|
raw: { words: y, integer: l, fraction: c }
|
|
2692
2723
|
};
|
|
2693
2724
|
}
|
|
2694
|
-
},
|
|
2725
|
+
}, Vr = [_r, Hr, jr], Yr = [
|
|
2695
2726
|
{
|
|
2696
2727
|
id: "tools.scientific",
|
|
2697
2728
|
group: "tools",
|
|
@@ -2702,7 +2733,7 @@ const Tr = {
|
|
|
2702
2733
|
compute: () => ({ primary: { label: "Scientific calculator", value: "" } }),
|
|
2703
2734
|
custom: "scientific"
|
|
2704
2735
|
}
|
|
2705
|
-
],
|
|
2736
|
+
], Kr = {
|
|
2706
2737
|
id: "loan.emi",
|
|
2707
2738
|
group: "loans",
|
|
2708
2739
|
title: "EMI / Loan",
|
|
@@ -2711,7 +2742,7 @@ const Tr = {
|
|
|
2711
2742
|
inputs: [],
|
|
2712
2743
|
compute: () => ({ primary: { label: "", value: "" } }),
|
|
2713
2744
|
custom: "loan.emi"
|
|
2714
|
-
},
|
|
2745
|
+
}, Wr = {
|
|
2715
2746
|
id: "tools.currency",
|
|
2716
2747
|
group: "tools",
|
|
2717
2748
|
title: "Currency converter",
|
|
@@ -2720,49 +2751,49 @@ const Tr = {
|
|
|
2720
2751
|
inputs: [],
|
|
2721
2752
|
compute: () => ({ primary: { label: "", value: "" } }),
|
|
2722
2753
|
custom: "currency"
|
|
2723
|
-
},
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
...
|
|
2727
|
-
...
|
|
2728
|
-
...
|
|
2729
|
-
...
|
|
2730
|
-
...
|
|
2731
|
-
...
|
|
2732
|
-
...
|
|
2733
|
-
...
|
|
2734
|
-
],
|
|
2735
|
-
function
|
|
2736
|
-
|
|
2737
|
-
}
|
|
2738
|
-
function
|
|
2739
|
-
return [...
|
|
2740
|
-
}
|
|
2741
|
-
function
|
|
2742
|
-
return
|
|
2743
|
-
}
|
|
2744
|
-
function
|
|
2745
|
-
return
|
|
2746
|
-
}
|
|
2747
|
-
const
|
|
2754
|
+
}, zr = [
|
|
2755
|
+
Kr,
|
|
2756
|
+
Wr,
|
|
2757
|
+
...Va,
|
|
2758
|
+
...er,
|
|
2759
|
+
...sr,
|
|
2760
|
+
...dr,
|
|
2761
|
+
...xr,
|
|
2762
|
+
...Or,
|
|
2763
|
+
...Vr,
|
|
2764
|
+
...Yr
|
|
2765
|
+
], It = [];
|
|
2766
|
+
function fs(e) {
|
|
2767
|
+
It.some((t) => t.id === e.id) || It.push(e);
|
|
2768
|
+
}
|
|
2769
|
+
function Ln() {
|
|
2770
|
+
return [...zr, ...It];
|
|
2771
|
+
}
|
|
2772
|
+
function Jr(e) {
|
|
2773
|
+
return Ln().filter((t) => !t.regions || t.regions.includes(e));
|
|
2774
|
+
}
|
|
2775
|
+
function Rt(e) {
|
|
2776
|
+
return Ln().find((t) => t.id === e);
|
|
2777
|
+
}
|
|
2778
|
+
const Zr = [
|
|
2748
2779
|
{ id: "loans", label: "Loans" },
|
|
2749
2780
|
{ id: "invest", label: "Invest" },
|
|
2750
2781
|
{ id: "returns", label: "Returns" },
|
|
2751
2782
|
{ id: "tax", label: "Tax" },
|
|
2752
2783
|
{ id: "tools", label: "Tools" }
|
|
2753
2784
|
];
|
|
2754
|
-
function
|
|
2785
|
+
function Xr(e, t) {
|
|
2755
2786
|
var n;
|
|
2756
2787
|
return ((n = e.labelByRegion) == null ? void 0 : n[t]) ?? e.label;
|
|
2757
2788
|
}
|
|
2758
|
-
function
|
|
2789
|
+
function Qr({
|
|
2759
2790
|
f: e,
|
|
2760
2791
|
value: t,
|
|
2761
2792
|
onChange: n,
|
|
2762
2793
|
values: a
|
|
2763
2794
|
}) {
|
|
2764
2795
|
var i, c;
|
|
2765
|
-
const { settings: r } = ue(), s = r.region, u =
|
|
2796
|
+
const { settings: r } = ue(), s = r.region, u = Xr(e, s), m = r.currency.symbol, d = t == null ? "" : String(t);
|
|
2766
2797
|
switch (e.kind) {
|
|
2767
2798
|
case "money":
|
|
2768
2799
|
case "number":
|
|
@@ -2800,7 +2831,7 @@ function Jr({
|
|
|
2800
2831
|
] })
|
|
2801
2832
|
] });
|
|
2802
2833
|
case "tenure":
|
|
2803
|
-
return /* @__PURE__ */ o(
|
|
2834
|
+
return /* @__PURE__ */ o(eo, { f: e, label: u, months: Number(t) || 0, onChange: n });
|
|
2804
2835
|
case "select":
|
|
2805
2836
|
return /* @__PURE__ */ b("label", { className: "field", children: [
|
|
2806
2837
|
/* @__PURE__ */ o("span", { className: "lbl", children: u }),
|
|
@@ -2838,12 +2869,12 @@ function Jr({
|
|
|
2838
2869
|
/* @__PURE__ */ o("div", { className: "input-wrap", children: /* @__PURE__ */ o("input", { value: d, placeholder: e.help, onChange: (l) => n(l.target.value), "aria-label": u }) })
|
|
2839
2870
|
] });
|
|
2840
2871
|
case "cashflows":
|
|
2841
|
-
return /* @__PURE__ */ o(
|
|
2872
|
+
return /* @__PURE__ */ o(to, { f: e, label: u, value: t ?? [], onChange: n });
|
|
2842
2873
|
default:
|
|
2843
2874
|
return null;
|
|
2844
2875
|
}
|
|
2845
2876
|
}
|
|
2846
|
-
function
|
|
2877
|
+
function eo({
|
|
2847
2878
|
f: e,
|
|
2848
2879
|
label: t,
|
|
2849
2880
|
months: n,
|
|
@@ -2883,7 +2914,7 @@ function Zr({
|
|
|
2883
2914
|
e.suffix && /* @__PURE__ */ o("div", { className: "solved-note", children: e.suffix })
|
|
2884
2915
|
] });
|
|
2885
2916
|
}
|
|
2886
|
-
function
|
|
2917
|
+
function to({
|
|
2887
2918
|
label: e,
|
|
2888
2919
|
value: t,
|
|
2889
2920
|
onChange: n
|
|
@@ -2906,7 +2937,7 @@ function Xr({
|
|
|
2906
2937
|
/* @__PURE__ */ o("button", { type: "button", className: "icon-btn", onClick: () => s([...a, { date: "", amount: "" }]), children: "+ Add cashflow" })
|
|
2907
2938
|
] });
|
|
2908
2939
|
}
|
|
2909
|
-
const
|
|
2940
|
+
const Un = {
|
|
2910
2941
|
principal: "pr-txt",
|
|
2911
2942
|
interest: "in-txt",
|
|
2912
2943
|
accent: "accent-txt",
|
|
@@ -2914,11 +2945,11 @@ const Ln = {
|
|
|
2914
2945
|
negative: "neg-txt",
|
|
2915
2946
|
default: ""
|
|
2916
2947
|
};
|
|
2917
|
-
function
|
|
2948
|
+
function no({ view: e }) {
|
|
2918
2949
|
const { settings: t } = ue(), n = t.currency.symbol, a = e.primary.value, r = a.startsWith(n), s = r ? a.slice(n.length).trim() : a, u = /[A-Za-z]{3,}/.test(a);
|
|
2919
2950
|
return /* @__PURE__ */ b("div", { className: "result", "aria-live": "polite", children: [
|
|
2920
2951
|
/* @__PURE__ */ o("div", { className: "label", children: e.primary.label }),
|
|
2921
|
-
/* @__PURE__ */ b("div", { className: `value num ${u ? "value-text" : ""} ${
|
|
2952
|
+
/* @__PURE__ */ b("div", { className: `value num ${u ? "value-text" : ""} ${Un[e.primary.tone ?? "default"]}`, children: [
|
|
2922
2953
|
r && /* @__PURE__ */ o("span", { className: "cur", children: n }),
|
|
2923
2954
|
s,
|
|
2924
2955
|
e.primaryPer && /* @__PURE__ */ b("span", { className: "per", children: [
|
|
@@ -2927,18 +2958,18 @@ function Qr({ view: e }) {
|
|
|
2927
2958
|
] })
|
|
2928
2959
|
] }),
|
|
2929
2960
|
e.primary.sub && /* @__PURE__ */ o("div", { className: "per", children: e.primary.sub }),
|
|
2930
|
-
e.split && e.split.length > 0 && /* @__PURE__ */ o(
|
|
2931
|
-
e.secondary && e.secondary.length > 0 && /* @__PURE__ */ o("div", { className: "secondary", children: e.secondary.map((m, d) => /* @__PURE__ */ o(
|
|
2961
|
+
e.split && e.split.length > 0 && /* @__PURE__ */ o(ro, { split: e.split }),
|
|
2962
|
+
e.secondary && e.secondary.length > 0 && /* @__PURE__ */ o("div", { className: "secondary", children: e.secondary.map((m, d) => /* @__PURE__ */ o(ao, { m }, d)) })
|
|
2932
2963
|
] });
|
|
2933
2964
|
}
|
|
2934
|
-
function
|
|
2965
|
+
function ao({ m: e }) {
|
|
2935
2966
|
return /* @__PURE__ */ b("div", { className: "kv", children: [
|
|
2936
2967
|
/* @__PURE__ */ o("div", { className: "k", children: e.label }),
|
|
2937
|
-
/* @__PURE__ */ o("div", { className: `v num ${
|
|
2968
|
+
/* @__PURE__ */ o("div", { className: `v num ${Un[e.tone ?? "default"]}`, children: e.value }),
|
|
2938
2969
|
e.sub && /* @__PURE__ */ o("div", { className: "k", children: e.sub })
|
|
2939
2970
|
] });
|
|
2940
2971
|
}
|
|
2941
|
-
function
|
|
2972
|
+
function ro({ split: e }) {
|
|
2942
2973
|
const t = e.reduce((a, r) => a + Math.max(0, r.value), 0) || 1, n = e.map((a) => Math.round(Math.max(0, a.value) / t * 100));
|
|
2943
2974
|
return /* @__PURE__ */ b(re, { children: [
|
|
2944
2975
|
/* @__PURE__ */ o("div", { className: "splitbar", role: "img", "aria-label": e.map((a, r) => `${a.label} ${n[r]}%`).join(", "), children: e.map((a, r) => /* @__PURE__ */ o("div", { className: a.tone, style: { width: `${n[r]}%` } }, r)) }),
|
|
@@ -2951,7 +2982,7 @@ function to({ split: e }) {
|
|
|
2951
2982
|
] }, r)) })
|
|
2952
2983
|
] });
|
|
2953
2984
|
}
|
|
2954
|
-
function
|
|
2985
|
+
function oo({ schedule: e }) {
|
|
2955
2986
|
var u;
|
|
2956
2987
|
const [t, n] = M(/* @__PURE__ */ new Set([0])), a = (m) => {
|
|
2957
2988
|
var d;
|
|
@@ -2993,7 +3024,7 @@ const zt = {
|
|
|
2993
3024
|
interest: "var(--fc-interest)",
|
|
2994
3025
|
accent: "var(--fc-accent)"
|
|
2995
3026
|
};
|
|
2996
|
-
function
|
|
3027
|
+
function io({ chart: e }) {
|
|
2997
3028
|
const m = Math.max(...e.series.map((h) => h.points.length), 1), d = Math.max(...e.series.flatMap((h) => h.points), 1), i = (h) => 8 + h / Math.max(m - 1, 1) * 704, c = (h) => 12 + (1 - h / d) * 226, l = (h) => h.map((f, y) => `${y === 0 ? "M" : "L"}${i(y).toFixed(1)},${c(f).toFixed(1)}`).join(" "), p = (h) => `M${i(0)},${c(0)} ${h.map((f, y) => `L${i(y).toFixed(1)},${c(f).toFixed(1)}`).join(" ")} L${i(h.length - 1)},${c(0)} Z`;
|
|
2998
3029
|
return /* @__PURE__ */ b("div", { className: "chart", children: [
|
|
2999
3030
|
/* @__PURE__ */ b("svg", { viewBox: "0 0 720 260", role: "img", "aria-label": "Projection chart", children: [
|
|
@@ -3009,7 +3040,7 @@ function ao({ chart: e }) {
|
|
|
3009
3040
|
] }, f)) })
|
|
3010
3041
|
] });
|
|
3011
3042
|
}
|
|
3012
|
-
const
|
|
3043
|
+
const On = 1, so = [
|
|
3013
3044
|
{ id: "csv", label: "CSV (.csv)" },
|
|
3014
3045
|
{ id: "tsv", label: "TSV (.tsv)" },
|
|
3015
3046
|
{ id: "json", label: "JSON (.json)" },
|
|
@@ -3038,52 +3069,52 @@ function _e(e) {
|
|
|
3038
3069
|
for (const n of e.rows) t.push([n.label, ...n.cells]);
|
|
3039
3070
|
return { header: e.columns, rows: t };
|
|
3040
3071
|
}
|
|
3041
|
-
function
|
|
3072
|
+
function lo(e) {
|
|
3042
3073
|
var t;
|
|
3043
3074
|
return e ? e.groups ? e.groups.reduce((n, a) => n + a.rows.length, 0) : ((t = e.rows) == null ? void 0 : t.length) ?? 0 : 0;
|
|
3044
3075
|
}
|
|
3045
|
-
function
|
|
3076
|
+
function Et(e) {
|
|
3046
3077
|
return String(e ?? "").replace(/[/\\]/g, "-").replace(/[-<>:"|?*]/g, "").trim().replace(/^\.+/, "") || "export";
|
|
3047
3078
|
}
|
|
3048
3079
|
function ve(e, t) {
|
|
3049
3080
|
var m;
|
|
3050
|
-
const n = new Date(((m = e.meta) == null ? void 0 : m.computedAt) || Date.now()), a = n.getFullYear(), r = String(n.getMonth() + 1).padStart(2, "0"), s = String(n.getDate()).padStart(2, "0"), u =
|
|
3051
|
-
return
|
|
3081
|
+
const n = new Date(((m = e.meta) == null ? void 0 : m.computedAt) || Date.now()), a = n.getFullYear(), r = String(n.getMonth() + 1).padStart(2, "0"), s = String(n.getDate()).padStart(2, "0"), u = Et(e.calculatorId || e.title || "export");
|
|
3082
|
+
return Et(`${u}-${a}${r}${s}.${t}`);
|
|
3052
3083
|
}
|
|
3053
3084
|
function Se(e, t, n = "application/octet-stream") {
|
|
3054
3085
|
if (!Ot() || typeof URL > "u" || !URL.createObjectURL)
|
|
3055
3086
|
throw new Error("Download is only available in the browser.");
|
|
3056
3087
|
const a = t instanceof Blob ? t : new Blob([t], { type: n }), r = URL.createObjectURL(a), s = document.createElement("a");
|
|
3057
|
-
s.href = r, s.download =
|
|
3088
|
+
s.href = r, s.download = Et(e), s.style.display = "none", document.body.appendChild(s), s.click(), setTimeout(() => {
|
|
3058
3089
|
URL.revokeObjectURL(r), s.remove();
|
|
3059
3090
|
}, 0);
|
|
3060
3091
|
}
|
|
3061
|
-
function
|
|
3092
|
+
function co(e, t) {
|
|
3062
3093
|
let n = e == null ? "" : String(e);
|
|
3063
3094
|
return /^[=+\-@\t\r]/.test(n) && (n = `'${n}`), (n.includes(t) || n.includes('"') || n.includes(`
|
|
3064
3095
|
`) || n.includes("\r")) && (n = `"${n.replace(/"/g, '""')}"`), n;
|
|
3065
3096
|
}
|
|
3066
|
-
function
|
|
3097
|
+
function uo(e) {
|
|
3067
3098
|
var t;
|
|
3068
3099
|
return ((t = e == null ? void 0 : e.numberFormat) == null ? void 0 : t.grouping) === "european" ? ";" : ",";
|
|
3069
3100
|
}
|
|
3070
|
-
function
|
|
3101
|
+
function Bn(e, t) {
|
|
3071
3102
|
const n = [["ArthaGanaka export"], ["Calculator", e.title]];
|
|
3072
3103
|
for (const a of Re(e)) n.push(a);
|
|
3073
3104
|
if (n.push([]), e.result.schedule) {
|
|
3074
3105
|
const a = _e(e.result.schedule);
|
|
3075
3106
|
n.push(a.header, ...a.rows);
|
|
3076
3107
|
}
|
|
3077
|
-
return n.map((a) => a.map((r) =>
|
|
3108
|
+
return n.map((a) => a.map((r) => co(r, t)).join(t)).join(`\r
|
|
3078
3109
|
`);
|
|
3079
3110
|
}
|
|
3080
|
-
function
|
|
3081
|
-
return
|
|
3111
|
+
function mo(e) {
|
|
3112
|
+
return Bn(e, uo(e.settingsSnapshot));
|
|
3082
3113
|
}
|
|
3083
|
-
function
|
|
3084
|
-
return
|
|
3114
|
+
function po(e) {
|
|
3115
|
+
return Bn(e, " ");
|
|
3085
3116
|
}
|
|
3086
|
-
function
|
|
3117
|
+
function ho(e, t = On) {
|
|
3087
3118
|
return JSON.stringify(
|
|
3088
3119
|
{
|
|
3089
3120
|
schemaVersion: t,
|
|
@@ -3103,7 +3134,7 @@ function uo(e, t = Un) {
|
|
|
3103
3134
|
2
|
|
3104
3135
|
);
|
|
3105
3136
|
}
|
|
3106
|
-
function
|
|
3137
|
+
function fo(e) {
|
|
3107
3138
|
const t = new TextEncoder().encode(e);
|
|
3108
3139
|
if (typeof btoa == "function") {
|
|
3109
3140
|
let n = "";
|
|
@@ -3112,9 +3143,9 @@ function mo(e) {
|
|
|
3112
3143
|
}
|
|
3113
3144
|
return globalThis.Buffer.from(t).toString("base64");
|
|
3114
3145
|
}
|
|
3115
|
-
const
|
|
3116
|
-
function
|
|
3117
|
-
const n =
|
|
3146
|
+
const yo = (e) => fo(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
3147
|
+
function _n(e, t) {
|
|
3148
|
+
const n = yo(JSON.stringify({ id: e, values: t }));
|
|
3118
3149
|
return `#fincalc=${encodeURIComponent(e)}&s=${n}`;
|
|
3119
3150
|
}
|
|
3120
3151
|
const Ye = (e) => String(e ?? "").replace(/\|/g, "\\|").replace(/\n/g, " ");
|
|
@@ -3131,22 +3162,22 @@ function Jt(e) {
|
|
|
3131
3162
|
`);
|
|
3132
3163
|
}
|
|
3133
3164
|
const Pe = (e) => String(e ?? "").replace(/[&<>"]/g, (t) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[t]);
|
|
3134
|
-
function
|
|
3165
|
+
function bo(e) {
|
|
3135
3166
|
return `<table><tbody>${Re(e).map(([n, a]) => `<tr><th>${Pe(n)}</th><td>${Pe(a)}</td></tr>`).join("")}</tbody></table>`;
|
|
3136
3167
|
}
|
|
3137
|
-
function
|
|
3168
|
+
function go(e) {
|
|
3138
3169
|
const t = _e(e), n = `<tr>${t.header.map((r) => `<th>${Pe(r)}</th>`).join("")}</tr>`, a = t.rows.map((r) => `<tr>${r.map((s) => `<td>${Pe(s)}</td>`).join("")}</tr>`).join("");
|
|
3139
3170
|
return `<table><thead>${n}</thead><tbody>${a}</tbody></table>`;
|
|
3140
3171
|
}
|
|
3141
|
-
function
|
|
3142
|
-
const t = e.result.schedule ? `<h2>${Pe(e.result.schedule.title ?? "Schedule")}</h2>${
|
|
3143
|
-
return `<h1>${Pe(e.title)}</h1>${
|
|
3172
|
+
function Hn(e) {
|
|
3173
|
+
const t = e.result.schedule ? `<h2>${Pe(e.result.schedule.title ?? "Schedule")}</h2>${go(e.result.schedule)}` : "";
|
|
3174
|
+
return `<h1>${Pe(e.title)}</h1>${bo(e)}${t}<p class="fc-print-foot">Generated by ArthaGanaka · ${Pe(e.meta.computedAt)}</p>`;
|
|
3144
3175
|
}
|
|
3145
|
-
const Zt = (e) => String(e ?? "").replace(/\\/g, "\\\\").replace(/[;,]/g, (t) => `\\${t}`).replace(/\n/g, "\\n"), Xt = (e) => `${e.getFullYear()}${String(e.getMonth() + 1).padStart(2, "0")}${String(e.getDate()).padStart(2, "0")}`,
|
|
3176
|
+
const Zt = (e) => String(e ?? "").replace(/\\/g, "\\\\").replace(/[;,]/g, (t) => `\\${t}`).replace(/\n/g, "\\n"), Xt = (e) => `${e.getFullYear()}${String(e.getMonth() + 1).padStart(2, "0")}${String(e.getDate()).padStart(2, "0")}`, vo = (e) => new Date(e || Date.now()).toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z"), ko = (e, t) => {
|
|
3146
3177
|
const n = new Date(e);
|
|
3147
3178
|
return n.setMonth(n.getMonth() + t), n;
|
|
3148
3179
|
};
|
|
3149
|
-
function
|
|
3180
|
+
function wo(e) {
|
|
3150
3181
|
for (const t of Object.values(e))
|
|
3151
3182
|
if (typeof t == "string" && /^\d{4}-\d{2}-\d{2}/.test(t)) {
|
|
3152
3183
|
const n = new Date(t);
|
|
@@ -3154,12 +3185,12 @@ function go(e) {
|
|
|
3154
3185
|
}
|
|
3155
3186
|
return /* @__PURE__ */ new Date();
|
|
3156
3187
|
}
|
|
3157
|
-
function
|
|
3158
|
-
const t =
|
|
3188
|
+
function No(e) {
|
|
3189
|
+
const t = lo(e.result.schedule);
|
|
3159
3190
|
if (!t) throw new Error("This calculator has no instalment schedule to put on a calendar.");
|
|
3160
|
-
const n =
|
|
3191
|
+
const n = wo(e.values), a = t <= 60, r = a ? t : Math.ceil(t / 12), s = vo(e.meta.computedAt), u = ["BEGIN:VCALENDAR", "VERSION:2.0", "PRODID:-//ArthaGanaka//Export//EN", "CALSCALE:GREGORIAN"];
|
|
3161
3192
|
for (let m = 0; m < r; m++) {
|
|
3162
|
-
const d =
|
|
3193
|
+
const d = ko(n, a ? m + 1 : (m + 1) * 12), i = a ? `instalment ${m + 1}` : `year ${m + 1}`;
|
|
3163
3194
|
u.push(
|
|
3164
3195
|
"BEGIN:VEVENT",
|
|
3165
3196
|
`UID:${Zt(e.calculatorId)}-${m + 1}-${Xt(d)}@arthaganaka`,
|
|
@@ -3172,13 +3203,13 @@ function vo(e) {
|
|
|
3172
3203
|
return u.push("END:VCALENDAR"), u.join(`\r
|
|
3173
3204
|
`);
|
|
3174
3205
|
}
|
|
3175
|
-
async function
|
|
3206
|
+
async function qn(e) {
|
|
3176
3207
|
var n;
|
|
3177
3208
|
const t = typeof navigator < "u" ? navigator : void 0;
|
|
3178
3209
|
if ((n = t == null ? void 0 : t.clipboard) != null && n.writeText) return t.clipboard.writeText(e);
|
|
3179
3210
|
throw new Error("Clipboard is not available in this browser.");
|
|
3180
3211
|
}
|
|
3181
|
-
async function
|
|
3212
|
+
async function xo(e, t) {
|
|
3182
3213
|
var a;
|
|
3183
3214
|
const n = typeof navigator < "u" ? navigator : void 0;
|
|
3184
3215
|
if ((a = n == null ? void 0 : n.clipboard) != null && a.write && typeof ClipboardItem < "u" && typeof Blob < "u")
|
|
@@ -3192,18 +3223,18 @@ async function ko(e, t) {
|
|
|
3192
3223
|
return;
|
|
3193
3224
|
} catch {
|
|
3194
3225
|
}
|
|
3195
|
-
await
|
|
3226
|
+
await qn(t);
|
|
3196
3227
|
}
|
|
3197
|
-
function
|
|
3228
|
+
function So(e) {
|
|
3198
3229
|
if (!Ot() || typeof window > "u") throw new Error("Print is only available in the browser.");
|
|
3199
3230
|
const t = document.createElement("div");
|
|
3200
|
-
t.className = "fc-print-root", t.innerHTML =
|
|
3231
|
+
t.className = "fc-print-root", t.innerHTML = Hn(e), document.body.appendChild(t), document.body.classList.add("fc-printing");
|
|
3201
3232
|
const n = () => {
|
|
3202
3233
|
document.body.classList.remove("fc-printing"), t.remove(), window.removeEventListener("afterprint", n);
|
|
3203
3234
|
};
|
|
3204
3235
|
window.addEventListener("afterprint", n), window.print(), setTimeout(n, 1500);
|
|
3205
3236
|
}
|
|
3206
|
-
function
|
|
3237
|
+
function Co(e, t = 2) {
|
|
3207
3238
|
if (!Ot()) return Promise.reject(new Error("PNG export is only available in the browser."));
|
|
3208
3239
|
const n = Re(e), a = 620, r = 120 + n.length * 30 + 30, s = document.createElement("canvas");
|
|
3209
3240
|
s.width = a * t, s.height = r * t;
|
|
@@ -3220,7 +3251,7 @@ function No(e, t = 2) {
|
|
|
3220
3251
|
(i, c) => s.toBlob((l) => l ? i(l) : c(new Error("Could not render PNG.")), "image/png")
|
|
3221
3252
|
);
|
|
3222
3253
|
}
|
|
3223
|
-
async function
|
|
3254
|
+
async function Po(e) {
|
|
3224
3255
|
let t;
|
|
3225
3256
|
try {
|
|
3226
3257
|
t = await import(
|
|
@@ -3246,7 +3277,7 @@ async function xo(e) {
|
|
|
3246
3277
|
const s = ve(e, "pdf");
|
|
3247
3278
|
return a.save(s), { ok: !0, filename: s };
|
|
3248
3279
|
}
|
|
3249
|
-
async function
|
|
3280
|
+
async function To(e) {
|
|
3250
3281
|
var i, c;
|
|
3251
3282
|
let t;
|
|
3252
3283
|
try {
|
|
@@ -3269,12 +3300,12 @@ async function So(e) {
|
|
|
3269
3300
|
const m = a(u, { type: "array", bookType: "xlsx" }), d = ve(e, "xlsx");
|
|
3270
3301
|
return Se(d, new Blob([m], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" })), { ok: !0, filename: d };
|
|
3271
3302
|
}
|
|
3272
|
-
function
|
|
3273
|
-
const t =
|
|
3303
|
+
function Gn(e) {
|
|
3304
|
+
const t = _n(e.calculatorId, e.values);
|
|
3274
3305
|
return (typeof location < "u" ? location.origin + location.pathname : "") + t;
|
|
3275
3306
|
}
|
|
3276
|
-
async function
|
|
3277
|
-
const t =
|
|
3307
|
+
async function Fo(e) {
|
|
3308
|
+
const t = _n(e.calculatorId, e.values), n = Gn(e);
|
|
3278
3309
|
if (typeof location < "u")
|
|
3279
3310
|
try {
|
|
3280
3311
|
location.hash = t;
|
|
@@ -3282,31 +3313,31 @@ async function Co(e) {
|
|
|
3282
3313
|
}
|
|
3283
3314
|
const a = n.length > 2e3 ? `Link is long (${n.length} chars) — some apps may trim it. ` : "";
|
|
3284
3315
|
try {
|
|
3285
|
-
return await
|
|
3316
|
+
return await qn(n), { ok: !0, data: n, note: `${a}Link copied to clipboard.` };
|
|
3286
3317
|
} catch {
|
|
3287
3318
|
return { ok: !0, data: n, note: `${a}Link is in the address bar — copy it from there.` };
|
|
3288
3319
|
}
|
|
3289
3320
|
}
|
|
3290
|
-
function
|
|
3321
|
+
function Io(e) {
|
|
3291
3322
|
return {
|
|
3292
3323
|
ok: !0,
|
|
3293
|
-
data:
|
|
3324
|
+
data: Gn(e),
|
|
3294
3325
|
note: "A QR image needs an optional QR library — share this link instead."
|
|
3295
3326
|
};
|
|
3296
3327
|
}
|
|
3297
|
-
function
|
|
3298
|
-
const t = e.schemaVersion ??
|
|
3328
|
+
function Ro(e = {}) {
|
|
3329
|
+
const t = e.schemaVersion ?? On, n = {
|
|
3299
3330
|
csv: (a) => {
|
|
3300
3331
|
const r = ve(a, "csv");
|
|
3301
|
-
return Se(r,
|
|
3332
|
+
return Se(r, mo(a), "text/csv;charset=utf-8"), { ok: !0, filename: r };
|
|
3302
3333
|
},
|
|
3303
3334
|
tsv: (a) => {
|
|
3304
3335
|
const r = ve(a, "tsv");
|
|
3305
|
-
return Se(r,
|
|
3336
|
+
return Se(r, po(a), "text/tab-separated-values;charset=utf-8"), { ok: !0, filename: r };
|
|
3306
3337
|
},
|
|
3307
3338
|
json: (a) => {
|
|
3308
3339
|
const r = ve(a, "json");
|
|
3309
|
-
return Se(r,
|
|
3340
|
+
return Se(r, ho(a, t), "application/json"), { ok: !0, filename: r };
|
|
3310
3341
|
},
|
|
3311
3342
|
markdown: (a) => {
|
|
3312
3343
|
const r = ve(a, "md");
|
|
@@ -3314,18 +3345,18 @@ function To(e = {}) {
|
|
|
3314
3345
|
},
|
|
3315
3346
|
ics: (a) => {
|
|
3316
3347
|
const r = ve(a, "ics");
|
|
3317
|
-
return Se(r,
|
|
3348
|
+
return Se(r, No(a), "text/calendar;charset=utf-8"), { ok: !0, filename: r };
|
|
3318
3349
|
},
|
|
3319
|
-
clipboard: async (a) => (await
|
|
3320
|
-
print: (a) => (
|
|
3321
|
-
url: (a) =>
|
|
3322
|
-
qr: (a) =>
|
|
3350
|
+
clipboard: async (a) => (await xo(Hn(a), Jt(a)), { ok: !0, note: "Copied table to clipboard." }),
|
|
3351
|
+
print: (a) => (So(a), { ok: !0 }),
|
|
3352
|
+
url: (a) => Fo(a),
|
|
3353
|
+
qr: (a) => Io(a),
|
|
3323
3354
|
png: async (a, r) => {
|
|
3324
3355
|
const s = ve(a, "png");
|
|
3325
|
-
return Se(s, await
|
|
3356
|
+
return Se(s, await Co(a, r.scale ?? 2)), { ok: !0, filename: s };
|
|
3326
3357
|
},
|
|
3327
|
-
pdf: (a) =>
|
|
3328
|
-
xlsx: (a) =>
|
|
3358
|
+
pdf: (a) => Po(a),
|
|
3359
|
+
xlsx: (a) => To(a)
|
|
3329
3360
|
};
|
|
3330
3361
|
return {
|
|
3331
3362
|
formats: Object.keys(n),
|
|
@@ -3335,13 +3366,13 @@ function To(e = {}) {
|
|
|
3335
3366
|
}
|
|
3336
3367
|
};
|
|
3337
3368
|
}
|
|
3338
|
-
function
|
|
3339
|
-
const t =
|
|
3340
|
-
|
|
3369
|
+
function jn({ payload: e }) {
|
|
3370
|
+
const t = X(() => Ro(), []), [n, a] = M(!1), [r, s] = M(null), u = de(null), m = de(null), d = de([]);
|
|
3371
|
+
Q(() => {
|
|
3341
3372
|
if (!r) return;
|
|
3342
3373
|
const p = setTimeout(() => s(null), 4500);
|
|
3343
3374
|
return () => clearTimeout(p);
|
|
3344
|
-
}, [r]),
|
|
3375
|
+
}, [r]), Q(() => {
|
|
3345
3376
|
var h;
|
|
3346
3377
|
if (!n) return;
|
|
3347
3378
|
(h = d.current[0]) == null || h.focus();
|
|
@@ -3404,7 +3435,7 @@ function Gn({ payload: e }) {
|
|
|
3404
3435
|
}
|
|
3405
3436
|
)
|
|
3406
3437
|
] }),
|
|
3407
|
-
n && /* @__PURE__ */ o("div", { ref: m, className: "menu-list", role: "menu", "aria-label": "Export as", children:
|
|
3438
|
+
n && /* @__PURE__ */ o("div", { ref: m, className: "menu-list", role: "menu", "aria-label": "Export as", children: so.map((p, h) => /* @__PURE__ */ o(
|
|
3408
3439
|
"button",
|
|
3409
3440
|
{
|
|
3410
3441
|
type: "button",
|
|
@@ -3421,10 +3452,10 @@ function Gn({ payload: e }) {
|
|
|
3421
3452
|
r && /* @__PURE__ */ o("div", { className: `export-toast ${r.kind}`, role: "status", "aria-live": "polite", children: r.msg })
|
|
3422
3453
|
] });
|
|
3423
3454
|
}
|
|
3424
|
-
const Bt = "calcsuite:history",
|
|
3455
|
+
const Bt = "calcsuite:history", Eo = 100, Mo = [];
|
|
3425
3456
|
let Ce = null;
|
|
3426
|
-
const
|
|
3427
|
-
function
|
|
3457
|
+
const Je = /* @__PURE__ */ new Set();
|
|
3458
|
+
function Vn() {
|
|
3428
3459
|
if (Ce) return Ce;
|
|
3429
3460
|
try {
|
|
3430
3461
|
Ce = JSON.parse(localStorage.getItem(Bt) || "[]");
|
|
@@ -3433,39 +3464,39 @@ function jn() {
|
|
|
3433
3464
|
}
|
|
3434
3465
|
return Ce;
|
|
3435
3466
|
}
|
|
3436
|
-
function
|
|
3467
|
+
function Yn(e) {
|
|
3437
3468
|
Ce = e;
|
|
3438
3469
|
try {
|
|
3439
3470
|
localStorage.setItem(Bt, JSON.stringify(e));
|
|
3440
3471
|
} catch {
|
|
3441
3472
|
}
|
|
3442
|
-
|
|
3473
|
+
Je.forEach((t) => t());
|
|
3443
3474
|
}
|
|
3444
3475
|
let Qt = !1;
|
|
3445
|
-
function
|
|
3446
|
-
return
|
|
3447
|
-
t.key === Bt && (Ce = null,
|
|
3448
|
-
})), () =>
|
|
3476
|
+
function $o(e) {
|
|
3477
|
+
return Je.add(e), !Qt && typeof window < "u" && (Qt = !0, window.addEventListener("storage", (t) => {
|
|
3478
|
+
t.key === Bt && (Ce = null, Je.forEach((n) => n()));
|
|
3479
|
+
})), () => Je.delete(e);
|
|
3449
3480
|
}
|
|
3450
|
-
function
|
|
3451
|
-
|
|
3481
|
+
function Kn(e) {
|
|
3482
|
+
Yn([{ ...e, at: Date.now() }, ...Vn()].slice(0, Eo));
|
|
3452
3483
|
}
|
|
3453
|
-
function
|
|
3454
|
-
|
|
3484
|
+
function Ao() {
|
|
3485
|
+
Yn([]);
|
|
3455
3486
|
}
|
|
3456
|
-
function
|
|
3457
|
-
const e =
|
|
3487
|
+
function Do() {
|
|
3488
|
+
const e = ba($o, Vn, () => Mo), t = ke((a) => Kn(a), []), n = ke(() => Ao(), []);
|
|
3458
3489
|
return { items: e, save: t, clear: n };
|
|
3459
3490
|
}
|
|
3460
|
-
function
|
|
3491
|
+
function Wn({ item: e }) {
|
|
3461
3492
|
const [t, n] = M(!1), a = de();
|
|
3462
|
-
return
|
|
3463
|
-
|
|
3493
|
+
return Q(() => () => clearTimeout(a.current), []), /* @__PURE__ */ o("button", { className: `icon-btn ${t ? "saved" : ""}`, onClick: () => {
|
|
3494
|
+
Kn(e), n(!0), clearTimeout(a.current), a.current = setTimeout(() => n(!1), 1500);
|
|
3464
3495
|
}, "aria-live": "polite", children: t ? "Saved ✓" : "Save" });
|
|
3465
3496
|
}
|
|
3466
|
-
const
|
|
3467
|
-
function
|
|
3468
|
-
const { settings: e, fmt: t } = ue(), n = e.region, a = me[n], [r, s] = M("payment"), [u, m] = M(a.defaultBasis), [d, i] = M(n === "IN" ? "2500000" : "300000"), [c, l] = M(a.defaultRatePct), [p, h] = M(String(Math.floor(a.defaultTermMonths / 12))), [f, y] = M(String(a.defaultTermMonths % 12)), [w, k] = M(n === "IN" ? "21934" : "1896"), [S, F] = M("schedule"), N = u === "flat" ? ["payment", "principal"] : ["payment", "principal", "rate", "tenure"], P = (parseInt(p || "0", 10) || 0) * 12 + (parseInt(f || "0", 10) || 0), x = (R) => R.replace(/[, ]/g, "").trim(), { result: T, error: $ } =
|
|
3497
|
+
const Lo = { payment: "Payment", principal: "Amount", rate: "Rate", tenure: "Term" };
|
|
3498
|
+
function zn() {
|
|
3499
|
+
const { settings: e, fmt: t } = ue(), n = e.region, a = me[n], [r, s] = M("payment"), [u, m] = M(a.defaultBasis), [d, i] = M(n === "IN" ? "2500000" : "300000"), [c, l] = M(a.defaultRatePct), [p, h] = M(String(Math.floor(a.defaultTermMonths / 12))), [f, y] = M(String(a.defaultTermMonths % 12)), [w, k] = M(n === "IN" ? "21934" : "1896"), [S, F] = M("schedule"), N = u === "flat" ? ["payment", "principal"] : ["payment", "principal", "rate", "tenure"], P = (parseInt(p || "0", 10) || 0) * 12 + (parseInt(f || "0", 10) || 0), x = (R) => R.replace(/[, ]/g, "").trim(), { result: T, error: $ } = X(() => {
|
|
3469
3500
|
try {
|
|
3470
3501
|
return { result: Ie({
|
|
3471
3502
|
region: n,
|
|
@@ -3482,7 +3513,7 @@ function Wn() {
|
|
|
3482
3513
|
payment: T ? t.money(T.payment) : "—",
|
|
3483
3514
|
principal: T ? t.money(T.principal) : "—",
|
|
3484
3515
|
rate: T ? `${t.num(T.annualRatePct, 3)} %` : "—",
|
|
3485
|
-
tenure: T ?
|
|
3516
|
+
tenure: T ? pt(T.tenureMonths) : "—"
|
|
3486
3517
|
}, G = T ? t.moneyParts(T.payment) : { symbol: "", digits: "—" }, q = e.currency.symbol, A = {
|
|
3487
3518
|
region: n,
|
|
3488
3519
|
basis: u,
|
|
@@ -3523,7 +3554,7 @@ function Wn() {
|
|
|
3523
3554
|
{ label: "Principal", value: t.money(R.principal) },
|
|
3524
3555
|
{ label: "Total interest", value: t.money(R.totalInterest), tone: "interest" },
|
|
3525
3556
|
{ label: "Total payment", value: t.money(R.totalPayment) },
|
|
3526
|
-
{ label: a.tenureWord, value:
|
|
3557
|
+
{ label: a.tenureWord, value: pt(R.tenureMonths) }
|
|
3527
3558
|
],
|
|
3528
3559
|
schedule: j,
|
|
3529
3560
|
formula: R.formula,
|
|
@@ -3540,7 +3571,7 @@ function Wn() {
|
|
|
3540
3571
|
/* @__PURE__ */ b("section", { className: "card", children: [
|
|
3541
3572
|
/* @__PURE__ */ b("div", { className: "solve-row", children: [
|
|
3542
3573
|
/* @__PURE__ */ o("span", { className: "lbl", children: "Solve for" }),
|
|
3543
|
-
/* @__PURE__ */ o("div", { className: "seg", role: "group", "aria-label": "Solve for", children: N.map((R) => /* @__PURE__ */ o("button", { "aria-pressed": r === R, onClick: () => s(R), children:
|
|
3574
|
+
/* @__PURE__ */ o("div", { className: "seg", role: "group", "aria-label": "Solve for", children: N.map((R) => /* @__PURE__ */ o("button", { "aria-pressed": r === R, onClick: () => s(R), children: Lo[R] }, R)) })
|
|
3544
3575
|
] }),
|
|
3545
3576
|
/* @__PURE__ */ b("div", { className: "field", style: { marginBottom: "calc(var(--fc-space) * 2)" }, children: [
|
|
3546
3577
|
/* @__PURE__ */ o("span", { className: "lbl", children: "Interest basis" }),
|
|
@@ -3559,8 +3590,8 @@ function Wn() {
|
|
|
3559
3590
|
] })
|
|
3560
3591
|
] }),
|
|
3561
3592
|
/* @__PURE__ */ b("div", { className: "grid two", children: [
|
|
3562
|
-
/* @__PURE__ */ o(
|
|
3563
|
-
/* @__PURE__ */ o(
|
|
3593
|
+
/* @__PURE__ */ o(bt, { label: "Loan amount", solved: L("principal"), solvedText: B.principal, affix: q, children: /* @__PURE__ */ o("input", { className: "num", inputMode: "decimal", value: d, onChange: (R) => i(R.target.value), "aria-label": "Loan amount" }) }),
|
|
3594
|
+
/* @__PURE__ */ o(bt, { label: "Interest rate", solved: L("rate"), solvedText: B.rate, suffix: "% p.a.", children: /* @__PURE__ */ o("input", { className: "num", inputMode: "decimal", value: c, onChange: (R) => l(R.target.value), "aria-label": "Interest rate" }) }),
|
|
3564
3595
|
/* @__PURE__ */ b("div", { className: "field", children: [
|
|
3565
3596
|
/* @__PURE__ */ o("span", { className: "lbl", children: a.tenureWord }),
|
|
3566
3597
|
L("tenure") ? /* @__PURE__ */ b(re, { children: [
|
|
@@ -3577,7 +3608,7 @@ function Wn() {
|
|
|
3577
3608
|
] })
|
|
3578
3609
|
] })
|
|
3579
3610
|
] }),
|
|
3580
|
-
/* @__PURE__ */ o(
|
|
3611
|
+
/* @__PURE__ */ o(bt, { label: a.paymentLabel, solved: L("payment"), solvedText: B.payment, affix: q, children: /* @__PURE__ */ o("input", { className: "num", inputMode: "decimal", value: w, onChange: (R) => k(R.target.value), "aria-label": a.paymentLabel }) })
|
|
3581
3612
|
] }),
|
|
3582
3613
|
$ && /* @__PURE__ */ o("div", { className: "error", role: "alert", style: { marginTop: 16 }, children: $ })
|
|
3583
3614
|
] }),
|
|
@@ -3594,7 +3625,7 @@ function Wn() {
|
|
|
3594
3625
|
/* @__PURE__ */ o("span", { className: "per", children: " /month" })
|
|
3595
3626
|
] })
|
|
3596
3627
|
] }),
|
|
3597
|
-
/* @__PURE__ */ o(
|
|
3628
|
+
/* @__PURE__ */ o(Uo, { result: T }),
|
|
3598
3629
|
/* @__PURE__ */ b("div", { className: "secondary", children: [
|
|
3599
3630
|
/* @__PURE__ */ b("div", { className: "kv", children: [
|
|
3600
3631
|
/* @__PURE__ */ o("div", { className: "k", children: "Principal" }),
|
|
@@ -3610,18 +3641,18 @@ function Wn() {
|
|
|
3610
3641
|
] }),
|
|
3611
3642
|
/* @__PURE__ */ b("div", { className: "kv", children: [
|
|
3612
3643
|
/* @__PURE__ */ o("div", { className: "k", children: a.tenureWord }),
|
|
3613
|
-
/* @__PURE__ */ o("div", { className: "v num", children:
|
|
3644
|
+
/* @__PURE__ */ o("div", { className: "v num", children: pt(T.tenureMonths) })
|
|
3614
3645
|
] })
|
|
3615
3646
|
] }),
|
|
3616
3647
|
/* @__PURE__ */ b("div", { className: "actions-row", children: [
|
|
3617
3648
|
/* @__PURE__ */ o(
|
|
3618
|
-
|
|
3649
|
+
Wn,
|
|
3619
3650
|
{
|
|
3620
3651
|
item: { id: "loan.emi", title: `Loan — ${t.money(T.payment)}/mo`, primary: t.money(T.payment), values: A }
|
|
3621
3652
|
}
|
|
3622
3653
|
),
|
|
3623
3654
|
/* @__PURE__ */ o(
|
|
3624
|
-
|
|
3655
|
+
jn,
|
|
3625
3656
|
{
|
|
3626
3657
|
payload: {
|
|
3627
3658
|
calculatorId: "loan.emi",
|
|
@@ -3653,8 +3684,8 @@ function Wn() {
|
|
|
3653
3684
|
e.ui.showFormulas && /* @__PURE__ */ o("button", { role: "tab", "aria-selected": S === "formula", onClick: () => F("formula"), children: "Formula" })
|
|
3654
3685
|
] }),
|
|
3655
3686
|
/* @__PURE__ */ b("div", { className: "tab-anim", children: [
|
|
3656
|
-
S === "schedule" && /* @__PURE__ */ o(
|
|
3657
|
-
S === "chart" && /* @__PURE__ */ o(
|
|
3687
|
+
S === "schedule" && /* @__PURE__ */ o(Oo, { result: T }),
|
|
3688
|
+
S === "chart" && /* @__PURE__ */ o(Bo, { result: T }),
|
|
3658
3689
|
S === "formula" && e.ui.showFormulas && /* @__PURE__ */ b("div", { className: "formula", children: [
|
|
3659
3690
|
/* @__PURE__ */ o("code", { children: T.formula }),
|
|
3660
3691
|
/* @__PURE__ */ b("div", { className: "assumptions", children: [
|
|
@@ -3679,7 +3710,7 @@ function Wn() {
|
|
|
3679
3710
|
] })
|
|
3680
3711
|
] });
|
|
3681
3712
|
}
|
|
3682
|
-
function
|
|
3713
|
+
function bt({
|
|
3683
3714
|
label: e,
|
|
3684
3715
|
solved: t,
|
|
3685
3716
|
solvedText: n,
|
|
@@ -3699,7 +3730,7 @@ function ft({
|
|
|
3699
3730
|
] })
|
|
3700
3731
|
] });
|
|
3701
3732
|
}
|
|
3702
|
-
function
|
|
3733
|
+
function Uo({ result: e }) {
|
|
3703
3734
|
const { fmt: t } = ue(), n = Number(e.principal.toFixed(2)), a = Number(e.totalInterest.toFixed(2)), r = n + a || 1, s = Math.round(n / r * 100);
|
|
3704
3735
|
return /* @__PURE__ */ b(re, { children: [
|
|
3705
3736
|
/* @__PURE__ */ b("div", { className: "splitbar", role: "img", "aria-label": `Principal ${s}%, interest ${100 - s}%`, children: [
|
|
@@ -3724,7 +3755,7 @@ function Ao({ result: e }) {
|
|
|
3724
3755
|
] })
|
|
3725
3756
|
] });
|
|
3726
3757
|
}
|
|
3727
|
-
function
|
|
3758
|
+
function Oo({ result: e }) {
|
|
3728
3759
|
const { fmt: t } = ue(), [n, a] = M("yearly"), [r, s] = M(/* @__PURE__ */ new Set([1])), u = (d) => s((i) => {
|
|
3729
3760
|
const c = new Set(i);
|
|
3730
3761
|
return c.has(d) ? c.delete(d) : c.add(d), c;
|
|
@@ -3786,7 +3817,7 @@ function Do({ result: e }) {
|
|
|
3786
3817
|
] }) })
|
|
3787
3818
|
] });
|
|
3788
3819
|
}
|
|
3789
|
-
function
|
|
3820
|
+
function Bo({ result: e }) {
|
|
3790
3821
|
const { fmt: t } = ue(), n = e.chart.balance.map((k) => k.toNumber()), a = e.chart.cumulativeInterest.map((k) => k.toNumber()), r = n.length, s = 720, u = 260, m = 8, d = 8, i = 12, c = 22, l = e.principal.toNumber(), p = Math.max(l, a[a.length - 1] ?? 0) || 1, h = (k) => m + k / Math.max(r - 1, 1) * (s - m - d), f = (k) => i + (1 - k / p) * (u - i - c), y = (k) => k.map((S, F) => `${F === 0 ? "M" : "L"}${h(F).toFixed(1)},${f(S).toFixed(1)}`).join(" "), w = `M${h(0)},${f(l)} ${n.map((k, S) => `L${h(S).toFixed(1)},${f(k).toFixed(1)}`).join(" ")} L${h(r - 1)},${f(0)} L${h(0)},${f(0)} Z`;
|
|
3791
3822
|
return /* @__PURE__ */ b("div", { className: "chart", children: [
|
|
3792
3823
|
/* @__PURE__ */ b("svg", { viewBox: `0 0 ${s} ${u}`, role: "img", "aria-label": "Balance and cumulative interest over the term", children: [
|
|
@@ -3809,7 +3840,7 @@ function Lo({ result: e }) {
|
|
|
3809
3840
|
] })
|
|
3810
3841
|
] });
|
|
3811
3842
|
}
|
|
3812
|
-
const
|
|
3843
|
+
const _o = /* @__PURE__ */ new Set([
|
|
3813
3844
|
"sin",
|
|
3814
3845
|
"cos",
|
|
3815
3846
|
"tan",
|
|
@@ -3846,7 +3877,7 @@ const Uo = /* @__PURE__ */ new Set([
|
|
|
3846
3877
|
"sq",
|
|
3847
3878
|
"cube",
|
|
3848
3879
|
"recip"
|
|
3849
|
-
]),
|
|
3880
|
+
]), Ho = {
|
|
3850
3881
|
arcsin: "asin",
|
|
3851
3882
|
arccos: "acos",
|
|
3852
3883
|
arctan: "atan",
|
|
@@ -3854,14 +3885,14 @@ const Uo = /* @__PURE__ */ new Set([
|
|
|
3854
3885
|
log10: "log",
|
|
3855
3886
|
ncr: "ncr",
|
|
3856
3887
|
npr: "npr"
|
|
3857
|
-
},
|
|
3858
|
-
` || e === "\r", fe = (e) => e >= "0" && e <= "9", en = (e) => e >= "a" && e <= "z" || e >= "A" && e <= "Z",
|
|
3859
|
-
function
|
|
3860
|
-
return e === "HEX" ?
|
|
3861
|
-
}
|
|
3862
|
-
function
|
|
3863
|
-
const t = e.toLowerCase(), n =
|
|
3864
|
-
if (
|
|
3888
|
+
}, qo = (e) => e === " " || e === " " || e === `
|
|
3889
|
+
` || e === "\r", fe = (e) => e >= "0" && e <= "9", en = (e) => e >= "a" && e <= "z" || e >= "A" && e <= "Z", Jn = (e) => fe(e) || e >= "a" && e <= "f" || e >= "A" && e <= "F", tn = /* @__PURE__ */ new Set(["num", "const", "var", "func", "lparen", "uop"]), Go = /* @__PURE__ */ new Set(["num", "const", "var", "rparen", "postfix"]);
|
|
3890
|
+
function jo(e) {
|
|
3891
|
+
return e === "HEX" ? Jn : e === "OCT" ? (t) => t >= "0" && t <= "7" : e === "BIN" ? (t) => t === "0" || t === "1" : fe;
|
|
3892
|
+
}
|
|
3893
|
+
function Vo(e) {
|
|
3894
|
+
const t = e.toLowerCase(), n = Ho[t] ?? t;
|
|
3895
|
+
if (_o.has(n)) return { type: "func", value: n };
|
|
3865
3896
|
if (t === "mod") return { type: "op", value: "mod" };
|
|
3866
3897
|
if (t === "and") return { type: "op", value: "and" };
|
|
3867
3898
|
if (t === "or") return { type: "op", value: "or" };
|
|
@@ -3878,12 +3909,12 @@ function qo(e) {
|
|
|
3878
3909
|
}
|
|
3879
3910
|
throw new Error(`Unknown name: ${e}`);
|
|
3880
3911
|
}
|
|
3881
|
-
function
|
|
3912
|
+
function Yo(e, t = {}) {
|
|
3882
3913
|
const n = t.base ?? "DEC", a = e, r = [];
|
|
3883
3914
|
let s = 0;
|
|
3884
3915
|
for (; s < a.length; ) {
|
|
3885
3916
|
const d = a[s];
|
|
3886
|
-
if (
|
|
3917
|
+
if (qo(d)) {
|
|
3887
3918
|
s++;
|
|
3888
3919
|
continue;
|
|
3889
3920
|
}
|
|
@@ -3891,14 +3922,14 @@ function Go(e, t = {}) {
|
|
|
3891
3922
|
if (d === "0" && (a[s + 1] === "x" || a[s + 1] === "X" || a[s + 1] === "o" || a[s + 1] === "O" || a[s + 1] === "b" || a[s + 1] === "B")) {
|
|
3892
3923
|
const l = a[s + 1].toLowerCase();
|
|
3893
3924
|
let p = s + 2;
|
|
3894
|
-
const h = l === "x" ?
|
|
3925
|
+
const h = l === "x" ? Jn : l === "o" ? (y) => y >= "0" && y <= "7" : (y) => y === "0" || y === "1", f = p;
|
|
3895
3926
|
for (; p < a.length && h(a[p]); ) p++;
|
|
3896
3927
|
if (p === f) throw new Error(`Malformed 0${l} literal`);
|
|
3897
3928
|
r.push({ type: "num", value: BigInt(`0${l}${a.slice(f, p)}`).toString() }), s = p;
|
|
3898
3929
|
continue;
|
|
3899
3930
|
}
|
|
3900
3931
|
if (n !== "DEC") {
|
|
3901
|
-
const l =
|
|
3932
|
+
const l = jo(n);
|
|
3902
3933
|
let p = s;
|
|
3903
3934
|
for (; p < a.length && l(a[p]); ) p++;
|
|
3904
3935
|
const h = a.slice(s, p), f = n === "HEX" ? "0x" : n === "OCT" ? "0o" : "0b";
|
|
@@ -3922,7 +3953,7 @@ function Go(e, t = {}) {
|
|
|
3922
3953
|
if (en(d) || d === "_") {
|
|
3923
3954
|
let c = s;
|
|
3924
3955
|
for (; c < a.length && (en(a[c]) || fe(a[c]) || a[c] === "_"); ) c++;
|
|
3925
|
-
r.push(
|
|
3956
|
+
r.push(Vo(a.slice(s, c))), s = c;
|
|
3926
3957
|
continue;
|
|
3927
3958
|
}
|
|
3928
3959
|
const i = a.slice(s, s + 2);
|
|
@@ -4002,11 +4033,11 @@ function Go(e, t = {}) {
|
|
|
4002
4033
|
}), m = [];
|
|
4003
4034
|
for (let d = 0; d < u.length; d++) {
|
|
4004
4035
|
const i = u[d], c = m[m.length - 1];
|
|
4005
|
-
c &&
|
|
4036
|
+
c && Go.has(c.type) && tn.has(i.type) && m.push({ type: "op", value: "*", implicit: !0 }), m.push(i);
|
|
4006
4037
|
}
|
|
4007
4038
|
return m;
|
|
4008
4039
|
}
|
|
4009
|
-
const
|
|
4040
|
+
const Ko = {
|
|
4010
4041
|
or: { prec: 1 },
|
|
4011
4042
|
xor: { prec: 2 },
|
|
4012
4043
|
and: { prec: 3 },
|
|
@@ -4020,7 +4051,7 @@ const jo = {
|
|
|
4020
4051
|
"%": { prec: 6 },
|
|
4021
4052
|
"^": { prec: 8, right: !0 }
|
|
4022
4053
|
}, nn = { neg: 7, bnot: 7, sqrt: 10, cbrt: 10, qdrt: 10 }, De = Symbol("arg");
|
|
4023
|
-
function
|
|
4054
|
+
function Wo(e) {
|
|
4024
4055
|
const t = [], n = [];
|
|
4025
4056
|
let a = !0;
|
|
4026
4057
|
const r = () => {
|
|
@@ -4071,7 +4102,7 @@ function Vo(e) {
|
|
|
4071
4102
|
else if (d.value !== "+") throw new Error(`Unexpected operator: ${d.value}`);
|
|
4072
4103
|
a = !0;
|
|
4073
4104
|
} else {
|
|
4074
|
-
const i =
|
|
4105
|
+
const i = Ko[d.value];
|
|
4075
4106
|
if (!i) throw new Error(`Unknown operator: ${d.value}`);
|
|
4076
4107
|
for (; n.length; ) {
|
|
4077
4108
|
const c = n[n.length - 1];
|
|
@@ -4112,11 +4143,11 @@ function Vo(e) {
|
|
|
4112
4143
|
if (m === De) throw new Error("Malformed expression");
|
|
4113
4144
|
return m;
|
|
4114
4145
|
}
|
|
4115
|
-
const
|
|
4116
|
-
function
|
|
4146
|
+
const zo = new H("3.141592653589793238462643383279502884197"), Jo = new H("2.718281828459045235360287471352662497757"), Zo = new H("1.618033988749894848204586834365638117720");
|
|
4147
|
+
function gt(e, t) {
|
|
4117
4148
|
return t === "deg" ? e * Math.PI / 180 : t === "grad" ? e * Math.PI / 200 : e;
|
|
4118
4149
|
}
|
|
4119
|
-
function
|
|
4150
|
+
function vt(e, t) {
|
|
4120
4151
|
return t === "deg" ? e * 180 / Math.PI : t === "grad" ? e * 200 / Math.PI : e;
|
|
4121
4152
|
}
|
|
4122
4153
|
function an(e) {
|
|
@@ -4126,13 +4157,13 @@ function an(e) {
|
|
|
4126
4157
|
for (let n = 2; n <= e.toNumber(); n++) t = t.times(n);
|
|
4127
4158
|
return t;
|
|
4128
4159
|
}
|
|
4129
|
-
function
|
|
4160
|
+
function Xo(e, t) {
|
|
4130
4161
|
if (!e.isInteger() || !t.isInteger() || t.isNegative() || t.gt(e)) throw new Error("nPr domain");
|
|
4131
4162
|
let n = g(1);
|
|
4132
4163
|
for (let a = 0; a < t.toNumber(); a++) n = n.times(e.minus(a));
|
|
4133
4164
|
return n;
|
|
4134
4165
|
}
|
|
4135
|
-
function
|
|
4166
|
+
function Qo(e, t) {
|
|
4136
4167
|
if (!e.isInteger() || !t.isInteger() || t.isNegative() || t.gt(e)) throw new Error("nCr domain");
|
|
4137
4168
|
const n = H.min(t, e.minus(t));
|
|
4138
4169
|
let a = g(1);
|
|
@@ -4147,7 +4178,7 @@ function rn(e, t) {
|
|
|
4147
4178
|
}
|
|
4148
4179
|
return n;
|
|
4149
4180
|
}
|
|
4150
|
-
function
|
|
4181
|
+
function kt(e, t) {
|
|
4151
4182
|
if (e.isNegative()) {
|
|
4152
4183
|
if (t.isInteger() && !t.mod(2).isZero()) return e.abs().pow(g(1).div(t)).neg();
|
|
4153
4184
|
throw new Error("root of negative");
|
|
@@ -4155,7 +4186,7 @@ function gt(e, t) {
|
|
|
4155
4186
|
return e.pow(g(1).div(t));
|
|
4156
4187
|
}
|
|
4157
4188
|
const ie = (e) => BigInt(e.trunc().toFixed(0));
|
|
4158
|
-
function
|
|
4189
|
+
function ei(e, t = {}) {
|
|
4159
4190
|
const n = t.angleMode ?? "deg", a = t.percentMode ?? "of", r = (i) => {
|
|
4160
4191
|
var l;
|
|
4161
4192
|
if (i === "ans") return g(t.ans ?? 0);
|
|
@@ -4167,22 +4198,22 @@ function Zo(e, t = {}) {
|
|
|
4167
4198
|
let p;
|
|
4168
4199
|
switch (i) {
|
|
4169
4200
|
case "sin":
|
|
4170
|
-
p = Math.sin(
|
|
4201
|
+
p = Math.sin(gt(l, n));
|
|
4171
4202
|
break;
|
|
4172
4203
|
case "cos":
|
|
4173
|
-
p = Math.cos(
|
|
4204
|
+
p = Math.cos(gt(l, n));
|
|
4174
4205
|
break;
|
|
4175
4206
|
case "tan":
|
|
4176
|
-
p = Math.tan(
|
|
4207
|
+
p = Math.tan(gt(l, n));
|
|
4177
4208
|
break;
|
|
4178
4209
|
case "asin":
|
|
4179
|
-
p =
|
|
4210
|
+
p = vt(Math.asin(l), n);
|
|
4180
4211
|
break;
|
|
4181
4212
|
case "acos":
|
|
4182
|
-
p =
|
|
4213
|
+
p = vt(Math.acos(l), n);
|
|
4183
4214
|
break;
|
|
4184
4215
|
case "atan":
|
|
4185
|
-
p =
|
|
4216
|
+
p = vt(Math.atan(l), n);
|
|
4186
4217
|
break;
|
|
4187
4218
|
case "sinh":
|
|
4188
4219
|
p = Math.sinh(l);
|
|
@@ -4216,11 +4247,11 @@ function Zo(e, t = {}) {
|
|
|
4216
4247
|
case "sqrt":
|
|
4217
4248
|
return p(1), l.sqrt();
|
|
4218
4249
|
case "cbrt":
|
|
4219
|
-
return p(1),
|
|
4250
|
+
return p(1), kt(l, g(3));
|
|
4220
4251
|
case "qdrt":
|
|
4221
|
-
return p(1),
|
|
4252
|
+
return p(1), kt(l, g(4));
|
|
4222
4253
|
case "root":
|
|
4223
|
-
return p(2),
|
|
4254
|
+
return p(2), kt(l, c[1]);
|
|
4224
4255
|
case "pow":
|
|
4225
4256
|
return p(2), l.pow(c[1]);
|
|
4226
4257
|
case "ln":
|
|
@@ -4237,9 +4268,9 @@ function Zo(e, t = {}) {
|
|
|
4237
4268
|
case "tenpow":
|
|
4238
4269
|
return p(1), g(10).pow(l);
|
|
4239
4270
|
case "ncr":
|
|
4240
|
-
return p(2),
|
|
4271
|
+
return p(2), Qo(l, c[1]);
|
|
4241
4272
|
case "npr":
|
|
4242
|
-
return p(2),
|
|
4273
|
+
return p(2), Xo(l, c[1]);
|
|
4243
4274
|
case "gcd":
|
|
4244
4275
|
return p(2), rn(l, c[1]);
|
|
4245
4276
|
case "lcm":
|
|
@@ -4305,7 +4336,7 @@ function Zo(e, t = {}) {
|
|
|
4305
4336
|
case "num":
|
|
4306
4337
|
return g(i.value);
|
|
4307
4338
|
case "const":
|
|
4308
|
-
return i.name === "PI" ?
|
|
4339
|
+
return i.name === "PI" ? zo : i.name === "E" ? Jo : Zo;
|
|
4309
4340
|
case "var":
|
|
4310
4341
|
return r(i.name);
|
|
4311
4342
|
case "percent":
|
|
@@ -4332,7 +4363,7 @@ function Zo(e, t = {}) {
|
|
|
4332
4363
|
function on(e, t = {}) {
|
|
4333
4364
|
if (e == null || e.trim() === "") return { value: new H(0) };
|
|
4334
4365
|
try {
|
|
4335
|
-
const n =
|
|
4366
|
+
const n = Yo(e, { base: t.base }), a = Wo(n), r = ei(a, t);
|
|
4336
4367
|
return r.isNaN() ? { value: r, error: "Not a number" } : { value: r };
|
|
4337
4368
|
} catch (n) {
|
|
4338
4369
|
return { value: new H(NaN), error: n instanceof Error ? n.message : String(n) };
|
|
@@ -4347,8 +4378,8 @@ function sn(e, t) {
|
|
|
4347
4378
|
}
|
|
4348
4379
|
return e.toSignificantDigits(12).toString();
|
|
4349
4380
|
}
|
|
4350
|
-
function
|
|
4351
|
-
const { settings: t } = ue(), n = t.percentMode ?? "of", [a, r] = M(""), [s, u] = M("deg"), [m, d] = M("DEC"), [i, c] = M(!1), [l, p] = M(() => new H(0)), [h, f] = M(() => new H(0)), [y, w] = M([]), k = de(null), S =
|
|
4381
|
+
function Zn({ def: e }) {
|
|
4382
|
+
const { settings: t } = ue(), n = t.percentMode ?? "of", [a, r] = M(""), [s, u] = M("deg"), [m, d] = M("DEC"), [i, c] = M(!1), [l, p] = M(() => new H(0)), [h, f] = M(() => new H(0)), [y, w] = M([]), k = de(null), S = X(
|
|
4352
4383
|
() => on(a, { angleMode: s, percentMode: n, base: m, ans: h, memory: l }),
|
|
4353
4384
|
[a, s, n, m, h, l]
|
|
4354
4385
|
), F = a.trim() ? S.error ? "" : sn(S.value, m) : "", N = (I) => requestAnimationFrame(() => {
|
|
@@ -4495,15 +4526,15 @@ function Jn({ def: e }) {
|
|
|
4495
4526
|
] }),
|
|
4496
4527
|
/* @__PURE__ */ b("div", { className: "sci-pad", role: "group", "aria-label": "calculator keypad", children: [
|
|
4497
4528
|
G.map((I, R) => /* @__PURE__ */ o("div", { className: "sci-row", children: I.map((j, Y) => {
|
|
4498
|
-
const V = i && j.alt ? j.alt : j,
|
|
4529
|
+
const V = i && j.alt ? j.alt : j, ee = j.t === "2nd";
|
|
4499
4530
|
return /* @__PURE__ */ o(
|
|
4500
4531
|
"button",
|
|
4501
4532
|
{
|
|
4502
4533
|
type: "button",
|
|
4503
4534
|
className: `sci-key ${V.cls ?? "fn"}`,
|
|
4504
4535
|
"aria-label": V.aria,
|
|
4505
|
-
"aria-pressed":
|
|
4506
|
-
onClick: () =>
|
|
4536
|
+
"aria-pressed": ee ? i : void 0,
|
|
4537
|
+
onClick: () => ee ? c((Ee) => !Ee) : B(V),
|
|
4507
4538
|
children: V.t
|
|
4508
4539
|
},
|
|
4509
4540
|
Y
|
|
@@ -4536,7 +4567,7 @@ function Jn({ def: e }) {
|
|
|
4536
4567
|
] })
|
|
4537
4568
|
] });
|
|
4538
4569
|
}
|
|
4539
|
-
const
|
|
4570
|
+
const at = [
|
|
4540
4571
|
{ code: "USD", name: "US Dollar", symbol: "$" },
|
|
4541
4572
|
{ code: "EUR", name: "Euro", symbol: "€" },
|
|
4542
4573
|
{ code: "GBP", name: "British Pound", symbol: "£" },
|
|
@@ -4581,28 +4612,28 @@ const tt = [
|
|
|
4581
4612
|
{ code: "BDT", name: "Bangladeshi Taka", symbol: "৳" },
|
|
4582
4613
|
{ code: "LKR", name: "Sri Lankan Rupee", symbol: "Rs" },
|
|
4583
4614
|
{ code: "NPR", name: "Nepalese Rupee", symbol: "रू" }
|
|
4584
|
-
],
|
|
4615
|
+
], ti = (e) => at.find((t) => t.code === e), ni = (e) => e === "INR" ? "en-IN" : "en-US", Xn = (e, t) => g(e).times(t), Qn = (e) => {
|
|
4585
4616
|
const t = g(e);
|
|
4586
4617
|
return t.gt(0) ? g(1).div(t) : g(0);
|
|
4587
4618
|
};
|
|
4588
|
-
function
|
|
4619
|
+
function Mt(e, t) {
|
|
4589
4620
|
const n = g(e);
|
|
4590
4621
|
try {
|
|
4591
|
-
return new Intl.NumberFormat(
|
|
4622
|
+
return new Intl.NumberFormat(ni(t), { style: "currency", currency: t }).format(
|
|
4592
4623
|
Number(n.toFixed(4))
|
|
4593
4624
|
);
|
|
4594
4625
|
} catch {
|
|
4595
4626
|
return `${new Intl.NumberFormat("en-US", { maximumFractionDigits: 4 }).format(Number(n.toFixed(4)))} ${t}`;
|
|
4596
4627
|
}
|
|
4597
4628
|
}
|
|
4598
|
-
function
|
|
4629
|
+
function ea(e) {
|
|
4599
4630
|
try {
|
|
4600
4631
|
return new Intl.NumberFormat("en-US", { style: "currency", currency: e }).resolvedOptions().maximumFractionDigits ?? 2;
|
|
4601
4632
|
} catch {
|
|
4602
4633
|
return 2;
|
|
4603
4634
|
}
|
|
4604
4635
|
}
|
|
4605
|
-
function
|
|
4636
|
+
function Ze(e, t) {
|
|
4606
4637
|
const n = Math.max(0, Math.floor((t - e) / 1e3));
|
|
4607
4638
|
if (n < 60) return "just now";
|
|
4608
4639
|
const a = Math.floor(n / 60);
|
|
@@ -4614,23 +4645,23 @@ function Je(e, t) {
|
|
|
4614
4645
|
const u = Math.floor(s / 30);
|
|
4615
4646
|
return `${u} month${u === 1 ? "" : "s"} ago`;
|
|
4616
4647
|
}
|
|
4617
|
-
const
|
|
4648
|
+
const ta = (e, t) => t - e > 864e5, ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4618
4649
|
__proto__: null,
|
|
4619
|
-
CURRENCIES:
|
|
4620
|
-
convert:
|
|
4621
|
-
currencyByCode:
|
|
4622
|
-
currencyDecimals:
|
|
4623
|
-
formatCurrency:
|
|
4624
|
-
inverseRate:
|
|
4625
|
-
isStale:
|
|
4626
|
-
stalenessLabel:
|
|
4627
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
4628
|
-
async function
|
|
4650
|
+
CURRENCIES: at,
|
|
4651
|
+
convert: Xn,
|
|
4652
|
+
currencyByCode: ti,
|
|
4653
|
+
currencyDecimals: ea,
|
|
4654
|
+
formatCurrency: Mt,
|
|
4655
|
+
inverseRate: Qn,
|
|
4656
|
+
isStale: ta,
|
|
4657
|
+
stalenessLabel: Ze
|
|
4658
|
+
}, Symbol.toStringTag, { value: "Module" })), ai = (e) => `https://open.er-api.com/v6/latest/${encodeURIComponent(e)}`;
|
|
4659
|
+
async function ri(e, t, n = {}) {
|
|
4629
4660
|
var m;
|
|
4630
4661
|
if (e === t) return { rate: "1", asOf: "", provider: "identity" };
|
|
4631
4662
|
const a = n.fetchImpl ?? (typeof fetch < "u" ? fetch : void 0);
|
|
4632
4663
|
if (!a) throw new Error("No fetch available in this environment");
|
|
4633
|
-
const r = await a(
|
|
4664
|
+
const r = await a(ai(e), { signal: n.signal });
|
|
4634
4665
|
if (!r.ok) throw new Error(`Rate service returned HTTP ${r.status}`);
|
|
4635
4666
|
const s = await r.json();
|
|
4636
4667
|
if (s != null && s.result && s.result !== "success") throw new Error(s["error-type"] || "Rate service error");
|
|
@@ -4642,35 +4673,35 @@ function ln(e, t) {
|
|
|
4642
4673
|
const n = Date.parse(e);
|
|
4643
4674
|
return Number.isFinite(n) ? n : t;
|
|
4644
4675
|
}
|
|
4645
|
-
const
|
|
4676
|
+
const na = "calcsuite:fxrates", aa = "calcsuite:fxmode", wt = () => {
|
|
4646
4677
|
try {
|
|
4647
|
-
return JSON.parse(localStorage.getItem(
|
|
4678
|
+
return JSON.parse(localStorage.getItem(na) || "{}");
|
|
4648
4679
|
} catch {
|
|
4649
4680
|
return {};
|
|
4650
4681
|
}
|
|
4651
|
-
},
|
|
4682
|
+
}, oi = (e) => {
|
|
4652
4683
|
try {
|
|
4653
|
-
localStorage.setItem(
|
|
4684
|
+
localStorage.setItem(na, JSON.stringify(e));
|
|
4654
4685
|
} catch {
|
|
4655
4686
|
}
|
|
4656
|
-
},
|
|
4687
|
+
}, ii = () => {
|
|
4657
4688
|
try {
|
|
4658
|
-
return localStorage.getItem(
|
|
4689
|
+
return localStorage.getItem(aa) === "offline" ? "offline" : "online";
|
|
4659
4690
|
} catch {
|
|
4660
4691
|
return "online";
|
|
4661
4692
|
}
|
|
4662
4693
|
}, Ke = (e, t) => `${e}_${t}`;
|
|
4663
|
-
function
|
|
4694
|
+
function ra() {
|
|
4664
4695
|
var _t;
|
|
4665
|
-
const [e, t] = M("USD"), [n, a] = M("INR"), [r, s] = M(""), [u, m] = M(""), [d, i] = M("none"), [c, l] = M(""), [p, h] = M("idle"), [f, y] = M(""), [w, k] = M(() =>
|
|
4666
|
-
|
|
4696
|
+
const [e, t] = M("USD"), [n, a] = M("INR"), [r, s] = M(""), [u, m] = M(""), [d, i] = M("none"), [c, l] = M(""), [p, h] = M("idle"), [f, y] = M(""), [w, k] = M(() => ii()), [S, F] = M(() => wt()), [N, P] = M(() => Date.now()), x = de(null);
|
|
4697
|
+
Q(() => {
|
|
4667
4698
|
const O = setInterval(() => P(Date.now()), 3e4);
|
|
4668
4699
|
return () => clearInterval(O);
|
|
4669
4700
|
}, []);
|
|
4670
4701
|
const T = (O, Z) => {
|
|
4671
4702
|
F((ae) => {
|
|
4672
4703
|
const oe = { ...ae, [Ke(e, n)]: { rate: O, at: Z } };
|
|
4673
|
-
return
|
|
4704
|
+
return oi(oe), oe;
|
|
4674
4705
|
});
|
|
4675
4706
|
}, $ = (O, Z) => {
|
|
4676
4707
|
var oe;
|
|
@@ -4680,11 +4711,11 @@ function aa() {
|
|
|
4680
4711
|
m("1"), i("live"), l(""), h("idle");
|
|
4681
4712
|
return;
|
|
4682
4713
|
}
|
|
4683
|
-
h("loading"), y(""),
|
|
4714
|
+
h("loading"), y(""), ri(O, Z, { signal: ae.signal }).then((xe) => {
|
|
4684
4715
|
ae.signal.aborted || (m(xe.rate), i("live"), l(xe.asOf), h("idle"), T(xe.rate, ln(xe.asOf, Date.now())));
|
|
4685
4716
|
}).catch((xe) => {
|
|
4686
4717
|
if (ae.signal.aborted) return;
|
|
4687
|
-
const Ht =
|
|
4718
|
+
const Ht = wt()[Ke(O, Z)];
|
|
4688
4719
|
Ht ? (m(Ht.rate), i("saved"), h("error"), y("Offline — showing your last saved rate. Refresh when back online.")) : (i("none"), h("error"), y(`Couldn’t fetch a live rate (${xe instanceof Error ? xe.message : "offline"}). Enter one manually.`));
|
|
4689
4720
|
});
|
|
4690
4721
|
}, L = (O, Z) => {
|
|
@@ -4693,27 +4724,27 @@ function aa() {
|
|
|
4693
4724
|
m("1"), i("saved");
|
|
4694
4725
|
return;
|
|
4695
4726
|
}
|
|
4696
|
-
const ae =
|
|
4727
|
+
const ae = wt()[Ke(O, Z)];
|
|
4697
4728
|
ae ? (m(ae.rate), i("saved")) : (m(""), i("none"));
|
|
4698
4729
|
};
|
|
4699
|
-
|
|
4730
|
+
Q(() => (w === "online" ? $(e, n) : L(e, n), () => {
|
|
4700
4731
|
var O;
|
|
4701
4732
|
return (O = x.current) == null ? void 0 : O.abort();
|
|
4702
4733
|
}), [e, n, w]);
|
|
4703
4734
|
const B = (O) => {
|
|
4704
4735
|
k(O);
|
|
4705
4736
|
try {
|
|
4706
|
-
localStorage.setItem(
|
|
4737
|
+
localStorage.setItem(aa, O);
|
|
4707
4738
|
} catch {
|
|
4708
4739
|
}
|
|
4709
|
-
}, G = (O) => O.replace(/[, ]/g, "").trim(), q = G(r), A = G(u), I = q !== "" && Number(q) >= 0 && Number.isFinite(Number(q)), R = A !== "" && Number(A) > 0 && Number.isFinite(Number(A)), j =
|
|
4710
|
-
() => I && R ?
|
|
4740
|
+
}, G = (O) => O.replace(/[, ]/g, "").trim(), q = G(r), A = G(u), I = q !== "" && Number(q) >= 0 && Number.isFinite(Number(q)), R = A !== "" && Number(A) > 0 && Number.isFinite(Number(A)), j = X(
|
|
4741
|
+
() => I && R ? Xn(q, A) : null,
|
|
4711
4742
|
[I, R, q, A]
|
|
4712
|
-
), Y = R ?
|
|
4743
|
+
), Y = R ? Qn(A) : null, V = (O) => {
|
|
4713
4744
|
m(O), i("manual"), h("idle"), y(""), (R || O.trim() !== "") && T(G(O), Date.now());
|
|
4714
|
-
},
|
|
4745
|
+
}, ee = () => {
|
|
4715
4746
|
t(n), a(e);
|
|
4716
|
-
}, Ee = c ?
|
|
4747
|
+
}, Ee = c ? Ze(ln(c, N), N) : "just now", K = (_t = S[Ke(e, n)]) == null ? void 0 : _t.at, pe = (O) => /* @__PURE__ */ b("option", { value: O.code, children: [
|
|
4717
4748
|
O.code,
|
|
4718
4749
|
" — ",
|
|
4719
4750
|
O.name
|
|
@@ -4727,7 +4758,7 @@ function aa() {
|
|
|
4727
4758
|
" · open.er-api.com"
|
|
4728
4759
|
] }) : null : d === "saved" && K ? /* @__PURE__ */ b("span", { children: [
|
|
4729
4760
|
"✈ Offline · saved rate ",
|
|
4730
|
-
|
|
4761
|
+
Ze(K, N)
|
|
4731
4762
|
] }) : /* @__PURE__ */ o("span", { children: "✈ Offline · enter a rate manually" });
|
|
4732
4763
|
return /* @__PURE__ */ b("div", { "data-part": "calculator", "data-calculator": "tools.currency", children: [
|
|
4733
4764
|
/* @__PURE__ */ b("section", { className: "card", children: [
|
|
@@ -4752,12 +4783,12 @@ function aa() {
|
|
|
4752
4783
|
] }),
|
|
4753
4784
|
/* @__PURE__ */ b("label", { className: "field cc-cur", children: [
|
|
4754
4785
|
/* @__PURE__ */ o("span", { className: "lbl", children: "From" }),
|
|
4755
|
-
/* @__PURE__ */ o("div", { className: "input-wrap", children: /* @__PURE__ */ o("select", { value: e, onChange: (O) => t(O.target.value), "aria-label": "From currency", children:
|
|
4786
|
+
/* @__PURE__ */ o("div", { className: "input-wrap", children: /* @__PURE__ */ o("select", { value: e, onChange: (O) => t(O.target.value), "aria-label": "From currency", children: at.map(pe) }) })
|
|
4756
4787
|
] }),
|
|
4757
|
-
/* @__PURE__ */ o("button", { type: "button", className: "cc-swap", onClick:
|
|
4788
|
+
/* @__PURE__ */ o("button", { type: "button", className: "cc-swap", onClick: ee, "aria-label": "Swap currencies", title: "Swap", children: "⇄" }),
|
|
4758
4789
|
/* @__PURE__ */ b("label", { className: "field cc-cur", children: [
|
|
4759
4790
|
/* @__PURE__ */ o("span", { className: "lbl", children: "To" }),
|
|
4760
|
-
/* @__PURE__ */ o("div", { className: "input-wrap", children: /* @__PURE__ */ o("select", { value: n, onChange: (O) => a(O.target.value), "aria-label": "To currency", children:
|
|
4791
|
+
/* @__PURE__ */ o("div", { className: "input-wrap", children: /* @__PURE__ */ o("select", { value: n, onChange: (O) => a(O.target.value), "aria-label": "To currency", children: at.map(pe) }) })
|
|
4761
4792
|
] })
|
|
4762
4793
|
] }),
|
|
4763
4794
|
/* @__PURE__ */ b("label", { className: "field", style: { marginTop: 16 }, children: [
|
|
@@ -4798,10 +4829,10 @@ function aa() {
|
|
|
4798
4829
|
/* @__PURE__ */ b("section", { className: "card", children: [
|
|
4799
4830
|
j ? /* @__PURE__ */ b("div", { className: "result", "aria-live": "polite", children: [
|
|
4800
4831
|
/* @__PURE__ */ b("div", { className: "label", children: [
|
|
4801
|
-
|
|
4832
|
+
Mt(q, e),
|
|
4802
4833
|
" ="
|
|
4803
4834
|
] }),
|
|
4804
|
-
/* @__PURE__ */ o("div", { className: "value num accent-txt", children:
|
|
4835
|
+
/* @__PURE__ */ o("div", { className: "value num accent-txt", children: Mt(j, n) }),
|
|
4805
4836
|
/* @__PURE__ */ b("div", { className: "secondary", children: [
|
|
4806
4837
|
/* @__PURE__ */ b("div", { className: "kv", children: [
|
|
4807
4838
|
/* @__PURE__ */ o("div", { className: "k", children: "Rate" }),
|
|
@@ -4828,7 +4859,7 @@ function aa() {
|
|
|
4828
4859
|
/* @__PURE__ */ b("div", { className: "kv", children: [
|
|
4829
4860
|
/* @__PURE__ */ o("div", { className: "k", children: "Precision" }),
|
|
4830
4861
|
/* @__PURE__ */ b("div", { className: "v num", children: [
|
|
4831
|
-
|
|
4862
|
+
ea(n),
|
|
4832
4863
|
" dp · ",
|
|
4833
4864
|
n
|
|
4834
4865
|
] })
|
|
@@ -4861,7 +4892,7 @@ function aa() {
|
|
|
4861
4892
|
oe
|
|
4862
4893
|
] }),
|
|
4863
4894
|
/* @__PURE__ */ o("span", { className: "num", children: Z.rate }),
|
|
4864
|
-
/* @__PURE__ */ o("span", { className: `cc-book-when ${
|
|
4895
|
+
/* @__PURE__ */ o("span", { className: `cc-book-when ${ta(Z.at, N) ? "cc-stale" : ""}`, children: Ze(Z.at, N) })
|
|
4865
4896
|
]
|
|
4866
4897
|
}
|
|
4867
4898
|
) }, O);
|
|
@@ -4869,23 +4900,23 @@ function aa() {
|
|
|
4869
4900
|
] })
|
|
4870
4901
|
] });
|
|
4871
4902
|
}
|
|
4872
|
-
const
|
|
4903
|
+
const si = {
|
|
4873
4904
|
id: "",
|
|
4874
4905
|
group: "tools",
|
|
4875
4906
|
title: "",
|
|
4876
4907
|
inputs: [],
|
|
4877
4908
|
compute: () => ({ primary: { label: "", value: "" } })
|
|
4878
|
-
},
|
|
4879
|
-
"loan.emi":
|
|
4880
|
-
scientific:
|
|
4881
|
-
currency:
|
|
4909
|
+
}, li = {
|
|
4910
|
+
"loan.emi": zn,
|
|
4911
|
+
scientific: Zn,
|
|
4912
|
+
currency: ra
|
|
4882
4913
|
};
|
|
4883
4914
|
function cn(e, t) {
|
|
4884
4915
|
const n = {};
|
|
4885
4916
|
for (const a of e.inputs) a.default !== void 0 && (n[a.key] = a.default);
|
|
4886
4917
|
return t ? { ...n, ...t } : n;
|
|
4887
4918
|
}
|
|
4888
|
-
function
|
|
4919
|
+
function ci({
|
|
4889
4920
|
def: e,
|
|
4890
4921
|
id: t,
|
|
4891
4922
|
seed: n,
|
|
@@ -4894,9 +4925,9 @@ function ii({
|
|
|
4894
4925
|
actions: s
|
|
4895
4926
|
}) {
|
|
4896
4927
|
var L, B, G, q;
|
|
4897
|
-
const u = e ?? (t ?
|
|
4898
|
-
|
|
4899
|
-
const k = i.region, S = (A, I) => p((R) => ({ ...R, [A]: I })), F = m.inputs.filter((A) => A.showIf ? A.showIf(l, k) : !0), N = F.filter((A) => !A.advanced), P = F.filter((A) => A.advanced), { result: x, error: T } =
|
|
4928
|
+
const u = e ?? (t ? Rt(t) : void 0), m = u ?? si, d = { ...li, ...a }, { settings: i, fmt: c } = ue(), [l, p] = M(() => cn(m, n)), [h, f] = M("schedule"), [y, w] = M(!1);
|
|
4929
|
+
Q(() => p(cn(m, n)), [m.id, n]);
|
|
4930
|
+
const k = i.region, S = (A, I) => p((R) => ({ ...R, [A]: I })), F = m.inputs.filter((A) => A.showIf ? A.showIf(l, k) : !0), N = F.filter((A) => !A.advanced), P = F.filter((A) => A.advanced), { result: x, error: T } = X(() => {
|
|
4900
4931
|
const A = { settings: i, region: k, fmt: c, D: g };
|
|
4901
4932
|
try {
|
|
4902
4933
|
return { result: m.compute(l, A), error: null };
|
|
@@ -4904,7 +4935,7 @@ function ii({
|
|
|
4904
4935
|
return { result: null, error: I instanceof Error ? I.message : "Could not calculate." };
|
|
4905
4936
|
}
|
|
4906
4937
|
}, [m, l, i, k, c]);
|
|
4907
|
-
if (
|
|
4938
|
+
if (Q(() => r == null ? void 0 : r(x, l), [x]), !u)
|
|
4908
4939
|
return /* @__PURE__ */ b("div", { className: "error", role: "alert", children: [
|
|
4909
4940
|
"Unknown calculator",
|
|
4910
4941
|
t ? `: ${t}` : "",
|
|
@@ -4932,7 +4963,7 @@ function ii({
|
|
|
4932
4963
|
T && /* @__PURE__ */ o("div", { className: "error", role: "alert", style: { marginTop: 16 }, children: T })
|
|
4933
4964
|
] }),
|
|
4934
4965
|
x && !T && /* @__PURE__ */ b("section", { className: "card", children: [
|
|
4935
|
-
/* @__PURE__ */ o(
|
|
4966
|
+
/* @__PURE__ */ o(no, { view: x }),
|
|
4936
4967
|
(B = x.warnings) == null ? void 0 : B.map((A, I) => /* @__PURE__ */ o("div", { className: "notice", children: A }, I)),
|
|
4937
4968
|
s && /* @__PURE__ */ o("div", { className: "actions-row", children: s(x, l) }),
|
|
4938
4969
|
$ && /* @__PURE__ */ b(re, { children: [
|
|
@@ -4943,8 +4974,8 @@ function ii({
|
|
|
4943
4974
|
(((G = x.notes) == null ? void 0 : G.length) ?? 0) > 0 && i.ui.showAssumptions && /* @__PURE__ */ o("button", { role: "tab", "aria-selected": h === "assumptions", onClick: () => f("assumptions"), children: "Assumptions" })
|
|
4944
4975
|
] }),
|
|
4945
4976
|
/* @__PURE__ */ b("div", { className: "tab-anim", children: [
|
|
4946
|
-
h === "schedule" && x.schedule && /* @__PURE__ */ o(
|
|
4947
|
-
h === "chart" && x.chart && /* @__PURE__ */ o(
|
|
4977
|
+
h === "schedule" && x.schedule && /* @__PURE__ */ o(oo, { schedule: x.schedule }),
|
|
4978
|
+
h === "chart" && x.chart && /* @__PURE__ */ o(io, { chart: x.chart }),
|
|
4948
4979
|
h === "formula" && x.formula && i.ui.showFormulas && /* @__PURE__ */ b("div", { className: "formula", children: [
|
|
4949
4980
|
/* @__PURE__ */ o("code", { children: x.formula }),
|
|
4950
4981
|
x.formulaSubstituted && /* @__PURE__ */ o("code", { style: { marginTop: 8 }, children: x.formulaSubstituted })
|
|
@@ -4967,21 +4998,8 @@ function un({ def: e, region: t }) {
|
|
|
4967
4998
|
}
|
|
4968
4999
|
function dn({ f: e, values: t, set: n }) {
|
|
4969
5000
|
const a = e.kind === "cashflows" || e.kind === "segmented" ? "span2" : "";
|
|
4970
|
-
return /* @__PURE__ */ o("div", { className: a, children: /* @__PURE__ */ o(
|
|
5001
|
+
return /* @__PURE__ */ o("div", { className: a, children: /* @__PURE__ */ o(Qr, { f: e, value: t[e.key], onChange: (r) => n(e.key, r), values: t }) });
|
|
4971
5002
|
}
|
|
4972
|
-
const si = [
|
|
4973
|
-
{ id: "default", label: "Green", main: "#00A76F", light: "#2CCF8E", dark: "#087055", ink: "#06251A" },
|
|
4974
|
-
{ id: "cyan", label: "Cyan", main: "#078DEE", light: "#68CDF9", dark: "#0351AB", ink: "#FFFFFF" },
|
|
4975
|
-
{ id: "purple", label: "Purple", main: "#7635DC", light: "#B985F4", dark: "#431A9E", ink: "#FFFFFF" },
|
|
4976
|
-
{ id: "blue", label: "Blue", main: "#2065D1", light: "#76B0F1", dark: "#103996", ink: "#FFFFFF" },
|
|
4977
|
-
{ id: "orange", label: "Orange", main: "#FDA92D", light: "#FED680", dark: "#B66816", ink: "#212B36" },
|
|
4978
|
-
{ id: "gray", label: "Gray", main: "#A4AAB3", light: "#CED1D7", dark: "#63686C", ink: "#FFFFFF" }
|
|
4979
|
-
], kt = "-apple-system, 'Segoe UI', system-ui, sans-serif", li = [
|
|
4980
|
-
{ id: "Inter Tight", label: "Inter Tight", stack: `'Inter Tight', ${kt}` },
|
|
4981
|
-
{ id: "Public Sans", label: "Public Sans", stack: `'Public Sans', ${kt}` },
|
|
4982
|
-
{ id: "system-ui", label: "System UI", stack: `system-ui, ${kt}` },
|
|
4983
|
-
{ id: "Georgia", label: "Georgia (serif)", stack: "Georgia, 'Times New Roman', serif" }
|
|
4984
|
-
];
|
|
4985
5003
|
class z extends Error {
|
|
4986
5004
|
constructor(n, a = { code: "transport_error" }) {
|
|
4987
5005
|
super(n);
|
|
@@ -4992,17 +5010,17 @@ class z extends Error {
|
|
|
4992
5010
|
this.name = "TransportError", this.code = a.code, this.status = a.status ?? 0, this.request = a.request;
|
|
4993
5011
|
}
|
|
4994
5012
|
}
|
|
4995
|
-
const
|
|
5013
|
+
const ui = ["authorization", "cookie", "x-api-key", "x-auth-token", "api-key"], di = {
|
|
4996
5014
|
attempts: 3,
|
|
4997
5015
|
backoff: "exponential",
|
|
4998
5016
|
baseDelayMs: 300,
|
|
4999
5017
|
retryOn: [408, 429, 500, 502, 503, 504],
|
|
5000
5018
|
respectRetryAfter: !0
|
|
5001
|
-
},
|
|
5019
|
+
}, mi = {
|
|
5002
5020
|
enabled: !0,
|
|
5003
5021
|
headerName: "Idempotency-Key",
|
|
5004
5022
|
keyFrom: "inputsHash"
|
|
5005
|
-
},
|
|
5023
|
+
}, pi = {
|
|
5006
5024
|
enabled: !0,
|
|
5007
5025
|
storage: "memory",
|
|
5008
5026
|
maxItems: 200,
|
|
@@ -5014,7 +5032,7 @@ const ci = ["authorization", "cookie", "x-api-key", "x-auth-token", "api-key"],
|
|
|
5014
5032
|
return !1;
|
|
5015
5033
|
}
|
|
5016
5034
|
};
|
|
5017
|
-
function
|
|
5035
|
+
function oa() {
|
|
5018
5036
|
const e = globalThis.crypto;
|
|
5019
5037
|
return e != null && e.randomUUID ? e.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
|
|
5020
5038
|
const n = Math.random() * 16 | 0;
|
|
@@ -5022,21 +5040,21 @@ function ra() {
|
|
|
5022
5040
|
});
|
|
5023
5041
|
}
|
|
5024
5042
|
const pn = (e) => new Promise((t) => setTimeout(t, Math.max(0, e)));
|
|
5025
|
-
function
|
|
5043
|
+
function hi(e) {
|
|
5026
5044
|
let t = String(e).replace(/[\\/]+/g, "-").replace(/[\x00-\x1f\x7f]+/g, "").replace(/[<>:"|?*]+/g, "").replace(/^\.+/, "");
|
|
5027
5045
|
return t = t.trim(), t || "file";
|
|
5028
5046
|
}
|
|
5029
|
-
function
|
|
5047
|
+
function ia(e, t) {
|
|
5030
5048
|
var m;
|
|
5031
5049
|
const n = /* @__PURE__ */ new Date(), a = (d) => String(d).padStart(2, "0"), r = (((m = t.filename) == null ? void 0 : m.split(".").pop()) || t.kind || "bin").toLowerCase(), s = (t.inputsHash || "").replace(/^sha256:/, "").slice(0, 8) || "00000000", u = e.replace(/\{calculator\}/g, t.calculator || "calc").replace(/\{yyyy\}/g, String(n.getFullYear())).replace(/\{MM\}/g, a(n.getMonth() + 1)).replace(/\{dd\}/g, a(n.getDate())).replace(/\{hash8\}/g, s).replace(/\{ext\}/g, r).replace(/\{kind\}/g, t.kind || "file");
|
|
5032
|
-
return
|
|
5050
|
+
return hi(u);
|
|
5033
5051
|
}
|
|
5034
|
-
function
|
|
5035
|
-
const n = /* @__PURE__ */ new Set([...
|
|
5052
|
+
function $t(e, t = []) {
|
|
5053
|
+
const n = /* @__PURE__ */ new Set([...ui, ...t.map((r) => r.toLowerCase())]), a = {};
|
|
5036
5054
|
for (const [r, s] of Object.entries(e)) a[r] = n.has(r.toLowerCase()) ? "***" : s;
|
|
5037
5055
|
return a;
|
|
5038
5056
|
}
|
|
5039
|
-
class
|
|
5057
|
+
class fi {
|
|
5040
5058
|
constructor(t, n) {
|
|
5041
5059
|
ge(this, "items", []);
|
|
5042
5060
|
ge(this, "key");
|
|
@@ -5064,7 +5082,7 @@ class hi {
|
|
|
5064
5082
|
return this.items.length;
|
|
5065
5083
|
}
|
|
5066
5084
|
enqueue(t) {
|
|
5067
|
-
const n = { ...t, id:
|
|
5085
|
+
const n = { ...t, id: oa(), createdAt: (/* @__PURE__ */ new Date()).toISOString(), retryCount: 0 };
|
|
5068
5086
|
for (this.items.push(n); this.items.length > this.cfg.maxItems; ) this.items.shift();
|
|
5069
5087
|
return this.save(), n;
|
|
5070
5088
|
}
|
|
@@ -5086,12 +5104,12 @@ class hi {
|
|
|
5086
5104
|
}
|
|
5087
5105
|
}
|
|
5088
5106
|
const hn = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
5089
|
-
function
|
|
5090
|
-
const t = e.fetch ?? globalThis.fetch, n = { ...
|
|
5107
|
+
function yi(e) {
|
|
5108
|
+
const t = e.fetch ?? globalThis.fetch, n = { ...di, ...e.retry }, a = { ...mi, ...e.idempotency }, r = { ...pi, ...e.offlineQueue }, s = e.timeoutMs ?? 15e3, u = e.credentials ?? "same-origin", m = new fi(r, "calcsuite");
|
|
5091
5109
|
function d(N, P) {
|
|
5092
5110
|
const x = e.endpoints[N];
|
|
5093
5111
|
if (!x) throw new z(`Endpoint "${N}" is not configured`, { code: "no_endpoint" });
|
|
5094
|
-
let T = /^https?:\/\//i.test(x) ? x :
|
|
5112
|
+
let T = /^https?:\/\//i.test(x) ? x : bi(e.baseUrl, x);
|
|
5095
5113
|
return P != null && (T = T.replace(/:id\b/, encodeURIComponent(P))), T;
|
|
5096
5114
|
}
|
|
5097
5115
|
function i() {
|
|
@@ -5106,10 +5124,10 @@ function fi(e) {
|
|
|
5106
5124
|
if (!a.enabled || x) return x;
|
|
5107
5125
|
if (hn.has(fn(N))) {
|
|
5108
5126
|
if (a.keyFrom === "inputsHash") {
|
|
5109
|
-
const T =
|
|
5127
|
+
const T = vi(P);
|
|
5110
5128
|
if (T) return T;
|
|
5111
5129
|
}
|
|
5112
|
-
return
|
|
5130
|
+
return oa();
|
|
5113
5131
|
}
|
|
5114
5132
|
}
|
|
5115
5133
|
async function p(N, P, x) {
|
|
@@ -5136,7 +5154,7 @@ function fi(e) {
|
|
|
5136
5154
|
}
|
|
5137
5155
|
async function f(N, P = {}) {
|
|
5138
5156
|
var B, G, q, A;
|
|
5139
|
-
const x = fn(N), T =
|
|
5157
|
+
const x = fn(N), T = gi(d(N, P.pathParam), P.query), $ = l(N, P.body, P.idempotencyKey);
|
|
5140
5158
|
let L;
|
|
5141
5159
|
for (let I = 1; I <= Math.max(1, n.attempts); I++) {
|
|
5142
5160
|
const R = await c(), j = {
|
|
@@ -5146,10 +5164,10 @@ function fi(e) {
|
|
|
5146
5164
|
...R.headers
|
|
5147
5165
|
};
|
|
5148
5166
|
$ && (j[a.headerName] = $);
|
|
5149
|
-
const Y =
|
|
5167
|
+
const Y = $t(j, R.keys);
|
|
5150
5168
|
let V = P.body;
|
|
5151
|
-
const
|
|
5152
|
-
e.transformRequest && V !== void 0 && (V = e.transformRequest(V,
|
|
5169
|
+
const ee = { endpoint: String(N), method: x, url: T, headers: Y, body: V, attempt: I };
|
|
5170
|
+
e.transformRequest && V !== void 0 && (V = e.transformRequest(V, ee)), (B = e.onRequest) == null || B.call(e, ee);
|
|
5153
5171
|
const Ee = yn();
|
|
5154
5172
|
try {
|
|
5155
5173
|
const K = await p(
|
|
@@ -5166,8 +5184,8 @@ function fi(e) {
|
|
|
5166
5184
|
await pn(h(I, K));
|
|
5167
5185
|
continue;
|
|
5168
5186
|
}
|
|
5169
|
-
const pe = await
|
|
5170
|
-
...
|
|
5187
|
+
const pe = await sa(K), Me = {
|
|
5188
|
+
...ee,
|
|
5171
5189
|
status: K.status,
|
|
5172
5190
|
ok: K.ok,
|
|
5173
5191
|
durationMs: yn() - Ee,
|
|
@@ -5177,11 +5195,11 @@ function fi(e) {
|
|
|
5177
5195
|
const Ge = new z(`Request failed with ${K.status}`, {
|
|
5178
5196
|
code: "http_error",
|
|
5179
5197
|
status: K.status,
|
|
5180
|
-
request:
|
|
5198
|
+
request: ee
|
|
5181
5199
|
});
|
|
5182
|
-
throw (q = e.onError) == null || q.call(e, Ge,
|
|
5200
|
+
throw (q = e.onError) == null || q.call(e, Ge, ee), Ge;
|
|
5183
5201
|
}
|
|
5184
|
-
return e.transformResponse ? e.transformResponse(pe,
|
|
5202
|
+
return e.transformResponse ? e.transformResponse(pe, ee) : pe;
|
|
5185
5203
|
} catch (K) {
|
|
5186
5204
|
if (L = K, K instanceof z && K.code === "http_error") throw K;
|
|
5187
5205
|
if (I < n.attempts) {
|
|
@@ -5197,16 +5215,16 @@ function fi(e) {
|
|
|
5197
5215
|
headers: { ...P.headers ?? {} }
|
|
5198
5216
|
// never the auth headers
|
|
5199
5217
|
}).id };
|
|
5200
|
-
const pe = K instanceof z ? K : new z("Network request failed", { code: "network_error", request:
|
|
5201
|
-
throw (A = e.onError) == null || A.call(e, pe,
|
|
5218
|
+
const pe = K instanceof z ? K : new z("Network request failed", { code: "network_error", request: ee });
|
|
5219
|
+
throw (A = e.onError) == null || A.call(e, pe, ee), pe;
|
|
5202
5220
|
}
|
|
5203
5221
|
}
|
|
5204
5222
|
throw L instanceof Error ? L : new z("Request failed", { code: "transport_error" });
|
|
5205
5223
|
}
|
|
5206
5224
|
async function y(N, P, x = {}) {
|
|
5207
5225
|
const T = e.upload;
|
|
5208
|
-
|
|
5209
|
-
const $ = P.filename ??
|
|
5226
|
+
wi(N, P, T.accept, T.maxBytes);
|
|
5227
|
+
const $ = P.filename ?? ia(T.filenameTemplate, P), L = { ...P, filename: $, bytes: N.size, contentType: P.contentType ?? la(N) };
|
|
5210
5228
|
if (T.beforeUpload && !await T.beforeUpload(N, L))
|
|
5211
5229
|
throw new z("Upload cancelled by host", { code: "upload_cancelled" });
|
|
5212
5230
|
return T.strategy === "presigned" ? F(N, L, x) : T.strategy === "base64Json" ? S(N, L, x) : k(N, L, x);
|
|
@@ -5237,10 +5255,10 @@ function fi(e) {
|
|
|
5237
5255
|
{ method: "POST", credentials: u, headers: B, body: $ },
|
|
5238
5256
|
x.signal
|
|
5239
5257
|
);
|
|
5240
|
-
return
|
|
5258
|
+
return ki(G);
|
|
5241
5259
|
}
|
|
5242
5260
|
async function S(N, P, x) {
|
|
5243
|
-
const T = await
|
|
5261
|
+
const T = await Ni(N);
|
|
5244
5262
|
return f("upload", {
|
|
5245
5263
|
...x,
|
|
5246
5264
|
body: {
|
|
@@ -5327,23 +5345,23 @@ function fn(e) {
|
|
|
5327
5345
|
function yn() {
|
|
5328
5346
|
return typeof performance < "u" && performance.now ? performance.now() : Date.now();
|
|
5329
5347
|
}
|
|
5330
|
-
function
|
|
5348
|
+
function bi(e, t) {
|
|
5331
5349
|
return e ? `${e.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}` : t;
|
|
5332
5350
|
}
|
|
5333
|
-
function
|
|
5351
|
+
function gi(e, t) {
|
|
5334
5352
|
if (!t) return e;
|
|
5335
5353
|
const n = [];
|
|
5336
5354
|
for (const [a, r] of Object.entries(t))
|
|
5337
5355
|
r == null || r === "" || n.push(`${encodeURIComponent(a)}=${encodeURIComponent(String(r))}`);
|
|
5338
5356
|
return n.length ? e + (e.includes("?") ? "&" : "?") + n.join("&") : e;
|
|
5339
5357
|
}
|
|
5340
|
-
function
|
|
5358
|
+
function vi(e) {
|
|
5341
5359
|
var a;
|
|
5342
5360
|
if (!e || typeof e != "object") return;
|
|
5343
5361
|
const t = e, n = ((a = t == null ? void 0 : t.meta) == null ? void 0 : a.inputsHash) ?? (t == null ? void 0 : t.inputsHash);
|
|
5344
5362
|
return typeof n == "string" && n ? n : void 0;
|
|
5345
5363
|
}
|
|
5346
|
-
async function
|
|
5364
|
+
async function sa(e) {
|
|
5347
5365
|
const t = e.headers.get("content-type") || "";
|
|
5348
5366
|
try {
|
|
5349
5367
|
return t.includes("application/json") ? await e.json() : await e.text() || null;
|
|
@@ -5351,21 +5369,21 @@ async function ia(e) {
|
|
|
5351
5369
|
return null;
|
|
5352
5370
|
}
|
|
5353
5371
|
}
|
|
5354
|
-
async function
|
|
5372
|
+
async function ki(e) {
|
|
5355
5373
|
if (!e.ok) throw new z(`Upload failed (${e.status})`, { code: "upload_failed", status: e.status });
|
|
5356
|
-
return
|
|
5374
|
+
return sa(e);
|
|
5357
5375
|
}
|
|
5358
|
-
function
|
|
5376
|
+
function la(e) {
|
|
5359
5377
|
return e.type || "application/octet-stream";
|
|
5360
5378
|
}
|
|
5361
|
-
function
|
|
5379
|
+
function wi(e, t, n, a) {
|
|
5362
5380
|
if (e.size > a)
|
|
5363
5381
|
throw new z(`File exceeds ${a} bytes`, { code: "too_large" });
|
|
5364
|
-
const r = t.contentType ??
|
|
5382
|
+
const r = t.contentType ?? la(e);
|
|
5365
5383
|
if (n.length && r && !n.includes(r))
|
|
5366
5384
|
throw new z(`Content type ${r} not accepted`, { code: "bad_type" });
|
|
5367
5385
|
}
|
|
5368
|
-
async function
|
|
5386
|
+
async function Ni(e) {
|
|
5369
5387
|
const t = await e.arrayBuffer(), n = new Uint8Array(t);
|
|
5370
5388
|
if (typeof btoa == "function") {
|
|
5371
5389
|
let r = "";
|
|
@@ -5394,15 +5412,15 @@ function bn(e, t, n) {
|
|
|
5394
5412
|
}
|
|
5395
5413
|
r[a[a.length - 1]] = n;
|
|
5396
5414
|
}
|
|
5397
|
-
function
|
|
5415
|
+
function xi(e, t) {
|
|
5398
5416
|
if (t === "asIs") return e;
|
|
5399
5417
|
const n = e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-\s]+/g, " ").trim().split(" ").filter(Boolean);
|
|
5400
5418
|
return n.length === 0 ? e : t === "snake" ? n.map((a) => a.toLowerCase()).join("_") : t === "kebab" ? n.map((a) => a.toLowerCase()).join("-") : n.map((a, r) => r === 0 ? a.toLowerCase() : a[0].toUpperCase() + a.slice(1).toLowerCase()).join("");
|
|
5401
5419
|
}
|
|
5402
5420
|
function gn(e, t) {
|
|
5403
|
-
return e.split(".").map((n) =>
|
|
5421
|
+
return e.split(".").map((n) => xi(n, t)).join(".");
|
|
5404
5422
|
}
|
|
5405
|
-
function
|
|
5423
|
+
function Si(e, t) {
|
|
5406
5424
|
switch (t) {
|
|
5407
5425
|
case "toFixed2":
|
|
5408
5426
|
return Number(e).toFixed(2);
|
|
@@ -5419,11 +5437,11 @@ function xi(e, t) {
|
|
|
5419
5437
|
return e;
|
|
5420
5438
|
}
|
|
5421
5439
|
}
|
|
5422
|
-
function
|
|
5440
|
+
function Ci(e, t) {
|
|
5423
5441
|
const n = e instanceof Date ? e : new Date(e);
|
|
5424
5442
|
return Number.isNaN(n.getTime()) ? String(e) : n.toISOString();
|
|
5425
5443
|
}
|
|
5426
|
-
function
|
|
5444
|
+
function Pi(e, t, n) {
|
|
5427
5445
|
switch (t) {
|
|
5428
5446
|
case "number": {
|
|
5429
5447
|
if (n.numberEncoding === "number") {
|
|
@@ -5435,7 +5453,7 @@ function Ci(e, t, n) {
|
|
|
5435
5453
|
case "boolean":
|
|
5436
5454
|
return typeof e == "string" ? e.toLowerCase() === "true" : !!e;
|
|
5437
5455
|
case "date":
|
|
5438
|
-
return
|
|
5456
|
+
return Ci(e, n.dateFormat);
|
|
5439
5457
|
case "json":
|
|
5440
5458
|
return e;
|
|
5441
5459
|
case "string":
|
|
@@ -5443,18 +5461,18 @@ function Ci(e, t, n) {
|
|
|
5443
5461
|
return String(e);
|
|
5444
5462
|
}
|
|
5445
5463
|
}
|
|
5446
|
-
function
|
|
5464
|
+
function rt(e, t) {
|
|
5447
5465
|
if (t === "number") return e;
|
|
5448
5466
|
if (typeof e == "number") return String(e);
|
|
5449
|
-
if (Array.isArray(e)) return e.map((n) =>
|
|
5467
|
+
if (Array.isArray(e)) return e.map((n) => rt(n, t));
|
|
5450
5468
|
if (e && typeof e == "object") {
|
|
5451
5469
|
const n = {};
|
|
5452
|
-
for (const [a, r] of Object.entries(e)) n[a] =
|
|
5470
|
+
for (const [a, r] of Object.entries(e)) n[a] = rt(r, t);
|
|
5453
5471
|
return n;
|
|
5454
5472
|
}
|
|
5455
5473
|
return e;
|
|
5456
5474
|
}
|
|
5457
|
-
function
|
|
5475
|
+
function Ti(e, t) {
|
|
5458
5476
|
var n;
|
|
5459
5477
|
switch (e.kind) {
|
|
5460
5478
|
case "static":
|
|
@@ -5475,10 +5493,10 @@ function Pi(e, t) {
|
|
|
5475
5493
|
return;
|
|
5476
5494
|
}
|
|
5477
5495
|
}
|
|
5478
|
-
function
|
|
5496
|
+
function Fi(e, t, n) {
|
|
5479
5497
|
const a = {};
|
|
5480
5498
|
for (const u of e) {
|
|
5481
|
-
let m =
|
|
5499
|
+
let m = Ti(u.source, n);
|
|
5482
5500
|
const d = m === "" || m == null;
|
|
5483
5501
|
if (u.omitWhenEmpty && d) continue;
|
|
5484
5502
|
const i = gn(u.key, t.keyCase);
|
|
@@ -5487,14 +5505,14 @@ function Ti(e, t, n) {
|
|
|
5487
5505
|
bn(a, i, null);
|
|
5488
5506
|
continue;
|
|
5489
5507
|
}
|
|
5490
|
-
u.transform && u.transform !== "none" && (m =
|
|
5508
|
+
u.transform && u.transform !== "none" && (m = Si(m, u.transform)), bn(a, i, Pi(m, u.type, t));
|
|
5491
5509
|
}
|
|
5492
5510
|
const r = t.include, s = (u, m) => {
|
|
5493
|
-
m !== void 0 && (a[gn(u, t.keyCase)] =
|
|
5511
|
+
m !== void 0 && (a[gn(u, t.keyCase)] = rt(m, t.numberEncoding));
|
|
5494
5512
|
};
|
|
5495
5513
|
return r != null && r.inputs && s("inputs", n.inputs), r != null && r.outputs && s("outputs", n.outputs), r != null && r.schedule && s("schedule", n.schedule), r != null && r.settingsSnapshot && s("settingsSnapshot", n.settings), r != null && r.meta && s("meta", n.context), t.numberEncoding === "number" && console.warn('[fincalc] numberEncoding="number" reintroduces float error; prefer "string".'), t.mode === "wrapped" && t.wrapperKey ? { [t.wrapperKey]: a } : a;
|
|
5496
5514
|
}
|
|
5497
|
-
const
|
|
5515
|
+
const bs = {
|
|
5498
5516
|
mode: "flat",
|
|
5499
5517
|
keyCase: "asIs",
|
|
5500
5518
|
dateFormat: "iso",
|
|
@@ -5503,9 +5521,9 @@ const ys = {
|
|
|
5503
5521
|
include: { inputs: !0, outputs: !0, schedule: !1, settingsSnapshot: !0, meta: !0 }
|
|
5504
5522
|
};
|
|
5505
5523
|
function vn(e) {
|
|
5506
|
-
return
|
|
5524
|
+
return rt(e, "string");
|
|
5507
5525
|
}
|
|
5508
|
-
function
|
|
5526
|
+
function gs(e) {
|
|
5509
5527
|
const t = e.settings;
|
|
5510
5528
|
return {
|
|
5511
5529
|
schemaVersion: 1,
|
|
@@ -5539,17 +5557,17 @@ function bs(e) {
|
|
|
5539
5557
|
warnings: e.warnings ?? []
|
|
5540
5558
|
},
|
|
5541
5559
|
...e.attachments && e.attachments.length ? { attachments: e.attachments } : {},
|
|
5542
|
-
client: { tz: e.clientTz ??
|
|
5560
|
+
client: { tz: e.clientTz ?? Ii(), platform: "web" }
|
|
5543
5561
|
};
|
|
5544
5562
|
}
|
|
5545
|
-
function
|
|
5563
|
+
function Ii() {
|
|
5546
5564
|
try {
|
|
5547
5565
|
return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
5548
5566
|
} catch {
|
|
5549
5567
|
return "UTC";
|
|
5550
5568
|
}
|
|
5551
5569
|
}
|
|
5552
|
-
const He = ["save", "update", "get", "list", "delete", "upload", "uploadUrl", "rates", "settings"],
|
|
5570
|
+
const He = ["save", "update", "get", "list", "delete", "upload", "uploadUrl", "rates", "settings"], Ri = {
|
|
5553
5571
|
save: "POST",
|
|
5554
5572
|
update: "PUT",
|
|
5555
5573
|
get: "GET",
|
|
@@ -5559,7 +5577,7 @@ const He = ["save", "update", "get", "list", "delete", "upload", "uploadUrl", "r
|
|
|
5559
5577
|
uploadUrl: "GET",
|
|
5560
5578
|
rates: "GET",
|
|
5561
5579
|
settings: "GET"
|
|
5562
|
-
},
|
|
5580
|
+
}, ca = ["bearer", "apiKeyHeader", "basic", "custom"], Ei = {
|
|
5563
5581
|
strategy: "multipart",
|
|
5564
5582
|
fieldName: "file",
|
|
5565
5583
|
maxBytes: 10 * 1024 * 1024,
|
|
@@ -5568,10 +5586,10 @@ const He = ["save", "update", "get", "list", "delete", "upload", "uploadUrl", "r
|
|
|
5568
5586
|
checksum: "none",
|
|
5569
5587
|
chunked: { enabled: !1, chunkBytes: 1024 * 1024 }
|
|
5570
5588
|
};
|
|
5571
|
-
function
|
|
5589
|
+
function ua() {
|
|
5572
5590
|
const e = {};
|
|
5573
5591
|
for (const t of He)
|
|
5574
|
-
e[t] = { path: `/calculations${t === "save" || t === "list" ? "" : t === "get" || t === "update" || t === "delete" ? "/:id" : "/" + t}`, method:
|
|
5592
|
+
e[t] = { path: `/calculations${t === "save" || t === "list" ? "" : t === "get" || t === "update" || t === "delete" ? "/:id" : "/" + t}`, method: Ri[t], enabled: t === "save" || t === "list" };
|
|
5575
5593
|
return {
|
|
5576
5594
|
baseUrl: "https://api.example.com/v1",
|
|
5577
5595
|
auth: { strategy: "bearer", headerName: "Authorization" },
|
|
@@ -5579,17 +5597,17 @@ function ca() {
|
|
|
5579
5597
|
credentials: "same-origin",
|
|
5580
5598
|
retry: { attempts: 3, backoff: "exponential", baseDelayMs: 300, retryOn: [408, 429, 500, 502, 503, 504], respectRetryAfter: !0 },
|
|
5581
5599
|
endpoints: e,
|
|
5582
|
-
upload:
|
|
5600
|
+
upload: Ei
|
|
5583
5601
|
};
|
|
5584
5602
|
}
|
|
5585
|
-
const
|
|
5603
|
+
const Mi = {
|
|
5586
5604
|
mode: "flat",
|
|
5587
5605
|
keyCase: "asIs",
|
|
5588
5606
|
dateFormat: "iso",
|
|
5589
5607
|
nullHandling: "omit",
|
|
5590
5608
|
numberEncoding: "string",
|
|
5591
5609
|
include: { inputs: !0, outputs: !0, schedule: !1, settingsSnapshot: !0, meta: !0 }
|
|
5592
|
-
},
|
|
5610
|
+
}, $i = [
|
|
5593
5611
|
{ key: "calculator", source: { kind: "context", path: "calculator" }, type: "string", required: !0, omitWhenEmpty: !1 },
|
|
5594
5612
|
{ key: "principal", source: { kind: "input", path: "principal" }, type: "number", required: !0, omitWhenEmpty: !1 },
|
|
5595
5613
|
{ key: "payment", source: { kind: "output", path: "payment" }, type: "number", required: !1, omitWhenEmpty: !1 },
|
|
@@ -5608,7 +5626,7 @@ function kn(e) {
|
|
|
5608
5626
|
n /= 1024, a++;
|
|
5609
5627
|
return `${n.toFixed(n < 10 ? 1 : 0)} ${t[a]}`;
|
|
5610
5628
|
}
|
|
5611
|
-
function
|
|
5629
|
+
function da(e, t, n) {
|
|
5612
5630
|
switch (e) {
|
|
5613
5631
|
case "bearer":
|
|
5614
5632
|
return { Authorization: `Bearer ${n}` };
|
|
@@ -5626,9 +5644,9 @@ function ua(e, t, n) {
|
|
|
5626
5644
|
function qe(e, t) {
|
|
5627
5645
|
return t ? /^https?:\/\//i.test(t) ? t : `${e.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}` : e;
|
|
5628
5646
|
}
|
|
5629
|
-
const
|
|
5630
|
-
function
|
|
5631
|
-
const { settings: n } = ue(), [a, r] = M("Connection"), [s, u] = M(
|
|
5647
|
+
const Ai = ["Connection", "Endpoints", "Upload", "Payload", "Test", "cURL", "Queue"];
|
|
5648
|
+
function ma({ hostConfig: e, getToken: t } = {}) {
|
|
5649
|
+
const { settings: n } = ue(), [a, r] = M("Connection"), [s, u] = M(ua), [m, d] = M(Mi), [i, c] = M($i);
|
|
5632
5650
|
if (!n.features.integrationPanel)
|
|
5633
5651
|
return /* @__PURE__ */ o("section", { className: "card", "data-part": "integration-panel", children: /* @__PURE__ */ b("div", { className: "panel-head", children: [
|
|
5634
5652
|
/* @__PURE__ */ o("h2", { children: "Integration" }),
|
|
@@ -5650,12 +5668,12 @@ function da({ hostConfig: e, getToken: t } = {}) {
|
|
|
5650
5668
|
/* @__PURE__ */ o("h2", { children: "Integration" }),
|
|
5651
5669
|
/* @__PURE__ */ o("p", { children: "Point the library at your backend without a code change. Nothing here stores a secret." })
|
|
5652
5670
|
] }),
|
|
5653
|
-
/* @__PURE__ */ o("div", { className: "tabs", role: "tablist", "aria-label": "Integration settings", children:
|
|
5671
|
+
/* @__PURE__ */ o("div", { className: "tabs", role: "tablist", "aria-label": "Integration settings", children: Ai.map((f) => /* @__PURE__ */ o("button", { role: "tab", "aria-selected": a === f, onClick: () => r(f), children: f }, f)) }),
|
|
5654
5672
|
/* @__PURE__ */ b("div", { role: "tabpanel", "aria-label": a, children: [
|
|
5655
|
-
a === "Connection" && /* @__PURE__ */ o(
|
|
5656
|
-
a === "Endpoints" && /* @__PURE__ */ o(
|
|
5673
|
+
a === "Connection" && /* @__PURE__ */ o(Di, { cfg: s, patch: p, hostLocked: l, getToken: t }),
|
|
5674
|
+
a === "Endpoints" && /* @__PURE__ */ o(Li, { cfg: s, setCfg: u, locked: l("endpoints") }),
|
|
5657
5675
|
a === "Upload" && /* @__PURE__ */ o(
|
|
5658
|
-
|
|
5676
|
+
Ui,
|
|
5659
5677
|
{
|
|
5660
5678
|
upload: s.upload,
|
|
5661
5679
|
baseUrl: s.baseUrl,
|
|
@@ -5665,7 +5683,7 @@ function da({ hostConfig: e, getToken: t } = {}) {
|
|
|
5665
5683
|
}
|
|
5666
5684
|
),
|
|
5667
5685
|
a === "Payload" && /* @__PURE__ */ o(
|
|
5668
|
-
|
|
5686
|
+
qi,
|
|
5669
5687
|
{
|
|
5670
5688
|
fields: i,
|
|
5671
5689
|
setFields: c,
|
|
@@ -5674,11 +5692,11 @@ function da({ hostConfig: e, getToken: t } = {}) {
|
|
|
5674
5692
|
ctx: h
|
|
5675
5693
|
}
|
|
5676
5694
|
),
|
|
5677
|
-
a === "Test" && /* @__PURE__ */ o(
|
|
5678
|
-
a === "cURL" && /* @__PURE__ */ o(
|
|
5679
|
-
a === "Queue" && /* @__PURE__ */ o(
|
|
5695
|
+
a === "Test" && /* @__PURE__ */ o(ji, { cfg: s, getToken: t }),
|
|
5696
|
+
a === "cURL" && /* @__PURE__ */ o(Vi, { cfg: s }),
|
|
5697
|
+
a === "Queue" && /* @__PURE__ */ o(Yi, { cfg: s, getToken: t })
|
|
5680
5698
|
] }),
|
|
5681
|
-
/* @__PURE__ */ o(
|
|
5699
|
+
/* @__PURE__ */ o(Ki, { cfg: s, setCfg: u })
|
|
5682
5700
|
] });
|
|
5683
5701
|
}
|
|
5684
5702
|
function Fe({ on: e, children: t }) {
|
|
@@ -5687,7 +5705,7 @@ function Fe({ on: e, children: t }) {
|
|
|
5687
5705
|
e && /* @__PURE__ */ o("div", { className: "int-note", children: "Set by your organisation — read-only." })
|
|
5688
5706
|
] });
|
|
5689
5707
|
}
|
|
5690
|
-
function
|
|
5708
|
+
function ne({
|
|
5691
5709
|
label: e,
|
|
5692
5710
|
value: t,
|
|
5693
5711
|
onChange: n,
|
|
@@ -5729,15 +5747,15 @@ function le({
|
|
|
5729
5747
|
/* @__PURE__ */ o("div", { className: "input-wrap", children: /* @__PURE__ */ o("select", { value: t, onChange: (s) => a(s.target.value), "aria-label": e, children: r.map((s) => /* @__PURE__ */ o("option", { value: s.value, children: s.label }, s.value)) }) })
|
|
5730
5748
|
] });
|
|
5731
5749
|
}
|
|
5732
|
-
function
|
|
5750
|
+
function Di({
|
|
5733
5751
|
cfg: e,
|
|
5734
5752
|
patch: t,
|
|
5735
5753
|
hostLocked: n,
|
|
5736
5754
|
getToken: a
|
|
5737
5755
|
}) {
|
|
5738
|
-
const r =
|
|
5756
|
+
const r = ca.includes(e.auth.strategy);
|
|
5739
5757
|
return /* @__PURE__ */ b("div", { className: "grid two", children: [
|
|
5740
|
-
/* @__PURE__ */ o(Fe, { on: n("baseUrl"), children: /* @__PURE__ */ o(
|
|
5758
|
+
/* @__PURE__ */ o(Fe, { on: n("baseUrl"), children: /* @__PURE__ */ o(ne, { label: "Base URL", value: e.baseUrl, onChange: (s) => t({ baseUrl: s }), help: "Absolute origin + base path" }) }),
|
|
5741
5759
|
/* @__PURE__ */ o(
|
|
5742
5760
|
le,
|
|
5743
5761
|
{
|
|
@@ -5747,7 +5765,7 @@ function Ai({
|
|
|
5747
5765
|
onChange: (s) => t({ auth: { ...e.auth, strategy: s } })
|
|
5748
5766
|
}
|
|
5749
5767
|
),
|
|
5750
|
-
(e.auth.strategy === "apiKeyHeader" || e.auth.strategy === "custom") && /* @__PURE__ */ o(
|
|
5768
|
+
(e.auth.strategy === "apiKeyHeader" || e.auth.strategy === "custom") && /* @__PURE__ */ o(ne, { label: "Header name", value: e.auth.headerName, onChange: (s) => t({ auth: { ...e.auth, headerName: s } }) }),
|
|
5751
5769
|
r && /* @__PURE__ */ b("div", { className: "field span2", children: [
|
|
5752
5770
|
/* @__PURE__ */ o("span", { className: "lbl", children: "Token" }),
|
|
5753
5771
|
a ? /* @__PURE__ */ o("div", { className: "input-wrap", style: { background: "var(--fc-accent-weak)" }, children: /* @__PURE__ */ o("input", { value: "•••••••••• supplied by host application", readOnly: !0, "aria-label": "token supplied by host", style: { textAlign: "left" } }) }) : /* @__PURE__ */ b("div", { className: "notice", children: [
|
|
@@ -5756,7 +5774,7 @@ function Ai({
|
|
|
5756
5774
|
" supplied by the host — endpoints that require auth are disabled. The panel never accepts a token as input."
|
|
5757
5775
|
] })
|
|
5758
5776
|
] }),
|
|
5759
|
-
/* @__PURE__ */ o(Fe, { on: n("timeoutMs"), children: /* @__PURE__ */ o(
|
|
5777
|
+
/* @__PURE__ */ o(Fe, { on: n("timeoutMs"), children: /* @__PURE__ */ o(ne, { label: "Timeout", type: "number", value: String(e.timeoutMs), onChange: (s) => t({ timeoutMs: Number(s) || 0 }), affix: "ms" }) }),
|
|
5760
5778
|
/* @__PURE__ */ o(Fe, { on: n("credentials"), children: /* @__PURE__ */ o(
|
|
5761
5779
|
le,
|
|
5762
5780
|
{
|
|
@@ -5766,7 +5784,7 @@ function Ai({
|
|
|
5766
5784
|
onChange: (s) => t({ credentials: s })
|
|
5767
5785
|
}
|
|
5768
5786
|
) }),
|
|
5769
|
-
/* @__PURE__ */ o(Fe, { on: n("retry"), children: /* @__PURE__ */ o(
|
|
5787
|
+
/* @__PURE__ */ o(Fe, { on: n("retry"), children: /* @__PURE__ */ o(ne, { label: "Retry attempts", type: "number", value: String(e.retry.attempts), onChange: (s) => t({ retry: { ...e.retry, attempts: Number(s) || 1 } }) }) }),
|
|
5770
5788
|
/* @__PURE__ */ o(
|
|
5771
5789
|
le,
|
|
5772
5790
|
{
|
|
@@ -5776,9 +5794,9 @@ function Ai({
|
|
|
5776
5794
|
onChange: (s) => t({ retry: { ...e.retry, backoff: s } })
|
|
5777
5795
|
}
|
|
5778
5796
|
),
|
|
5779
|
-
/* @__PURE__ */ o(
|
|
5797
|
+
/* @__PURE__ */ o(ne, { label: "Base delay", type: "number", value: String(e.retry.baseDelayMs), onChange: (s) => t({ retry: { ...e.retry, baseDelayMs: Number(s) || 0 } }), affix: "ms" }),
|
|
5780
5798
|
/* @__PURE__ */ o(
|
|
5781
|
-
|
|
5799
|
+
ne,
|
|
5782
5800
|
{
|
|
5783
5801
|
label: "Retry on (status codes)",
|
|
5784
5802
|
value: e.retry.retryOn.join(", "),
|
|
@@ -5788,7 +5806,7 @@ function Ai({
|
|
|
5788
5806
|
)
|
|
5789
5807
|
] });
|
|
5790
5808
|
}
|
|
5791
|
-
function
|
|
5809
|
+
function Li({ cfg: e, setCfg: t, locked: n }) {
|
|
5792
5810
|
const a = (r, s) => t((u) => ({ ...u, endpoints: { ...u.endpoints, [r]: { ...u.endpoints[r], ...s } } }));
|
|
5793
5811
|
return /* @__PURE__ */ o(Fe, { on: n, children: /* @__PURE__ */ o("div", { className: "int-table-wrap", children: /* @__PURE__ */ b("table", { className: "int-table", children: [
|
|
5794
5812
|
/* @__PURE__ */ o("thead", { children: /* @__PURE__ */ b("tr", { children: [
|
|
@@ -5811,25 +5829,25 @@ function Di({ cfg: e, setCfg: t, locked: n }) {
|
|
|
5811
5829
|
}) })
|
|
5812
5830
|
] }) }) });
|
|
5813
5831
|
}
|
|
5814
|
-
function
|
|
5832
|
+
function Ui({ upload: e, baseUrl: t, uploadUri: n, onChange: a, locked: r }) {
|
|
5815
5833
|
var m, d, i;
|
|
5816
|
-
const s = (c) => a({ ...e, ...c }), u =
|
|
5817
|
-
() =>
|
|
5834
|
+
const s = (c) => a({ ...e, ...c }), u = X(
|
|
5835
|
+
() => ia(e.filenameTemplate, { calculator: "loan.emi", kind: "pdf", inputsHash: Ue.inputsHash, filename: "x.pdf" }),
|
|
5818
5836
|
[e.filenameTemplate]
|
|
5819
5837
|
);
|
|
5820
5838
|
return /* @__PURE__ */ o(Fe, { on: r, children: /* @__PURE__ */ b("div", { className: "grid two", children: [
|
|
5821
|
-
/* @__PURE__ */ o(
|
|
5839
|
+
/* @__PURE__ */ o(ne, { label: "Upload URI", value: n, readOnly: !0, help: "Resolved from baseUrl + the 'upload' endpoint path (edit it under Endpoints)" }),
|
|
5822
5840
|
/* @__PURE__ */ o(le, { label: "Strategy", value: e.strategy, options: ["multipart", "presigned", "base64Json"], onChange: (c) => s({ strategy: c }) }),
|
|
5823
|
-
/* @__PURE__ */ o(
|
|
5824
|
-
/* @__PURE__ */ o(
|
|
5841
|
+
/* @__PURE__ */ o(ne, { label: "Field name", value: e.fieldName, onChange: (c) => s({ fieldName: c }) }),
|
|
5842
|
+
/* @__PURE__ */ o(ne, { label: "Max bytes", type: "number", value: String(e.maxBytes), onChange: (c) => s({ maxBytes: Number(c) || 0 }), affix: kn(e.maxBytes) }),
|
|
5825
5843
|
/* @__PURE__ */ b("div", { className: "field span2", children: [
|
|
5826
|
-
/* @__PURE__ */ o(
|
|
5844
|
+
/* @__PURE__ */ o(ne, { label: "Filename template", value: e.filenameTemplate, onChange: (c) => s({ filenameTemplate: c }), help: "{calculator} {yyyy} {MM} {dd} {hash8} {ext}" }),
|
|
5827
5845
|
/* @__PURE__ */ b("div", { className: "int-note mono", children: [
|
|
5828
5846
|
"→ ",
|
|
5829
5847
|
u
|
|
5830
5848
|
] })
|
|
5831
5849
|
] }),
|
|
5832
|
-
/* @__PURE__ */ o(
|
|
5850
|
+
/* @__PURE__ */ o(ne, { label: "Accepted MIME types", value: e.accept.join(", "), onChange: (c) => s({ accept: c.split(",").map((l) => l.trim()).filter(Boolean) }) }),
|
|
5833
5851
|
/* @__PURE__ */ o(le, { label: "Checksum", value: e.checksum ?? "none", options: ["none", "sha256"], onChange: (c) => s({ checksum: c }) }),
|
|
5834
5852
|
/* @__PURE__ */ b("label", { className: "field toggle-field span2", children: [
|
|
5835
5853
|
/* @__PURE__ */ o("span", { className: "lbl", children: "Chunked upload (large PDFs)" }),
|
|
@@ -5849,7 +5867,7 @@ function Li({ upload: e, baseUrl: t, uploadUri: n, onChange: a, locked: r }) {
|
|
|
5849
5867
|
}
|
|
5850
5868
|
)
|
|
5851
5869
|
] }),
|
|
5852
|
-
((i = e.chunked) == null ? void 0 : i.enabled) && /* @__PURE__ */ o(
|
|
5870
|
+
((i = e.chunked) == null ? void 0 : i.enabled) && /* @__PURE__ */ o(ne, { label: "Chunk size", type: "number", value: String(e.chunked.chunkBytes), onChange: (c) => s({ chunked: { enabled: !0, chunkBytes: Number(c) || 1 } }), affix: kn(e.chunked.chunkBytes) }),
|
|
5853
5871
|
e.strategy === "presigned" && /* @__PURE__ */ b("div", { className: "span2 int-subform", children: [
|
|
5854
5872
|
/* @__PURE__ */ b("div", { className: "int-note", children: [
|
|
5855
5873
|
/* @__PURE__ */ o("strong", { children: "Presigned sub-form" }),
|
|
@@ -5866,14 +5884,14 @@ function Li({ upload: e, baseUrl: t, uploadUri: n, onChange: a, locked: r }) {
|
|
|
5866
5884
|
] })
|
|
5867
5885
|
] }) });
|
|
5868
5886
|
}
|
|
5869
|
-
const
|
|
5870
|
-
function
|
|
5887
|
+
const Oi = ["static", "input", "output", "setting", "context", "token", "callback"];
|
|
5888
|
+
function Bi(e) {
|
|
5871
5889
|
return e.kind === "static" ? String(e.value) : e.kind === "token" ? e.name : e.kind === "callback" ? "fn()" : e.path;
|
|
5872
5890
|
}
|
|
5873
|
-
function
|
|
5891
|
+
function _i(e, t) {
|
|
5874
5892
|
return e.kind === "static" ? { kind: "static", value: t } : e.kind === "token" ? { kind: "token", name: t } : e.kind === "callback" ? e : { kind: e.kind, path: t };
|
|
5875
5893
|
}
|
|
5876
|
-
function
|
|
5894
|
+
function Hi(e) {
|
|
5877
5895
|
switch (e) {
|
|
5878
5896
|
case "static":
|
|
5879
5897
|
return { kind: "static", value: "" };
|
|
@@ -5885,16 +5903,16 @@ function _i(e) {
|
|
|
5885
5903
|
return { kind: e, path: "" };
|
|
5886
5904
|
}
|
|
5887
5905
|
}
|
|
5888
|
-
function
|
|
5906
|
+
function qi({
|
|
5889
5907
|
fields: e,
|
|
5890
5908
|
setFields: t,
|
|
5891
5909
|
envelope: n,
|
|
5892
5910
|
setEnvelope: a,
|
|
5893
5911
|
ctx: r
|
|
5894
5912
|
}) {
|
|
5895
|
-
const s =
|
|
5913
|
+
const s = X(() => {
|
|
5896
5914
|
try {
|
|
5897
|
-
return JSON.stringify(
|
|
5915
|
+
return JSON.stringify(Fi(e, n, r), null, 2);
|
|
5898
5916
|
} catch (i) {
|
|
5899
5917
|
return `// ${i instanceof Error ? i.message : "preview failed"}`;
|
|
5900
5918
|
}
|
|
@@ -5908,7 +5926,7 @@ function Hi({
|
|
|
5908
5926
|
/* @__PURE__ */ b("div", { children: [
|
|
5909
5927
|
/* @__PURE__ */ b("div", { className: "grid two", children: [
|
|
5910
5928
|
/* @__PURE__ */ o(le, { label: "Envelope", value: n.mode, options: ["flat", "wrapped"], onChange: (i) => a({ ...n, mode: i }) }),
|
|
5911
|
-
n.mode === "wrapped" && /* @__PURE__ */ o(
|
|
5929
|
+
n.mode === "wrapped" && /* @__PURE__ */ o(ne, { label: "Wrapper key", value: n.wrapperKey ?? "data", onChange: (i) => a({ ...n, wrapperKey: i }) }),
|
|
5912
5930
|
/* @__PURE__ */ o(le, { label: "Key case", value: n.keyCase, options: ["asIs", "camel", "snake", "kebab"], onChange: (i) => a({ ...n, keyCase: i }) }),
|
|
5913
5931
|
/* @__PURE__ */ o(le, { label: "Null handling", value: n.nullHandling, options: ["omit", "null"], onChange: (i) => a({ ...n, nullHandling: i }) }),
|
|
5914
5932
|
/* @__PURE__ */ o(le, { label: "Number encoding", value: n.numberEncoding, options: ["string", "number"], onChange: (i) => a({ ...n, numberEncoding: i }) })
|
|
@@ -5935,13 +5953,13 @@ function Hi({
|
|
|
5935
5953
|
] }) }),
|
|
5936
5954
|
/* @__PURE__ */ o("tbody", { children: e.map((i, c) => /* @__PURE__ */ b("tr", { children: [
|
|
5937
5955
|
/* @__PURE__ */ o("td", { children: /* @__PURE__ */ o("input", { value: i.key, onChange: (l) => u(c, { key: l.target.value }), "aria-label": "key", className: "int-cell-input" }) }),
|
|
5938
|
-
/* @__PURE__ */ o("td", { children: /* @__PURE__ */ o("select", { value: i.source.kind, onChange: (l) => u(c, { source:
|
|
5956
|
+
/* @__PURE__ */ o("td", { children: /* @__PURE__ */ o("select", { value: i.source.kind, onChange: (l) => u(c, { source: Hi(l.target.value) }), "aria-label": "source kind", children: Oi.map((l) => /* @__PURE__ */ o("option", { children: l }, l)) }) }),
|
|
5939
5957
|
/* @__PURE__ */ o("td", { children: /* @__PURE__ */ o(
|
|
5940
5958
|
"input",
|
|
5941
5959
|
{
|
|
5942
|
-
value:
|
|
5960
|
+
value: Bi(i.source),
|
|
5943
5961
|
disabled: i.source.kind === "callback",
|
|
5944
|
-
onChange: (l) => u(c, { source:
|
|
5962
|
+
onChange: (l) => u(c, { source: _i(i.source, l.target.value) }),
|
|
5945
5963
|
"aria-label": "source value",
|
|
5946
5964
|
className: "int-cell-input"
|
|
5947
5965
|
}
|
|
@@ -5972,7 +5990,7 @@ function Hi({
|
|
|
5972
5990
|
] })
|
|
5973
5991
|
] });
|
|
5974
5992
|
}
|
|
5975
|
-
function
|
|
5993
|
+
function Gi(e, t) {
|
|
5976
5994
|
const n = {};
|
|
5977
5995
|
for (const a of He) {
|
|
5978
5996
|
const r = e.endpoints[a];
|
|
@@ -5986,10 +6004,10 @@ function qi(e, t) {
|
|
|
5986
6004
|
retry: e.retry,
|
|
5987
6005
|
upload: e.upload,
|
|
5988
6006
|
offlineQueue: { enabled: !0, storage: "memory", maxItems: 200, flushOn: "manual" },
|
|
5989
|
-
getAuth: t ? async () =>
|
|
6007
|
+
getAuth: t ? async () => da(e.auth.strategy, e.auth.headerName, await t()) : void 0
|
|
5990
6008
|
};
|
|
5991
6009
|
}
|
|
5992
|
-
function
|
|
6010
|
+
function ji({ cfg: e, getToken: t }) {
|
|
5993
6011
|
const [n, a] = M({ loading: !1 }), [r, s] = M("save");
|
|
5994
6012
|
return /* @__PURE__ */ b("div", { children: [
|
|
5995
6013
|
/* @__PURE__ */ b("div", { className: "grid two", children: [
|
|
@@ -5997,13 +6015,13 @@ function Gi({ cfg: e, getToken: t }) {
|
|
|
5997
6015
|
/* @__PURE__ */ o("div", { className: "field", style: { display: "flex", alignItems: "flex-end" }, children: /* @__PURE__ */ o("button", { type: "button", className: "icon-btn", onClick: async () => {
|
|
5998
6016
|
a({ loading: !0 });
|
|
5999
6017
|
const m = e.endpoints[r], d = qe(e.baseUrl, m.path).replace(/:id\b/, "sample-id"), i = { "content-type": "application/json", "X-FinCalc-Test": "1" };
|
|
6000
|
-
t && Object.assign(i,
|
|
6018
|
+
t && Object.assign(i, da(e.auth.strategy, e.auth.headerName, await t()));
|
|
6001
6019
|
const c = performance.now();
|
|
6002
6020
|
try {
|
|
6003
6021
|
const l = await fetch(d, { method: m.method, headers: i, credentials: e.credentials }), p = await l.text(), h = {};
|
|
6004
|
-
l.headers.forEach((f, y) => h[y] = f), a({ loading: !1, ok: l.ok, status: l.status, ms: Math.round(performance.now() - c), headers: h, body:
|
|
6022
|
+
l.headers.forEach((f, y) => h[y] = f), a({ loading: !1, ok: l.ok, status: l.status, ms: Math.round(performance.now() - c), headers: h, body: Wi(p), sent: { url: d, method: m.method, headers: $t(i) } });
|
|
6005
6023
|
} catch (l) {
|
|
6006
|
-
a({ loading: !1, ok: !1, ms: Math.round(performance.now() - c), error: l instanceof Error ? l.message : "request failed", sent: { url: d, method: m.method, headers:
|
|
6024
|
+
a({ loading: !1, ok: !1, ms: Math.round(performance.now() - c), error: l instanceof Error ? l.message : "request failed", sent: { url: d, method: m.method, headers: $t(i) } });
|
|
6007
6025
|
}
|
|
6008
6026
|
}, disabled: n.loading, children: n.loading ? "Testing…" : "Test connection" }) })
|
|
6009
6027
|
] }),
|
|
@@ -6031,9 +6049,9 @@ ${JSON.stringify(n.sent.headers, null, 2)}` })
|
|
|
6031
6049
|
] })
|
|
6032
6050
|
] });
|
|
6033
6051
|
}
|
|
6034
|
-
function
|
|
6052
|
+
function Vi({ cfg: e }) {
|
|
6035
6053
|
const [t, n] = M(!1), [a, r] = M("save"), s = e.endpoints[a], u = qe(e.baseUrl, s.path).replace(/:id\b/, "sample-id"), m = { "content-type": "application/json" };
|
|
6036
|
-
|
|
6054
|
+
ca.includes(e.auth.strategy) && (m[e.auth.strategy === "apiKeyHeader" || e.auth.strategy === "custom" ? e.auth.headerName || "X-API-Key" : "Authorization"] = t ? "<token>" : "***");
|
|
6037
6055
|
const d = [`curl -X ${s.method} '${u}'`];
|
|
6038
6056
|
for (const [c, l] of Object.entries(m)) d.push(` -H '${c}: ${l}'`);
|
|
6039
6057
|
["POST", "PUT", "PATCH"].includes(s.method) && d.push(` -d '{"example":"body"}'`);
|
|
@@ -6054,8 +6072,8 @@ function ji({ cfg: e }) {
|
|
|
6054
6072
|
}, children: "Copy" })
|
|
6055
6073
|
] });
|
|
6056
6074
|
}
|
|
6057
|
-
function
|
|
6058
|
-
const n =
|
|
6075
|
+
function Yi({ cfg: e, getToken: t }) {
|
|
6076
|
+
const n = X(() => yi(Gi(e, t)), [e, t]), [a, r] = M(() => n.queue.list()), [s, u] = M(""), m = () => r(n.queue.list());
|
|
6059
6077
|
return /* @__PURE__ */ b("div", { children: [
|
|
6060
6078
|
/* @__PURE__ */ b("div", { className: "actions-row", style: { marginTop: 0 }, children: [
|
|
6061
6079
|
/* @__PURE__ */ o("button", { type: "button", className: "icon-btn", onClick: m, children: "Refresh" }),
|
|
@@ -6084,7 +6102,7 @@ function Vi({ cfg: e, getToken: t }) {
|
|
|
6084
6102
|
] }) })
|
|
6085
6103
|
] });
|
|
6086
6104
|
}
|
|
6087
|
-
function
|
|
6105
|
+
function Ki({ cfg: e, setCfg: t }) {
|
|
6088
6106
|
const [n, a] = M(""), [r, s] = M("");
|
|
6089
6107
|
return /* @__PURE__ */ b("div", { className: "accordion", style: { marginTop: 20 }, children: [
|
|
6090
6108
|
/* @__PURE__ */ o("span", { className: "lbl", children: "Import / export config (JSON)" }),
|
|
@@ -6098,7 +6116,7 @@ function Yi({ cfg: e, setCfg: t }) {
|
|
|
6098
6116
|
const d = JSON.parse(n);
|
|
6099
6117
|
for (const i of ["token", "apiKey", "getAuth", "authorization"])
|
|
6100
6118
|
i in d && (delete d[i], s(`Refused to import "${i}" — the panel never persists a secret.`));
|
|
6101
|
-
t(() => ({ ...
|
|
6119
|
+
t(() => ({ ...ua(), ...d })), r || s("Imported.");
|
|
6102
6120
|
} catch {
|
|
6103
6121
|
s("Invalid JSON.");
|
|
6104
6122
|
}
|
|
@@ -6107,16 +6125,16 @@ function Yi({ cfg: e, setCfg: t }) {
|
|
|
6107
6125
|
r && /* @__PURE__ */ o("div", { className: "int-note", children: r })
|
|
6108
6126
|
] });
|
|
6109
6127
|
}
|
|
6110
|
-
function
|
|
6128
|
+
function Wi(e) {
|
|
6111
6129
|
try {
|
|
6112
6130
|
return JSON.stringify(JSON.parse(e), null, 2);
|
|
6113
6131
|
} catch {
|
|
6114
6132
|
return e;
|
|
6115
6133
|
}
|
|
6116
6134
|
}
|
|
6117
|
-
const
|
|
6118
|
-
function
|
|
6119
|
-
const { settings: e, update: t, setRegion: n, reset: a, replace: r } = ue(), s = de(null), u = Sn(e).money(g(
|
|
6135
|
+
const zi = "1234567.891";
|
|
6136
|
+
function Ji() {
|
|
6137
|
+
const { settings: e, update: t, setRegion: n, reset: a, replace: r } = ue(), s = de(null), u = Sn(e).money(g(zi)), m = () => {
|
|
6120
6138
|
const i = new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), c = URL.createObjectURL(i), l = document.createElement("a");
|
|
6121
6139
|
l.href = c, l.download = "calcsuite-settings.json", l.click(), URL.revokeObjectURL(c);
|
|
6122
6140
|
}, d = (i) => {
|
|
@@ -6207,7 +6225,7 @@ function zi() {
|
|
|
6207
6225
|
options: [["system", "System"], ["light", "Light"], ["dark", "Dark"], ["highContrast", "High contrast"]]
|
|
6208
6226
|
}
|
|
6209
6227
|
) }),
|
|
6210
|
-
/* @__PURE__ */ o(W, { label: "Accent colour", children: /* @__PURE__ */ o("div", { className: "swatches", children:
|
|
6228
|
+
/* @__PURE__ */ o(W, { label: "Accent colour", children: /* @__PURE__ */ o("div", { className: "swatches", children: wa.map((i) => {
|
|
6211
6229
|
const c = e.ui.accent.toLowerCase() === i.main.toLowerCase();
|
|
6212
6230
|
return /* @__PURE__ */ o(
|
|
6213
6231
|
"button",
|
|
@@ -6228,7 +6246,7 @@ function zi() {
|
|
|
6228
6246
|
{
|
|
6229
6247
|
value: e.ui.fontFamily,
|
|
6230
6248
|
onChange: (i) => t({ ui: { fontFamily: i } }),
|
|
6231
|
-
options:
|
|
6249
|
+
options: Cn.map((i) => [i.id, i.label])
|
|
6232
6250
|
}
|
|
6233
6251
|
) }),
|
|
6234
6252
|
/* @__PURE__ */ o(W, { label: "Density", children: /* @__PURE__ */ o(
|
|
@@ -6251,7 +6269,7 @@ function zi() {
|
|
|
6251
6269
|
" — so exports (PDF/CSV/…) and saved calculations post directly to your own server. No secret is ever stored by the app."
|
|
6252
6270
|
] })
|
|
6253
6271
|
] }),
|
|
6254
|
-
e.features.integrationPanel && /* @__PURE__ */ o(
|
|
6272
|
+
e.features.integrationPanel && /* @__PURE__ */ o(ma, {}),
|
|
6255
6273
|
/* @__PURE__ */ b("div", { className: "actions-row", children: [
|
|
6256
6274
|
/* @__PURE__ */ o("button", { className: "icon-btn", onClick: m, children: "Export settings" }),
|
|
6257
6275
|
/* @__PURE__ */ o("button", { className: "icon-btn", onClick: () => {
|
|
@@ -6284,7 +6302,7 @@ function he({ value: e, onChange: t, options: n }) {
|
|
|
6284
6302
|
function Le({ on: e, onClick: t }) {
|
|
6285
6303
|
return /* @__PURE__ */ o("button", { type: "button", role: "switch", "aria-checked": e, className: `toggle ${e ? "on" : ""}`, onClick: t, children: /* @__PURE__ */ o("span", { className: "knob" }) });
|
|
6286
6304
|
}
|
|
6287
|
-
function
|
|
6305
|
+
function Zi({
|
|
6288
6306
|
items: e,
|
|
6289
6307
|
onRestore: t,
|
|
6290
6308
|
onClear: n
|
|
@@ -6313,18 +6331,18 @@ function wn(e, t) {
|
|
|
6313
6331
|
for (let s = 0; s < n.length && r < e.length; s++) n[s] === e[r] && r++;
|
|
6314
6332
|
return r === e.length ? 10 : -1;
|
|
6315
6333
|
}
|
|
6316
|
-
function
|
|
6334
|
+
function Xi({
|
|
6317
6335
|
calculators: e,
|
|
6318
6336
|
actions: t,
|
|
6319
6337
|
onPick: n,
|
|
6320
6338
|
onClose: a
|
|
6321
6339
|
}) {
|
|
6322
6340
|
const [r, s] = M(""), [u, m] = M(0), d = de(null);
|
|
6323
|
-
|
|
6341
|
+
Q(() => {
|
|
6324
6342
|
var l;
|
|
6325
6343
|
return (l = d.current) == null ? void 0 : l.focus();
|
|
6326
|
-
}, []),
|
|
6327
|
-
const i =
|
|
6344
|
+
}, []), Q(() => (Sa(), () => Ca()), []);
|
|
6345
|
+
const i = X(() => {
|
|
6328
6346
|
const l = e.map((y) => ({
|
|
6329
6347
|
key: `calc:${y.id}`,
|
|
6330
6348
|
label: y.title,
|
|
@@ -6337,7 +6355,7 @@ function Zi({
|
|
|
6337
6355
|
return { it: y, s: Math.max(wn(f, y.label), wn(f, `${y.group} ${((k = (w = e.find((S) => S.title === y.label)) == null ? void 0 : w.keywords) == null ? void 0 : k.join(" ")) ?? ""}`)) };
|
|
6338
6356
|
}).filter((y) => y.s > 0).sort((y, w) => w.s - y.s).map((y) => y.it) : h;
|
|
6339
6357
|
}, [r, e, t, n]);
|
|
6340
|
-
return
|
|
6358
|
+
return Q(() => m(0), [r]), /* @__PURE__ */ o("div", { className: "palette-backdrop", onClick: a, children: /* @__PURE__ */ b("div", { className: "palette", role: "dialog", "aria-label": "Command palette", onClick: (l) => l.stopPropagation(), children: [
|
|
6341
6359
|
/* @__PURE__ */ o(
|
|
6342
6360
|
"input",
|
|
6343
6361
|
{
|
|
@@ -6373,7 +6391,7 @@ function Zi({
|
|
|
6373
6391
|
] })
|
|
6374
6392
|
] }) });
|
|
6375
6393
|
}
|
|
6376
|
-
const
|
|
6394
|
+
const dt = (e) => ({
|
|
6377
6395
|
width: e,
|
|
6378
6396
|
height: e,
|
|
6379
6397
|
viewBox: "0 0 24 24",
|
|
@@ -6384,35 +6402,35 @@ const ct = (e) => ({
|
|
|
6384
6402
|
strokeLinejoin: "round",
|
|
6385
6403
|
"aria-hidden": !0
|
|
6386
6404
|
});
|
|
6387
|
-
function
|
|
6388
|
-
return /* @__PURE__ */ b("svg", { ...
|
|
6405
|
+
function Qi({ size: e = 17 }) {
|
|
6406
|
+
return /* @__PURE__ */ b("svg", { ...dt(e), children: [
|
|
6389
6407
|
/* @__PURE__ */ o("circle", { cx: "12", cy: "12", r: "3" }),
|
|
6390
6408
|
/* @__PURE__ */ o("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z" })
|
|
6391
6409
|
] });
|
|
6392
6410
|
}
|
|
6393
|
-
function
|
|
6394
|
-
return /* @__PURE__ */ b("svg", { ...
|
|
6411
|
+
function es({ size: e = 17 }) {
|
|
6412
|
+
return /* @__PURE__ */ b("svg", { ...dt(e), children: [
|
|
6395
6413
|
/* @__PURE__ */ o("circle", { cx: "12", cy: "12", r: "4" }),
|
|
6396
6414
|
/* @__PURE__ */ o("path", { d: "M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41" })
|
|
6397
6415
|
] });
|
|
6398
6416
|
}
|
|
6399
|
-
function es({ size: e = 17 }) {
|
|
6400
|
-
return /* @__PURE__ */ o("svg", { ...ct(e), children: /* @__PURE__ */ o("path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" }) });
|
|
6401
|
-
}
|
|
6402
6417
|
function ts({ size: e = 17 }) {
|
|
6403
|
-
return /* @__PURE__ */
|
|
6418
|
+
return /* @__PURE__ */ o("svg", { ...dt(e), children: /* @__PURE__ */ o("path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" }) });
|
|
6419
|
+
}
|
|
6420
|
+
function ns({ size: e = 17 }) {
|
|
6421
|
+
return /* @__PURE__ */ b("svg", { ...dt(e), children: [
|
|
6404
6422
|
/* @__PURE__ */ o("path", { d: "M3 3v5h5" }),
|
|
6405
6423
|
/* @__PURE__ */ o("path", { d: "M3.05 13A9 9 0 1 0 6 5.3L3 8" }),
|
|
6406
6424
|
/* @__PURE__ */ o("path", { d: "M12 7v5l4 2" })
|
|
6407
6425
|
] });
|
|
6408
6426
|
}
|
|
6409
|
-
const
|
|
6410
|
-
function
|
|
6411
|
-
const { settings: t, setRegion: n, update: a, resolvedTheme: r } = ue(), s = t.region, u =
|
|
6412
|
-
|
|
6427
|
+
const as = { "loan.emi": zn, scientific: Zn, currency: ra };
|
|
6428
|
+
function rs({ onClose: e }) {
|
|
6429
|
+
const { settings: t, setRegion: n, update: a, resolvedTheme: r } = ue(), s = t.region, u = X(() => Jr(s), [s]), [m, d] = M("loan.emi"), [i, c] = M("calc"), [l, p] = M(void 0), [h, f] = M(!1), { items: y, clear: w } = Do();
|
|
6430
|
+
Q(() => {
|
|
6413
6431
|
const x = () => {
|
|
6414
6432
|
const T = new URLSearchParams(location.hash.replace(/^#/, "") || location.search), $ = T.get("fincalc");
|
|
6415
|
-
if ($ &&
|
|
6433
|
+
if ($ && Rt($)) {
|
|
6416
6434
|
d($), c("calc");
|
|
6417
6435
|
const L = T.get("s");
|
|
6418
6436
|
if (L)
|
|
@@ -6428,7 +6446,7 @@ function as({ onClose: e }) {
|
|
|
6428
6446
|
(x.metaKey || x.ctrlKey) && x.key.toLowerCase() === "k" && (x.preventDefault(), f(!0));
|
|
6429
6447
|
}, S = (x) => {
|
|
6430
6448
|
d(x), c("calc"), p(void 0), f(!1);
|
|
6431
|
-
}, F =
|
|
6449
|
+
}, F = Rt(m) ?? u[0], N = [
|
|
6432
6450
|
{ id: "settings", label: "Open settings", run: () => {
|
|
6433
6451
|
c("settings"), f(!1);
|
|
6434
6452
|
} },
|
|
@@ -6460,17 +6478,17 @@ function as({ onClose: e }) {
|
|
|
6460
6478
|
/* @__PURE__ */ o("button", { "aria-pressed": s === "IN", onClick: () => n("IN"), children: "🇮🇳" }),
|
|
6461
6479
|
/* @__PURE__ */ o("button", { "aria-pressed": s === "US", onClick: () => n("US"), children: "🇺🇸" })
|
|
6462
6480
|
] }),
|
|
6463
|
-
/* @__PURE__ */ o("button", { className: "icon-btn icon-only", onClick: () => a({ ui: { theme: r === "dark" ? "light" : "dark" } }), "aria-label": r === "dark" ? "Switch to light mode" : "Switch to dark mode", children: r === "dark" ? /* @__PURE__ */ o(
|
|
6481
|
+
/* @__PURE__ */ o("button", { className: "icon-btn icon-only", onClick: () => a({ ui: { theme: r === "dark" ? "light" : "dark" } }), "aria-label": r === "dark" ? "Switch to light mode" : "Switch to dark mode", children: r === "dark" ? /* @__PURE__ */ o(es, {}) : /* @__PURE__ */ o(ts, {}) }),
|
|
6464
6482
|
/* @__PURE__ */ b("button", { className: "icon-btn", "aria-label": "History", onClick: () => c("history"), children: [
|
|
6465
|
-
/* @__PURE__ */ o(
|
|
6483
|
+
/* @__PURE__ */ o(ns, {}),
|
|
6466
6484
|
" History"
|
|
6467
6485
|
] }),
|
|
6468
|
-
/* @__PURE__ */ o("button", { className: "icon-btn icon-only", "aria-label": "Settings", onClick: () => c("settings"), children: /* @__PURE__ */ o(
|
|
6486
|
+
/* @__PURE__ */ o("button", { className: "icon-btn icon-only", "aria-label": "Settings", onClick: () => c("settings"), children: /* @__PURE__ */ o(Qi, {}) }),
|
|
6469
6487
|
e && /* @__PURE__ */ o("button", { className: "icon-btn icon-only", "aria-label": "Close", onClick: e, children: "✕" })
|
|
6470
6488
|
] })
|
|
6471
6489
|
] }),
|
|
6472
6490
|
/* @__PURE__ */ b("div", { className: "fc-body", children: [
|
|
6473
|
-
/* @__PURE__ */ o("nav", { className: "fc-rail", "aria-label": "Calculators", children:
|
|
6491
|
+
/* @__PURE__ */ o("nav", { className: "fc-rail", "aria-label": "Calculators", children: Zr.map((x) => {
|
|
6474
6492
|
const T = u.filter(($) => $.group === x.id);
|
|
6475
6493
|
return T.length === 0 ? null : /* @__PURE__ */ b("div", { className: "rail-group", children: [
|
|
6476
6494
|
/* @__PURE__ */ o("div", { className: "rail-group-label", children: x.label }),
|
|
@@ -6486,24 +6504,24 @@ function as({ onClose: e }) {
|
|
|
6486
6504
|
] }, x.id);
|
|
6487
6505
|
}) }),
|
|
6488
6506
|
/* @__PURE__ */ o("main", { className: "fc-main", children: /* @__PURE__ */ b("div", { className: "fc-anim-in", children: [
|
|
6489
|
-
i === "settings" && /* @__PURE__ */ o(
|
|
6490
|
-
i === "history" && /* @__PURE__ */ o(
|
|
6491
|
-
i === "integration" && /* @__PURE__ */ o(
|
|
6507
|
+
i === "settings" && /* @__PURE__ */ o(Ji, {}),
|
|
6508
|
+
i === "history" && /* @__PURE__ */ o(Zi, { items: y, onRestore: P, onClear: w }),
|
|
6509
|
+
i === "integration" && /* @__PURE__ */ o(ma, {}),
|
|
6492
6510
|
i === "calc" && /* @__PURE__ */ o(
|
|
6493
|
-
|
|
6511
|
+
ci,
|
|
6494
6512
|
{
|
|
6495
6513
|
def: F,
|
|
6496
6514
|
seed: l,
|
|
6497
|
-
customRegistry:
|
|
6515
|
+
customRegistry: as,
|
|
6498
6516
|
actions: (x, T) => x ? /* @__PURE__ */ b(re, { children: [
|
|
6499
6517
|
/* @__PURE__ */ o(
|
|
6500
|
-
|
|
6518
|
+
Wn,
|
|
6501
6519
|
{
|
|
6502
6520
|
item: { id: F.id, title: `${F.title} — ${x.primary.value}`, primary: x.primary.value, values: T }
|
|
6503
6521
|
}
|
|
6504
6522
|
),
|
|
6505
6523
|
/* @__PURE__ */ o(
|
|
6506
|
-
|
|
6524
|
+
jn,
|
|
6507
6525
|
{
|
|
6508
6526
|
payload: {
|
|
6509
6527
|
calculatorId: F.id,
|
|
@@ -6520,7 +6538,7 @@ function as({ onClose: e }) {
|
|
|
6520
6538
|
)
|
|
6521
6539
|
] }, i === "calc" ? `calc:${F.id}` : i) })
|
|
6522
6540
|
] }),
|
|
6523
|
-
h && /* @__PURE__ */ o(
|
|
6541
|
+
h && /* @__PURE__ */ o(Xi, { calculators: u, actions: N, onPick: S, onClose: () => f(!1) })
|
|
6524
6542
|
] });
|
|
6525
6543
|
}
|
|
6526
6544
|
function Nn({ size: e = 22 }) {
|
|
@@ -6550,7 +6568,7 @@ function Nn({ size: e = 22 }) {
|
|
|
6550
6568
|
}
|
|
6551
6569
|
);
|
|
6552
6570
|
}
|
|
6553
|
-
function
|
|
6571
|
+
function vs({
|
|
6554
6572
|
variant: e = "fab",
|
|
6555
6573
|
position: t = "bottom-right",
|
|
6556
6574
|
hotkey: n = "mod+shift+k",
|
|
@@ -6574,7 +6592,7 @@ function gs({
|
|
|
6574
6592
|
close: () => S(!1),
|
|
6575
6593
|
toggle: () => S(!k)
|
|
6576
6594
|
};
|
|
6577
|
-
|
|
6595
|
+
Q(() => {
|
|
6578
6596
|
if (!n) return;
|
|
6579
6597
|
const x = n.includes("mod"), T = n.includes("shift"), $ = n.split("+").pop(), L = (B) => {
|
|
6580
6598
|
(!x || B.metaKey || B.ctrlKey) && (!T || B.shiftKey) && B.key.toLowerCase() === $ && (B.preventDefault(), S(!k));
|
|
@@ -6587,12 +6605,12 @@ function gs({
|
|
|
6587
6605
|
/* @__PURE__ */ o("span", { "aria-hidden": !0, style: { marginRight: 6, display: "inline-flex", alignItems: "center" }, children: m ?? /* @__PURE__ */ o(Nn, { size: 16 }) }),
|
|
6588
6606
|
u
|
|
6589
6607
|
] }),
|
|
6590
|
-
/* @__PURE__ */ o(
|
|
6608
|
+
/* @__PURE__ */ o(Fa, { open: k, onClose: F.close, title: h, size: p, children: /* @__PURE__ */ o(rs, { onClose: F.close }) })
|
|
6591
6609
|
] });
|
|
6592
6610
|
}
|
|
6593
|
-
const
|
|
6594
|
-
function
|
|
6595
|
-
const n = t.ttlMs ??
|
|
6611
|
+
const os = 60 * 60 * 1e3, Nt = (e, t) => `${e}|${[...t].sort().join(",")}`;
|
|
6612
|
+
function ks(e, t = {}) {
|
|
6613
|
+
const n = t.ttlMs ?? os, a = t.now ?? Date.now, r = /* @__PURE__ */ new Map();
|
|
6596
6614
|
let s = null;
|
|
6597
6615
|
function u(i) {
|
|
6598
6616
|
var l;
|
|
@@ -6604,7 +6622,7 @@ function vs(e, t = {}) {
|
|
|
6604
6622
|
return a() - i.lastUpdated < n;
|
|
6605
6623
|
}
|
|
6606
6624
|
async function d(i, c) {
|
|
6607
|
-
const l =
|
|
6625
|
+
const l = Nt(i, c), p = r.get(l);
|
|
6608
6626
|
if (p && m(p)) return { ...p, stale: !1 };
|
|
6609
6627
|
if (e)
|
|
6610
6628
|
try {
|
|
@@ -6627,82 +6645,82 @@ function vs(e, t = {}) {
|
|
|
6627
6645
|
return {
|
|
6628
6646
|
getRates: d,
|
|
6629
6647
|
/** Non-throwing peek at whatever is cached, if anything. */
|
|
6630
|
-
peek: (i, c) => r.get(
|
|
6648
|
+
peek: (i, c) => r.get(Nt(i, c)),
|
|
6631
6649
|
get lastUpdated() {
|
|
6632
6650
|
return s == null ? null : new Date(s);
|
|
6633
6651
|
},
|
|
6634
6652
|
isStale(i, c) {
|
|
6635
|
-
const l = r.get(
|
|
6653
|
+
const l = r.get(Nt(i, c));
|
|
6636
6654
|
return !l || !m(l);
|
|
6637
6655
|
},
|
|
6638
6656
|
clear: () => r.clear()
|
|
6639
6657
|
};
|
|
6640
6658
|
}
|
|
6641
|
-
const
|
|
6659
|
+
const ws = { solve: Ie, REGIONS: me };
|
|
6642
6660
|
export {
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6661
|
+
ci as CalculatorPanel,
|
|
6662
|
+
io as Chart,
|
|
6663
|
+
Xi as CommandPalette,
|
|
6664
|
+
ra as CurrencyConverter,
|
|
6647
6665
|
g as D,
|
|
6648
|
-
|
|
6649
|
-
|
|
6666
|
+
bs as DEFAULT_ENVELOPE,
|
|
6667
|
+
Xe as DEFAULT_SETTINGS,
|
|
6650
6668
|
H as Decimal,
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6669
|
+
Fa as Dialog,
|
|
6670
|
+
so as EXPORT_FORMATS,
|
|
6671
|
+
jn as ExportMenu,
|
|
6672
|
+
Qr as Field,
|
|
6673
|
+
Fa as FinCalcDialog,
|
|
6656
6674
|
se as FinCalcError,
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6675
|
+
vs as FinCalcLauncher,
|
|
6676
|
+
ps as FinCalcProvider,
|
|
6677
|
+
rs as FinCalcRoot,
|
|
6678
|
+
Zr as GROUPS,
|
|
6679
|
+
Zi as HistoryPanel,
|
|
6680
|
+
ma as IntegrationPanel,
|
|
6681
|
+
vs as Launcher,
|
|
6682
|
+
zn as LoanEmiPanel,
|
|
6683
|
+
ga as POLICY_DEFAULT,
|
|
6684
|
+
no as ResultCard,
|
|
6685
|
+
Wn as SaveButton,
|
|
6686
|
+
oo as ScheduleTable,
|
|
6687
|
+
Zn as SciCalculator,
|
|
6688
|
+
Ji as SettingsPanel,
|
|
6689
|
+
ps as SettingsProvider,
|
|
6690
|
+
rs as Shell,
|
|
6691
|
+
Ln as allCalculators,
|
|
6674
6692
|
ye as boolval,
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6693
|
+
ia as buildFilename,
|
|
6694
|
+
Fi as buildPayload,
|
|
6695
|
+
gs as buildSavePayload,
|
|
6696
|
+
Rt as calculatorById,
|
|
6697
|
+
Jr as calculatorsForRegion,
|
|
6698
|
+
Ao as clearHistory,
|
|
6699
|
+
Ro as createExporter,
|
|
6700
|
+
ks as createFxCache,
|
|
6701
|
+
yi as createTransport,
|
|
6702
|
+
ys as currency,
|
|
6685
6703
|
D as dmoney,
|
|
6686
|
-
|
|
6704
|
+
us as eq,
|
|
6687
6705
|
on as evalExpression,
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6706
|
+
ei as evaluateExpression,
|
|
6707
|
+
ri as fetchLiveRate,
|
|
6708
|
+
hs as finance,
|
|
6709
|
+
ds as gt,
|
|
6692
6710
|
ce as isZeroish,
|
|
6693
|
-
|
|
6694
|
-
|
|
6711
|
+
ws as loan,
|
|
6712
|
+
ms as lt,
|
|
6695
6713
|
Sn as makeFormatter,
|
|
6696
6714
|
v as metric,
|
|
6697
6715
|
C as numval,
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6716
|
+
Wo as parseExpression,
|
|
6717
|
+
xt as regionDefaults,
|
|
6718
|
+
fs as registerCalculator,
|
|
6719
|
+
hi as sanitizeFilename,
|
|
6720
|
+
Kn as saveHistory,
|
|
6703
6721
|
Ie as solveLoan,
|
|
6704
6722
|
_ as strval,
|
|
6705
6723
|
ue as useFinCalc,
|
|
6706
|
-
|
|
6724
|
+
Do as useHistory,
|
|
6707
6725
|
ue as useSettings
|
|
6708
6726
|
};
|