1import { z as I, a8 as P, ar as C, g as A, G as V, k as L, w as T, D as G, u as w, o as k, c as z, s as W } from "./app-yg_pP4S4.js"; 2import { b as M } from "./functions-DLrKIvnr.js"; 3var y; 4(function(s) { 5 s.symbol = "symbol", s.narrowSymbol = "narrowSymbol", s.code = "code", s.name = "name", s.hidden = "hidden"; 6})(y || (y = {})); 7var p; 8(function(s) { 9 s.precision = "precision", s.thousands = "thousands", s.tenThousands = "tenThousands", s.millions = "millions", s.billions = "billions"; 10})(p || (p = {})); 11const x = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), N = (s) => s.replace(/^0+(0$|[^0])/, "$1"), E = (s, i) => (s.match(new RegExp(x(i), "g")) || []).length, j = (s, i) => s.substring(0, s.indexOf(i)), R = [",", ".", "\u066B", "\u3002"], _ = "(0|[1-9]\\d*)"; 12class q { 13 constructor(i) { 14 var t, e, n, m, a, l; 15 const { currency: c, currencyDisplay: g, locale: r, precision: o, accountingSign: h, useGrouping: f } = i; 16 this.locale = r, this.options = { currency: c, useGrouping: f, style: "currency", currencySign: h ? "accounting" : void 0, currencyDisplay: g !== y.hidden ? g : void 0 }; 17 const d = new Intl.NumberFormat(r, this.options), v = d.formatToParts(123456); 18 this.currency = (t = v.find(({ type: u }) => u === "currency")) === null || t === void 0 ? void 0 : t.value, this.digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((u) => u.toLocaleString(r)), this.decimalSymbol = (e = v.find(({ type: u }) => u === "decimal")) === null || e === void 0 ? void 0 : e.value, this.groupingSymbol = (n = v.find(({ type: u }) => u === "group")) === null || n === void 0 ? void 0 : n.value, this.minusSign = (m = d.formatToParts(-1).find(({ type: u }) => u === "minusSign")) === null || m === void 0 ? void 0 : m.value, this.decimalSymbol === void 0 ? this.minimumFractionDigits = this.maximumFractionDigits = 0 : typeof o == "number" ? this.minimumFractionDigits = this.maximumFractionDigits = o : (this.minimumFractionDigits = (a = o == null ? void 0 : o.min) !== null && a !== void 0 ? a : d.resolvedOptions().minimumFractionDigits, this.maximumFractionDigits = (l = o == null ? void 0 : o.max) !== null && l !== void 0 ? l : d.resolvedOptions().maximumFractionDigits); 19 const b = (u) => j(u, this.digits[1]), S = (u) => u.substring(u.lastIndexOf(this.decimalSymbol ? this.digits[0] : this.digits[1]) + 1); 20 this.prefix = b(d.format(1)), this.suffix = S(d.format(1)), this.negativePrefix = b(d.format(-1)), this.negativeSuffix = S(d.format(-1)); 21 } 22 parse(i) { 23 if (i) { 24 const t = this.isNegative(i); 25 i = this.normalizeDigits(i), i = this.stripCurrency(i, t), i = this.stripSignLiterals(i); 26 const e = this.decimalSymbol ? `(?:${x(this.decimalSymbol)}(\\d*))?` : "", n = this.stripGroupingSeparator(i).match(new RegExp(`^${_}${e}$`)); 27 if (n && this.isValidIntegerFormat(this.decimalSymbol ? i.split(this.decimalSymbol)[0] : i, Number(n[1]))) return +`${t ? "-" : ""}${this.onlyDigits(n[1])}.${this.onlyDigits(n[2] || "")}`; 28 } 29 return null; 30 } 31 isValidIntegerFormat(i, t) { 32 const e = { ...this.options, minimumFractionDigits: 0 }; 33 return [this.stripCurrency(this.normalizeDigits(t.toLocaleString(this.locale, { ...e, useGrouping: true })), false), this.stripCurrency(this.normalizeDigits(t.toLocaleString(this.locale, { ...e, useGrouping: false })), false)].includes(i); 34 } 35 format(i, t = { minimumFractionDigits: this.minimumFractionDigits, maximumFractionDigits: this.maximumFractionDigits }) { 36 return i != null ? i.toLocaleString(this.locale, { ...this.options, ...t }) : ""; 37 } 38 toFraction(i) { 39 return `${this.digits[0]}${this.decimalSymbol}${this.onlyLocaleDigits(i.substring(1)).substring(0, this.maximumFractionDigits)}`; 40 } 41 isFractionIncomplete(i) { 42 return !!this.normalizeDigits(this.stripGroupingSeparator(i)).match(new RegExp(`^${_}${x(this.decimalSymbol)}$`)); 43 } 44 isNegative(i) { 45 return i.startsWith(this.negativePrefix) || this.minusSign === void 0 && (i.startsWith("(") || i.startsWith("-")) || this.minusSign !== void 0 && i.replace("-", this.minusSign).startsWith(this.minusSign); 46 } 47 insertCurrency(i, t) { 48 return `${t ? this.negativePrefix : this.prefix}${i}${t ? this.negativeSuffix : this.suffix}`; 49 } 50 stripGroupingSeparator(i) { 51 return this.groupingSymbol !== void 0 ? i.replace(new RegExp(x(this.groupingSymbol), "g"), "") : i; 52 } 53 stripSignLiterals(i) { 54 return this.minusSign !== void 0 ? i.replace("-", this.minusSign).replace(this.minusSign, "") : i.replace(/[-()]/g, ""); 55 } 56 stripCurrency(i, t) { 57 return i.replace(t ? this.negativePrefix : this.prefix, "").replace(t ? this.negativeSuffix : this.suffix, ""); 58 } 59 normalizeDecimalSeparator(i, t) { 60 return R.forEach((e) => { 61 i = i.substring(0, t) + i.substring(t).replace(e, this.decimalSymbol); 62 }), i; 63 } 64 normalizeDigits(i) {
65 return this.digits[0] !== "0" && this.digits.forEach((t, e) => { 66 i = i.replace(new RegExp(t, "g"), String(e)); 67 }), i; 68 } 69 onlyDigits(i) { 70 return this.normalizeDigits(i).replace(/\D+/g, ""); 71 } 72 onlyLocaleDigits(i) { 73 return i.replace(new RegExp(`[^${this.digits.join("")}]*`, "g"), ""); 74 } 75} 76class $ { 77 constructor(i) { 78 this.currencyFormat = i; 79 } 80} 81class X extends $ { 82 conformToMask(i, t = "") { 83 const e = this.currencyFormat.isNegative(i), n = (d) => d === "" && e && !(this.currencyFormat.minusSign === void 0 ? t === this.currencyFormat.negativePrefix + this.currencyFormat.negativeSuffix : t === this.currencyFormat.negativePrefix), m = (d) => { 84 if (n(d)) return ""; 85 if (this.currencyFormat.maximumFractionDigits > 0) { 86 if (this.currencyFormat.isFractionIncomplete(d)) return d; 87 if (d.startsWith(this.currencyFormat.decimalSymbol)) return this.currencyFormat.toFraction(d); 88 } 89 return null; 90 }; 91 let a = i; 92 a = this.currencyFormat.stripCurrency(a, e), a = this.currencyFormat.stripSignLiterals(a); 93 const l = m(a); 94 if (l != null) return this.currencyFormat.insertCurrency(l, e); 95 const [c, ...g] = a.split(this.currencyFormat.decimalSymbol), r = N(this.currencyFormat.onlyDigits(c)), o = this.currencyFormat.onlyDigits(g.join("")).substring(0, this.currencyFormat.maximumFractionDigits), h = g.length > 0 && o.length === 0, f = r === "" && e && (this.currencyFormat.minusSign === void 0 ? t === i.slice(0, -2) + this.currencyFormat.negativeSuffix : t === i.slice(0, -1)); 96 return h || f || n(r) ? t : r.match(/\d+/) ? { numberValue: +`${e ? "-" : ""}${r}.${o}`, fractionDigits: o } : ""; 97 } 98} 99class B extends $ { 100 conformToMask(i, t = "") { 101 if (i === "" || i === this.currencyFormat.decimalSymbol || this.currencyFormat.parse(t) === 0 && this.currencyFormat.stripCurrency(t, true).slice(0, -1) === this.currencyFormat.stripCurrency(i, true)) return ""; 102 const e = this.currencyFormat.isNegative(i), n = this.currencyFormat.stripSignLiterals(i) === "" ? -0 : +`${e ? "-" : ""}${N(this.currencyFormat.onlyDigits(i))}` / Math.pow(10, this.currencyFormat.maximumFractionDigits); 103 return { numberValue: n, fractionDigits: n.toFixed(this.currencyFormat.maximumFractionDigits).slice(-this.currencyFormat.maximumFractionDigits) }; 104 } 105} 106const U = { locale: void 0, currency: void 0, currencyDisplay: void 0, hideGroupingSeparatorOnFocus: true, hideCurrencySymbolOnFocus: true, hideNegligibleDecimalDigitsOnFocus: true, precision: void 0, autoDecimalDigits: false, valueRange: void 0, useGrouping: void 0, valueScaling: void 0 }; 107class Z { 108 constructor(i) { 109 this.el = i.el, this.onInput = i.onInput, this.onChange = i.onChange, this.addEventListener(), this.init(i.options); 110 } 111 setOptions(i) { 112 this.init(i), this.format(this.currencyFormat.format(this.validateValueRange(this.numberValue))), this.onChange(this.getValue()); 113 } 114 getValue() { 115 return { number: this.valueScaling && this.numberValue != null ? this.toInteger(this.numberValue, this.valueScaling) : this.numberValue, formatted: this.formattedValue }; 116 } 117 setValue(i) { 118 const t = this.valueScaling !== void 0 && i != null ? this.toFloat(i, this.valueScaling) : i; 119 t !== this.numberValue && (this.format(this.currencyFormat.format(this.validateValueRange(t))), this.onChange(this.getValue())); 120 } 121 init(i) { 122 this.options = { ...U, ...i }, this.options.autoDecimalDigits && (this.options.hideNegligibleDecimalDigitsOnFocus = false), this.el.getAttribute("inputmode") || this.el.setAttribute("inputmode", this.options.autoDecimalDigits ? "numeric" : "decimal"), this.currencyFormat = new q(this.options), this.numberMask = this.options.autoDecimalDigits ? new B(this.currencyFormat) : new X(this.currencyFormat); 123 const t = { [p.precision]: this.currencyFormat.maximumFractionDigits, [p.thousands]: 3, [p.tenThousands]: 4, [p.millions]: 6, [p.billions]: 9 }; 124 this.valueScaling = this.options.valueScaling ? t[this.options.valueScaling] : void 0, this.valueScalingFractionDigits = this.valueScaling !== void 0 && this.options.valueScaling !== p.precision ? this.valueScaling + this.currencyFormat.maximumFractionDigits : this.currencyFormat.maximumFractionDigits, this.minValue = this.getMinValue(), this.maxValue = this.getMaxValue(); 125 } 126 getMinValue() { 127 var i, t;
128 let e = this.toFloat(-Number.MAX_SAFE_INTEGER); 129 return ((i = this.options.valueRange) === null || i === void 0 ? void 0 : i.min) !== void 0 && (e = Math.max((t = this.options.valueRange) === null || t === void 0 ? void 0 : t.min, this.toFloat(-Number.MAX_SAFE_INTEGER))), e; 130 } 131 getMaxValue() { 132 var i, t; 133 let e = this.toFloat(Number.MAX_SAFE_INTEGER); 134 return ((i = this.options.valueRange) === null || i === void 0 ? void 0 : i.max) !== void 0 && (e = Math.min((t = this.options.valueRange) === null || t === void 0 ? void 0 : t.max, this.toFloat(Number.MAX_SAFE_INTEGER))), e; 135 } 136 toFloat(i, t) { 137 return i / Math.pow(10, t ?? this.valueScalingFractionDigits); 138 } 139 toInteger(i, t) { 140 return Number(i.toFixed(t ?? this.valueScalingFractionDigits).split(".").join("")); 141 } 142 validateValueRange(i) { 143 return i != null ? Math.min(Math.max(i, this.minValue), this.maxValue) : i; 144 } 145 format(i, t = false) { 146 if (i != null) { 147 this.decimalSymbolInsertedAt !== void 0 && (i = this.currencyFormat.normalizeDecimalSeparator(i, this.decimalSymbolInsertedAt), this.decimalSymbolInsertedAt = void 0); 148 const e = this.numberMask.conformToMask(i, this.formattedValue); 149 let n; 150 if (typeof e == "object") { 151 const { numberValue: m, fractionDigits: a } = e; 152 let { maximumFractionDigits: l, minimumFractionDigits: c } = this.currencyFormat; 153 this.focus ? c = t ? a.replace(/0+$/, "").length : Math.min(l, a.length) : Number.isInteger(m) && !this.options.autoDecimalDigits && (this.options.precision === void 0 || c === 0) && (c = l = 0), n = this.toInteger(Math.abs(m)) > Number.MAX_SAFE_INTEGER ? this.formattedValue : this.currencyFormat.format(m, { useGrouping: this.options.useGrouping !== false && !(this.focus && this.options.hideGroupingSeparatorOnFocus), minimumFractionDigits: c, maximumFractionDigits: l }); 154 } else n = e; 155 this.maxValue <= 0 && !this.currencyFormat.isNegative(n) && this.currencyFormat.parse(n) !== 0 && (n = n.replace(this.currencyFormat.prefix, this.currencyFormat.negativePrefix)), this.minValue >= 0 && (n = n.replace(this.currencyFormat.negativePrefix, this.currencyFormat.prefix)), (this.options.currencyDisplay === y.hidden || this.focus && this.options.hideCurrencySymbolOnFocus) && (n = n.replace(this.currencyFormat.negativePrefix, this.currencyFormat.minusSign !== void 0 ? this.currencyFormat.minusSign : "(").replace(this.currencyFormat.negativeSuffix, this.currencyFormat.minusSign !== void 0 ? "" : ")").replace(this.currencyFormat.prefix, "").replace(this.currencyFormat.suffix, "")), this.el.value = n, this.numberValue = this.currencyFormat.parse(n); 156 } else this.el.value = "", this.numberValue = null; 157 this.formattedValue = this.el.value, this.onInput(this.getValue()); 158 } 159 addEventListener() { 160 this.el.addEventListener("input", (i) => { 161 const { value: t, selectionStart: e } = this.el, n = i; 162 if (e && n.data && R.includes(n.data) && (this.decimalSymbolInsertedAt = e - 1), this.format(t), this.focus && e != null) { 163 const m = () => {
164 const { prefix: a, suffix: l, decimalSymbol: c, maximumFractionDigits: g, groupingSymbol: r } = this.currencyFormat; 165 let o = t.length - e; 166 const h = this.formattedValue.length; 167 if (this.currencyFormat.minusSign === void 0 && (t.startsWith("(") || t.startsWith("-")) && !t.endsWith(")")) return h - this.currencyFormat.negativeSuffix.length > 1 ? this.formattedValue.substring(e).length : 1; 168 if (this.formattedValue.substring(e, 1) === r && E(this.formattedValue, r) === E(t, r) + 1) return h - o - 1; 169 if (h < o) return e; 170 if (c !== void 0 && t.indexOf(c) !== -1) { 171 const f = t.indexOf(c) + 1; 172 if (Math.abs(h - t.length) > 1 && e <= f) return this.formattedValue.indexOf(c) + 1; 173 !this.options.autoDecimalDigits && e > f && this.currencyFormat.onlyDigits(t.substring(f)).length - 1 === g && (o -= 1); 174 } 175 return this.options.hideCurrencySymbolOnFocus || this.options.currencyDisplay === y.hidden ? h - o : Math.max(h - Math.max(o, l.length), a.length); 176 }; 177 this.setCaretPosition(m()); 178 } 179 }), this.el.addEventListener("focus", () => { 180 this.focus = true, this.numberValueOnFocus = this.numberValue, setTimeout(() => { 181 const { value: i, selectionStart: t, selectionEnd: e } = this.el; 182 if (this.format(i, this.options.hideNegligibleDecimalDigitsOnFocus), t != null && e != null && Math.abs(t - e) > 0) this.setCaretPosition(0, this.el.value.length); 183 else if (t != null) { 184 const n = this.getCaretPositionOnFocus(i, t); 185 this.setCaretPosition(n); 186 } 187 }); 188 }), this.el.addEventListener("blur", () => { 189 this.focus = false, this.format(this.currencyFormat.format(this.validateValueRange(this.numberValue))), this.numberValueOnFocus !== this.numberValue && this.onChange(this.getValue()); 190 }); 191 } 192 getCaretPositionOnFocus(i, t) { 193 if (this.numberValue == null) return t; 194 const { prefix: e, negativePrefix: n, suffix: m, negativeSuffix: a, groupingSymbol: l, currency: c } = this.currencyFormat, g = this.numberValue < 0, r = g ? n : e, o = r.length; 195 if (this.options.hideCurrencySymbolOnFocus || this.options.currencyDisplay === y.hidden) { 196 if (g) { 197 if (t <= 1) return 1; 198 if (i.endsWith(")") && t > i.indexOf(")")) return this.formattedValue.length - 1; 199 } 200 } else { 201 const f = g ? a.length : m.length; 202 if (t >= i.length - f) return this.formattedValue.length - f; 203 if (t < o) return o; 204 } 205 let h = t; 206 return this.options.hideCurrencySymbolOnFocus && this.options.currencyDisplay !== y.hidden && t >= o && c !== void 0 && r.includes(c) && (h -= o, g && (h += 1)), this.options.hideGroupingSeparatorOnFocus && l !== void 0 && (h -= E(i.substring(0, t), l)), h; 207 } 208 setCaretPosition(i, t = i) { 209 this.el.setSelectionRange(i, t); 210 } 211} 212const H = (s) => (s == null ? void 0 : s.matches("input")) ? s : s == null ? void 0 : s.querySelector("input"); 213function J(s, i) { 214 var t, e, n, m; 215 let a; 216 const l = V(null), c = V(null), g = V(null), r = P(), o = (r == null ? void 0 : r.emit) || ((e = (t = r == null ? void 0 : r.proxy) === null || t === void 0 ? void 0 : t.$emit) === null || e === void 0 ? void 0 : e.bind(r == null ? void 0 : r.proxy)), h = (r == null ? void 0 : r.props) || ((n = r == null ? void 0 : r.proxy) === null || n === void 0 ? void 0 : n.$props), f = C.startsWith("3"), d = f && ((m = r == null ? void 0 : r.attrs.modelModifiers) === null || m === void 0 ? void 0 : m.lazy), v = A(() => h == null ? void 0 : h[f ? "modelValue" : "value"]), b = f ? "update:modelValue" : "input", S = d ? "update:modelValue" : "change"; 217 return I(l, (u) => { 218 var D; 219 if (u) { 220 const O = H((D = u == null ? void 0 : u.$el) !== null && D !== void 0 ? D : u); 221 O ? (a = new Z({ el: O, options: s, onInput: (F) => { 222 !d && i !== false && v.value !== F.number && (o == null ? void 0 : o(b, F.number)), g.value = F.number, c.value = F.formatted; 223 }, onChange: (F) => { 224 o == null ? void 0 : o(S, F.number); 225 } }), a.setValue(v.value)) : console.error('No input element found. Please make sure that the "inputRef" template ref is properly assigned.'); 226 } else a = null; 227 }), { inputRef: l, numberValue: g, formattedValue: c, setValue: (u) => a == null ? void 0 : a.setValue(u), setOptions: (u) => a == null ? void 0 : a.setOptions(u) }; 228} 229const Y = { __name: "CurrencyInput", props: { modelValue: { type: [Number, String], required: false, default: null }, options: { type: Object, required: false }, currency: { type: String, required: false, default: () => M.value.currency }, autofocus: { type: Boolean, required: false, default: false } }, setup(s) { 230 const i = s, t = { locale: M.value.locale, currency: i.currency, currencyDisplay: "symbol", precision: 2, hideCurrencySymbolOnFocus: true, hideGroupingSeparatorOnFocus: false, hideNegligibleDecimalDigitsOnFocus: false, autoDecimalDigits: false, valueScaling: "precision", useGrouping: true, accountingSign: false, ...i.options }, { inputRef: e, formattedValue: n, setValue: m, setOptions: a } = J(t); 231 return L(() => { 232 i.autofocus && e.value && setTimeout(() => { 233 e.value.focus(); 234 }, 100); 235 }), I(() => i.modelValue, (l) => m(l)), I(() => i.currency, (l) => a({ ...t, currency: l })), (l, c) => T((k(), z("input", { ref_key: "inputRef", ref: e, "onUpdate:modelValue": c[0] || (c[0] = (g) => W(n) ? n.value = g : null), type: "text" }, null, 512)), [[G, w(n)]]); 236} }; 237export { 238 Y as _ 239};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.