@vinaverse/tokens 0.0.0-stage → 0.1.0-alpha.3

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,36 @@
1
- # Temporary Holding Version
1
+ # @vinaverse/tokens
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The design tokens every Vinaverse UI kit starts from, so the React Native and Angular kits look alike out of the box:
4
+ colors for light and dark, a type scale and weights, spacing, radii, motion durations and sizes. Every text and
5
+ control pair meets WCAG AA in both schemes, held by its tests. No framework, no platform.
6
+
7
+ ```ts
8
+ import { colors, contrastProblems, font, space } from '@vinaverse/tokens';
9
+
10
+ const palette = { ...colors('dark'), primary: '#7FA4FF' }; // a tenant's brand on top
11
+ if (contrastProblems(palette).length) console.warn('this theme is hard to read');
12
+ ```
13
+
14
+ `@vinaverse/tokens/tokens.json` is the same set as one JSON in the W3C design-tokens style (`$type`, `$value`), for
15
+ build tools that emit CSS custom properties or native styles. Its paths are public API, frozen by a test; a CSS
16
+ property is the path without its mode, kebab-cased (`cssVariable('color.light.agentBubble')` →
17
+ `--vv-color-agent-bubble`). The contrast pairs every theme must keep are in the JSON too.
18
+
19
+ `@vinaverse/tokens/copy` holds the words every kit says (English, Spanish, Brazilian Portuguese), with the rules on
20
+ them: a tenant's overrides on top, never the AI disclosure in a built-in language and in another only a translation
21
+ that still discloses; never "assistant", "bot" or "crew". Also the locale's text direction and Intl formatting.
22
+
23
+ How the kits use them: [docs/architecture/ui-kits.md](../../docs/architecture/ui-kits.md).
24
+
25
+ ## Install
26
+
27
+ ```sh
28
+ npm install @vinaverse/tokens@alpha
29
+ ```
30
+
31
+ Alphas are published under the `alpha` tag. The UI kits depend on it already; install it yourself only to build on
32
+ the tokens or the copy directly.
33
+
34
+ ## License
35
+
36
+ Apache-2.0
@@ -0,0 +1,299 @@
1
+ 'use strict';
2
+
3
+ // src/copy/copy.ts
4
+ var en = {
5
+ disclosureFallback: "You're chatting with an AI agent. Powered by Vinaverse.",
6
+ agentLabel: "AI agent",
7
+ agentFallbackName: "the agent",
8
+ you: "You",
9
+ staffLabel: "{by} \xB7 person",
10
+ staffFallbackRole: "the team",
11
+ composerPlaceholder: "Message {agent}",
12
+ composerPlaceholderTakeover: "Message {by}",
13
+ send: "Send",
14
+ stop: "Stop",
15
+ typeAnswerBelow: "Type your answer below.",
16
+ bannerConnecting: "Connecting\u2026",
17
+ bannerReconnecting: "Reconnecting\u2026",
18
+ bannerOffline: "You're offline. Messages send when you're back.",
19
+ bannerContinuedElsewhere: "This conversation continued on another device.",
20
+ bannerUnavailable: "Couldn't connect.",
21
+ continueHere: "Continue here",
22
+ tryAgain: "Try again",
23
+ talkToPerson: "Talk to a person",
24
+ messageSending: "Sending",
25
+ messageHeld: "Sends when you continue",
26
+ messageNotSent: "Not sent",
27
+ messageDelivered: "Delivered",
28
+ messageCutOff: "This reply was cut off.",
29
+ takeoverStarted: "A person from {by} is replying now.",
30
+ takeoverEnded: "{agent} is back.",
31
+ handoffCreated: "We've passed this to the team. They'll reply {expected}.",
32
+ handoffCreatedNoTime: "We've passed this to the team. They'll reply soon.",
33
+ flowSent: "Your answers were sent.",
34
+ flowNotSent: "Your answers couldn't be sent yet.",
35
+ turnFailed: "Something went wrong.",
36
+ working: "{agent} is working on it\u2026",
37
+ proposalConfirm: "Confirm",
38
+ proposalDecline: "Decline",
39
+ proposalChange: "Change",
40
+ proposalConfirmed: "Confirmed",
41
+ proposalDeclined: "Declined",
42
+ proposalFailed: "Couldn't be confirmed",
43
+ proposalExpired: "Expired",
44
+ proposalSettled: "No longer open",
45
+ questionSubmit: "Send",
46
+ questionSkip: "Skip",
47
+ questionOther: "Other",
48
+ questionSearch: "Search",
49
+ questionAnswered: "Answered",
50
+ questionReplaced: "Replaced by a newer question",
51
+ questionStep: "Question {step} of {total}",
52
+ questionAddPhoto: "Add a photo",
53
+ questionCharactersLeft: "{count} characters left",
54
+ priceFrom: "From {price}",
55
+ open: "Open"
56
+ };
57
+ var es = {
58
+ disclosureFallback: "Est\xE1s hablando con un agente de IA. Con la tecnolog\xEDa de Vinaverse.",
59
+ agentLabel: "Agente de IA",
60
+ agentFallbackName: "el agente",
61
+ you: "T\xFA",
62
+ staffLabel: "{by} \xB7 persona",
63
+ staffFallbackRole: "el equipo",
64
+ composerPlaceholder: "Escribe a {agent}",
65
+ composerPlaceholderTakeover: "Escribe a {by}",
66
+ send: "Enviar",
67
+ stop: "Detener",
68
+ typeAnswerBelow: "Escribe tu respuesta abajo.",
69
+ bannerConnecting: "Conectando\u2026",
70
+ bannerReconnecting: "Reconectando\u2026",
71
+ bannerOffline: "Sin conexi\xF3n. Los mensajes se env\xEDan cuando vuelvas.",
72
+ bannerContinuedElsewhere: "Esta conversaci\xF3n continu\xF3 en otro dispositivo.",
73
+ bannerUnavailable: "No se pudo conectar.",
74
+ continueHere: "Continuar aqu\xED",
75
+ tryAgain: "Intentar de nuevo",
76
+ talkToPerson: "Hablar con una persona",
77
+ messageSending: "Enviando",
78
+ messageHeld: "Se env\xEDa cuando contin\xFAes",
79
+ messageNotSent: "No enviado",
80
+ messageDelivered: "Entregado",
81
+ messageCutOff: "Esta respuesta qued\xF3 incompleta.",
82
+ takeoverStarted: "Una persona de {by} est\xE1 respondiendo.",
83
+ takeoverEnded: "{agent} volvi\xF3.",
84
+ handoffCreated: "Le pasamos esto al equipo. Responder\xE1n {expected}.",
85
+ handoffCreatedNoTime: "Le pasamos esto al equipo. Responder\xE1n pronto.",
86
+ flowSent: "Tus respuestas se enviaron.",
87
+ flowNotSent: "Tus respuestas a\xFAn no se pudieron enviar.",
88
+ turnFailed: "Algo sali\xF3 mal.",
89
+ working: "{agent} est\xE1 en ello\u2026",
90
+ proposalConfirm: "Confirmar",
91
+ proposalDecline: "Rechazar",
92
+ proposalChange: "Cambiar",
93
+ proposalConfirmed: "Confirmado",
94
+ proposalDeclined: "Rechazado",
95
+ proposalFailed: "No se pudo confirmar",
96
+ proposalExpired: "Vencido",
97
+ proposalSettled: "Ya no est\xE1 abierto",
98
+ questionSubmit: "Enviar",
99
+ questionSkip: "Omitir",
100
+ questionOther: "Otro",
101
+ questionSearch: "Buscar",
102
+ questionAnswered: "Respondida",
103
+ questionReplaced: "Reemplazada por una pregunta m\xE1s reciente",
104
+ questionStep: "Pregunta {step} de {total}",
105
+ questionAddPhoto: "Agregar una foto",
106
+ questionCharactersLeft: "Quedan {count} caracteres",
107
+ priceFrom: "Desde {price}",
108
+ open: "Abrir"
109
+ };
110
+ var ptBR = {
111
+ disclosureFallback: "Voc\xEA est\xE1 conversando com um agente de IA. Com tecnologia Vinaverse.",
112
+ agentLabel: "Agente de IA",
113
+ agentFallbackName: "o agente",
114
+ you: "Voc\xEA",
115
+ staffLabel: "{by} \xB7 pessoa",
116
+ staffFallbackRole: "a equipe",
117
+ composerPlaceholder: "Mensagem para {agent}",
118
+ composerPlaceholderTakeover: "Mensagem para {by}",
119
+ send: "Enviar",
120
+ stop: "Parar",
121
+ typeAnswerBelow: "Digite sua resposta abaixo.",
122
+ bannerConnecting: "Conectando\u2026",
123
+ bannerReconnecting: "Reconectando\u2026",
124
+ bannerOffline: "Sem conex\xE3o. As mensagens s\xE3o enviadas quando voc\xEA voltar.",
125
+ bannerContinuedElsewhere: "Esta conversa continuou em outro aparelho.",
126
+ bannerUnavailable: "N\xE3o foi poss\xEDvel conectar.",
127
+ continueHere: "Continuar aqui",
128
+ tryAgain: "Tentar de novo",
129
+ talkToPerson: "Falar com uma pessoa",
130
+ messageSending: "Enviando",
131
+ messageHeld: "Ser\xE1 enviada quando voc\xEA continuar",
132
+ messageNotSent: "N\xE3o enviada",
133
+ messageDelivered: "Entregue",
134
+ messageCutOff: "Esta resposta foi interrompida.",
135
+ takeoverStarted: "Uma pessoa de {by} est\xE1 respondendo agora.",
136
+ takeoverEnded: "{agent} voltou.",
137
+ handoffCreated: "Passamos isso para a equipe. Eles v\xE3o responder {expected}.",
138
+ handoffCreatedNoTime: "Passamos isso para a equipe. Eles v\xE3o responder em breve.",
139
+ flowSent: "Suas respostas foram enviadas.",
140
+ flowNotSent: "Ainda n\xE3o foi poss\xEDvel enviar suas respostas.",
141
+ turnFailed: "Algo deu errado.",
142
+ working: "{agent} est\xE1 cuidando disso\u2026",
143
+ proposalConfirm: "Confirmar",
144
+ proposalDecline: "Recusar",
145
+ proposalChange: "Alterar",
146
+ proposalConfirmed: "Confirmado",
147
+ proposalDeclined: "Recusado",
148
+ proposalFailed: "N\xE3o foi poss\xEDvel confirmar",
149
+ proposalExpired: "Expirado",
150
+ proposalSettled: "N\xE3o est\xE1 mais aberto",
151
+ questionSubmit: "Enviar",
152
+ questionSkip: "Pular",
153
+ questionOther: "Outro",
154
+ questionSearch: "Buscar",
155
+ questionAnswered: "Respondida",
156
+ questionReplaced: "Substitu\xEDda por uma pergunta mais recente",
157
+ questionStep: "Pergunta {step} de {total}",
158
+ questionAddPhoto: "Adicionar uma foto",
159
+ questionCharactersLeft: "Restam {count} caracteres",
160
+ priceFrom: "A partir de {price}",
161
+ open: "Abrir"
162
+ };
163
+ var COPY = {
164
+ en,
165
+ es,
166
+ "pt-BR": ptBR
167
+ };
168
+ var FIXED = /* @__PURE__ */ new Set([
169
+ "disclosureFallback",
170
+ "agentLabel"
171
+ ]);
172
+ var AI_MARK = /(?:^|[^\p{L}])(?:AI|IA|KI|SI|YZ|ИИ|ШІ)(?:$|[^\p{L}])|الذكاء الاصطناعي|بالذكاء|בינה מלאכותית|एआई|कृत्रिम बुद्धि|人工智能|人工知能|인공지능/u;
173
+ function discloses(key, value) {
174
+ if (!AI_MARK.test(value)) return false;
175
+ return key !== "disclosureFallback" || value.includes("Vinaverse");
176
+ }
177
+ function builtIn(locale) {
178
+ const language = (locale ?? "en").split(/[-_]/)[0]?.toLowerCase();
179
+ if (language === "en") return COPY.en;
180
+ if (language === "es") return COPY.es;
181
+ if (language === "pt") return COPY["pt-BR"];
182
+ return null;
183
+ }
184
+ function builtInCopy(locale) {
185
+ return builtIn(locale) ?? COPY.en;
186
+ }
187
+ function createTranslate(locale, overrides = {}) {
188
+ const own = builtIn(locale);
189
+ const merged = { ...own ?? COPY.en };
190
+ for (const [key, value] of Object.entries(overrides)) {
191
+ if (value === void 0) continue;
192
+ if (FIXED.has(key) && !(own === null && discloses(key, value)))
193
+ continue;
194
+ merged[key] = value;
195
+ }
196
+ return (key, vars) => (merged[key] ?? en[key]).replace(
197
+ /\{(\w+)\}/g,
198
+ (all, name) => vars && name in vars ? String(vars[name]) : all
199
+ );
200
+ }
201
+ var BANNED_WORDS = [
202
+ /\bassistant/i,
203
+ /\basistente/i,
204
+ /\bassistent/i,
205
+ /\bbot\b/i,
206
+ /\bcrew\b/i
207
+ ];
208
+ function bannedWordsIn(overrides) {
209
+ return Object.entries(overrides).filter(([, v]) => v !== void 0 && BANNED_WORDS.some((w) => w.test(v))).map(([k]) => k);
210
+ }
211
+
212
+ // src/copy/format.ts
213
+ var RTL_LANGUAGES = /* @__PURE__ */ new Set([
214
+ "ar",
215
+ "he",
216
+ "iw",
217
+ "fa",
218
+ "ur",
219
+ "ps",
220
+ "yi",
221
+ "dv",
222
+ "ckb",
223
+ "sd",
224
+ "ug",
225
+ "syr"
226
+ ]);
227
+ var RTL_SCRIPTS = /* @__PURE__ */ new Set([
228
+ "arab",
229
+ "hebr",
230
+ "thaa",
231
+ "syrc",
232
+ "nkoo",
233
+ "adlm",
234
+ "rohg"
235
+ ]);
236
+ function textDirection(locale) {
237
+ const parts = (locale ?? "").toLowerCase().split(/[-_]/);
238
+ if (parts.some((p) => p.length === 4 && RTL_SCRIPTS.has(p))) return "rtl";
239
+ return RTL_LANGUAGES.has(parts[0] ?? "") ? "rtl" : "ltr";
240
+ }
241
+ function formatMoney(amountMinor, currency, locale) {
242
+ try {
243
+ const format = new Intl.NumberFormat(locale, {
244
+ style: "currency",
245
+ currency
246
+ });
247
+ const digits = format.resolvedOptions().maximumFractionDigits ?? 2;
248
+ return format.format(amountMinor / 10 ** digits);
249
+ } catch {
250
+ return `${currency} ${(amountMinor / 100).toFixed(2)}`;
251
+ }
252
+ }
253
+ function formatTimeRange(start, end, locale, timeZone) {
254
+ const from = new Date(start);
255
+ if (Number.isNaN(from.getTime())) return start;
256
+ const options = {
257
+ weekday: "short",
258
+ month: "short",
259
+ day: "numeric",
260
+ hour: "numeric",
261
+ minute: "2-digit",
262
+ ...timeZone ? { timeZone } : {}
263
+ };
264
+ try {
265
+ const format = new Intl.DateTimeFormat(locale, options);
266
+ const to = end ? new Date(end) : null;
267
+ if (!to || Number.isNaN(to.getTime())) return format.format(from);
268
+ return typeof format.formatRange === "function" ? format.formatRange(from, to) : `${format.format(from)} \u2013 ${format.format(to)}`;
269
+ } catch {
270
+ return from.toISOString();
271
+ }
272
+ }
273
+ function formatDate(date, locale) {
274
+ const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(date);
275
+ if (!m) return date;
276
+ try {
277
+ return new Intl.DateTimeFormat(locale, {
278
+ year: "numeric",
279
+ month: "long",
280
+ day: "numeric",
281
+ timeZone: "UTC"
282
+ }).format(new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3]))));
283
+ } catch {
284
+ return date;
285
+ }
286
+ }
287
+
288
+ exports.AI_MARK = AI_MARK;
289
+ exports.BANNED_WORDS = BANNED_WORDS;
290
+ exports.COPY = COPY;
291
+ exports.bannedWordsIn = bannedWordsIn;
292
+ exports.builtInCopy = builtInCopy;
293
+ exports.createTranslate = createTranslate;
294
+ exports.formatDate = formatDate;
295
+ exports.formatMoney = formatMoney;
296
+ exports.formatTimeRange = formatTimeRange;
297
+ exports.textDirection = textDirection;
298
+ //# sourceMappingURL=index.cjs.map
299
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/copy/copy.ts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,OAAO,CAAA,CAAE,CAAC,CAAC,CAAA,GAAI,CAAA,EAAG,MAAA,CAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAAA,EAC5E,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"index.cjs","sourcesContent":["// The words a Vinaverse UI says, in English, Spanish and Brazilian Portuguese, each overridable by the tenant except\n// the fallback disclosure. People first: \"agent\", never \"assistant\"; a person from the business is a person, by role.\n// `{name}` placeholders are filled from `vars`.\n\nconst en = {\n disclosureFallback: \"You're chatting with an AI agent. Powered by Vinaverse.\",\n agentLabel: 'AI agent',\n agentFallbackName: 'the agent',\n you: 'You',\n staffLabel: '{by} · person',\n staffFallbackRole: 'the team',\n composerPlaceholder: 'Message {agent}',\n composerPlaceholderTakeover: 'Message {by}',\n send: 'Send',\n stop: 'Stop',\n typeAnswerBelow: 'Type your answer below.',\n bannerConnecting: 'Connecting…',\n bannerReconnecting: 'Reconnecting…',\n bannerOffline: \"You're offline. Messages send when you're back.\",\n bannerContinuedElsewhere: 'This conversation continued on another device.',\n bannerUnavailable: \"Couldn't connect.\",\n continueHere: 'Continue here',\n tryAgain: 'Try again',\n talkToPerson: 'Talk to a person',\n messageSending: 'Sending',\n messageHeld: 'Sends when you continue',\n messageNotSent: 'Not sent',\n messageDelivered: 'Delivered',\n messageCutOff: 'This reply was cut off.',\n takeoverStarted: 'A person from {by} is replying now.',\n takeoverEnded: '{agent} is back.',\n handoffCreated: \"We've passed this to the team. They'll reply {expected}.\",\n handoffCreatedNoTime: \"We've passed this to the team. They'll reply soon.\",\n flowSent: 'Your answers were sent.',\n flowNotSent: \"Your answers couldn't be sent yet.\",\n turnFailed: 'Something went wrong.',\n working: '{agent} is working on it…',\n proposalConfirm: 'Confirm',\n proposalDecline: 'Decline',\n proposalChange: 'Change',\n proposalConfirmed: 'Confirmed',\n proposalDeclined: 'Declined',\n proposalFailed: \"Couldn't be confirmed\",\n proposalExpired: 'Expired',\n proposalSettled: 'No longer open',\n questionSubmit: 'Send',\n questionSkip: 'Skip',\n questionOther: 'Other',\n questionSearch: 'Search',\n questionAnswered: 'Answered',\n questionReplaced: 'Replaced by a newer question',\n questionStep: 'Question {step} of {total}',\n questionAddPhoto: 'Add a photo',\n questionCharactersLeft: '{count} characters left',\n priceFrom: 'From {price}',\n open: 'Open',\n} as const;\n\nexport type CopyKey = keyof typeof en;\nexport type Copy = Readonly<Record<CopyKey, string>>;\n/** A tenant's words, by key; a key left out (or undefined) keeps the built-in one. */\nexport type CopyOverrides = { readonly [K in CopyKey]?: string | undefined };\n\nconst es: Copy = {\n disclosureFallback:\n 'Estás hablando con un agente de IA. Con la tecnología de Vinaverse.',\n agentLabel: 'Agente de IA',\n agentFallbackName: 'el agente',\n you: 'Tú',\n staffLabel: '{by} · persona',\n staffFallbackRole: 'el equipo',\n composerPlaceholder: 'Escribe a {agent}',\n composerPlaceholderTakeover: 'Escribe a {by}',\n send: 'Enviar',\n stop: 'Detener',\n typeAnswerBelow: 'Escribe tu respuesta abajo.',\n bannerConnecting: 'Conectando…',\n bannerReconnecting: 'Reconectando…',\n bannerOffline: 'Sin conexión. Los mensajes se envían cuando vuelvas.',\n bannerContinuedElsewhere: 'Esta conversación continuó en otro dispositivo.',\n bannerUnavailable: 'No se pudo conectar.',\n continueHere: 'Continuar aquí',\n tryAgain: 'Intentar de nuevo',\n talkToPerson: 'Hablar con una persona',\n messageSending: 'Enviando',\n messageHeld: 'Se envía cuando continúes',\n messageNotSent: 'No enviado',\n messageDelivered: 'Entregado',\n messageCutOff: 'Esta respuesta quedó incompleta.',\n takeoverStarted: 'Una persona de {by} está respondiendo.',\n takeoverEnded: '{agent} volvió.',\n handoffCreated: 'Le pasamos esto al equipo. Responderán {expected}.',\n handoffCreatedNoTime: 'Le pasamos esto al equipo. Responderán pronto.',\n flowSent: 'Tus respuestas se enviaron.',\n flowNotSent: 'Tus respuestas aún no se pudieron enviar.',\n turnFailed: 'Algo salió mal.',\n working: '{agent} está en ello…',\n proposalConfirm: 'Confirmar',\n proposalDecline: 'Rechazar',\n proposalChange: 'Cambiar',\n proposalConfirmed: 'Confirmado',\n proposalDeclined: 'Rechazado',\n proposalFailed: 'No se pudo confirmar',\n proposalExpired: 'Vencido',\n proposalSettled: 'Ya no está abierto',\n questionSubmit: 'Enviar',\n questionSkip: 'Omitir',\n questionOther: 'Otro',\n questionSearch: 'Buscar',\n questionAnswered: 'Respondida',\n questionReplaced: 'Reemplazada por una pregunta más reciente',\n questionStep: 'Pregunta {step} de {total}',\n questionAddPhoto: 'Agregar una foto',\n questionCharactersLeft: 'Quedan {count} caracteres',\n priceFrom: 'Desde {price}',\n open: 'Abrir',\n};\n\nconst ptBR: Copy = {\n disclosureFallback:\n 'Você está conversando com um agente de IA. Com tecnologia Vinaverse.',\n agentLabel: 'Agente de IA',\n agentFallbackName: 'o agente',\n you: 'Você',\n staffLabel: '{by} · pessoa',\n staffFallbackRole: 'a equipe',\n composerPlaceholder: 'Mensagem para {agent}',\n composerPlaceholderTakeover: 'Mensagem para {by}',\n send: 'Enviar',\n stop: 'Parar',\n typeAnswerBelow: 'Digite sua resposta abaixo.',\n bannerConnecting: 'Conectando…',\n bannerReconnecting: 'Reconectando…',\n bannerOffline: 'Sem conexão. As mensagens são enviadas quando você voltar.',\n bannerContinuedElsewhere: 'Esta conversa continuou em outro aparelho.',\n bannerUnavailable: 'Não foi possível conectar.',\n continueHere: 'Continuar aqui',\n tryAgain: 'Tentar de novo',\n talkToPerson: 'Falar com uma pessoa',\n messageSending: 'Enviando',\n messageHeld: 'Será enviada quando você continuar',\n messageNotSent: 'Não enviada',\n messageDelivered: 'Entregue',\n messageCutOff: 'Esta resposta foi interrompida.',\n takeoverStarted: 'Uma pessoa de {by} está respondendo agora.',\n takeoverEnded: '{agent} voltou.',\n handoffCreated: 'Passamos isso para a equipe. Eles vão responder {expected}.',\n handoffCreatedNoTime:\n 'Passamos isso para a equipe. Eles vão responder em breve.',\n flowSent: 'Suas respostas foram enviadas.',\n flowNotSent: 'Ainda não foi possível enviar suas respostas.',\n turnFailed: 'Algo deu errado.',\n working: '{agent} está cuidando disso…',\n proposalConfirm: 'Confirmar',\n proposalDecline: 'Recusar',\n proposalChange: 'Alterar',\n proposalConfirmed: 'Confirmado',\n proposalDeclined: 'Recusado',\n proposalFailed: 'Não foi possível confirmar',\n proposalExpired: 'Expirado',\n proposalSettled: 'Não está mais aberto',\n questionSubmit: 'Enviar',\n questionSkip: 'Pular',\n questionOther: 'Outro',\n questionSearch: 'Buscar',\n questionAnswered: 'Respondida',\n questionReplaced: 'Substituída por uma pergunta mais recente',\n questionStep: 'Pergunta {step} de {total}',\n questionAddPhoto: 'Adicionar uma foto',\n questionCharactersLeft: 'Restam {count} caracteres',\n priceFrom: 'A partir de {price}',\n open: 'Abrir',\n};\n\n/** The built-in languages; any other locale falls back to English, its own `copy` overrides aside. */\nexport const COPY: Readonly<Record<'en' | 'es' | 'pt-BR', Copy>> = {\n en,\n es,\n 'pt-BR': ptBR,\n};\n\n/**\n * Keys a tenant may not override in a built-in language: the AI disclosure is the platform's, never removed or reworded.\n * In a language without built-in copy the tenant supplies them, translated, so the disclosure reads in the person's\n * language, and only a translation that still discloses is taken (`discloses`): the label says AI, the disclosure says\n * AI and names Vinaverse.\n */\nconst FIXED: ReadonlySet<CopyKey> = new Set([\n 'disclosureFallback',\n 'agentLabel',\n]);\n\n/**\n * \"AI\" as languages write it: AI, IA (es, pt, fr, it, ro), KI (de, nl, da, no, sv), SI (pl), YZ (tr), ИИ (ru), ШІ\n * (uk), and the words for it in Arabic, Hebrew, Hindi, Chinese, Japanese and Korean.\n */\nexport const AI_MARK =\n /(?:^|[^\\p{L}])(?:AI|IA|KI|SI|YZ|ИИ|ШІ)(?:$|[^\\p{L}])|الذكاء الاصطناعي|بالذكاء|בינה מלאכותית|एआई|कृत्रिम बुद्धि|人工智能|人工知能|인공지능/u;\n\n/**\n * Whether a tenant's text for a fixed key still makes the AI disclosure: the label says AI; the disclosure says AI\n * and names Vinaverse. A tenant's translation that does not is ignored, and the English built-in shows instead.\n */\nfunction discloses(key: string, value: string): boolean {\n if (!AI_MARK.test(value)) return false;\n return key !== 'disclosureFallback' || value.includes('Vinaverse');\n}\n\nexport type Translate = (\n key: CopyKey,\n vars?: Readonly<Record<string, string | number>>,\n) => string;\n\n/** The built-in copy for a locale: its language (`es-US` → `es`, `pt-PT` → `pt-BR`), else null. */\nfunction builtIn(locale: string | undefined): Copy | null {\n const language = (locale ?? 'en').split(/[-_]/)[0]?.toLowerCase();\n if (language === 'en') return COPY.en;\n if (language === 'es') return COPY.es;\n if (language === 'pt') return COPY['pt-BR'];\n return null;\n}\n\n/** The built-in copy for a locale, English when the language has none. */\nexport function builtInCopy(locale: string | undefined): Copy {\n return builtIn(locale) ?? COPY.en;\n}\n\n/** A translator for a locale, with the tenant's overrides on top (fixed keys excepted). */\nexport function createTranslate(\n locale: string | undefined,\n overrides: CopyOverrides = {},\n): Translate {\n const own = builtIn(locale);\n const merged: Record<string, string> = { ...(own ?? COPY.en) };\n for (const [key, value] of Object.entries(overrides)) {\n if (value === undefined) continue;\n if (FIXED.has(key as CopyKey) && !(own === null && discloses(key, value)))\n continue;\n merged[key] = value;\n }\n return (key, vars) =>\n (merged[key] ?? en[key]).replace(/\\{(\\w+)\\}/g, (all, name: string) =>\n vars && name in vars ? String(vars[name]) : all,\n );\n}\n\n/**\n * Words a Vinaverse UI never says to people (a tenant override that uses them gets a development warning): the\n * runtime is an agent, never an assistant or a bot; and never \"crew\".\n */\nexport const BANNED_WORDS: readonly RegExp[] = [\n /\\bassistant/i,\n /\\basistente/i,\n /\\bassistent/i,\n /\\bbot\\b/i,\n /\\bcrew\\b/i,\n];\n\n/** The overrides that use a banned word, by key. */\nexport function bannedWordsIn(overrides: CopyOverrides): CopyKey[] {\n return (Object.entries(overrides) as [CopyKey, string | undefined][])\n .filter(([, v]) => v !== undefined && BANNED_WORDS.some((w) => w.test(v)))\n .map(([k]) => k);\n}\n","// Dates, times, money and text direction in the person's locale, through Intl (Hermes has it), with a plain fallback\n// where a runtime lacks it.\n\n/** Languages and scripts written right to left. */\nconst RTL_LANGUAGES = new Set([\n 'ar',\n 'he',\n 'iw',\n 'fa',\n 'ur',\n 'ps',\n 'yi',\n 'dv',\n 'ckb',\n 'sd',\n 'ug',\n 'syr',\n]);\nconst RTL_SCRIPTS = new Set([\n 'arab',\n 'hebr',\n 'thaa',\n 'syrc',\n 'nkoo',\n 'adlm',\n 'rohg',\n]);\n\n/** `rtl` for Arabic, Hebrew, Persian, Urdu and the other right-to-left languages and scripts; `ltr` otherwise. */\nexport function textDirection(locale: string | undefined): 'ltr' | 'rtl' {\n const parts = (locale ?? '').toLowerCase().split(/[-_]/);\n if (parts.some((p) => p.length === 4 && RTL_SCRIPTS.has(p))) return 'rtl';\n return RTL_LANGUAGES.has(parts[0] ?? '') ? 'rtl' : 'ltr';\n}\n\n/** An amount in minor units (`amount` cents) in its currency: `$85.00`. */\nexport function formatMoney(\n amountMinor: number,\n currency: string,\n locale?: string,\n): string {\n try {\n const format = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n });\n const digits = format.resolvedOptions().maximumFractionDigits ?? 2;\n return format.format(amountMinor / 10 ** digits);\n } catch {\n return `${currency} ${(amountMinor / 100).toFixed(2)}`;\n }\n}\n\n/** A start and an end: \"Wed, Oct 14, 10:00 – 11:30 AM\" in the locale and time zone. */\nexport function formatTimeRange(\n start: string,\n end: string | undefined,\n locale?: string,\n timeZone?: string,\n): string {\n const from = new Date(start);\n if (Number.isNaN(from.getTime())) return start;\n const options: Intl.DateTimeFormatOptions = {\n weekday: 'short',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n ...(timeZone ? { timeZone } : {}),\n };\n try {\n const format = new Intl.DateTimeFormat(locale, options);\n const to = end ? new Date(end) : null;\n if (!to || Number.isNaN(to.getTime())) return format.format(from);\n return typeof format.formatRange === 'function'\n ? format.formatRange(from, to)\n : `${format.format(from)} – ${format.format(to)}`;\n } catch {\n return from.toISOString();\n }\n}\n\n/** A calendar date (`YYYY-MM-DD`) in the locale: \"October 14, 2026\". */\nexport function formatDate(date: string, locale?: string): string {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(date);\n if (!m) return date;\n try {\n return new Intl.DateTimeFormat(locale, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n timeZone: 'UTC',\n }).format(new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3]))));\n } catch {\n return date;\n }\n}\n"]}