inertia-bootstrap-forms 3.0.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.fa.md +86 -6
  2. package/README.md +95 -8
  3. package/dist/chunks/UppyInput-Dt8CPfgC.js +210 -0
  4. package/dist/chunks/UppyInput-ldc834tZ.cjs +1 -0
  5. package/dist/chunks/_plugin-vue_export-helper-13TPlHFF.js +81 -0
  6. package/dist/chunks/_plugin-vue_export-helper-BHyUve4F.cjs +1 -0
  7. package/dist/chunks/http-CDPNmbjF.cjs +1 -0
  8. package/dist/chunks/http-DV3dRBe5.js +158 -0
  9. package/dist/country-codes.cjs +1 -0
  10. package/dist/country-codes.js +245 -0
  11. package/dist/dropzone.cjs +1 -0
  12. package/dist/dropzone.js +81 -0
  13. package/dist/editor.cjs +1 -0
  14. package/dist/editor.js +52 -0
  15. package/dist/index.cjs +1 -0
  16. package/dist/index.js +3230 -0
  17. package/dist/location.cjs +1 -0
  18. package/dist/location.js +84 -0
  19. package/dist/persian-date.cjs +1 -0
  20. package/dist/persian-date.js +73 -0
  21. package/dist/style.css +1 -0
  22. package/dist/tel.cjs +1 -0
  23. package/dist/tel.js +85 -0
  24. package/dist/uppy-dashboard.cjs +1 -0
  25. package/dist/uppy-dashboard.js +31 -0
  26. package/dist/uppy.cjs +1 -0
  27. package/dist/uppy.js +4 -0
  28. package/index.d.ts +50 -30
  29. package/package.json +101 -17
  30. package/src/CheckboxToggle.vue +1 -1
  31. package/src/ComboboxInput.vue +495 -496
  32. package/src/PasswordInput.vue +124 -123
  33. package/src/StarRatingInput.vue +1 -1
  34. package/src/UppyDashboardInput.vue +45 -0
  35. package/src/UppyInput.vue +36 -3
  36. package/src/VoiceRecorderInput.vue +660 -0
  37. package/src/VoiceRecorderResultArea.vue +109 -0
  38. package/src/composables/useVoiceChannel.js +31 -0
  39. package/src/entries/country-codes.js +1 -0
  40. package/src/entries/dropzone.js +1 -0
  41. package/src/entries/editor.js +1 -0
  42. package/src/entries/location.js +1 -0
  43. package/src/entries/persian-date.js +1 -0
  44. package/src/entries/tel.js +1 -0
  45. package/src/entries/uppy-dashboard.js +1 -0
  46. package/src/entries/uppy.js +1 -0
  47. package/src/index.js +6 -19
  48. package/types/country-codes.d.ts +1 -0
  49. package/types/dropzone.d.ts +2 -0
  50. package/types/editor.d.ts +2 -0
  51. package/types/location.d.ts +2 -0
  52. package/types/persian-date.d.ts +2 -0
  53. package/types/tel.d.ts +2 -0
  54. package/types/uppy-dashboard.d.ts +12 -0
  55. package/types/uppy.d.ts +10 -0
  56. package/dist/inertia-bootstrap-forms.cjs.js +0 -1
  57. package/dist/inertia-bootstrap-forms.es.js +0 -3536
  58. package/src/RangeSliderInput.vue +0 -103
  59. package/src/Select2Input.vue +0 -251
package/dist/index.js ADDED
@@ -0,0 +1,3230 @@
1
+ import * as xe from "vue";
2
+ import { defineComponent as F, createElementBlock as h, openBlock as m, normalizeClass as q, renderSlot as j, createElementVNode as p, createCommentVNode as M, toDisplayString as V, computed as C, withDirectives as re, vModelText as sn, normalizeStyle as se, ref as E, onMounted as J, watch as H, vModelDynamic as ke, createTextVNode as _, shallowRef as yn, onBeforeUnmount as un, nextTick as W, Fragment as G, renderList as ae, reactive as ie, resolveComponent as oe, createBlock as le, mergeProps as Ke, withModifiers as _e, provide as Ve, inject as pe, withCtx as Qe, createVNode as Ne, h as bn, vModelCheckbox as $n, Teleport as wn } from "vue";
3
+ import { _ as L, f as z, u as U } from "./chunks/_plugin-vue_export-helper-13TPlHFF.js";
4
+ import { u as Q, a as Le, l as De, c as kn } from "./chunks/http-DV3dRBe5.js";
5
+ import { useForm as Sn } from "@inertiajs/vue3";
6
+ const In = "۰۱۲۳۴۵۶۷۸۹", Cn = "٠١٢٣٤٥٦٧٨٩";
7
+ function Je(e) {
8
+ return String(e ?? "").replace(/[۰-۹٠-٩]/g, (n) => {
9
+ const a = In.indexOf(n);
10
+ return String(a !== -1 ? a : Cn.indexOf(n));
11
+ });
12
+ }
13
+ function qe(e) {
14
+ if (e == null || e === "") return "";
15
+ const n = Number(e);
16
+ return Number.isNaN(n) ? "" : n.toLocaleString("en-US");
17
+ }
18
+ function dn(e) {
19
+ const n = Je(e).replace(/\D/g, "");
20
+ return n === "" ? null : parseInt(n, 10);
21
+ }
22
+ const Tn = F({
23
+ name: "AmountInput",
24
+ emits: ["update:modelValue", "change", "input", "focus", "blur"],
25
+ props: {
26
+ ...z,
27
+ placeholder: { type: String, default: null },
28
+ unit: { type: String, default: null },
29
+ min: { type: Number, default: null },
30
+ max: { type: Number, default: null },
31
+ inputClass: { type: [String, Array, Object], default: null },
32
+ size: { type: String, default: null },
33
+ locale: { type: String, default: null }
34
+ },
35
+ setup(e, { emit: n }) {
36
+ const a = U(e, n), { t: l } = Q(() => e.locale), c = C(() => qe(a.model.value)), i = C(() => e.unit ?? l("amount.unit")), t = C(() => e.size ? `form-control-${e.size}` : null);
37
+ function u($) {
38
+ const y = $.target, b = y.value.slice(0, y.selectionStart ?? 0), w = Je(b).replace(/\D/g, "").length, T = dn(y.value);
39
+ a.model.value = T;
40
+ const o = qe(T);
41
+ y.value = o;
42
+ let r = 0, s = 0;
43
+ for (; r < o.length && s < w; )
44
+ /\d/.test(o[r]) && s++, r++;
45
+ document.activeElement === y && y.setSelectionRange(r, r), n("input", T, $);
46
+ }
47
+ function g($) {
48
+ let y = a.model.value;
49
+ y != null && (e.max !== null && y > e.max && (y = e.max), e.min !== null && y < e.min && (y = e.min), y !== a.model.value && (a.model.value = y)), a.emitChange(y, $);
50
+ }
51
+ return { ...a, displayValue: c, unitText: i, sizeClass: t, onInput: u, clamp: g, t: l };
52
+ }
53
+ }), Mn = ["name", "id", "value", "placeholder", "required", "readonly", "disabled", "aria-invalid"], Bn = {
54
+ key: 0,
55
+ class: "input-group-text fanum"
56
+ };
57
+ function En(e, n, a, l, c, i) {
58
+ return m(), h("div", {
59
+ class: q(["input-group", { "is-invalid": e.isInvalid }])
60
+ }, [
61
+ j(e.$slots, "prefix"),
62
+ p("input", {
63
+ name: e.name,
64
+ id: e.inputId,
65
+ value: e.displayValue,
66
+ placeholder: e.placeholder ?? e.t("amount.placeholder"),
67
+ required: e.required,
68
+ readonly: e.readonly,
69
+ disabled: e.isDisabled,
70
+ "aria-invalid": e.isInvalid || void 0,
71
+ type: "tel",
72
+ inputmode: "numeric",
73
+ autocomplete: "off",
74
+ class: q(["form-control fanum", [e.sizeClass, e.inputClass, { "is-invalid": e.isInvalid }]]),
75
+ onInput: n[0] || (n[0] = (...t) => e.onInput && e.onInput(...t)),
76
+ onChange: n[1] || (n[1] = (...t) => e.clamp && e.clamp(...t)),
77
+ onFocus: n[2] || (n[2] = (t) => e.$emit("focus", t)),
78
+ onBlur: n[3] || (n[3] = (t) => e.$emit("blur", t))
79
+ }, null, 42, Mn),
80
+ e.unitText ? (m(), h("span", Bn, V(e.unitText), 1)) : M("", !0),
81
+ j(e.$slots, "suffix")
82
+ ], 2);
83
+ }
84
+ const An = /* @__PURE__ */ L(Tn, [["render", En]]), On = F({
85
+ name: "CaptchaInput",
86
+ emits: ["update:modelValue", "change", "input", "refresh"],
87
+ props: {
88
+ ...z,
89
+ name: { type: String, default: "captcha" },
90
+ /** Endpoint that returns the captcha image. */
91
+ url: { type: String, default: "/captcha/default" },
92
+ placeholder: { type: String, default: null },
93
+ /** Reload the image (and clear the input) when a submit finishes. */
94
+ refreshOnSubmit: { type: Boolean, default: !0 },
95
+ imageWidth: { type: [Number, String], default: 82 },
96
+ imageHeight: { type: [Number, String], default: 38 },
97
+ locale: { type: String, default: null }
98
+ },
99
+ setup(e, { emit: n, expose: a }) {
100
+ const l = U(e, n), { t: c } = Q(() => e.locale), i = Le(), t = E(null), u = E(!0);
101
+ function g() {
102
+ u.value = !0, t.value = `${e.url}${e.url.includes("?") ? "&" : "?"}t=${Date.now()}`, i.timeout(() => {
103
+ u.value = !1;
104
+ }, 500), n("refresh");
105
+ }
106
+ return J(g), H(
107
+ () => {
108
+ var $;
109
+ return ($ = l.form.value) == null ? void 0 : $.processing;
110
+ },
111
+ ($, y) => {
112
+ e.refreshOnSubmit && y && !$ && (l.model.value = null, g());
113
+ }
114
+ ), a({ refresh: g }), { ...l, t: c, src: t, loading: u, refresh: g };
115
+ }
116
+ }), Vn = ["name", "id", "placeholder", "required", "readonly", "disabled", "aria-invalid"], Nn = ["src", "alt", "width", "height"], Dn = {
117
+ key: 1,
118
+ class: "placeholder-wave w-100",
119
+ "aria-hidden": "true"
120
+ }, qn = ["disabled", "aria-label"];
121
+ function Fn(e, n, a, l, c, i) {
122
+ return m(), h("div", {
123
+ class: q(["input-group captcha", { "is-invalid": e.isInvalid }])
124
+ }, [
125
+ re(p("input", {
126
+ "onUpdate:modelValue": n[0] || (n[0] = (t) => e.model = t),
127
+ name: e.name,
128
+ id: e.inputId,
129
+ type: "text",
130
+ inputmode: "numeric",
131
+ autocomplete: "off",
132
+ placeholder: e.placeholder ?? e.t("captcha.placeholder"),
133
+ required: e.required,
134
+ readonly: e.readonly,
135
+ disabled: e.isDisabled,
136
+ "aria-invalid": e.isInvalid || void 0,
137
+ class: q(["form-control text-start", { "is-invalid": e.isInvalid }]),
138
+ onInput: n[1] || (n[1] = (t) => e.$emit("input", e.model, t)),
139
+ onChange: n[2] || (n[2] = (t) => e.emitChange(e.model, t))
140
+ }, null, 42, Vn), [
141
+ [sn, e.model]
142
+ ]),
143
+ p("span", {
144
+ class: "input-group-text p-0 overflow-hidden",
145
+ style: se({ width: e.imageWidth + "px", height: "auto" })
146
+ }, [
147
+ e.src && !e.loading ? (m(), h("img", {
148
+ key: 0,
149
+ src: e.src,
150
+ alt: e.t("captcha.alt"),
151
+ width: e.imageWidth,
152
+ height: e.imageHeight,
153
+ class: "captcha-holder",
154
+ style: { cursor: "pointer", objectFit: "contain" },
155
+ onClick: n[3] || (n[3] = (...t) => e.refresh && e.refresh(...t))
156
+ }, null, 8, Nn)) : (m(), h("span", Dn, [
157
+ p("span", {
158
+ class: "placeholder w-100",
159
+ style: se({ height: e.imageHeight + "px" })
160
+ }, null, 4)
161
+ ]))
162
+ ], 4),
163
+ p("button", {
164
+ type: "button",
165
+ class: "btn-outline theme-secondary btn-icon",
166
+ disabled: e.isDisabled || e.loading,
167
+ "aria-label": e.t("captcha.refresh"),
168
+ onClick: n[4] || (n[4] = (...t) => e.refresh && e.refresh(...t))
169
+ }, n[5] || (n[5] = [
170
+ p("svg", {
171
+ width: "16",
172
+ height: "16",
173
+ viewBox: "0 0 16 16",
174
+ fill: "none",
175
+ stroke: "currentColor",
176
+ "stroke-width": "1.5",
177
+ "stroke-linecap": "round",
178
+ "stroke-linejoin": "round",
179
+ "aria-hidden": "true"
180
+ }, [
181
+ p("path", { d: "M13.5 3v3.5H10M2.5 13V9.5H6" }),
182
+ p("path", { d: "M3.2 6.5A5.5 5.5 0 0 1 13 6.5M12.8 9.5A5.5 5.5 0 0 1 3 9.5" })
183
+ ], -1)
184
+ ]), 8, qn)
185
+ ], 2);
186
+ }
187
+ const Ln = /* @__PURE__ */ L(On, [["render", Fn]]);
188
+ function Re(e, n, a, { type: l = () => e.type } = {}) {
189
+ function c() {
190
+ if (!e.checked) return;
191
+ const t = n.model.value;
192
+ l() === "radio" ? (t == null || t === "") && (n.model.value = e.value) : Array.isArray(t) ? t.includes(e.value) || (n.model.value = [...t, e.value]) : t || (n.model.value = e.trueValue !== void 0 ? e.trueValue : !0);
193
+ }
194
+ function i() {
195
+ a.value && (a.value.indeterminate = !!e.indeterminate);
196
+ }
197
+ return J(() => {
198
+ c(), i();
199
+ }), H(() => e.indeterminate, i), { applyInitialChecked: c };
200
+ }
201
+ const Rn = F({
202
+ name: "CheckboxButtonInput",
203
+ emits: ["update:modelValue", "change", "focus", "blur"],
204
+ props: {
205
+ ...z,
206
+ type: { type: String, default: "radio", validator: (e) => ["checkbox", "radio"].includes(e) },
207
+ value: { type: [String, Number, Boolean, Object], default: "yes" },
208
+ trueValue: { type: null, default: !0 },
209
+ falseValue: { type: null, default: !1 },
210
+ checked: { type: Boolean, default: !1 },
211
+ /** solid | outline | subtle | text | styled */
212
+ variant: { type: String, default: "outline" },
213
+ theme: { type: String, default: "primary" }
214
+ },
215
+ setup(e, { emit: n }) {
216
+ const a = E(null), l = U(e, n, { valued: () => e.value });
217
+ return Re(e, l, a), { ...l, input: a, onChange: (c) => l.emitChange(l.model.value, c) };
218
+ },
219
+ expose: ["input"]
220
+ }), jn = ["name", "type", "value", "true-value", "false-value", "required", "disabled", "aria-invalid"];
221
+ function Pn(e, n, a, l, c, i) {
222
+ return m(), h("label", {
223
+ class: q(["btn-check", [`btn-${e.variant}`, `theme-${e.theme}`, { "is-invalid": e.isInvalid, disabled: e.isDisabled }]])
224
+ }, [
225
+ re(p("input", {
226
+ ref: "input",
227
+ "onUpdate:modelValue": n[0] || (n[0] = (t) => e.model = t),
228
+ name: e.name,
229
+ type: e.type,
230
+ value: e.value,
231
+ "true-value": e.trueValue,
232
+ "false-value": e.falseValue,
233
+ required: e.required,
234
+ disabled: e.isDisabled,
235
+ "aria-invalid": e.isInvalid || void 0,
236
+ autocomplete: "off",
237
+ class: q({ "is-invalid": e.isInvalid }),
238
+ onChange: n[1] || (n[1] = (...t) => e.onChange && e.onChange(...t)),
239
+ onFocus: n[2] || (n[2] = (t) => e.$emit("focus", t)),
240
+ onBlur: n[3] || (n[3] = (t) => e.$emit("blur", t))
241
+ }, null, 42, jn), [
242
+ [ke, e.model]
243
+ ]),
244
+ j(e.$slots, "default")
245
+ ], 2);
246
+ }
247
+ const zn = /* @__PURE__ */ L(Rn, [["render", Pn]]), Un = F({
248
+ name: "CheckboxInput",
249
+ emits: ["update:modelValue", "change", "focus", "blur"],
250
+ props: {
251
+ ...z,
252
+ /** checkbox | radio */
253
+ type: { type: String, default: "checkbox", validator: (e) => ["checkbox", "radio"].includes(e) },
254
+ /** Value added to the model (arrays / radios) when this option is checked. */
255
+ value: { type: [String, Number, Boolean, Object], default: "yes" },
256
+ trueValue: { type: null, default: !0 },
257
+ falseValue: { type: null, default: !1 },
258
+ /** Initial checked state (applied only when the model is still empty). */
259
+ checked: { type: Boolean, default: !1 },
260
+ indeterminate: { type: Boolean, default: !1 },
261
+ label: { type: String, default: null }
262
+ },
263
+ setup(e, { emit: n }) {
264
+ const a = E(null), l = U(e, n, { valued: () => e.value });
265
+ Re(e, l, a);
266
+ function c(i) {
267
+ l.emitChange(l.model.value, i);
268
+ }
269
+ return { ...l, input: a, onChange: c };
270
+ },
271
+ expose: ["input"]
272
+ }), Hn = { class: "form-field" }, Kn = ["name", "id", "type", "value", "true-value", "false-value", "required", "disabled", "aria-invalid"], Xn = ["for"];
273
+ function Gn(e, n, a, l, c, i) {
274
+ return m(), h("div", Hn, [
275
+ re(p("input", {
276
+ ref: "input",
277
+ "onUpdate:modelValue": n[0] || (n[0] = (t) => e.model = t),
278
+ name: e.name,
279
+ id: e.inputId,
280
+ type: e.type,
281
+ value: e.value,
282
+ "true-value": e.trueValue,
283
+ "false-value": e.falseValue,
284
+ required: e.required,
285
+ disabled: e.isDisabled,
286
+ "aria-invalid": e.isInvalid || void 0,
287
+ class: q([e.type === "radio" ? "radio" : "check", { "is-invalid": e.isInvalid }]),
288
+ onClick: n[1] || (n[1] = (t) => e.readonly && t.preventDefault()),
289
+ onChange: n[2] || (n[2] = (...t) => e.onChange && e.onChange(...t)),
290
+ onFocus: n[3] || (n[3] = (t) => e.$emit("focus", t)),
291
+ onBlur: n[4] || (n[4] = (t) => e.$emit("blur", t))
292
+ }, null, 42, Kn), [
293
+ [ke, e.model]
294
+ ]),
295
+ p("label", { for: e.inputId }, [
296
+ j(e.$slots, "default", {}, () => [
297
+ _(V(e.label), 1)
298
+ ])
299
+ ], 8, Xn)
300
+ ]);
301
+ }
302
+ const Wn = /* @__PURE__ */ L(Un, [["render", Gn]]), Qn = F({
303
+ name: "CheckboxToggle",
304
+ emits: ["update:modelValue", "change", "focus", "blur"],
305
+ props: {
306
+ ...z,
307
+ type: { type: String, default: "checkbox", validator: (e) => ["checkbox", "radio"].includes(e) },
308
+ value: { type: [String, Number, Boolean, Object], default: "yes" },
309
+ trueValue: { type: null, default: !0 },
310
+ falseValue: { type: null, default: !1 },
311
+ checked: { type: Boolean, default: !1 },
312
+ /** Visually hide the check mark (the card highlight is the only indicator). */
313
+ hideInput: { type: Boolean, default: !1 },
314
+ formField: { type: Boolean, default: !0 },
315
+ formFieldCard: { type: Boolean, default: !0 }
316
+ },
317
+ setup(e, { emit: n }) {
318
+ const a = E(null), l = U(e, n, { valued: () => e.value });
319
+ return Re(e, l, a), { ...l, input: a, onChange: (c) => l.emitChange(l.model.value, c) };
320
+ },
321
+ expose: ["input"]
322
+ }), Jn = ["name", "id", "type", "value", "true-value", "false-value", "required", "disabled", "aria-invalid"], Zn = ["for"];
323
+ function Yn(e, n, a, l, c, i) {
324
+ return m(), h("div", {
325
+ class: q({
326
+ "form-field": e.formField,
327
+ "form-field-card": e.formFieldCard,
328
+ "is-invalid": e.isInvalid,
329
+ disabled: e.isDisabled || e.readonly
330
+ })
331
+ }, [
332
+ re(p("input", {
333
+ ref: "input",
334
+ "onUpdate:modelValue": n[0] || (n[0] = (t) => e.model = t),
335
+ name: e.name,
336
+ id: e.inputId,
337
+ type: e.type,
338
+ value: e.value,
339
+ "true-value": e.trueValue,
340
+ "false-value": e.falseValue,
341
+ required: e.required,
342
+ disabled: e.isDisabled,
343
+ "aria-invalid": e.isInvalid || void 0,
344
+ class: q([e.type === "radio" ? "radio" : "check", { "is-invalid": e.isInvalid, "visually-hidden": e.hideInput }]),
345
+ onClick: n[1] || (n[1] = (t) => e.readonly && t.preventDefault()),
346
+ onChange: n[2] || (n[2] = (...t) => e.onChange && e.onChange(...t)),
347
+ onFocus: n[3] || (n[3] = (t) => e.$emit("focus", t)),
348
+ onBlur: n[4] || (n[4] = (t) => e.$emit("blur", t))
349
+ }, null, 42, Jn), [
350
+ [ke, e.model]
351
+ ]),
352
+ p("label", { for: e.inputId }, [
353
+ j(e.$slots, "default")
354
+ ], 8, Zn)
355
+ ], 2);
356
+ }
357
+ const xn = /* @__PURE__ */ L(Qn, [["render", Yn]]), Xe = {}, $e = /* @__PURE__ */ new Map(), en = {
358
+ Combobox: () => import("bootstrap/js/dist/combobox.js"),
359
+ Menu: () => import("bootstrap/js/dist/menu.js"),
360
+ Strength: () => import("bootstrap/js/dist/strength.js"),
361
+ Chips: () => import("bootstrap/js/dist/chips.js"),
362
+ OtpInput: () => import("bootstrap/js/dist/otp-input.js"),
363
+ Range: () => import("bootstrap/js/dist/range.js")
364
+ };
365
+ function _n(e = {}) {
366
+ Object.assign(Xe, e), $e.clear();
367
+ }
368
+ function et(e) {
369
+ return Xe[e] ? Promise.resolve(Xe[e]) : en[e] ? ($e.has(e) || $e.set(
370
+ e,
371
+ en[e]().then((n) => n.default ?? n[e]).catch((n) => {
372
+ throw $e.delete(e), n;
373
+ })
374
+ ), $e.get(e)) : Promise.reject(new Error(`[inertia-bootstrap-forms] Unknown Bootstrap plugin "${e}"`));
375
+ }
376
+ function he(e, n, a, l = {}) {
377
+ const c = yn(null);
378
+ let i = 0, t = !1, u = null;
379
+ function g() {
380
+ var b;
381
+ i++;
382
+ const y = c.value;
383
+ if (c.value = null, y) {
384
+ try {
385
+ (b = l.onDestroy) == null || b.call(l, y, u);
386
+ } catch {
387
+ }
388
+ try {
389
+ y.dispose();
390
+ } catch {
391
+ }
392
+ }
393
+ u = null;
394
+ }
395
+ async function $() {
396
+ var o, r, s;
397
+ g();
398
+ const y = i, b = await et(e);
399
+ if (t || y !== i) return null;
400
+ const w = n();
401
+ if (!w) return null;
402
+ (r = (o = b.getInstance) == null ? void 0 : o.call(b, w)) == null || r.dispose(), u = w;
403
+ const T = new b(w, a());
404
+ return c.value = T, (s = l.onCreate) == null || s.call(l, T, w), T;
405
+ }
406
+ return J(() => {
407
+ t = !1, $().catch((y) => {
408
+ console.error(`[inertia-bootstrap-forms] Could not start Bootstrap ${e}.`, y);
409
+ });
410
+ }), un(() => {
411
+ t = !0, g();
412
+ }), { instance: c, create: $, destroy: g };
413
+ }
414
+ const nn = (e, n) => e.length === n.length && e.every((a, l) => a === n[l]), nt = F({
415
+ name: "ChipsInput",
416
+ emits: ["update:modelValue", "change", "add", "remove", "select", "rejected", "focus", "blur"],
417
+ props: {
418
+ ...z,
419
+ placeholder: { type: String, default: null },
420
+ /** Character that splits typed / pasted text into chips. Use null to disable. */
421
+ separator: { type: String, default: "," },
422
+ allowDuplicates: { type: Boolean, default: !1 },
423
+ maxChips: { type: Number, default: null },
424
+ dismissible: { type: Boolean, default: !0 },
425
+ /** HTML / SVG of the remove icon (sanitised by Bootstrap). */
426
+ dismissIcon: { type: String, default: null },
427
+ /** Turn the pending text into a chip when the input loses focus. */
428
+ createOnBlur: { type: Boolean, default: !0 },
429
+ /** (value: string) => boolean — return false to reject a chip. */
430
+ validator: { type: Function, default: null },
431
+ locale: { type: String, default: null }
432
+ },
433
+ setup(e, { emit: n, expose: a }) {
434
+ const l = U(e, n), { t: c } = Q(() => e.locale), i = E(null), t = E(null);
435
+ let u = !1, g = [];
436
+ const $ = (o) => Array.isArray(o) ? o.map(String) : typeof o == "string" && o !== "" ? e.separator ? o.split(e.separator).map((r) => r.trim()).filter(Boolean) : [o] : [];
437
+ function y() {
438
+ const o = w.value;
439
+ if (!o) return;
440
+ const r = $(l.model.value);
441
+ if (nn(o.getValues(), r)) return;
442
+ u = !0;
443
+ try {
444
+ o.clear(), r.forEach((f) => o.add(f));
445
+ } finally {
446
+ u = !1;
447
+ }
448
+ const s = o.getValues();
449
+ !nn(s, r) && Array.isArray(l.model.value) && (l.model.value = s);
450
+ }
451
+ const b = () => e.readonly || l.isDisabled.value, { instance: w, create: T } = he(
452
+ "Chips",
453
+ () => i.value,
454
+ () => {
455
+ const o = {
456
+ separator: e.separator,
457
+ allowDuplicates: e.allowDuplicates,
458
+ maxChips: e.maxChips,
459
+ dismissible: e.dismissible && !b(),
460
+ createOnBlur: e.createOnBlur,
461
+ placeholder: e.placeholder ?? c("chips.placeholder")
462
+ };
463
+ return e.dismissIcon && (o.dismissIcon = e.dismissIcon), o;
464
+ },
465
+ {
466
+ onCreate(o, r) {
467
+ const s = (f, S) => {
468
+ r.addEventListener(f, S), g.push(() => r.removeEventListener(f, S));
469
+ };
470
+ s("add.bs.chips", (f) => {
471
+ if (!u) {
472
+ if (e.validator && !e.validator(f.value)) {
473
+ f.preventDefault(), n("rejected", f.value);
474
+ return;
475
+ }
476
+ n("add", f.value);
477
+ }
478
+ }), s("remove.bs.chips", (f) => !u && n("remove", f.value)), s("select.bs.chips", (f) => n("select", f.selected)), s("change.bs.chips", (f) => {
479
+ u || (l.model.value = f.values, l.emitChange(f.values, f));
480
+ }), y();
481
+ },
482
+ onDestroy() {
483
+ g.forEach((o) => o()), g = [];
484
+ }
485
+ }
486
+ );
487
+ return H(() => l.model.value, y, { deep: !0 }), H(
488
+ () => [e.separator, e.allowDuplicates, e.maxChips, e.dismissible, e.createOnBlur, e.dismissIcon, e.readonly, l.isDisabled.value],
489
+ async () => {
490
+ await W(), T();
491
+ }
492
+ ), a({
493
+ add: (o) => {
494
+ var r;
495
+ return (r = w.value) == null ? void 0 : r.add(o);
496
+ },
497
+ remove: (o) => {
498
+ var r;
499
+ return (r = w.value) == null ? void 0 : r.remove(o);
500
+ },
501
+ clear: () => {
502
+ var o;
503
+ return (o = w.value) == null ? void 0 : o.clear();
504
+ },
505
+ focus: () => {
506
+ var o;
507
+ return (o = t.value) == null ? void 0 : o.focus();
508
+ }
509
+ }), { ...l, t: c, el: i, ghost: t, locked: b };
510
+ }
511
+ }), tt = ["aria-disabled"], lt = ["id", "placeholder", "disabled", "readonly", "aria-invalid"];
512
+ function at(e, n, a, l, c, i) {
513
+ return m(), h("div", {
514
+ ref: "el",
515
+ class: "chip-input",
516
+ "aria-disabled": e.isDisabled || void 0
517
+ }, [
518
+ p("input", {
519
+ ref: "ghost",
520
+ type: "text",
521
+ class: q(["form-ghost", { "is-invalid": e.isInvalid }]),
522
+ id: e.inputId,
523
+ placeholder: e.placeholder ?? e.t("chips.placeholder"),
524
+ disabled: e.isDisabled,
525
+ readonly: e.readonly,
526
+ "aria-invalid": e.isInvalid || void 0,
527
+ autocomplete: "off",
528
+ onFocus: n[0] || (n[0] = (t) => e.$emit("focus", t)),
529
+ onBlur: n[1] || (n[1] = (t) => e.$emit("blur", t))
530
+ }, null, 42, lt)
531
+ ], 8, tt);
532
+ }
533
+ const ot = /* @__PURE__ */ L(nt, [["render", at]]), me = (e) => e !== null && typeof e == "object", tn = (e) => e == null || e === "";
534
+ function rt() {
535
+ if (typeof document > "u") return null;
536
+ const e = document.cookie.match(/(?:^|;\s*)XSRF-TOKEN=([^;]+)/);
537
+ return e ? decodeURIComponent(e[1]) : null;
538
+ }
539
+ const st = F({
540
+ name: "ComboboxInput",
541
+ emits: [
542
+ "update:modelValue",
543
+ "change",
544
+ "selected",
545
+ "clear",
546
+ "search",
547
+ "search-success",
548
+ "search-error",
549
+ "show",
550
+ "shown",
551
+ "hide",
552
+ "hidden"
553
+ ],
554
+ props: {
555
+ ...z,
556
+ /** Strings, numbers or objects ({ id | value, name | label, description, disabled }). */
557
+ options: { type: Array, default: () => [] },
558
+ /** Property that holds the value of an option object (default: id → value → name → label). */
559
+ valueKey: { type: String, default: null },
560
+ /** Property that holds the label of an option object (default: name → label → title → value). */
561
+ labelKey: { type: String, default: null },
562
+ /** Legacy alias of `labelKey`. */
563
+ label: { type: String, default: null },
564
+ descriptionKey: { type: String, default: "description" },
565
+ multiple: { type: Boolean, default: !1 },
566
+ placeholder: { type: String, default: null },
567
+ /** Show a client-side search box. */
568
+ searchEnabled: { type: Boolean, default: !1 },
569
+ searchPlaceholder: { type: String, default: null },
570
+ /**
571
+ * Remote search: { url, method = 'POST', param = 'query', debounce = 400, minChars = 0, headers = {}, resultsKey }.
572
+ * The endpoint must answer with a JSON array (or { data: [] }).
573
+ */
574
+ search: { type: Object, default: () => ({ url: null }) },
575
+ /** Add an entry at the top of a single select that clears the value. */
576
+ clearable: { type: Boolean, default: !1 },
577
+ clearText: { type: String, default: null },
578
+ noResultsText: { type: String, default: null },
579
+ loadingText: { type: String, default: null },
580
+ /** Text of a multiple select when more than one item is chosen. `{count}` is replaced. */
581
+ selectedText: { type: String, default: null },
582
+ /**
583
+ * Multiple select only: show the chosen options themselves (true) instead of the
584
+ * "N selected" counter (false, default).
585
+ */
586
+ showSelected: { type: Boolean, default: !0 },
587
+ /** With `showSelected`: above this many chosen options the counter is shown instead. */
588
+ maxVisible: { type: Number, default: null },
589
+ /** Separator between the chosen labels (default: "، " for fa, ", " otherwise). */
590
+ selectedSeparator: { type: String, default: null },
591
+ searchNormalize: { type: Boolean, default: !1 },
592
+ /** Floating UI placement of the menu. */
593
+ placement: { type: String, default: "bottom-start" },
594
+ size: { type: String, default: null },
595
+ /** Hide the caret icon. */
596
+ hideDropdown: { type: Boolean, default: !1 },
597
+ locale: { type: String, default: null }
598
+ },
599
+ setup(e, { emit: n, expose: a, slots: l }) {
600
+ const c = U(e, n), { t: i, locale: t } = Q(() => e.locale), u = Le(), g = E(null), $ = E(null), y = E(null), b = E(null), w = E(null), T = E({}), o = ie({ results: null, loading: !1, error: !1 }), r = C(() => {
601
+ var v;
602
+ return ((v = e.search) == null ? void 0 : v.url) || null;
603
+ }), s = C(() => e.searchEnabled || !!r.value), f = (v) => me(v) ? e.valueKey ? v[e.valueKey] : v.id ?? v.value ?? v.name ?? v.label : v, S = (v) => {
604
+ if (!me(v)) return v;
605
+ const k = e.labelKey || e.label;
606
+ return (k ? v[k] : v.name ?? v.label ?? v.title ?? v.value) ?? f(v);
607
+ }, R = (v) => me(v) ? v[e.descriptionKey] ?? null : null, A = (v) => String(f(v));
608
+ function K(v) {
609
+ const k = { ...T.value };
610
+ (v || []).forEach((D) => {
611
+ k[A(D)] = D;
612
+ }), T.value = k;
613
+ }
614
+ H(() => e.options, (v) => K(v), { immediate: !0, deep: !0 });
615
+ const ee = C(() => {
616
+ const v = c.model.value;
617
+ return e.multiple ? Array.isArray(v) ? v : me(v) ? Object.values(v) : tn(v) ? [] : [v] : tn(v) ? [] : [v];
618
+ }), P = C(() => ee.value.map((v) => me(v) ? A(v) : String(v))), Se = (v) => {
619
+ const k = T.value[v];
620
+ return k !== void 0 ? String(S(k)) : v;
621
+ }, Ie = C(
622
+ () => P.value.map((v) => {
623
+ const k = T.value[v];
624
+ return {
625
+ key: v,
626
+ raw: k,
627
+ label: k !== void 0 ? String(S(k)) : v,
628
+ description: k !== void 0 ? R(k) : null
629
+ };
630
+ })
631
+ ), Ce = C(() => e.selectedSeparator ?? (t.value === "fa" ? "، " : ", ")), ve = C(
632
+ () => e.multiple && e.showSelected && P.value.length > 1 && (e.maxVisible === null || P.value.length <= e.maxVisible)
633
+ ), Te = C(
634
+ () => !!l.selection && P.value.length > 0 && (!e.multiple || P.value.length === 1 || ve.value)
635
+ ), Me = C(() => {
636
+ const v = P.value;
637
+ return v.length ? e.multiple && v.length > 1 ? ve.value ? Ie.value.map((k) => k.label).join(Ce.value) : (e.selectedText ?? i("select.selectedCount")).replace("{count}", v.length) : Se(v[0]) : e.placeholder ?? i("select.placeholder");
638
+ }), ge = C(() => Te.value ? "" : Me.value), Be = C(() => P.value.length === 0), ye = C(() => {
639
+ let v = o.results ?? e.options;
640
+ if (o.results && e.multiple) {
641
+ const k = new Set(v.map(A));
642
+ v = [...P.value.filter((d) => !k.has(d) && T.value[d] !== void 0).map((d) => T.value[d]), ...v];
643
+ }
644
+ return v.map((k) => ({
645
+ raw: k,
646
+ key: A(k),
647
+ label: S(k),
648
+ description: R(k),
649
+ disabled: me(k) && !!k.disabled
650
+ }));
651
+ });
652
+ function Z() {
653
+ if (!y.value) return;
654
+ const v = new Set(P.value);
655
+ y.value.querySelectorAll(".menu-item[data-bs-value]").forEach((k) => {
656
+ const D = v.has(k.dataset.bsValue) && k.dataset.bsValue !== "";
657
+ k.classList.toggle("selected", D), k.setAttribute("aria-selected", D ? "true" : "false");
658
+ });
659
+ }
660
+ function ue() {
661
+ b.value && (b.value.textContent = ge.value, b.value.classList.toggle("combobox-placeholder", Be.value));
662
+ }
663
+ function Pe() {
664
+ var v;
665
+ (v = $.value) == null || v.classList.toggle("is-invalid", c.isInvalid.value);
666
+ }
667
+ function ne() {
668
+ Z(), ue(), Pe();
669
+ }
670
+ H([() => c.model.value, ye, ge, c.isInvalid], () => W(ne), { flush: "post" });
671
+ function te(v) {
672
+ const k = T.value[v];
673
+ return k !== void 0 ? f(k) : v;
674
+ }
675
+ function be(v) {
676
+ let k, D;
677
+ if (e.multiple) {
678
+ const d = v.value || [];
679
+ k = d.map(te), D = d.map((O) => T.value[O]);
680
+ } else v.value === "" || v.value === void 0 ? (k = null, D = null) : (k = te(v.value), D = T.value[v.value]);
681
+ c.model.value = k, k === null && n("clear"), n("selected", D), c.emitChange(k, v), W(ne), ue();
682
+ }
683
+ let de = null, X = null;
684
+ u.add(() => {
685
+ clearTimeout(de), X == null || X.abort();
686
+ });
687
+ function ce() {
688
+ var v;
689
+ y.value && (y.value.querySelectorAll(".menu-item[data-bs-value]").forEach((k) => {
690
+ k.style.display = "";
691
+ }), (v = y.value.querySelector(".combobox-no-results")) == null || v.classList.toggle("d-none", ye.value.length > 0));
692
+ }
693
+ async function ze(v) {
694
+ const k = e.search || {};
695
+ if (k.url) {
696
+ X == null || X.abort(), X = new AbortController(), o.loading = !0, o.error = !1;
697
+ try {
698
+ const D = new URL(k.url, window.location.origin);
699
+ D.searchParams.set(k.param || "query", v);
700
+ const d = {
701
+ Accept: "application/json",
702
+ "X-Requested-With": "XMLHttpRequest",
703
+ ...k.headers || {}
704
+ }, O = rt();
705
+ O && !d["X-XSRF-TOKEN"] && (d["X-XSRF-TOKEN"] = O);
706
+ const I = await fetch(D, {
707
+ method: (k.method || "POST").toUpperCase(),
708
+ headers: d,
709
+ credentials: "same-origin",
710
+ signal: X.signal
711
+ });
712
+ if (!I.ok) throw new Error(`HTTP ${I.status}`);
713
+ const B = await I.json(), N = Array.isArray(B) ? B : (B == null ? void 0 : B[k.resultsKey || "data"]) ?? (B == null ? void 0 : B.results) ?? [];
714
+ K(N), o.results = N, o.loading = !1, n("search-success", N), await W(), ce(), ne();
715
+ } catch (D) {
716
+ if ((D == null ? void 0 : D.name) === "AbortError") return;
717
+ o.loading = !1, o.error = !0, o.results = [], n("search-error", D), await W(), ce();
718
+ }
719
+ }
720
+ }
721
+ function Ee(v) {
722
+ var d, O;
723
+ const k = v.target.value;
724
+ if (n("search", k), !r.value) return;
725
+ clearTimeout(de);
726
+ const D = ((d = e.search) == null ? void 0 : d.minChars) ?? 0;
727
+ if (k.length < D) {
728
+ X == null || X.abort(), o.results = null, o.loading = !1;
729
+ return;
730
+ }
731
+ o.loading = !0, de = setTimeout(() => ze(k), ((O = e.search) == null ? void 0 : O.debounce) ?? 400);
732
+ }
733
+ let x = [];
734
+ const { instance: fe, create: Ae } = he(
735
+ "Combobox",
736
+ () => $.value,
737
+ () => ({
738
+ multiple: e.multiple,
739
+ placeholder: e.placeholder ?? i("select.placeholder"),
740
+ placement: e.placement,
741
+ search: s.value,
742
+ searchNormalize: e.searchNormalize
743
+ }),
744
+ {
745
+ onCreate(v, k) {
746
+ const D = (d, O, I) => {
747
+ d.addEventListener(O, I), x.push(() => d.removeEventListener(O, I));
748
+ };
749
+ D(k, "change.bs.combobox", be), D(k, "show.bs.combobox", (d) => n("show", d)), D(k, "shown.bs.combobox", (d) => n("shown", d)), D(k, "hide.bs.combobox", (d) => n("hide", d)), D(k, "hidden.bs.combobox", (d) => {
750
+ o.results !== null && (o.results = null, o.error = !1, W(() => {
751
+ ce(), ne();
752
+ })), n("hidden", d);
753
+ }), w.value && (D(w.value, "input", Ee), D(w.value, "keydown", (d) => d.key === "Enter" && d.preventDefault())), ne();
754
+ },
755
+ onDestroy() {
756
+ x.forEach((v) => v()), x = [];
757
+ }
758
+ }
759
+ );
760
+ return H(
761
+ () => [e.multiple, s.value, e.placement, e.searchNormalize],
762
+ async () => {
763
+ await W(), Ae();
764
+ }
765
+ ), a({
766
+ show: () => {
767
+ var v;
768
+ return (v = fe.value) == null ? void 0 : v.show();
769
+ },
770
+ hide: () => {
771
+ var v;
772
+ return (v = fe.value) == null ? void 0 : v.hide();
773
+ },
774
+ toggle: () => {
775
+ var v;
776
+ return (v = fe.value) == null ? void 0 : v.toggle();
777
+ },
778
+ clear: () => {
779
+ c.model.value = e.multiple ? [] : null, n("clear"), c.emitChange(c.model.value);
780
+ },
781
+ focus: () => {
782
+ var v;
783
+ return (v = $.value) == null ? void 0 : v.focus();
784
+ }
785
+ }), {
786
+ ...c,
787
+ t: i,
788
+ root: g,
789
+ toggle: $,
790
+ menu: y,
791
+ valueEl: b,
792
+ searchInput: w,
793
+ remote: o,
794
+ hasSearch: s,
795
+ rendered: ye,
796
+ displayText: Me,
797
+ plainText: ge,
798
+ selectedItems: Ie,
799
+ customSelection: Te,
800
+ separator: Ce,
801
+ selectedSet: C(() => new Set(P.value)),
802
+ showingPlaceholder: Be,
803
+ sizeClass: C(() => e.size ? `form-control-${e.size}` : null)
804
+ };
805
+ }
806
+ }), it = {
807
+ ref: "root",
808
+ class: "combobox"
809
+ }, ut = ["id", "disabled", "aria-invalid", "aria-required"], dt = {
810
+ key: 0,
811
+ class: "combobox-selection d-flex align-items-center flex-wrap gap-2 text-start"
812
+ }, ct = ["textContent"], ft = {
813
+ key: 1,
814
+ class: "combobox-caret",
815
+ width: "16",
816
+ height: "16",
817
+ viewBox: "0 0 16 16",
818
+ fill: "none",
819
+ stroke: "currentColor",
820
+ "stroke-width": "1.5",
821
+ "stroke-linecap": "round",
822
+ "stroke-linejoin": "round",
823
+ "aria-hidden": "true"
824
+ }, mt = ["aria-multiselectable"], pt = {
825
+ key: 0,
826
+ class: "combobox-search"
827
+ }, ht = ["placeholder"], vt = {
828
+ key: 1,
829
+ class: "menu-header",
830
+ role: "status"
831
+ }, gt = {
832
+ key: 2,
833
+ class: "menu-header",
834
+ role: "alert"
835
+ }, yt = {
836
+ key: 3,
837
+ type: "button",
838
+ class: "menu-item",
839
+ "data-bs-value": "",
840
+ role: "option"
841
+ }, bt = { class: "menu-item-content" }, $t = ["data-bs-value", "disabled"], wt = { class: "menu-item-content" }, kt = {
842
+ key: 0,
843
+ class: "menu-item-description"
844
+ }, St = { class: "combobox-no-results d-none" };
845
+ function It(e, n, a, l, c, i) {
846
+ return m(), h("div", it, [
847
+ p("button", {
848
+ ref: "toggle",
849
+ type: "button",
850
+ class: q(["combobox-toggle form-control", e.sizeClass]),
851
+ "data-bs-toggle": "combobox",
852
+ id: e.inputId,
853
+ disabled: e.isDisabled || e.readonly,
854
+ "aria-haspopup": "listbox",
855
+ "aria-invalid": e.isInvalid || void 0,
856
+ "aria-required": e.required || void 0
857
+ }, [
858
+ e.customSelection ? (m(), h("span", dt, [
859
+ (m(!0), h(G, null, ae(e.selectedItems, (t, u) => j(e.$slots, "selection", {
860
+ key: t.key,
861
+ option: t.raw,
862
+ label: t.label,
863
+ description: t.description,
864
+ value: t.key,
865
+ index: u,
866
+ multiple: e.multiple
867
+ }, () => [
868
+ _(V(t.label), 1)
869
+ ])), 128))
870
+ ])) : M("", !0),
871
+ p("span", {
872
+ ref: "valueEl",
873
+ class: q(["combobox-value", { "combobox-placeholder": e.showingPlaceholder }]),
874
+ textContent: V(e.plainText)
875
+ }, null, 10, ct),
876
+ e.hideDropdown ? M("", !0) : (m(), h("svg", ft, n[0] || (n[0] = [
877
+ p("path", { d: "m3 6 5 5 5-5" }, null, -1)
878
+ ])))
879
+ ], 10, ut),
880
+ p("div", {
881
+ ref: "menu",
882
+ class: "menu",
883
+ role: "listbox",
884
+ "aria-multiselectable": e.multiple || void 0
885
+ }, [
886
+ e.hasSearch ? (m(), h("div", pt, [
887
+ p("input", {
888
+ ref: "searchInput",
889
+ type: "search",
890
+ class: "form-control combobox-search-input",
891
+ autocomplete: "off",
892
+ placeholder: e.searchPlaceholder ?? e.t("select.search")
893
+ }, null, 8, ht)
894
+ ])) : M("", !0),
895
+ e.remote.loading ? (m(), h("div", vt, V(e.loadingText ?? e.t("select.loading")), 1)) : e.remote.error ? (m(), h("div", gt, V(e.t("select.error")), 1)) : M("", !0),
896
+ e.clearable && !e.multiple ? (m(), h("button", yt, [
897
+ p("span", bt, [
898
+ p("span", null, V(e.clearText ?? e.t("select.clear")), 1)
899
+ ])
900
+ ])) : M("", !0),
901
+ (m(!0), h(G, null, ae(e.rendered, (t) => (m(), h("button", {
902
+ key: t.key,
903
+ type: "button",
904
+ class: "menu-item",
905
+ role: "option",
906
+ "data-bs-value": t.key,
907
+ disabled: t.disabled || void 0
908
+ }, [
909
+ p("span", wt, [
910
+ j(e.$slots, "option", {
911
+ option: t.raw,
912
+ label: t.label,
913
+ description: t.description,
914
+ value: t.key,
915
+ selected: e.selectedSet.has(t.key),
916
+ disabled: t.disabled
917
+ }, () => [
918
+ p("span", null, V(t.label), 1),
919
+ t.description ? (m(), h("span", kt, V(t.description), 1)) : M("", !0)
920
+ ])
921
+ ]),
922
+ n[1] || (n[1] = p("svg", {
923
+ class: "menu-item-check",
924
+ width: "16",
925
+ height: "16",
926
+ viewBox: "0 0 16 16",
927
+ fill: "none",
928
+ stroke: "currentColor",
929
+ "stroke-width": "2",
930
+ "stroke-linecap": "round",
931
+ "stroke-linejoin": "round",
932
+ "aria-hidden": "true"
933
+ }, [
934
+ p("path", { d: "m3.5 8.5 3 3 6-7" })
935
+ ], -1))
936
+ ], 8, $t))), 128)),
937
+ p("div", St, V(e.noResultsText ?? e.t("select.noResults")), 1)
938
+ ], 8, mt)
939
+ ], 512);
940
+ }
941
+ const cn = /* @__PURE__ */ L(st, [["render", It]]), Ct = F({
942
+ name: "TextInput",
943
+ emits: ["update:modelValue", "change", "input", "focus", "blur"],
944
+ props: {
945
+ ...z,
946
+ type: { type: String, default: "text" },
947
+ placeholder: { type: String, default: null },
948
+ /** sm | lg */
949
+ size: { type: String, default: null }
950
+ },
951
+ setup(e, { emit: n }) {
952
+ const a = U(e, n), l = C(() => e.size ? `form-control-${e.size}` : null);
953
+ return { ...a, sizeClass: l, emit: n };
954
+ }
955
+ }), Tt = ["name", "id", "type", "placeholder", "required", "readonly", "disabled", "aria-invalid"];
956
+ function Mt(e, n, a, l, c, i) {
957
+ return re((m(), h("input", {
958
+ "onUpdate:modelValue": n[0] || (n[0] = (t) => e.model = t),
959
+ name: e.name,
960
+ id: e.inputId,
961
+ type: e.type,
962
+ placeholder: e.placeholder,
963
+ required: e.required,
964
+ readonly: e.readonly,
965
+ disabled: e.isDisabled,
966
+ "aria-invalid": e.isInvalid || void 0,
967
+ class: q(["form-control", [e.sizeClass, { "is-invalid": e.isInvalid }]]),
968
+ onInput: n[1] || (n[1] = (t) => e.emit("input", e.model, t)),
969
+ onChange: n[2] || (n[2] = (t) => e.emitChange(e.model, t)),
970
+ onFocus: n[3] || (n[3] = (t) => e.$emit("focus", t)),
971
+ onBlur: n[4] || (n[4] = (t) => e.$emit("blur", t))
972
+ }, null, 42, Tt)), [
973
+ [ke, e.model]
974
+ ]);
975
+ }
976
+ const je = /* @__PURE__ */ L(Ct, [["render", Mt]]), Bt = F({
977
+ name: "EmailInput",
978
+ components: { TextInput: je },
979
+ props: {
980
+ name: { type: String, default: "email" },
981
+ placeholder: { type: String, default: null },
982
+ locale: { type: String, default: null }
983
+ },
984
+ setup(e) {
985
+ const { t: n } = Q(() => e.locale);
986
+ return { t: n };
987
+ }
988
+ });
989
+ function Et(e, n, a, l, c, i) {
990
+ const t = oe("TextInput");
991
+ return m(), le(t, {
992
+ type: "email",
993
+ autocomplete: "email",
994
+ name: e.name,
995
+ placeholder: e.placeholder ?? e.t("email.placeholder")
996
+ }, null, 8, ["name", "placeholder"]);
997
+ }
998
+ const At = /* @__PURE__ */ L(Bt, [["render", Et]]);
999
+ let Ot = 0;
1000
+ const Vt = F({
1001
+ name: "FileInput",
1002
+ emits: ["update:modelValue", "change", "added", "progress", "uploaded", "error", "removed"],
1003
+ props: {
1004
+ ...z,
1005
+ multiple: { type: Boolean, default: !1 },
1006
+ endpoint: { type: String, default: "/upload" },
1007
+ accept: { type: String, default: null },
1008
+ headers: { type: Object, default: () => ({}) },
1009
+ /** Name of the multipart field. */
1010
+ fieldName: { type: String, default: "file" },
1011
+ locale: { type: String, default: null }
1012
+ },
1013
+ setup(e, { emit: n, expose: a }) {
1014
+ const l = U(e, n), { t: c } = Q(() => e.locale), i = Le(), t = E(null), u = E([]), g = /* @__PURE__ */ new Map();
1015
+ i.add(() => {
1016
+ g.forEach((s) => s.abort()), g.clear(), l.form.value && (l.form.value.uploading = null);
1017
+ });
1018
+ const $ = () => u.value.filter((s) => s.path).map((s) => s.path);
1019
+ function y(s) {
1020
+ const f = e.multiple ? $() : $()[0] ?? null;
1021
+ l.model.value = f, l.emitChange(f, s);
1022
+ }
1023
+ function b() {
1024
+ const s = l.form.value;
1025
+ if (!s) return;
1026
+ const f = u.value.filter((S) => S.uploading);
1027
+ s.uploading = f.length ? Math.min(99, Math.round(f.reduce((S, R) => S + R.percent, 0) / f.length)) : null;
1028
+ }
1029
+ function w(s) {
1030
+ s.error = "", s.percent = 0, s.uploading = !0, b();
1031
+ const f = new FormData();
1032
+ f.append(e.fieldName, s.file);
1033
+ const S = new XMLHttpRequest();
1034
+ g.set(s.id, S), S.open("POST", e.endpoint), Object.entries(De(e.headers)).forEach(([A, K]) => S.setRequestHeader(A, K)), S.upload.onprogress = (A) => {
1035
+ A.lengthComputable && (s.percent = Math.round(A.loaded / A.total * 100), n("progress", s, s.percent), b());
1036
+ };
1037
+ const R = (A) => {
1038
+ s.uploading = !1, s.error = A || c("upload.failed"), g.delete(s.id), b(), n("error", s, s.error);
1039
+ };
1040
+ S.onerror = () => R(), S.onload = () => {
1041
+ var ee;
1042
+ let A = null;
1043
+ try {
1044
+ A = JSON.parse(S.responseText);
1045
+ } catch {
1046
+ }
1047
+ if (S.status < 200 || S.status >= 300) {
1048
+ const P = A != null && A.errors ? Object.values(A.errors)[0] : null;
1049
+ return R((A == null ? void 0 : A.message) || (Array.isArray(P) ? P[0] : P));
1050
+ }
1051
+ const K = ((ee = A == null ? void 0 : A.data) == null ? void 0 : ee.path) ?? (A == null ? void 0 : A.path);
1052
+ if (!K) return R();
1053
+ s.path = K, s.percent = 100, s.uploading = !1, g.delete(s.id), b(), y(), n("uploaded", s);
1054
+ }, S.send(f);
1055
+ }
1056
+ function T(s) {
1057
+ const f = ie({ id: `f${++Ot}`, file: s, percent: 0, error: "", path: null, uploading: !1 });
1058
+ u.value = e.multiple ? [...u.value, f] : [f], n("added", f), w(f);
1059
+ }
1060
+ function o(s) {
1061
+ Array.from(s.target.files).forEach(T), s.target.value = "";
1062
+ }
1063
+ async function r(s) {
1064
+ var f;
1065
+ if ((f = g.get(s.id)) == null || f.abort(), g.delete(s.id), u.value = u.value.filter((S) => S.id !== s.id), b(), s.path) {
1066
+ y();
1067
+ try {
1068
+ await fetch(e.endpoint, {
1069
+ method: "DELETE",
1070
+ headers: De(e.headers),
1071
+ credentials: "same-origin",
1072
+ body: s.path
1073
+ });
1074
+ } catch {
1075
+ }
1076
+ }
1077
+ n("removed", s);
1078
+ }
1079
+ return H(
1080
+ () => l.model.value,
1081
+ (s) => {
1082
+ (s == null || s === "" || Array.isArray(s) && !s.length) && u.value.some((S) => S.path) && (u.value = u.value.filter((S) => !S.path));
1083
+ }
1084
+ ), a({ clear: () => u.value.slice().forEach(r) }), { ...l, t: c, input: t, files: u, onSelect: o, remove: r, retry: w, size: (s) => `${Math.round(s / 1024)}KB` };
1085
+ }
1086
+ }), Nt = { class: "file-input-uploader" }, Dt = ["name", "id", "multiple", "accept", "required", "disabled", "aria-invalid"], qt = {
1087
+ key: 0,
1088
+ class: "list-group mt-2"
1089
+ }, Ft = { class: "d-flex align-items-center justify-content-between gap-2" }, Lt = { class: "text-truncate" }, Rt = { class: "d-flex align-items-center gap-2" }, jt = {
1090
+ class: "fg-secondary fanum",
1091
+ dir: "ltr"
1092
+ }, Pt = ["aria-label", "onClick"], zt = ["aria-label", "onClick"], Ut = ["aria-valuenow"], Ht = {
1093
+ key: 1,
1094
+ class: "fg-danger mt-1",
1095
+ role: "alert"
1096
+ };
1097
+ function Kt(e, n, a, l, c, i) {
1098
+ return m(), h("div", Nt, [
1099
+ p("input", {
1100
+ ref: "input",
1101
+ type: "file",
1102
+ class: q(["form-control", { "is-invalid": e.isInvalid }]),
1103
+ name: e.name,
1104
+ id: e.inputId,
1105
+ multiple: e.multiple,
1106
+ accept: e.accept || void 0,
1107
+ required: e.required && !e.files.length,
1108
+ disabled: e.isDisabled || e.readonly,
1109
+ "aria-invalid": e.isInvalid || void 0,
1110
+ onChange: n[0] || (n[0] = (...t) => e.onSelect && e.onSelect(...t))
1111
+ }, null, 42, Dt),
1112
+ e.files.length ? (m(), h("ul", qt, [
1113
+ (m(!0), h(G, null, ae(e.files, (t) => (m(), h("li", {
1114
+ key: t.id,
1115
+ class: "list-group-item"
1116
+ }, [
1117
+ p("div", Ft, [
1118
+ p("span", Lt, V(t.file.name), 1),
1119
+ p("span", Rt, [
1120
+ p("span", jt, V(e.size(t.file.size)), 1),
1121
+ t.error ? (m(), h("button", {
1122
+ key: 0,
1123
+ type: "button",
1124
+ class: "btn-text theme-secondary btn-icon",
1125
+ "aria-label": e.t("file.retry"),
1126
+ onClick: (u) => e.retry(t)
1127
+ }, n[1] || (n[1] = [
1128
+ p("svg", {
1129
+ width: "16",
1130
+ height: "16",
1131
+ viewBox: "0 0 16 16",
1132
+ fill: "none",
1133
+ stroke: "currentColor",
1134
+ "stroke-width": "1.5",
1135
+ "stroke-linecap": "round",
1136
+ "stroke-linejoin": "round",
1137
+ "aria-hidden": "true"
1138
+ }, [
1139
+ p("path", { d: "M13.5 3v3.5H10" }),
1140
+ p("path", { d: "M3.2 6.5A5.5 5.5 0 0 1 13 6.5M12.8 9.5A5.5 5.5 0 0 1 3 9.5M2.5 13V9.5H6" })
1141
+ ], -1)
1142
+ ]), 8, Pt)) : M("", !0),
1143
+ t.path || t.error ? (m(), h("button", {
1144
+ key: 1,
1145
+ type: "button",
1146
+ class: "btn-text theme-danger btn-icon",
1147
+ "aria-label": e.t("file.remove"),
1148
+ onClick: (u) => e.remove(t)
1149
+ }, n[2] || (n[2] = [
1150
+ p("svg", {
1151
+ width: "16",
1152
+ height: "16",
1153
+ viewBox: "0 0 16 16",
1154
+ fill: "none",
1155
+ stroke: "currentColor",
1156
+ "stroke-width": "1.5",
1157
+ "stroke-linecap": "round",
1158
+ "aria-hidden": "true"
1159
+ }, [
1160
+ p("path", { d: "m4 4 8 8M12 4l-8 8" })
1161
+ ], -1)
1162
+ ]), 8, zt)) : M("", !0)
1163
+ ])
1164
+ ]),
1165
+ t.uploading ? (m(), h("div", {
1166
+ key: 0,
1167
+ class: "progress mt-2",
1168
+ role: "progressbar",
1169
+ "aria-valuenow": t.percent,
1170
+ "aria-valuemin": "0",
1171
+ "aria-valuemax": "100"
1172
+ }, [
1173
+ p("div", {
1174
+ class: "progress-bar",
1175
+ style: se({ width: t.percent + "%" })
1176
+ }, null, 4)
1177
+ ], 8, Ut)) : M("", !0),
1178
+ t.error ? (m(), h("div", Ht, V(t.error), 1)) : M("", !0)
1179
+ ]))), 128))
1180
+ ])) : M("", !0)
1181
+ ]);
1182
+ }
1183
+ const fn = /* @__PURE__ */ L(Vt, [["render", Kt]]), Xt = F({
1184
+ name: "FormAdornInput",
1185
+ inheritAttrs: !1,
1186
+ emits: ["update:modelValue", "change", "input", "focus", "blur"],
1187
+ props: {
1188
+ ...z,
1189
+ type: { type: String, default: "text" },
1190
+ placeholder: { type: String, default: null },
1191
+ /** Text shown before the input. */
1192
+ startText: { type: String, default: null },
1193
+ /** Text shown after the input. */
1194
+ endText: { type: String, default: null },
1195
+ size: { type: String, default: null }
1196
+ },
1197
+ setup(e, { emit: n }) {
1198
+ const a = U(e, n), l = E(null), c = C(() => e.size ? `form-control-${e.size}` : null);
1199
+ function i(t) {
1200
+ var u, g, $;
1201
+ (t.target === t.currentTarget || (g = (u = t.target).closest) != null && g.call(u, ".form-adorn-icon, .form-adorn-text")) && (($ = l.value) == null || $.focus());
1202
+ }
1203
+ return { ...a, input: l, sizeClass: c, focusInput: i, emit: n, focus: () => {
1204
+ var t;
1205
+ return (t = l.value) == null ? void 0 : t.focus();
1206
+ } };
1207
+ },
1208
+ expose: ["focus"]
1209
+ }), Gt = {
1210
+ key: 0,
1211
+ class: "form-adorn-text"
1212
+ }, Wt = ["name", "id", "type", "placeholder", "required", "readonly", "disabled", "aria-invalid"], Qt = {
1213
+ key: 0,
1214
+ class: "form-adorn-text"
1215
+ };
1216
+ function Jt(e, n, a, l, c, i) {
1217
+ return m(), h("div", {
1218
+ class: q(["form-control form-adorn", [e.sizeClass, { "is-invalid": e.isInvalid }, e.$attrs.class]]),
1219
+ style: se(e.$attrs.style),
1220
+ onClick: n[5] || (n[5] = (...t) => e.focusInput && e.focusInput(...t))
1221
+ }, [
1222
+ j(e.$slots, "start", {}, () => [
1223
+ e.startText ? (m(), h("span", Gt, V(e.startText), 1)) : M("", !0)
1224
+ ]),
1225
+ re(p("input", Ke({
1226
+ ref: "input",
1227
+ "onUpdate:modelValue": n[0] || (n[0] = (t) => e.model = t)
1228
+ }, { ...e.$attrs, class: void 0, style: void 0 }, {
1229
+ name: e.name,
1230
+ id: e.inputId,
1231
+ type: e.type,
1232
+ placeholder: e.placeholder,
1233
+ required: e.required,
1234
+ readonly: e.readonly,
1235
+ disabled: e.isDisabled,
1236
+ "aria-invalid": e.isInvalid || void 0,
1237
+ class: ["form-ghost", { "is-invalid": e.isInvalid }],
1238
+ onInput: n[1] || (n[1] = (t) => e.emit("input", e.model, t)),
1239
+ onChange: n[2] || (n[2] = (t) => e.emitChange(e.model, t)),
1240
+ onFocus: n[3] || (n[3] = (t) => e.$emit("focus", t)),
1241
+ onBlur: n[4] || (n[4] = (t) => e.$emit("blur", t))
1242
+ }), null, 16, Wt), [
1243
+ [ke, e.model]
1244
+ ]),
1245
+ j(e.$slots, "end", {}, () => [
1246
+ e.endText ? (m(), h("span", Qt, V(e.endText), 1)) : M("", !0)
1247
+ ])
1248
+ ], 6);
1249
+ }
1250
+ const Ze = /* @__PURE__ */ L(Xt, [["render", Jt]]), Zt = (e) => e !== null && typeof e == "object" && (Object.getPrototypeOf(e) === Object.prototype || Object.getPrototypeOf(e) === null);
1251
+ function Ge(e) {
1252
+ return typeof e == "string" ? Je(e) : Array.isArray(e) ? e.map(Ge) : Zt(e) ? Object.keys(e).reduce((n, a) => (n[a] = Ge(e[a]), n), {}) : e;
1253
+ }
1254
+ function ln(e, n) {
1255
+ try {
1256
+ return JSON.stringify(e) === JSON.stringify(n);
1257
+ } catch {
1258
+ return !1;
1259
+ }
1260
+ }
1261
+ const Yt = F({
1262
+ name: "FormContainer",
1263
+ emits: [
1264
+ "update:modelValue",
1265
+ "change",
1266
+ "submit",
1267
+ "reset",
1268
+ "before",
1269
+ "start",
1270
+ "progress",
1271
+ "success",
1272
+ "error",
1273
+ "cancel",
1274
+ "finish",
1275
+ // Legacy (v2) event names
1276
+ "onStart",
1277
+ "onFinish",
1278
+ "onSuccess",
1279
+ "onError"
1280
+ ],
1281
+ props: {
1282
+ /** The object that holds the value of every field (v-model). */
1283
+ modelValue: { type: Object, default: () => ({}) },
1284
+ url: { type: String, default: "" },
1285
+ method: { type: String, default: "post" },
1286
+ /** Only reload these props after a successful visit (Inertia `only`). */
1287
+ only: { type: Array, default: () => [] },
1288
+ /** Extra form fields that are not part of `modelValue`. */
1289
+ options: { type: Object, default: () => ({}) },
1290
+ /** Extra Inertia visit options (preserveScroll, preserveState, headers, …). */
1291
+ visitOptions: { type: Object, default: () => ({}) },
1292
+ autoTab: { type: Boolean, default: !0 },
1293
+ resetOnSuccess: { type: Boolean, default: !1 },
1294
+ /** Replace the default submit behaviour. Receives (event, form). */
1295
+ submitHandler: { type: Function, default: null },
1296
+ /** Convert Persian/Arabic digits to English digits before submitting. */
1297
+ normalizeDigits: { type: Boolean, default: !0 },
1298
+ /** Enable Bootstrap 6 client-side validation (`data-bs-validate`). */
1299
+ validate: { type: Boolean, default: !1 },
1300
+ /** Render server messages as HTML (only enable for trusted messages). */
1301
+ htmlMessages: { type: Boolean, default: !1 },
1302
+ /** Hide the built-in error / success alerts. */
1303
+ hideAlerts: { type: Boolean, default: !1 }
1304
+ },
1305
+ setup(e, { emit: n, expose: a }) {
1306
+ const l = E(null), c = ie({ hasMessage: !1, successMessage: null }), i = Sn({
1307
+ ...e.options,
1308
+ ...e.modelValue
1309
+ });
1310
+ i.uploading = null, i.getID = function(o = {}) {
1311
+ var s;
1312
+ const r = [];
1313
+ return (s = l.value) != null && s.id && r.push(l.value.id), typeof o == "string" && r.push(o), o.group && (o.group.name && r.push(o.group.name), o.group.index !== void 0 && o.group.index !== null && r.push(o.group.index)), o.name && r.push(o.name), o.value !== void 0 && o.value !== null && o.value !== "" && r.push(o.value), r.join("-");
1314
+ };
1315
+ const t = new Set(Object.keys(i)), u = () => Object.keys(i).filter((o) => !t.has(o) && typeof i[o] != "function" && i[o] !== void 0), g = () => {
1316
+ const o = typeof i.data == "function" ? { ...i.data() } : Object.keys(i).reduce((r, s) => (t.has(s) && typeof i[s] != "function" && (r[s] = i[s]), r), {});
1317
+ return u().forEach((r) => {
1318
+ o[r] = i[r];
1319
+ }), o;
1320
+ }, $ = () => {
1321
+ u().forEach((o) => delete i[o]), i.reset();
1322
+ };
1323
+ H(
1324
+ () => g(),
1325
+ (o) => {
1326
+ n("change", o), n("update:modelValue", o);
1327
+ },
1328
+ { deep: !0 }
1329
+ ), H(
1330
+ () => e.modelValue,
1331
+ (o) => {
1332
+ !o || ln(o, g()) || Object.keys(o).forEach((r) => {
1333
+ ln(i[r], o[r]) || (i[r] = o[r]);
1334
+ });
1335
+ },
1336
+ { deep: !0 }
1337
+ );
1338
+ function y(o) {
1339
+ const r = Array.from(l.value.querySelectorAll("input, select, textarea")).filter(
1340
+ (f) => !f.disabled && f.tabIndex !== -1 && f.type !== "hidden" && f.offsetParent !== null
1341
+ ), s = r[r.indexOf(o) + 1];
1342
+ s && (s.focus(), s.tagName !== "SELECT" && typeof s.select == "function" && s.select());
1343
+ }
1344
+ function b(o) {
1345
+ const r = o.target;
1346
+ if (!["INPUT", "TEXTAREA"].includes(r.tagName)) return;
1347
+ e.autoTab && r.maxLength > 0 && r.value.length >= r.maxLength && y(r);
1348
+ const s = parseInt(r.dataset.autoSubmitLength, 10);
1349
+ !isNaN(s) && r.value.length >= s && T();
1350
+ }
1351
+ function w() {
1352
+ $(), i.clearErrors(), c.hasMessage = !1, c.successMessage = null, n("reset");
1353
+ }
1354
+ async function T(o) {
1355
+ if (e.submitHandler)
1356
+ return e.submitHandler(o, i);
1357
+ n("submit", o), i.transform((r) => {
1358
+ const s = { ...e.modelValue, ...r, ...g() };
1359
+ return e.normalizeDigits ? Ge(s) : s;
1360
+ }).submit((e.method || "post").toString().toLowerCase(), e.url, {
1361
+ only: e.only,
1362
+ ...e.visitOptions,
1363
+ onBefore: (r) => {
1364
+ var s, f;
1365
+ return n("before", r), (f = (s = e.visitOptions).onBefore) == null ? void 0 : f.call(s, r);
1366
+ },
1367
+ onStart: (r) => {
1368
+ var s, f;
1369
+ c.hasMessage = !1, c.successMessage = null, i.clearErrors(), n("start", r), n("onStart", r), (f = (s = e.visitOptions).onStart) == null || f.call(s, r);
1370
+ },
1371
+ onProgress: (r) => {
1372
+ var s, f;
1373
+ n("progress", r), (f = (s = e.visitOptions).onProgress) == null || f.call(s, r);
1374
+ },
1375
+ onCancel: () => {
1376
+ var r, s;
1377
+ n("cancel"), (s = (r = e.visitOptions).onCancel) == null || s.call(r);
1378
+ },
1379
+ onFinish: (r) => {
1380
+ var s, f;
1381
+ n("finish", r), n("onFinish", r), (f = (s = e.visitOptions).onFinish) == null || f.call(s, r);
1382
+ },
1383
+ onError: (r) => {
1384
+ var s, f;
1385
+ n("error", r), n("onError", r), (f = (s = e.visitOptions).onError) == null || f.call(s, r);
1386
+ },
1387
+ onSuccess: (r) => {
1388
+ var s, f, S;
1389
+ e.resetOnSuccess && $(), (s = r == null ? void 0 : r.props) != null && s.message && (c.hasMessage = !0, c.successMessage = r.props.message), n("success", r), n("onSuccess", r), (S = (f = e.visitOptions).onSuccess) == null || S.call(f, r);
1390
+ }
1391
+ });
1392
+ }
1393
+ return Ve("form", C(() => i)), Ve("formApi", { submit: T, reset: w, el: l }), a({ submit: T, reset: w, form: i, el: l }), { form: i, formEl: l, ui: c, handleInput: b, reset: w, submit: T };
1394
+ }
1395
+ }), xt = ["action", "method", "data-bs-validate", "novalidate"], _t = {
1396
+ key: 0,
1397
+ class: "alert theme-danger",
1398
+ role: "alert"
1399
+ }, el = { class: "list-unstyled p-0 m-0 fanum" }, nl = ["innerHTML"], tl = {
1400
+ key: 0,
1401
+ class: "alert theme-success",
1402
+ role: "status"
1403
+ }, ll = ["innerHTML"], al = { key: 1 };
1404
+ function ol(e, n, a, l, c, i) {
1405
+ return m(), h("form", {
1406
+ ref: "formEl",
1407
+ action: e.url || void 0,
1408
+ method: e.method,
1409
+ "data-bs-validate": e.validate ? "" : void 0,
1410
+ novalidate: !e.validate || e.form.hasErrors ? !0 : void 0,
1411
+ class: q({ "form-processing": e.form.processing }),
1412
+ onInput: n[0] || (n[0] = (...t) => e.handleInput && e.handleInput(...t)),
1413
+ onSubmit: n[1] || (n[1] = _e((...t) => e.submit && e.submit(...t), ["prevent"])),
1414
+ onReset: n[2] || (n[2] = _e((...t) => e.reset && e.reset(...t), ["prevent"]))
1415
+ }, [
1416
+ e.hideAlerts ? M("", !0) : (m(), h(G, { key: 0 }, [
1417
+ j(e.$slots, "errors", {
1418
+ errors: e.form.errors,
1419
+ form: e.form
1420
+ }, () => [
1421
+ e.form.hasErrors ? (m(), h("div", _t, [
1422
+ p("ul", el, [
1423
+ (m(!0), h(G, null, ae(e.form.errors, (t, u) => (m(), h("li", { key: u }, [
1424
+ e.htmlMessages ? (m(), h("span", {
1425
+ key: 0,
1426
+ innerHTML: t
1427
+ }, null, 8, nl)) : (m(), h(G, { key: 1 }, [
1428
+ _(V(t), 1)
1429
+ ], 64))
1430
+ ]))), 128))
1431
+ ])
1432
+ ])) : M("", !0)
1433
+ ]),
1434
+ j(e.$slots, "message", {
1435
+ message: e.ui.successMessage
1436
+ }, () => [
1437
+ e.ui.hasMessage && e.ui.successMessage ? (m(), h("div", tl, [
1438
+ e.htmlMessages ? (m(), h("span", {
1439
+ key: 0,
1440
+ innerHTML: e.ui.successMessage
1441
+ }, null, 8, ll)) : (m(), h("span", al, V(e.ui.successMessage), 1))
1442
+ ])) : M("", !0)
1443
+ ])
1444
+ ], 64)),
1445
+ j(e.$slots, "default", {
1446
+ form: e.form,
1447
+ submit: e.submit,
1448
+ reset: e.reset
1449
+ })
1450
+ ], 42, xt);
1451
+ }
1452
+ const rl = /* @__PURE__ */ L(Yt, [["render", ol]]), sl = F({
1453
+ name: "FormLabel",
1454
+ props: {
1455
+ /** id of the control. Detected automatically inside <FormField> or from the next element. */
1456
+ for: { type: String, default: null },
1457
+ required: { type: Boolean, default: !1 }
1458
+ },
1459
+ setup(e) {
1460
+ const n = pe("formField", null), a = E(null), l = E(null);
1461
+ J(() => {
1462
+ var t, u;
1463
+ if (e.for || n != null && n.id) return;
1464
+ const i = (t = a.value) == null ? void 0 : t.nextElementSibling;
1465
+ i && (l.value = i.id || ((u = i.querySelector("[id]")) == null ? void 0 : u.id) || null);
1466
+ });
1467
+ const c = C(() => e.for || (n == null ? void 0 : n.id) || l.value || void 0);
1468
+ return { el: a, target: c };
1469
+ }
1470
+ }), il = ["for"], ul = {
1471
+ key: 0,
1472
+ class: "fg-danger",
1473
+ "aria-hidden": "true"
1474
+ };
1475
+ function dl(e, n, a, l, c, i) {
1476
+ return m(), h("label", {
1477
+ ref: "el",
1478
+ class: "form-label",
1479
+ for: e.target
1480
+ }, [
1481
+ j(e.$slots, "default"),
1482
+ e.required ? (m(), h("span", ul, " *")) : M("", !0)
1483
+ ], 8, il);
1484
+ }
1485
+ const mn = /* @__PURE__ */ L(sl, [["render", dl]]);
1486
+ let cl = 0;
1487
+ const fl = F({
1488
+ name: "FormField",
1489
+ components: { FormLabel: mn },
1490
+ props: {
1491
+ /** Field key. Used to read the server-side error of the field. */
1492
+ name: { type: String, default: null },
1493
+ label: { type: String, default: null },
1494
+ help: { type: String, default: null },
1495
+ /** Override the error text (otherwise it is read from the form errors). */
1496
+ error: { type: String, default: null },
1497
+ required: { type: Boolean, default: !1 },
1498
+ id: { type: String, default: null }
1499
+ },
1500
+ setup(e) {
1501
+ const n = pe("form", null), a = xe.useId ? xe.useId() : `ff-${++cl}`, l = C(() => e.id || (e.name ? `${e.name}-${a}` : a));
1502
+ Ve("formField", {
1503
+ get id() {
1504
+ return l.value;
1505
+ },
1506
+ get name() {
1507
+ return e.name;
1508
+ }
1509
+ });
1510
+ const c = C(() => {
1511
+ var i, t;
1512
+ return e.error ?? (e.name ? (t = (i = n == null ? void 0 : n.value) == null ? void 0 : i.errors) == null ? void 0 : t[e.name] : null) ?? null;
1513
+ });
1514
+ return { fieldId: l, errorText: c };
1515
+ }
1516
+ }), ml = { class: "form-field" }, pl = ["id"], hl = ["id"];
1517
+ function vl(e, n, a, l, c, i) {
1518
+ const t = oe("FormLabel");
1519
+ return m(), h("div", ml, [
1520
+ j(e.$slots, "label", {}, () => [
1521
+ e.label ? (m(), le(t, {
1522
+ key: 0,
1523
+ for: e.fieldId,
1524
+ required: e.required
1525
+ }, {
1526
+ default: Qe(() => [
1527
+ _(V(e.label), 1)
1528
+ ]),
1529
+ _: 1
1530
+ }, 8, ["for", "required"])) : M("", !0)
1531
+ ]),
1532
+ j(e.$slots, "default"),
1533
+ j(e.$slots, "help", {}, () => [
1534
+ e.help ? (m(), h("div", {
1535
+ key: 0,
1536
+ id: e.fieldId + "-help",
1537
+ class: "form-text"
1538
+ }, V(e.help), 9, pl)) : M("", !0)
1539
+ ]),
1540
+ j(e.$slots, "error", { error: e.errorText }, () => [
1541
+ e.errorText ? (m(), h("div", {
1542
+ key: 0,
1543
+ id: e.fieldId + "-error",
1544
+ class: "invalid-feedback d-block",
1545
+ role: "alert"
1546
+ }, V(e.errorText), 9, hl)) : M("", !0)
1547
+ ])
1548
+ ]);
1549
+ }
1550
+ const gl = /* @__PURE__ */ L(fl, [["render", vl]]), yl = F({
1551
+ name: "GroupControl",
1552
+ props: {
1553
+ /** Key of the object / array inside the form that holds the grouped values. */
1554
+ name: { type: String, required: !0 },
1555
+ /** Explicit item index (repeaters). When omitted it is detected from the DOM position. */
1556
+ index: { type: [Number, String], default: null }
1557
+ },
1558
+ setup(e) {
1559
+ const n = pe("form", null), a = E(null), l = E("0"), c = C(() => e.index !== null ? String(e.index) : l.value);
1560
+ J(() => {
1561
+ var u, g, $;
1562
+ if (e.index !== null) return;
1563
+ const t = ($ = (g = (u = a.value) == null ? void 0 : u.parentNode) == null ? void 0 : g.parentNode) == null ? void 0 : $.querySelectorAll(".form-control-group");
1564
+ t == null || t.forEach((y, b) => {
1565
+ y === a.value && (l.value = String(b));
1566
+ });
1567
+ });
1568
+ const i = {
1569
+ get name() {
1570
+ return e.name;
1571
+ },
1572
+ get index() {
1573
+ return c.value;
1574
+ },
1575
+ getData(t) {
1576
+ var g, $;
1577
+ const u = (g = n == null ? void 0 : n.value) == null ? void 0 : g[e.name];
1578
+ return u == null ? null : Array.isArray(u) ? (($ = u[Number(c.value)]) == null ? void 0 : $[t]) ?? null : u[t] ?? null;
1579
+ },
1580
+ setData(t, u) {
1581
+ const g = n == null ? void 0 : n.value;
1582
+ if (g)
1583
+ if ((g[e.name] === null || g[e.name] === void 0) && (g[e.name] = e.index !== null ? [] : {}), Array.isArray(g[e.name])) {
1584
+ const $ = Number(c.value);
1585
+ g[e.name][$] || (g[e.name][$] = {}), g[e.name][$][t] = u;
1586
+ } else
1587
+ g[e.name][t] = u;
1588
+ }
1589
+ };
1590
+ return Ve("group", C(() => i)), { groupEl: a, index: c };
1591
+ }
1592
+ }), bl = ["data-name", "data-group-id"];
1593
+ function $l(e, n, a, l, c, i) {
1594
+ return m(), h("div", {
1595
+ ref: "groupEl",
1596
+ class: "form-control-group",
1597
+ "data-name": e.name,
1598
+ "data-group-id": e.index
1599
+ }, [
1600
+ j(e.$slots, "default")
1601
+ ], 8, bl);
1602
+ }
1603
+ const pn = /* @__PURE__ */ L(yl, [["render", $l]]), wl = F({
1604
+ name: "MobileInput",
1605
+ components: { TextInput: je },
1606
+ props: {
1607
+ name: { type: String, default: "mobile" },
1608
+ placeholder: { type: String, default: null },
1609
+ locale: { type: String, default: null }
1610
+ },
1611
+ setup(e) {
1612
+ const { t: n } = Q(() => e.locale);
1613
+ return { t: n };
1614
+ }
1615
+ });
1616
+ function kl(e, n, a, l, c, i) {
1617
+ const t = oe("TextInput");
1618
+ return m(), le(t, {
1619
+ type: "tel",
1620
+ inputmode: "tel",
1621
+ autocomplete: "tel",
1622
+ class: "form-control-mobile fanum",
1623
+ name: e.name,
1624
+ placeholder: e.placeholder ?? e.t("mobile.placeholder")
1625
+ }, null, 8, ["name", "placeholder"]);
1626
+ }
1627
+ const Sl = /* @__PURE__ */ L(wl, [["render", kl]]), Il = F({
1628
+ name: "QuantityInput",
1629
+ emits: ["update:modelValue", "change", "input", "increment", "decrement", "focus", "blur"],
1630
+ props: {
1631
+ ...z,
1632
+ min: { type: Number, default: 0 },
1633
+ max: { type: Number, default: null },
1634
+ step: { type: Number, default: 1 },
1635
+ unit: { type: String, default: null },
1636
+ size: { type: String, default: null },
1637
+ locale: { type: String, default: null }
1638
+ },
1639
+ setup(e, { emit: n }) {
1640
+ const a = U(e, n), { t: l } = Q(() => e.locale), c = C(() => {
1641
+ const w = Number(a.model.value);
1642
+ return Number.isFinite(w) ? w : e.min;
1643
+ }), i = C(() => e.unit ?? l("quantity.unit")), t = C(() => qe(c.value)), u = C(() => e.readonly || a.isDisabled.value), g = C(() => !u.value && (e.max === null || c.value + e.step <= e.max)), $ = C(() => !u.value && c.value - e.step >= e.min);
1644
+ function y(w, T, o) {
1645
+ let r = w;
1646
+ e.max !== null && (r = Math.min(r, e.max)), r = Math.max(r, e.min), a.model.value = r, o && n(o, r), a.emitChange(r, T);
1647
+ }
1648
+ function b(w) {
1649
+ const T = dn(w.target.value);
1650
+ a.model.value = T === null ? e.min : T, w.target.value = qe(a.model.value), n("input", a.model.value, w);
1651
+ }
1652
+ return J(() => {
1653
+ const w = a.model.value;
1654
+ (w == null || w === "") && (a.model.value = e.min);
1655
+ }), {
1656
+ ...a,
1657
+ t: l,
1658
+ unitText: i,
1659
+ display: t,
1660
+ canIncrement: g,
1661
+ canDecrement: $,
1662
+ lock: u,
1663
+ increment: (w) => g.value && y(c.value + e.step, w, "increment"),
1664
+ decrement: (w) => $.value && y(c.value - e.step, w, "decrement"),
1665
+ onInput: b,
1666
+ clampOnBlur: (w) => y(c.value, w)
1667
+ };
1668
+ }
1669
+ }), Cl = ["disabled", "aria-label"], Tl = ["name", "id", "value", "readonly", "disabled", "aria-invalid"], Ml = ["disabled", "aria-label"], Bl = {
1670
+ key: 0,
1671
+ class: "input-group-text fanum"
1672
+ };
1673
+ function El(e, n, a, l, c, i) {
1674
+ return m(), h("div", {
1675
+ class: q(["input-group input-group-quantity", { "is-invalid": e.isInvalid }])
1676
+ }, [
1677
+ p("button", {
1678
+ type: "button",
1679
+ class: "btn-outline theme-secondary btn-icon",
1680
+ disabled: !e.canIncrement,
1681
+ "aria-label": e.t("quantity.increase"),
1682
+ onClick: n[0] || (n[0] = (...t) => e.increment && e.increment(...t))
1683
+ }, n[6] || (n[6] = [
1684
+ p("svg", {
1685
+ width: "14",
1686
+ height: "14",
1687
+ viewBox: "0 0 16 16",
1688
+ fill: "none",
1689
+ stroke: "currentColor",
1690
+ "stroke-width": "2",
1691
+ "stroke-linecap": "round",
1692
+ "aria-hidden": "true"
1693
+ }, [
1694
+ p("path", { d: "M8 3v10M3 8h10" })
1695
+ ], -1)
1696
+ ]), 8, Cl),
1697
+ p("input", {
1698
+ name: e.name,
1699
+ id: e.inputId,
1700
+ value: e.display,
1701
+ readonly: e.readonly,
1702
+ disabled: e.isDisabled,
1703
+ "aria-invalid": e.isInvalid || void 0,
1704
+ type: "tel",
1705
+ inputmode: "numeric",
1706
+ autocomplete: "off",
1707
+ class: q(["form-control fanum text-center", { "is-invalid": e.isInvalid }]),
1708
+ onInput: n[1] || (n[1] = (...t) => e.onInput && e.onInput(...t)),
1709
+ onChange: n[2] || (n[2] = (...t) => e.clampOnBlur && e.clampOnBlur(...t)),
1710
+ onFocus: n[3] || (n[3] = (t) => e.$emit("focus", t)),
1711
+ onBlur: n[4] || (n[4] = (t) => e.$emit("blur", t))
1712
+ }, null, 42, Tl),
1713
+ p("button", {
1714
+ type: "button",
1715
+ class: "btn-outline theme-secondary btn-icon",
1716
+ disabled: !e.canDecrement,
1717
+ "aria-label": e.t("quantity.decrease"),
1718
+ onClick: n[5] || (n[5] = (...t) => e.decrement && e.decrement(...t))
1719
+ }, n[7] || (n[7] = [
1720
+ p("svg", {
1721
+ width: "14",
1722
+ height: "14",
1723
+ viewBox: "0 0 16 16",
1724
+ fill: "none",
1725
+ stroke: "currentColor",
1726
+ "stroke-width": "2",
1727
+ "stroke-linecap": "round",
1728
+ "aria-hidden": "true"
1729
+ }, [
1730
+ p("path", { d: "M3 8h10" })
1731
+ ], -1)
1732
+ ]), 8, Ml),
1733
+ e.unitText ? (m(), h("span", Bl, V(e.unitText), 1)) : M("", !0),
1734
+ j(e.$slots, "suffix")
1735
+ ], 2);
1736
+ }
1737
+ const hn = /* @__PURE__ */ L(Il, [["render", El]]), Al = F({
1738
+ name: "MultiQuantityInput",
1739
+ components: { GroupControl: pn, QuantityInput: hn },
1740
+ emits: ["update:modelValue", "change", "show", "shown", "hide", "hidden"],
1741
+ props: {
1742
+ ...z,
1743
+ /** Array of strings or { name, min, max, description, html }. */
1744
+ options: { type: Array, default: () => [] },
1745
+ min: { type: Number, default: 0 },
1746
+ max: { type: Number, default: null },
1747
+ totalMin: { type: Number, default: null },
1748
+ totalMax: { type: Number, default: null },
1749
+ unit: { type: String, default: null },
1750
+ placement: { type: String, default: "bottom-start" },
1751
+ locale: { type: String, default: null }
1752
+ },
1753
+ setup(e, { emit: n }) {
1754
+ const a = U(e, n), { t: l } = Q(() => e.locale), c = E(null), i = C(() => {
1755
+ const $ = a.model.value;
1756
+ return $ && typeof $ == "object" ? $ : {};
1757
+ }), t = C(
1758
+ () => e.options.reduce(($, y, b) => $ + (Number(i.value[b]) || 0), 0)
1759
+ ), u = C(() => e.unit ?? l("quantity.unit")), g = C(
1760
+ () => e.options.map(($, y) => {
1761
+ const b = typeof $ == "object" && $ !== null ? $ : { name: $ }, w = Number(i.value[y]) || 0, T = b.max ?? e.max, o = e.totalMax === null ? 1 / 0 : w + (e.totalMax - t.value);
1762
+ return {
1763
+ key: y,
1764
+ name: b.name ?? b.label ?? String($),
1765
+ description: b.description ?? null,
1766
+ html: !!b.html,
1767
+ min: b.min ?? e.min,
1768
+ max: Math.min(T ?? 1 / 0, o) === 1 / 0 ? null : Math.min(T ?? 1 / 0, o)
1769
+ };
1770
+ })
1771
+ );
1772
+ return J(() => {
1773
+ (!a.model.value || typeof a.model.value != "object") && (a.model.value = e.options.reduce(($, y, b) => ($[b] = typeof y == "object" && (y == null ? void 0 : y.min) || e.min, $), {}));
1774
+ }), he(
1775
+ "Menu",
1776
+ () => c.value,
1777
+ () => ({ autoClose: "outside", placement: e.placement }),
1778
+ {
1779
+ onCreate($, y) {
1780
+ ["show", "shown", "hide", "hidden"].forEach(
1781
+ (b) => y.addEventListener(`${b}.bs.menu`, (w) => n(b, w))
1782
+ );
1783
+ }
1784
+ }
1785
+ ), { ...a, t: l, toggle: c, total: t, unitText: u, normalized: g };
1786
+ }
1787
+ }), Ol = { class: "multi-quantity-input fanum" }, Vl = ["disabled"], Nl = { class: "combobox-value" }, Dl = { class: "menu p-3" }, ql = ["innerHTML"], Fl = { key: 1 }, Ll = {
1788
+ key: 2,
1789
+ class: "form-text mt-0"
1790
+ };
1791
+ function Rl(e, n, a, l, c, i) {
1792
+ const t = oe("QuantityInput"), u = oe("GroupControl");
1793
+ return m(), h("div", Ol, [
1794
+ p("button", {
1795
+ ref: "toggle",
1796
+ type: "button",
1797
+ class: q(["form-control combobox-toggle", { "is-invalid": e.isInvalid }]),
1798
+ "data-bs-toggle": "menu",
1799
+ "aria-haspopup": "true",
1800
+ disabled: e.isDisabled || e.readonly
1801
+ }, [
1802
+ p("span", Nl, V(e.total) + " " + V(e.unitText), 1)
1803
+ ], 10, Vl),
1804
+ p("div", Dl, [
1805
+ Ne(u, { name: e.name }, {
1806
+ default: Qe(() => [
1807
+ (m(!0), h(G, null, ae(e.normalized, (g) => (m(), h("div", {
1808
+ key: g.key,
1809
+ class: "d-flex align-items-center justify-content-between gap-3 py-1"
1810
+ }, [
1811
+ p("div", null, [
1812
+ g.html ? (m(), h("span", {
1813
+ key: 0,
1814
+ innerHTML: g.name
1815
+ }, null, 8, ql)) : (m(), h("span", Fl, V(g.name), 1)),
1816
+ g.description ? (m(), h("div", Ll, V(g.description), 1)) : M("", !0)
1817
+ ]),
1818
+ Ne(t, {
1819
+ name: String(g.key),
1820
+ min: g.min,
1821
+ max: g.max,
1822
+ readonly: e.readonly,
1823
+ unit: ""
1824
+ }, null, 8, ["name", "min", "max", "readonly"])
1825
+ ]))), 128))
1826
+ ]),
1827
+ _: 1
1828
+ }, 8, ["name"])
1829
+ ])
1830
+ ]);
1831
+ }
1832
+ const jl = /* @__PURE__ */ L(Al, [["render", Rl]]), Pl = F({
1833
+ name: "OTPInput",
1834
+ emits: ["update:modelValue", "change", "input", "complete", "focus", "blur"],
1835
+ props: {
1836
+ ...z,
1837
+ /** Number of characters. */
1838
+ length: { type: Number, default: null },
1839
+ /** Legacy alias of `length`. */
1840
+ maxLength: { type: Number, default: null },
1841
+ /** numeric | alphanumeric | alpha */
1842
+ type: { type: String, default: "numeric", validator: (e) => ["numeric", "alphanumeric", "alpha"].includes(e) },
1843
+ /** Show • instead of the typed character. */
1844
+ mask: { type: Boolean, default: !1 },
1845
+ /** Visual grouping, e.g. [3, 3] renders `123 · 456`. */
1846
+ groups: { type: Array, default: null },
1847
+ separator: { type: String, default: "·" },
1848
+ /** Submit the surrounding FormContainer as soon as the code is complete. */
1849
+ autoSubmit: { type: Boolean, default: !1 },
1850
+ autofocus: { type: Boolean, default: !1 }
1851
+ },
1852
+ setup(e, { emit: n, expose: a }) {
1853
+ const l = U(e, n), c = E(null), i = E(null);
1854
+ let t = !1, u = [];
1855
+ const g = () => e.length ?? e.maxLength ?? 6, $ = (o) => o == null ? "" : String(o);
1856
+ function y() {
1857
+ var o;
1858
+ (o = i.value) == null || o.classList.toggle("is-invalid", l.isInvalid.value);
1859
+ }
1860
+ function b() {
1861
+ const o = w.value;
1862
+ if (!o) return;
1863
+ const r = $(l.model.value);
1864
+ if (o.getValue() !== r) {
1865
+ t = !0;
1866
+ try {
1867
+ o.setValue(r);
1868
+ } finally {
1869
+ t = !1;
1870
+ }
1871
+ }
1872
+ }
1873
+ const { instance: w, create: T } = he(
1874
+ "OtpInput",
1875
+ () => c.value,
1876
+ () => ({
1877
+ length: g(),
1878
+ type: e.type,
1879
+ mask: e.mask,
1880
+ groups: e.groups,
1881
+ separator: e.separator
1882
+ }),
1883
+ {
1884
+ onCreate(o, r) {
1885
+ const s = (f, S) => {
1886
+ r.addEventListener(f, S), u.push(() => r.removeEventListener(f, S));
1887
+ };
1888
+ s("input.bs.otpInput", (f) => {
1889
+ t || (l.model.value = f.value, n("input", f.value, f), l.emitChange(f.value, f));
1890
+ }), s("complete.bs.otpInput", (f) => {
1891
+ var S, R;
1892
+ t || (n("complete", f.value), e.autoSubmit && ((R = (S = l.formApi) == null ? void 0 : S.submit) == null || R.call(S)));
1893
+ }), b(), y(), e.autofocus && o.focus();
1894
+ },
1895
+ onDestroy() {
1896
+ u.forEach((o) => o()), u = [];
1897
+ }
1898
+ }
1899
+ );
1900
+ return J(() => {
1901
+ i.value && (i.value.value = $(l.model.value));
1902
+ }), H(() => l.model.value, b), H(l.isInvalid, y, { flush: "post" }), H(
1903
+ () => [g(), e.type, e.mask, e.groups, e.separator],
1904
+ async () => {
1905
+ await W(), T();
1906
+ },
1907
+ { deep: !0 }
1908
+ ), a({
1909
+ focus: () => {
1910
+ var o;
1911
+ return (o = w.value) == null ? void 0 : o.focus();
1912
+ },
1913
+ clear: () => {
1914
+ var o;
1915
+ (o = w.value) == null || o.clear(), l.model.value = "";
1916
+ }
1917
+ }), { ...l, el: c, input: i };
1918
+ }
1919
+ }), zl = {
1920
+ ref: "el",
1921
+ class: "otp fanum"
1922
+ }, Ul = ["name", "id", "disabled", "readonly", "required", "aria-invalid"];
1923
+ function Hl(e, n, a, l, c, i) {
1924
+ return m(), h("div", zl, [
1925
+ p("input", {
1926
+ ref: "input",
1927
+ type: "text",
1928
+ name: e.name,
1929
+ id: e.inputId,
1930
+ disabled: e.isDisabled,
1931
+ readonly: e.readonly,
1932
+ required: e.required,
1933
+ "aria-invalid": e.isInvalid || void 0,
1934
+ onFocus: n[0] || (n[0] = (t) => e.$emit("focus", t)),
1935
+ onBlur: n[1] || (n[1] = (t) => e.$emit("blur", t))
1936
+ }, null, 40, Ul)
1937
+ ], 512);
1938
+ }
1939
+ const Kl = /* @__PURE__ */ L(Pl, [["render", Hl]]), an = {
1940
+ en: { weak: "Weak", fair: "Fair", good: "Good", strong: "Strong" },
1941
+ fa: { weak: "ضعیف", fair: "متوسط", good: "خوب", strong: "قوی" }
1942
+ }, Xl = F({
1943
+ name: "PasswordInput",
1944
+ components: { TextInput: je, FormAdornInput: Ze },
1945
+ inheritAttrs: !1,
1946
+ emits: ["toggle", "strength"],
1947
+ props: {
1948
+ ...z,
1949
+ name: { type: String, default: "password" },
1950
+ placeholder: { type: String, default: null },
1951
+ /** Show a "reveal password" button. */
1952
+ toggle: { type: Boolean, default: !1 },
1953
+ /** Show the password strength meter. */
1954
+ strength: { type: Boolean, default: !1 },
1955
+ /** Show the text feedback ("Weak", "Strong", …) under the meter. */
1956
+ strengthText: { type: Boolean, default: !0 },
1957
+ /** Override the labels: { weak, fair, good, strong }. */
1958
+ strengthMessages: { type: Object, default: null },
1959
+ /** Bootstrap Strength options: { minLength, thresholds: [2, 4, 6], weights, scorer(password) => number }. */
1960
+ strengthOptions: { type: Object, default: () => ({}) },
1961
+ size: { type: String, default: null },
1962
+ locale: { type: String, default: null }
1963
+ },
1964
+ setup(e, { emit: n, expose: a }) {
1965
+ const { t: l, locale: c } = Q(() => e.locale), i = U(e, () => {
1966
+ }), t = E(null), u = E(null), g = E(!1), $ = C(() => ({
1967
+ ...an[c.value] || an.en,
1968
+ ...e.strengthMessages || {}
1969
+ }));
1970
+ function y() {
1971
+ g.value = !g.value, n("toggle", g.value);
1972
+ }
1973
+ let b = [];
1974
+ const { instance: w, create: T } = he(
1975
+ "Strength",
1976
+ () => e.strength ? u.value : null,
1977
+ () => {
1978
+ var r;
1979
+ return {
1980
+ ...e.strengthOptions,
1981
+ input: (r = t.value) == null ? void 0 : r.querySelector("input"),
1982
+ messages: $.value
1983
+ };
1984
+ },
1985
+ {
1986
+ onCreate(r, s) {
1987
+ const f = (S) => n("strength", S.strength ?? null, S.score ?? 0);
1988
+ s.addEventListener("strengthChange.bs.strength", f), b.push(() => s.removeEventListener("strengthChange.bs.strength", f));
1989
+ },
1990
+ onDestroy() {
1991
+ b.forEach((r) => r()), b = [];
1992
+ }
1993
+ }
1994
+ );
1995
+ H(
1996
+ () => i.model.value,
1997
+ () => W(() => {
1998
+ var r;
1999
+ return (r = w.value) == null ? void 0 : r.evaluate();
2000
+ })
2001
+ ), H(
2002
+ () => [e.strength, e.toggle, e.strengthText, $.value, e.strengthOptions],
2003
+ async () => {
2004
+ await W(), e.strength && T();
2005
+ },
2006
+ { deep: !0 }
2007
+ ), a({ strength: () => {
2008
+ var r, s;
2009
+ return ((s = (r = w.value) == null ? void 0 : r.getStrength) == null ? void 0 : s.call(r)) ?? null;
2010
+ } });
2011
+ const o = C(() => ({
2012
+ name: e.name,
2013
+ modelValue: e.modelValue,
2014
+ id: e.id,
2015
+ disabled: e.disabled,
2016
+ readonly: e.readonly,
2017
+ required: e.required,
2018
+ invalid: e.invalid,
2019
+ size: e.size,
2020
+ placeholder: e.placeholder ?? l("password.placeholder")
2021
+ }));
2022
+ return { t: l, root: t, meter: u, visible: g, toggleVisible: y, forwarded: o };
2023
+ }
2024
+ }), Gl = {
2025
+ ref: "root",
2026
+ class: "password-input"
2027
+ }, Wl = ["aria-label", "aria-pressed"], Ql = {
2028
+ key: 0,
2029
+ width: "16",
2030
+ height: "16",
2031
+ viewBox: "0 0 16 16",
2032
+ fill: "none",
2033
+ stroke: "currentColor",
2034
+ "stroke-width": "1.5",
2035
+ "stroke-linecap": "round",
2036
+ "stroke-linejoin": "round",
2037
+ "aria-hidden": "true"
2038
+ }, Jl = {
2039
+ key: 1,
2040
+ width: "16",
2041
+ height: "16",
2042
+ viewBox: "0 0 16 16",
2043
+ fill: "none",
2044
+ stroke: "currentColor",
2045
+ "stroke-width": "1.5",
2046
+ "stroke-linecap": "round",
2047
+ "stroke-linejoin": "round",
2048
+ "aria-hidden": "true"
2049
+ }, Zl = {
2050
+ ref: "meter",
2051
+ class: "strength",
2052
+ "aria-hidden": "true"
2053
+ }, Yl = {
2054
+ key: 0,
2055
+ class: "strength-text",
2056
+ "aria-live": "polite"
2057
+ };
2058
+ function xl(e, n, a, l, c, i) {
2059
+ const t = oe("FormAdornInput"), u = oe("TextInput");
2060
+ return m(), h("div", Gl, [
2061
+ e.toggle ? (m(), le(t, Ke({ key: 0 }, { ...e.$attrs, ...e.forwarded }, {
2062
+ type: e.visible ? "text" : "password",
2063
+ autocomplete: "current-password"
2064
+ }), {
2065
+ end: Qe(() => [
2066
+ p("button", {
2067
+ type: "button",
2068
+ class: "btn-text theme-secondary btn-icon",
2069
+ "aria-label": e.visible ? e.t("password.hide") : e.t("password.show"),
2070
+ "aria-pressed": e.visible,
2071
+ onClick: n[0] || (n[0] = (...g) => e.toggleVisible && e.toggleVisible(...g))
2072
+ }, [
2073
+ e.visible ? (m(), h("svg", Jl, n[2] || (n[2] = [
2074
+ p("path", { d: "M2 2l12 12M6.6 3.7A7 7 0 0 1 8 3.5C12.5 3.5 15 8 15 8a11 11 0 0 1-2.2 2.6M4 5.4A11 11 0 0 0 1 8s2.5 4.5 7 4.5c1 0 1.9-.2 2.7-.6" }, null, -1)
2075
+ ]))) : (m(), h("svg", Ql, n[1] || (n[1] = [
2076
+ p("path", { d: "M1 8s2.5-4.5 7-4.5S15 8 15 8s-2.5 4.5-7 4.5S1 8 1 8Z" }, null, -1),
2077
+ p("circle", {
2078
+ cx: "8",
2079
+ cy: "8",
2080
+ r: "2"
2081
+ }, null, -1)
2082
+ ])))
2083
+ ], 8, Wl)
2084
+ ]),
2085
+ _: 1
2086
+ }, 16, ["type"])) : (m(), le(u, Ke({ key: 1 }, { ...e.$attrs, ...e.forwarded }, {
2087
+ type: "password",
2088
+ autocomplete: "current-password"
2089
+ }), null, 16)),
2090
+ e.strength ? (m(), h(G, { key: 2 }, [
2091
+ p("div", Zl, n[3] || (n[3] = [
2092
+ p("div", { class: "strength-segment" }, null, -1),
2093
+ p("div", { class: "strength-segment" }, null, -1),
2094
+ p("div", { class: "strength-segment" }, null, -1),
2095
+ p("div", { class: "strength-segment" }, null, -1)
2096
+ ]), 512),
2097
+ e.strengthText ? (m(), h("div", Yl)) : M("", !0)
2098
+ ], 64)) : M("", !0)
2099
+ ], 512);
2100
+ }
2101
+ const _l = /* @__PURE__ */ L(Xl, [["render", xl]]), ea = F({
2102
+ name: "RangeInput",
2103
+ emits: ["update:modelValue", "change", "input", "focus", "blur"],
2104
+ props: {
2105
+ ...z,
2106
+ min: { type: Number, default: 0 },
2107
+ max: { type: Number, default: 100 },
2108
+ step: { type: Number, default: 1 },
2109
+ /** Show the current value above the thumb. */
2110
+ bubble: { type: Boolean, default: !1 },
2111
+ /** (value:number) => string — formats the bubble and the tick labels. */
2112
+ formatter: { type: Function, default: null },
2113
+ /** Tick marks: numbers or { value, label } objects. */
2114
+ ticks: { type: Array, default: () => [] }
2115
+ },
2116
+ setup(e, { emit: n }) {
2117
+ const a = U(e, n), l = E(null), c = E(null), i = C(() => {
2118
+ const b = Number(a.model.value);
2119
+ return a.model.value === null || a.model.value === void 0 || Number.isNaN(b) ? e.min : b;
2120
+ }), t = C(() => e.ticks.length ? `${a.inputId.value}-ticks` : void 0), u = C(
2121
+ () => e.ticks.map((b) => typeof b == "object" && b !== null ? b : { value: b, label: e.formatter ? e.formatter(b) : String(b) })
2122
+ );
2123
+ function g(b) {
2124
+ const w = Number(b.target.value);
2125
+ a.model.value = w, n("input", w, b);
2126
+ }
2127
+ const { instance: $, create: y } = he(
2128
+ "Range",
2129
+ () => l.value,
2130
+ () => ({ bubble: e.bubble, formatter: e.formatter })
2131
+ );
2132
+ return H(
2133
+ () => [a.model.value, e.min, e.max],
2134
+ () => W(() => {
2135
+ var b;
2136
+ return (b = $.value) == null ? void 0 : b.update();
2137
+ }),
2138
+ { flush: "post" }
2139
+ ), H(
2140
+ () => [e.bubble, e.formatter, e.ticks, e.min, e.max],
2141
+ async () => {
2142
+ await W(), y();
2143
+ },
2144
+ { deep: !0 }
2145
+ ), { ...a, el: l, input: c, current: i, listId: t, tickItems: u, onInput: g };
2146
+ }
2147
+ }), na = {
2148
+ ref: "el",
2149
+ class: "form-range"
2150
+ }, ta = ["name", "id", "min", "max", "step", "list", "disabled", "aria-invalid", "value"], la = ["id"], aa = ["value", "label"];
2151
+ function oa(e, n, a, l, c, i) {
2152
+ return m(), h("div", na, [
2153
+ p("input", {
2154
+ ref: "input",
2155
+ type: "range",
2156
+ class: q(["form-range-input", { "is-invalid": e.isInvalid }]),
2157
+ name: e.name,
2158
+ id: e.inputId,
2159
+ min: e.min,
2160
+ max: e.max,
2161
+ step: e.step,
2162
+ list: e.listId,
2163
+ disabled: e.isDisabled || e.readonly,
2164
+ "aria-invalid": e.isInvalid || void 0,
2165
+ value: e.current,
2166
+ onInput: n[0] || (n[0] = (...t) => e.onInput && e.onInput(...t)),
2167
+ onChange: n[1] || (n[1] = (t) => e.emitChange(Number(t.target.value), t)),
2168
+ onFocus: n[2] || (n[2] = (t) => e.$emit("focus", t)),
2169
+ onBlur: n[3] || (n[3] = (t) => e.$emit("blur", t))
2170
+ }, null, 42, ta),
2171
+ e.listId ? (m(), h("datalist", {
2172
+ key: 0,
2173
+ id: e.listId
2174
+ }, [
2175
+ (m(!0), h(G, null, ae(e.tickItems, (t) => (m(), h("option", {
2176
+ key: t.value,
2177
+ value: t.value,
2178
+ label: t.label
2179
+ }, null, 8, aa))), 128))
2180
+ ], 8, la)) : M("", !0)
2181
+ ], 512);
2182
+ }
2183
+ const vn = /* @__PURE__ */ L(ea, [["render", oa]]), ra = F({
2184
+ name: "SimpleUploader",
2185
+ inheritAttrs: !0,
2186
+ setup(e, { attrs: n, slots: a }) {
2187
+ return () => bn(fn, n, a);
2188
+ }
2189
+ }), sa = F({
2190
+ name: "StarRatingInput",
2191
+ emits: ["update:modelValue", "change", "hover"],
2192
+ props: {
2193
+ ...z,
2194
+ /** Initial rating used when the model is empty. */
2195
+ value: { type: Number, default: 0 },
2196
+ maxStars: { type: Number, default: 5 },
2197
+ /** Steps per star: 1 = whole stars, 2 = half stars, 4 = quarter stars… */
2198
+ precision: { type: Number, default: 2 },
2199
+ showValue: { type: Boolean, default: !0 },
2200
+ /** Allow clicking the current rating again to reset it to 0. */
2201
+ clearable: { type: Boolean, default: !1 }
2202
+ },
2203
+ setup(e, { emit: n }) {
2204
+ const a = U(e, n), l = E(null), c = E(null), i = E(!1);
2205
+ J(() => {
2206
+ l.value && (i.value = getComputedStyle(l.value).direction === "rtl");
2207
+ });
2208
+ const t = C(() => e.readonly || a.isDisabled.value), u = C(() => {
2209
+ const f = Number(a.model.value);
2210
+ return a.model.value === null || a.model.value === void 0 || Number.isNaN(f) ? e.value : f;
2211
+ }), g = C(() => c.value ?? u.value), $ = C(() => 1 / e.precision), y = (f) => Math.max(0, Math.min(1, g.value - (f - 1))) * 100;
2212
+ function b(f) {
2213
+ const S = l.value.getBoundingClientRect(), R = i.value ? S.right - f.clientX : f.clientX - S.left, A = S.width / e.maxStars, K = Math.ceil(R / A * e.precision) / e.precision;
2214
+ return Math.min(e.maxStars, Math.max($.value, K));
2215
+ }
2216
+ function w(f) {
2217
+ t.value || (c.value = b(f), n("hover", c.value));
2218
+ }
2219
+ function T() {
2220
+ c.value = null;
2221
+ }
2222
+ function o(f, S) {
2223
+ if (t.value) return;
2224
+ const R = e.clearable && f === u.value ? 0 : f;
2225
+ a.model.value = R, a.emitChange(R, S);
2226
+ }
2227
+ function r(f) {
2228
+ t.value || o(b(f), f);
2229
+ }
2230
+ function s(f) {
2231
+ if (t.value) return;
2232
+ const S = i.value ? "ArrowLeft" : "ArrowRight", R = i.value ? "ArrowRight" : "ArrowLeft";
2233
+ let A = null;
2234
+ f.key === S || f.key === "ArrowUp" ? A = u.value + $.value : f.key === R || f.key === "ArrowDown" ? A = u.value - $.value : f.key === "Home" ? A = 0 : f.key === "End" && (A = e.maxStars), A !== null && (f.preventDefault(), o(Math.min(e.maxStars, Math.max(0, Number(A.toFixed(4)))), f));
2235
+ }
2236
+ return {
2237
+ ...a,
2238
+ container: l,
2239
+ rating: g,
2240
+ stored: u,
2241
+ fillOf: y,
2242
+ onMove: w,
2243
+ leave: T,
2244
+ onClick: r,
2245
+ onKeydown: s,
2246
+ locked: t,
2247
+ display: C(() => g.value.toFixed(1))
2248
+ };
2249
+ }
2250
+ }), ia = ["tabindex", "aria-valuemax", "aria-valuenow", "aria-readonly", "aria-invalid"], ua = ["name", "value"], da = {
2251
+ key: 1,
2252
+ class: "rating-value fanum"
2253
+ };
2254
+ function ca(e, n, a, l, c, i) {
2255
+ return m(), h("div", {
2256
+ class: q(["star-rating d-flex align-items-center gap-2", { "is-invalid": e.isInvalid }])
2257
+ }, [
2258
+ p("div", {
2259
+ ref: "container",
2260
+ class: "star-rating-container d-flex position-relative",
2261
+ role: "slider",
2262
+ tabindex: e.locked ? -1 : 0,
2263
+ "aria-valuemin": 0,
2264
+ "aria-valuemax": e.maxStars,
2265
+ "aria-valuenow": e.stored,
2266
+ "aria-readonly": e.locked || void 0,
2267
+ "aria-invalid": e.isInvalid || void 0,
2268
+ style: se({ cursor: e.locked ? "default" : "pointer" }),
2269
+ onPointermove: n[0] || (n[0] = (...t) => e.onMove && e.onMove(...t)),
2270
+ onPointerleave: n[1] || (n[1] = (...t) => e.leave && e.leave(...t)),
2271
+ onClick: n[2] || (n[2] = (...t) => e.onClick && e.onClick(...t)),
2272
+ onKeydown: n[3] || (n[3] = (...t) => e.onKeydown && e.onKeydown(...t))
2273
+ }, [
2274
+ (m(!0), h(G, null, ae(e.maxStars, (t) => (m(), h("span", {
2275
+ key: t,
2276
+ class: "star-wrapper position-relative d-inline-block fs-2xl lh-1"
2277
+ }, [
2278
+ n[4] || (n[4] = p("span", {
2279
+ class: "star-bg fg-secondary opacity-50",
2280
+ "aria-hidden": "true"
2281
+ }, "★", -1)),
2282
+ p("span", {
2283
+ class: "star-overlay fg-warning",
2284
+ "aria-hidden": "true",
2285
+ style: se({ position: "absolute", top: 0, insetInlineStart: 0, overflow: "hidden", whiteSpace: "nowrap", width: e.fillOf(t) + "%" })
2286
+ }, "★", 4)
2287
+ ]))), 128))
2288
+ ], 44, ia),
2289
+ e.name ? (m(), h("input", {
2290
+ key: 0,
2291
+ type: "hidden",
2292
+ name: e.name,
2293
+ value: e.stored
2294
+ }, null, 8, ua)) : M("", !0),
2295
+ e.showValue && e.rating > 0 ? (m(), h("span", da, V(e.display), 1)) : M("", !0)
2296
+ ], 2);
2297
+ }
2298
+ const fa = /* @__PURE__ */ L(sa, [["render", ca]]), ma = F({
2299
+ name: "SubmitButton",
2300
+ emits: ["click"],
2301
+ props: {
2302
+ disabled: { type: Boolean, default: !1 },
2303
+ /** Force the loading state (otherwise it follows form.processing / form.uploading). */
2304
+ loading: { type: Boolean, default: null },
2305
+ /** Bootstrap 6 button variant: solid | outline | subtle | text | styled | link. Use null to supply your own classes. */
2306
+ variant: { type: String, default: "solid" },
2307
+ /** Bootstrap 6 theme: primary | secondary | accent | success | danger | warning | info | inverse. */
2308
+ theme: { type: String, default: "primary" },
2309
+ locale: { type: String, default: null }
2310
+ },
2311
+ setup(e, { emit: n }) {
2312
+ const a = pe("form", null), l = C(() => (a == null ? void 0 : a.value) ?? null), { t: c } = Q(() => e.locale), i = C(
2313
+ () => {
2314
+ var u, g;
2315
+ return e.loading !== null ? e.loading : !!((u = l.value) != null && u.processing || (g = l.value) != null && g.uploading);
2316
+ }
2317
+ ), t = C(() => [
2318
+ e.variant ? `btn-${e.variant}` : null,
2319
+ e.theme && e.variant ? `theme-${e.theme}` : null
2320
+ ]);
2321
+ return { form: l, busy: i, classes: t, t: c, onClick: (u) => n("click", u) };
2322
+ }
2323
+ }), pa = ["disabled", "aria-busy"], ha = {
2324
+ key: 0,
2325
+ class: "spinner-border spinner-sm me-2",
2326
+ role: "status",
2327
+ "aria-hidden": "true"
2328
+ }, va = {
2329
+ key: 0,
2330
+ class: "fanum"
2331
+ };
2332
+ function ga(e, n, a, l, c, i) {
2333
+ var t;
2334
+ return m(), h("button", {
2335
+ type: "submit",
2336
+ class: q(e.classes),
2337
+ disabled: e.disabled || e.busy,
2338
+ "aria-busy": e.busy || void 0,
2339
+ onClick: n[0] || (n[0] = (...u) => e.onClick && e.onClick(...u))
2340
+ }, [
2341
+ e.busy ? (m(), h("span", ha)) : M("", !0),
2342
+ j(e.$slots, "default", {
2343
+ form: e.form,
2344
+ loading: e.busy
2345
+ }, () => [
2346
+ _(V(e.t("submit.default")), 1)
2347
+ ]),
2348
+ j(e.$slots, "progress", {
2349
+ progress: (t = e.form) == null ? void 0 : t.uploading
2350
+ }, () => {
2351
+ var u;
2352
+ return [
2353
+ (u = e.form) != null && u.uploading ? (m(), h("span", va, V(e.form.uploading) + "%", 1)) : M("", !0)
2354
+ ];
2355
+ })
2356
+ ], 10, pa);
2357
+ }
2358
+ const ya = /* @__PURE__ */ L(ma, [["render", ga]]), ba = F({
2359
+ name: "SwitchInput",
2360
+ emits: ["update:modelValue", "change", "focus", "blur"],
2361
+ props: {
2362
+ ...z,
2363
+ value: { type: [String, Number, Boolean, Object], default: null },
2364
+ trueValue: { type: null, default: !0 },
2365
+ falseValue: { type: null, default: !1 },
2366
+ checked: { type: Boolean, default: !1 },
2367
+ label: { type: String, default: null }
2368
+ },
2369
+ setup(e, { emit: n }) {
2370
+ const a = E(null), l = U(e, n, { valued: () => e.value });
2371
+ return Re(e, l, a, { type: () => "checkbox" }), {
2372
+ ...l,
2373
+ input: a,
2374
+ onChange: (c) => l.emitChange(l.model.value, c)
2375
+ };
2376
+ },
2377
+ expose: ["input"]
2378
+ }), $a = { class: "form-field" }, wa = { class: "switch" }, ka = ["name", "id", "value", "true-value", "false-value", "required", "disabled", "aria-invalid"], Sa = ["for"];
2379
+ function Ia(e, n, a, l, c, i) {
2380
+ return m(), h("div", $a, [
2381
+ p("div", wa, [
2382
+ re(p("input", {
2383
+ ref: "input",
2384
+ "onUpdate:modelValue": n[0] || (n[0] = (t) => e.model = t),
2385
+ name: e.name,
2386
+ id: e.inputId,
2387
+ type: "checkbox",
2388
+ role: "switch",
2389
+ switch: "",
2390
+ value: e.value ?? void 0,
2391
+ "true-value": e.trueValue,
2392
+ "false-value": e.falseValue,
2393
+ required: e.required,
2394
+ disabled: e.isDisabled,
2395
+ "aria-invalid": e.isInvalid || void 0,
2396
+ class: q({ "is-invalid": e.isInvalid }),
2397
+ onChange: n[1] || (n[1] = (...t) => e.onChange && e.onChange(...t)),
2398
+ onFocus: n[2] || (n[2] = (t) => e.$emit("focus", t)),
2399
+ onBlur: n[3] || (n[3] = (t) => e.$emit("blur", t))
2400
+ }, null, 42, ka), [
2401
+ [$n, e.model]
2402
+ ])
2403
+ ]),
2404
+ p("label", { for: e.inputId }, [
2405
+ j(e.$slots, "default", {}, () => [
2406
+ _(V(e.label), 1)
2407
+ ])
2408
+ ], 8, Sa)
2409
+ ]);
2410
+ }
2411
+ const Ca = /* @__PURE__ */ L(ba, [["render", Ia]]), Ta = F({
2412
+ name: "TextAreaInput",
2413
+ emits: ["update:modelValue", "change", "input", "focus", "blur"],
2414
+ props: {
2415
+ ...z,
2416
+ rows: { type: [Number, String], default: 3 },
2417
+ placeholder: { type: String, default: null },
2418
+ size: { type: String, default: null }
2419
+ },
2420
+ setup(e, { emit: n }) {
2421
+ const a = U(e, n), l = C(() => e.size ? `form-control-${e.size}` : null);
2422
+ return { ...a, sizeClass: l, emit: n };
2423
+ }
2424
+ }), Ma = ["name", "id", "rows", "placeholder", "required", "readonly", "disabled", "aria-invalid"];
2425
+ function Ba(e, n, a, l, c, i) {
2426
+ return re((m(), h("textarea", {
2427
+ "onUpdate:modelValue": n[0] || (n[0] = (t) => e.model = t),
2428
+ name: e.name,
2429
+ id: e.inputId,
2430
+ rows: e.rows,
2431
+ placeholder: e.placeholder,
2432
+ required: e.required,
2433
+ readonly: e.readonly,
2434
+ disabled: e.isDisabled,
2435
+ "aria-invalid": e.isInvalid || void 0,
2436
+ class: q(["form-control", [e.sizeClass, { "is-invalid": e.isInvalid }]]),
2437
+ onInput: n[1] || (n[1] = (t) => e.emit("input", e.model, t)),
2438
+ onChange: n[2] || (n[2] = (t) => e.emitChange(e.model, t)),
2439
+ onFocus: n[3] || (n[3] = (t) => e.$emit("focus", t)),
2440
+ onBlur: n[4] || (n[4] = (t) => e.$emit("blur", t))
2441
+ }, null, 42, Ma)), [
2442
+ [sn, e.model]
2443
+ ]);
2444
+ }
2445
+ const Ea = /* @__PURE__ */ L(Ta, [["render", Ba]]), Fe = ie({}), we = ie({});
2446
+ function Aa(e, n) {
2447
+ Fe[e] = n;
2448
+ }
2449
+ function Oa(e, n) {
2450
+ var a;
2451
+ ((a = Fe[e]) == null ? void 0 : a.owner) === n && delete Fe[e];
2452
+ }
2453
+ function Va(e) {
2454
+ return we[e] = (we[e] || 0) + 1, () => {
2455
+ we[e] = Math.max(0, (we[e] || 1) - 1);
2456
+ };
2457
+ }
2458
+ const on = (e) => String(Math.floor(e)).padStart(2, "0"), We = (e) => `${on(e / 60)}:${on(e % 60)}`, Na = F({
2459
+ name: "VoiceRecorderResultArea",
2460
+ props: {
2461
+ /** channel / name of the recorder to display. */
2462
+ for: { type: String, required: !0 },
2463
+ showList: { type: Boolean, default: !0 },
2464
+ showProblem: { type: Boolean, default: !0 },
2465
+ /** Extra classes of the list-group. */
2466
+ listClass: { type: [String, Array, Object], default: null },
2467
+ /** Classes of the error alert. */
2468
+ alertClass: { type: [String, Array, Object], default: "alert theme-danger mb-2" },
2469
+ /** Used by the recorder itself for its built-in output; does not count as an external area. */
2470
+ internal: { type: Boolean, default: !1 }
2471
+ },
2472
+ setup(e) {
2473
+ const n = E(null), a = C(() => Fe[e.for] ?? null);
2474
+ let l = null;
2475
+ J(() => {
2476
+ e.internal || (l = Va(e.for));
2477
+ }), un(() => l == null ? void 0 : l());
2478
+ const c = (t) => {
2479
+ var u, g;
2480
+ return ((g = (u = a.value) == null ? void 0 : u.t) == null ? void 0 : g.call(u, t)) ?? t;
2481
+ };
2482
+ function i(t) {
2483
+ var u;
2484
+ (u = n.value) == null || u.querySelectorAll("audio").forEach((g) => {
2485
+ g !== t.target && g.pause();
2486
+ });
2487
+ }
2488
+ return { root: n, channel: a, t: c, onPlay: i, formatTime: We };
2489
+ }
2490
+ }), Da = {
2491
+ key: 0,
2492
+ ref: "root",
2493
+ class: "voice-recorder-results"
2494
+ }, qa = ["data-code"], Fa = { class: "row gx-3 align-items-center" }, La = { class: "col-12 sm:col-4" }, Ra = ["src"], ja = {
2495
+ key: 0,
2496
+ class: "col-auto"
2497
+ }, Pa = {
2498
+ class: "fg-secondary fanum",
2499
+ dir: "ltr"
2500
+ }, za = { class: "col" }, Ua = ["aria-valuenow"], Ha = {
2501
+ key: 1,
2502
+ class: "fg-danger",
2503
+ role: "alert"
2504
+ }, Ka = {
2505
+ key: 1,
2506
+ class: "col-auto"
2507
+ }, Xa = ["aria-label", "onClick"], Ga = { class: "col-auto" }, Wa = ["aria-label", "onClick"];
2508
+ function Qa(e, n, a, l, c, i) {
2509
+ return e.channel && (e.showProblem && e.channel.problem || e.showList && e.channel.items.length) ? (m(), h("div", Da, [
2510
+ e.showProblem && e.channel.problem ? (m(), h("div", {
2511
+ key: 0,
2512
+ class: q(e.alertClass),
2513
+ role: "alert",
2514
+ "data-code": e.channel.problem.code
2515
+ }, V(e.channel.problem.message), 11, qa)) : M("", !0),
2516
+ e.showList && e.channel.items.length ? (m(), h("ul", {
2517
+ key: 1,
2518
+ class: q(["list-group", e.listClass])
2519
+ }, [
2520
+ (m(!0), h(G, null, ae(e.channel.items, (t) => (m(), h("li", {
2521
+ key: t.id,
2522
+ class: "list-group-item"
2523
+ }, [
2524
+ j(e.$slots, "item", {
2525
+ item: t,
2526
+ time: t.seconds !== null ? e.formatTime(t.seconds) : null,
2527
+ locked: e.channel.locked,
2528
+ remove: () => e.channel.remove(t),
2529
+ retry: () => e.channel.retry(t)
2530
+ }, () => [
2531
+ p("div", Fa, [
2532
+ p("div", La, [
2533
+ p("audio", {
2534
+ class: "flex-grow-1 w-100",
2535
+ controls: "",
2536
+ preload: "metadata",
2537
+ src: t.src,
2538
+ onPlay: n[0] || (n[0] = (...u) => e.onPlay && e.onPlay(...u))
2539
+ }, null, 40, Ra)
2540
+ ]),
2541
+ t.seconds !== null ? (m(), h("div", ja, [
2542
+ p("span", Pa, V(e.formatTime(t.seconds)), 1)
2543
+ ])) : M("", !0),
2544
+ p("div", za, [
2545
+ t.status === "uploading" ? (m(), h("div", {
2546
+ key: 0,
2547
+ class: "progress",
2548
+ role: "progressbar",
2549
+ "aria-valuenow": t.percent,
2550
+ "aria-valuemin": "0",
2551
+ "aria-valuemax": "100"
2552
+ }, [
2553
+ p("div", {
2554
+ class: "progress-bar",
2555
+ style: se({ width: t.percent + "%" })
2556
+ }, null, 4)
2557
+ ], 8, Ua)) : M("", !0),
2558
+ t.status === "error" ? (m(), h("div", Ha, V(t.error), 1)) : M("", !0)
2559
+ ]),
2560
+ t.status === "error" ? (m(), h("div", Ka, [
2561
+ p("button", {
2562
+ type: "button",
2563
+ class: "btn-text theme-secondary btn-icon",
2564
+ "aria-label": e.t("retry"),
2565
+ onClick: (u) => e.channel.retry(t)
2566
+ }, n[1] || (n[1] = [
2567
+ p("svg", {
2568
+ width: "16",
2569
+ height: "16",
2570
+ viewBox: "0 0 16 16",
2571
+ fill: "none",
2572
+ stroke: "currentColor",
2573
+ "stroke-width": "1.5",
2574
+ "stroke-linecap": "round",
2575
+ "stroke-linejoin": "round",
2576
+ "aria-hidden": "true"
2577
+ }, [
2578
+ p("path", { d: "M13.5 3v3.5H10" }),
2579
+ p("path", { d: "M3.2 6.5A5.5 5.5 0 0 1 13 6.5M12.8 9.5A5.5 5.5 0 0 1 3 9.5M2.5 13V9.5H6" })
2580
+ ], -1)
2581
+ ]), 8, Xa)
2582
+ ])) : M("", !0),
2583
+ p("div", Ga, [
2584
+ e.channel.locked ? M("", !0) : (m(), h("button", {
2585
+ key: 0,
2586
+ type: "button",
2587
+ class: "btn-text theme-danger btn-icon",
2588
+ "aria-label": e.t("remove"),
2589
+ onClick: (u) => e.channel.remove(t)
2590
+ }, n[2] || (n[2] = [
2591
+ p("svg", {
2592
+ width: "16",
2593
+ height: "16",
2594
+ viewBox: "0 0 16 16",
2595
+ fill: "none",
2596
+ stroke: "currentColor",
2597
+ "stroke-width": "1.5",
2598
+ "stroke-linecap": "round",
2599
+ "stroke-linejoin": "round",
2600
+ "aria-hidden": "true"
2601
+ }, [
2602
+ p("path", { d: "M2.5 4.5h11M6 4.5V3a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v1.5M4 4.5l.6 8.1a1 1 0 0 0 1 .9h4.8a1 1 0 0 0 1-.9l.6-8.1" })
2603
+ ], -1)
2604
+ ]), 8, Wa))
2605
+ ])
2606
+ ])
2607
+ ])
2608
+ ]))), 128))
2609
+ ], 2)) : M("", !0)
2610
+ ], 512)) : M("", !0);
2611
+ }
2612
+ const gn = /* @__PURE__ */ L(Na, [["render", Qa]]), Ue = {
2613
+ en: {
2614
+ start: "Record voice",
2615
+ stop: "Stop recording",
2616
+ idle: "Click the microphone to record",
2617
+ starting: "Waiting for microphone permission…",
2618
+ recording: "Recording…",
2619
+ uploading: "Uploading…",
2620
+ retry: "Retry",
2621
+ remove: "Remove",
2622
+ denied: "Microphone access is blocked. Allow the microphone for this site (lock icon in the address bar, or the browser settings) and try again.",
2623
+ noDevice: "No microphone was found on this device. Connect a microphone and try again.",
2624
+ busy: "The microphone cannot be used. It may be in use by another app or tab. Close it and try again.",
2625
+ insecure: "Voice recording only works on secure pages (HTTPS).",
2626
+ unsupported: "This browser does not support voice recording.",
2627
+ recorder: "Recording failed. Please try again.",
2628
+ disconnected: "The microphone was disconnected. The audio recorded so far was kept.",
2629
+ tooShort: "The recording is too short.",
2630
+ unknown: "Could not start the recording.",
2631
+ uploadFailed: "Upload failed"
2632
+ },
2633
+ fa: {
2634
+ start: "ضبط صدا",
2635
+ stop: "پایان ضبط",
2636
+ idle: "برای ضبط روی میکروفن بزنید",
2637
+ starting: "در انتظار اجازه دسترسی به میکروفن…",
2638
+ recording: "در حال ضبط…",
2639
+ uploading: "در حال ارسال…",
2640
+ retry: "تلاش مجدد",
2641
+ remove: "حذف",
2642
+ denied: "دسترسی به میکروفن مسدود است. از آیکن قفل کنار آدرس (یا تنظیمات مرورگر) اجازه استفاده از میکروفن را برای این سایت فعال کنید و دوباره تلاش کنید.",
2643
+ noDevice: "میکروفنی روی این دستگاه پیدا نشد. یک میکروفن وصل کنید و دوباره تلاش کنید.",
2644
+ busy: "امکان استفاده از میکروفن نیست. ممکن است برنامه یا تب دیگری از آن استفاده کند. آن را ببندید و دوباره تلاش کنید.",
2645
+ insecure: "ضبط صدا فقط در صفحه‌های امن (HTTPS) کار می‌کند.",
2646
+ unsupported: "این مرورگر از ضبط صدا پشتیبانی نمی‌کند.",
2647
+ recorder: "ضبط با خطا مواجه شد. دوباره تلاش کنید.",
2648
+ disconnected: "میکروفن قطع شد. صدایی که تا این لحظه ضبط شده بود نگه داشته شد.",
2649
+ tooShort: "مدت ضبط خیلی کوتاه است.",
2650
+ unknown: "شروع ضبط ممکن نشد.",
2651
+ uploadFailed: "خطا در ارسال"
2652
+ }
2653
+ }, Ja = ["audio/ogg;codecs=opus", "audio/webm;codecs=opus", "audio/mp4", "audio/webm", "audio/ogg"];
2654
+ let He = 0;
2655
+ function rn() {
2656
+ return typeof MediaRecorder > "u" || !MediaRecorder.isTypeSupported ? "" : Ja.find((e) => MediaRecorder.isTypeSupported(e)) || "";
2657
+ }
2658
+ function Za(e = "") {
2659
+ return /ogg/.test(e) ? "ogg" : /webm/.test(e) ? "webm" : /mp4|aac|m4a/.test(e) ? "m4a" : /mpeg|mp3/.test(e) ? "mp3" : /wav/.test(e) ? "wav" : "audio";
2660
+ }
2661
+ function Ya(e) {
2662
+ switch (e == null ? void 0 : e.name) {
2663
+ case "NotAllowedError":
2664
+ case "PermissionDeniedError":
2665
+ return "denied";
2666
+ case "SecurityError":
2667
+ return typeof window < "u" && window.isSecureContext === !1 ? "insecure" : "denied";
2668
+ case "NotFoundError":
2669
+ case "DevicesNotFoundError":
2670
+ case "OverconstrainedError":
2671
+ case "ConstraintNotSatisfiedError":
2672
+ return "noDevice";
2673
+ case "NotReadableError":
2674
+ case "TrackStartError":
2675
+ case "AbortError":
2676
+ return "busy";
2677
+ default:
2678
+ return "unknown";
2679
+ }
2680
+ }
2681
+ const xa = F({
2682
+ name: "VoiceRecorderInput",
2683
+ components: { VoiceRecorderResultArea: gn },
2684
+ emits: ["update:modelValue", "change", "start", "stop", "recorded", "progress", "uploaded", "removed", "error"],
2685
+ props: {
2686
+ ...z,
2687
+ /** box | button */
2688
+ variant: { type: String, default: "box", validator: (e) => ["box", "button"].includes(e) },
2689
+ url: { type: String, default: "/upload" },
2690
+ /** Name of the multipart field. */
2691
+ fieldName: { type: String, default: "file" },
2692
+ multiple: { type: Boolean, default: !1 },
2693
+ headers: { type: Object, default: () => ({}) },
2694
+ /** Stop automatically after this many seconds. */
2695
+ maxDuration: { type: Number, default: null },
2696
+ /** Bitrate of the recording; 32 kbps opus is plenty for speech and keeps files tiny. */
2697
+ audioBitsPerSecond: { type: Number, default: 32e3 },
2698
+ audioConstraints: { type: Object, default: () => ({ echoCancellation: !0, noiseSuppression: !0, autoGainControl: !0 }) },
2699
+ /** Classes of the button (idle) … */
2700
+ buttonClass: { type: [String, Array, Object], default: "btn-solid theme-inverse" },
2701
+ /** … while there is a problem to show … */
2702
+ problemClass: { type: [String, Array, Object], default: "btn-solid theme-danger" },
2703
+ /** … and while recording. */
2704
+ recordingClass: { type: [String, Array, Object], default: "btn-solid theme-danger" },
2705
+ /** Show the list of recordings (in the built-in output, in `result-target` and in the result areas). */
2706
+ showList: { type: Boolean, default: !0 },
2707
+ /** Ask the server to delete the file (DELETE {url}) when a recording is removed. */
2708
+ deleteOnRemove: { type: Boolean, default: !0 },
2709
+ /** (storedValue) => playable URL — used for recordings that come from the form data (edit pages). */
2710
+ playbackUrl: { type: Function, default: (e) => e },
2711
+ /**
2712
+ * Key that <VoiceRecorderResultArea for="…"> uses to find this recorder. Defaults to `name`.
2713
+ * Set it when two recorders share the same name or have no name.
2714
+ */
2715
+ channel: { type: String, default: null },
2716
+ /** CSS selector (or element) the list and errors are moved into, e.g. "#voice-results". It must exist in the page. */
2717
+ resultTarget: { type: [String, Object], default: null },
2718
+ /** Force the built-in output on / off. null = automatic: hidden while a <VoiceRecorderResultArea> is attached. */
2719
+ inlineResults: { type: Boolean, default: null },
2720
+ startText: { type: String, default: null },
2721
+ stopText: { type: String, default: null },
2722
+ locale: { type: String, default: null }
2723
+ },
2724
+ setup(e, { emit: n, expose: a }) {
2725
+ const l = U(e, n), { locale: c } = Q(() => e.locale), i = Le(), t = (d) => (Ue[c.value] || Ue.en)[d] ?? Ue.en[d] ?? d, u = `voice-${++He}`, g = e.channel ?? e.name ?? u, $ = E(null), y = E([]), b = E(!1), w = E(!1), T = E(0), o = E(null), r = E(!0), s = E(!1), f = /* @__PURE__ */ new Map();
2726
+ let S = null, R = null, A = [], K = null, ee = 0, P = !1;
2727
+ const Se = C(() => e.readonly || l.isDisabled.value), Ie = C(() => We(T.value)), Ce = C(() => y.value.some((d) => d.status === "uploading")), ve = C(() => !r.value || Se.value), Te = C(() => (we[g] || 0) > 0), Me = C(() => !e.resultTarget && (e.inlineResults ?? !Te.value)), ge = C(
2728
+ () => b.value ? e.recordingClass : o.value ? e.problemClass : e.buttonClass
2729
+ ), Be = C(() => w.value ? t("starting") : b.value ? t("recording") : Ce.value ? t("uploading") : t("idle")), ye = C(
2730
+ () => b.value ? e.stopText ?? t("stop") : e.startText ?? t("start")
2731
+ );
2732
+ function Z(d, O, I = null) {
2733
+ o.value = { code: d, message: t(d) }, n("error", { code: d, message: o.value.message, error: O ?? null, item: I });
2734
+ }
2735
+ const ue = () => {
2736
+ o.value = null;
2737
+ }, Pe = () => {
2738
+ const d = l.model.value;
2739
+ return e.multiple ? Array.isArray(d) ? d : d ? [d] : [] : d ? [d] : [];
2740
+ };
2741
+ function ne(d) {
2742
+ const O = y.value.filter((B) => B.path).map((B) => B.path), I = e.multiple ? O : O[0] ?? null;
2743
+ l.model.value = I, l.emitChange(I, d);
2744
+ }
2745
+ function te() {
2746
+ const d = l.form.value;
2747
+ if (!d) return;
2748
+ const O = y.value.filter((I) => I.status === "uploading");
2749
+ d.uploading = O.length ? Math.min(99, Math.round(O.reduce((I, B) => I + B.percent, 0) / O.length)) : null;
2750
+ }
2751
+ function be(d) {
2752
+ d.local && d.src && URL.revokeObjectURL(d.src);
2753
+ }
2754
+ function de() {
2755
+ const d = Pe();
2756
+ !d.length && y.value.some((I) => I.path) && (y.value.filter((I) => I.path).forEach(be), y.value = y.value.filter((I) => !I.path));
2757
+ const O = new Set(y.value.map((I) => I.path).filter(Boolean));
2758
+ d.forEach((I) => {
2759
+ O.has(I) || y.value.push(
2760
+ ie({ id: `v${++He}`, path: I, src: e.playbackUrl(I), status: "done", percent: 100, seconds: null, error: "", local: !1, file: null })
2761
+ );
2762
+ });
2763
+ }
2764
+ J(() => {
2765
+ var d;
2766
+ s.value = !0, Aa(g, { owner: u, items: y, problem: o, locked: Se, t, remove: D, retry: k }), i.add(() => Oa(g, u)), r.value = typeof navigator < "u" && !!((d = navigator.mediaDevices) != null && d.getUserMedia) && typeof MediaRecorder < "u", r.value ? X() : Z(typeof window < "u" && window.isSecureContext === !1 ? "insecure" : "unsupported"), de();
2767
+ }), H(() => l.model.value, de, { deep: !0 });
2768
+ async function X() {
2769
+ var d;
2770
+ try {
2771
+ const O = await ((d = navigator.permissions) == null ? void 0 : d.query({ name: "microphone" }));
2772
+ if (!O || i.isDisposed()) return;
2773
+ const I = () => {
2774
+ var B;
2775
+ O.state === "denied" ? Z("denied") : ((B = o.value) == null ? void 0 : B.code) === "denied" && ue();
2776
+ };
2777
+ I(), O.addEventListener("change", I), i.add(() => O.removeEventListener("change", I));
2778
+ } catch {
2779
+ }
2780
+ }
2781
+ function ce() {
2782
+ R == null || R.getTracks().forEach((d) => d.stop()), R = null;
2783
+ }
2784
+ function ze() {
2785
+ T.value = (Date.now() - ee) / 1e3, e.maxDuration && T.value >= e.maxDuration && x();
2786
+ }
2787
+ async function Ee() {
2788
+ if (b.value || w.value || ve.value) return;
2789
+ ue(), w.value = !0;
2790
+ let d;
2791
+ try {
2792
+ d = await navigator.mediaDevices.getUserMedia({
2793
+ audio: Object.keys(e.audioConstraints || {}).length ? e.audioConstraints : !0
2794
+ });
2795
+ } catch (B) {
2796
+ return w.value = !1, Z(Ya(B), B);
2797
+ }
2798
+ if (w.value = !1, i.isDisposed()) {
2799
+ d.getTracks().forEach((B) => B.stop());
2800
+ return;
2801
+ }
2802
+ const O = rn();
2803
+ let I;
2804
+ try {
2805
+ I = new MediaRecorder(d, { ...O ? { mimeType: O } : {}, audioBitsPerSecond: e.audioBitsPerSecond });
2806
+ } catch {
2807
+ try {
2808
+ I = new MediaRecorder(d);
2809
+ } catch (N) {
2810
+ return d.getTracks().forEach((Y) => Y.stop()), Z("recorder", N);
2811
+ }
2812
+ }
2813
+ R = d, S = I, A = [], P = !1, I.ondataavailable = (B) => {
2814
+ var N;
2815
+ (N = B.data) != null && N.size && A.push(B.data);
2816
+ }, I.onerror = (B) => {
2817
+ P = !0, Z("recorder", B.error), x();
2818
+ }, I.onstop = () => fe(I), d.getAudioTracks().forEach(
2819
+ (B) => B.addEventListener("ended", () => {
2820
+ b.value && (Z("disconnected"), x());
2821
+ })
2822
+ ), I.start(500), ee = Date.now(), T.value = 0, b.value = !0, K = setInterval(ze, 250), n("start");
2823
+ }
2824
+ function x() {
2825
+ if (clearInterval(K), K = null, S && S.state !== "inactive")
2826
+ try {
2827
+ S.stop();
2828
+ } catch {
2829
+ fe(S);
2830
+ }
2831
+ b.value = !1;
2832
+ }
2833
+ function fe(d) {
2834
+ clearInterval(K), K = null, b.value = !1;
2835
+ const O = (Date.now() - ee) / 1e3, I = A;
2836
+ if (A = [], ce(), S = null, P) return;
2837
+ n("stop", O);
2838
+ const B = d.mimeType || rn() || "audio/webm", N = new Blob(I, { type: B });
2839
+ if (!N.size || O < 0.4) return Z("tooShort");
2840
+ v(N, O);
2841
+ }
2842
+ function Ae() {
2843
+ return b.value ? x() : Ee();
2844
+ }
2845
+ function v(d, O) {
2846
+ e.multiple || y.value.slice().forEach((N) => D(N, !1));
2847
+ const I = new File([d], `voice-${Date.now()}.${Za(d.type)}`, { type: d.type }), B = ie({
2848
+ id: `v${++He}`,
2849
+ file: I,
2850
+ src: URL.createObjectURL(I),
2851
+ seconds: Math.round(O),
2852
+ status: "uploading",
2853
+ percent: 0,
2854
+ path: null,
2855
+ error: "",
2856
+ local: !0
2857
+ });
2858
+ y.value = [...y.value, B], n("recorded", B), k(B);
2859
+ }
2860
+ function k(d) {
2861
+ d.status = "uploading", d.percent = 0, d.error = "", te();
2862
+ const O = new FormData();
2863
+ O.append(e.fieldName, d.file, d.file.name);
2864
+ const I = new XMLHttpRequest();
2865
+ f.set(d.id, I), I.open("POST", e.url), Object.entries(De(e.headers)).forEach(([N, Y]) => I.setRequestHeader(N, Y)), I.upload.onprogress = (N) => {
2866
+ N.lengthComputable && (d.percent = Math.round(N.loaded / N.total * 100), n("progress", d, d.percent), te());
2867
+ };
2868
+ const B = (N) => {
2869
+ f.delete(d.id), d.status = "error", d.error = N || t("uploadFailed"), te(), Z("uploadFailed", null, d), o.value = { code: "uploadFailed", message: d.error };
2870
+ };
2871
+ I.onerror = () => B(), I.onload = () => {
2872
+ let N = null;
2873
+ try {
2874
+ N = JSON.parse(I.responseText);
2875
+ } catch {
2876
+ }
2877
+ if (I.status < 200 || I.status >= 300) {
2878
+ const Oe = N != null && N.errors ? Object.values(N.errors)[0] : null;
2879
+ return B((N == null ? void 0 : N.message) || (Array.isArray(Oe) ? Oe[0] : Oe));
2880
+ }
2881
+ const Y = (N == null ? void 0 : N.data) ?? N, Ye = (Y == null ? void 0 : Y.path) ?? (Y == null ? void 0 : Y.url);
2882
+ if (!Ye) return B();
2883
+ f.delete(d.id), d.path = Ye, d.status = "done", d.percent = 100, te(), ue(), ne(), n("uploaded", d, N);
2884
+ }, I.send(O);
2885
+ }
2886
+ async function D(d, O = !0) {
2887
+ var I;
2888
+ if ((I = f.get(d.id)) == null || I.abort(), f.delete(d.id), be(d), y.value = y.value.filter((B) => B.id !== d.id), te(), d.path && (ne(), e.deleteOnRemove))
2889
+ try {
2890
+ await fetch(e.url, {
2891
+ method: "DELETE",
2892
+ headers: De(e.headers),
2893
+ credentials: "same-origin",
2894
+ body: d.path
2895
+ });
2896
+ } catch {
2897
+ }
2898
+ O && n("removed", d);
2899
+ }
2900
+ return i.add(() => {
2901
+ if (P = !0, clearInterval(K), S && S.state !== "inactive")
2902
+ try {
2903
+ S.stop();
2904
+ } catch {
2905
+ }
2906
+ ce(), f.forEach((d) => d.abort()), f.clear(), y.value.forEach(be), l.form.value && (l.form.value.uploading = null);
2907
+ }), a({ start: Ee, stop: x, toggle: Ae, channel: g }), {
2908
+ ...l,
2909
+ t,
2910
+ root: $,
2911
+ items: y,
2912
+ recording: b,
2913
+ starting: w,
2914
+ seconds: T,
2915
+ time: Ie,
2916
+ problem: o,
2917
+ supported: r,
2918
+ blocked: ve,
2919
+ mounted: s,
2920
+ channelKey: g,
2921
+ showInline: Me,
2922
+ stateClass: ge,
2923
+ statusText: Be,
2924
+ buttonLabel: ye,
2925
+ toggle: Ae,
2926
+ formatTime: We
2927
+ };
2928
+ }
2929
+ }), _a = ["id"], eo = {
2930
+ key: 0,
2931
+ class: "voice-recorder-box p-5"
2932
+ }, no = { class: "card-body" }, to = { class: "row gx-5" }, lo = {
2933
+ key: 0,
2934
+ class: "col-auto mx-auto"
2935
+ }, ao = { class: "col-12 text-center" }, oo = { class: "row gx-5 align-items-center" }, ro = { class: "col-auto" }, so = ["disabled", "aria-label", "aria-pressed"], io = {
2936
+ key: 0,
2937
+ class: "spinner-border spinner-sm",
2938
+ role: "status",
2939
+ "aria-hidden": "true"
2940
+ }, uo = {
2941
+ key: 1,
2942
+ width: "18",
2943
+ height: "18",
2944
+ viewBox: "0 0 16 16",
2945
+ fill: "currentColor",
2946
+ "aria-hidden": "true"
2947
+ }, co = {
2948
+ key: 2,
2949
+ width: "18",
2950
+ height: "18",
2951
+ viewBox: "0 0 16 16",
2952
+ fill: "none",
2953
+ stroke: "currentColor",
2954
+ "stroke-width": "1.5",
2955
+ "stroke-linecap": "round",
2956
+ "stroke-linejoin": "round",
2957
+ "aria-hidden": "true"
2958
+ }, fo = { class: "col" }, mo = { class: "flex-grow-1 text-center" }, po = {
2959
+ class: "fw-semibold",
2960
+ role: "status",
2961
+ "aria-live": "polite"
2962
+ }, ho = {
2963
+ class: "fg-secondary fanum",
2964
+ dir: "ltr"
2965
+ }, vo = {
2966
+ key: 0,
2967
+ class: "col-auto"
2968
+ }, go = ["disabled", "aria-pressed"], yo = {
2969
+ key: 0,
2970
+ class: "spinner-border spinner-sm me-2",
2971
+ role: "status",
2972
+ "aria-hidden": "true"
2973
+ }, bo = {
2974
+ key: 1,
2975
+ class: "me-2",
2976
+ width: "16",
2977
+ height: "16",
2978
+ viewBox: "0 0 16 16",
2979
+ fill: "currentColor",
2980
+ "aria-hidden": "true"
2981
+ }, $o = {
2982
+ key: 2,
2983
+ class: "me-2",
2984
+ width: "16",
2985
+ height: "16",
2986
+ viewBox: "0 0 16 16",
2987
+ fill: "none",
2988
+ stroke: "currentColor",
2989
+ "stroke-width": "1.5",
2990
+ "stroke-linecap": "round",
2991
+ "stroke-linejoin": "round",
2992
+ "aria-hidden": "true"
2993
+ }, wo = {
2994
+ key: 3,
2995
+ class: "ms-2 fanum",
2996
+ dir: "ltr"
2997
+ };
2998
+ function ko(e, n, a, l, c, i) {
2999
+ const t = oe("VoiceRecorderResultArea");
3000
+ return m(), h("div", {
3001
+ ref: "root",
3002
+ class: q(["voice-recorder", { "is-invalid": e.isInvalid }]),
3003
+ id: e.inputId
3004
+ }, [
3005
+ e.variant === "box" ? (m(), h("div", eo, [
3006
+ p("div", no, [
3007
+ p("div", to, [
3008
+ e.showInline && e.problem ? (m(), h("div", lo, [
3009
+ Ne(t, {
3010
+ for: e.channelKey,
3011
+ internal: "",
3012
+ "show-list": !1,
3013
+ "alert-class": "alert theme-danger p-1 text-center mb-4"
3014
+ }, null, 8, ["for"])
3015
+ ])) : M("", !0),
3016
+ p("div", ao, [
3017
+ p("div", {
3018
+ class: "btn btn-subtle mx-auto p-3",
3019
+ onClick: n[0] || (n[0] = (...u) => e.toggle && e.toggle(...u))
3020
+ }, [
3021
+ p("div", oo, [
3022
+ p("div", ro, [
3023
+ p("button", {
3024
+ type: "button",
3025
+ class: q(["btn", e.stateClass]),
3026
+ disabled: e.blocked || e.starting,
3027
+ "aria-label": e.buttonLabel,
3028
+ "aria-pressed": e.recording
3029
+ }, [
3030
+ e.starting ? (m(), h("span", io)) : e.recording ? (m(), h("svg", uo, n[2] || (n[2] = [
3031
+ p("rect", {
3032
+ x: "3.5",
3033
+ y: "3.5",
3034
+ width: "9",
3035
+ height: "9",
3036
+ rx: "1.5"
3037
+ }, null, -1)
3038
+ ]))) : (m(), h("svg", co, n[3] || (n[3] = [
3039
+ p("rect", {
3040
+ x: "5.5",
3041
+ y: "1.5",
3042
+ width: "5",
3043
+ height: "8",
3044
+ rx: "2.5"
3045
+ }, null, -1),
3046
+ p("path", { d: "M3 7.5a5 5 0 0 0 10 0M8 12.5v2" }, null, -1)
3047
+ ])))
3048
+ ], 10, so)
3049
+ ]),
3050
+ p("div", fo, [
3051
+ p("div", mo, [
3052
+ p("div", po, V(e.statusText), 1),
3053
+ p("div", ho, [
3054
+ _(V(e.time) + " ", 1),
3055
+ e.maxDuration ? (m(), h(G, { key: 0 }, [
3056
+ _(" / " + V(e.formatTime(e.maxDuration)), 1)
3057
+ ], 64)) : M("", !0)
3058
+ ])
3059
+ ])
3060
+ ]),
3061
+ e.recording ? (m(), h("div", vo, n[4] || (n[4] = [
3062
+ p("span", {
3063
+ class: "spinner-grow spinner-sm fg-danger",
3064
+ role: "status",
3065
+ "aria-hidden": "true"
3066
+ }, null, -1)
3067
+ ]))) : M("", !0)
3068
+ ])
3069
+ ])
3070
+ ])
3071
+ ]),
3072
+ e.showInline && e.showList ? (m(), le(t, {
3073
+ key: 0,
3074
+ class: "d-block mt-2",
3075
+ for: e.channelKey,
3076
+ internal: "",
3077
+ "show-problem": !1
3078
+ }, null, 8, ["for"])) : M("", !0)
3079
+ ])
3080
+ ])) : (m(), h(G, { key: 1 }, [
3081
+ p("button", {
3082
+ type: "button",
3083
+ disabled: e.blocked || e.starting,
3084
+ "aria-pressed": e.recording,
3085
+ class: q(e.stateClass),
3086
+ onClick: n[1] || (n[1] = (...u) => e.toggle && e.toggle(...u))
3087
+ }, [
3088
+ j(e.$slots, "default", {
3089
+ recording: e.recording,
3090
+ starting: e.starting,
3091
+ seconds: e.seconds,
3092
+ time: e.time
3093
+ }, () => [
3094
+ e.starting ? (m(), h("span", yo)) : e.recording ? (m(), h("svg", bo, n[5] || (n[5] = [
3095
+ p("rect", {
3096
+ x: "3.5",
3097
+ y: "3.5",
3098
+ width: "9",
3099
+ height: "9",
3100
+ rx: "1.5"
3101
+ }, null, -1)
3102
+ ]))) : (m(), h("svg", $o, n[6] || (n[6] = [
3103
+ p("rect", {
3104
+ x: "5.5",
3105
+ y: "1.5",
3106
+ width: "5",
3107
+ height: "8",
3108
+ rx: "2.5"
3109
+ }, null, -1),
3110
+ p("path", { d: "M3 7.5a5 5 0 0 0 10 0M8 12.5v2" }, null, -1)
3111
+ ]))),
3112
+ _(" " + V(e.buttonLabel) + " ", 1),
3113
+ e.recording ? (m(), h("span", wo, V(e.time), 1)) : M("", !0)
3114
+ ])
3115
+ ], 10, go),
3116
+ e.showInline ? (m(), le(t, {
3117
+ key: 0,
3118
+ class: "d-block mt-2",
3119
+ for: e.channelKey,
3120
+ internal: "",
3121
+ "show-list": e.showList
3122
+ }, null, 8, ["for", "show-list"])) : M("", !0)
3123
+ ], 64)),
3124
+ e.resultTarget && e.mounted ? (m(), le(wn, {
3125
+ key: 2,
3126
+ to: e.resultTarget
3127
+ }, [
3128
+ Ne(t, {
3129
+ for: e.channelKey,
3130
+ internal: "",
3131
+ "show-list": e.showList
3132
+ }, null, 8, ["for", "show-list"])
3133
+ ], 8, ["to"])) : M("", !0)
3134
+ ], 10, _a);
3135
+ }
3136
+ const So = /* @__PURE__ */ L(xa, [["render", ko]]);
3137
+ function Vo() {
3138
+ const e = pe("form", null), n = pe("formApi", null);
3139
+ return {
3140
+ form: e,
3141
+ submit: (...a) => {
3142
+ var l;
3143
+ return (l = n == null ? void 0 : n.submit) == null ? void 0 : l.call(n, ...a);
3144
+ },
3145
+ reset: () => {
3146
+ var a;
3147
+ return (a = n == null ? void 0 : n.reset) == null ? void 0 : a.call(n);
3148
+ }
3149
+ };
3150
+ }
3151
+ const Io = cn, Co = vn, To = Ze, Mo = {
3152
+ AmountInput: An,
3153
+ CaptchaInput: Ln,
3154
+ VoiceRecorderInput: So,
3155
+ VoiceRecorderResultArea: gn,
3156
+ CheckboxButtonInput: zn,
3157
+ CheckboxInput: Wn,
3158
+ CheckboxToggle: xn,
3159
+ ChipsInput: ot,
3160
+ ComboboxInput: cn,
3161
+ EmailInput: At,
3162
+ FileInput: fn,
3163
+ FormAdornInput: Ze,
3164
+ FormContainer: rl,
3165
+ FormField: gl,
3166
+ FormLabel: mn,
3167
+ GroupControl: pn,
3168
+ MobileInput: Sl,
3169
+ MultiQuantityInput: jl,
3170
+ OTPInput: Kl,
3171
+ PasswordInput: _l,
3172
+ QuantityInput: hn,
3173
+ RangeInput: vn,
3174
+ SimpleUploader: ra,
3175
+ StarRatingInput: fa,
3176
+ SubmitButton: ya,
3177
+ SwitchInput: Ca,
3178
+ TextAreaInput: Ea,
3179
+ TextInput: je,
3180
+ // aliases
3181
+ Select2Input: Io,
3182
+ RangeSliderInput: Co,
3183
+ FormAdorn: To
3184
+ }, No = {
3185
+ install(e, n = {}) {
3186
+ (n.locale || n.messages) && kn(n), n.bootstrap && _n(n.bootstrap), Object.entries(Mo).forEach(([a, l]) => e.component(a, l));
3187
+ }
3188
+ };
3189
+ export {
3190
+ An as AmountInput,
3191
+ Ln as CaptchaInput,
3192
+ zn as CheckboxButtonInput,
3193
+ Wn as CheckboxInput,
3194
+ xn as CheckboxToggle,
3195
+ ot as ChipsInput,
3196
+ cn as ComboboxInput,
3197
+ At as EmailInput,
3198
+ fn as FileInput,
3199
+ To as FormAdorn,
3200
+ Ze as FormAdornInput,
3201
+ rl as FormContainer,
3202
+ gl as FormField,
3203
+ mn as FormLabel,
3204
+ pn as GroupControl,
3205
+ Sl as MobileInput,
3206
+ jl as MultiQuantityInput,
3207
+ Kl as OTPInput,
3208
+ _l as PasswordInput,
3209
+ hn as QuantityInput,
3210
+ vn as RangeInput,
3211
+ Co as RangeSliderInput,
3212
+ Io as Select2Input,
3213
+ ra as SimpleUploader,
3214
+ fa as StarRatingInput,
3215
+ ya as SubmitButton,
3216
+ Ca as SwitchInput,
3217
+ Ea as TextAreaInput,
3218
+ je as TextInput,
3219
+ So as VoiceRecorderInput,
3220
+ gn as VoiceRecorderResultArea,
3221
+ _n as configureBootstrap,
3222
+ kn as configureI18n,
3223
+ No as default,
3224
+ z as fieldProps,
3225
+ Je as toEnglishDigits,
3226
+ he as useBsInstance,
3227
+ Le as useDisposables,
3228
+ U as useField,
3229
+ Vo as useFormApi
3230
+ };