@7ots/cli 0.1.17 → 0.1.36

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 (107) hide show
  1. package/.env.example +14 -0
  2. package/README.md +11 -0
  3. package/brand/logos/base.svg +1 -0
  4. package/brand/logos/clawpump.png +0 -0
  5. package/brand/logos/conductors.svg +1 -0
  6. package/brand/logos/notlogin.svg +12 -0
  7. package/brand/logos/pumpfun.png +0 -0
  8. package/brand/logos/solana.png +0 -0
  9. package/brand/logos/spawnerbot.svg +1 -0
  10. package/brand/logos/virtuals.png +0 -0
  11. package/cli/7ots.mjs +61 -1
  12. package/cli/lib/account.mjs +23 -3
  13. package/cli/lib/assistant.mjs +92 -14
  14. package/cli/lib/brain.mjs +84 -11
  15. package/cli/lib/card-shot.mjs +1 -1
  16. package/cli/lib/config.mjs +14 -3
  17. package/cli/lib/desktop-sync.mjs +177 -0
  18. package/cli/lib/i18n.mjs +9 -0
  19. package/cli/lib/inferences.mjs +19 -2
  20. package/cli/lib/integrations.mjs +98 -13
  21. package/cli/lib/mcp.mjs +1 -1
  22. package/cli/lib/open.mjs +3 -1
  23. package/cli/lib/pet-server.mjs +352 -41
  24. package/cli/lib/prompts.mjs +1 -1
  25. package/cli/lib/screen.mjs +1 -1
  26. package/cli/lib/senses/gestures.mjs +121 -0
  27. package/cli/lib/senses/index.mjs +490 -0
  28. package/cli/lib/senses/rules.mjs +159 -0
  29. package/cli/lib/senses/sources/activity.mjs +95 -0
  30. package/cli/lib/senses/sources/calendar.mjs +75 -0
  31. package/cli/lib/senses/sources/index.mjs +17 -0
  32. package/cli/lib/senses/sources/mail.mjs +48 -0
  33. package/cli/lib/senses/sources/system.mjs +39 -0
  34. package/cli/lib/senses/util.mjs +41 -0
  35. package/cli/lib/senses/vendor.mjs +78 -0
  36. package/cli/lib/stt-local.py +16 -8
  37. package/cli/lib/stt.mjs +53 -6
  38. package/cli/lib/tooluse.mjs +56 -0
  39. package/cli/lib/tts-local.mjs +2 -2
  40. package/cli/lib/vm.mjs +2 -2
  41. package/cli/lib/wake-local.py +109 -0
  42. package/cli/lib/wake.mjs +102 -0
  43. package/cli/pet/electron/main.cjs +190 -8
  44. package/cli/pet/pet.html +153 -34
  45. package/cli/pet/senses.html +342 -0
  46. package/cli/pet/settings.html +815 -74
  47. package/dist/7ots.esm.js +373 -146
  48. package/dist/7ots.esm.js.map +4 -4
  49. package/dist/7ots.iife.js +373 -146
  50. package/dist/7ots.iife.js.map +4 -4
  51. package/llms.txt +27 -0
  52. package/package.json +5 -2
  53. package/server/channels/apuchat.mjs +18 -4
  54. package/server/errors.mjs +90 -0
  55. package/server/notify.mjs +78 -0
  56. package/server/server.mjs +84 -14
  57. package/server/settings.mjs +3 -0
  58. package/server/site.mjs +401 -0
  59. package/server/tts.mjs +29 -5
  60. package/src/avatar/AvatarStage.js +2 -2
  61. package/src/avatar/three.js +3 -2
  62. package/src/character/AvatarEditor.js +2 -1
  63. package/src/character/Character.js +38 -5
  64. package/src/character/TradingCard.js +2 -0
  65. package/src/character/beat.js +64 -2
  66. package/src/character/mods/orc.js +8 -1
  67. package/src/character/mods.js +104 -10
  68. package/src/character/motion.js +252 -1
  69. package/src/character/parts.js +40 -38
  70. package/src/character/styles.js +40 -38
  71. package/src/character3d/Character3D.js +26 -5
  72. package/src/character3d/body.js +14 -12
  73. package/src/character3d/export.js +693 -0
  74. package/src/character3d/fx.js +13 -0
  75. package/src/character3d/index.js +2 -0
  76. package/src/character3d/materials.js +106 -10
  77. package/src/character3d/room-themes.js +1184 -0
  78. package/src/character3d/room.js +487 -0
  79. package/src/character3d/stage.js +14 -2
  80. package/src/creator/StepCreator.js +316 -0
  81. package/src/i18n/index.js +3 -3
  82. package/src/i18n/messages/character.js +352 -4
  83. package/src/i18n/messages/creator.js +138 -0
  84. package/src/i18n/messages/identity.js +89 -1
  85. package/src/i18n/messages/platform.js +270 -4
  86. package/src/i18n/messages/server.js +443 -1
  87. package/src/i18n/messages/widget.js +233 -0
  88. package/src/identity/random.js +14 -2
  89. package/src/identity/schema.js +2 -1
  90. package/src/index.js +9 -2
  91. package/src/voice/tags.js +22 -0
  92. package/server/platform/apuchat.mjs +0 -266
  93. package/server/platform/auth.mjs +0 -319
  94. package/server/platform/connect.mjs +0 -387
  95. package/server/platform/crypto.mjs +0 -80
  96. package/server/platform/db.mjs +0 -275
  97. package/server/platform/device.mjs +0 -222
  98. package/server/platform/integrations.mjs +0 -169
  99. package/server/platform/look.mjs +0 -20
  100. package/server/platform/mods.mjs +0 -222
  101. package/server/platform/orquesta.mjs +0 -577
  102. package/server/platform/profile.mjs +0 -161
  103. package/server/platform/routes.mjs +0 -542
  104. package/server/platform/runtime.mjs +0 -242
  105. package/server/platform/sites.mjs +0 -146
  106. package/server/platform/store.mjs +0 -456
  107. package/server/platform/vm.mjs +0 -1057
@@ -0,0 +1,401 @@
1
+ /**
2
+ * Capa pública de 7ots.com sobre los estáticos de site/:
3
+ *
4
+ * - idioma servido desde el servidor: ?lang → cookie 7ots-lang → Accept-Language → inglés.
5
+ * <html lang>, textos data-i18n (site/i18n.js), canonical, hreflang (es/en/pt/zh/hi + x-default),
6
+ * og:locale/og:title/og:description/og:image por idioma.
7
+ * - pie común (ecosistema con logos, privacidad, términos, contacto, idiomas) + botón de feedback.
8
+ * - /site/privacy/ · /site/terms/ · /site/contact/ (site/footer/legal.js)
9
+ * - POST /api/site/contact formulario de contacto/feedback → correo interno (server/notify.mjs)
10
+ * - /robots.txt · /sitemap.xml · página 404 en HTML para navegadores
11
+ */
12
+
13
+ import { SITE_LANGS, OG_LOCALE, LANG_NAMES, STRINGS, footerHtml, pickLang } from '../site/footer/strings.js';
14
+ import { LEGAL, UPDATED } from '../site/footer/legal.js';
15
+ import siteMessages from '../site/i18n.js';
16
+ import { sendNotify } from './notify.mjs';
17
+
18
+ const env = process.env;
19
+ const BASE = () => (env.PLATFORM_URL || 'https://7ots.com').replace(/\/+$/, '');
20
+ const LANG_COOKIE = '7ots-lang';
21
+ const EMAIL_RE = /^[^\s@]{1,64}@[^\s@]+\.[^\s@]{2,}$/;
22
+
23
+ /** Páginas que llevan el pie común (las demás son apps/embeds con su propia UI). */
24
+ const FOOTER_PAGES = new Set(['site/start/index.html', 'site/index.html']);
25
+ /** Páginas indexables (sitemap). */
26
+ const PUBLIC_PAGES = ['/site/start/', '/site/', '/site/pet/', '/site/plaza/', '/site/contact/', '/site/privacy/', '/site/terms/'];
27
+
28
+ // ───────────────────────────── idioma ─────────────────────────────
29
+
30
+ function cookies(req) {
31
+ const out = {};
32
+ for (const part of String(req.headers.cookie || '').split(';')) {
33
+ const i = part.indexOf('=');
34
+ if (i > 0) out[part.slice(0, i).trim()] = part.slice(i + 1).trim();
35
+ }
36
+ return out;
37
+ }
38
+
39
+ /** Idioma del sitio para esta petición. */
40
+ export function siteLocale(req, url) {
41
+ const q = (url.searchParams.get('lang') || '').toLowerCase().split('-')[0];
42
+ if (SITE_LANGS.includes(q)) return q;
43
+ const c = (cookies(req)[LANG_COOKIE] || '').toLowerCase().split('-')[0];
44
+ if (SITE_LANGS.includes(c)) return c;
45
+ const prefs = String(req.headers['accept-language'] || '')
46
+ .split(',')
47
+ .map((p, i) => {
48
+ const [tag, ...params] = p.trim().split(';');
49
+ const qv = params.map((x) => x.trim()).find((x) => x.startsWith('q='));
50
+ return { lang: tag.toLowerCase().split('-')[0], q: qv ? Number(qv.slice(2)) || 0 : 1, i };
51
+ })
52
+ .filter((p) => p.lang && p.q > 0)
53
+ .sort((a, b) => b.q - a.q || a.i - b.i);
54
+ for (const p of prefs) if (SITE_LANGS.includes(p.lang)) return p.lang;
55
+ return 'en';
56
+ }
57
+
58
+ // Catálogo del sitio aplanado: lang → Map(clave → texto).
59
+ const flat = {};
60
+ function flatten(obj, prefix, map) {
61
+ for (const [k, v] of Object.entries(obj || {})) {
62
+ const key = prefix ? `${prefix}.${k}` : k;
63
+ if (v && typeof v === 'object' && !Array.isArray(v)) flatten(v, key, map);
64
+ else if (typeof v === 'string') map.set(key, v);
65
+ }
66
+ }
67
+ for (const l of SITE_LANGS) {
68
+ flat[l] = new Map();
69
+ flatten(siteMessages[l], '', flat[l]);
70
+ }
71
+ const msg = (lang, key) => flat[lang]?.get(key);
72
+
73
+ const esc = (v) => String(v ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
74
+ const unesc = (v) => String(v ?? '').replace(/&(amp|lt|gt|quot|#39);/g, (m, e) => ({ amp: '&', lt: '<', gt: '>', quot: '"', '#39': "'" })[e]);
75
+
76
+ /** URL de una variante de idioma (en = sin parámetro sería ambiguo con la detección: se marca explícito). */
77
+ const langUrl = (path, l) => `${BASE()}${path}?lang=${l}`;
78
+
79
+ function headTags(path, lang, explicit, { title, description }) {
80
+ const canonical = explicit ? langUrl(path, lang) : `${BASE()}${path}`;
81
+ const alt = SITE_LANGS.map((l) => `<link rel="alternate" hreflang="${l}" href="${langUrl(path, l)}">`).join('\n');
82
+ const ogImg = lang === 'es' ? 'og-es.png' : lang === 'pt' ? 'og-pt.png' : 'og.png';
83
+ const others = SITE_LANGS.filter((l) => l !== lang).map((l) => `<meta property="og:locale:alternate" content="${OG_LOCALE[l]}">`).join('\n');
84
+ const fonts = lang === 'zh' || lang === 'hi'
85
+ ? `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=${lang === 'zh' ? 'Noto+Sans+SC' : 'Noto+Sans+Devanagari'}:wght@400;600;700&display=swap">\n<style>:root{--font-body:Inter,${lang === 'zh' ? "'Noto Sans SC'" : "'Noto Sans Devanagari'"},system-ui,sans-serif;--font-display:'Bricolage Grotesque',${lang === 'zh' ? "'Noto Sans SC'" : "'Noto Sans Devanagari'"},Inter,system-ui,sans-serif}</style>`
86
+ : '';
87
+ return [
88
+ `<link rel="canonical" href="${canonical}">`,
89
+ alt,
90
+ `<link rel="alternate" hreflang="x-default" href="${BASE()}${path}">`,
91
+ `<meta property="og:locale" content="${OG_LOCALE[lang]}">`,
92
+ others,
93
+ `<meta property="og:url" content="${canonical}">`,
94
+ title ? `<meta property="og:title" content="${esc(title)}">\n<meta name="twitter:title" content="${esc(title)}">` : '',
95
+ description ? `<meta property="og:description" content="${esc(description)}">\n<meta name="twitter:description" content="${esc(description)}">` : '',
96
+ `<meta property="og:image" content="${BASE()}/brand/${ogImg}">`,
97
+ `<meta name="twitter:image" content="${BASE()}/brand/${ogImg}">`,
98
+ fonts,
99
+ ].filter(Boolean).join('\n');
100
+ }
101
+
102
+ function jsonLd(lang) {
103
+ const data = {
104
+ '@context': 'https://schema.org',
105
+ '@graph': [
106
+ { '@type': 'Organization', '@id': `${BASE()}/#org`, name: '7ots', url: BASE(), logo: `${BASE()}/brand/apple-touch-icon.png`, sameAs: ['https://github.com/7ots/pet', 'https://www.npmjs.com/package/@7ots/cli'] },
107
+ { '@type': 'WebSite', '@id': `${BASE()}/#site`, name: '7ots', url: BASE(), inLanguage: SITE_LANGS, publisher: { '@id': `${BASE()}/#org` } },
108
+ {
109
+ '@type': 'SoftwareApplication',
110
+ name: '7ots',
111
+ applicationCategory: 'LifestyleApplication',
112
+ operatingSystem: 'Windows, macOS, Linux, Web',
113
+ description: msg(lang, 'site.meta.description') || msg('en', 'site.meta.description'),
114
+ offers: { '@type': 'Offer', price: '0', priceCurrency: 'USD' },
115
+ url: BASE(),
116
+ },
117
+ ],
118
+ };
119
+ return `<script type="application/ld+json">${JSON.stringify(data).replace(/</g, '\\u003c')}</script>`;
120
+ }
121
+
122
+ /**
123
+ * Traduce y completa una página HTML de site/ para el idioma de la petición.
124
+ * @param {string} rel ruta relativa al repo (site/start/index.html)
125
+ */
126
+ export function renderSitePage(req, url, rel, html) {
127
+ const lang = siteLocale(req, url);
128
+ const explicit = SITE_LANGS.includes((url.searchParams.get('lang') || '').toLowerCase());
129
+ const embed = url.searchParams.has('embed');
130
+ const path = url.pathname;
131
+ const tr = (key) => {
132
+ const v = msg(lang, key);
133
+ return v !== undefined && !v.includes('{') ? v : undefined;
134
+ };
135
+
136
+ let out = html.replace(/<html\b([^>]*?)\slang=(["'])[^"']*\2/i, `<html$1 lang="${lang}"`);
137
+ if (lang !== 'en') {
138
+ // Texto de elementos con data-i18n y sin hijos.
139
+ out = out.replace(/(<([a-z0-9]+)\b[^>]*?\sdata-i18n="([\w.-]+)"[^>]*>)([^<]*)(<\/\2>)/gi, (m, open, tag, key, inner, close) => {
140
+ const v = tr(key);
141
+ return v === undefined ? m : `${open}${esc(v)}${close}`;
142
+ });
143
+ // Atributos traducibles.
144
+ const ATTRS = { content: 'content', aria: 'aria-label', placeholder: 'placeholder', value: 'value', title: 'title' };
145
+ out = out.replace(/<[a-z0-9]+\b[^>]*\sdata-i18n-(content|aria|placeholder|value|title)="[\w.-]+"[^>]*>/gi, (tagStr) => {
146
+ let t = tagStr;
147
+ for (const [k, attr] of Object.entries(ATTRS)) {
148
+ const km = t.match(new RegExp(`\\sdata-i18n-${k}="([\\w.-]+)"`));
149
+ if (!km) continue;
150
+ const v = tr(km[1]);
151
+ if (v === undefined) continue;
152
+ const re = new RegExp(`(\\s${attr}=)(["'])[^"']*\\2`);
153
+ t = re.test(t) ? t.replace(re, `$1"${esc(v)}"`) : t.replace(/\s*\/?>$/, (end) => ` ${attr}="${esc(v)}"${end}`);
154
+ }
155
+ return t;
156
+ });
157
+ }
158
+
159
+ const title = unesc((out.match(/<title[^>]*>([^<]*)<\/title>/i) || [])[1] || '');
160
+ const description = unesc((out.match(/<meta\s+name="description"\s+content="([^"]*)"/i) || [])[1] || '');
161
+ // Fuera lo que se vuelve a poner por idioma.
162
+ out = out.replace(/\s*<link rel="canonical"[^>]*>/gi, '')
163
+ .replace(/\s*<link rel="alternate" hreflang=[^>]*>/gi, '')
164
+ .replace(/\s*<meta property="og:(url|title|description|image|locale)"[^>]*>/gi, '')
165
+ .replace(/\s*<meta name="twitter:(title|description|image)"[^>]*>/gi, '');
166
+
167
+ let head = headTags(path, lang, explicit, { title, description }) + '\n<script src="/site/footer/errors.js" defer></script>';
168
+ if (FOOTER_PAGES.has(rel) && !embed) head += `\n<link rel="stylesheet" href="/site/footer/footer.css">\n${jsonLd(lang)}`;
169
+ out = out.replace(/<\/head>/i, `${head}\n</head>`);
170
+ if (FOOTER_PAGES.has(rel) && !embed) {
171
+ out = out.replace(/<\/body>(?![\s\S]*<\/body>)/i, `${footerHtml(lang)}\n<script type="module" src="/site/footer/footer.js"></script>\n</body>`);
172
+ }
173
+ return out;
174
+ }
175
+
176
+ // ───────────────────────────── páginas propias ─────────────────────────────
177
+
178
+ function pageShell(req, url, { lang, path, title, description, body, noindex = false }) {
179
+ const explicit = SITE_LANGS.includes((url.searchParams.get('lang') || '').toLowerCase());
180
+ return `<!doctype html>
181
+ <html lang="${lang}">
182
+ <head>
183
+ <meta charset="utf-8">
184
+ <meta name="viewport" content="width=device-width,initial-scale=1">
185
+ <title>${esc(title)} · 7ots</title>
186
+ <meta name="description" content="${esc(description)}">
187
+ ${noindex ? '<meta name="robots" content="noindex">' : ''}
188
+ <meta property="og:type" content="website">
189
+ <meta name="twitter:card" content="summary_large_image">
190
+ <meta name="theme-color" content="#120d33">
191
+ <link rel="icon" type="image/svg+xml" href="/brand/favicon.svg">
192
+ <link rel="apple-touch-icon" href="/brand/apple-touch-icon.png">
193
+ <link rel="preconnect" href="https://fonts.googleapis.com">
194
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
195
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=Inter:wght@400;500;600&display=swap">
196
+ <link rel="stylesheet" href="/brand/tokens.css">
197
+ <link rel="stylesheet" href="/site/footer/footer.css">
198
+ ${headTags(path, lang, explicit, { title: `${title} · 7ots`, description })}
199
+ <script src="/site/footer/errors.js" defer></script>
200
+ </head>
201
+ <body class="ots-page">
202
+ <header class="ots-page-top"><a class="ots-page-logo" href="/site/start/${lang === 'en' ? '' : `?lang=${lang}`}" aria-label="7ots.com"><img src="/brand/mark.svg" alt="" width="28" height="28"><span>7ots</span></a></header>
203
+ <main class="ots-page-main">
204
+ ${body}
205
+ </main>
206
+ ${footerHtml(lang)}
207
+ <script type="module" src="/site/footer/footer.js"></script>
208
+ </body>
209
+ </html>`;
210
+ }
211
+
212
+ function legalBody(lang, doc) {
213
+ const L = LEGAL[lang];
214
+ const d = L[doc];
215
+ const secs = d.sections.map(([h, ps]) => `<section><h2>${esc(h)}</h2>${ps.map((p) => `<p>${esc(p)}</p>`).join('')}</section>`).join('\n');
216
+ return `<article class="ots-legal-doc"><h1>${esc(d.title)}</h1><p class="ots-lead">${esc(d.lead)}</p>${secs}<p class="ots-updated">${esc(L.updated)}: <time datetime="${UPDATED}">${UPDATED}</time></p></article>`;
217
+ }
218
+
219
+ function contactBody(lang, url) {
220
+ const L = LEGAL[lang].contact;
221
+ const t = STRINGS[lang];
222
+ const sent = url.searchParams.get('sent') === '1';
223
+ const err = url.searchParams.get('error');
224
+ const kind = url.searchParams.get('kind') === 'feedback' ? 'feedback' : 'contact';
225
+ if (sent) return `<article class="ots-legal-doc"><h1>${esc(L.sentTitle)}</h1><p class="ots-lead">${esc(t.sent)}</p><p><a href="/site/start/${lang === 'en' ? '' : `?lang=${lang}`}">${esc(L.back)}</a></p></article>`;
226
+ return `<article class="ots-legal-doc"><h1>${esc(kind === 'feedback' ? t.feedbackTitle : L.title)}</h1><p class="ots-lead">${esc(kind === 'feedback' ? t.feedbackLead : L.lead)}</p>
227
+ ${err ? `<p class="ots-form-msg err" role="alert">${esc(err === 'invalid' ? t.invalid : t.error)}</p>` : ''}
228
+ <form class="ots-form" method="post" action="/api/site/contact" data-ots-form>
229
+ <input type="hidden" name="kind" value="${kind}">
230
+ <input type="hidden" name="lang" value="${lang}">
231
+ <div class="ots-hp" aria-hidden="true"><label>Website <input name="website" tabindex="-1" autocomplete="off"></label></div>
232
+ <label>${esc(t.name)}<input name="name" maxlength="80" autocomplete="name"></label>
233
+ <label>${esc(kind === 'feedback' ? t.emailOpt : t.email)}<input name="email" type="email" maxlength="200" autocomplete="email"${kind === 'feedback' ? '' : ' required'}></label>
234
+ <label>${esc(t.message)}<textarea name="message" rows="6" maxlength="5000" required></textarea></label>
235
+ <button type="submit" class="ots-btn">${esc(t.send)}</button>
236
+ </form></article>`;
237
+ }
238
+
239
+ // ───────────────────────────── contacto / feedback ─────────────────────────────
240
+
241
+ const hits = new Map(); // ip → timestamps
242
+ let dayCount = { day: '', n: 0 };
243
+ function contactAllowed(ip) {
244
+ const now = Date.now();
245
+ const day = new Date(now).toISOString().slice(0, 10);
246
+ if (dayCount.day !== day) dayCount = { day, n: 0 };
247
+ if (dayCount.n >= Number(env.CONTACT_MAX_PER_DAY || 300)) return { ok: false, retry: 3600 };
248
+ const list = (hits.get(ip) || []).filter((t) => now - t < 86400_000);
249
+ const recent = list.filter((t) => now - t < 600_000);
250
+ if (recent.length >= 5) return { ok: false, retry: Math.ceil((600_000 - (now - recent[0])) / 1000) };
251
+ if (list.length >= 20) return { ok: false, retry: Math.ceil((86400_000 - (now - list[0])) / 1000) };
252
+ list.push(now);
253
+ hits.set(ip, list);
254
+ if (hits.size > 5000) hits.clear();
255
+ dayCount.n++;
256
+ return { ok: true };
257
+ }
258
+
259
+ async function readBody(req, limit) {
260
+ let size = 0;
261
+ const chunks = [];
262
+ for await (const c of req) {
263
+ size += c.length;
264
+ if (size > limit) return null;
265
+ chunks.push(c);
266
+ }
267
+ const raw = Buffer.concat(chunks).toString('utf8');
268
+ const type = String(req.headers['content-type'] || '');
269
+ if (type.includes('application/json')) {
270
+ try {
271
+ return JSON.parse(raw || '{}');
272
+ } catch {
273
+ return null;
274
+ }
275
+ }
276
+ return Object.fromEntries(new URLSearchParams(raw));
277
+ }
278
+
279
+ const clip = (v, n) => String(v ?? '').replace(/\r/g, '').slice(0, n).trim();
280
+
281
+ /**
282
+ * @param {{ send: Function, clientIp: (req) => string, originOf: (req) => string }} deps
283
+ */
284
+ export function createSite({ send, clientIp, originOf }) {
285
+ function html(res, status, body, req) {
286
+ res.writeHead(status, { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-cache', Vary: 'Accept-Language, Cookie', 'X-Content-Type-Options': 'nosniff' });
287
+ res.end(req.method === 'HEAD' ? undefined : body);
288
+ }
289
+
290
+ async function contact(req, res, url) {
291
+ const origin = req.headers.origin;
292
+ if (origin && origin !== originOf(req) && origin !== new URL(BASE()).origin) return send(res, 403, { error: 'origin not allowed' });
293
+ const json = String(req.headers['content-type'] || '').includes('application/json');
294
+ const body = await readBody(req, 32 * 1024);
295
+ const lang = pickLang(body?.lang);
296
+ const kind = body?.kind === 'feedback' ? 'feedback' : 'contact';
297
+ const back = (q) => {
298
+ res.writeHead(303, { Location: `/site/contact/?lang=${lang}&kind=${kind}&${q}`, 'Cache-Control': 'no-store' });
299
+ res.end();
300
+ };
301
+ if (!body) return json ? send(res, 400, { error: 'bad request' }) : back('error=invalid');
302
+ // Honeypot: el bot cree que salió.
303
+ if (body.website) return json ? send(res, 200, { ok: true }) : back('sent=1');
304
+ const message = clip(body.message, 5000);
305
+ const email = clip(body.email, 200).toLowerCase();
306
+ const name = clip(body.name, 80);
307
+ const rating = body.rating === 'up' || body.rating === 'down' ? body.rating : '';
308
+ if (message.length < 2 || (email && !EMAIL_RE.test(email)) || (kind === 'contact' && !email)) {
309
+ return json ? send(res, 400, { error: STRINGS[lang].invalid }) : back('error=invalid');
310
+ }
311
+ const lim = contactAllowed(clientIp(req));
312
+ if (!lim.ok) {
313
+ res.setHeader('Retry-After', String(lim.retry));
314
+ return json ? send(res, 429, { error: STRINGS[lang].error }) : back('error=limit');
315
+ }
316
+ const page = clip(body.page || req.headers.referer, 300);
317
+ const text = [
318
+ message,
319
+ '',
320
+ '—',
321
+ `Tipo: ${kind}${rating ? ` (${rating === 'up' ? '👍' : '👎'})` : ''}`,
322
+ `Nombre: ${name || '-'}`,
323
+ `Email: ${email || '-'}`,
324
+ `Idioma: ${lang}`,
325
+ `Página: ${page || '-'}`,
326
+ `Fecha: ${new Date().toISOString()}`,
327
+ ].join('\n');
328
+ try {
329
+ await sendNotify({
330
+ to: env.CONTACT_TO || 'maestro@apumail.com',
331
+ subject: `[7ots ${kind}] ${clip(message.split('\n')[0], 80)}`,
332
+ text,
333
+ replyTo: email || undefined,
334
+ });
335
+ } catch (e) {
336
+ console.warn('[7ots] contacto no enviado:', e.message);
337
+ return json ? send(res, 502, { error: STRINGS[lang].error }) : back('error=send');
338
+ }
339
+ return json ? send(res, 200, { ok: true }) : back('sent=1');
340
+ }
341
+
342
+ /** @returns {Promise<boolean>} true si atendió la petición */
343
+ async function handle(req, res, url) {
344
+ const p = url.pathname;
345
+ const get = req.method === 'GET' || req.method === 'HEAD';
346
+ if (p === '/api/site/contact') {
347
+ if (req.method !== 'POST') return send(res, 405, { error: 'method not allowed' }), true;
348
+ await contact(req, res, url);
349
+ return true;
350
+ }
351
+ if (p === '/robots.txt' && get) {
352
+ res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8', 'Cache-Control': 'public, max-age=3600' });
353
+ res.end(req.method === 'HEAD' ? undefined : `User-agent: *\nAllow: /\nDisallow: /api/\nDisallow: /auth/\nDisallow: /app/\nDisallow: /backoffice/\n\nSitemap: ${BASE()}/sitemap.xml\n`);
354
+ return true;
355
+ }
356
+ if (p === '/sitemap.xml' && get) {
357
+ const urls = PUBLIC_PAGES.map((pg) => {
358
+ const alts = SITE_LANGS.map((l) => ` <xhtml:link rel="alternate" hreflang="${l}" href="${langUrl(pg, l)}"/>`).join('\n');
359
+ return ` <url>\n <loc>${BASE()}${pg}</loc>\n${alts}\n <xhtml:link rel="alternate" hreflang="x-default" href="${BASE()}${pg}"/>\n </url>`;
360
+ }).join('\n');
361
+ res.writeHead(200, { 'Content-Type': 'application/xml; charset=utf-8', 'Cache-Control': 'public, max-age=3600' });
362
+ res.end(req.method === 'HEAD' ? undefined : `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">\n${urls}\n</urlset>\n`);
363
+ return true;
364
+ }
365
+ const m = p.match(/^\/site\/(privacy|terms|contact)(\/?)$/);
366
+ if (m && get) {
367
+ if (!m[2]) {
368
+ res.writeHead(301, { Location: `${p}/${url.search}` });
369
+ res.end();
370
+ return true;
371
+ }
372
+ const lang = siteLocale(req, url);
373
+ const doc = m[1];
374
+ const L = LEGAL[lang];
375
+ const body = doc === 'contact' ? contactBody(lang, url) : legalBody(lang, doc);
376
+ const sub = url.searchParams.has('sent') || url.searchParams.has('error');
377
+ html(res, 200, pageShell(req, url, { lang, path: `/site/${doc}/`, title: L[doc].title, description: L[doc].lead, body, noindex: sub }), req);
378
+ return true;
379
+ }
380
+ return false;
381
+ }
382
+
383
+ /** 404 propia: HTML para navegadores, JSON para el resto. */
384
+ function notFound(req, res, url, jsonBody) {
385
+ const accept = String(req.headers.accept || '');
386
+ if ((req.method === 'GET' || req.method === 'HEAD') && accept.includes('text/html') && !url.pathname.startsWith('/api/')) {
387
+ const lang = siteLocale(req, url);
388
+ const T = { en: ['Page not found', 'This page does not exist or was moved.', 'Go to 7ots.com'], es: ['Página no encontrada', 'Esta página no existe o se movió.', 'Ir a 7ots.com'], pt: ['Página não encontrada', 'Esta página não existe ou foi movida.', 'Ir para 7ots.com'], zh: ['页面未找到', '此页面不存在或已被移动。', '前往 7ots.com'], hi: ['पेज नहीं मिला', 'यह पेज मौजूद नहीं है या हटा दिया गया है।', '7ots.com पर जाएँ'] }[lang];
389
+ const body = `<article class="ots-legal-doc ots-404"><p class="ots-404-code">404</p><h1>${esc(T[0])}</h1><p class="ots-lead">${esc(T[1])}</p><p><a class="ots-btn" href="/site/start/${lang === 'en' ? '' : `?lang=${lang}`}">${esc(T[2])}</a></p></article>`;
390
+ const page = pageShell(req, url, { lang, path: '/site/start/', title: T[0], description: T[1], body, noindex: true })
391
+ .replace(/\s*<link rel="(canonical|alternate)"[^>]*>/g, '');
392
+ html(res, 404, page, req);
393
+ return;
394
+ }
395
+ send(res, 404, jsonBody);
396
+ }
397
+
398
+ return { handle, notFound };
399
+ }
400
+
401
+ export { LANG_NAMES };
package/server/tts.mjs CHANGED
@@ -161,7 +161,10 @@ async function openaiClient(apiKey) {
161
161
  return openaiClients.get(apiKey);
162
162
  }
163
163
 
164
- /** POST JSON con tiempo límite. Si el proveedor falla, 502 sin reenviar su respuesta (podría llevar datos de la cuenta). */
164
+ /**
165
+ * POST JSON con tiempo límite. Si el proveedor falla, 502 con un motivo accionable: solo el código y el mensaje
166
+ * corto del proveedor (sin correos ni ids de request), nunca su respuesta entera (podría llevar datos de la cuenta).
167
+ */
165
168
  async function post(url, { headers, body }, name) {
166
169
  let res;
167
170
  try {
@@ -169,13 +172,34 @@ async function post(url, { headers, body }, name) {
169
172
  } catch {
170
173
  throw httpError(502, `${name} unreachable`);
171
174
  }
172
- if (!res.ok) {
173
- await res.text().catch(() => ''); // libera el socket
174
- throw httpError(502, `${name} ${res.status}`);
175
- }
175
+ if (!res.ok) throw providerError(name, res.status, await res.text().catch(() => ''));
176
176
  return res;
177
177
  }
178
178
 
179
+ /**
180
+ * Error de un proveedor de voz → mensaje que dice qué hacer. Formatos reales (2026-10-07):
181
+ * ElevenLabs { detail: { code: 'paid_plan_required' | 'quota_exceeded' | 'unauthorized', status, message } }
182
+ * xAI { code, error: 'Incorrect API key provided…' } (¡clave inválida = 400, no 401!)
183
+ * apuchat { code: 'invalid_token', reason } 401 · sin token 402 (x402)
184
+ */
185
+ export function providerError(name, status, raw) {
186
+ let j = {};
187
+ try {
188
+ j = JSON.parse(raw);
189
+ } catch {}
190
+ const d = j && typeof j.detail === 'object' && j.detail ? j.detail : j || {};
191
+ const code = String(d.code || d.status || '').toLowerCase();
192
+ const said = String((typeof d.message === 'string' && d.message) || (typeof j.error === 'string' && j.error) || (typeof j.error?.message === 'string' && j.error.message) || j.reason || (typeof j.detail === 'string' && j.detail) || '');
193
+ const detail = said ? `: ${said.replace(/[\w.+-]+@[\w-]+(\.[\w-]+)+/g, '[email]').replace(/\s+/g, ' ').trim().slice(0, 180)}` : '';
194
+ const err = (key, vars = {}) => Object.assign(i18nError(502, `server.tts.${key}`, { provider: name, status, detail, ...vars }), { providerStatus: status });
195
+ if (name === 'apuchat' && status === 401) return err('apuchatToken');
196
+ if (name === 'apuchat' && status === 402) return err('apuchatPay');
197
+ if (name === 'ElevenLabs' && (status === 402 || /paid_plan|payment_required/.test(code))) return err('elevenPaid');
198
+ if (name === 'ElevenLabs' && /quota|credit/.test(code)) return err('elevenQuota');
199
+ if (status === 401 || status === 403 || /api key|invalid_api_key|unauthorized|authentication/i.test(`${code} ${said}`)) return err('badKey');
200
+ return err('failed');
201
+ }
202
+
179
203
  // Idiomas que admite xAI TTS (docs.x.ai); el resto se deja en 'auto'.
180
204
  const XAI_LANGS = ['en', 'ar-EG', 'ar-SA', 'ar-AE', 'bn', 'zh', 'fr', 'de', 'hi', 'id', 'it', 'ja', 'ko', 'pt-BR', 'pt-PT', 'ru', 'es-MX', 'es-ES', 'tr', 'vi'];
181
205
 
@@ -137,7 +137,7 @@ export class AvatarStage {
137
137
  this._mouth = null;
138
138
  this._face = null;
139
139
  const ch = m.createCharacter3D(this.container, this.cfg.character, {
140
- material: this.cfg.material === 'vinyl' ? 'vinyl' : 'plush',
140
+ material: this.cfg.material || 'plush',
141
141
  orbit: this.cfg.orbit === true,
142
142
  quality: this.cfg.quality || 'high',
143
143
  // escenario propio por encima del panel del widget (z-index 2147483000)
@@ -236,7 +236,7 @@ export class AvatarStage {
236
236
  }
237
237
  Object.assign(this.cfg, next);
238
238
  if (isPlush) {
239
- this._ch.update(next.character, { material: next.material === 'vinyl' ? 'vinyl' : 'plush' });
239
+ this._ch.update(next.character, { material: next.material || 'plush' });
240
240
  if (next.mood) this.setMood(next.mood);
241
241
  } else if (this.mode === '2d') {
242
242
  if (this._ch && next.character && !next.image) this._ch.update(next.character);
@@ -42,13 +42,14 @@ export function loadThree() {
42
42
  threeP ??= (async () => {
43
43
  if (globalThis.__OTS_THREE__?.three) return globalThis.__OTS_THREE__;
44
44
  const u = (p) => `${base()}/${p}/+esm`;
45
- const [three, BufferGeometryUtils, RoomEnvironment, GLTFLoader] = await Promise.all([
45
+ const [three, BufferGeometryUtils, RoomEnvironment, GLTFLoader, RoundedBoxGeometry] = await Promise.all([
46
46
  import(/* @vite-ignore */ /* webpackIgnore: true */ `${base()}/+esm`),
47
47
  import(/* @vite-ignore */ /* webpackIgnore: true */ u('examples/jsm/utils/BufferGeometryUtils.js')),
48
48
  import(/* @vite-ignore */ /* webpackIgnore: true */ u('examples/jsm/environments/RoomEnvironment.js')),
49
49
  import(/* @vite-ignore */ /* webpackIgnore: true */ u('examples/jsm/loaders/GLTFLoader.js')),
50
+ import(/* @vite-ignore */ /* webpackIgnore: true */ u('examples/jsm/geometries/RoundedBoxGeometry.js')),
50
51
  ]);
51
- return (globalThis.__OTS_THREE__ = { three, BufferGeometryUtils, RoomEnvironment, GLTFLoader });
52
+ return (globalThis.__OTS_THREE__ = { three, BufferGeometryUtils, RoomEnvironment, GLTFLoader, RoundedBoxGeometry });
52
53
  })();
53
54
  threeP.catch(() => { threeP = null; });
54
55
  return threeP;
@@ -31,6 +31,7 @@ import {
31
31
  import { translator, detectLocale, getLocale, onLocaleChange, formatNumber } from '../i18n/index.js';
32
32
  import { STYLES as ART_STYLES } from './styles.js';
33
33
  import { loadCharacter3D } from '../avatar/three.js';
34
+ import { LOOK_MATERIALS } from '../identity/schema.js';
34
35
  import { createTradingCard, CARD_FOILS } from './TradingCard.js';
35
36
 
36
37
  const VIEW = [-20, -50, 240, 270];
@@ -39,7 +40,7 @@ const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '
39
40
 
40
41
  const KINDS = ['character', 'plush', 'image'];
41
42
  const RANDOM_N = 12;
42
- const MATERIALS = ['plush', 'vinyl'];
43
+ const MATERIALS = LOOK_MATERIALS;
43
44
 
44
45
  const TABS = ['styles', 'shape', 'color', 'eyes', 'mouth', 'face', 'acc'];
45
46
  const GESTURES = CHARACTER_GESTURES;
@@ -36,7 +36,7 @@ import { STYLE_IDS, stylizeSpec, styleLayers, styleSeed, backdropIn, backdropCSS
36
36
  import { translator } from '../i18n/index.js';
37
37
  import {
38
38
  GESTURES, GESTURE_ALIAS, MORPHS, EFFECTS, VISEMES, POSE0, EASE, clamp, lerp, approach, seeded,
39
- shapePoints, ptsBox, textToVisemes, babbleVisemes,
39
+ shapePoints, ptsBox, textToVisemes, babbleVisemes, drawLegs,
40
40
  } from './motion.js';
41
41
 
42
42
  export const CHARACTER_MOODS = ['neutral', 'happy', 'angry', 'sad', 'fear', 'disgust', 'love', 'sleep', 'surprised'];
@@ -714,6 +714,7 @@ export function createCharacter(container, spec, opts = {}) {
714
714
  const mo = { open: 0, target: 0, msx: 1, tmsx: 1 };
715
715
  let blinkAt = -1e9;
716
716
  let gest = null;
717
+ let legs = null; // patas de los bailes: { pose, dir, k, on, start }
717
718
  let pose = { ...POSE0 };
718
719
  const morphs = new Map();
719
720
  let fxs = [];
@@ -724,7 +725,7 @@ export function createCharacter(container, spec, opts = {}) {
724
725
  let accMask = '';
725
726
  let morphMask = '';
726
727
  let px = 240;
727
- const keys = { body: '', eyes: '', brows: '', mouth: '', rig: '', mback: '', mfront: '', fx: '', fxface: '', mask: '', detail: '' };
728
+ const keys = { body: '', eyes: '', brows: '', mouth: '', rig: '', legs: '', mback: '', mfront: '', fx: '', fxface: '', mask: '', detail: '' };
728
729
 
729
730
  /**
730
731
  * Nivel de detalle de la piel: sin textura si se ve diminuto; sin filtros mientras el contorno
@@ -738,7 +739,7 @@ export function createCharacter(container, spec, opts = {}) {
738
739
 
739
740
  function build() {
740
741
  pal = palette(s);
741
- svg.innerHTML = `<style>${STYLE}</style><defs data-p="defs"></defs><defs data-p="mask"></defs><g data-p="styled"><g class="otsc-rig"><g data-p="fxback"></g><g class="otsc-sway"><g class="otsc-breathe"><g data-p="mback"></g><g data-p="back"></g><g data-p="body"></g><g data-p="cheeks"></g><g data-p="fxface"></g><g data-p="eyes"></g><g data-p="brows"></g><g data-p="mouth"></g><g data-p="front"></g><g data-p="mfront"></g></g></g><g data-p="fx"></g></g></g>`;
742
+ svg.innerHTML = `<style>${STYLE}</style><defs data-p="defs"></defs><defs data-p="mask"></defs><g data-p="styled"><g data-p="legs"></g><g class="otsc-rig"><g data-p="fxback"></g><g class="otsc-sway"><g class="otsc-breathe"><g data-p="mback"></g><g data-p="back"></g><g data-p="body"></g><g data-p="cheeks"></g><g data-p="fxface"></g><g data-p="eyes"></g><g data-p="brows"></g><g data-p="mouth"></g><g data-p="front"></g><g data-p="mfront"></g></g></g><g data-p="fx"></g></g></g>`;
742
743
  g = { rig: svg.querySelector('.otsc-rig') };
743
744
  for (const el of svg.querySelectorAll('[data-p]')) g[el.dataset.p] = el;
744
745
  if (!idle) {
@@ -1025,6 +1026,35 @@ export function createCharacter(container, spec, opts = {}) {
1025
1026
  if (fxFront !== keys.fx) { g.fx.innerHTML = fxFront; keys.fx = fxFront; }
1026
1027
  if (fxFace !== keys.fxface) { g.fxface.innerHTML = fxFace; keys.fxface = fxFace; }
1027
1028
 
1029
+ // 8b) patas de los bailes: el cuerpo sube sobre ellas y los pies se quedan en el suelo
1030
+ let legLift = 0;
1031
+ let legSVG = '';
1032
+ if (legs) {
1033
+ busy = true;
1034
+ const lt = legs.on ? 1 : 0;
1035
+ legs.k = rm ? lt : approach(legs.k, lt, dt, 150);
1036
+ if (!legs.on && legs.k < 0.01) legs = null;
1037
+ else {
1038
+ const W = L0.box.w;
1039
+ const H = L0.box.h;
1040
+ const LL = H * 0.36;
1041
+ legLift = LL * legs.k;
1042
+ room = Math.max(room, 1 + 0.42 * legs.k);
1043
+ const ox = L0.cx;
1044
+ const oy = L0.box.y + H;
1045
+ const rr = ((pose.r + (rm ? 0 : look.x * 2)) * Math.PI) / 180;
1046
+ const hips = [-1, 1].map((sd) => {
1047
+ const lx = sd * W * 0.2 * pose.sx;
1048
+ const ly = -H * 0.1 * pose.sy;
1049
+ return { x: ox + pose.x * W + lx * Math.cos(rr) - ly * Math.sin(rr), y: oy + pose.y * H - legLift + lx * Math.sin(rr) + ly * Math.cos(rr) };
1050
+ });
1051
+ const ol = outlineOf(s, pal);
1052
+ const hr = Math.max(6, W * 0.1);
1053
+ legSVG = drawLegs({ hips, floor: oy, cx: ox, W, LL, hr, aw: hr * 0.55, fill: skin?.solid || s.body.color, line: ol ? ol.color : pal.line, lw: ol ? R(Math.min(ol.w, 3.2)) : 1.8 }, legs.k, rm ? 0 : t - legs.start, legs);
1054
+ }
1055
+ }
1056
+ if (legSVG !== keys.legs) { g.legs.innerHTML = legSVG; keys.legs = legSVG; }
1057
+
1028
1058
  // 9) zoom del encuadre para que quepan alas, manos, pinchos…
1029
1059
  const zt = canZoom ? room : 1;
1030
1060
  if (zoom !== zt) {
@@ -1042,7 +1072,7 @@ export function createCharacter(container, spec, opts = {}) {
1042
1072
  const r = pose.r + (rm ? 0 : look.x * 2);
1043
1073
  const ox = L0.cx;
1044
1074
  const oy = L0.box.y + L0.box.h;
1045
- const tf = `translate(${R(ox + pose.x * L0.box.w)} ${R(oy + pose.y * L0.box.h)}) rotate(${R(r)}) scale(${R(sx * 1000) / 1000} ${R(sy * 1000) / 1000}) translate(${R(-ox)} ${R(-oy)})`;
1075
+ const tf = `translate(${R(ox + pose.x * L0.box.w)} ${R(oy + pose.y * L0.box.h - legLift)}) rotate(${R(r)}) scale(${R(sx * 1000) / 1000} ${R(sy * 1000) / 1000}) translate(${R(-ox)} ${R(-oy)})`;
1046
1076
  if (tf !== keys.rig) { g.rig.setAttribute('transform', tf); keys.rig = tf; }
1047
1077
 
1048
1078
  if (busy) raf = requestAnimationFrame(frame);
@@ -1079,6 +1109,7 @@ export function createCharacter(container, spec, opts = {}) {
1079
1109
  const old = gest;
1080
1110
  gest = null;
1081
1111
  g.rig?.setAttribute('class', 'otsc-rig');
1112
+ if (legs) legs.on = false;
1082
1113
  const hands = morphs.get('hands');
1083
1114
  if (old.def.hands && hands && !hands.byGesture && hands.userPose !== undefined) setPose(hands, hands.userPose);
1084
1115
  const wings = morphs.get('wings');
@@ -1097,6 +1128,8 @@ export function createCharacter(container, spec, opts = {}) {
1097
1128
  if (gest) endGesture();
1098
1129
  gest = { name: gname, def, start: t, ms, dir, from, fired: new Set() };
1099
1130
  g.rig.setAttribute('class', `otsc-rig otsc-g-${gname}`);
1131
+ // patas: los bailes las sacan (si ya estaban, solo cambian de paso)
1132
+ if (def.legs && opts.legs !== false) legs = { pose: def.legs, dir, k: legs?.k || 0, on: true, start: legs?.start ?? t };
1100
1133
  // manos y alas que necesita el gesto (si ya estaban, solo cambian de postura)
1101
1134
  const hands = morphs.get('hands');
1102
1135
  if (def.hands) {
@@ -1425,4 +1458,4 @@ export function createCharacter(container, spec, opts = {}) {
1425
1458
  export { SHAPES, EYES, BROWS, MOUTHS, CHEEKS, PATTERNS, FINISHES, TEXTURES, ACCESSORIES, PRESETS, BODY_POINTS };
1426
1459
  export { ACCESSORY_GROUPS, partLabel } from './parts.js';
1427
1460
  export { STYLES as CHARACTER_STYLES } from './styles.js';
1428
- export { normalizeMods, normalizeMod, sanitizeSvg, modName, MOD_ANCHORS, MAX_MODS } from './mods.js';
1461
+ export { normalizeMods, normalizeMod, sanitizeSvg, modName, MOD_ANCHORS, MOD_SLOTS, MOD_FACE, MAX_MODS } from './mods.js';
@@ -17,6 +17,8 @@ const T = {
17
17
  en: { stats: ['Energy', 'Wit', 'Charm', 'Chaos'], rar: ['Common', 'Rare', 'Epic', 'Legendary'] },
18
18
  es: { stats: ['Energía', 'Ingenio', 'Encanto', 'Caos'], rar: ['Común', 'Rara', 'Épica', 'Legendaria'] },
19
19
  pt: { stats: ['Energia', 'Engenho', 'Charme', 'Caos'], rar: ['Comum', 'Rara', 'Épica', 'Lendária'] },
20
+ zh: { stats: ['能量', '机智', '魅力', '混沌'], rar: ['普通', '稀有', '史诗', '传说'] },
21
+ hi: { stats: ['ऊर्जा', 'चतुराई', 'आकर्षण', 'उत्पात'], rar: ['साधारण', 'दुर्लभ', 'महाकाव्य', 'पौराणिक'] },
20
22
  };
21
23
 
22
24
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);