@i18n-micro/vue 1.4.0 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,759 +1,683 @@
1
- import { defineComponent as G, inject as S, h as g, computed as k, ref as Q, onMounted as ae, onUnmounted as oe, nextTick as re, shallowRef as z } from "vue";
2
- import { BaseI18n as le } from "@i18n-micro/core";
3
- import { FormatService as Se, defaultPlural as we, interpolate as ke } from "@i18n-micro/core";
4
- const W = /* @__PURE__ */ Symbol("i18n"), Y = /* @__PURE__ */ Symbol("i18n-locales"), ee = /* @__PURE__ */ Symbol("i18n-default-locale"), U = /* @__PURE__ */ Symbol("i18n-router-strategy"), ie = G({
5
- name: "I18nGroup",
6
- props: {
7
- prefix: {
8
- type: String,
9
- required: !0
10
- },
11
- groupClass: {
12
- type: String,
13
- default: ""
14
- }
15
- },
16
- setup(t, { slots: e }) {
17
- const a = S(W);
18
- if (!a)
19
- throw new Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
20
- const o = (c, r) => a.t(`${t.prefix}.${c}`, r, void 0, a.getRoute());
21
- return () => g(
22
- "div",
23
- {
24
- class: ["i18n-group", t.groupClass]
25
- },
26
- e.default?.({ prefix: t.prefix, t: o })
27
- );
28
- }
29
- }), ce = G({
30
- name: "I18nLink",
31
- props: {
32
- to: {
33
- type: [String, Object],
34
- required: !0
35
- },
36
- activeStyle: {
37
- type: Object,
38
- default: () => ({})
39
- },
40
- localeRoute: {
41
- type: Function,
42
- default: void 0
43
- }
44
- },
45
- setup(t, { slots: e }) {
46
- const a = S(W), o = S(U, void 0);
47
- if (!a)
48
- throw new Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");
49
- const c = k(() => typeof t.to == "string" ? /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to) : !1), r = k(() => {
50
- if (c.value)
51
- return t.to;
52
- if (t.localeRoute) {
53
- const n = t.localeRoute(t.to);
54
- return typeof n == "string" ? n : n.path || "/";
55
- }
56
- if (!o?.resolvePath)
57
- return typeof t.to == "string" ? t.to : t.to.path || "/";
58
- const i = o.resolvePath(t.to, a.locale.value);
59
- return typeof i == "string" ? i : i.path || "/";
60
- }), u = k(() => {
61
- if (c.value || !o)
62
- return !1;
63
- const i = o.getCurrentPath().replace(/#.*$/, "").replace(/\/$/, ""), n = r.value.replace(/#.*$/, "").replace(/\/$/, "");
64
- return i === n;
65
- }), f = k(() => u.value ? t.activeStyle : {});
66
- return () => c.value ? g(
67
- "a",
68
- {
69
- href: r.value,
70
- target: "_blank",
71
- rel: "noopener noreferrer",
72
- style: f.value
73
- },
74
- e.default?.()
75
- ) : o?.linkComponent ? g(
76
- o.linkComponent,
77
- {
78
- to: r.value,
79
- style: f.value
80
- },
81
- { default: e.default }
82
- ) : g(
83
- "a",
84
- {
85
- href: r.value,
86
- style: f.value,
87
- onClick: (i) => {
88
- i.preventDefault(), o ? o.push({ path: r.value }) : window.location.href = r.value;
89
- }
90
- },
91
- e.default?.()
92
- );
93
- }
94
- }), se = G({
95
- name: "I18nSwitcher",
96
- props: {
97
- customLabels: {
98
- type: Object,
99
- default: () => ({})
100
- },
101
- customWrapperStyle: {
102
- type: Object,
103
- default: () => ({})
104
- },
105
- customButtonStyle: {
106
- type: Object,
107
- default: () => ({})
108
- },
109
- customDropdownStyle: {
110
- type: Object,
111
- default: () => ({})
112
- },
113
- customItemStyle: {
114
- type: Object,
115
- default: () => ({})
116
- },
117
- customLinkStyle: {
118
- type: Object,
119
- default: () => ({})
120
- },
121
- customActiveLinkStyle: {
122
- type: Object,
123
- default: () => ({})
124
- },
125
- /**
126
- * Inline style applied to the switcher button when the *current* locale is
127
- * marked as `disabled: true` in the locale config.
128
- *
129
- * Note: disabled locales are omitted from the dropdown list, but the current
130
- * locale label is still shown on the button.
131
- */
132
- customDisabledLinkStyle: {
133
- type: Object,
134
- default: () => ({})
135
- },
136
- customIconStyle: {
137
- type: Object,
138
- default: () => ({})
139
- },
140
- locales: {
141
- type: Array,
142
- default: void 0
143
- },
144
- currentLocale: {
145
- type: [String, Function],
146
- default: void 0
147
- },
148
- getLocaleName: {
149
- type: Function,
150
- default: void 0
151
- },
152
- switchLocale: {
153
- type: Function,
154
- default: void 0
155
- },
156
- localeRoute: {
157
- type: Function,
158
- default: void 0
159
- }
160
- },
161
- setup(t, { slots: e }) {
162
- const a = S(W), o = S(U, void 0), c = S(Y, void 0);
163
- if (!a)
164
- throw new Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");
165
- if (!c && !t.locales)
166
- throw new Error(
167
- "[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop."
168
- );
169
- const r = k(() => t.locales || c || []), u = k(() => r.value.filter((s) => !s.disabled)), f = k(() => t.currentLocale !== void 0 ? typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale : a.locale.value), i = k(() => r.value.some((s) => s.code === f.value && s.disabled)), n = k(() => t.getLocaleName ? t.getLocaleName() || null : r.value.find((m) => m.code === a.locale.value)?.displayName || null), l = Q(!1), y = Q(null), p = (s) => {
170
- s && (s.stopPropagation(), s.preventDefault()), l.value = !l.value;
171
- }, L = (s) => t.customLabels[s.code] || s.displayName || s.code, T = k(() => {
172
- const s = r.value.find((m) => m.code === f.value);
173
- return s ? L(s) : n.value || f.value;
174
- }), P = async (s) => {
175
- if (l.value = !1, await re(), t.switchLocale) {
176
- t.switchLocale(s);
177
- return;
178
- }
179
- if (a.locale.value = s, !o)
180
- return;
181
- const m = o.getCurrentPath(), b = t.localeRoute ? (() => {
182
- const d = t.localeRoute(m, s);
183
- return typeof d == "string" ? d : d.path || "/";
184
- })() : o?.resolvePath ? (() => {
185
- const d = o.resolvePath(m, s);
186
- return typeof d == "string" ? d : d.path || "/";
187
- })() : m;
188
- o.push({ path: b });
189
- }, $ = {
190
- position: "relative",
191
- display: "inline-block",
192
- verticalAlign: "middle"
193
- }, M = {
194
- padding: "4px 12px",
195
- fontSize: "16px",
196
- cursor: "pointer",
197
- backgroundColor: "#fff",
198
- border: "1px solid #333",
199
- transition: "background-color 0.3s ease",
200
- display: "flex",
201
- alignItems: "center",
202
- justifyContent: "space-between"
203
- }, D = {
204
- position: "absolute",
205
- top: "100%",
206
- left: "0",
207
- zIndex: 1e3,
208
- backgroundColor: "#fff",
209
- border: "1px solid #333",
210
- listStyle: "none",
211
- padding: "0",
212
- margin: "4px 0 0 0",
213
- minWidth: "150px",
214
- boxShadow: "0 2px 8px rgba(0,0,0,0.15)"
215
- }, _ = {
216
- margin: "0",
217
- padding: "0"
218
- }, R = {
219
- display: "block",
220
- padding: "8px 12px",
221
- color: "#333",
222
- textDecoration: "none",
223
- transition: "background-color 0.3s ease",
224
- cursor: "pointer"
225
- }, Z = {
226
- fontWeight: "bold",
227
- color: "#007bff",
228
- // Current locale is not a meaningful switch target
229
- cursor: "not-allowed"
230
- }, V = {
231
- marginLeft: "8px",
232
- display: "inline-block",
233
- transition: "transform 0.3s ease"
234
- }, F = {
235
- transform: "rotate(180deg)"
236
- }, v = (s) => s ? Array.isArray(s) ? s : [s] : [], O = (s) => {
237
- if (!l.value) return;
238
- const m = s.target;
239
- if (!m || !y.value) return;
240
- const b = y.value.contains(m), d = m.closest(".i18n-switcher-button") !== null;
241
- !b && !d && (l.value = !1);
242
- };
243
- return ae(() => {
244
- document.addEventListener("click", O);
245
- }), oe(() => {
246
- document.removeEventListener("click", O);
247
- }), () => {
248
- const s = [];
249
- e["before-button"] && s.push(...v(e["before-button"]()));
250
- const m = [];
251
- if (e["before-selected-locale"] && m.push(...v(e["before-selected-locale"]())), m.push(g("span", T.value)), e["after-selected-locale"] && m.push(...v(e["after-selected-locale"]())), m.push(
252
- g(
253
- "span",
254
- {
255
- style: {
256
- ...V,
257
- ...l.value ? F : {},
258
- ...t.customIconStyle
259
- }
260
- },
261
- "▼"
262
- )
263
- ), s.push(
264
- g(
265
- "button",
266
- {
267
- class: "i18n-switcher-button",
268
- style: {
269
- ...M,
270
- ...t.customButtonStyle,
271
- ...i.value ? t.customDisabledLinkStyle : {}
272
- },
273
- onClick: (b) => {
274
- b.preventDefault(), b.stopPropagation(), p(b);
275
- },
276
- type: "button",
277
- ariaHaspopup: !0,
278
- ariaExpanded: l.value
279
- },
280
- m
281
- )
282
- ), e["before-dropdown"] && s.push(...v(e["before-dropdown"]())), l.value) {
283
- const b = [];
284
- e["before-dropdown-items"] && b.push(...v(e["before-dropdown-items"]())), u.value.forEach((d) => {
285
- const A = [];
286
- e["before-item"] && A.push(...v(e["before-item"]({ locale: d })));
287
- const E = [];
288
- e["before-link-content"] && E.push(...v(e["before-link-content"]({ locale: d }))), E.push(L(d)), e["after-link-content"] && E.push(...v(e["after-link-content"]({ locale: d })));
289
- const H = typeof window < "u" ? window.location.pathname : "/", B = t.localeRoute ? t.localeRoute(H, d.code) : o?.resolvePath ? o.resolvePath(H, d.code) : H, j = typeof B == "string" ? B : B.path || "#", N = d.code === f.value;
290
- A.push(
291
- g(
292
- "a",
293
- {
294
- class: `switcher-locale-${d.code}`,
295
- href: typeof j == "string" ? j : "#",
296
- style: {
297
- ...R,
298
- ...N ? Z : {},
299
- ...t.customLinkStyle,
300
- // active-specific customization wins over the generic link style
301
- // (matches the React/Preact/Solid switchers)
302
- ...N ? t.customActiveLinkStyle : {}
303
- },
304
- // Prevent default navigation, use only handleSwitchLocale
305
- onClick: (K) => {
306
- K.preventDefault(), K.stopPropagation(), P(d.code);
307
- }
308
- },
309
- E
310
- )
311
- ), e["after-item"] && A.push(...v(e["after-item"]({ locale: d }))), b.push(
312
- g(
313
- "li",
314
- {
315
- key: d.code,
316
- style: { ..._, ...t.customItemStyle }
317
- },
318
- A
319
- )
320
- );
321
- }), e["after-dropdown-items"] && b.push(...v(e["after-dropdown-items"]())), s.push(
322
- g(
323
- "ul",
324
- {
325
- class: "i18n-switcher-dropdown",
326
- style: { ...D, ...t.customDropdownStyle }
327
- },
328
- b
329
- )
330
- );
331
- }
332
- return e["after-dropdown"] && s.push(...v(e["after-dropdown"]())), g(
333
- "div",
334
- {
335
- ref: y,
336
- class: "i18n-switcher-wrapper",
337
- style: { ...$, ...t.customWrapperStyle }
338
- },
339
- s
340
- );
341
- };
342
- }
343
- }), ue = G({
344
- name: "I18nT",
345
- props: {
346
- keypath: {
347
- type: String,
348
- required: !0
349
- },
350
- plural: {
351
- type: [Number, String]
352
- },
353
- tag: {
354
- type: String,
355
- default: "span"
356
- },
357
- params: {
358
- type: Object,
359
- default: () => ({})
360
- },
361
- defaultValue: {
362
- type: String,
363
- default: ""
364
- },
365
- html: {
366
- type: Boolean,
367
- default: !1
368
- },
369
- hideIfEmpty: {
370
- type: Boolean,
371
- default: !1
372
- },
373
- customPluralRule: {
374
- type: Function,
375
- default: null
376
- },
377
- number: {
378
- type: [Number, String]
379
- },
380
- date: {
381
- type: [Date, String, Number]
382
- },
383
- relativeDate: {
384
- type: [Date, String, Number]
385
- }
386
- },
387
- setup(t, { slots: e, attrs: a }) {
388
- const o = S(W);
389
- if (!o)
390
- throw new Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
391
- return () => {
392
- const c = {}, r = o.getRoute();
393
- if (t.number !== void 0) {
394
- const n = Number(t.number), l = o.tn(n), y = o.t(t.keypath, { number: l, ...t.params }, void 0, r);
395
- return g(t.tag, { ...a, innerHTML: y });
396
- }
397
- if (t.date !== void 0) {
398
- const n = o.td(t.date), l = o.t(t.keypath, { date: n, ...t.params }, void 0, r);
399
- return g(t.tag, { ...a, innerHTML: l });
400
- }
401
- if (t.relativeDate !== void 0) {
402
- const n = o.tdr(t.relativeDate), l = o.t(t.keypath, { relativeDate: n, ...t.params }, void 0, r);
403
- return g(t.tag, { ...a, innerHTML: l });
404
- }
405
- if (t.plural !== void 0) {
406
- const n = Number.parseInt(t.plural.toString(), 10);
407
- if (t.customPluralRule) {
408
- const l = t.customPluralRule(
409
- t.keypath,
410
- n,
411
- t.params,
412
- o.locale.value,
413
- (y, p, L) => o.t(y, p, L, r)
414
- );
415
- return g(t.tag, { ...a, innerHTML: l || "" });
416
- } else {
417
- const l = o.tc(t.keypath, { count: n, ...t.params });
418
- return g(t.tag, { ...a, innerHTML: l });
419
- }
420
- }
421
- const u = (o.t(t.keypath, { ...t.params, ...c }, void 0, r) ?? "").toString();
422
- if (t.hideIfEmpty && !u.trim())
423
- return t.defaultValue ?? null;
424
- if (t.html)
425
- return g(t.tag, { ...a, innerHTML: u });
426
- if (e.default)
427
- return g(t.tag, a, e.default({ translation: u }));
428
- const f = [];
429
- let i = 0;
430
- for (const [n, l] of Object.entries(e)) {
431
- if (n === "default") continue;
432
- const y = `{${n}}`, p = u.indexOf(y, i);
433
- p !== -1 && (p > i && f.push(u.slice(i, p)), l && f.push(g(l)), i = p + y.length);
434
- }
435
- return i < u.length && f.push(u.slice(i)), e.default ? g(t.tag, a, e.default({ children: f })) : f.length > 0 ? g(t.tag, a, f) : g(t.tag, a, u);
436
- };
437
- }
1
+ import { computed as e, defineComponent as t, h as n, inject as r, nextTick as i, onMounted as a, onUnmounted as o, ref as s, shallowRef as c } from "vue";
2
+ import { BaseI18n as l, FormatService as u, defaultPlural as d, interpolate as f } from "@i18n-micro/core";
3
+ //#region src/injection.ts
4
+ var p = Symbol("i18n"), m = Symbol("i18n-locales"), h = Symbol("i18n-default-locale"), g = Symbol("i18n-router-strategy"), _ = t({
5
+ name: "I18nGroup",
6
+ props: {
7
+ prefix: {
8
+ type: String,
9
+ required: !0
10
+ },
11
+ groupClass: {
12
+ type: String,
13
+ default: ""
14
+ }
15
+ },
16
+ setup(e, { slots: t }) {
17
+ let i = r(p);
18
+ if (!i) throw Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
19
+ let a = (t, n) => i.t(`${e.prefix}.${t}`, n, void 0, i.getRoute());
20
+ return () => n("div", { class: ["i18n-group", e.groupClass] }, t.default?.({
21
+ prefix: e.prefix,
22
+ t: a
23
+ }));
24
+ }
25
+ }), v = t({
26
+ name: "I18nLink",
27
+ props: {
28
+ to: {
29
+ type: [String, Object],
30
+ required: !0
31
+ },
32
+ activeStyle: {
33
+ type: Object,
34
+ default: () => ({})
35
+ },
36
+ localeRoute: {
37
+ type: Function,
38
+ default: void 0
39
+ }
40
+ },
41
+ setup(t, { slots: i }) {
42
+ let a = r(p), o = r(g, void 0);
43
+ if (!a) throw Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");
44
+ let s = e(() => typeof t.to == "string" && /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to)), c = e(() => {
45
+ if (s.value) return t.to;
46
+ if (t.localeRoute) {
47
+ let e = t.localeRoute(t.to);
48
+ return typeof e == "string" ? e : e.path || "/";
49
+ }
50
+ if (!o?.resolvePath) return typeof t.to == "string" ? t.to : t.to.path || "/";
51
+ let e = o.resolvePath(t.to, a.locale.value);
52
+ return typeof e == "string" ? e : e.path || "/";
53
+ }), l = e(() => s.value || !o ? !1 : o.getCurrentPath().replace(/#.*$/, "").replace(/\/$/, "") === c.value.replace(/#.*$/, "").replace(/\/$/, "")), u = e(() => l.value ? t.activeStyle : {});
54
+ return () => s.value ? n("a", {
55
+ href: c.value,
56
+ target: "_blank",
57
+ rel: "noopener noreferrer",
58
+ style: u.value
59
+ }, i.default?.()) : o?.linkComponent ? n(o.linkComponent, {
60
+ to: c.value,
61
+ style: u.value
62
+ }, { default: i.default }) : n("a", {
63
+ href: c.value,
64
+ style: u.value,
65
+ onClick: (e) => {
66
+ e.preventDefault(), o ? o.push({ path: c.value }) : window.location.href = c.value;
67
+ }
68
+ }, i.default?.());
69
+ }
70
+ }), y = t({
71
+ name: "I18nSwitcher",
72
+ props: {
73
+ customLabels: {
74
+ type: Object,
75
+ default: () => ({})
76
+ },
77
+ customWrapperStyle: {
78
+ type: Object,
79
+ default: () => ({})
80
+ },
81
+ customButtonStyle: {
82
+ type: Object,
83
+ default: () => ({})
84
+ },
85
+ customDropdownStyle: {
86
+ type: Object,
87
+ default: () => ({})
88
+ },
89
+ customItemStyle: {
90
+ type: Object,
91
+ default: () => ({})
92
+ },
93
+ customLinkStyle: {
94
+ type: Object,
95
+ default: () => ({})
96
+ },
97
+ customActiveLinkStyle: {
98
+ type: Object,
99
+ default: () => ({})
100
+ },
101
+ customDisabledLinkStyle: {
102
+ type: Object,
103
+ default: () => ({})
104
+ },
105
+ customIconStyle: {
106
+ type: Object,
107
+ default: () => ({})
108
+ },
109
+ locales: {
110
+ type: Array,
111
+ default: void 0
112
+ },
113
+ currentLocale: {
114
+ type: [String, Function],
115
+ default: void 0
116
+ },
117
+ getLocaleName: {
118
+ type: Function,
119
+ default: void 0
120
+ },
121
+ switchLocale: {
122
+ type: Function,
123
+ default: void 0
124
+ },
125
+ localeRoute: {
126
+ type: Function,
127
+ default: void 0
128
+ }
129
+ },
130
+ setup(t, { slots: c }) {
131
+ let l = r(p), u = r(g, void 0), d = r(m, void 0);
132
+ if (!l) throw Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");
133
+ if (!d && !t.locales) throw Error("[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop.");
134
+ let f = e(() => t.locales || d || []), h = e(() => f.value.filter((e) => !e.disabled)), _ = e(() => t.currentLocale === void 0 ? l.locale.value : typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale), v = e(() => f.value.some((e) => e.code === _.value && e.disabled)), y = e(() => t.getLocaleName ? t.getLocaleName() || null : f.value.find((e) => e.code === l.locale.value)?.displayName || null), b = s(!1), x = s(null), S = (e) => {
135
+ e && (e.stopPropagation(), e.preventDefault()), b.value = !b.value;
136
+ }, C = (e) => t.customLabels[e.code] || e.displayName || e.code, w = e(() => {
137
+ let e = f.value.find((e) => e.code === _.value);
138
+ return e ? C(e) : y.value || _.value;
139
+ }), T = async (e) => {
140
+ if (b.value = !1, await i(), t.switchLocale) {
141
+ t.switchLocale(e);
142
+ return;
143
+ }
144
+ if (l.locale.value = e, !u) return;
145
+ let n = u.getCurrentPath(), r = t.localeRoute ? (() => {
146
+ let r = t.localeRoute(n, e);
147
+ return typeof r == "string" ? r : r.path || "/";
148
+ })() : u?.resolvePath ? (() => {
149
+ let t = u.resolvePath(n, e);
150
+ return typeof t == "string" ? t : t.path || "/";
151
+ })() : n;
152
+ u.push({ path: r });
153
+ }, E = {
154
+ position: "relative",
155
+ display: "inline-block",
156
+ verticalAlign: "middle"
157
+ }, D = {
158
+ padding: "4px 12px",
159
+ fontSize: "16px",
160
+ cursor: "pointer",
161
+ backgroundColor: "#fff",
162
+ border: "1px solid #333",
163
+ transition: "background-color 0.3s ease",
164
+ display: "flex",
165
+ alignItems: "center",
166
+ justifyContent: "space-between"
167
+ }, O = {
168
+ position: "absolute",
169
+ top: "100%",
170
+ left: "0",
171
+ zIndex: 1e3,
172
+ backgroundColor: "#fff",
173
+ border: "1px solid #333",
174
+ listStyle: "none",
175
+ padding: "0",
176
+ margin: "4px 0 0 0",
177
+ minWidth: "150px",
178
+ boxShadow: "0 2px 8px rgba(0,0,0,0.15)"
179
+ }, k = {
180
+ margin: "0",
181
+ padding: "0"
182
+ }, A = {
183
+ display: "block",
184
+ padding: "8px 12px",
185
+ color: "#333",
186
+ textDecoration: "none",
187
+ transition: "background-color 0.3s ease",
188
+ cursor: "pointer"
189
+ }, j = {
190
+ fontWeight: "bold",
191
+ color: "#007bff",
192
+ cursor: "not-allowed"
193
+ }, M = {
194
+ marginLeft: "8px",
195
+ display: "inline-block",
196
+ transition: "transform 0.3s ease"
197
+ }, N = { transform: "rotate(180deg)" }, P = (e) => e ? Array.isArray(e) ? e : [e] : [], F = (e) => {
198
+ if (!b.value) return;
199
+ let t = e.target;
200
+ if (!t || !x.value) return;
201
+ let n = x.value.contains(t), r = t.closest(".i18n-switcher-button") !== null;
202
+ !n && !r && (b.value = !1);
203
+ };
204
+ return a(() => {
205
+ document.addEventListener("click", F);
206
+ }), o(() => {
207
+ document.removeEventListener("click", F);
208
+ }), () => {
209
+ let e = [];
210
+ c["before-button"] && e.push(...P(c["before-button"]()));
211
+ let r = [];
212
+ if (c["before-selected-locale"] && r.push(...P(c["before-selected-locale"]())), r.push(n("span", w.value)), c["after-selected-locale"] && r.push(...P(c["after-selected-locale"]())), r.push(n("span", { style: {
213
+ ...M,
214
+ ...b.value ? N : {},
215
+ ...t.customIconStyle
216
+ } }, "")), e.push(n("button", {
217
+ class: "i18n-switcher-button",
218
+ style: {
219
+ ...D,
220
+ ...t.customButtonStyle,
221
+ ...v.value ? t.customDisabledLinkStyle : {}
222
+ },
223
+ onClick: (e) => {
224
+ e.preventDefault(), e.stopPropagation(), S(e);
225
+ },
226
+ type: "button",
227
+ ariaHaspopup: !0,
228
+ ariaExpanded: b.value
229
+ }, r)), c["before-dropdown"] && e.push(...P(c["before-dropdown"]())), b.value) {
230
+ let r = [];
231
+ c["before-dropdown-items"] && r.push(...P(c["before-dropdown-items"]())), h.value.forEach((e) => {
232
+ let i = [];
233
+ c["before-item"] && i.push(...P(c["before-item"]({ locale: e })));
234
+ let a = [];
235
+ c["before-link-content"] && a.push(...P(c["before-link-content"]({ locale: e }))), a.push(C(e)), c["after-link-content"] && a.push(...P(c["after-link-content"]({ locale: e })));
236
+ let o = typeof window < "u" ? window.location.pathname : "/", s = t.localeRoute ? t.localeRoute(o, e.code) : u?.resolvePath ? u.resolvePath(o, e.code) : o, l = typeof s == "string" ? s : s.path || "#", d = e.code === _.value;
237
+ i.push(n("a", {
238
+ class: `switcher-locale-${e.code}`,
239
+ href: typeof l == "string" ? l : "#",
240
+ style: {
241
+ ...A,
242
+ ...d ? j : {},
243
+ ...t.customLinkStyle,
244
+ ...d ? t.customActiveLinkStyle : {}
245
+ },
246
+ onClick: (t) => {
247
+ t.preventDefault(), t.stopPropagation(), T(e.code);
248
+ }
249
+ }, a)), c["after-item"] && i.push(...P(c["after-item"]({ locale: e }))), r.push(n("li", {
250
+ key: e.code,
251
+ style: {
252
+ ...k,
253
+ ...t.customItemStyle
254
+ }
255
+ }, i));
256
+ }), c["after-dropdown-items"] && r.push(...P(c["after-dropdown-items"]())), e.push(n("ul", {
257
+ class: "i18n-switcher-dropdown",
258
+ style: {
259
+ ...O,
260
+ ...t.customDropdownStyle
261
+ }
262
+ }, r));
263
+ }
264
+ return c["after-dropdown"] && e.push(...P(c["after-dropdown"]())), n("div", {
265
+ ref: x,
266
+ class: "i18n-switcher-wrapper",
267
+ style: {
268
+ ...E,
269
+ ...t.customWrapperStyle
270
+ }
271
+ }, e);
272
+ };
273
+ }
274
+ }), b = t({
275
+ name: "I18nT",
276
+ inheritAttrs: !1,
277
+ props: {
278
+ keypath: {
279
+ type: String,
280
+ required: !0
281
+ },
282
+ plural: { type: [Number, String] },
283
+ tag: {
284
+ type: String,
285
+ default: "span"
286
+ },
287
+ params: {
288
+ type: Object,
289
+ default: () => ({})
290
+ },
291
+ defaultValue: {
292
+ type: String,
293
+ default: ""
294
+ },
295
+ html: {
296
+ type: Boolean,
297
+ default: !1
298
+ },
299
+ hideIfEmpty: {
300
+ type: Boolean,
301
+ default: !1
302
+ },
303
+ customPluralRule: {
304
+ type: Function,
305
+ default: null
306
+ },
307
+ number: { type: [Number, String] },
308
+ date: { type: [
309
+ Date,
310
+ String,
311
+ Number
312
+ ] },
313
+ relativeDate: { type: [
314
+ Date,
315
+ String,
316
+ Number
317
+ ] }
318
+ },
319
+ setup(e, { slots: t, attrs: i }) {
320
+ let a = r(p);
321
+ if (!a) throw Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
322
+ return () => {
323
+ let r = {}, o = a.getRoute(), s = { ...i };
324
+ delete s.innerHTML;
325
+ let c = (t) => e.html ? n(e.tag, {
326
+ ...s,
327
+ innerHTML: t
328
+ }) : n(e.tag, s, t);
329
+ if (e.number !== void 0) {
330
+ let t = Number(e.number), n = a.tn(t), r = a.t(e.keypath, {
331
+ number: n,
332
+ ...e.params
333
+ }, void 0, o);
334
+ return c(String(r ?? ""));
335
+ }
336
+ if (e.date !== void 0) {
337
+ let t = a.td(e.date), n = a.t(e.keypath, {
338
+ date: t,
339
+ ...e.params
340
+ }, void 0, o);
341
+ return c(String(n ?? ""));
342
+ }
343
+ if (e.relativeDate !== void 0) {
344
+ let t = a.tdr(e.relativeDate), n = a.t(e.keypath, {
345
+ relativeDate: t,
346
+ ...e.params
347
+ }, void 0, o);
348
+ return c(String(n ?? ""));
349
+ }
350
+ if (e.plural !== void 0) {
351
+ let t = Number.parseInt(e.plural.toString(), 10);
352
+ return e.customPluralRule ? c(e.customPluralRule(e.keypath, t, e.params, a.locale.value, (e, t, n) => a.t(e, t, n, o)) || "") : c(a.tc(e.keypath, {
353
+ count: t,
354
+ ...e.params
355
+ }));
356
+ }
357
+ let l = (a.t(e.keypath, {
358
+ ...e.params,
359
+ ...r
360
+ }, void 0, o) ?? "").toString();
361
+ if (e.hideIfEmpty && !l.trim()) return e.defaultValue ?? null;
362
+ if (e.html) return c(l);
363
+ if (t.default) return n(e.tag, s, t.default({ translation: l }));
364
+ let u = [], d = 0;
365
+ for (let [e, r] of Object.entries(t)) {
366
+ if (e === "default") continue;
367
+ let t = `{${e}}`, i = l.indexOf(t, d);
368
+ i !== -1 && (i > d && u.push(l.slice(d, i)), r && u.push(n(r)), d = i + t.length);
369
+ }
370
+ return d < l.length && u.push(l.slice(d)), t.default ? n(e.tag, s, t.default({ children: u })) : u.length > 0 ? n(e.tag, s, u) : n(e.tag, s, l);
371
+ };
372
+ }
438
373
  });
439
- function J(t) {
440
- return t.iso?.trim() || String(t.code);
374
+ //#endregion
375
+ //#region ../utils/dist/resolve-hreflang.mjs
376
+ function x(e) {
377
+ return e.iso?.trim() || String(e.code);
441
378
  }
442
- function te(t) {
443
- const e = t.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);
444
- return e ? { language: e[1], region: e[2] } : { language: t };
379
+ function S(e) {
380
+ let t = e.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);
381
+ return t ? {
382
+ language: t[1],
383
+ region: t[2]
384
+ } : { language: e };
445
385
  }
446
- function fe(t, e = {}) {
447
- const { hreflangBaseLanguage: a = !1 } = e;
448
- if (!a)
449
- return t.map((u) => {
450
- const f = String(u.code);
451
- return { hreflang: J(u), localeCode: f };
452
- });
453
- const o = /* @__PURE__ */ new Map();
454
- for (const u of t) {
455
- const f = String(u.code), i = J(u), { language: n, region: l } = te(i);
456
- n && l && !o.has(n) && o.set(n, f), o.set(i, f);
457
- }
458
- const c = /* @__PURE__ */ new Set(), r = [];
459
- for (const u of t) {
460
- const f = String(u.code), i = J(u), { language: n, region: l } = te(i);
461
- n && l && o.get(n) === f && !c.has(n) && (c.add(n), r.push({ hreflang: n, localeCode: f })), c.has(i) || (c.add(i), r.push({ hreflang: i, localeCode: f }));
462
- }
463
- return r;
386
+ function C(e, t = {}) {
387
+ let { hreflangBaseLanguage: n = !1 } = t;
388
+ if (!n) return e.map((e) => {
389
+ let t = String(e.code);
390
+ return {
391
+ hreflang: x(e),
392
+ localeCode: t
393
+ };
394
+ });
395
+ let r = /* @__PURE__ */ new Map();
396
+ for (let t of e) {
397
+ let e = String(t.code), n = x(t), { language: i, region: a } = S(n);
398
+ i && a && !r.has(i) && r.set(i, e), r.set(n, e);
399
+ }
400
+ let i = /* @__PURE__ */ new Set(), a = [];
401
+ for (let t of e) {
402
+ let e = String(t.code), n = x(t), { language: o, region: s } = S(n);
403
+ o && s && r.get(o) === e && !i.has(o) && (i.add(o), a.push({
404
+ hreflang: o,
405
+ localeCode: e
406
+ })), i.has(n) || (i.add(n), a.push({
407
+ hreflang: n,
408
+ localeCode: e
409
+ }));
410
+ }
411
+ return a;
464
412
  }
465
- function X(t) {
466
- const e = t.og?.trim();
467
- if (e) return e;
468
- const a = t.iso?.trim();
469
- if (!a) return null;
470
- const o = a.indexOf("_");
471
- if (o > 0) {
472
- const r = a.slice(0, o), u = a.slice(o + 1);
473
- if (r.length >= 2 && u.length === 2)
474
- return `${r.toLowerCase()}_${u.toUpperCase()}`;
475
- }
476
- const c = a.indexOf("-");
477
- if (c > 0) {
478
- const r = a.slice(0, c), u = a.slice(c + 1);
479
- if (r.length >= 2 && u.length === 2 && /^[A-Za-z]{2}$/.test(u))
480
- return `${r.toLowerCase()}_${u.toUpperCase()}`;
481
- }
482
- return null;
413
+ //#endregion
414
+ //#region ../utils/dist/resolve-og-locale.mjs
415
+ function w(e) {
416
+ let t = e.og?.trim();
417
+ if (t) return t;
418
+ let n = e.iso?.trim();
419
+ if (!n) return null;
420
+ let r = n.indexOf("_");
421
+ if (r > 0) {
422
+ let e = n.slice(0, r), t = n.slice(r + 1);
423
+ if (e.length >= 2 && t.length === 2) return `${e.toLowerCase()}_${t.toUpperCase()}`;
424
+ }
425
+ let i = n.indexOf("-");
426
+ if (i > 0) {
427
+ let e = n.slice(0, i), t = n.slice(i + 1);
428
+ if (e.length >= 2 && t.length === 2 && /^[A-Za-z]{2}$/.test(t)) return `${e.toLowerCase()}_${t.toUpperCase()}`;
429
+ }
430
+ return null;
483
431
  }
484
- function ne(t, e = {}) {
485
- if (X(t) !== null || e.missingWarn === !1 || process.env.NODE_ENV === "production") return;
486
- const a = e.tag ?? "og:locale", o = String(t.code ?? "unknown"), c = t.iso ? `, iso: '${t.iso}'` : "";
487
- console.warn(
488
- `[i18n] Cannot derive ${a} for locale '${o}'${c}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`
489
- );
432
+ function T(e, t = {}) {
433
+ if (w(e) !== null || t.missingWarn === !1 || process.env.NODE_ENV === "production") return;
434
+ let n = t.tag ?? "og:locale", r = String(e.code ?? "unknown"), i = e.iso ? `, iso: '${e.iso}'` : "";
435
+ console.warn(`[i18n] Cannot derive ${n} for locale '${r}'${i}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`);
490
436
  }
491
- function de(t) {
492
- const e = S(W), a = S(U, void 0), o = S(Y, void 0), c = S(ee, void 0);
493
- if (!e)
494
- throw new Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");
495
- if (!o)
496
- throw new Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");
497
- if (!c)
498
- throw new Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");
499
- const r = t?.locales || o, u = t?.defaultLocale || c, f = (i, n) => a?.resolvePath ? a.resolvePath(i, n || e.locale.value) : i;
500
- return {
501
- // Direct access to instance
502
- instance: e,
503
- // Locale (reactive)
504
- locale: k({
505
- get: () => e.locale.value,
506
- set: (i) => {
507
- e.locale.value = i;
508
- }
509
- }),
510
- // Locale helpers
511
- getLocales: () => r,
512
- defaultLocale: () => u,
513
- getLocaleName: () => r.find((n) => n.code === e.locale.value)?.displayName || null,
514
- // Routing helpers
515
- localeRoute: f,
516
- localePath: (i, n) => {
517
- const l = f(i, n);
518
- return typeof l == "string" ? l : l.path || "/";
519
- },
520
- switchLocale: (i) => {
521
- if (e.locale.value = i, a) {
522
- const n = a.getCurrentPath(), l = f(n, i);
523
- a.push(typeof l == "string" ? { path: l } : { path: l.path || "/" });
524
- }
525
- },
526
- // Translation methods (delegate to instance)
527
- t: e.t.bind(e),
528
- ts: e.ts.bind(e),
529
- tc: e.tc.bind(e),
530
- tn: e.tn.bind(e),
531
- td: e.td.bind(e),
532
- tdr: e.tdr.bind(e),
533
- has: e.has.bind(e),
534
- resolveTranslations: e.resolveTranslations.bind(e),
535
- setTranslation: e.setTranslation.bind(e),
536
- // Route management
537
- setRoute: e.setRoute.bind(e),
538
- getRoute: e.getRoute.bind(e),
539
- getLocale: () => e.locale.value,
540
- // Translation management
541
- addTranslations: e.addTranslations.bind(e),
542
- addRouteTranslations: e.addRouteTranslations.bind(e),
543
- mergeTranslations: e.mergeTranslations.bind(e),
544
- clearCache: e.clearCache.bind(e)
545
- };
437
+ //#endregion
438
+ //#region src/use-i18n.ts
439
+ function E(t) {
440
+ let n = r(p), i = r(g, void 0), a = r(m, void 0), o = r(h, void 0);
441
+ if (!n) throw Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");
442
+ if (!a) throw Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");
443
+ if (!o) throw Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");
444
+ let s = t?.locales || a, c = t?.defaultLocale || o, l = (e, t) => i?.resolvePath ? i.resolvePath(e, t || n.locale.value) : e;
445
+ return {
446
+ instance: n,
447
+ locale: e({
448
+ get: () => n.locale.value,
449
+ set: (e) => {
450
+ n.locale.value = e;
451
+ }
452
+ }),
453
+ getLocales: () => s,
454
+ defaultLocale: () => c,
455
+ getLocaleName: () => s.find((e) => e.code === n.locale.value)?.displayName || null,
456
+ localeRoute: l,
457
+ localePath: (e, t) => {
458
+ let n = l(e, t);
459
+ return typeof n == "string" ? n : n.path || "/";
460
+ },
461
+ switchLocale: (e) => {
462
+ if (n.locale.value = e, i) {
463
+ let t = i.getCurrentPath(), n = l(t, e);
464
+ i.push(typeof n == "string" ? { path: n } : { path: n.path || "/" });
465
+ }
466
+ },
467
+ t: n.t.bind(n),
468
+ ts: n.ts.bind(n),
469
+ tc: n.tc.bind(n),
470
+ tn: n.tn.bind(n),
471
+ td: n.td.bind(n),
472
+ tdr: n.tdr.bind(n),
473
+ has: n.has.bind(n),
474
+ resolveTranslations: n.resolveTranslations.bind(n),
475
+ setTranslation: n.setTranslation.bind(n),
476
+ setRoute: n.setRoute.bind(n),
477
+ getRoute: n.getRoute.bind(n),
478
+ getLocale: () => n.locale.value,
479
+ addTranslations: n.addTranslations.bind(n),
480
+ addRouteTranslations: n.addRouteTranslations.bind(n),
481
+ mergeTranslations: n.mergeTranslations.bind(n),
482
+ clearCache: n.clearCache.bind(n)
483
+ };
546
484
  }
547
- function ve(t = {}) {
548
- const { addDirAttribute: e = !0, identifierAttribute: a = "id", addSeoAttributes: o = !0, baseUrl: c = "/", hreflangBaseLanguage: r = !1 } = t, { getLocale: u, getLocales: f, localeRoute: i } = de(), n = S(U, void 0), l = Q({
549
- htmlAttrs: {},
550
- link: [],
551
- meta: []
552
- });
553
- function y(L, T) {
554
- const P = new URL(L, "http://localhost"), $ = new URLSearchParams(P.search), M = {};
555
- for (const _ of T)
556
- $.has(_) && (M[_] = $.get(_));
557
- const D = new URLSearchParams(M);
558
- return D.toString() ? `${P.pathname}?${D.toString()}` : P.pathname;
559
- }
560
- function p(L = []) {
561
- if (!n) {
562
- l.value = { htmlAttrs: {}, link: [], meta: [] };
563
- return;
564
- }
565
- const T = u(), P = f(), $ = P.find((h) => h.code === T);
566
- if (!$)
567
- return;
568
- const M = $.iso || T, D = X($), _ = $.dir || "auto";
569
- let R = n.getCurrentPath();
570
- R.startsWith("/") || (R = `/${R}`);
571
- const Z = R.split("/").filter(Boolean), V = P.find((h) => Z[0] === h.code);
572
- let F = R, v, O;
573
- const s = typeof c == "function" ? c() : c;
574
- if (V) {
575
- F = R.slice(V.code.length + 1) || "/", v = y(F, L);
576
- const h = `/${T}`;
577
- O = `${s}${h}${v.startsWith("/") ? "" : "/"}${v}`;
578
- } else
579
- v = y(R, L), O = `${s}${v.startsWith("/") ? "" : "/"}${v}`;
580
- const m = {
581
- lang: M,
582
- ...e ? { dir: _ } : {}
583
- };
584
- if (!o) {
585
- l.value = { htmlAttrs: m, link: [], meta: [] };
586
- return;
587
- }
588
- const b = P.filter((h) => !h.disabled && h.seo !== !1);
589
- D || ne($, { tag: "og:locale" });
590
- const d = D ? {
591
- [a]: "i18n-og",
592
- property: "og:locale",
593
- content: D
594
- } : null, A = {
595
- [a]: "i18n-og-url",
596
- property: "og:url",
597
- content: O
598
- }, E = b.filter((h) => h.code !== T).map((h) => {
599
- const x = X(h);
600
- return x ? {
601
- [a]: `i18n-og-alt-${x}`,
602
- property: "og:locale:alternate",
603
- content: x
604
- } : (ne(h, { tag: "og:locale:alternate" }), null);
605
- }).filter((h) => h !== null), H = {
606
- [a]: "i18n-can",
607
- rel: "canonical",
608
- href: O
609
- }, B = (() => {
610
- if (!i || !n)
611
- return [];
612
- const h = /* @__PURE__ */ new Map(), x = n.getCurrentPath();
613
- for (const w of b) {
614
- const I = i(x, w.code), C = typeof I == "string" ? I : I?.path || "/";
615
- if (!C) continue;
616
- let q;
617
- C.startsWith("http://") || C.startsWith("https://") ? q = C : q = `${typeof c == "function" ? c() : c}${C.startsWith("/") ? "" : "/"}${C}`, h.set(String(w.code), q);
618
- }
619
- return fe(b, { hreflangBaseLanguage: r }).flatMap(({ hreflang: w, localeCode: I }) => {
620
- const C = h.get(I);
621
- return C ? [
622
- {
623
- [a]: `i18n-alternate-${w}`,
624
- rel: "alternate",
625
- href: C,
626
- hreflang: w
627
- }
628
- ] : [];
629
- });
630
- })(), j = S(ee, void 0);
631
- let N = null;
632
- const K = j ? P.find((h) => h.code === j) : void 0;
633
- if (i && n && j && K?.seo !== !1) {
634
- const h = n.getCurrentPath(), x = i(h, j), w = typeof x == "string" ? x : x?.path || "/";
635
- if (w) {
636
- let I;
637
- w.startsWith("http://") || w.startsWith("https://") ? I = w : I = `${typeof c == "function" ? c() : c}${w.startsWith("/") ? "" : "/"}${w}`, N = {
638
- [a]: "i18n-xd",
639
- rel: "alternate",
640
- href: I,
641
- hreflang: "x-default"
642
- };
643
- }
644
- }
645
- l.value = {
646
- htmlAttrs: m,
647
- meta: [...d ? [d] : [], A, ...E],
648
- link: [H, ...B, ...N ? [N] : []]
649
- };
650
- }
651
- return {
652
- metaObject: l,
653
- updateMeta: p
654
- };
485
+ //#endregion
486
+ //#region src/composables/use-locale-head.ts
487
+ function D(e = {}) {
488
+ let { addDirAttribute: t = !0, identifierAttribute: n = "id", addSeoAttributes: i = !0, baseUrl: a = "/", hreflangBaseLanguage: o = !1 } = e, { getLocale: c, getLocales: l, localeRoute: u } = E(), d = r(g, void 0), f = s({
489
+ htmlAttrs: {},
490
+ link: [],
491
+ meta: []
492
+ });
493
+ function p(e, t) {
494
+ let n = new URL(e, "http://localhost"), r = new URLSearchParams(n.search), i = {};
495
+ for (let e of t) r.has(e) && (i[e] = r.get(e));
496
+ let a = new URLSearchParams(i);
497
+ return a.toString() ? `${n.pathname}?${a.toString()}` : n.pathname;
498
+ }
499
+ function m(e = []) {
500
+ if (!d) {
501
+ f.value = {
502
+ htmlAttrs: {},
503
+ link: [],
504
+ meta: []
505
+ };
506
+ return;
507
+ }
508
+ let s = c(), m = l(), g = m.find((e) => e.code === s);
509
+ if (!g) return;
510
+ let _ = g.iso || s, v = w(g), y = g.dir || "auto", b = d.getCurrentPath();
511
+ b.startsWith("/") || (b = `/${b}`);
512
+ let x = b.split("/").filter(Boolean), S = m.find((e) => x[0] === e.code), E = b, D, O, k = typeof a == "function" ? a() : a;
513
+ S ? (E = b.slice(S.code.length + 1) || "/", D = p(E, e), O = `${k}${`/${s}`}${D.startsWith("/") ? "" : "/"}${D}`) : (D = p(b, e), O = `${k}${D.startsWith("/") ? "" : "/"}${D}`);
514
+ let A = {
515
+ lang: _,
516
+ ...t ? { dir: y } : {}
517
+ };
518
+ if (!i) {
519
+ f.value = {
520
+ htmlAttrs: A,
521
+ link: [],
522
+ meta: []
523
+ };
524
+ return;
525
+ }
526
+ let j = m.filter((e) => !e.disabled && e.seo !== !1);
527
+ v || T(g, { tag: "og:locale" });
528
+ let M = v ? {
529
+ [n]: "i18n-og",
530
+ property: "og:locale",
531
+ content: v
532
+ } : null, N = {
533
+ [n]: "i18n-og-url",
534
+ property: "og:url",
535
+ content: O
536
+ }, P = j.filter((e) => e.code !== s).map((e) => {
537
+ let t = w(e);
538
+ return t ? {
539
+ [n]: `i18n-og-alt-${t}`,
540
+ property: "og:locale:alternate",
541
+ content: t
542
+ } : (T(e, { tag: "og:locale:alternate" }), null);
543
+ }).filter((e) => e !== null), F = {
544
+ [n]: "i18n-can",
545
+ rel: "canonical",
546
+ href: O
547
+ }, I = (() => {
548
+ if (!u || !d) return [];
549
+ let e = /* @__PURE__ */ new Map(), t = d.getCurrentPath();
550
+ for (let n of j) {
551
+ let r = u(t, n.code), i = typeof r == "string" ? r : r?.path || "/";
552
+ if (!i) continue;
553
+ let o;
554
+ o = i.startsWith("http://") || i.startsWith("https://") ? i : `${typeof a == "function" ? a() : a}${i.startsWith("/") ? "" : "/"}${i}`, e.set(String(n.code), o);
555
+ }
556
+ return C(j, { hreflangBaseLanguage: o }).flatMap(({ hreflang: t, localeCode: r }) => {
557
+ let i = e.get(r);
558
+ return i ? [{
559
+ [n]: `i18n-alternate-${t}`,
560
+ rel: "alternate",
561
+ href: i,
562
+ hreflang: t
563
+ }] : [];
564
+ });
565
+ })(), L = r(h, void 0), R = null, z = L ? m.find((e) => e.code === L) : void 0;
566
+ if (u && d && L && z?.seo !== !1) {
567
+ let e = d.getCurrentPath(), t = u(e, L), r = typeof t == "string" ? t : t?.path || "/";
568
+ if (r) {
569
+ let e;
570
+ e = r.startsWith("http://") || r.startsWith("https://") ? r : `${typeof a == "function" ? a() : a}${r.startsWith("/") ? "" : "/"}${r}`, R = {
571
+ [n]: "i18n-xd",
572
+ rel: "alternate",
573
+ href: e,
574
+ hreflang: "x-default"
575
+ };
576
+ }
577
+ }
578
+ f.value = {
579
+ htmlAttrs: A,
580
+ meta: [
581
+ ...M ? [M] : [],
582
+ N,
583
+ ...P
584
+ ],
585
+ link: [
586
+ F,
587
+ ...I,
588
+ ...R ? [R] : []
589
+ ]
590
+ };
591
+ }
592
+ return {
593
+ metaObject: f,
594
+ updateMeta: m
595
+ };
655
596
  }
656
- class he extends le {
657
- constructor(e) {
658
- const a = {
659
- translations: /* @__PURE__ */ new Map()
660
- };
661
- if (super({
662
- storage: a,
663
- plural: e.plural,
664
- missingWarn: e.missingWarn,
665
- missingHandler: e.missingHandler
666
- }), this.listeners = /* @__PURE__ */ new Set(), this.storage = a, this._locale = z(e.locale), this._fallbackLocale = z(e.fallbackLocale || e.locale), this._currentRoute = z("index"), this._revision = z(0), e.messages)
667
- for (const [o, c] of Object.entries(e.messages))
668
- this.helper.loadTranslations(o, c);
669
- }
670
- get locale() {
671
- return this._locale;
672
- }
673
- set locale(e) {
674
- typeof e == "string" ? this._locale.value = e : this._locale = e;
675
- }
676
- get fallbackLocale() {
677
- return this._fallbackLocale;
678
- }
679
- set fallbackLocale(e) {
680
- typeof e == "string" ? this._fallbackLocale.value = e : this._fallbackLocale = e;
681
- }
682
- get currentRoute() {
683
- return this._currentRoute;
684
- }
685
- setRoute(e) {
686
- this._currentRoute.value = e;
687
- }
688
- getLocale() {
689
- return this._locale.value;
690
- }
691
- getFallbackLocale() {
692
- return this._fallbackLocale.value;
693
- }
694
- getRoute() {
695
- return this._currentRoute.value;
696
- }
697
- addTranslations(e, a, o = !0) {
698
- super.loadTranslationsCore(e, a, o), this._revision.value++, this.notifyListeners();
699
- }
700
- addRouteTranslations(e, a, o, c = !0) {
701
- super.loadRouteTranslationsCore(e, a, o, c), this._revision.value++, this.notifyListeners();
702
- }
703
- mergeTranslations(e, a, o) {
704
- this.helper.mergeTranslation(e, a, o, !0), this._revision.value++, this.notifyListeners();
705
- }
706
- clearCache() {
707
- super.clearCache(), this._revision.value++, this.notifyListeners();
708
- }
709
- onTranslationsChanged() {
710
- this._revision.value++, this.notifyListeners();
711
- }
712
- subscribeToChanges(e) {
713
- return this.listeners.add(e), () => this.listeners.delete(e);
714
- }
715
- notifyListeners() {
716
- this.listeners.forEach((e) => e());
717
- }
718
- getStorage() {
719
- return this.storage;
720
- }
721
- getRouteCache() {
722
- const e = {};
723
- for (const [a, o] of this.storage.translations)
724
- e[a] = o;
725
- return e;
726
- }
727
- }
728
- function pe(t) {
729
- const { routingStrategy: e, locales: a, defaultLocale: o, ...c } = t, r = new he(c);
730
- let u = null, f = e || null;
731
- return {
732
- global: r,
733
- // Access to instance outside components
734
- setRoutingStrategy: (n) => {
735
- f = n, u && u.provide(U, n);
736
- },
737
- // Method for setting adapter after creation
738
- install(n) {
739
- u = n, n.provide(W, r), f && n.provide(U, f), a && n.provide(Y, a), o && n.provide(ee, o), n.config.globalProperties.$t = (l, y, p, L) => r.t(l, y, p, L), n.config.globalProperties.$ts = (l, y, p, L) => r.ts(l, y, p, L), n.config.globalProperties.$tc = (l, y, p) => r.tc(l, y, p), n.config.globalProperties.$tn = r.tn.bind(r), n.config.globalProperties.$td = r.td.bind(r), n.config.globalProperties.$tdr = r.tdr.bind(r), n.config.globalProperties.$has = (l, y) => r.has(l, y), n.config.globalProperties.$i18n = r, n.component("I18nT", ue), n.component("I18nLink", ce), n.component("I18nGroup", ie), n.component("I18nSwitcher", se);
740
- }
741
- };
742
- }
743
- export {
744
- Se as FormatService,
745
- ee as I18nDefaultLocaleKey,
746
- ie as I18nGroup,
747
- W as I18nInjectionKey,
748
- ce as I18nLink,
749
- Y as I18nLocalesKey,
750
- se as I18nSwitcher,
751
- ue as I18nT,
752
- he as VueI18n,
753
- pe as createI18n,
754
- we as defaultPlural,
755
- ke as interpolate,
756
- de as useI18n,
757
- ve as useLocaleHead
597
+ //#endregion
598
+ //#region src/composer.ts
599
+ var O = class extends l {
600
+ constructor(e) {
601
+ let t = { translations: /* @__PURE__ */ new Map() };
602
+ if (super({
603
+ storage: t,
604
+ plural: e.plural,
605
+ missingWarn: e.missingWarn,
606
+ missingHandler: e.missingHandler
607
+ }), this.listeners = /* @__PURE__ */ new Set(), this.storage = t, this._locale = c(e.locale), this._fallbackLocale = c(e.fallbackLocale || e.locale), this._currentRoute = c("index"), this._revision = c(0), e.messages) for (let [t, n] of Object.entries(e.messages)) this.helper.loadTranslations(t, n);
608
+ }
609
+ get locale() {
610
+ return this._locale;
611
+ }
612
+ set locale(e) {
613
+ typeof e == "string" ? this._locale.value = e : this._locale = e;
614
+ }
615
+ get fallbackLocale() {
616
+ return this._fallbackLocale;
617
+ }
618
+ set fallbackLocale(e) {
619
+ typeof e == "string" ? this._fallbackLocale.value = e : this._fallbackLocale = e;
620
+ }
621
+ get currentRoute() {
622
+ return this._currentRoute;
623
+ }
624
+ setRoute(e) {
625
+ this._currentRoute.value = e;
626
+ }
627
+ getLocale() {
628
+ return this._locale.value;
629
+ }
630
+ getFallbackLocale() {
631
+ return this._fallbackLocale.value;
632
+ }
633
+ getRoute() {
634
+ return this._currentRoute.value;
635
+ }
636
+ addTranslations(e, t, n = !0) {
637
+ super.loadTranslationsCore(e, t, n), this._revision.value++, this.notifyListeners();
638
+ }
639
+ addRouteTranslations(e, t, n, r = !0) {
640
+ super.loadRouteTranslationsCore(e, t, n, r), this._revision.value++, this.notifyListeners();
641
+ }
642
+ mergeTranslations(e, t, n) {
643
+ this.helper.mergeTranslation(e, t, n, !0), this._revision.value++, this.notifyListeners();
644
+ }
645
+ clearCache() {
646
+ super.clearCache(), this._revision.value++, this.notifyListeners();
647
+ }
648
+ onTranslationsChanged() {
649
+ this._revision.value++, this.notifyListeners();
650
+ }
651
+ subscribeToChanges(e) {
652
+ return this.listeners.add(e), () => this.listeners.delete(e);
653
+ }
654
+ notifyListeners() {
655
+ this.listeners.forEach((e) => e());
656
+ }
657
+ getStorage() {
658
+ return this.storage;
659
+ }
660
+ getRouteCache() {
661
+ let e = {};
662
+ for (let [t, n] of this.storage.translations) e[t] = n;
663
+ return e;
664
+ }
758
665
  };
759
- //# sourceMappingURL=index.mjs.map
666
+ //#endregion
667
+ //#region src/plugin.ts
668
+ function k(e) {
669
+ let { routingStrategy: t, locales: n, defaultLocale: r, ...i } = e, a = new O(i), o = null, s = t || null;
670
+ return {
671
+ global: a,
672
+ setRoutingStrategy: (e) => {
673
+ s = e, o && o.provide(g, e);
674
+ },
675
+ install(e) {
676
+ o = e, e.provide(p, a), s && e.provide(g, s), n && e.provide(m, n), r && e.provide(h, r), e.config.globalProperties.$t = (e, t, n, r) => a.t(e, t, n, r), e.config.globalProperties.$ts = (e, t, n, r) => a.ts(e, t, n, r), e.config.globalProperties.$tc = (e, t, n) => a.tc(e, t, n), e.config.globalProperties.$tn = a.tn.bind(a), e.config.globalProperties.$td = a.td.bind(a), e.config.globalProperties.$tdr = a.tdr.bind(a), e.config.globalProperties.$has = (e, t) => a.has(e, t), e.config.globalProperties.$i18n = a, e.component("I18nT", b), e.component("I18nLink", v), e.component("I18nGroup", _), e.component("I18nSwitcher", y);
677
+ }
678
+ };
679
+ }
680
+ //#endregion
681
+ export { u as FormatService, h as I18nDefaultLocaleKey, _ as I18nGroup, p as I18nInjectionKey, v as I18nLink, m as I18nLocalesKey, y as I18nSwitcher, b as I18nT, O as VueI18n, k as createI18n, d as defaultPlural, f as interpolate, E as useI18n, D as useLocaleHead };
682
+
683
+ //# sourceMappingURL=index.mjs.map