@plupin/cli 0.1.0 → 0.2.0

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/cli.js CHANGED
@@ -18,6 +18,19 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
18
18
  var __require = import.meta.require;
19
19
 
20
20
  // src/credentials.ts
21
+ var exports_credentials = {};
22
+ __export(exports_credentials, {
23
+ saveCredentials: () => saveCredentials,
24
+ readCredentialsIfPresent: () => readCredentialsIfPresent,
25
+ notSignedIn: () => notSignedIn,
26
+ loadCredentials: () => loadCredentials,
27
+ credentialsPath: () => credentialsPath,
28
+ credentialsMode: () => credentialsMode,
29
+ SESSION_COOKIE: () => SESSION_COOKIE,
30
+ DEFAULT_API_URL: () => DEFAULT_API_URL,
31
+ CliError: () => CliError,
32
+ CREDENTIALS_MODE: () => CREDENTIALS_MODE
33
+ });
21
34
  import { chmod, mkdir, readFile, stat, writeFile } from "fs/promises";
22
35
  import { homedir } from "os";
23
36
  import { dirname, join } from "path";
@@ -81,10 +94,27 @@ async function loadCredentials(env = process.env, options = {}) {
81
94
  path
82
95
  };
83
96
  }
97
+ async function readCredentialsIfPresent(env = process.env) {
98
+ try {
99
+ const text = await readFile(credentialsPath(env), "utf8");
100
+ const parsed = JSON.parse(text);
101
+ if (!parsed.token)
102
+ return null;
103
+ return {
104
+ apiUrl: (parsed.apiUrl ?? DEFAULT_API_URL).replace(/\/+$/, ""),
105
+ token: parsed.token,
106
+ kind: parsed.kind === "bearer" ? "bearer" : "session",
107
+ ...parsed.refreshToken ? { refreshToken: parsed.refreshToken } : {},
108
+ ...parsed.expiresAt ? { expiresAt: parsed.expiresAt } : {}
109
+ };
110
+ } catch {
111
+ return null;
112
+ }
113
+ }
84
114
  async function credentialsMode(path) {
85
115
  return (await stat(path)).mode & 511;
86
116
  }
87
- var SESSION_COOKIE = "__Host-plus1.session_token", DEFAULT_API_URL = "https://api.plupin.com", CREDENTIALS_MODE = 384, CliError;
117
+ var SESSION_COOKIE = "__Host-plupin.session_token", DEFAULT_API_URL = "https://api.plupin.com", CREDENTIALS_MODE = 384, CliError;
88
118
  var init_credentials = __esm(() => {
89
119
  CliError = class CliError extends Error {
90
120
  code;
@@ -207,7 +237,7 @@ Platform tidak menebak arti skor dari genre.`
207
237
  {
208
238
  id: "cli",
209
239
  title: "CLI",
210
- summary: "Semua perintah plus1 di terminal, beserta exit code-nya.",
240
+ summary: "Semua perintah plupin di terminal, beserta exit code-nya.",
211
241
  children: ["deploy", "oauth", "local-development"],
212
242
  body: `Semua perintah yang ada tercantum di bawah. Tidak ada perintah tersembunyi dan tidak ada yang
213
243
  butuh flag ajaib.
@@ -222,6 +252,33 @@ debit.
222
252
  Bikin baris game yang dibutuhkan deploy: id dan authority dari plupin.json, judul dari --title.
223
253
  Langsung live kecuali --visibility draft.
224
254
 
255
+ ### plupin emote new [dir] [--id <id>] [--name <n>] [--slot emote|outfit|hair|accessory] [--price <n>]
256
+ Tulis \`emote.json\` plus folder \`assets/\` di folder itu: id, nama, slot, harga, dan komposisinya
257
+ (\`{ glyph, face, clip }\` untuk emote, \`{ color }\` untuk item yang dipakai). Komposisinya divalidasi
258
+ lokal dengan paket character yang sama dengan server, jadi salah nama face atau clip gagal di sini,
259
+ bukan nanti di antrean review. \`--glyph\`, \`--face\`, \`--clip\`, \`--color\` mengisi komposisinya;
260
+ harga 0 berarti giveaway.
261
+
262
+ ### plupin emote import <clip.json> [dir] [--fps <n>]
263
+ Pasang animasi ke emote. File-nya klip hasil bake (format 18 sendi dari perpustakaan CC0: Quaternius,
264
+ CMU, atau keyframe sendiri) atau sudah berupa keyframe \`{ fps, loop, bones, frames }\`. Klip bake
265
+ diselesaikan jadi rotasi enam tulang rig, divalidasi dengan aturan server (maks 30 fps, 240 frame,
266
+ 8 detik, 32 KB), lalu ditulis ke \`assetConfig.anim\` di \`emote.json\`. Tanpa \`emote.json\` foldernya
267
+ dibuatkan dulu. \`--fps\` menurunkan frame rate keluaran (default 20).
268
+
269
+ ### plupin emote preview [dir] [--out <file>]
270
+ Render komposisi jadi SVG persis seperti yang disimpan dan dilihat moderator, lalu tulis ke
271
+ \`<dir>/.plupin/emote-preview.svg\` (atau \`--out\`). Tidak ada panggilan jaringan dan tidak ada
272
+ upload: buka filenya, itu hasil review-nya. Byte-nya sama dengan \`previewUrl\` yang nanti dikirim
273
+ server, dan \`emote push\` membandingkan keduanya.
274
+
275
+ ### plupin emote push [dir] [--api <url>]
276
+ Upload lewat \`POST /api/items\` dengan token kreator yang disimpan \`plupin login\`. Server
277
+ memvalidasi manifest, render preview, hitung hash, tarik fee listing (10 sigma untuk listing
278
+ berbayar), lalu simpan sebagai \`pending\`. Hasilnya id listing dan state \`pending\`; penolakan
279
+ dibaca sebagai kalimat server sendiri (\`DAILY_LISTING_LIMIT\`, \`ACTIVE_LISTING_CAP\`,
280
+ \`DUPLICATE_CONTENT\`, atau nama field dan nilai yang diterima).
281
+
225
282
  ### plupin up [dir] [--dry-run] [--skip-checks] [--api <url>]
226
283
  Satu perintah dari folder ke URL live: ukur build dulu seperti ponsel memainkannya (Chromium headless
227
284
  390x844 di 3G cepat: MB lewat kabel, halaman termuat, detik sampai tap pertama diterima, error
@@ -251,6 +308,19 @@ disimpan mode 600.
251
308
  Masuk sebagai kreator hasil seed di API lokal, untuk \`bun run db:seed\` + \`bun run dev\`. Tidak ada
252
309
  akun produksi yang tersentuh.
253
310
 
311
+ ### plupin connect claude [--api <url>]
312
+ Tulis konfigurasi MCP yang dibaca Claude Code (\`~/.claude.json\`): dua server, yang lokal lewat paket
313
+ yang sudah dipublikasikan (\`bunx -y @plupin/cli mcp\`) dan yang hosted di \`<api>/mcp\` dengan bearer
314
+ dari \`plupin login\`. File user-level, bukan project, karena entri hosted membawa token dan file
315
+ project ikut ter-commit. Token ditulis ke file (mode 600) dan tidak pernah dicetak; setelah menulis,
316
+ perintah ini memanggil \`tools/list\` dan mencetak berapa tool yang benar-benar menjawab.
317
+
318
+ ### plupin connect codex [--api <url>]
319
+ Sama untuk Codex CLI, sebagai tabel TOML di \`~/.codex/config.toml\`:
320
+ \`[mcp_servers.plupin]\` untuk server lokal dan \`[mcp_servers.plupin-hosted]\` untuk endpoint hosted
321
+ (\`http_headers\` berisi bearer). Idempoten: menjalankannya lagi memperbarui tabel yang sama, tidak
322
+ pernah meninggalkan entri ganda.
323
+
254
324
  ### plupin mcp
255
325
  Server MCP stdio untuk asisten coding yang tidak bisa memakai HTTP MCP.
256
326
 
@@ -277,6 +347,11 @@ dokumen ini akan menyebutkannya begitu ada.
277
347
  Endpoint-nya Streamable HTTP dengan OAuth 2.1. Tidak ada API key: klien membuka sign-in sekali, lalu
278
348
  menyimpan refresh token-nya sendiri.
279
349
 
350
+ Cara tercepat: \`plupin connect claude\` atau \`plupin connect codex\`. Perintah itu menulis file
351
+ konfigurasi yang dibaca agennya sendiri (user-level, mode 600) dengan dua server: server stdio lokal
352
+ dari paket yang sudah dipublikasikan, dan endpoint hosted dengan token \`plupin login\` di header,
353
+ lalu membuktikannya dengan \`tools/list\`.
354
+
280
355
  Klien yang sudah bicara HTTP MCP: isi alamat \`https://api.plupin.com/mcp\` apa adanya.
281
356
 
282
357
  Klien yang hanya bicara stdio (Claude Desktop, sebagian editor) menjalankannya lewat \`mcp-remote\`:
@@ -284,7 +359,7 @@ Klien yang hanya bicara stdio (Claude Desktop, sebagian editor) menjalankannya l
284
359
  \`\`\`
285
360
  {
286
361
  "mcpServers": {
287
- "plus1": {
362
+ "plupin": {
288
363
  "command": "npx",
289
364
  "args": ["-y", "mcp-remote", "https://api.plupin.com/mcp"]
290
365
  }
@@ -328,6 +403,21 @@ Dibaca dari baris registry, jadi room-nya tidak dibangunkan.
328
403
  Scope \`mcp:read\`. Tanpa argumen board: papan apa yang dideklarasikan game. Dengan board:
329
404
  peringkatnya.
330
405
 
406
+ ### emote_new
407
+ Scope \`mcp:read\`. Scaffold satu listing emote/item: id, nama, slot, harga, dan komposisinya, sudah
408
+ divalidasi paket character. Tidak menulis apa pun dan tidak menarik fee; langkah berikutnya
409
+ \`emote_preview\`, lalu \`emote_push\`.
410
+
411
+ ### emote_preview
412
+ Scope \`mcp:read\`. Validasi komposisi dan kembalikan headshot yang diputuskan moderator: SVG yang
413
+ sama persis yang disimpan server (data URL plus blok image), berikut asset config yang dinormalkan.
414
+ Penolakannya kalimat yang sama dengan \`emote_push\`, jadi typo ketemu sebelum upload.
415
+
416
+ ### emote_push
417
+ Scope \`mcp:deploy\`. Publish satu listing ke antrean moderasi lewat jalur yang sama dengan
418
+ \`plupin emote push\`: validasi, preview tersimpan, fee listing, budget harian, cap aktif. Balasannya
419
+ id listing dengan state \`pending\`, atau kalimat penolakan yang bisa langsung diperbaiki.
420
+
331
421
  ### deploy
332
422
  Scope \`mcp:deploy\`. Publish bundle kecil (maksimal 4 MB per panggilan) lewat jalur yang sama
333
423
  dengan CLI.
@@ -335,7 +425,7 @@ dengan CLI.
335
425
  ### rollback
336
426
  Scope \`mcp:deploy\`. Kembalikan pointer ke revisi sebelumnya, dengan validasi kepemilikan game.
337
427
 
338
- - Dokumen ini juga didaftarkan sebagai resource \`plus1://docs\` dan \`plus1://docs/<topic>\`, jadi
428
+ - Dokumen ini juga didaftarkan sebagai resource \`plupin://docs\` dan \`plupin://docs/<topic>\`, jadi
339
429
  klien yang hanya membaca resource tetap mendapat teks yang sama.
340
430
  - \`game_create\`, \`plupin create\`, dan \`plupin up\` memakai jalur publish yang sama dengan
341
431
  Studio: satu baris, satu kuota, satu revisi.
@@ -1312,7 +1402,7 @@ function loginPage(input) {
1312
1402
  <meta charset="utf-8" />
1313
1403
  <meta name="viewport" content="width=device-width, initial-scale=1" />
1314
1404
  <meta name="color-scheme" content="dark" />
1315
- <title>plus1 \u2014 ${title}</title>
1405
+ <title>plupin \u2014 ${title}</title>
1316
1406
  <style>
1317
1407
  @font-face {
1318
1408
  font-family: "m6x11plus";
@@ -1676,7 +1766,7 @@ var init_login = __esm(() => {
1676
1766
  SCOPES = ["openid", "offline_access", "mcp:read", "mcp:deploy"];
1677
1767
  });
1678
1768
 
1679
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/util.js
1769
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/util.js
1680
1770
  var exports_util = {};
1681
1771
  __export(exports_util, {
1682
1772
  unwrapMessage: () => unwrapMessage,
@@ -2525,7 +2615,7 @@ var init_util = __esm(() => {
2525
2615
  };
2526
2616
  });
2527
2617
 
2528
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/core.js
2618
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/core.js
2529
2619
  function newError(Definition) {
2530
2620
  const E = _E;
2531
2621
  if (E) {
@@ -2650,7 +2740,7 @@ var init_core = __esm(() => {
2650
2740
  globalConfig = globalThis.__zod_globalConfig;
2651
2741
  });
2652
2742
 
2653
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/errors.js
2743
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/errors.js
2654
2744
  function _getMessage() {
2655
2745
  const internals = this._zod;
2656
2746
  internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
@@ -2847,7 +2937,7 @@ var init_errors = __esm(() => {
2847
2937
  });
2848
2938
  });
2849
2939
 
2850
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/parse.js
2940
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/parse.js
2851
2941
  function finalizeParams(callee, params) {
2852
2942
  return { callee: params?.callee ?? callee, Err: params?.Err };
2853
2943
  }
@@ -2999,7 +3089,7 @@ var init_parse = __esm(() => {
2999
3089
  safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
3000
3090
  });
3001
3091
 
3002
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/regexes.js
3092
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/regexes.js
3003
3093
  var exports_regexes = {};
3004
3094
  __export(exports_regexes, {
3005
3095
  xid: () => xid,
@@ -3170,7 +3260,7 @@ var init_regexes = __esm(() => {
3170
3260
  sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
3171
3261
  });
3172
3262
 
3173
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/checks.js
3263
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/checks.js
3174
3264
  function handleCheckPropertyResult(result, payload, property) {
3175
3265
  if (result.issues.length) {
3176
3266
  payload.issues.push(...prefixIssues(property, result.issues));
@@ -3648,7 +3738,7 @@ var init_checks = __esm(() => {
3648
3738
  });
3649
3739
  });
3650
3740
 
3651
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/doc.js
3741
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/doc.js
3652
3742
  class Doc {
3653
3743
  constructor(args = [], closed = {}) {
3654
3744
  this.content = [];
@@ -3690,17 +3780,17 @@ ${content.join(`
3690
3780
  }
3691
3781
  }
3692
3782
 
3693
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/versions.js
3783
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/versions.js
3694
3784
  var version;
3695
3785
  var init_versions = __esm(() => {
3696
3786
  version = {
3697
3787
  major: 4,
3698
3788
  minor: 6,
3699
- patch: 7
3789
+ patch: 6
3700
3790
  };
3701
3791
  });
3702
3792
 
3703
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/schemas.js
3793
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/schemas.js
3704
3794
  async function validateAsync2(inst, value) {
3705
3795
  const ctx = { async: true };
3706
3796
  return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx), ctx);
@@ -6134,7 +6224,7 @@ var init_schemas = __esm(() => {
6134
6224
  });
6135
6225
  });
6136
6226
 
6137
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/memoizer.js
6227
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/memoizer.js
6138
6228
  function isRef(value) {
6139
6229
  return value !== null && typeof value === "object";
6140
6230
  }
@@ -6406,7 +6496,7 @@ var init_memoizer = __esm(() => {
6406
6496
  };
6407
6497
  });
6408
6498
 
6409
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ar.js
6499
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ar.js
6410
6500
  function ar_default() {
6411
6501
  return {
6412
6502
  localeError: error()
@@ -6521,7 +6611,7 @@ var init_ar = __esm(() => {
6521
6611
  init_util();
6522
6612
  });
6523
6613
 
6524
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/az.js
6614
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/az.js
6525
6615
  function az_default() {
6526
6616
  return {
6527
6617
  localeError: error2()
@@ -6635,7 +6725,7 @@ var init_az = __esm(() => {
6635
6725
  init_util();
6636
6726
  });
6637
6727
 
6638
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/be.js
6728
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/be.js
6639
6729
  function getBelarusianPlural(count, one, few, many) {
6640
6730
  const absCount = Math.abs(count);
6641
6731
  const lastDigit = absCount % 10;
@@ -6807,7 +6897,7 @@ var init_be = __esm(() => {
6807
6897
  init_util();
6808
6898
  });
6809
6899
 
6810
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/bg.js
6900
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/bg.js
6811
6901
  function bg_default() {
6812
6902
  return {
6813
6903
  localeError: error4()
@@ -6936,7 +7026,7 @@ var init_bg = __esm(() => {
6936
7026
  init_util();
6937
7027
  });
6938
7028
 
6939
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/bn.js
7029
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/bn.js
6940
7030
  function bn_default() {
6941
7031
  return {
6942
7032
  localeError: error5()
@@ -7053,7 +7143,7 @@ var init_bn = __esm(() => {
7053
7143
  init_util();
7054
7144
  });
7055
7145
 
7056
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ca.js
7146
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ca.js
7057
7147
  function ca_default() {
7058
7148
  return {
7059
7149
  localeError: error6()
@@ -7169,7 +7259,7 @@ var init_ca = __esm(() => {
7169
7259
  init_util();
7170
7260
  });
7171
7261
 
7172
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ckb.js
7262
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ckb.js
7173
7263
  function ckb_default() {
7174
7264
  return {
7175
7265
  localeError: error7()
@@ -7305,7 +7395,7 @@ var init_ckb = __esm(() => {
7305
7395
  init_util();
7306
7396
  });
7307
7397
 
7308
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/cs.js
7398
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/cs.js
7309
7399
  function cs_default() {
7310
7400
  return {
7311
7401
  localeError: error8()
@@ -7425,7 +7515,7 @@ var init_cs = __esm(() => {
7425
7515
  init_util();
7426
7516
  });
7427
7517
 
7428
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/da.js
7518
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/da.js
7429
7519
  function da_default() {
7430
7520
  return {
7431
7521
  localeError: error9()
@@ -7549,7 +7639,7 @@ var init_da = __esm(() => {
7549
7639
  init_util();
7550
7640
  });
7551
7641
 
7552
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/de.js
7642
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/de.js
7553
7643
  function de_default() {
7554
7644
  return {
7555
7645
  localeError: error10()
@@ -7666,7 +7756,7 @@ var init_de = __esm(() => {
7666
7756
  init_util();
7667
7757
  });
7668
7758
 
7669
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/el.js
7759
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/el.js
7670
7760
  function el_default() {
7671
7761
  return {
7672
7762
  localeError: error11()
@@ -7782,7 +7872,7 @@ var init_el = __esm(() => {
7782
7872
  init_util();
7783
7873
  });
7784
7874
 
7785
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/en.js
7875
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/en.js
7786
7876
  function en_default() {
7787
7877
  return {
7788
7878
  localeError: error12()
@@ -7908,7 +7998,7 @@ var init_en = __esm(() => {
7908
7998
  init_util();
7909
7999
  });
7910
8000
 
7911
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/eo.js
8001
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/eo.js
7912
8002
  function eo_default() {
7913
8003
  return {
7914
8004
  localeError: error13()
@@ -8026,7 +8116,7 @@ var init_eo = __esm(() => {
8026
8116
  init_util();
8027
8117
  });
8028
8118
 
8029
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/es.js
8119
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/es.js
8030
8120
  function es_default() {
8031
8121
  return {
8032
8122
  localeError: error14()
@@ -8166,7 +8256,7 @@ var init_es = __esm(() => {
8166
8256
  init_util();
8167
8257
  });
8168
8258
 
8169
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/fa.js
8259
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/fa.js
8170
8260
  function fa_default() {
8171
8261
  return {
8172
8262
  localeError: error15()
@@ -8289,7 +8379,7 @@ var init_fa = __esm(() => {
8289
8379
  init_util();
8290
8380
  });
8291
8381
 
8292
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/fi.js
8382
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/fi.js
8293
8383
  function fi_default() {
8294
8384
  return {
8295
8385
  localeError: error16()
@@ -8410,7 +8500,7 @@ var init_fi = __esm(() => {
8410
8500
  init_util();
8411
8501
  });
8412
8502
 
8413
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/fr.js
8503
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/fr.js
8414
8504
  function fr_default() {
8415
8505
  return {
8416
8506
  localeError: error17()
@@ -8543,7 +8633,7 @@ var init_fr = __esm(() => {
8543
8633
  init_util();
8544
8634
  });
8545
8635
 
8546
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/fr-CA.js
8636
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/fr-CA.js
8547
8637
  function fr_CA_default() {
8548
8638
  return {
8549
8639
  localeError: error18()
@@ -8659,7 +8749,7 @@ var init_fr_CA = __esm(() => {
8659
8749
  init_util();
8660
8750
  });
8661
8751
 
8662
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/gu.js
8752
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/gu.js
8663
8753
  function gu_default() {
8664
8754
  return {
8665
8755
  localeError: error19()
@@ -8776,7 +8866,7 @@ var init_gu = __esm(() => {
8776
8866
  init_util();
8777
8867
  });
8778
8868
 
8779
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/he.js
8869
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/he.js
8780
8870
  function he_default() {
8781
8871
  return {
8782
8872
  localeError: error20()
@@ -8980,7 +9070,7 @@ var init_he = __esm(() => {
8980
9070
  init_util();
8981
9071
  });
8982
9072
 
8983
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/hi.js
9073
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/hi.js
8984
9074
  function hi_default() {
8985
9075
  return {
8986
9076
  localeError: error21()
@@ -9095,7 +9185,7 @@ var init_hi = __esm(() => {
9095
9185
  init_util();
9096
9186
  });
9097
9187
 
9098
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/hr.js
9188
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/hr.js
9099
9189
  function hr_default() {
9100
9190
  return {
9101
9191
  localeError: error22()
@@ -9225,7 +9315,7 @@ var init_hr = __esm(() => {
9225
9315
  init_util();
9226
9316
  });
9227
9317
 
9228
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/hu.js
9318
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/hu.js
9229
9319
  function hu_default() {
9230
9320
  return {
9231
9321
  localeError: error23()
@@ -9342,7 +9432,7 @@ var init_hu = __esm(() => {
9342
9432
  init_util();
9343
9433
  });
9344
9434
 
9345
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/hy.js
9435
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/hy.js
9346
9436
  function getArmenianPlural(count, one, many) {
9347
9437
  return Math.abs(count) === 1 ? one : many;
9348
9438
  }
@@ -9504,7 +9594,7 @@ var init_hy = __esm(() => {
9504
9594
  init_util();
9505
9595
  });
9506
9596
 
9507
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/id.js
9597
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/id.js
9508
9598
  function id_default() {
9509
9599
  return {
9510
9600
  localeError: error25()
@@ -9619,7 +9709,7 @@ var init_id = __esm(() => {
9619
9709
  init_util();
9620
9710
  });
9621
9711
 
9622
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/is.js
9712
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/is.js
9623
9713
  function is_default() {
9624
9714
  return {
9625
9715
  localeError: error26()
@@ -9737,7 +9827,7 @@ var init_is = __esm(() => {
9737
9827
  init_util();
9738
9828
  });
9739
9829
 
9740
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/it.js
9830
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/it.js
9741
9831
  function it_default() {
9742
9832
  return {
9743
9833
  localeError: error27()
@@ -9854,7 +9944,7 @@ var init_it = __esm(() => {
9854
9944
  init_util();
9855
9945
  });
9856
9946
 
9857
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ja.js
9947
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ja.js
9858
9948
  function ja_default() {
9859
9949
  return {
9860
9950
  localeError: error28()
@@ -9970,7 +10060,7 @@ var init_ja = __esm(() => {
9970
10060
  init_util();
9971
10061
  });
9972
10062
 
9973
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ka.js
10063
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ka.js
9974
10064
  function ka_default() {
9975
10065
  return {
9976
10066
  localeError: error29()
@@ -10091,7 +10181,7 @@ var init_ka = __esm(() => {
10091
10181
  init_util();
10092
10182
  });
10093
10183
 
10094
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/km.js
10184
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/km.js
10095
10185
  function km_default() {
10096
10186
  return {
10097
10187
  localeError: error30()
@@ -10210,7 +10300,7 @@ var init_km = __esm(() => {
10210
10300
  init_util();
10211
10301
  });
10212
10302
 
10213
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/kh.js
10303
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/kh.js
10214
10304
  function kh_default() {
10215
10305
  return km_default();
10216
10306
  }
@@ -10218,7 +10308,7 @@ var init_kh = __esm(() => {
10218
10308
  init_km();
10219
10309
  });
10220
10310
 
10221
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/kn.js
10311
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/kn.js
10222
10312
  function kn_default() {
10223
10313
  return {
10224
10314
  localeError: error31()
@@ -10335,7 +10425,7 @@ var init_kn = __esm(() => {
10335
10425
  init_util();
10336
10426
  });
10337
10427
 
10338
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ko.js
10428
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ko.js
10339
10429
  function ko_default() {
10340
10430
  return {
10341
10431
  localeError: error32()
@@ -10455,7 +10545,7 @@ var init_ko = __esm(() => {
10455
10545
  init_util();
10456
10546
  });
10457
10547
 
10458
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/lt.js
10548
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/lt.js
10459
10549
  function getUnitTypeFromNumber(number2) {
10460
10550
  const abs = Math.abs(number2);
10461
10551
  const last = abs % 10;
@@ -10665,7 +10755,7 @@ var init_lt = __esm(() => {
10665
10755
  init_util();
10666
10756
  });
10667
10757
 
10668
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/mk.js
10758
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/mk.js
10669
10759
  function mk_default() {
10670
10760
  return {
10671
10761
  localeError: error34()
@@ -10783,7 +10873,7 @@ var init_mk = __esm(() => {
10783
10873
  init_util();
10784
10874
  });
10785
10875
 
10786
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ms.js
10876
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ms.js
10787
10877
  function ms_default() {
10788
10878
  return {
10789
10879
  localeError: error35()
@@ -10899,7 +10989,7 @@ var init_ms = __esm(() => {
10899
10989
  init_util();
10900
10990
  });
10901
10991
 
10902
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ne.js
10992
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ne.js
10903
10993
  function ne_default() {
10904
10994
  return {
10905
10995
  localeError: error36()
@@ -11014,7 +11104,7 @@ var init_ne = __esm(() => {
11014
11104
  init_util();
11015
11105
  });
11016
11106
 
11017
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/nl.js
11107
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/nl.js
11018
11108
  function nl_default() {
11019
11109
  return {
11020
11110
  localeError: error37()
@@ -11133,7 +11223,7 @@ var init_nl = __esm(() => {
11133
11223
  init_util();
11134
11224
  });
11135
11225
 
11136
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/nn.js
11226
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/nn.js
11137
11227
  function nn_default() {
11138
11228
  return {
11139
11229
  localeError: error38()
@@ -11250,7 +11340,7 @@ var init_nn = __esm(() => {
11250
11340
  init_util();
11251
11341
  });
11252
11342
 
11253
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/no.js
11343
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/no.js
11254
11344
  function no_default() {
11255
11345
  return {
11256
11346
  localeError: error39()
@@ -11367,7 +11457,7 @@ var init_no = __esm(() => {
11367
11457
  init_util();
11368
11458
  });
11369
11459
 
11370
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ota.js
11460
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ota.js
11371
11461
  function ota_default() {
11372
11462
  return {
11373
11463
  localeError: error40()
@@ -11485,7 +11575,7 @@ var init_ota = __esm(() => {
11485
11575
  init_util();
11486
11576
  });
11487
11577
 
11488
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ps.js
11578
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ps.js
11489
11579
  function ps_default() {
11490
11580
  return {
11491
11581
  localeError: error41()
@@ -11608,7 +11698,7 @@ var init_ps = __esm(() => {
11608
11698
  init_util();
11609
11699
  });
11610
11700
 
11611
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/pl.js
11701
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/pl.js
11612
11702
  function pl_default() {
11613
11703
  return {
11614
11704
  localeError: error42()
@@ -11726,7 +11816,7 @@ var init_pl = __esm(() => {
11726
11816
  init_util();
11727
11817
  });
11728
11818
 
11729
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/pt.js
11819
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/pt.js
11730
11820
  function pt_default() {
11731
11821
  return {
11732
11822
  localeError: error43()
@@ -11872,7 +11962,7 @@ var init_pt = __esm(() => {
11872
11962
  init_util();
11873
11963
  });
11874
11964
 
11875
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/pt-BR.js
11965
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/pt-BR.js
11876
11966
  function pt_BR_default() {
11877
11967
  return {
11878
11968
  localeError: error44()
@@ -12019,7 +12109,7 @@ var init_pt_BR = __esm(() => {
12019
12109
  init_util();
12020
12110
  });
12021
12111
 
12022
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ro.js
12112
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ro.js
12023
12113
  function ro_default() {
12024
12114
  return {
12025
12115
  localeError: error45()
@@ -12145,7 +12235,7 @@ var init_ro = __esm(() => {
12145
12235
  init_util();
12146
12236
  });
12147
12237
 
12148
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ru.js
12238
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ru.js
12149
12239
  function getRussianPlural(count, one, few, many) {
12150
12240
  const absCount = Math.abs(count);
12151
12241
  const lastDigit = absCount % 10;
@@ -12317,7 +12407,7 @@ var init_ru = __esm(() => {
12317
12407
  init_util();
12318
12408
  });
12319
12409
 
12320
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/sk.js
12410
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/sk.js
12321
12411
  function sk_default() {
12322
12412
  return {
12323
12413
  localeError: error47()
@@ -12437,7 +12527,7 @@ var init_sk = __esm(() => {
12437
12527
  init_util();
12438
12528
  });
12439
12529
 
12440
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/sl.js
12530
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/sl.js
12441
12531
  function sl_default() {
12442
12532
  return {
12443
12533
  localeError: error48()
@@ -12555,7 +12645,7 @@ var init_sl = __esm(() => {
12555
12645
  init_util();
12556
12646
  });
12557
12647
 
12558
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/sv.js
12648
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/sv.js
12559
12649
  function sv_default() {
12560
12650
  return {
12561
12651
  localeError: error49()
@@ -12674,7 +12764,7 @@ var init_sv = __esm(() => {
12674
12764
  init_util();
12675
12765
  });
12676
12766
 
12677
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ta.js
12767
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ta.js
12678
12768
  function ta_default() {
12679
12769
  return {
12680
12770
  localeError: error50()
@@ -12793,7 +12883,7 @@ var init_ta = __esm(() => {
12793
12883
  init_util();
12794
12884
  });
12795
12885
 
12796
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/tg.js
12886
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/tg.js
12797
12887
  function tg_default() {
12798
12888
  return {
12799
12889
  localeError: error51()
@@ -12913,7 +13003,7 @@ var init_tg = __esm(() => {
12913
13003
  init_util();
12914
13004
  });
12915
13005
 
12916
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/th.js
13006
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/th.js
12917
13007
  function th_default() {
12918
13008
  return {
12919
13009
  localeError: error52()
@@ -13032,7 +13122,7 @@ var init_th = __esm(() => {
13032
13122
  init_util();
13033
13123
  });
13034
13124
 
13035
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/tk.js
13125
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/tk.js
13036
13126
  function tk_default() {
13037
13127
  return {
13038
13128
  localeError: error53()
@@ -13143,7 +13233,7 @@ var init_tk = __esm(() => {
13143
13233
  init_util();
13144
13234
  });
13145
13235
 
13146
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/tr.js
13236
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/tr.js
13147
13237
  function tr_default() {
13148
13238
  return {
13149
13239
  localeError: error54()
@@ -13257,7 +13347,7 @@ var init_tr = __esm(() => {
13257
13347
  init_util();
13258
13348
  });
13259
13349
 
13260
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/uk.js
13350
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/uk.js
13261
13351
  function uk_default() {
13262
13352
  return {
13263
13353
  localeError: error55()
@@ -13374,7 +13464,7 @@ var init_uk = __esm(() => {
13374
13464
  init_util();
13375
13465
  });
13376
13466
 
13377
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ua.js
13467
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ua.js
13378
13468
  function ua_default() {
13379
13469
  return uk_default();
13380
13470
  }
@@ -13382,7 +13472,7 @@ var init_ua = __esm(() => {
13382
13472
  init_uk();
13383
13473
  });
13384
13474
 
13385
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/ur.js
13475
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/ur.js
13386
13476
  function ur_default() {
13387
13477
  return {
13388
13478
  localeError: error56()
@@ -13501,7 +13591,7 @@ var init_ur = __esm(() => {
13501
13591
  init_util();
13502
13592
  });
13503
13593
 
13504
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/uz.js
13594
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/uz.js
13505
13595
  function uz_default() {
13506
13596
  return {
13507
13597
  localeError: error57()
@@ -13618,7 +13708,7 @@ var init_uz = __esm(() => {
13618
13708
  init_util();
13619
13709
  });
13620
13710
 
13621
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/vi.js
13711
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/vi.js
13622
13712
  function vi_default() {
13623
13713
  return {
13624
13714
  localeError: error58()
@@ -13735,7 +13825,7 @@ var init_vi = __esm(() => {
13735
13825
  init_util();
13736
13826
  });
13737
13827
 
13738
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/zh-CN.js
13828
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/zh-CN.js
13739
13829
  function zh_CN_default() {
13740
13830
  return {
13741
13831
  localeError: error59()
@@ -13853,7 +13943,7 @@ var init_zh_CN = __esm(() => {
13853
13943
  init_util();
13854
13944
  });
13855
13945
 
13856
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/zh-TW.js
13946
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/zh-TW.js
13857
13947
  function zh_TW_default() {
13858
13948
  return {
13859
13949
  localeError: error60()
@@ -13969,7 +14059,7 @@ var init_zh_TW = __esm(() => {
13969
14059
  init_util();
13970
14060
  });
13971
14061
 
13972
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/yo.js
14062
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/yo.js
13973
14063
  function yo_default() {
13974
14064
  return {
13975
14065
  localeError: error61()
@@ -14085,7 +14175,7 @@ var init_yo = __esm(() => {
14085
14175
  init_util();
14086
14176
  });
14087
14177
 
14088
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/index.js
14178
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/index.js
14089
14179
  var exports_locales = {};
14090
14180
  __export(exports_locales, {
14091
14181
  zhTW: () => zh_TW_default,
@@ -14218,7 +14308,7 @@ var init_locales = __esm(() => {
14218
14308
  init_yo();
14219
14309
  });
14220
14310
 
14221
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/registries.js
14311
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/registries.js
14222
14312
  class $ZodRegistry {
14223
14313
  constructor() {
14224
14314
  this._map = new WeakMap;
@@ -14270,7 +14360,7 @@ var init_registries = __esm(() => {
14270
14360
  globalRegistry = globalThis.__zod_globalRegistry;
14271
14361
  });
14272
14362
 
14273
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/compile.js
14363
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/compile.js
14274
14364
  function compileValidator(schema, parser) {
14275
14365
  try {
14276
14366
  return compileFn(schema, { assertOnly: true });
@@ -15883,7 +15973,7 @@ var init_compile = __esm(() => {
15883
15973
  ]);
15884
15974
  });
15885
15975
 
15886
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/api.js
15976
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/api.js
15887
15977
  function snapshotChecks(def) {
15888
15978
  if (def.checks)
15889
15979
  def.checks = [...def.checks];
@@ -16828,7 +16918,7 @@ var init_api = __esm(() => {
16828
16918
  };
16829
16919
  });
16830
16920
 
16831
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/to-json-schema.js
16921
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/to-json-schema.js
16832
16922
  function assignProps(target, ...sources) {
16833
16923
  for (const source of sources) {
16834
16924
  for (const key of Reflect.ownKeys(source)) {
@@ -17355,7 +17445,7 @@ var init_to_json_schema = __esm(() => {
17355
17445
  UNION_KEYS = ["oneOf", "anyOf"];
17356
17446
  });
17357
17447
 
17358
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/json-schema-processors.js
17448
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/json-schema-processors.js
17359
17449
  function aggregateChecks(schema) {
17360
17450
  const agg = {};
17361
17451
  const def = schema._zod.def;
@@ -18056,7 +18146,7 @@ var init_json_schema_processors = __esm(() => {
18056
18146
  };
18057
18147
  });
18058
18148
 
18059
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/json-schema-generator.js
18149
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/json-schema-generator.js
18060
18150
  class JSONSchemaGenerator {
18061
18151
  get metadataRegistry() {
18062
18152
  return this.ctx.metadataRegistry;
@@ -18122,11 +18212,11 @@ var init_json_schema_generator = __esm(() => {
18122
18212
  init_to_json_schema();
18123
18213
  });
18124
18214
 
18125
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/json-schema.js
18215
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/json-schema.js
18126
18216
  var exports_json_schema = {};
18127
18217
  var init_json_schema = () => {};
18128
18218
 
18129
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/index.js
18219
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/index.js
18130
18220
  var exports_core2 = {};
18131
18221
  __export(exports_core2, {
18132
18222
  withParser: () => withParser,
@@ -18463,7 +18553,7 @@ var init_core2 = __esm(() => {
18463
18553
  init_to_json_schema();
18464
18554
  });
18465
18555
 
18466
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/checks.js
18556
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/checks.js
18467
18557
  var exports_checks2 = {};
18468
18558
  __export(exports_checks2, {
18469
18559
  uppercase: () => _uppercase,
@@ -18501,7 +18591,7 @@ var init_checks2 = __esm(() => {
18501
18591
  init_core2();
18502
18592
  });
18503
18593
 
18504
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/errors.js
18594
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/errors.js
18505
18595
  function _lazyMethod(proto, key, make) {
18506
18596
  Object.defineProperty(proto, key, {
18507
18597
  configurable: true,
@@ -18552,7 +18642,7 @@ var init_errors2 = __esm(() => {
18552
18642
  });
18553
18643
  });
18554
18644
 
18555
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/parse.js
18645
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/parse.js
18556
18646
  var parse3, parseAsync2, safeParse2, safeParseAsync2, encode2, decode2, encodeAsync2, decodeAsync2, safeEncode2, safeDecode2, safeEncodeAsync2, safeDecodeAsync2;
18557
18647
  var init_parse2 = __esm(() => {
18558
18648
  init_core2();
@@ -18572,7 +18662,7 @@ var init_parse2 = __esm(() => {
18572
18662
  safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
18573
18663
  });
18574
18664
 
18575
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/schemas.js
18665
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/schemas.js
18576
18666
  var exports_schemas2 = {};
18577
18667
  __export(exports_schemas2, {
18578
18668
  xor: () => xor,
@@ -20204,7 +20294,7 @@ var init_schemas2 = __esm(() => {
20204
20294
  });
20205
20295
  });
20206
20296
 
20207
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/compat.js
20297
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/compat.js
20208
20298
  function setErrorMap(map2) {
20209
20299
  config({
20210
20300
  customError: map2
@@ -20232,7 +20322,7 @@ var init_compat = __esm(() => {
20232
20322
  (function(ZodFirstPartyTypeKind2) {})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
20233
20323
  });
20234
20324
 
20235
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/iso.js
20325
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/iso.js
20236
20326
  var exports_iso = {};
20237
20327
  __export(exports_iso, {
20238
20328
  time: () => time2,
@@ -20262,7 +20352,7 @@ var init_iso = __esm(() => {
20262
20352
  init_schemas2();
20263
20353
  });
20264
20354
 
20265
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/from-json-schema.js
20355
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/from-json-schema.js
20266
20356
  function detectVersion(schema, defaultTarget) {
20267
20357
  const $schema = schema.$schema;
20268
20358
  if ($schema === "https://json-schema.org/draft/2020-12/schema") {
@@ -20991,7 +21081,7 @@ var init_from_json_schema = __esm(() => {
20991
21081
  fullTime = /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
20992
21082
  });
20993
21083
 
20994
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/visit.js
21084
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/visit.js
20995
21085
  function visit(schema, fnOrHandlers) {
20996
21086
  const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
20997
21087
  const h = fnOrHandlers[node2._zod.def.type];
@@ -21148,7 +21238,7 @@ var init_visit = __esm(() => {
21148
21238
  RESOLVING = Symbol("z.visit/resolving");
21149
21239
  });
21150
21240
 
21151
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/deep-partial.js
21241
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/deep-partial.js
21152
21242
  function deepPartial(schema) {
21153
21243
  return visit(schema, {
21154
21244
  object: (s) => s.partial(),
@@ -21163,7 +21253,7 @@ var init_deep_partial = __esm(() => {
21163
21253
  init_schemas2();
21164
21254
  });
21165
21255
 
21166
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/in-out.js
21256
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/in-out.js
21167
21257
  function withChecks(side, checks2) {
21168
21258
  if (!checks2?.length)
21169
21259
  return side;
@@ -21195,7 +21285,7 @@ var init_in_out = __esm(() => {
21195
21285
  init_schemas2();
21196
21286
  });
21197
21287
 
21198
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/coerce.js
21288
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/coerce.js
21199
21289
  var exports_coerce = {};
21200
21290
  __export(exports_coerce, {
21201
21291
  string: () => string3,
@@ -21224,7 +21314,7 @@ var init_coerce = __esm(() => {
21224
21314
  init_schemas2();
21225
21315
  });
21226
21316
 
21227
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/external.js
21317
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/external.js
21228
21318
  var exports_external = {};
21229
21319
  __export(exports_external, {
21230
21320
  xor: () => xor,
@@ -21504,7 +21594,7 @@ var init_external = __esm(() => {
21504
21594
  init_compat();
21505
21595
  });
21506
21596
 
21507
- // ../../node_modules/.bun/zod@4.6.7/node_modules/zod/index.js
21597
+ // ../../node_modules/.bun/zod@4.6.6/node_modules/zod/index.js
21508
21598
  var init_zod = __esm(() => {
21509
21599
  init_external();
21510
21600
  init_external();
@@ -21530,7 +21620,7 @@ async function signReceipt(keyHash, timestamp, body) {
21530
21620
  function isReceiptAck(answer, purchaseId) {
21531
21621
  return answer?.acknowledged === purchaseId;
21532
21622
  }
21533
- var GAME_CREATOR_SHARE_BPS = 9500, GAME_PLATFORM_SHARE_BPS, MIN_PRODUCT_PRICE = 2, MAX_PRODUCT_PRICE = 1e5, MAX_PRODUCTS_PER_GAME = 100, PLAYER_TOKEN_TTL_MS, PURCHASE_DELIVERY_WINDOW_MS, PURCHASE_RESULT_MESSAGE = "plupin:purchase-result", RECEIPT_SIGNATURE_HEADER = "plupin-signature", PRODUCT_KINDS, skuSchema, requestKeySchema, purchaseTagSchema, gameProductSchema, gameProductsSchema, PRIVATE_HOST, receiptUrlSchema, RETRY_MAX_MS;
21623
+ var GAME_CREATOR_SHARE_BPS = 8500, GAME_PLATFORM_SHARE_BPS, MIN_PRODUCT_PRICE = 2, MAX_PRODUCT_PRICE = 1e5, MAX_PRODUCTS_PER_GAME = 100, PLAYER_TOKEN_TTL_MS, PURCHASE_DELIVERY_WINDOW_MS, PURCHASE_RESULT_MESSAGE = "plupin:purchase-result", RECEIPT_SIGNATURE_HEADER = "plupin-signature", PRODUCT_KINDS, skuSchema, requestKeySchema, purchaseTagSchema, gameProductSchema, gameProductsSchema, PRIVATE_HOST, receiptUrlSchema, RETRY_MAX_MS;
21534
21624
  var init_game_purchase = __esm(() => {
21535
21625
  init_zod();
21536
21626
  GAME_PLATFORM_SHARE_BPS = 1e4 - GAME_CREATOR_SHARE_BPS;
@@ -21793,6 +21883,72 @@ var init_content_types = __esm(() => {
21793
21883
  };
21794
21884
  });
21795
21885
 
21886
+ // ../api/src/domains/random/source.ts
21887
+ function cryptoUint32() {
21888
+ const buffer = new Uint32Array(1);
21889
+ crypto.getRandomValues(buffer);
21890
+ const value = buffer[0];
21891
+ if (value === undefined)
21892
+ throw new Error("crypto.getRandomValues produced no value");
21893
+ return value;
21894
+ }
21895
+ var UINT32_SPAN = 4294967296;
21896
+
21897
+ // ../api/src/domains/random/weighted.ts
21898
+ function uniformBelow(range, next = cryptoUint32) {
21899
+ if (!Number.isInteger(range) || range < 1 || range > UINT32_SPAN)
21900
+ throw new Error(`a draw range is an integer between 1 and 2^32, got ${range}`);
21901
+ const limit = UINT32_SPAN - UINT32_SPAN % range;
21902
+ for (let attempt = 0;attempt < 64; attempt += 1) {
21903
+ const value = next();
21904
+ if (!Number.isInteger(value) || value < 0 || value >= UINT32_SPAN)
21905
+ throw new Error(`a random source returns uint32 values, got ${value}`);
21906
+ if (value < limit)
21907
+ return value % range;
21908
+ }
21909
+ throw new Error("a random source produced 64 rejectable values in a row");
21910
+ }
21911
+ function weightTotal(entries) {
21912
+ let total = 0;
21913
+ for (const entry of entries) {
21914
+ if (!Number.isInteger(entry.weight) || entry.weight < 1 || entry.weight > MAX_WEIGHT)
21915
+ throw new Error(`a weight is an integer between 1 and ${MAX_WEIGHT}, got ${entry.weight}`);
21916
+ total += entry.weight;
21917
+ }
21918
+ if (total === 0)
21919
+ throw new Error("a weighted draw needs at least one entry");
21920
+ return total;
21921
+ }
21922
+ function pickWeighted(entries, next = cryptoUint32) {
21923
+ if (entries.length === 0)
21924
+ throw new Error("a weighted draw needs at least one entry");
21925
+ const total = weightTotal(entries);
21926
+ const roll = uniformBelow(total, next);
21927
+ let cursor = roll;
21928
+ for (const entry of entries) {
21929
+ if (cursor < entry.weight)
21930
+ return { entry, roll, total };
21931
+ cursor -= entry.weight;
21932
+ }
21933
+ throw new Error("the weighted table did not cover its own total");
21934
+ }
21935
+ var MAX_WEIGHT = 1e4, MAX_OUTCOMES = 64;
21936
+ var init_weighted = () => {};
21937
+
21938
+ // ../api/src/domains/random/roll.ts
21939
+ function rollWeights(weights, next = cryptoUint32) {
21940
+ const pick2 = pickWeighted(weights.map((weight, index) => ({ value: index, weight })), next);
21941
+ return { index: pick2.entry.value, roll: pick2.roll, total: pick2.total };
21942
+ }
21943
+ var randomRollInputSchema;
21944
+ var init_roll = __esm(() => {
21945
+ init_zod();
21946
+ init_weighted();
21947
+ randomRollInputSchema = exports_external.object({
21948
+ weights: exports_external.array(exports_external.number().int().min(1).max(MAX_WEIGHT)).min(2).max(MAX_OUTCOMES)
21949
+ }).strict();
21950
+ });
21951
+
21796
21952
  // src/local-leaderboard.ts
21797
21953
  function hash2(text) {
21798
21954
  let value = 2166136261;
@@ -22073,9 +22229,8 @@ function createLocalPurchases(input2) {
22073
22229
  const uses = new Map;
22074
22230
  const purchases = new Map;
22075
22231
  const byRequest = new Map;
22076
- async function postReceipt(purchase) {
22077
- if (!input2.receiptUrl || purchase.status !== "paid")
22078
- return;
22232
+ const posting = new Map;
22233
+ async function sendReceipt(url2, purchase) {
22079
22234
  const receipt = {
22080
22235
  id: purchase.id,
22081
22236
  gameId: purchase.gameId,
@@ -22088,7 +22243,7 @@ function createLocalPurchases(input2) {
22088
22243
  };
22089
22244
  const body = JSON.stringify(receipt);
22090
22245
  try {
22091
- const response = await fetch(input2.receiptUrl, {
22246
+ const response = await fetch(url2, {
22092
22247
  method: "POST",
22093
22248
  headers: {
22094
22249
  "Content-Type": "application/json",
@@ -22102,6 +22257,16 @@ function createLocalPurchases(input2) {
22102
22257
  acknowledge(purchase.id);
22103
22258
  } catch {}
22104
22259
  }
22260
+ function postReceipt(purchase) {
22261
+ if (!input2.receiptUrl || purchase.status !== "paid")
22262
+ return Promise.resolve();
22263
+ const running = posting.get(purchase.id);
22264
+ if (running)
22265
+ return running;
22266
+ const attempt = sendReceipt(input2.receiptUrl, purchase).finally(() => posting.delete(purchase.id));
22267
+ posting.set(purchase.id, attempt);
22268
+ return attempt;
22269
+ }
22105
22270
  async function retryReceipts() {
22106
22271
  for (const purchase of purchases.values())
22107
22272
  await postReceipt(purchase);
@@ -22399,7 +22564,7 @@ async function buildRoomFromSource() {
22399
22564
  const output2 = built.outputs[0];
22400
22565
  if (!output2)
22401
22566
  throw new Error("the room did not build");
22402
- const dir = await mkdtemp(join3(tmpdir(), "plus1-room-"));
22567
+ const dir = await mkdtemp(join3(tmpdir(), "plupin-room-"));
22403
22568
  const file2 = join3(dir, "relay-room.mjs");
22404
22569
  await writeFile2(file2, await output2.text());
22405
22570
  return file2;
@@ -22681,6 +22846,20 @@ async function startDevServer(options) {
22681
22846
  throw error62;
22682
22847
  }
22683
22848
  }
22849
+ if (path2 === "/api/play/random" && request.method === "POST") {
22850
+ let body;
22851
+ try {
22852
+ body = await request.json();
22853
+ } catch {
22854
+ return Response.json({ error: "invalid_json" }, { status: 400, headers: { "Cache-Control": "no-store" } });
22855
+ }
22856
+ const parsed = randomRollInputSchema.safeParse(body);
22857
+ if (!parsed.success)
22858
+ return Response.json({ error: "invalid_roll" }, { status: 400, headers: { "Cache-Control": "no-store" } });
22859
+ return Response.json(rollWeights(parsed.data.weights), {
22860
+ headers: { "Cache-Control": "no-store" }
22861
+ });
22862
+ }
22684
22863
  if (path2.startsWith("/api/play/")) {
22685
22864
  try {
22686
22865
  const answer = await playerItemRoute(request, url3);
@@ -22816,6 +22995,7 @@ var SHUTDOWN_GRACE_MS = 500, COMPRESSIBLE, COMPRESS_MIN_BYTES = 1024, compressed
22816
22995
  var init_dev = __esm(() => {
22817
22996
  init_src();
22818
22997
  init_content_types();
22998
+ init_roll();
22819
22999
  init_local_leaderboard();
22820
23000
  init_local_money();
22821
23001
  init_local_purchase();
@@ -23799,12 +23979,1912 @@ var init_up = __esm(() => {
23799
23979
  init_deploy();
23800
23980
  });
23801
23981
 
23982
+ // ../character/src/clip-bake.ts
23983
+ function limbEuler(d, previous) {
23984
+ const r = Math.hypot(d[1], d[2]);
23985
+ if (r < 0.0001)
23986
+ return { x: previous?.x ?? 0, z: Math.sign(d[0]) * (Math.PI / 2) };
23987
+ const below = { x: Math.atan2(-d[2], -d[1]), z: Math.atan2(d[0], r) };
23988
+ const above = { x: Math.atan2(d[2], d[1]), z: Math.atan2(d[0], -r) };
23989
+ if (!previous)
23990
+ return d[1] <= 0 ? below : above;
23991
+ const cost = (e) => Math.abs(wrap(e.x - previous.x)) + Math.abs(wrap(e.z - previous.z));
23992
+ const near = (e) => ({ x: unwrap(e.x, previous.x), z: unwrap(e.z, previous.z) });
23993
+ const inRange = (e) => Math.abs(e.x) <= MAX_TURN && Math.abs(e.z) <= MAX_TURN;
23994
+ const ranked = [below, above].sort((a, b) => cost(a) - cost(b)).map(near);
23995
+ return ranked.find(inRange) ?? { x: wrap(ranked[0].x), z: wrap(ranked[0].z) };
23996
+ }
23997
+ function uprightEuler(d) {
23998
+ return { z: -Math.asin(Math.max(-1, Math.min(1, d[0]))), x: Math.atan2(d[2], d[1]) };
23999
+ }
24000
+ function bakeToCustomClip(source, options = {}) {
24001
+ const joints = source.sendi;
24002
+ const index = (name) => {
24003
+ const found = joints.indexOf(name);
24004
+ if (found < 0)
24005
+ throw new BakeError(`The clip has no joint "${name}"; a baked clip carries ${BAKED_JOINTS.join(", ")}.`);
24006
+ return found;
24007
+ };
24008
+ const stride = joints.length * 3;
24009
+ if (!source.fps || source.data.length === 0 || source.data.length % stride !== 0)
24010
+ throw new BakeError("The clip is empty or its data does not divide into whole frames.");
24011
+ const sourceFrames = source.data.length / stride;
24012
+ const at = (frame, name) => {
24013
+ const base = frame * stride + index(name) * 3;
24014
+ return [source.data[base] ?? 0, source.data[base + 1] ?? 0, source.data[base + 2] ?? 0];
24015
+ };
24016
+ const lerp = (a, b, t) => [
24017
+ a[0] + (b[0] - a[0]) * t,
24018
+ a[1] + (b[1] - a[1]) * t,
24019
+ a[2] + (b[2] - a[2]) * t
24020
+ ];
24021
+ const joint = (time3, name) => {
24022
+ const position = Math.min(time3 * source.fps, sourceFrames - 1);
24023
+ const lo = Math.floor(position);
24024
+ return lerp(at(lo, name), at(Math.min(lo + 1, sourceFrames - 1), name), position - lo);
24025
+ };
24026
+ const fps = Math.min(Math.round(options.fps ?? 20), Math.round(source.fps));
24027
+ const seconds = Math.min(source.durasi || sourceFrames / source.fps, options.maxSeconds ?? 8);
24028
+ const count = Math.max(1, Math.floor(seconds * fps));
24029
+ const sideOf = (a, b) => at(0, a)[0] >= at(0, b)[0] ? [a, b] : [b, a];
24030
+ const [shoulderPlus, shoulderMinus] = sideOf("shoulder_l", "shoulder_r");
24031
+ const wristOf = (shoulder) => shoulder.replace("shoulder", "wrist");
24032
+ const hipOf = (hip) => hip.replace("hip", "ankle");
24033
+ const [hipPlus, hipMinus] = sideOf("hip_l", "hip_r");
24034
+ const limbs = [
24035
+ [shoulderMinus, wristOf(shoulderMinus)],
24036
+ [shoulderPlus, wristOf(shoulderPlus)],
24037
+ [hipMinus, hipOf(hipMinus)],
24038
+ [hipPlus, hipOf(hipPlus)]
24039
+ ];
24040
+ const restPelvis = at(0, "pelvis")[1];
24041
+ const previous = [];
24042
+ const frames = [];
24043
+ for (let step = 0;step < count; step += 1) {
24044
+ const time3 = step / fps;
24045
+ const row = [];
24046
+ limbs.forEach(([from, to], slot) => {
24047
+ const d = unit(sub(joint(time3, to), joint(time3, from)));
24048
+ const e = limbEuler(d, previous[slot]);
24049
+ previous[slot] = e;
24050
+ row.push(round(e.x), 0, round(e.z));
24051
+ });
24052
+ const spine = uprightEuler(unit(sub(joint(time3, "neck"), joint(time3, "pelvis"))));
24053
+ row.push(round(spine.x), 0, round(spine.z));
24054
+ const head = uprightEuler(unit(sub(joint(time3, "head"), joint(time3, "neck"))));
24055
+ row.push(round(head.x - spine.x), 0, round(head.z - spine.z));
24056
+ row.push(round(Math.max(0, (joint(time3, "pelvis")[1] - restPelvis) * STUDS_PER_METRE)));
24057
+ frames.push(row);
24058
+ }
24059
+ return { fps, loop: source.loop === true, bones: [...BAKE_BONES], frames };
24060
+ }
24061
+ var BAKED_JOINTS, BAKE_BONES, STUDS_PER_METRE, sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]], unit = (v) => {
24062
+ const length = Math.hypot(v[0], v[1], v[2]) || 1;
24063
+ return [v[0] / length, v[1] / length, v[2] / length];
24064
+ }, wrap = (angle) => Math.atan2(Math.sin(angle), Math.cos(angle)), unwrap = (angle, near) => near + wrap(angle - near), MAX_TURN = 3.15, round = (value) => Math.round(value * 100) / 100, BakeError;
24065
+ var init_clip_bake = __esm(() => {
24066
+ BAKED_JOINTS = [
24067
+ "pelvis",
24068
+ "spine",
24069
+ "neck",
24070
+ "head",
24071
+ "shoulder_l",
24072
+ "elbow_l",
24073
+ "wrist_l",
24074
+ "shoulder_r",
24075
+ "elbow_r",
24076
+ "wrist_r",
24077
+ "hip_l",
24078
+ "knee_l",
24079
+ "ankle_l",
24080
+ "toe_l",
24081
+ "hip_r",
24082
+ "knee_r",
24083
+ "ankle_r",
24084
+ "toe_r"
24085
+ ];
24086
+ BAKE_BONES = [
24087
+ "armL",
24088
+ "armR",
24089
+ "legL",
24090
+ "legR",
24091
+ "torso",
24092
+ "head"
24093
+ ];
24094
+ STUDS_PER_METRE = 5 / 1.75;
24095
+ BakeError = class BakeError extends Error {
24096
+ };
24097
+ });
24098
+
24099
+ // ../character/src/named-faces.ts
24100
+ var NAMED_FACE_STAMPS;
24101
+ var init_named_faces = __esm(() => {
24102
+ NAMED_FACE_STAMPS = {
24103
+ sparkle: [".ew..we.", ".ee..ee.", "p..mm..p", "........"],
24104
+ shock: [".ee..ee.", ".ew..we.", "...mm...", "...mm..."],
24105
+ yell: ["..e..e..", ".ew..we.", ".mmmmmm.", ".mttttm."],
24106
+ pain: [".ee..ee.", "........", ".m.mm.m.", "..mmmm.."],
24107
+ dead: ["www..www", "www..www", "..mmmm..", "........"],
24108
+ rage: ["ee....ee", ".ee..ee.", ".mwwwwm.", "..mmmm.."],
24109
+ speechless: ["........", ".e....e.", "........", "...mm..."],
24110
+ idea: [".ee..ee.", ".ew..ew.", "..m..m..", "...mm..."],
24111
+ smug: ["........", "eee..eee", "........", "..mmmm.."],
24112
+ cry: ["eee..eee", "c......c", "c.mmmm.c", "..mttm.."],
24113
+ smirk: [".ee..ee.", "........", "....mmm.", "........"],
24114
+ tongue: ["........", ".ee..ee.", "...mm...", "...tt..."],
24115
+ cool: ["eeeeeeee", ".ee..ee.", "..m..m..", "...mm..."],
24116
+ serious: ["eee..eee", "ewe..ewe", "........", "..mmmm.."],
24117
+ stars: [".y....y.", "yyy..yyy", "..mmmm..", "..mttm.."],
24118
+ licik: [".ee..ee.", "........", ".mm..mm.", "..mmmm.."],
24119
+ tidur: ["........", ".ee..ee.", "...mm...", "...mm..."],
24120
+ teriak: ["..e..e..", ".e....e.", ".mmmmmm.", "..mttm.."],
24121
+ ngomel: ["ee....ee", ".e....e.", "...mm...", "..m..m.."]
24122
+ };
24123
+ });
24124
+
24125
+ // ../character/src/faces.ts
24126
+ function isNamedFace(name) {
24127
+ return Object.hasOwn(NAMED_FACE_STAMPS, name);
24128
+ }
24129
+ var NAMED_FACES, FACE_STAMP_PALETTE;
24130
+ var init_faces = __esm(() => {
24131
+ init_named_faces();
24132
+ NAMED_FACES = Object.keys(NAMED_FACE_STAMPS);
24133
+ FACE_STAMP_PALETTE = {
24134
+ e: "#161923",
24135
+ w: "#ffffff",
24136
+ m: "#5a1f2a",
24137
+ t: "#e8607a",
24138
+ p: "#f08aa8",
24139
+ y: "#f2d24b",
24140
+ c: "#4cc9e2"
24141
+ };
24142
+ });
24143
+
24144
+ // ../../node_modules/.bun/fflate@0.8.3/node_modules/fflate/esm/index.mjs
24145
+ import { createRequire } from "module";
24146
+ function unzlibSync(data, opts) {
24147
+ return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary);
24148
+ }
24149
+ var require2, _a3, Worker, isMarkedAsUntransferable, u8, u16, i32, fleb, fdeb, clim, freb = function(eb, start) {
24150
+ var b = new u16(31);
24151
+ for (var i = 0;i < 31; ++i) {
24152
+ b[i] = start += 1 << eb[i - 1];
24153
+ }
24154
+ var r = new i32(b[30]);
24155
+ for (var i = 1;i < 30; ++i) {
24156
+ for (var j = b[i];j < b[i + 1]; ++j) {
24157
+ r[j] = j - b[i] << 5 | i;
24158
+ }
24159
+ }
24160
+ return { b, r };
24161
+ }, _a3, fl, revfl, _b, fd, revfd, rev, x, i, hMap = function(cd, mb, r) {
24162
+ var s = cd.length;
24163
+ var i2 = 0;
24164
+ var l = new u16(mb);
24165
+ for (;i2 < s; ++i2) {
24166
+ if (cd[i2])
24167
+ ++l[cd[i2] - 1];
24168
+ }
24169
+ var le = new u16(mb);
24170
+ for (i2 = 1;i2 < mb; ++i2) {
24171
+ le[i2] = le[i2 - 1] + l[i2 - 1] << 1;
24172
+ }
24173
+ var co;
24174
+ if (r) {
24175
+ co = new u16(1 << mb);
24176
+ var rvb = 15 - mb;
24177
+ for (i2 = 0;i2 < s; ++i2) {
24178
+ if (cd[i2]) {
24179
+ var sv = i2 << 4 | cd[i2];
24180
+ var r_1 = mb - cd[i2];
24181
+ var v = le[cd[i2] - 1]++ << r_1;
24182
+ for (var m = v | (1 << r_1) - 1;v <= m; ++v) {
24183
+ co[rev[v] >> rvb] = sv;
24184
+ }
24185
+ }
24186
+ }
24187
+ } else {
24188
+ co = new u16(s);
24189
+ for (i2 = 0;i2 < s; ++i2) {
24190
+ if (cd[i2]) {
24191
+ co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
24192
+ }
24193
+ }
24194
+ }
24195
+ return co;
24196
+ }, flt, i, i, i, i, fdt, i, flrm, fdrm, max = function(a) {
24197
+ var m = a[0];
24198
+ for (var i2 = 1;i2 < a.length; ++i2) {
24199
+ if (a[i2] > m)
24200
+ m = a[i2];
24201
+ }
24202
+ return m;
24203
+ }, bits = function(d, p, m) {
24204
+ var o = p / 8 | 0;
24205
+ return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
24206
+ }, bits16 = function(d, p) {
24207
+ var o = p / 8 | 0;
24208
+ return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
24209
+ }, shft = function(p) {
24210
+ return (p + 7) / 8 | 0;
24211
+ }, slc = function(v, s, e) {
24212
+ if (s == null || s < 0)
24213
+ s = 0;
24214
+ if (e == null || e > v.length)
24215
+ e = v.length;
24216
+ return new u8(v.subarray(s, e));
24217
+ }, ec, err = function(ind, msg, nt) {
24218
+ var e = new Error(msg || ec[ind]);
24219
+ e.code = ind;
24220
+ if (Error.captureStackTrace)
24221
+ Error.captureStackTrace(e, err);
24222
+ if (!nt)
24223
+ throw e;
24224
+ return e;
24225
+ }, inflt = function(dat, st, buf, dict) {
24226
+ var sl = dat.length, dl = dict ? dict.length : 0;
24227
+ if (!sl || st.f && !st.l)
24228
+ return buf || new u8(0);
24229
+ var noBuf = !buf;
24230
+ var resize = noBuf || st.i != 2;
24231
+ var noSt = st.i;
24232
+ if (noBuf)
24233
+ buf = new u8(sl * 3);
24234
+ var cbuf = function(l2) {
24235
+ var bl = buf.length;
24236
+ if (l2 > bl) {
24237
+ var nbuf = new u8(Math.max(bl * 2, l2));
24238
+ nbuf.set(buf);
24239
+ buf = nbuf;
24240
+ }
24241
+ };
24242
+ var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
24243
+ var tbts = sl * 8;
24244
+ do {
24245
+ if (!lm) {
24246
+ final = bits(dat, pos, 1);
24247
+ var type = bits(dat, pos + 1, 3);
24248
+ pos += 3;
24249
+ if (!type) {
24250
+ var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
24251
+ if (t > sl) {
24252
+ if (noSt)
24253
+ err(0);
24254
+ break;
24255
+ }
24256
+ if (resize)
24257
+ cbuf(bt + l);
24258
+ buf.set(dat.subarray(s, t), bt);
24259
+ st.b = bt += l, st.p = pos = t * 8, st.f = final;
24260
+ continue;
24261
+ } else if (type == 1)
24262
+ lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
24263
+ else if (type == 2) {
24264
+ var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
24265
+ var tl = hLit + bits(dat, pos + 5, 31) + 1;
24266
+ pos += 14;
24267
+ var ldt = new u8(tl);
24268
+ var clt = new u8(19);
24269
+ for (var i2 = 0;i2 < hcLen; ++i2) {
24270
+ clt[clim[i2]] = bits(dat, pos + i2 * 3, 7);
24271
+ }
24272
+ pos += hcLen * 3;
24273
+ var clb = max(clt), clbmsk = (1 << clb) - 1;
24274
+ var clm = hMap(clt, clb, 1);
24275
+ for (var i2 = 0;i2 < tl; ) {
24276
+ var r = clm[bits(dat, pos, clbmsk)];
24277
+ pos += r & 15;
24278
+ var s = r >> 4;
24279
+ if (s < 16) {
24280
+ ldt[i2++] = s;
24281
+ } else {
24282
+ var c = 0, n = 0;
24283
+ if (s == 16)
24284
+ n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i2 - 1];
24285
+ else if (s == 17)
24286
+ n = 3 + bits(dat, pos, 7), pos += 3;
24287
+ else if (s == 18)
24288
+ n = 11 + bits(dat, pos, 127), pos += 7;
24289
+ while (n--)
24290
+ ldt[i2++] = c;
24291
+ }
24292
+ }
24293
+ var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
24294
+ lbt = max(lt);
24295
+ dbt = max(dt);
24296
+ lm = hMap(lt, lbt, 1);
24297
+ dm = hMap(dt, dbt, 1);
24298
+ } else
24299
+ err(1);
24300
+ if (pos > tbts) {
24301
+ if (noSt)
24302
+ err(0);
24303
+ break;
24304
+ }
24305
+ }
24306
+ if (resize)
24307
+ cbuf(bt + 131072);
24308
+ var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
24309
+ var lpos = pos;
24310
+ for (;; lpos = pos) {
24311
+ var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
24312
+ pos += c & 15;
24313
+ if (pos > tbts) {
24314
+ if (noSt)
24315
+ err(0);
24316
+ break;
24317
+ }
24318
+ if (!c)
24319
+ err(2);
24320
+ if (sym < 256)
24321
+ buf[bt++] = sym;
24322
+ else if (sym == 256) {
24323
+ lpos = pos, lm = null;
24324
+ break;
24325
+ } else {
24326
+ var add = sym - 254;
24327
+ if (sym > 264) {
24328
+ var i2 = sym - 257, b = fleb[i2];
24329
+ add = bits(dat, pos, (1 << b) - 1) + fl[i2];
24330
+ pos += b;
24331
+ }
24332
+ var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
24333
+ if (!d)
24334
+ err(3);
24335
+ pos += d & 15;
24336
+ var dt = fd[dsym];
24337
+ if (dsym > 3) {
24338
+ var b = fdeb[dsym];
24339
+ dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
24340
+ }
24341
+ if (pos > tbts) {
24342
+ if (noSt)
24343
+ err(0);
24344
+ break;
24345
+ }
24346
+ if (resize)
24347
+ cbuf(bt + 131072);
24348
+ var end = bt + add;
24349
+ if (bt < dt) {
24350
+ var shift = dl - dt, dend = Math.min(dt, end);
24351
+ if (shift + bt < 0)
24352
+ err(3);
24353
+ for (;bt < dend; ++bt)
24354
+ buf[bt] = dict[shift + bt];
24355
+ }
24356
+ for (;bt < end; ++bt)
24357
+ buf[bt] = buf[bt - dt];
24358
+ }
24359
+ }
24360
+ st.l = lm, st.p = lpos, st.b = bt, st.f = final;
24361
+ if (lm)
24362
+ final = 1, st.m = lbt, st.d = dm, st.n = dbt;
24363
+ } while (!final);
24364
+ return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
24365
+ }, et, zls = function(d, dict) {
24366
+ if ((d[0] & 15) != 8 || d[0] >> 4 > 7 || (d[0] << 8 | d[1]) % 31)
24367
+ err(6, "invalid zlib data");
24368
+ if ((d[1] >> 5 & 1) == +!dict)
24369
+ err(6, "invalid zlib data: " + (d[1] & 32 ? "need" : "unexpected") + " dictionary");
24370
+ return (d[1] >> 3 & 4) + 2;
24371
+ }, td, tds = 0;
24372
+ var init_esm = __esm(() => {
24373
+ require2 = createRequire("/");
24374
+ try {
24375
+ _a3 = require2("worker_threads"), Worker = _a3.Worker, isMarkedAsUntransferable = _a3.isMarkedAsUntransferable;
24376
+ } catch (e) {}
24377
+ u8 = Uint8Array;
24378
+ u16 = Uint16Array;
24379
+ i32 = Int32Array;
24380
+ fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0]);
24381
+ fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0]);
24382
+ clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
24383
+ _a3 = freb(fleb, 2);
24384
+ fl = _a3.b;
24385
+ revfl = _a3.r;
24386
+ fl[28] = 258, revfl[258] = 28;
24387
+ _b = freb(fdeb, 0);
24388
+ fd = _b.b;
24389
+ revfd = _b.r;
24390
+ rev = new u16(32768);
24391
+ for (i = 0;i < 32768; ++i) {
24392
+ x = (i & 43690) >> 1 | (i & 21845) << 1;
24393
+ x = (x & 52428) >> 2 | (x & 13107) << 2;
24394
+ x = (x & 61680) >> 4 | (x & 3855) << 4;
24395
+ rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
24396
+ }
24397
+ flt = new u8(288);
24398
+ for (i = 0;i < 144; ++i)
24399
+ flt[i] = 8;
24400
+ for (i = 144;i < 256; ++i)
24401
+ flt[i] = 9;
24402
+ for (i = 256;i < 280; ++i)
24403
+ flt[i] = 7;
24404
+ for (i = 280;i < 288; ++i)
24405
+ flt[i] = 8;
24406
+ fdt = new u8(32);
24407
+ for (i = 0;i < 32; ++i)
24408
+ fdt[i] = 5;
24409
+ flrm = /* @__PURE__ */ hMap(flt, 9, 1);
24410
+ fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
24411
+ ec = [
24412
+ "unexpected EOF",
24413
+ "invalid block type",
24414
+ "invalid length/literal",
24415
+ "invalid distance",
24416
+ "stream finished",
24417
+ "no stream handler",
24418
+ ,
24419
+ "no callback",
24420
+ "invalid UTF-8 data",
24421
+ "extra field too long",
24422
+ "date not in range 1980-2099",
24423
+ "filename too long",
24424
+ "stream finishing",
24425
+ "invalid zip data"
24426
+ ];
24427
+ et = /* @__PURE__ */ new u8(0);
24428
+ td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder;
24429
+ try {
24430
+ td.decode(et, { stream: true });
24431
+ tds = 1;
24432
+ } catch (e) {}
24433
+ });
24434
+
24435
+ // ../character/src/png.ts
24436
+ function* chunks(bytes) {
24437
+ let at = 8;
24438
+ while (at + 8 <= bytes.length) {
24439
+ const length = readUint32(bytes, at);
24440
+ const type = String.fromCharCode(bytes[at + 4] ?? 0, bytes[at + 5] ?? 0, bytes[at + 6] ?? 0, bytes[at + 7] ?? 0);
24441
+ const start = at + 8;
24442
+ const end = start + length;
24443
+ if (end + 4 > bytes.length)
24444
+ return;
24445
+ yield { type, data: bytes.subarray(start, end) };
24446
+ at = end + 4;
24447
+ }
24448
+ }
24449
+ function parseHeader(bytes) {
24450
+ if (!isPng(bytes))
24451
+ return { ok: false, reason: "not_png" };
24452
+ const first = chunks(bytes).next();
24453
+ if (first.done)
24454
+ return { ok: false, reason: "truncated" };
24455
+ const chunk = first.value;
24456
+ if (chunk.type !== "IHDR" || chunk.data.length !== 13)
24457
+ return { ok: false, reason: "bad_header" };
24458
+ const header = {
24459
+ width: readUint32(chunk.data, 0),
24460
+ height: readUint32(chunk.data, 4),
24461
+ bitDepth: chunk.data[8] ?? 0,
24462
+ colorType: chunk.data[9] ?? 0,
24463
+ interlaced: (chunk.data[12] ?? 0) === 1
24464
+ };
24465
+ if (header.width === 0 || header.height === 0)
24466
+ return { ok: false, reason: "bad_header" };
24467
+ if (header.width * header.height > MAX_PIXELS)
24468
+ return { ok: false, reason: "too_large" };
24469
+ return { ok: true, header };
24470
+ }
24471
+ function readPngHeader(bytes) {
24472
+ const parsed = parseHeader(bytes);
24473
+ if (!parsed.ok)
24474
+ return parsed;
24475
+ const { header } = parsed;
24476
+ if (header.bitDepth !== 8)
24477
+ return { ok: false, reason: "unsupported_format" };
24478
+ if (header.colorType !== 2 && header.colorType !== 6)
24479
+ return { ok: false, reason: "unsupported_format" };
24480
+ if (header.interlaced)
24481
+ return { ok: false, reason: "interlaced" };
24482
+ for (const chunk of chunks(bytes)) {
24483
+ if (chunk.type === "PLTE")
24484
+ return { ok: false, reason: "unsupported_format" };
24485
+ }
24486
+ return { ok: true, header };
24487
+ }
24488
+ function unfilter(raw, width, height, channels) {
24489
+ const stride = width * channels;
24490
+ const out = new Uint8Array(stride * height);
24491
+ for (let row = 0;row < height; row++) {
24492
+ const filter = raw[row * (stride + 1)];
24493
+ const start = row * (stride + 1) + 1;
24494
+ const target = row * stride;
24495
+ const prior = target - stride;
24496
+ for (let index = 0;index < stride; index++) {
24497
+ const value = raw[start + index] ?? 0;
24498
+ const left = index >= channels ? out[target + index - channels] ?? 0 : 0;
24499
+ const up2 = row > 0 ? out[prior + index] ?? 0 : 0;
24500
+ const upLeft = row > 0 && index >= channels ? out[prior + index - channels] ?? 0 : 0;
24501
+ let restored = value;
24502
+ if (filter === 1)
24503
+ restored = value + left;
24504
+ else if (filter === 2)
24505
+ restored = value + up2;
24506
+ else if (filter === 3)
24507
+ restored = value + Math.floor((left + up2) / 2);
24508
+ else if (filter === 4)
24509
+ restored = value + paeth(left, up2, upLeft);
24510
+ else if (filter !== 0)
24511
+ return null;
24512
+ out[target + index] = restored & 255;
24513
+ }
24514
+ }
24515
+ return out;
24516
+ }
24517
+ function decodePng(bytes) {
24518
+ const header = readPngHeader(bytes);
24519
+ if (!header.ok)
24520
+ return header;
24521
+ const { width, height, colorType } = header.header;
24522
+ const channels = CHANNELS[colorType] ?? 0;
24523
+ if (!channels)
24524
+ return { ok: false, reason: "unsupported_format" };
24525
+ const parts = [];
24526
+ let sawEnd = false;
24527
+ for (const chunk of chunks(bytes)) {
24528
+ if (chunk.type === "IDAT")
24529
+ parts.push(chunk.data);
24530
+ if (chunk.type === "IEND") {
24531
+ sawEnd = true;
24532
+ break;
24533
+ }
24534
+ }
24535
+ if (parts.length === 0 || !sawEnd)
24536
+ return { ok: false, reason: "truncated" };
24537
+ const compressed2 = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
24538
+ let offset = 0;
24539
+ for (const part of parts) {
24540
+ compressed2.set(part, offset);
24541
+ offset += part.length;
24542
+ }
24543
+ let raw;
24544
+ try {
24545
+ raw = unzlibSync(compressed2);
24546
+ } catch {
24547
+ return { ok: false, reason: "corrupt" };
24548
+ }
24549
+ if (raw.length < (width * channels + 1) * height)
24550
+ return { ok: false, reason: "corrupt" };
24551
+ const pixels = unfilter(raw, width, height, channels);
24552
+ if (!pixels)
24553
+ return { ok: false, reason: "corrupt" };
24554
+ const data = new Uint8Array(width * height * 4);
24555
+ for (let index = 0;index < width * height; index++) {
24556
+ const source = index * channels;
24557
+ data[index * 4] = pixels[source] ?? 0;
24558
+ data[index * 4 + 1] = pixels[source + 1] ?? 0;
24559
+ data[index * 4 + 2] = pixels[source + 2] ?? 0;
24560
+ data[index * 4 + 3] = channels === 4 ? pixels[source + 3] ?? 255 : 255;
24561
+ }
24562
+ return { ok: true, image: { width, height, data } };
24563
+ }
24564
+ function decodeBase64(value) {
24565
+ if (value.length === 0 || value.length % 4 !== 0)
24566
+ return null;
24567
+ if (!/^[A-Za-z0-9+/]*={0,2}$/.test(value))
24568
+ return null;
24569
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
24570
+ const bytes = new Uint8Array(value.length / 4 * 3 - padding);
24571
+ let written = 0;
24572
+ for (let at = 0;at < value.length; at += 4) {
24573
+ const codes = [0, 1, 2, 3].map((offset) => {
24574
+ const character = value[at + offset] ?? "=";
24575
+ return character === "=" ? 0 : BASE64.indexOf(character);
24576
+ });
24577
+ if (codes.some((code) => code < 0))
24578
+ return null;
24579
+ const [a = 0, b = 0, c = 0, d = 0] = codes;
24580
+ const triple = a << 18 | b << 12 | c << 6 | d;
24581
+ if (written < bytes.length)
24582
+ bytes[written++] = triple >> 16 & 255;
24583
+ if (written < bytes.length)
24584
+ bytes[written++] = triple >> 8 & 255;
24585
+ if (written < bytes.length)
24586
+ bytes[written++] = triple & 255;
24587
+ }
24588
+ return bytes;
24589
+ }
24590
+ var MAX_PIXELS = 4000000, SIGNATURE, CHANNELS, readUint32 = (bytes, at) => ((bytes[at] ?? 0) << 24 | (bytes[at + 1] ?? 0) << 16 | (bytes[at + 2] ?? 0) << 8 | (bytes[at + 3] ?? 0)) >>> 0, isPng = (bytes) => bytes.length >= 8 && SIGNATURE.every((byte, index) => bytes[index] === byte), paeth = (left, up2, upLeft) => {
24591
+ const estimate = left + up2 - upLeft;
24592
+ const toLeft = Math.abs(estimate - left);
24593
+ const toUp = Math.abs(estimate - up2);
24594
+ const toUpLeft = Math.abs(estimate - upLeft);
24595
+ if (toLeft <= toUp && toLeft <= toUpLeft)
24596
+ return left;
24597
+ return toUp <= toUpLeft ? up2 : upLeft;
24598
+ }, BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
24599
+ var init_png = __esm(() => {
24600
+ init_esm();
24601
+ SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
24602
+ CHANNELS = { 0: 1, 2: 3, 4: 2, 6: 4 };
24603
+ });
24604
+
24605
+ // ../character/src/rig.ts
24606
+ var box = (name, parent, joint, size, center = [0, 0, 0]) => ({ name, parent, joint, size, center }), R6, R15, PLUP;
24607
+ var init_rig = __esm(() => {
24608
+ R6 = {
24609
+ id: "r6",
24610
+ height: 5,
24611
+ bones: [
24612
+ box("Torso", null, [0, 3, 0], [2, 2, 1]),
24613
+ box("Head", "Torso", [0, 1, 0], [2, 1, 1], [0, 0.5, 0]),
24614
+ box("LeftArm", "Torso", [-1, 1, 0], [1, 2, 1], [-0.5, -1, 0]),
24615
+ box("RightArm", "Torso", [1, 1, 0], [1, 2, 1], [0.5, -1, 0]),
24616
+ box("LeftLeg", "Torso", [-0.5, -1, 0], [1, 2, 1], [0, -1, 0]),
24617
+ box("RightLeg", "Torso", [0.5, -1, 0], [1, 2, 1], [0, -1, 0])
24618
+ ],
24619
+ aliases: {
24620
+ head: "Head",
24621
+ torso: "Torso",
24622
+ armL: "LeftArm",
24623
+ armR: "RightArm",
24624
+ legL: "LeftLeg",
24625
+ legR: "RightLeg"
24626
+ },
24627
+ lower: {}
24628
+ };
24629
+ R15 = {
24630
+ id: "r15",
24631
+ height: 5,
24632
+ bones: [
24633
+ box("LowerTorso", null, [0, 2.4, 0], [2, 0.4, 1], [0, -0.2, 0]),
24634
+ box("UpperTorso", "LowerTorso", [0, -0, 0], [2, 1.6, 1], [0, 0.8, 0]),
24635
+ box("Head", "UpperTorso", [0, 1.6, 0], [2, 1, 1], [0, 0.5, 0]),
24636
+ box("LeftUpperArm", "UpperTorso", [-1, 1.6, 0], [1, 1, 1], [-0.5, -0.5, 0]),
24637
+ box("LeftLowerArm", "LeftUpperArm", [-0.5, -1, 0], [1, 0.8, 1], [0, -0.4, 0]),
24638
+ box("LeftHand", "LeftLowerArm", [0, -0.8, 0], [1, 0.2, 1], [0, -0.1, 0]),
24639
+ box("RightUpperArm", "UpperTorso", [1, 1.6, 0], [1, 1, 1], [0.5, -0.5, 0]),
24640
+ box("RightLowerArm", "RightUpperArm", [0.5, -1, 0], [1, 0.8, 1], [0, -0.4, 0]),
24641
+ box("RightHand", "RightLowerArm", [0, -0.8, 0], [1, 0.2, 1], [0, -0.1, 0]),
24642
+ box("LeftUpperLeg", "LowerTorso", [-0.5, -0.4, 0], [1, 0.9, 1], [0, -0.45, 0]),
24643
+ box("LeftLowerLeg", "LeftUpperLeg", [0, -0.9, 0], [1, 0.9, 1], [0, -0.45, 0]),
24644
+ box("LeftFoot", "LeftLowerLeg", [0, -0.9, 0], [1, 0.2, 1], [0, -0.1, 0]),
24645
+ box("RightUpperLeg", "LowerTorso", [0.5, -0.4, 0], [1, 0.9, 1], [0, -0.45, 0]),
24646
+ box("RightLowerLeg", "RightUpperLeg", [0, -0.9, 0], [1, 0.9, 1], [0, -0.45, 0]),
24647
+ box("RightFoot", "RightLowerLeg", [0, -0.9, 0], [1, 0.2, 1], [0, -0.1, 0])
24648
+ ],
24649
+ aliases: {
24650
+ head: "Head",
24651
+ torso: "UpperTorso",
24652
+ armL: "LeftUpperArm",
24653
+ armR: "RightUpperArm",
24654
+ legL: "LeftUpperLeg",
24655
+ legR: "RightUpperLeg"
24656
+ },
24657
+ lower: {
24658
+ armL: "LeftLowerArm",
24659
+ armR: "RightLowerArm",
24660
+ legL: "LeftLowerLeg",
24661
+ legR: "RightLowerLeg"
24662
+ }
24663
+ };
24664
+ PLUP = {
24665
+ id: "plup",
24666
+ height: 3.4,
24667
+ bones: [
24668
+ box("Body", null, [0, 1.1, 0], [2.6, 2.3, 2], [0, 1, 0]),
24669
+ box("LeftArm", "Body", [-1.3, 1, 0], [0.5, 0.9, 0.5], [-0.2, -0.45, 0]),
24670
+ box("RightArm", "Body", [1.3, 1, 0], [0.5, 0.9, 0.5], [0.2, -0.45, 0]),
24671
+ box("LeftLeg", "Body", [-0.6, 0, 0], [0.7, 1.1, 0.8], [0, -0.55, 0]),
24672
+ box("RightLeg", "Body", [0.6, 0, 0], [0.7, 1.1, 0.8], [0, -0.55, 0])
24673
+ ],
24674
+ aliases: {
24675
+ head: "Body",
24676
+ torso: "Body",
24677
+ armL: "LeftArm",
24678
+ armR: "RightArm",
24679
+ legL: "LeftLeg",
24680
+ legR: "RightLeg"
24681
+ },
24682
+ lower: {}
24683
+ };
24684
+ });
24685
+
24686
+ // ../character/src/pose.ts
24687
+ var sin = (t, rate, phase = 0) => Math.sin(t * rate * Math.PI * 2 + phase), stride = (t, rate, swing) => ({
24688
+ armL: { x: sin(t, rate) * swing * 0.9 },
24689
+ armR: { x: -sin(t, rate) * swing * 0.9 },
24690
+ legL: { x: -sin(t, rate) * swing },
24691
+ legR: { x: sin(t, rate) * swing },
24692
+ lift: Math.abs(sin(t, rate)) * 0.08
24693
+ }), CLIPS;
24694
+ var init_pose = __esm(() => {
24695
+ init_rig();
24696
+ CLIPS = {
24697
+ idle: (t) => ({
24698
+ armL: { z: -0.06 + sin(t, 0.4) * 0.03 },
24699
+ armR: { z: 0.06 - sin(t, 0.4) * 0.03 },
24700
+ head: { y: sin(t, 0.15) * 0.12 },
24701
+ lift: sin(t, 0.4) * 0.02
24702
+ }),
24703
+ walk: (t) => stride(t, 1.4, 0.65),
24704
+ run: (t) => ({ ...stride(t, 2.4, 1.05), torso: { x: 0.12 } }),
24705
+ jump: (t) => {
24706
+ const air = Math.max(0, Math.sin(Math.min(t, 1) * Math.PI));
24707
+ return {
24708
+ armL: { z: -0.5 - air * 1.8 },
24709
+ armR: { z: 0.5 + air * 1.8 },
24710
+ legL: { x: air * 0.5 },
24711
+ legR: { x: -air * 0.3 },
24712
+ lift: air * 1.6
24713
+ };
24714
+ },
24715
+ wave: (t) => ({ armR: { z: 2.6 + sin(t, 2) * 0.35 }, head: { y: 0.15 } }),
24716
+ dance: (t) => ({
24717
+ armL: { z: -1.6 + sin(t, 2) * 0.7 },
24718
+ armR: { z: 1.6 + sin(t, 2) * 0.7 },
24719
+ legL: { x: Math.max(0, sin(t, 2)) * 0.5 },
24720
+ legR: { x: Math.max(0, -sin(t, 2)) * 0.5 },
24721
+ torso: { z: sin(t, 1) * 0.12 },
24722
+ lift: Math.abs(sin(t, 2)) * 0.25
24723
+ })
24724
+ };
24725
+ });
24726
+
24727
+ // ../character/src/skin.ts
24728
+ var rect = (x2, y, w, h) => ({ x: x2, y, w, h }), CLASSIC_WIDTH = 585, CLASSIC_HEIGHT = 559, CLASSIC_TORSO, CLASSIC_RIGHT_LIMB, CLASSIC_LEFT_LIMB, CLASSIC_BONES;
24729
+ var init_skin = __esm(() => {
24730
+ CLASSIC_TORSO = {
24731
+ up: rect(231, 8, 128, 64),
24732
+ front: rect(231, 74, 128, 128),
24733
+ down: rect(231, 204, 128, 64),
24734
+ left: rect(361, 74, 64, 128),
24735
+ right: rect(165, 74, 64, 128),
24736
+ back: rect(427, 74, 128, 128)
24737
+ };
24738
+ CLASSIC_RIGHT_LIMB = {
24739
+ left: rect(19, 355, 64, 128),
24740
+ back: rect(85, 355, 64, 128),
24741
+ right: rect(151, 355, 64, 128),
24742
+ front: rect(217, 355, 64, 128),
24743
+ up: rect(217, 289, 64, 64),
24744
+ down: rect(217, 485, 64, 64)
24745
+ };
24746
+ CLASSIC_LEFT_LIMB = {
24747
+ front: rect(308, 355, 64, 128),
24748
+ left: rect(374, 355, 64, 128),
24749
+ back: rect(440, 355, 64, 128),
24750
+ right: rect(506, 355, 64, 128),
24751
+ up: rect(308, 289, 64, 64),
24752
+ down: rect(308, 485, 64, 64)
24753
+ };
24754
+ CLASSIC_BONES = {
24755
+ Torso: { sheet: "shirt", faces: CLASSIC_TORSO },
24756
+ LeftArm: { sheet: "shirt", faces: CLASSIC_LEFT_LIMB },
24757
+ RightArm: { sheet: "shirt", faces: CLASSIC_RIGHT_LIMB },
24758
+ LeftLeg: { sheet: "pants", faces: CLASSIC_LEFT_LIMB },
24759
+ RightLeg: { sheet: "pants", faces: CLASSIC_RIGHT_LIMB },
24760
+ UpperTorso: { sheet: "shirt", faces: CLASSIC_TORSO, slice: [0, 0.8] },
24761
+ LowerTorso: { sheet: "pants", faces: CLASSIC_TORSO, slice: [0.8, 1] },
24762
+ LeftUpperArm: { sheet: "shirt", faces: CLASSIC_LEFT_LIMB, slice: [0, 0.5] },
24763
+ LeftLowerArm: { sheet: "shirt", faces: CLASSIC_LEFT_LIMB, slice: [0.5, 0.9] },
24764
+ LeftHand: { sheet: "shirt", faces: CLASSIC_LEFT_LIMB, slice: [0.9, 1] },
24765
+ RightUpperArm: { sheet: "shirt", faces: CLASSIC_RIGHT_LIMB, slice: [0, 0.5] },
24766
+ RightLowerArm: { sheet: "shirt", faces: CLASSIC_RIGHT_LIMB, slice: [0.5, 0.9] },
24767
+ RightHand: { sheet: "shirt", faces: CLASSIC_RIGHT_LIMB, slice: [0.9, 1] },
24768
+ LeftUpperLeg: { sheet: "pants", faces: CLASSIC_LEFT_LIMB, slice: [0, 0.45] },
24769
+ LeftLowerLeg: { sheet: "pants", faces: CLASSIC_LEFT_LIMB, slice: [0.45, 0.9] },
24770
+ LeftFoot: { sheet: "pants", faces: CLASSIC_LEFT_LIMB, slice: [0.9, 1] },
24771
+ RightUpperLeg: { sheet: "pants", faces: CLASSIC_RIGHT_LIMB, slice: [0, 0.45] },
24772
+ RightLowerLeg: { sheet: "pants", faces: CLASSIC_RIGHT_LIMB, slice: [0.45, 0.9] },
24773
+ RightFoot: { sheet: "pants", faces: CLASSIC_RIGHT_LIMB, slice: [0.9, 1] }
24774
+ };
24775
+ });
24776
+
24777
+ // ../character/src/skin-native.ts
24778
+ function clampBodyScale(scale) {
24779
+ const width = {};
24780
+ for (const part of WIDTH_PARTS) {
24781
+ const value = scale?.width?.[part];
24782
+ if (typeof value === "number")
24783
+ width[part] = clamp(value, BODY_SCALE_LIMITS.width);
24784
+ }
24785
+ return {
24786
+ stature: clamp(scale?.stature, BODY_SCALE_LIMITS.stature),
24787
+ width,
24788
+ head: clamp(scale?.head, BODY_SCALE_LIMITS.head)
24789
+ };
24790
+ }
24791
+ var NATIVE_WIDTH = 512, NATIVE_HEIGHT = 256, rect2 = (x2, y, w, h) => ({ x: x2, y, w, h }), NATIVE_TORSO, NATIVE_HEAD, NATIVE_ARM_LEFT, NATIVE_ARM_RIGHT, NATIVE_LEG_LEFT, NATIVE_LEG_RIGHT, NATIVE_PARTS, BODY_SCALE_LIMITS, WIDTH_PARTS, clamp = (value, limit) => typeof value === "number" && Number.isFinite(value) ? Math.min(limit.max, Math.max(limit.min, value)) : 1, NATIVE_SHEET_CAPS, CONVERSION_FACES, CLASSIC_SOURCES, CLASSIC_TO_NATIVE;
24792
+ var init_skin_native = __esm(() => {
24793
+ init_rig();
24794
+ init_skin();
24795
+ NATIVE_TORSO = {
24796
+ up: rect2(32, 0, 64, 32),
24797
+ left: rect2(0, 32, 32, 64),
24798
+ front: rect2(32, 32, 64, 64),
24799
+ right: rect2(96, 32, 32, 64),
24800
+ back: rect2(128, 32, 64, 64),
24801
+ down: rect2(32, 96, 64, 32)
24802
+ };
24803
+ NATIVE_HEAD = {
24804
+ up: rect2(224, 0, 64, 32),
24805
+ left: rect2(192, 32, 32, 32),
24806
+ front: rect2(224, 32, 64, 32),
24807
+ right: rect2(288, 32, 32, 32),
24808
+ back: rect2(320, 32, 64, 32),
24809
+ down: rect2(224, 64, 64, 32)
24810
+ };
24811
+ NATIVE_ARM_LEFT = {
24812
+ up: rect2(32, 128, 32, 32),
24813
+ left: rect2(0, 160, 32, 64),
24814
+ front: rect2(32, 160, 32, 64),
24815
+ right: rect2(64, 160, 32, 64),
24816
+ back: rect2(96, 160, 32, 64),
24817
+ down: rect2(32, 224, 32, 32)
24818
+ };
24819
+ NATIVE_ARM_RIGHT = {
24820
+ up: rect2(160, 128, 32, 32),
24821
+ left: rect2(128, 160, 32, 64),
24822
+ front: rect2(160, 160, 32, 64),
24823
+ right: rect2(192, 160, 32, 64),
24824
+ back: rect2(224, 160, 32, 64),
24825
+ down: rect2(160, 224, 32, 32)
24826
+ };
24827
+ NATIVE_LEG_LEFT = {
24828
+ up: rect2(288, 128, 32, 32),
24829
+ left: rect2(256, 160, 32, 64),
24830
+ front: rect2(288, 160, 32, 64),
24831
+ right: rect2(320, 160, 32, 64),
24832
+ back: rect2(352, 160, 32, 64),
24833
+ down: rect2(288, 224, 32, 32)
24834
+ };
24835
+ NATIVE_LEG_RIGHT = {
24836
+ up: rect2(416, 128, 32, 32),
24837
+ left: rect2(384, 160, 32, 64),
24838
+ front: rect2(416, 160, 32, 64),
24839
+ right: rect2(448, 160, 32, 64),
24840
+ back: rect2(480, 160, 32, 64),
24841
+ down: rect2(416, 224, 32, 32)
24842
+ };
24843
+ NATIVE_PARTS = {
24844
+ torso: { block: rect2(0, 0, 192, 128), studs: [2, 2, 1], faces: NATIVE_TORSO },
24845
+ head: { block: rect2(192, 0, 192, 96), studs: [2, 1, 1], faces: NATIVE_HEAD },
24846
+ armL: { block: rect2(0, 128, 128, 128), studs: [1, 2, 1], faces: NATIVE_ARM_LEFT },
24847
+ armR: { block: rect2(128, 128, 128, 128), studs: [1, 2, 1], faces: NATIVE_ARM_RIGHT },
24848
+ legL: { block: rect2(256, 128, 128, 128), studs: [1, 2, 1], faces: NATIVE_LEG_LEFT },
24849
+ legR: { block: rect2(384, 128, 128, 128), studs: [1, 2, 1], faces: NATIVE_LEG_RIGHT }
24850
+ };
24851
+ BODY_SCALE_LIMITS = {
24852
+ stature: { min: 0.5, max: 1.15 },
24853
+ width: { min: 0.9, max: 1.3 },
24854
+ head: { min: 0.9, max: 1.25 }
24855
+ };
24856
+ WIDTH_PARTS = ["torso", "armL", "armR", "legL", "legR"];
24857
+ NATIVE_SHEET_CAPS = {
24858
+ format: "png-24",
24859
+ width: NATIVE_WIDTH,
24860
+ height: NATIVE_HEIGHT,
24861
+ maxBytes: 64 * 1024
24862
+ };
24863
+ CONVERSION_FACES = ["front", "back", "left", "right", "up", "down"];
24864
+ CLASSIC_SOURCES = [
24865
+ { part: "torso", bone: "Torso" },
24866
+ { part: "armL", bone: "LeftArm" },
24867
+ { part: "armR", bone: "RightArm" },
24868
+ { part: "legL", bone: "LeftLeg" },
24869
+ { part: "legR", bone: "RightLeg" }
24870
+ ];
24871
+ CLASSIC_TO_NATIVE = CLASSIC_SOURCES.flatMap(({ part, bone }) => {
24872
+ const mapping = CLASSIC_BONES[bone];
24873
+ if (!mapping)
24874
+ return [];
24875
+ return CONVERSION_FACES.map((face) => ({
24876
+ part,
24877
+ face,
24878
+ sheet: mapping.sheet,
24879
+ source: mapping.faces[face],
24880
+ dest: NATIVE_PARTS[part].faces[face]
24881
+ }));
24882
+ });
24883
+ });
24884
+
24885
+ // ../character/src/listing.ts
24886
+ function refuse2(message) {
24887
+ throw new Refusal(message);
24888
+ }
24889
+ function asObject(value) {
24890
+ if (!value || typeof value !== "object" || Array.isArray(value))
24891
+ refuse2("assetConfig must be an object: the composition the editor produced.");
24892
+ return value;
24893
+ }
24894
+ function refuseUnknownKeys(record2, allowed, kind) {
24895
+ for (const key of Object.keys(record2)) {
24896
+ if (!allowed.includes(key))
24897
+ refuse2(`assetConfig.${key} is not part of an ${kind} manifest. Allowed: ${allowed.join(", ")}.`);
24898
+ }
24899
+ }
24900
+ function readGlyph(value) {
24901
+ if (typeof value !== "string")
24902
+ refuse2('assetConfig.glyph must be the kaomoji text, for example "(\u2267\u25BD\u2266)".');
24903
+ const glyph = value.trim();
24904
+ const characters = [...glyph];
24905
+ if (characters.length === 0 || characters.length > MAX_GLYPH_CHARACTERS)
24906
+ refuse2(`assetConfig.glyph must be 1 to ${MAX_GLYPH_CHARACTERS} characters; this one is ${characters.length}.`);
24907
+ for (const character of characters) {
24908
+ const code = character.codePointAt(0) ?? 0;
24909
+ if (code < 32 || code === 127)
24910
+ refuse2("assetConfig.glyph must stay on one line: no control characters.");
24911
+ }
24912
+ return glyph;
24913
+ }
24914
+ function readFace(value) {
24915
+ if (typeof value !== "string" || !value)
24916
+ refuse2(`assetConfig.face must name a face. Choose one of: ${NAMED_FACES.join(", ")}.`);
24917
+ if (!isNamedFace(value))
24918
+ refuse2(`assetConfig.face "${value}" is not a named face. Choose one of: ${NAMED_FACES.join(", ")}, or draw your own with faceStamp.`);
24919
+ return value;
24920
+ }
24921
+ function readClip(value) {
24922
+ if (typeof value !== "string" || !Object.hasOwn(CLIPS, value))
24923
+ refuse2(`assetConfig.clip must be one the rig plays: ${Object.keys(CLIPS).join(", ")}${typeof value === "string" ? `. "${value}" is not one.` : "."}`);
24924
+ return value;
24925
+ }
24926
+ function readFaceStamp(value) {
24927
+ if (!Array.isArray(value) || value.length !== FACE_STAMP_ROWS)
24928
+ refuse2(`assetConfig.faceStamp must be ${FACE_STAMP_ROWS} rows of ${FACE_STAMP_COLUMNS} characters: one row per pixel row.`);
24929
+ return value.map((row, index) => {
24930
+ if (typeof row !== "string")
24931
+ refuse2(`assetConfig.faceStamp[${index}] must be a string of ${FACE_STAMP_COLUMNS} keys.`);
24932
+ const characters = [...row];
24933
+ if (characters.length !== FACE_STAMP_COLUMNS)
24934
+ refuse2(`assetConfig.faceStamp[${index}] has ${characters.length} characters; a face row is ${FACE_STAMP_COLUMNS}.`);
24935
+ for (const [column, key] of characters.entries()) {
24936
+ if (key !== "." && !FACE_PALETTE_KEYS.includes(key))
24937
+ refuse2(`assetConfig.faceStamp[${index}][${column}] is "${key}". Use "." for transparent or one of: ${FACE_PALETTE_KEYS.join(", ")}.`);
24938
+ }
24939
+ return characters.join("");
24940
+ });
24941
+ }
24942
+ function readColor(value) {
24943
+ if (typeof value !== "string" || !COLOR_PATTERN.test(value))
24944
+ refuse2('assetConfig.color must be a hex colour such as "#8a5ad8".');
24945
+ return value.toLowerCase();
24946
+ }
24947
+ async function readImage(field, value, maxBytes) {
24948
+ if (typeof value !== "string" || !value.startsWith(PNG_DATA_URL))
24949
+ refuse2(`${field} must be a data:image/png;base64, URL carrying the PNG bytes.`);
24950
+ const base643 = value.slice(PNG_DATA_URL.length);
24951
+ const bytes = decodeBase64(base643);
24952
+ if (!bytes)
24953
+ refuse2(`${field} is not valid base64.`);
24954
+ const header = readPngHeader(bytes);
24955
+ if (!header.ok) {
24956
+ if (header.reason === "not_png")
24957
+ refuse2(`${field} must be a PNG file: these bytes are not one.`);
24958
+ if (header.reason === "unsupported_format")
24959
+ refuse2(`${field} must be a PNG-24 file (8-bit truecolour or truecolour+alpha, no palette): re-export it as PNG-24.`);
24960
+ if (header.reason === "interlaced")
24961
+ refuse2(`${field} must be a non-interlaced PNG: re-export it without Adam7.`);
24962
+ if (header.reason === "too_large")
24963
+ refuse2(`${field} is larger than any listing image may be: re-export it at the template size.`);
24964
+ refuse2(`${field} could not be read as a PNG: re-export it as PNG-24.`);
24965
+ }
24966
+ if (bytes.length > maxBytes)
24967
+ refuse2(`${field} must be ${maxBytes / 1024} KiB at most; these bytes are ${Math.ceil(bytes.length / 1024)} KiB.`);
24968
+ const decoded = decodePng(bytes);
24969
+ if (!decoded.ok)
24970
+ refuse2(`${field} could not be decoded as a PNG: re-export it as PNG-24.`);
24971
+ const digest2 = await crypto.subtle.digest("SHA-256", bytes);
24972
+ return {
24973
+ url: value,
24974
+ digest: [...new Uint8Array(digest2)].map((byte) => byte.toString(16).padStart(2, "0")).join(""),
24975
+ image: decoded.image
24976
+ };
24977
+ }
24978
+ function readLayer(value) {
24979
+ if (value !== "shirt" && value !== "pants")
24980
+ refuse2('assetConfig.layer must be "shirt" or "pants": which classic template the sheet is.');
24981
+ return value;
24982
+ }
24983
+ function readVariantParts(value) {
24984
+ if (!Array.isArray(value) || value.length === 0)
24985
+ refuse2('assetConfig.parts must list at least one part, for example [{"part":"armL","faces":["front","left","right"]}].');
24986
+ const seen = new Set;
24987
+ return value.map((entry, index) => {
24988
+ const field = `assetConfig.parts[${index}]`;
24989
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
24990
+ refuse2(`${field} must be an object with part and faces.`);
24991
+ const record2 = entry;
24992
+ for (const key of Object.keys(record2)) {
24993
+ if (key !== "part" && key !== "faces")
24994
+ refuse2(`${field}.${key} is not part of a part entry. Allowed: part, faces.`);
24995
+ }
24996
+ const part = record2.part;
24997
+ if (typeof part !== "string" || !VARIANT_PARTS.includes(part))
24998
+ refuse2(`${field}.part ${typeof part === "string" ? `"${part}"` : "must be a name"}: choose one of ${VARIANT_PARTS.join(", ")}.`);
24999
+ if (seen.has(part))
25000
+ refuse2(`${field}.part repeats "${part}": list each part once.`);
25001
+ seen.add(part);
25002
+ const faces = record2.faces;
25003
+ if (!Array.isArray(faces) || faces.length === 0)
25004
+ refuse2(`${field}.faces must list one or more of: ${VARIANT_FACES.join(", ")}.`);
25005
+ const normalised = [];
25006
+ for (const face of faces) {
25007
+ if (typeof face !== "string" || !VARIANT_FACES.includes(face))
25008
+ refuse2(`${field}.faces has ${typeof face === "string" ? `"${face}"` : "a value that is not a name"}: allowed faces are ${VARIANT_FACES.join(", ")}.`);
25009
+ if (!normalised.includes(face))
25010
+ normalised.push(face);
25011
+ }
25012
+ return { part, faces: normalised };
25013
+ });
25014
+ }
25015
+ function readKnob(field, value, limit) {
25016
+ if (value === undefined)
25017
+ return;
25018
+ if (typeof value !== "number" || !Number.isFinite(value))
25019
+ refuse2(`${field} must be a number between ${limit.min} and ${limit.max}.`);
25020
+ if (value < limit.min || value > limit.max)
25021
+ refuse2(`${field} must be between ${limit.min} and ${limit.max}; this one is ${value}.`);
25022
+ return value;
25023
+ }
25024
+ function readScale(value) {
25025
+ if (!value || typeof value !== "object" || Array.isArray(value))
25026
+ refuse2("assetConfig.scale must be an object of stature, width and head: the proportion profile.");
25027
+ const record2 = value;
25028
+ for (const key of Object.keys(record2)) {
25029
+ if (!["stature", "width", "head"].includes(key))
25030
+ refuse2(`assetConfig.scale.${key} is not a scale knob. Allowed: stature, width, head.`);
25031
+ }
25032
+ const width = {};
25033
+ if (record2.width !== undefined) {
25034
+ if (!record2.width || typeof record2.width !== "object" || Array.isArray(record2.width))
25035
+ refuse2('assetConfig.scale.width must be an object of body parts, for example { "armL": 1.2 }.');
25036
+ for (const [part, knob] of Object.entries(record2.width)) {
25037
+ if (!WIDTH_KNOBS.includes(part))
25038
+ refuse2(`assetConfig.scale.width.${part} is not a body part with a width. Allowed: ${WIDTH_KNOBS.join(", ")}.`);
25039
+ const read = readKnob(`assetConfig.scale.width.${part}`, knob, BODY_SCALE_LIMITS.width);
25040
+ if (read !== undefined)
25041
+ width[part] = read;
25042
+ }
25043
+ }
25044
+ return {
25045
+ stature: readKnob("assetConfig.scale.stature", record2.stature, BODY_SCALE_LIMITS.stature) ?? 1,
25046
+ width,
25047
+ head: readKnob("assetConfig.scale.head", record2.head, BODY_SCALE_LIMITS.head) ?? 1
25048
+ };
25049
+ }
25050
+ function readSlotFor(kind, slot, allowed) {
25051
+ if (!allowed.includes(slot))
25052
+ refuse2(`A ${kind} is worn on the ${allowed.join(" or ")} slot, not ${slot}.`);
25053
+ }
25054
+ async function readSheet(record2, slot) {
25055
+ readSlotFor("sheet", slot, ["outfit"]);
25056
+ refuseUnknownKeys(record2, SHEET_KEYS, "sheet item");
25057
+ const layer = readLayer(record2.layer);
25058
+ const caps = LISTING_ASSET_CAPS.sheet;
25059
+ const image = await readImage("assetConfig.sheet", record2.sheet, caps.maxBytes);
25060
+ if (image.image.width !== caps.width || image.image.height !== caps.height)
25061
+ refuse2(`assetConfig.sheet must be the classic ${caps.width}x${caps.height} template; this one is ${image.image.width}x${image.image.height}.`);
25062
+ return { assetConfig: { sheet: image.url, layer }, assets: [image.digest] };
25063
+ }
25064
+ async function readVariant(record2, slot) {
25065
+ readSlotFor("bodyVariant", slot, ["outfit"]);
25066
+ refuseUnknownKeys(record2, VARIANT_KEYS, "body-variant item");
25067
+ const parts = readVariantParts(record2.parts);
25068
+ const scale = record2.scale === undefined ? undefined : readScale(record2.scale);
25069
+ const caps = LISTING_ASSET_CAPS.bodyVariant;
25070
+ const image = await readImage("assetConfig.variant", record2.variant, caps.maxBytes);
25071
+ if (image.image.width !== caps.width || image.image.height !== caps.height)
25072
+ refuse2(`assetConfig.variant must be the Plupin-native ${caps.width}x${caps.height} grid; this one is ${image.image.width}x${image.image.height}.`);
25073
+ const assetConfig = {
25074
+ variant: image.url,
25075
+ parts,
25076
+ ...scale ? { scale } : {}
25077
+ };
25078
+ return { assetConfig, assets: [image.digest] };
25079
+ }
25080
+ async function readSprite(record2, slot) {
25081
+ readSlotFor("sprite", slot, ["hair", "accessory"]);
25082
+ refuseUnknownKeys(record2, SPRITE_KEYS, "sprite item");
25083
+ const caps = LISTING_ASSET_CAPS.accessory;
25084
+ const image = await readImage("assetConfig.sprite", record2.sprite, caps.maxBytes);
25085
+ if (image.image.width > caps.maxWidth || image.image.height > caps.maxHeight)
25086
+ refuse2(`assetConfig.sprite must be at most ${caps.maxWidth}x${caps.maxHeight}; this one is ${image.image.width}x${image.image.height}.`);
25087
+ return { assetConfig: { sprite: image.url }, assets: [image.digest] };
25088
+ }
25089
+ async function faceStampDigest(rows) {
25090
+ const digest2 = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`plupin-face-v1
25091
+ ${rows.join(`
25092
+ `)}`));
25093
+ return [...new Uint8Array(digest2)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
25094
+ }
25095
+ async function animDigest(anim) {
25096
+ const digest2 = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`plupin-anim-v1
25097
+ ${JSON.stringify(anim)}`));
25098
+ return [...new Uint8Array(digest2)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
25099
+ }
25100
+ function readAnim(value) {
25101
+ const record2 = asObject(value);
25102
+ refuseUnknownKeys(record2, ANIM_KEYS, "assetConfig.anim");
25103
+ const { fps, loop, bones, frames } = record2;
25104
+ if (!Number.isInteger(fps) || fps < 1 || fps > ANIM_CAPS.maxFps)
25105
+ refuse2(`assetConfig.anim.fps must be a whole number from 1 to ${ANIM_CAPS.maxFps}.`);
25106
+ if (typeof loop !== "boolean")
25107
+ refuse2("assetConfig.anim.loop must be true or false.");
25108
+ if (!Array.isArray(bones) || bones.length < 1 || bones.length > ANIM_BONES.length)
25109
+ refuse2(`assetConfig.anim.bones must list 1 to ${ANIM_BONES.length} of: ${ANIM_BONES.join(", ")}.`);
25110
+ bones.forEach((bone, index) => {
25111
+ if (!ANIM_BONES.includes(bone))
25112
+ refuse2(`assetConfig.anim.bones[${index}] "${String(bone)}" is not a bone. Choose from: ${ANIM_BONES.join(", ")}.`);
25113
+ });
25114
+ if (new Set(bones).size !== bones.length)
25115
+ refuse2("assetConfig.anim.bones lists a bone twice.");
25116
+ if (!Array.isArray(frames) || frames.length < 1)
25117
+ refuse2("assetConfig.anim.frames must be a list with at least one frame.");
25118
+ if (frames.length > ANIM_CAPS.maxFrames)
25119
+ refuse2(`assetConfig.anim.frames has ${frames.length} frames; the most is ${ANIM_CAPS.maxFrames}.`);
25120
+ const seconds = frames.length / fps;
25121
+ if (seconds > ANIM_CAPS.maxSeconds)
25122
+ refuse2(`assetConfig.anim runs ${seconds.toFixed(1)} s; the longest is ${ANIM_CAPS.maxSeconds} s. Lower the frame count or raise fps.`);
25123
+ const width = bones.length * 3 + 1;
25124
+ const checked = frames.map((frame, row) => {
25125
+ if (!Array.isArray(frame) || frame.length !== width)
25126
+ refuse2(`assetConfig.anim.frames[${row}] must hold ${width} numbers: x, y, z for each of ${bones.length} bone(s), then lift.`);
25127
+ return frame.map((entry, column) => {
25128
+ if (typeof entry !== "number" || !Number.isFinite(entry))
25129
+ refuse2(`assetConfig.anim.frames[${row}][${column}] must be a finite number.`);
25130
+ const lift = column === width - 1;
25131
+ const [low, high] = lift ? [ANIM_CAPS.minLift, ANIM_CAPS.maxLift] : [-ANIM_CAPS.maxRotation, ANIM_CAPS.maxRotation];
25132
+ if (entry < low || entry > high)
25133
+ refuse2(`assetConfig.anim.frames[${row}][${column}] is ${entry}; ${lift ? "lift" : "a rotation"} must stay within ${low} to ${high}.`);
25134
+ return Math.round(entry * 1000) / 1000;
25135
+ });
25136
+ });
25137
+ const anim = {
25138
+ fps,
25139
+ loop,
25140
+ bones,
25141
+ frames: checked
25142
+ };
25143
+ if (JSON.stringify(anim).length > ANIM_CAPS.maxBytes)
25144
+ refuse2(`assetConfig.anim is larger than ${ANIM_CAPS.maxBytes / 1024} KB. Fewer frames or a lower fps.`);
25145
+ return anim;
25146
+ }
25147
+ async function readEmote(record2) {
25148
+ refuseUnknownKeys(record2, EMOTE_KEYS, "emote");
25149
+ const glyph = readGlyph(record2.glyph);
25150
+ const anim = record2.anim === undefined ? undefined : readAnim(record2.anim);
25151
+ const clip = record2.clip === undefined && anim ? "idle" : readClip(record2.clip);
25152
+ const faceStamp = record2.faceStamp === undefined ? undefined : readFaceStamp(record2.faceStamp);
25153
+ const face = record2.face === undefined && faceStamp ? undefined : readFace(record2.face);
25154
+ const assetConfig = { glyph, clip, ...face ? { face } : {} };
25155
+ if (faceStamp)
25156
+ assetConfig.faceStamp = faceStamp;
25157
+ if (anim)
25158
+ assetConfig.anim = anim;
25159
+ return {
25160
+ assetConfig,
25161
+ assets: [
25162
+ ...faceStamp ? [await faceStampDigest(faceStamp)] : [],
25163
+ ...anim ? [await animDigest(anim)] : []
25164
+ ]
25165
+ };
25166
+ }
25167
+ function readItem(record2, slot) {
25168
+ const present = ITEM_FORMS.filter((form2) => record2[form2] !== undefined);
25169
+ if (present.length === 0)
25170
+ refuse2("assetConfig needs one of: color (a hex colour), sheet (a classic 585x559 shirt or pants PNG), variant (a Plupin-native body-variant sheet) or sprite (an accessory PNG).");
25171
+ if (present.length > 1)
25172
+ throw new Refusal(`assetConfig mixes ${present.join(" and ")}: an item manifest carries one form.`);
25173
+ const form = present[0];
25174
+ if (form === "color") {
25175
+ refuseUnknownKeys(record2, COLOR_KEYS, "item");
25176
+ return Promise.resolve({ assetConfig: { color: readColor(record2.color) }, assets: [] });
25177
+ }
25178
+ if (form === "sheet")
25179
+ return readSheet(record2, slot);
25180
+ if (form === "variant")
25181
+ return readVariant(record2, slot);
25182
+ return readSprite(record2, slot);
25183
+ }
25184
+ async function checkListingManifest(input2) {
25185
+ if (!LISTABLE_SLOTS.includes(input2.slot))
25186
+ return { ok: false, message: `Only ${LISTABLE_SLOTS.join(", ")} can be listed.` };
25187
+ try {
25188
+ const record2 = asObject(input2.assetConfig);
25189
+ return {
25190
+ ok: true,
25191
+ manifest: input2.slot === "emote" ? await readEmote(record2) : await readItem(record2, input2.slot)
25192
+ };
25193
+ } catch (error62) {
25194
+ if (error62 instanceof Refusal)
25195
+ return { ok: false, message: error62.message };
25196
+ throw error62;
25197
+ }
25198
+ }
25199
+ function starterManifest(input2) {
25200
+ const slot = input2.slot ?? "emote";
25201
+ return {
25202
+ id: input2.id,
25203
+ slot,
25204
+ name: input2.name,
25205
+ sigmaPrice: input2.sigmaPrice ?? 0,
25206
+ assetConfig: slot === "emote" ? {
25207
+ glyph: input2.glyph ?? "(\u2267\u25BD\u2266)",
25208
+ face: input2.face ?? "teriak",
25209
+ clip: input2.clip ?? "jump"
25210
+ } : { color: input2.color ?? "#8a5ad8" }
25211
+ };
25212
+ }
25213
+ function paint(pixels, x2, y, width, height, colour) {
25214
+ for (let row = y;row < y + height; row++) {
25215
+ for (let column = x2;column < x2 + width; column++)
25216
+ pixels.set(`${column},${row}`, colour);
25217
+ }
25218
+ }
25219
+ function stamp(rows, left, top, pixels) {
25220
+ for (const [row, line] of rows.entries()) {
25221
+ for (const [column, key] of [...line].entries()) {
25222
+ const colour = FACE_STAMP_PALETTE[key];
25223
+ if (colour)
25224
+ pixels.set(`${left + column},${top + row}`, colour);
25225
+ }
25226
+ }
25227
+ }
25228
+ function drawnFace(assetConfig) {
25229
+ const value = assetConfig.faceStamp;
25230
+ if (!Array.isArray(value) || value.length !== 4)
25231
+ return null;
25232
+ return value.every((row) => typeof row === "string") ? value : null;
25233
+ }
25234
+ function namedFace(assetConfig) {
25235
+ const face = assetConfig.face;
25236
+ if (typeof face !== "string")
25237
+ return null;
25238
+ const rows = NAMED_FACE_STAMPS[face];
25239
+ return rows ?? null;
25240
+ }
25241
+ function escapeXml(value) {
25242
+ return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&apos;");
25243
+ }
25244
+ function asRecord(value) {
25245
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
25246
+ }
25247
+ function itemAssetKindOf(assetConfig) {
25248
+ const record2 = asRecord(assetConfig);
25249
+ for (const kind of Object.keys(ITEM_ASSET_KINDS)) {
25250
+ if (typeof record2[ITEM_ASSET_KINDS[kind]] === "string")
25251
+ return kind;
25252
+ }
25253
+ return null;
25254
+ }
25255
+ function manifestImage(record2, field) {
25256
+ const value = record2[field];
25257
+ if (typeof value !== "string" || !value.startsWith(PNG_DATA_URL))
25258
+ return null;
25259
+ const bytes = decodeBase64(value.slice(PNG_DATA_URL.length));
25260
+ if (!bytes)
25261
+ return null;
25262
+ const decoded = decodePng(bytes);
25263
+ return decoded.ok ? decoded.image : null;
25264
+ }
25265
+ function bodyBoxes(scale) {
25266
+ const torsoWidth = Math.max(2, Math.round(BODY_TORSO_BOX.w * scale.stature * (scale.width.torso ?? 1)));
25267
+ const torsoHeight = Math.max(2, Math.round(BODY_TORSO_BOX.h * scale.stature));
25268
+ const torso = {
25269
+ x: 12 - Math.floor(torsoWidth / 2),
25270
+ y: 22 - torsoHeight,
25271
+ w: torsoWidth,
25272
+ h: torsoHeight
25273
+ };
25274
+ const headSide = Math.max(2, Math.round(BODY_HEAD_BOX.w * scale.stature * scale.head));
25275
+ const headHeight = Math.max(2, Math.round(BODY_HEAD_BOX.h * scale.stature * scale.head));
25276
+ const head = {
25277
+ x: 12 - Math.floor(headSide / 2),
25278
+ y: torso.y - headHeight,
25279
+ w: headSide,
25280
+ h: headHeight
25281
+ };
25282
+ return { torso, head };
25283
+ }
25284
+ function sampleInto(pixels, image, source, dest) {
25285
+ if (dest.w <= 0 || dest.h <= 0)
25286
+ return;
25287
+ for (let y = dest.y;y < dest.y + dest.h; y++) {
25288
+ if (y < 0 || y >= GRID)
25289
+ continue;
25290
+ for (let x2 = dest.x;x2 < dest.x + dest.w; x2++) {
25291
+ if (x2 < 0 || x2 >= GRID)
25292
+ continue;
25293
+ const u = (x2 - dest.x + 0.5) / dest.w;
25294
+ const v = (y - dest.y + 0.5) / dest.h;
25295
+ const sx = Math.min(source.x + source.w - 1, Math.max(source.x, Math.floor(source.x + u * source.w)));
25296
+ const sy = Math.min(source.y + source.h - 1, Math.max(source.y, Math.floor(source.y + v * source.h)));
25297
+ if (sx >= image.width || sy >= image.height)
25298
+ continue;
25299
+ const at = (sy * image.width + sx) * 4;
25300
+ if ((image.data[at + 3] ?? 255) < 128)
25301
+ continue;
25302
+ pixels.set(`${x2},${y}`, hexColour(image, at));
25303
+ }
25304
+ }
25305
+ }
25306
+ function paintArtItem(pixels, assetConfig, kind, slot) {
25307
+ const scale = clampBodyScale(assetConfig.scale && typeof assetConfig.scale === "object" ? assetConfig.scale : undefined);
25308
+ const { torso, head } = bodyBoxes(scale);
25309
+ paint(pixels, torso.x, torso.y, torso.w, torso.h, SKIN);
25310
+ paint(pixels, head.x, head.y, head.w, head.h, SKIN);
25311
+ if (kind === "bodyVariant") {
25312
+ const image = manifestImage(assetConfig, "variant");
25313
+ if (image) {
25314
+ sampleInto(pixels, image, NATIVE_TORSO.front, torso);
25315
+ sampleInto(pixels, image, NATIVE_HEAD.front, head);
25316
+ }
25317
+ return;
25318
+ }
25319
+ if (kind === "sheet") {
25320
+ const image = manifestImage(assetConfig, "sheet");
25321
+ if (image)
25322
+ sampleInto(pixels, image, CLASSIC_TORSO.front, torso);
25323
+ } else {
25324
+ const image = manifestImage(assetConfig, "sprite");
25325
+ if (image) {
25326
+ const band = slot === "hair" ? { x: head.x, y: head.y, w: head.w, h: Math.max(1, Math.floor(head.h * 0.45)) } : { x: torso.x, y: torso.y, w: torso.w, h: Math.max(1, Math.floor(torso.h * 0.5)) };
25327
+ sampleInto(pixels, image, { x: 0, y: 0, w: image.width, h: image.height }, band);
25328
+ }
25329
+ }
25330
+ const face = drawnFace(assetConfig) ?? namedFace(assetConfig) ?? NEUTRAL_FACE;
25331
+ stamp(face, head.x, head.y + Math.max(0, Math.floor((head.h - FACE_STAMP_ROWS) / 2)), pixels);
25332
+ }
25333
+ function renderListingPreview(input2) {
25334
+ const assetConfig = asRecord(input2.assetConfig);
25335
+ const kind = itemAssetKindOf(assetConfig);
25336
+ const colour = typeof assetConfig.color === "string" && COLOR_PATTERN.test(assetConfig.color) ? assetConfig.color.toLowerCase() : BODY;
25337
+ const pixels = new Map;
25338
+ if (kind === "sheet" || kind === "bodyVariant" || kind === "accessory") {
25339
+ paintArtItem(pixels, assetConfig, kind, input2.slot);
25340
+ } else {
25341
+ paint(pixels, 5, 17, 14, 4, input2.slot === "emote" ? BODY : colour);
25342
+ paint(pixels, 7, 4, 10, 12, SKIN);
25343
+ paint(pixels, 7, 3, 10, 1, INK);
25344
+ paint(pixels, 7, 16, 10, 1, INK);
25345
+ paint(pixels, 6, 4, 1, 12, INK);
25346
+ paint(pixels, 17, 4, 1, 12, INK);
25347
+ const face = drawnFace(assetConfig) ?? namedFace(assetConfig) ?? NEUTRAL_FACE;
25348
+ stamp(face, 8, 8, pixels);
25349
+ if (input2.slot === "hair")
25350
+ paint(pixels, 7, 3, 10, 3, colour);
25351
+ if (input2.slot === "accessory")
25352
+ paint(pixels, 7, 13, 10, 1, colour);
25353
+ if (input2.slot === "outfit")
25354
+ paint(pixels, 5, 20, 14, 1, NEUTRAL);
25355
+ }
25356
+ const rects = [];
25357
+ for (let y = 0;y < GRID; y++) {
25358
+ for (let x2 = 0;x2 < GRID; x2++) {
25359
+ const painted = pixels.get(`${x2},${y}`);
25360
+ if (painted)
25361
+ rects.push(`<rect x="${x2}" y="${y}" width="1" height="1" fill="${painted}"/>`);
25362
+ }
25363
+ }
25364
+ let overlay = "";
25365
+ const glyph = assetConfig.glyph;
25366
+ if (input2.slot === "emote" && typeof glyph === "string" && glyph.trim()) {
25367
+ const text = glyph.trim();
25368
+ const size = Math.min(3.6, (GRID - 4) / Math.max(4, [...text].length));
25369
+ overlay = `<text x="${GRID / 2}" y="${GRID - 1}" text-anchor="middle" font-family="monospace" font-size="${size.toFixed(2)}" fill="#ffffff" stroke="${INK}" stroke-width="0.4">${escapeXml(text)}</text>`;
25370
+ }
25371
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${GRID} ${GRID}" width="${GRID * SCALE}" height="${GRID * SCALE}" shape-rendering="crispEdges" role="img" aria-label="${escapeXml(input2.name)}"><title>${escapeXml(input2.name)}</title>${rects.join("")}${overlay}</svg>`;
25372
+ }
25373
+ function previewDataUrl(svg) {
25374
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
25375
+ }
25376
+ var LISTABLE_SLOTS, EMOTE_KEYS, ANIM_KEYS, ANIM_CAPS, ANIM_BONES, COLOR_KEYS, SHEET_KEYS, VARIANT_KEYS, SPRITE_KEYS, ITEM_ASSET_KINDS, LISTING_ASSET_CAPS, VARIANT_PARTS, VARIANT_FACES, FACE_STAMP_ROWS = 4, FACE_STAMP_COLUMNS = 8, MAX_GLYPH_CHARACTERS = 20, COLOR_PATTERN, PNG_DATA_URL = "data:image/png;base64,", FACE_PALETTE_KEYS, Refusal, WIDTH_KNOBS, ITEM_FORMS, GRID = 24, SCALE = 8, INK = "#161923", SKIN = "#f0b184", BODY = "#2f6fed", NEUTRAL = "#8b93a8", NEUTRAL_FACE, BODY_TORSO_BOX, BODY_HEAD_BOX, hexColour = (image, at) => `#${[0, 1, 2].map((offset) => (image.data[at + offset] ?? 0).toString(16).padStart(2, "0")).join("")}`;
25377
+ var init_listing = __esm(() => {
25378
+ init_faces();
25379
+ init_png();
25380
+ init_pose();
25381
+ init_skin();
25382
+ init_skin_native();
25383
+ LISTABLE_SLOTS = ["outfit", "hair", "accessory", "emote"];
25384
+ EMOTE_KEYS = ["glyph", "face", "clip", "faceStamp", "anim"];
25385
+ ANIM_KEYS = ["fps", "loop", "bones", "frames"];
25386
+ ANIM_CAPS = {
25387
+ maxFps: 30,
25388
+ maxFrames: 240,
25389
+ maxSeconds: 8,
25390
+ maxRotation: 3.2,
25391
+ minLift: 0,
25392
+ maxLift: 3,
25393
+ maxBytes: 32 * 1024
25394
+ };
25395
+ ANIM_BONES = ["head", "torso", "armL", "armR", "legL", "legR"];
25396
+ COLOR_KEYS = ["color"];
25397
+ SHEET_KEYS = ["sheet", "layer"];
25398
+ VARIANT_KEYS = ["variant", "parts", "scale"];
25399
+ SPRITE_KEYS = ["sprite"];
25400
+ ITEM_ASSET_KINDS = {
25401
+ color: "color",
25402
+ sheet: "sheet",
25403
+ bodyVariant: "variant",
25404
+ accessory: "sprite"
25405
+ };
25406
+ LISTING_ASSET_CAPS = {
25407
+ sheet: { width: CLASSIC_WIDTH, height: CLASSIC_HEIGHT, maxBytes: 160 * 1024 },
25408
+ bodyVariant: {
25409
+ width: NATIVE_SHEET_CAPS.width,
25410
+ height: NATIVE_SHEET_CAPS.height,
25411
+ maxBytes: NATIVE_SHEET_CAPS.maxBytes
25412
+ },
25413
+ accessory: { maxWidth: 64, maxHeight: 64, maxBytes: 8 * 1024 }
25414
+ };
25415
+ VARIANT_PARTS = ["torso", "head", "armL", "armR", "legL", "legR"];
25416
+ VARIANT_FACES = ["front", "back", "left", "right", "up", "down"];
25417
+ COLOR_PATTERN = /^#[0-9a-f]{6}$/i;
25418
+ FACE_PALETTE_KEYS = Object.keys(FACE_STAMP_PALETTE);
25419
+ Refusal = class Refusal extends Error {
25420
+ };
25421
+ WIDTH_KNOBS = ["torso", "armL", "armR", "legL", "legR"];
25422
+ ITEM_FORMS = ["color", "sheet", "variant", "sprite"];
25423
+ NEUTRAL_FACE = [".e....e.", "........", "...mm...", "........"];
25424
+ BODY_TORSO_BOX = { x: 6, y: 14, w: 12, h: 8 };
25425
+ BODY_HEAD_BOX = { x: 8, y: 5, w: 8, h: 9 };
25426
+ });
25427
+
25428
+ // src/emote.ts
25429
+ var exports_emote = {};
25430
+ __export(exports_emote, {
25431
+ slugOf: () => slugOf,
25432
+ readEmoteManifest: () => readEmoteManifest,
25433
+ pushEmote: () => pushEmote,
25434
+ previewEmote: () => previewEmote,
25435
+ newEmote: () => newEmote,
25436
+ importAnimation: () => importAnimation,
25437
+ EMOTE_SLOTS: () => EMOTE_SLOTS,
25438
+ EMOTE_MANIFEST: () => EMOTE_MANIFEST,
25439
+ EMOTE_ASSETS: () => EMOTE_ASSETS
25440
+ });
25441
+ import { mkdir as mkdir3, readFile as readFile2, writeFile as writeFile4 } from "fs/promises";
25442
+ import { basename, dirname as dirname4, join as join7, resolve as resolve5 } from "path";
25443
+ function slugOf(value) {
25444
+ const slug = value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
25445
+ return slug.length >= 3 ? slug : "emote-baru";
25446
+ }
25447
+ function manifestPath(dir) {
25448
+ return join7(resolve5(dir), EMOTE_MANIFEST);
25449
+ }
25450
+ async function writeManifest(path2, manifest) {
25451
+ await writeFile4(path2, `${JSON.stringify(manifest, null, 2)}
25452
+ `);
25453
+ }
25454
+ async function newEmote(options) {
25455
+ const dir = resolve5(options.dir);
25456
+ const path2 = manifestPath(dir);
25457
+ if (await Bun.file(path2).exists())
25458
+ throw new CliError(1, `${path2} already exists \u2014 edit it, or delete it to scaffold a new listing`);
25459
+ const draft = starterManifest({
25460
+ id: options.id ?? slugOf(basename(dir)),
25461
+ name: options.name ?? "Emote Baru",
25462
+ ...options.slot === undefined ? {} : { slot: options.slot },
25463
+ ...options.sigmaPrice === undefined ? {} : { sigmaPrice: options.sigmaPrice },
25464
+ ...options.glyph === undefined ? {} : { glyph: options.glyph },
25465
+ ...options.face === undefined ? {} : { face: options.face },
25466
+ ...options.clip === undefined ? {} : { clip: options.clip },
25467
+ ...options.color === undefined ? {} : { color: options.color }
25468
+ });
25469
+ const checked = await checkListingManifest({ slot: draft.slot, assetConfig: draft.assetConfig });
25470
+ if (!checked.ok)
25471
+ throw new CliError(1, checked.message);
25472
+ const manifest = { ...draft, assetConfig: checked.manifest.assetConfig };
25473
+ await mkdir3(dir, { recursive: true });
25474
+ await mkdir3(join7(dir, EMOTE_ASSETS), { recursive: true });
25475
+ await writeManifest(path2, manifest);
25476
+ return { path: path2, assets: join7(dir, EMOTE_ASSETS), manifest };
25477
+ }
25478
+ async function readEmoteManifest(dir) {
25479
+ const path2 = manifestPath(dir);
25480
+ if (!await Bun.file(path2).exists())
25481
+ throw new CliError(1, `no ${EMOTE_MANIFEST} in ${resolve5(dir)} \u2014 run: plupin emote new`);
25482
+ let parsed;
25483
+ try {
25484
+ parsed = JSON.parse(await readFile2(path2, "utf8"));
25485
+ } catch (error62) {
25486
+ throw new CliError(1, `${path2} is not valid JSON: ${error62.message}`);
25487
+ }
25488
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
25489
+ throw new CliError(1, `${path2} must be a JSON object`);
25490
+ const record2 = parsed;
25491
+ for (const key of ["id", "slot", "name", "sigmaPrice"]) {
25492
+ if (record2[key] === undefined)
25493
+ throw new CliError(1, `${path2} is missing "${key}"`);
25494
+ }
25495
+ const slot = record2.slot;
25496
+ if (!EMOTE_SLOTS.includes(slot))
25497
+ throw new CliError(1, `${path2}: slot must be one of ${EMOTE_SLOTS.join(", ")}`);
25498
+ const checked = await checkListingManifest({ slot, assetConfig: record2.assetConfig });
25499
+ if (!checked.ok)
25500
+ throw new CliError(1, `${path2}: ${checked.message}`);
25501
+ return {
25502
+ id: String(record2.id),
25503
+ slot,
25504
+ name: String(record2.name),
25505
+ sigmaPrice: Number(record2.sigmaPrice),
25506
+ assetConfig: checked.manifest.assetConfig
25507
+ };
25508
+ }
25509
+ async function importAnimation(options) {
25510
+ const dir = resolve5(options.dir);
25511
+ const path2 = manifestPath(dir);
25512
+ let source;
25513
+ try {
25514
+ source = JSON.parse(await readFile2(resolve5(options.file), "utf8"));
25515
+ } catch (error62) {
25516
+ throw new CliError(1, `${options.file} is not readable JSON: ${error62.message}`);
25517
+ }
25518
+ if (!source || typeof source !== "object" || Array.isArray(source))
25519
+ throw new CliError(1, `${options.file} must be a JSON object`);
25520
+ const record2 = source;
25521
+ let anim;
25522
+ if (Array.isArray(record2.frames))
25523
+ anim = record2;
25524
+ else {
25525
+ try {
25526
+ anim = bakeToCustomClip(record2, options.fps ? { fps: options.fps } : {});
25527
+ } catch (error62) {
25528
+ if (error62 instanceof BakeError)
25529
+ throw new CliError(1, `${options.file}: ${error62.message}`);
25530
+ throw error62;
25531
+ }
25532
+ }
25533
+ if (!await Bun.file(path2).exists())
25534
+ await newEmote({
25535
+ dir,
25536
+ name: options.name ?? basename(options.file).replace(/\.json$/i, "").replace(/[-_]+/g, " ")
25537
+ });
25538
+ const existing = await readEmoteManifest(dir);
25539
+ if (existing.slot !== "emote")
25540
+ throw new CliError(1, `${path2} is a ${existing.slot}: only an emote can carry an animation`);
25541
+ const { clip: _fallback, ...rest } = existing.assetConfig;
25542
+ const checked = await checkListingManifest({ slot: "emote", assetConfig: { ...rest, anim } });
25543
+ if (!checked.ok)
25544
+ throw new CliError(1, checked.message);
25545
+ const manifest = {
25546
+ ...existing,
25547
+ assetConfig: checked.manifest.assetConfig
25548
+ };
25549
+ await writeManifest(path2, manifest);
25550
+ const clip = checked.manifest.assetConfig;
25551
+ const frames = clip.anim?.frames.length ?? 0;
25552
+ return { path: path2, manifest, frames, seconds: frames / (clip.anim?.fps || 1) };
25553
+ }
25554
+ async function previewEmote(options) {
25555
+ const dir = resolve5(options.dir);
25556
+ const manifest = await readEmoteManifest(dir);
25557
+ const svg = renderListingPreview({
25558
+ slot: manifest.slot,
25559
+ name: manifest.name,
25560
+ assetConfig: manifest.assetConfig
25561
+ });
25562
+ const path2 = options.out ? resolve5(options.out) : join7(dir, ".plupin", "emote-preview.svg");
25563
+ await mkdir3(dirname4(path2), { recursive: true });
25564
+ await writeFile4(path2, svg);
25565
+ return { manifest, path: path2, svg, dataUrl: previewDataUrl(svg) };
25566
+ }
25567
+ async function pushEmote(options) {
25568
+ const dir = resolve5(options.dir);
25569
+ const manifest = await readEmoteManifest(dir);
25570
+ const local = await previewEmote({ dir });
25571
+ const response = await call(options, "/api/items", {
25572
+ method: "POST",
25573
+ headers: { "Content-Type": "application/json" },
25574
+ body: JSON.stringify(manifest)
25575
+ });
25576
+ if (!response.ok)
25577
+ throw await refuse(response, "emote push");
25578
+ const pushed = await response.json();
25579
+ if (pushed.previewUrl !== local.dataUrl)
25580
+ throw new CliError(3, "the platform rendered a different preview than this machine \u2014 the local preview would have been a lie, so nothing was reported as published. Update the CLI (@plupin/character) and try again");
25581
+ return { ...pushed, previewPath: local.path };
25582
+ }
25583
+ var EMOTE_MANIFEST = "emote.json", EMOTE_ASSETS = "assets", EMOTE_SLOTS;
25584
+ var init_emote = __esm(() => {
25585
+ init_clip_bake();
25586
+ init_listing();
25587
+ init_credentials();
25588
+ init_deploy();
25589
+ EMOTE_SLOTS = ["emote", "outfit", "hair", "accessory"];
25590
+ });
25591
+
25592
+ // src/connect.ts
25593
+ var exports_connect = {};
25594
+ __export(exports_connect, {
25595
+ writeConfig: () => writeConfig,
25596
+ verifyHosted: () => verifyHosted,
25597
+ upsertTomlTable: () => upsertTomlTable,
25598
+ tomlString: () => tomlString,
25599
+ tableOf: () => tableOf,
25600
+ stdioEntry: () => stdioEntry,
25601
+ readTomlConfig: () => readTomlConfig,
25602
+ readJsonConfig: () => readJsonConfig,
25603
+ ownsTable: () => ownsTable,
25604
+ mergeClaudeConfig: () => mergeClaudeConfig,
25605
+ isPlainObject: () => isPlainObject2,
25606
+ hostedUrl: () => hostedUrl,
25607
+ connect: () => connect,
25608
+ codexStdioBlock: () => codexStdioBlock,
25609
+ codexHostedBlock: () => codexHostedBlock,
25610
+ codexConfigPath: () => codexConfigPath,
25611
+ codexBlock: () => codexBlock,
25612
+ claudeConfigPath: () => claudeConfigPath,
25613
+ authorization: () => authorization,
25614
+ VERIFY_TIMEOUT_MS: () => VERIFY_TIMEOUT_MS,
25615
+ STDIO_SERVER: () => STDIO_SERVER,
25616
+ STDIO_COMMAND: () => STDIO_COMMAND,
25617
+ STDIO_ARGS: () => STDIO_ARGS,
25618
+ HOSTED_SERVER: () => HOSTED_SERVER,
25619
+ CONNECT_TARGETS: () => CONNECT_TARGETS,
25620
+ CONFIG_MODE: () => CONFIG_MODE
25621
+ });
25622
+ import { chmod as chmod2, mkdir as mkdir4, rename, stat as stat4, writeFile as writeFile5 } from "fs/promises";
25623
+ import { homedir as homedir2 } from "os";
25624
+ import { dirname as dirname5, join as join8 } from "path";
25625
+ function isPlainObject2(value) {
25626
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25627
+ }
25628
+ function claudeConfigPath(env = process.env) {
25629
+ const dir = env.CLAUDE_CONFIG_DIR?.trim();
25630
+ return dir ? join8(dir, ".claude.json") : join8(homedir2(), ".claude.json");
25631
+ }
25632
+ function codexConfigPath(env = process.env) {
25633
+ const home = env.CODEX_HOME?.trim();
25634
+ return home ? join8(home, "config.toml") : join8(homedir2(), ".codex", "config.toml");
25635
+ }
25636
+ function stdioEntry() {
25637
+ return { command: STDIO_COMMAND, args: [...STDIO_ARGS] };
25638
+ }
25639
+ function hostedUrl(apiUrl) {
25640
+ return `${apiUrl.replace(/\/+$/, "")}/mcp`;
25641
+ }
25642
+ function authorization(token) {
25643
+ return `Bearer ${token}`;
25644
+ }
25645
+ function mergeClaudeConfig(existing, input2) {
25646
+ const root = isPlainObject2(existing) ? existing : {};
25647
+ const servers = isPlainObject2(root.mcpServers) ? root.mcpServers : {};
25648
+ const next = {
25649
+ ...servers,
25650
+ [STDIO_SERVER]: { type: "stdio", ...stdioEntry() }
25651
+ };
25652
+ if (input2.token) {
25653
+ next[HOSTED_SERVER] = {
25654
+ type: "http",
25655
+ url: hostedUrl(input2.apiUrl),
25656
+ headers: { Authorization: authorization(input2.token) }
25657
+ };
25658
+ }
25659
+ return { ...root, mcpServers: next };
25660
+ }
25661
+ function tomlString(value) {
25662
+ return JSON.stringify(value);
25663
+ }
25664
+ function codexBlock(name, lines) {
25665
+ return [`[mcp_servers.${name}]`, ...lines].join(`
25666
+ `);
25667
+ }
25668
+ function codexStdioBlock() {
25669
+ return codexBlock(STDIO_SERVER, [
25670
+ `command = ${tomlString(STDIO_COMMAND)}`,
25671
+ `args = [${STDIO_ARGS.map(tomlString).join(", ")}]`
25672
+ ]);
25673
+ }
25674
+ function codexHostedBlock(apiUrl, token) {
25675
+ return codexBlock(HOSTED_SERVER, [
25676
+ `url = ${tomlString(hostedUrl(apiUrl))}`,
25677
+ `http_headers = { Authorization = ${tomlString(authorization(token))} }`
25678
+ ]);
25679
+ }
25680
+ function tableOf(line) {
25681
+ const match = TABLE_HEADER.exec(line);
25682
+ return match?.[1]?.trim() ?? null;
25683
+ }
25684
+ function ownsTable(header, table) {
25685
+ return header === table || header.startsWith(`${table}.`);
25686
+ }
25687
+ function upsertTomlTable(text, table, block) {
25688
+ const lines = text.split(`
25689
+ `);
25690
+ const rendered = block.replace(/\n+$/, "").split(`
25691
+ `);
25692
+ const owned = new Set;
25693
+ let insertAt = null;
25694
+ for (let index = 0;index < lines.length; index += 1) {
25695
+ const header = tableOf(lines[index]);
25696
+ if (header === null || !ownsTable(header, table))
25697
+ continue;
25698
+ if (insertAt === null)
25699
+ insertAt = index;
25700
+ let end = lines.length;
25701
+ for (let next = index + 1;next < lines.length; next += 1) {
25702
+ const later = tableOf(lines[next]);
25703
+ if (later !== null && !ownsTable(later, table)) {
25704
+ end = next;
25705
+ break;
25706
+ }
25707
+ }
25708
+ for (let line = index;line < end; line += 1)
25709
+ owned.add(line);
25710
+ }
25711
+ if (insertAt === null) {
25712
+ const base = text.replace(/\s*$/, "");
25713
+ return `${base}${base ? `
25714
+
25715
+ ` : ""}${rendered.join(`
25716
+ `)}
25717
+ `;
25718
+ }
25719
+ const kept = [];
25720
+ let prefix = 0;
25721
+ for (let index = 0;index < lines.length; index += 1) {
25722
+ if (owned.has(index))
25723
+ continue;
25724
+ if (index < insertAt)
25725
+ prefix += 1;
25726
+ kept.push(lines[index]);
25727
+ }
25728
+ const before = kept.slice(0, prefix);
25729
+ while (before.length > 0 && before[before.length - 1].trim() === "")
25730
+ before.pop();
25731
+ const after = kept.slice(prefix);
25732
+ while (after.length > 0 && after[0].trim() === "")
25733
+ after.shift();
25734
+ const out = [...before];
25735
+ if (out.length > 0)
25736
+ out.push("");
25737
+ out.push(...rendered);
25738
+ if (after.length > 0) {
25739
+ out.push("");
25740
+ out.push(...after);
25741
+ }
25742
+ return `${out.join(`
25743
+ `).replace(/\s*$/, "")}
25744
+ `;
25745
+ }
25746
+ async function readJsonConfig(path2) {
25747
+ const file2 = Bun.file(path2);
25748
+ if (!await file2.exists())
25749
+ return {};
25750
+ const text = await file2.text();
25751
+ if (text.trim() === "")
25752
+ return {};
25753
+ try {
25754
+ return JSON.parse(text);
25755
+ } catch (error62) {
25756
+ throw new CliError(1, `${path2} is not valid JSON (${error62 instanceof Error ? error62.message : String(error62)}) \u2014 fix it by hand, nothing was written`);
25757
+ }
25758
+ }
25759
+ async function readTomlConfig(path2) {
25760
+ const file2 = Bun.file(path2);
25761
+ return await file2.exists() ? file2.text() : "";
25762
+ }
25763
+ async function writeConfig(path2, body) {
25764
+ await mkdir4(dirname5(path2), { recursive: true, mode: 448 });
25765
+ const temp = `${path2}.plupin-connect.tmp`;
25766
+ await writeFile5(temp, body, { mode: CONFIG_MODE });
25767
+ await rename(temp, path2);
25768
+ await chmod2(path2, CONFIG_MODE);
25769
+ return (await stat4(path2)).mode & 511;
25770
+ }
25771
+ async function verifyHosted(apiUrl, token) {
25772
+ const headers = {
25773
+ "content-type": "application/json",
25774
+ accept: "application/json, text/event-stream",
25775
+ authorization: authorization(token)
25776
+ };
25777
+ const post = async (payload) => fetch(hostedUrl(apiUrl), {
25778
+ method: "POST",
25779
+ headers,
25780
+ body: JSON.stringify(payload),
25781
+ signal: AbortSignal.timeout(VERIFY_TIMEOUT_MS)
25782
+ });
25783
+ const read = async (response) => {
25784
+ const text = await response.text();
25785
+ if (response.headers.get("content-type")?.includes("text/event-stream")) {
25786
+ const data = text.split(`
25787
+ `).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim()).join(`
25788
+ `);
25789
+ try {
25790
+ return JSON.parse(data);
25791
+ } catch {
25792
+ return null;
25793
+ }
25794
+ }
25795
+ try {
25796
+ return JSON.parse(text);
25797
+ } catch {
25798
+ return null;
25799
+ }
25800
+ };
25801
+ try {
25802
+ const init = await post({
25803
+ jsonrpc: "2.0",
25804
+ id: 1,
25805
+ method: "initialize",
25806
+ params: {
25807
+ protocolVersion: "2025-06-18",
25808
+ capabilities: {},
25809
+ clientInfo: { name: "plupin-connect", version: "1" }
25810
+ }
25811
+ });
25812
+ if (!init.ok)
25813
+ return { status: init.status, tools: null, error: await errorLine(init) };
25814
+ const list = await post({ jsonrpc: "2.0", id: 2, method: "tools/list", params: {} });
25815
+ if (!list.ok)
25816
+ return { status: list.status, tools: null, error: await errorLine(list) };
25817
+ const body = await read(list);
25818
+ const result = isPlainObject2(body?.result) ? body?.result : null;
25819
+ const tools = Array.isArray(result?.tools) ? result.tools.map((tool) => isPlainObject2(tool) ? tool.name : null).filter((name) => typeof name === "string") : [];
25820
+ return { status: list.status, tools, error: null };
25821
+ } catch (error62) {
25822
+ const message = error62 instanceof Error ? error62.message : String(error62);
25823
+ return { status: null, tools: null, error: message.replace(token, "***") };
25824
+ }
25825
+ }
25826
+ async function errorLine(response) {
25827
+ const challenge = response.headers.get("www-authenticate");
25828
+ const body = (await response.text()).slice(0, 200).replace(/\s+/g, " ").trim();
25829
+ const detail = challenge ? ` (${challenge.replace(/resource_metadata="[^"]*"/, "")})` : "";
25830
+ return `${response.status}${detail}${body ? `: ${body}` : ""}`;
25831
+ }
25832
+ async function connect(target, input2) {
25833
+ const env = input2.env ?? process.env;
25834
+ const verification = input2.token && input2.verify !== false ? await verifyHosted(input2.apiUrl, input2.token) : { status: null, tools: null, error: null };
25835
+ if (target === "claude") {
25836
+ const path3 = claudeConfigPath(env);
25837
+ const merged = mergeClaudeConfig(await readJsonConfig(path3), input2);
25838
+ const body = `${JSON.stringify(merged, null, 2)}`;
25839
+ const mode2 = await writeConfig(path3, body);
25840
+ return {
25841
+ body,
25842
+ receipt: {
25843
+ target,
25844
+ path: path3,
25845
+ mode: mode2.toString(8).padStart(3, "0"),
25846
+ servers: input2.token ? [STDIO_SERVER, HOSTED_SERVER] : [STDIO_SERVER],
25847
+ hosted: Boolean(input2.token),
25848
+ verifyStatus: verification.status,
25849
+ verifyTools: verification.tools,
25850
+ verifyError: verification.error
25851
+ }
25852
+ };
25853
+ }
25854
+ const path2 = codexConfigPath(env);
25855
+ const original = await readTomlConfig(path2);
25856
+ let text = upsertTomlTable(original, `mcp_servers.${STDIO_SERVER}`, codexStdioBlock());
25857
+ if (input2.token)
25858
+ text = upsertTomlTable(text, `mcp_servers.${HOSTED_SERVER}`, codexHostedBlock(input2.apiUrl, input2.token));
25859
+ const mode = await writeConfig(path2, text);
25860
+ return {
25861
+ body: text,
25862
+ receipt: {
25863
+ target,
25864
+ path: path2,
25865
+ mode: mode.toString(8).padStart(3, "0"),
25866
+ servers: input2.token ? [STDIO_SERVER, HOSTED_SERVER] : [STDIO_SERVER],
25867
+ hosted: Boolean(input2.token),
25868
+ verifyStatus: verification.status,
25869
+ verifyTools: verification.tools,
25870
+ verifyError: verification.error
25871
+ }
25872
+ };
25873
+ }
25874
+ var CONNECT_TARGETS, STDIO_SERVER = "plupin", HOSTED_SERVER = "plupin-hosted", STDIO_COMMAND = "bunx", STDIO_ARGS, CONFIG_MODE = 384, VERIFY_TIMEOUT_MS = 8000, TABLE_HEADER;
25875
+ var init_connect = __esm(() => {
25876
+ init_credentials();
25877
+ CONNECT_TARGETS = ["claude", "codex"];
25878
+ STDIO_ARGS = ["-y", "@plupin/cli", "mcp"];
25879
+ TABLE_HEADER = /^[ \t]*\[\[?([^\]]+)\]\]?[ \t]*(?:#.*)?$/;
25880
+ });
25881
+
23802
25882
  // src/mcp.ts
23803
25883
  var exports_mcp = {};
23804
25884
  __export(exports_mcp, {
23805
25885
  serveMcp: () => serveMcp
23806
25886
  });
23807
- import { resolve as resolve5 } from "path";
25887
+ import { resolve as resolve6 } from "path";
23808
25888
  function serverFor(id) {
23809
25889
  const found = id ? running.get(id) : last;
23810
25890
  if (!found)
@@ -23839,7 +25919,7 @@ async function handle(message) {
23839
25919
  return reply(id, {
23840
25920
  protocolVersion: PROTOCOL_VERSION,
23841
25921
  capabilities: { tools: {} },
23842
- serverInfo: { name: "plupin", version: "0.1.0" }
25922
+ serverInfo: { name: "plupin", version: "0.2.0" }
23843
25923
  });
23844
25924
  }
23845
25925
  if (method === "notifications/initialized" || method === "initialized")
@@ -23927,7 +26007,7 @@ var init_mcp = __esm(() => {
23927
26007
  properties: { dir: { type: "string", description: "build directory, default ./dist" } }
23928
26008
  },
23929
26009
  async run(args) {
23930
- const dir = resolve5(String(args.dir ?? "dist"));
26010
+ const dir = resolve6(String(args.dir ?? "dist"));
23931
26011
  const manifest = await readManifest(dir);
23932
26012
  return JSON.stringify({ ok: true, dir, manifest }, null, 2);
23933
26013
  }
@@ -23943,7 +26023,7 @@ var init_mcp = __esm(() => {
23943
26023
  }
23944
26024
  },
23945
26025
  async run(args) {
23946
- const dir = resolve5(String(args.dir ?? "dist"));
26026
+ const dir = resolve6(String(args.dir ?? "dist"));
23947
26027
  const manifest = await readManifest(dir);
23948
26028
  const key = `${manifest.id}:${dir}`;
23949
26029
  const existing = running.get(key);
@@ -24009,7 +26089,7 @@ var init_mcp = __esm(() => {
24009
26089
 
24010
26090
  // src/bin.ts
24011
26091
  init_credentials();
24012
- import { resolve as resolve6 } from "path";
26092
+ import { resolve as resolve7 } from "path";
24013
26093
 
24014
26094
  // src/docs.ts
24015
26095
  init_agent_docs();
@@ -24053,6 +26133,10 @@ function jwtPayload(token) {
24053
26133
  // src/bin.ts
24054
26134
  var USAGE = `plupin dev [dir] [--port 8787] [--seed <n>] [--ledger] [--receipt-url <url>]
24055
26135
  plupin create [dir] --title <t> [--visibility public|restricted|draft] [--engine 2d|3d] [--authority host|server]
26136
+ plupin emote new [dir] [--id <id>] [--name <n>] [--slot emote|outfit|hair|accessory] [--price <n>]
26137
+ plupin emote import <clip.json> [dir] [--fps <n>]
26138
+ plupin emote preview [dir] [--out <file>]
26139
+ plupin emote push [dir] [--api <url>]
24056
26140
  plupin up [dir] [--dry-run] [--skip-checks] [--api <url>]
24057
26141
  plupin deploy [dir] [--dry-run] [--api <url>]
24058
26142
  plupin deploy --rollback <bundleRef> [--api <url>]
@@ -24060,6 +26144,8 @@ plupin status [dir] [--game <id>] [--api <url>]
24060
26144
  plupin purchases key [dir] [--game <id>] [--api <url>] issue or replace the game's server key
24061
26145
  plupin login [--token <token>|--token -] [--api <url>]
24062
26146
  plupin login --dev [--api <url>]
26147
+ plupin connect claude [--api <url>]
26148
+ plupin connect codex [--api <url>]
24063
26149
  plupin mcp stdio MCP server for an AI coding assistant
24064
26150
  plupin docs [topic] this documentation, printed from the same source the site renders
24065
26151
 
@@ -24077,6 +26163,10 @@ Serves a built game and hosts its room on the same origin, the way production do
24077
26163
  --authority must agree with plupin.json: the manifest decides who simulates (create)
24078
26164
  --dry-run up: run the checks, print the revision and the URL, publish nothing (up)
24079
26165
  --skip-checks up: publish without measuring the build first (up)
26166
+ --id the listing id the shop and the queue use (emote new, default: the folder name)
26167
+ --slot emote (played) or outfit/hair/accessory (worn); an emote is the default
26168
+ --price 0 for a giveaway, otherwise Sigma in the shop (emote new, default 0)
26169
+ --out where the preview SVG lands (emote preview, default <dir>/.plupin/emote-preview.svg)
24080
26170
 
24081
26171
  The game id, engine and authority come from plupin.json, never from a flag.
24082
26172
 
@@ -24095,9 +26185,17 @@ both fingerprints printed; a status code is never treated as a deploy. Point it
24095
26185
  the URL is <game>.localhost:3001; the check is the same code either way.
24096
26186
  \`plupin login --dev\` signs in as the creator \`bun run db:seed\` created (dev@plupin.local).
24097
26187
 
26188
+ \`plupin connect claude\` and \`plupin connect codex\` write the MCP config that agent CLI already reads:
26189
+ the local stdio server (\`bunx -y @plupin/cli mcp\`) and the hosted surface (\`<api>/mcp\`) with the
26190
+ token \`plupin login\` stored, so emote_push works without hand-editing a file. It writes the
26191
+ user-level config (\`~/.claude.json\`, \`~/.codex/config.toml\`) rather than a project one, because the
26192
+ hosted entry carries a token and a project file is a file that gets committed. The token is written
26193
+ into the config, mode 600, and never printed.
26194
+
24098
26195
  Exit codes: 0 ok, 1 invalid plupin.json or arguments, 2 not signed in, 3 the platform refused,
24099
26196
  4 the API could not be reached, 5 up refused a build that failed its checks.`;
24100
26197
  var VALUE_FLAGS = new Set([
26198
+ "--fps",
24101
26199
  "--port",
24102
26200
  "--manifest",
24103
26201
  "--seed",
@@ -24112,7 +26210,16 @@ var VALUE_FLAGS = new Set([
24112
26210
  "--email",
24113
26211
  "--password",
24114
26212
  "--game-origin",
24115
- "--receipt-url"
26213
+ "--receipt-url",
26214
+ "--id",
26215
+ "--name",
26216
+ "--slot",
26217
+ "--price",
26218
+ "--glyph",
26219
+ "--face",
26220
+ "--clip",
26221
+ "--color",
26222
+ "--out"
24116
26223
  ]);
24117
26224
  function flag(args, name) {
24118
26225
  const index = args.indexOf(name);
@@ -24121,6 +26228,19 @@ function flag(args, name) {
24121
26228
  const value = args[index + 1];
24122
26229
  return value === undefined || value.startsWith("--") ? undefined : value;
24123
26230
  }
26231
+ function positionals(args) {
26232
+ const found = [];
26233
+ for (let index = 0;index < args.length; index += 1) {
26234
+ const value = args[index];
26235
+ if (value.startsWith("--")) {
26236
+ if (VALUE_FLAGS.has(value))
26237
+ index += 1;
26238
+ continue;
26239
+ }
26240
+ found.push(value);
26241
+ }
26242
+ return found;
26243
+ }
24124
26244
  function positional(args) {
24125
26245
  for (let index = 0;index < args.length; index += 1) {
24126
26246
  const value = args[index];
@@ -24226,7 +26346,7 @@ async function login(args) {
24226
26346
  async function createCommand(args) {
24227
26347
  const { readManifest: readManifest2 } = await Promise.resolve().then(() => (init_dev(), exports_dev));
24228
26348
  const { CREATE_ENGINES: CREATE_ENGINES2, CREATE_VISIBILITIES: CREATE_VISIBILITIES2, create: create2 } = await Promise.resolve().then(() => (init_create(), exports_create));
24229
- const dir = resolve6(positional(args) ?? "dist");
26349
+ const dir = resolve7(positional(args) ?? "dist");
24230
26350
  const manifest = await readManifest2(dir);
24231
26351
  const title = flag(args, "--title");
24232
26352
  if (!title)
@@ -24257,7 +26377,7 @@ async function upCommand(args) {
24257
26377
  const { CREATE_ENGINES: CREATE_ENGINES2, CREATE_VISIBILITIES: CREATE_VISIBILITIES2 } = await Promise.resolve().then(() => (init_create(), exports_create));
24258
26378
  const { localGameOrigin: localGameOrigin2 } = await Promise.resolve().then(() => (init_deploy(), exports_deploy));
24259
26379
  const { up: up2 } = await Promise.resolve().then(() => (init_up(), exports_up));
24260
- const dir = resolve6(positional(args) ?? "dist");
26380
+ const dir = resolve7(positional(args) ?? "dist");
24261
26381
  const manifest = await readManifest2(dir);
24262
26382
  const visibility = oneOf("--visibility", flag(args, "--visibility"), CREATE_VISIBILITIES2, "public");
24263
26383
  const engineFlag = flag(args, "--engine");
@@ -24299,7 +26419,7 @@ async function deployCommand(args) {
24299
26419
  console.log(` url ${result2.url}`);
24300
26420
  return;
24301
26421
  }
24302
- const dir = resolve6(positional(args) ?? "dist");
26422
+ const dir = resolve7(positional(args) ?? "dist");
24303
26423
  const manifest = await readManifest2(dir);
24304
26424
  const result = await deploy2({
24305
26425
  ...api2,
@@ -24320,7 +26440,7 @@ async function statusCommand(args) {
24320
26440
  const { readManifest: readManifest2 } = await Promise.resolve().then(() => (init_dev(), exports_dev));
24321
26441
  const { readStatus: readStatus2 } = await Promise.resolve().then(() => (init_deploy(), exports_deploy));
24322
26442
  const gameId = flag(args, "--game");
24323
- const manifest = gameId ? null : await readManifest2(resolve6(positional(args) ?? "dist"));
26443
+ const manifest = gameId ? null : await readManifest2(resolve7(positional(args) ?? "dist"));
24324
26444
  const api2 = await apiFor(args);
24325
26445
  const state = await readStatus2(api2, gameId ?? manifest.id);
24326
26446
  console.log(` game ${state.gameId}`);
@@ -24330,32 +26450,99 @@ async function statusCommand(args) {
24330
26450
  console.log(` deployed ${state.deployedAt ?? "unknown"}`);
24331
26451
  }
24332
26452
  async function purchasesCommand(args) {
24333
- const { call: call2, refuse: refuse2 } = await Promise.resolve().then(() => (init_deploy(), exports_deploy));
26453
+ const { call: call2, refuse: refuse3 } = await Promise.resolve().then(() => (init_deploy(), exports_deploy));
24334
26454
  const { readManifest: readManifest2 } = await Promise.resolve().then(() => (init_dev(), exports_dev));
24335
26455
  const [action, ...rest] = args;
24336
26456
  if (action !== "key")
24337
26457
  throw new CliError(1, "usage: plupin purchases key [dir] [--game <id>]");
24338
- const gameId = flag(rest, "--game") ?? (await readManifest2(resolve6(positional(rest) ?? "dist"))).id;
26458
+ const gameId = flag(rest, "--game") ?? (await readManifest2(resolve7(positional(rest) ?? "dist"))).id;
24339
26459
  const response = await call2(await apiFor(rest), `/api/games/${gameId}/server-key`, {
24340
26460
  method: "POST"
24341
26461
  });
24342
26462
  if (!response.ok)
24343
- throw await refuse2(response, "purchases key");
26463
+ throw await refuse3(response, "purchases key");
24344
26464
  const { key } = await response.json();
24345
26465
  console.log(` game ${gameId}`);
24346
26466
  console.log(` key ${key}`);
24347
26467
  console.log(" note shown once, and any earlier key stopped working. Keep it on your server.");
24348
26468
  }
26469
+ async function emoteCommand(args) {
26470
+ const { EMOTE_SLOTS: EMOTE_SLOTS2, importAnimation: importAnimation2, newEmote: newEmote2, previewEmote: previewEmote2, pushEmote: pushEmote2 } = await Promise.resolve().then(() => (init_emote(), exports_emote));
26471
+ const [action, ...rest] = args;
26472
+ if (action === "new") {
26473
+ const price = flag(rest, "--price");
26474
+ const sigmaPrice = price === undefined ? 0 : Number(price);
26475
+ if (!Number.isInteger(sigmaPrice) || sigmaPrice < 0)
26476
+ throw new CliError(1, "--price takes a non-negative whole number of Sigma, e.g. --price 25");
26477
+ const created = await newEmote2({
26478
+ dir: resolve7(positional(rest) ?? "."),
26479
+ ...flag(rest, "--id") === undefined ? {} : { id: flag(rest, "--id") },
26480
+ ...flag(rest, "--name") === undefined ? {} : { name: flag(rest, "--name") },
26481
+ slot: oneOf("--slot", flag(rest, "--slot"), EMOTE_SLOTS2, "emote"),
26482
+ sigmaPrice,
26483
+ ...flag(rest, "--glyph") === undefined ? {} : { glyph: flag(rest, "--glyph") },
26484
+ ...flag(rest, "--face") === undefined ? {} : { face: flag(rest, "--face") },
26485
+ ...flag(rest, "--clip") === undefined ? {} : { clip: flag(rest, "--clip") },
26486
+ ...flag(rest, "--color") === undefined ? {} : { color: flag(rest, "--color") }
26487
+ });
26488
+ console.log(` emote ${created.manifest.id} (${created.manifest.slot})`);
26489
+ console.log(` manifest ${created.path}`);
26490
+ console.log(` assets ${created.assets}`);
26491
+ console.log(" done edit the manifest, then: plupin emote preview");
26492
+ return;
26493
+ }
26494
+ if (action === "import") {
26495
+ const file2 = positional(rest);
26496
+ if (!file2)
26497
+ throw new CliError(1, "usage: plupin emote import <clip.json> [dir] [--fps <n>]");
26498
+ const fps = flag(rest, "--fps");
26499
+ const done = await importAnimation2({
26500
+ file: file2,
26501
+ dir: resolve7(positionals(rest)[1] ?? "."),
26502
+ ...fps === undefined ? {} : { fps: Number(fps) }
26503
+ });
26504
+ console.log(` emote ${done.manifest.id}`);
26505
+ console.log(` anim ${done.frames} frames, ${done.seconds.toFixed(1)} s`);
26506
+ console.log(` manifest ${done.path}`);
26507
+ console.log(" done plupin emote preview, then push");
26508
+ return;
26509
+ }
26510
+ if (action === "preview") {
26511
+ const preview = await previewEmote2({
26512
+ dir: resolve7(positional(rest) ?? "."),
26513
+ ...flag(rest, "--out") === undefined ? {} : { out: flag(rest, "--out") }
26514
+ });
26515
+ console.log(` emote ${preview.manifest.id} (${preview.manifest.slot})`);
26516
+ console.log(` preview ${preview.path}`);
26517
+ console.log(` bytes ${new TextEncoder().encode(preview.svg).byteLength}`);
26518
+ console.log(" done that is the headshot the moderator sees; push when it is right");
26519
+ return;
26520
+ }
26521
+ if (action === "push") {
26522
+ const result = await pushEmote2({
26523
+ ...await apiFor(rest),
26524
+ dir: resolve7(positional(rest) ?? ".")
26525
+ });
26526
+ console.log(` item ${result.id}`);
26527
+ console.log(` state ${result.state} (waiting for review; not on sale yet)`);
26528
+ console.log(` hash ${result.contentHash.slice(0, 12)}`);
26529
+ console.log(` fee ${result.listingFeeSigma} sigma`);
26530
+ console.log(` preview ${result.previewPath}`);
26531
+ console.log(" done in the review queue; a rejection comes back with a reason to fix");
26532
+ return;
26533
+ }
26534
+ throw new CliError(1, "usage: plupin emote new|import|preview|push [dir]");
26535
+ }
24349
26536
  async function dev(args) {
24350
26537
  const { readManifest: readManifest2, startDevServer: startDevServer2 } = await Promise.resolve().then(() => (init_dev(), exports_dev));
24351
- const dir = resolve6(positional(args) ?? "dist");
26538
+ const dir = resolve7(positional(args) ?? "dist");
24352
26539
  const manifestDir = flag(args, "--manifest");
24353
26540
  const port = Number(flag(args, "--port") ?? 8787);
24354
26541
  const rawSeed = flag(args, "--seed");
24355
26542
  const seed = rawSeed === undefined ? DEFAULT_SEED : Number(rawSeed);
24356
26543
  if (!Number.isInteger(seed) || seed < 0)
24357
26544
  throw new CliError(1, "--seed takes a non-negative integer, e.g. --seed 7");
24358
- const manifest = await readManifest2(manifestDir ? resolve6(manifestDir) : dir);
26545
+ const manifest = await readManifest2(manifestDir ? resolve7(manifestDir) : dir);
24359
26546
  const server = await startDevServer2({
24360
26547
  dir,
24361
26548
  manifest,
@@ -24382,6 +26569,35 @@ async function dev(args) {
24382
26569
  process.exit(0);
24383
26570
  });
24384
26571
  }
26572
+ async function connectCommand(args) {
26573
+ const { CONNECT_TARGETS: CONNECT_TARGETS2, connect: connect2, hostedUrl: hostedUrl2 } = await Promise.resolve().then(() => (init_connect(), exports_connect));
26574
+ const { readCredentialsIfPresent: readCredentialsIfPresent2 } = await Promise.resolve().then(() => (init_credentials(), exports_credentials));
26575
+ const [target, ...rest] = args;
26576
+ if (!target || !CONNECT_TARGETS2.includes(target))
26577
+ throw new CliError(1, `usage: plupin connect ${CONNECT_TARGETS2.join("|")} [--api <url>]`);
26578
+ const stored = await readCredentialsIfPresent2(process.env);
26579
+ const apiUrl = (flag(rest, "--api") ?? process.env.PLUPIN_API_URL ?? stored?.apiUrl ?? DEFAULT_API_URL).replace(/\/+$/, "");
26580
+ const bearer2 = stored && stored.kind === "bearer" ? stored.token : null;
26581
+ const { receipt } = await connect2(target, {
26582
+ apiUrl,
26583
+ token: bearer2
26584
+ });
26585
+ console.log(` agent ${receipt.target}`);
26586
+ console.log(` config ${receipt.path}`);
26587
+ console.log(` mode ${receipt.mode}`);
26588
+ console.log(` server ${receipt.servers.join(", ")} (stdio: bunx -y @plupin/cli mcp)`);
26589
+ if (receipt.hosted) {
26590
+ console.log(` hosted ${hostedUrl2(apiUrl)} \u2014 token written, never printed`);
26591
+ if (receipt.verifyTools)
26592
+ console.log(` tools ${receipt.verifyTools.length} from the hosted surface: ${receipt.verifyTools.join(", ")}`);
26593
+ else
26594
+ console.log(` check ${receipt.verifyStatus ?? "no response"}${receipt.verifyError ? ` \u2014 ${receipt.verifyError}` : ""}; the config is written`);
26595
+ } else if (stored)
26596
+ console.log(" hosted skipped \u2014 that token is a browser session; run: plupin login (OAuth), then this again");
26597
+ else
26598
+ console.log(" hosted skipped \u2014 run: plupin login, then this command again");
26599
+ console.log(` done restart ${receipt.target} so it loads the servers`);
26600
+ }
24385
26601
  function docs(args) {
24386
26602
  const topic = args.find((arg) => !arg.startsWith("--"));
24387
26603
  process.stdout.write(docsText(topic));
@@ -24394,6 +26610,8 @@ if (command === "mcp") {
24394
26610
  await dev(rest).catch((error62) => fail2("dev", error62));
24395
26611
  } else if (command === "create") {
24396
26612
  await createCommand(rest).catch((error62) => fail2("create", error62));
26613
+ } else if (command === "emote") {
26614
+ await emoteCommand(rest).catch((error62) => fail2("emote", error62));
24397
26615
  } else if (command === "up") {
24398
26616
  await upCommand(rest).catch((error62) => fail2("up", error62));
24399
26617
  } else if (command === "deploy") {
@@ -24404,6 +26622,8 @@ if (command === "mcp") {
24404
26622
  await purchasesCommand(rest).catch((error62) => fail2("purchases", error62));
24405
26623
  } else if (command === "login") {
24406
26624
  await login(rest).catch((error62) => fail2("login", error62));
26625
+ } else if (command === "connect") {
26626
+ await connectCommand(rest).catch((error62) => fail2("connect", error62));
24407
26627
  } else if (command === "docs") {
24408
26628
  try {
24409
26629
  docs(rest);