@lunora/studio 0.0.0 → 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE.md +105 -0
  2. package/README.md +123 -9
  3. package/__assets__/package-og.svg +14 -0
  4. package/dist/index.d.ts +1402 -0
  5. package/dist/index.js +41 -0
  6. package/dist/mount.d.ts +21 -0
  7. package/dist/mount.js +26 -0
  8. package/dist/packem_shared/ADMIN_FUNCTION_PREFIX-DmBqMZ-z.js +45 -0
  9. package/dist/packem_shared/ApiDocsPanel-DpRjJhG5.js +842 -0
  10. package/dist/packem_shared/ApiReferencePanel-DMIUp-kK.js +229 -0
  11. package/dist/packem_shared/ApiTab-DURGU15e.js +251 -0
  12. package/dist/packem_shared/AuditPanel-BC59Nhst.js +212 -0
  13. package/dist/packem_shared/CommandPalette-Dx_CoB9i.js +373 -0
  14. package/dist/packem_shared/ConfirmButton-WQVUoGFb.js +59 -0
  15. package/dist/packem_shared/ConnectionBadge-Bxagrip8.js +111 -0
  16. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +50 -0
  17. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +89 -0
  18. package/dist/packem_shared/DataBrowser-Coz6jJE6.js +4542 -0
  19. package/dist/packem_shared/DataFilters-FNquMaiu.js +249 -0
  20. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +66 -0
  21. package/dist/packem_shared/ExportImportPanel-WO34fJxy.js +193 -0
  22. package/dist/packem_shared/FileBrowser-Zcr-Qgxo.js +2932 -0
  23. package/dist/packem_shared/FunctionRunner-j0Rd5m9t.js +343 -0
  24. package/dist/packem_shared/FunctionStatsPanel-DboBl-XL.js +432 -0
  25. package/dist/packem_shared/GlobalDataBrowser-9MhPEfgN.js +318 -0
  26. package/dist/packem_shared/HealthPanel-DOIgbUtx.js +640 -0
  27. package/dist/packem_shared/HomePanel-bdOCNA-p.js +1273 -0
  28. package/dist/packem_shared/InsightsPanel-DaZPnSgt.js +423 -0
  29. package/dist/packem_shared/LogsPanel-CWdqAGpQ.js +839 -0
  30. package/dist/packem_shared/MailPanel-D_EGtDnS.js +447 -0
  31. package/dist/packem_shared/MetricsPanel-E4Gv6wTO.js +1625 -0
  32. package/dist/packem_shared/MigrationsPanel-DQdPY9io.js +246 -0
  33. package/dist/packem_shared/OpenRpcReferencePanel-j2p3HB0s.js +191 -0
  34. package/dist/packem_shared/PitrPanel-BbBkQR6t.js +252 -0
  35. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +3 -0
  36. package/dist/packem_shared/ScheduledJobs-Ok1CYYwI.js +159 -0
  37. package/dist/packem_shared/SchemaViewer-D8XGnp-X.js +2512 -0
  38. package/dist/packem_shared/SecurityAdvisorPanel-Cdm2IxLW.js +79 -0
  39. package/dist/packem_shared/SettingsPanel-D3WF2mBU.js +176 -0
  40. package/dist/packem_shared/ShardInput-DNCsT1KW.js +107 -0
  41. package/dist/packem_shared/SqlEditorPanel-BuQ7f2Hs.js +13 -0
  42. package/dist/packem_shared/Studio-D36od9Oz.js +33 -0
  43. package/dist/packem_shared/StudioApp-dvywkJ8I.js +383 -0
  44. package/dist/packem_shared/StudioI18nProvider-Dcajsznk.js +48 -0
  45. package/dist/packem_shared/TableEditor-DIVDk3vT.js +371 -0
  46. package/dist/packem_shared/advisor-view-DBlzJi6C.js +159 -0
  47. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +108 -0
  48. package/dist/packem_shared/app.d-CCmwDEVs.d.ts +300 -0
  49. package/dist/packem_shared/badge-B2PKA1-5.js +49 -0
  50. package/dist/packem_shared/bar-chart-CzJAgqkp.js +3245 -0
  51. package/dist/packem_shared/button-BhsN2uZH.js +49 -0
  52. package/dist/packem_shared/card-DURq3ElK.js +175 -0
  53. package/dist/packem_shared/cf-links-BZfRdxSE.js +8 -0
  54. package/dist/packem_shared/checkbox-UNkzAxl-.js +63 -0
  55. package/dist/packem_shared/createStudioI18n-CgvlmDkN.js +27 -0
  56. package/dist/packem_shared/data-grid-CCh2Couo.js +183 -0
  57. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +280 -0
  58. package/dist/packem_shared/empty-state-DY_oe0k6.js +98 -0
  59. package/dist/packem_shared/grid-features-DTjG6Sex.js +840 -0
  60. package/dist/packem_shared/input-XH4r1Pt1.js +53 -0
  61. package/dist/packem_shared/internal-BBZYexre.js +68 -0
  62. package/dist/packem_shared/label-D8ykjn5J.js +46 -0
  63. package/dist/packem_shared/live-status-bPff1O7Y.js +44 -0
  64. package/dist/packem_shared/reference-view-BCKIoai7.js +2180 -0
  65. package/dist/packem_shared/shard-history-DyebH1R5.js +38 -0
  66. package/dist/packem_shared/sparkline-10dG-_f0.js +93 -0
  67. package/dist/packem_shared/sql-editor-panel-CW2y2x9h.js +2562 -0
  68. package/dist/packem_shared/storage-tier-CL98eOvn.js +85 -0
  69. package/dist/packem_shared/studio-BDVd7rIV.js +10303 -0
  70. package/dist/packem_shared/table-_RzNvy3R.js +246 -0
  71. package/dist/packem_shared/table-list-sidebar-aZHLq70w.js +832 -0
  72. package/dist/packem_shared/textarea-D3gaCU_-.js +46 -0
  73. package/dist/packem_shared/use-live-admin-D1h1Fzsd.js +73 -0
  74. package/dist/packem_shared/use-live-shard-seed-B74RYcOy.js +76 -0
  75. package/dist/packem_shared/useDebounced-Dxncpg6z.js +32 -0
  76. package/dist/packem_shared/utils-B05Dmz_H.js +8 -0
  77. package/dist/packem_shared/virtual-rect-CVMUskSm.js +10 -0
  78. package/dist/standalone/studio.js +356 -0
  79. package/dist/styles.css +2 -0
  80. package/package.json +77 -17
  81. package/src/theme.css +59 -0
@@ -0,0 +1,2180 @@
1
+ import { c } from 'react/compiler-runtime';
2
+ import { c as cn } from './utils-B05Dmz_H.js';
3
+ import { jsxDEV, Fragment } from 'react/jsx-dev-runtime';
4
+ import { useState, useEffect, createContext, use } from 'react';
5
+ import { e as errorMessage, b as copyToClipboard, f as fireAndForget, c as callOptions, a as adminRef } from './internal-BBZYexre.js';
6
+ import { SentIcon, Copy01Icon, Search01Icon } from '@hugeicons/core-free-icons';
7
+ import { HugeiconsIcon } from '@hugeicons/react';
8
+ import { I as Input } from './input-XH4r1Pt1.js';
9
+ import { useT } from './createStudioI18n-CgvlmDkN.js';
10
+ import { B as Button } from './button-BhsN2uZH.js';
11
+ import { B as Badge$1 } from './badge-B2PKA1-5.js';
12
+ import { ShardInput } from './ShardInput-DNCsT1KW.js';
13
+ import { L as Label } from './label-D8ykjn5J.js';
14
+ import { T as Textarea } from './textarea-D3gaCU_-.js';
15
+ import { useLunora } from '@lunora/react';
16
+
17
+ function Skeleton(t0) {
18
+ const $ = c(8);
19
+ let className;
20
+ let props;
21
+ if ($[0] !== t0) {
22
+ ({
23
+ className,
24
+ ...props
25
+ } = t0);
26
+ $[0] = t0;
27
+ $[1] = className;
28
+ $[2] = props;
29
+ } else {
30
+ className = $[1];
31
+ props = $[2];
32
+ }
33
+ let t1;
34
+ if ($[3] !== className) {
35
+ t1 = cn("animate-pulse rounded-md bg-muted", className);
36
+ $[3] = className;
37
+ $[4] = t1;
38
+ } else {
39
+ t1 = $[4];
40
+ }
41
+ let t2;
42
+ if ($[5] !== props || $[6] !== t1) {
43
+ t2 = /* @__PURE__ */ jsxDEV("div", {
44
+ "data-slot": "skeleton",
45
+ className: t1,
46
+ ...props
47
+ }, void 0, false);
48
+ $[5] = props;
49
+ $[6] = t1;
50
+ $[7] = t2;
51
+ } else {
52
+ t2 = $[7];
53
+ }
54
+ return t2;
55
+ }
56
+
57
+ const useAdminSpec = function(inlineSpec, fetcher, classify) {
58
+ const $ = c(10);
59
+ let t0;
60
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
61
+ t0 = {
62
+ kind: "loading"
63
+ };
64
+ $[0] = t0;
65
+ } else {
66
+ t0 = $[0];
67
+ }
68
+ const [fetched, setFetched] = useState(t0);
69
+ let t1;
70
+ let t2;
71
+ if ($[1] !== classify || $[2] !== fetcher || $[3] !== inlineSpec) {
72
+ t1 = () => {
73
+ if (inlineSpec !== void 0) {
74
+ return;
75
+ }
76
+ let cancelled = false;
77
+ fetcher().then((spec) => {
78
+ if (!cancelled) {
79
+ setFetched(classify(spec));
80
+ }
81
+ return spec;
82
+ }).catch((error) => {
83
+ if (!cancelled) {
84
+ setFetched({
85
+ kind: "error",
86
+ message: errorMessage(error)
87
+ });
88
+ }
89
+ });
90
+ return () => {
91
+ cancelled = true;
92
+ };
93
+ };
94
+ t2 = [classify, fetcher, inlineSpec];
95
+ $[1] = classify;
96
+ $[2] = fetcher;
97
+ $[3] = inlineSpec;
98
+ $[4] = t1;
99
+ $[5] = t2;
100
+ } else {
101
+ t1 = $[4];
102
+ t2 = $[5];
103
+ }
104
+ useEffect(t1, t2);
105
+ let t3;
106
+ if ($[6] !== classify || $[7] !== fetched || $[8] !== inlineSpec) {
107
+ t3 = inlineSpec === void 0 ? fetched : classify(inlineSpec);
108
+ $[6] = classify;
109
+ $[7] = fetched;
110
+ $[8] = inlineSpec;
111
+ $[9] = t3;
112
+ } else {
113
+ t3 = $[9];
114
+ }
115
+ return t3;
116
+ };
117
+
118
+ const scalarOf = (value) => {
119
+ if (typeof value === "number") {
120
+ return "number";
121
+ }
122
+ if (typeof value === "boolean") {
123
+ return "boolean";
124
+ }
125
+ return "string";
126
+ };
127
+ const enumValues = (schema) => {
128
+ if (schema.enum !== void 0 && schema.enum.length > 0) {
129
+ return schema.enum;
130
+ }
131
+ if (schema.anyOf !== void 0 && schema.anyOf.length > 0 && schema.anyOf.every((member) => member.const !== void 0)) {
132
+ return schema.anyOf.map((member) => member.const);
133
+ }
134
+ return void 0;
135
+ };
136
+ const typeLabel = (schema) => {
137
+ if (schema === void 0) {
138
+ return "any";
139
+ }
140
+ if (schema.const !== void 0) {
141
+ return JSON.stringify(schema.const);
142
+ }
143
+ if (schema.enum !== void 0 && schema.enum.length > 0) {
144
+ return schema.enum.map((value) => JSON.stringify(value)).join(" | ");
145
+ }
146
+ if (schema.anyOf !== void 0 && schema.anyOf.length > 0) {
147
+ return schema.anyOf.map((member) => typeLabel(member)).join(" | ");
148
+ }
149
+ if (schema.type === "array") {
150
+ return `array<${typeLabel(schema.items)}>`;
151
+ }
152
+ return schema.type ?? "any";
153
+ };
154
+ const fieldTypeLabel = (schema) => {
155
+ const values = enumValues(schema);
156
+ if (values !== void 0) {
157
+ return schema.type ?? scalarOf(values[0]);
158
+ }
159
+ return typeLabel(schema);
160
+ };
161
+ const valueInText = (schema) => {
162
+ const values = enumValues(schema);
163
+ return values === void 0 ? void 0 : values.map((value) => JSON.stringify(value)).join(" | ");
164
+ };
165
+ const rangeText = (schema) => {
166
+ const parts = [];
167
+ if (schema.minimum !== void 0) {
168
+ parts.push(`${String(schema.minimum)} ≤`);
169
+ } else if (schema.exclusiveMinimum !== void 0) {
170
+ parts.push(`${String(schema.exclusiveMinimum)} <`);
171
+ }
172
+ const hasLower = parts.length > 0;
173
+ parts.push("value");
174
+ if (schema.maximum !== void 0) {
175
+ parts.push(`≤ ${String(schema.maximum)}`);
176
+ } else if (schema.exclusiveMaximum !== void 0) {
177
+ parts.push(`< ${String(schema.exclusiveMaximum)}`);
178
+ }
179
+ const hasUpper = parts.length > (hasLower ? 2 : 1);
180
+ return hasLower || hasUpper ? parts.join(" ") : void 0;
181
+ };
182
+ const childObject = (schema) => {
183
+ if (schema.type === "object" && schema.properties !== void 0) {
184
+ return schema;
185
+ }
186
+ if (schema.type === "array" && schema.items?.type === "object" && schema.items.properties !== void 0) {
187
+ return schema.items;
188
+ }
189
+ return void 0;
190
+ };
191
+ const exampleForSchema = (schema) => {
192
+ if (schema === void 0) {
193
+ return null;
194
+ }
195
+ if (schema.const !== void 0) {
196
+ return schema.const;
197
+ }
198
+ if (schema.enum !== void 0 && schema.enum.length > 0) {
199
+ return schema.enum[0];
200
+ }
201
+ if (schema.anyOf !== void 0 && schema.anyOf.length > 0) {
202
+ return exampleForSchema(schema.anyOf[0]);
203
+ }
204
+ switch (schema.type) {
205
+ case "array": {
206
+ return [];
207
+ }
208
+ case "boolean": {
209
+ return false;
210
+ }
211
+ case "number": {
212
+ return 0;
213
+ }
214
+ case "object": {
215
+ const out = {};
216
+ for (const [key, child] of Object.entries(schema.properties ?? {})) {
217
+ out[key] = exampleForSchema(child);
218
+ }
219
+ return out;
220
+ }
221
+ case "string": {
222
+ return "";
223
+ }
224
+ default: {
225
+ return null;
226
+ }
227
+ }
228
+ };
229
+ const Badge = (t0) => {
230
+ const $ = c(7);
231
+ const {
232
+ label,
233
+ value
234
+ } = t0;
235
+ let t1;
236
+ if ($[0] !== label) {
237
+ t1 = /* @__PURE__ */ jsxDEV("span", {
238
+ className: "text-muted-foreground",
239
+ children: label
240
+ }, void 0, false);
241
+ $[0] = label;
242
+ $[1] = t1;
243
+ } else {
244
+ t1 = $[1];
245
+ }
246
+ let t2;
247
+ if ($[2] !== value) {
248
+ t2 = /* @__PURE__ */ jsxDEV("span", {
249
+ className: "text-foreground",
250
+ children: value
251
+ }, void 0, false);
252
+ $[2] = value;
253
+ $[3] = t2;
254
+ } else {
255
+ t2 = $[3];
256
+ }
257
+ let t3;
258
+ if ($[4] !== t1 || $[5] !== t2) {
259
+ t3 = /* @__PURE__ */ jsxDEV("span", {
260
+ className: "inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",
261
+ children: [t1, t2]
262
+ }, void 0, true);
263
+ $[4] = t1;
264
+ $[5] = t2;
265
+ $[6] = t3;
266
+ } else {
267
+ t3 = $[6];
268
+ }
269
+ return t3;
270
+ };
271
+ const FieldRow = (t0) => {
272
+ const $ = c(40);
273
+ const {
274
+ name,
275
+ required,
276
+ schema
277
+ } = t0;
278
+ const t = useT();
279
+ let t1;
280
+ if ($[0] !== schema) {
281
+ t1 = rangeText(schema);
282
+ $[0] = schema;
283
+ $[1] = t1;
284
+ } else {
285
+ t1 = $[1];
286
+ }
287
+ const range = t1;
288
+ let t2;
289
+ if ($[2] !== schema) {
290
+ t2 = valueInText(schema);
291
+ $[2] = schema;
292
+ $[3] = t2;
293
+ } else {
294
+ t2 = $[3];
295
+ }
296
+ const values = t2;
297
+ const relation = schema["x-lunora-table"];
298
+ const hasBadges = schema.format !== void 0 || range !== void 0 || values !== void 0 || relation !== void 0;
299
+ let t3;
300
+ if ($[4] !== schema) {
301
+ t3 = childObject(schema);
302
+ $[4] = schema;
303
+ $[5] = t3;
304
+ } else {
305
+ t3 = $[5];
306
+ }
307
+ const nested = t3;
308
+ const t4 = required ? "*" : "?";
309
+ let t5;
310
+ if ($[6] !== t4) {
311
+ t5 = /* @__PURE__ */ jsxDEV("span", {
312
+ className: "text-muted-foreground",
313
+ children: t4
314
+ }, void 0, false);
315
+ $[6] = t4;
316
+ $[7] = t5;
317
+ } else {
318
+ t5 = $[7];
319
+ }
320
+ let t6;
321
+ if ($[8] !== name || $[9] !== t5) {
322
+ t6 = /* @__PURE__ */ jsxDEV("span", {
323
+ className: "font-mono text-foreground",
324
+ children: [name, t5]
325
+ }, void 0, true);
326
+ $[8] = name;
327
+ $[9] = t5;
328
+ $[10] = t6;
329
+ } else {
330
+ t6 = $[10];
331
+ }
332
+ let t7;
333
+ if ($[11] !== schema) {
334
+ t7 = fieldTypeLabel(schema);
335
+ $[11] = schema;
336
+ $[12] = t7;
337
+ } else {
338
+ t7 = $[12];
339
+ }
340
+ let t8;
341
+ if ($[13] !== t7) {
342
+ t8 = /* @__PURE__ */ jsxDEV("span", {
343
+ className: "font-mono text-muted-foreground",
344
+ children: t7
345
+ }, void 0, false);
346
+ $[13] = t7;
347
+ $[14] = t8;
348
+ } else {
349
+ t8 = $[14];
350
+ }
351
+ let t9;
352
+ if ($[15] !== t6 || $[16] !== t8) {
353
+ t9 = /* @__PURE__ */ jsxDEV("div", {
354
+ className: "flex items-baseline gap-2",
355
+ children: [t6, t8]
356
+ }, void 0, true);
357
+ $[15] = t6;
358
+ $[16] = t8;
359
+ $[17] = t9;
360
+ } else {
361
+ t9 = $[17];
362
+ }
363
+ let t10;
364
+ if ($[18] !== schema.description) {
365
+ t10 = schema.description !== void 0 && /* @__PURE__ */ jsxDEV("p", {
366
+ className: "max-w-prose text-muted-foreground",
367
+ children: schema.description
368
+ }, void 0, false);
369
+ $[18] = schema.description;
370
+ $[19] = t10;
371
+ } else {
372
+ t10 = $[19];
373
+ }
374
+ let t11;
375
+ if ($[20] !== hasBadges || $[21] !== range || $[22] !== relation || $[23] !== schema.format || $[24] !== t || $[25] !== values) {
376
+ t11 = hasBadges && /* @__PURE__ */ jsxDEV("div", {
377
+ className: "flex flex-wrap gap-1",
378
+ children: [schema.format !== void 0 && /* @__PURE__ */ jsxDEV(Badge, {
379
+ label: t("Format"),
380
+ value: schema.format
381
+ }, void 0, false), range !== void 0 && /* @__PURE__ */ jsxDEV(Badge, {
382
+ label: t("Range"),
383
+ value: range
384
+ }, void 0, false), values !== void 0 && /* @__PURE__ */ jsxDEV(Badge, {
385
+ label: t("Value in"),
386
+ value: values
387
+ }, void 0, false), relation !== void 0 && /* @__PURE__ */ jsxDEV(Badge, {
388
+ label: t("relation"),
389
+ value: relation
390
+ }, void 0, false)]
391
+ }, void 0, true);
392
+ $[20] = hasBadges;
393
+ $[21] = range;
394
+ $[22] = relation;
395
+ $[23] = schema.format;
396
+ $[24] = t;
397
+ $[25] = values;
398
+ $[26] = t11;
399
+ } else {
400
+ t11 = $[26];
401
+ }
402
+ let t12;
403
+ if ($[27] !== t10 || $[28] !== t11 || $[29] !== t9) {
404
+ t12 = /* @__PURE__ */ jsxDEV("div", {
405
+ className: "flex flex-col gap-1 py-2",
406
+ children: [t9, t10, t11]
407
+ }, void 0, true);
408
+ $[27] = t10;
409
+ $[28] = t11;
410
+ $[29] = t9;
411
+ $[30] = t12;
412
+ } else {
413
+ t12 = $[30];
414
+ }
415
+ const header = t12;
416
+ if (nested === void 0) {
417
+ let t132;
418
+ if ($[31] !== header) {
419
+ t132 = /* @__PURE__ */ jsxDEV("div", {
420
+ className: "border-b border-border/50 last:border-b-0",
421
+ children: header
422
+ }, void 0, false);
423
+ $[31] = header;
424
+ $[32] = t132;
425
+ } else {
426
+ t132 = $[32];
427
+ }
428
+ return t132;
429
+ }
430
+ let t13;
431
+ if ($[33] !== header) {
432
+ t13 = /* @__PURE__ */ jsxDEV("summary", {
433
+ className: "cursor-pointer marker:text-muted-foreground",
434
+ children: header
435
+ }, void 0, false);
436
+ $[33] = header;
437
+ $[34] = t13;
438
+ } else {
439
+ t13 = $[34];
440
+ }
441
+ let t14;
442
+ if ($[35] !== nested) {
443
+ t14 = /* @__PURE__ */ jsxDEV("div", {
444
+ className: "mb-2 ml-2 border-l border-border pl-3",
445
+ children: /* @__PURE__ */ jsxDEV(SchemaFields, {
446
+ schema: nested
447
+ }, void 0, false)
448
+ }, void 0, false);
449
+ $[35] = nested;
450
+ $[36] = t14;
451
+ } else {
452
+ t14 = $[36];
453
+ }
454
+ let t15;
455
+ if ($[37] !== t13 || $[38] !== t14) {
456
+ t15 = /* @__PURE__ */ jsxDEV("details", {
457
+ className: "border-b border-border/50 last:border-b-0",
458
+ children: [t13, t14]
459
+ }, void 0, true);
460
+ $[37] = t13;
461
+ $[38] = t14;
462
+ $[39] = t15;
463
+ } else {
464
+ t15 = $[39];
465
+ }
466
+ return t15;
467
+ };
468
+ const SchemaFields = (t0) => {
469
+ const $ = c(7);
470
+ const {
471
+ schema
472
+ } = t0;
473
+ let t1;
474
+ if ($[0] !== schema.required) {
475
+ t1 = new Set(schema.required);
476
+ $[0] = schema.required;
477
+ $[1] = t1;
478
+ } else {
479
+ t1 = $[1];
480
+ }
481
+ const required = t1;
482
+ let t2;
483
+ if ($[2] !== schema.properties) {
484
+ t2 = Object.entries(schema.properties ?? {});
485
+ $[2] = schema.properties;
486
+ $[3] = t2;
487
+ } else {
488
+ t2 = $[3];
489
+ }
490
+ const rows = t2;
491
+ let t3;
492
+ if ($[4] !== required || $[5] !== rows) {
493
+ t3 = /* @__PURE__ */ jsxDEV("div", {
494
+ className: "flex flex-col",
495
+ children: rows.map((t4) => {
496
+ const [name, child] = t4;
497
+ return /* @__PURE__ */ jsxDEV(FieldRow, {
498
+ name,
499
+ required: required.has(name),
500
+ schema: child
501
+ }, name, false);
502
+ })
503
+ }, void 0, false);
504
+ $[4] = required;
505
+ $[5] = rows;
506
+ $[6] = t3;
507
+ } else {
508
+ t3 = $[6];
509
+ }
510
+ return t3;
511
+ };
512
+ const SchemaTable = (t0) => {
513
+ const $ = c(10);
514
+ const {
515
+ schema,
516
+ testId
517
+ } = t0;
518
+ if (schema?.type !== "object" || Object.keys(schema.properties ?? {}).length === 0) {
519
+ let t12;
520
+ if ($[0] !== schema) {
521
+ t12 = typeLabel(schema);
522
+ $[0] = schema;
523
+ $[1] = t12;
524
+ } else {
525
+ t12 = $[1];
526
+ }
527
+ let t22;
528
+ if ($[2] !== t12 || $[3] !== testId) {
529
+ t22 = /* @__PURE__ */ jsxDEV("p", {
530
+ className: "font-mono text-xs text-muted-foreground",
531
+ "data-testid": testId,
532
+ children: t12
533
+ }, void 0, false);
534
+ $[2] = t12;
535
+ $[3] = testId;
536
+ $[4] = t22;
537
+ } else {
538
+ t22 = $[4];
539
+ }
540
+ return t22;
541
+ }
542
+ let t1;
543
+ if ($[5] !== schema) {
544
+ t1 = /* @__PURE__ */ jsxDEV(SchemaFields, {
545
+ schema
546
+ }, void 0, false);
547
+ $[5] = schema;
548
+ $[6] = t1;
549
+ } else {
550
+ t1 = $[6];
551
+ }
552
+ let t2;
553
+ if ($[7] !== t1 || $[8] !== testId) {
554
+ t2 = /* @__PURE__ */ jsxDEV("div", {
555
+ className: "text-xs",
556
+ "data-testid": testId,
557
+ children: t1
558
+ }, void 0, false);
559
+ $[7] = t1;
560
+ $[8] = testId;
561
+ $[9] = t2;
562
+ } else {
563
+ t2 = $[9];
564
+ }
565
+ return t2;
566
+ };
567
+
568
+ const SAMPLE_ORDER = ["curl", "javascript", "lunora"];
569
+ const SAMPLE_LABEL = {
570
+ lunora: "Lunora",
571
+ curl: "cURL",
572
+ javascript: "JavaScript"
573
+ };
574
+ const apiReferenceOf = (functionPath) => `api.${functionPath.replaceAll(/[/:]/g, ".")}`;
575
+ const requestBody = (operation) => {
576
+ const args = exampleForSchema(operation.argsSchema) ?? {};
577
+ return operation.functionPath === void 0 ? args : {
578
+ args,
579
+ functionPath: operation.functionPath
580
+ };
581
+ };
582
+ const sampleSource = (sample, operation, server) => {
583
+ const url = `${server}${operation.httpPath}`;
584
+ const body = JSON.stringify(requestBody(operation), void 0, 2);
585
+ const args = JSON.stringify(exampleForSchema(operation.argsSchema) ?? {}, void 0, 2);
586
+ switch (sample) {
587
+ case "curl": {
588
+ const hasBody = operation.method !== "GET" && operation.method !== "HEAD";
589
+ const lines = [`curl -X ${operation.method} ${JSON.stringify(url)}`];
590
+ if (hasBody) {
591
+ lines.push(` -H "Content-Type: application/json"`, ` -d '${body}'`);
592
+ }
593
+ return lines.join(" \\\n");
594
+ }
595
+ case "lunora": {
596
+ if (operation.functionPath === void 0) {
597
+ return `await fetch(${JSON.stringify(operation.httpPath)}, { method: ${JSON.stringify(operation.method)} });`;
598
+ }
599
+ const method = operation.kind ?? "query";
600
+ return `import { useLunora } from "@lunora/react";
601
+ import { api } from "./_generated/api";
602
+
603
+ const client = useLunora();
604
+ await client.${method}(${apiReferenceOf(operation.functionPath)}, ${args});`;
605
+ }
606
+ default: {
607
+ const hasBody = operation.method !== "GET" && operation.method !== "HEAD";
608
+ const init = hasBody ? `{
609
+ method: ${JSON.stringify(operation.method)},
610
+ headers: { "Content-Type": "application/json" },
611
+ body: JSON.stringify(${body}),
612
+ }` : `{ method: ${JSON.stringify(operation.method)} }`;
613
+ return `const response = await fetch(${JSON.stringify(url)}, ${init});
614
+ const data = await response.json();`;
615
+ }
616
+ }
617
+ };
618
+ const CodeSamples = (t0) => {
619
+ const $ = c(24);
620
+ const {
621
+ operation,
622
+ server
623
+ } = t0;
624
+ const t = useT();
625
+ const [sample, setSample] = useState("curl");
626
+ let t1;
627
+ if ($[0] !== operation || $[1] !== sample || $[2] !== server) {
628
+ t1 = sampleSource(sample, operation, server);
629
+ $[0] = operation;
630
+ $[1] = sample;
631
+ $[2] = server;
632
+ $[3] = t1;
633
+ } else {
634
+ t1 = $[3];
635
+ }
636
+ const source = t1;
637
+ let t2;
638
+ if ($[4] !== source) {
639
+ t2 = () => {
640
+ copyToClipboard(source);
641
+ };
642
+ $[4] = source;
643
+ $[5] = t2;
644
+ } else {
645
+ t2 = $[5];
646
+ }
647
+ const onCopy = t2;
648
+ let t3;
649
+ if ($[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
650
+ t3 = (event) => {
651
+ setSample(event.currentTarget.dataset.sample);
652
+ };
653
+ $[6] = t3;
654
+ } else {
655
+ t3 = $[6];
656
+ }
657
+ const onSelect = t3;
658
+ let t4;
659
+ if ($[7] !== sample) {
660
+ t4 = SAMPLE_ORDER.map((key) => /* @__PURE__ */ jsxDEV("button", {
661
+ "aria-selected": sample === key,
662
+ className: "rounded px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium aria-selected:text-foreground",
663
+ "data-sample": key,
664
+ "data-testid": `api-sample-${key}`,
665
+ onClick: onSelect,
666
+ role: "tab",
667
+ type: "button",
668
+ children: SAMPLE_LABEL[key]
669
+ }, key, false));
670
+ $[7] = sample;
671
+ $[8] = t4;
672
+ } else {
673
+ t4 = $[8];
674
+ }
675
+ let t5;
676
+ if ($[9] !== t4) {
677
+ t5 = /* @__PURE__ */ jsxDEV("div", {
678
+ className: "flex gap-1",
679
+ role: "tablist",
680
+ children: t4
681
+ }, void 0, false);
682
+ $[9] = t4;
683
+ $[10] = t5;
684
+ } else {
685
+ t5 = $[10];
686
+ }
687
+ let t6;
688
+ if ($[11] !== t) {
689
+ t6 = t("Copy");
690
+ $[11] = t;
691
+ $[12] = t6;
692
+ } else {
693
+ t6 = $[12];
694
+ }
695
+ let t7;
696
+ if ($[13] !== onCopy || $[14] !== t6) {
697
+ t7 = /* @__PURE__ */ jsxDEV(Button, {
698
+ "data-testid": "api-sample-copy",
699
+ onClick: onCopy,
700
+ size: "xs",
701
+ type: "button",
702
+ variant: "ghost",
703
+ children: t6
704
+ }, void 0, false);
705
+ $[13] = onCopy;
706
+ $[14] = t6;
707
+ $[15] = t7;
708
+ } else {
709
+ t7 = $[15];
710
+ }
711
+ let t8;
712
+ if ($[16] !== t5 || $[17] !== t7) {
713
+ t8 = /* @__PURE__ */ jsxDEV("div", {
714
+ className: "flex items-center justify-between gap-2 border-b border-border px-3 py-2",
715
+ children: [t5, t7]
716
+ }, void 0, true);
717
+ $[16] = t5;
718
+ $[17] = t7;
719
+ $[18] = t8;
720
+ } else {
721
+ t8 = $[18];
722
+ }
723
+ let t9;
724
+ if ($[19] !== source) {
725
+ t9 = /* @__PURE__ */ jsxDEV("pre", {
726
+ className: "overflow-auto px-3 pb-3 font-mono text-xs",
727
+ "data-testid": "api-sample-source",
728
+ children: source
729
+ }, void 0, false);
730
+ $[19] = source;
731
+ $[20] = t9;
732
+ } else {
733
+ t9 = $[20];
734
+ }
735
+ let t10;
736
+ if ($[21] !== t8 || $[22] !== t9) {
737
+ t10 = /* @__PURE__ */ jsxDEV("div", {
738
+ className: "flex flex-col gap-2 rounded-xl border border-border bg-card",
739
+ "data-testid": "api-code-samples",
740
+ children: [t8, t9]
741
+ }, void 0, true);
742
+ $[21] = t8;
743
+ $[22] = t9;
744
+ $[23] = t10;
745
+ } else {
746
+ t10 = $[23];
747
+ }
748
+ return t10;
749
+ };
750
+
751
+ const TONE_CLASS = {
752
+ blue: "text-info",
753
+ emerald: "text-success",
754
+ neutral: "text-muted-foreground",
755
+ orange: "text-warning",
756
+ red: "text-destructive",
757
+ violet: "text-royal-amethyst"
758
+ };
759
+ const methodTone = (method) => {
760
+ switch (method.toUpperCase()) {
761
+ case "DELETE": {
762
+ return "red";
763
+ }
764
+ case "GET": {
765
+ return "emerald";
766
+ }
767
+ case "PATCH": {
768
+ return "orange";
769
+ }
770
+ case "POST": {
771
+ return "blue";
772
+ }
773
+ case "PUT": {
774
+ return "orange";
775
+ }
776
+ default: {
777
+ return "neutral";
778
+ }
779
+ }
780
+ };
781
+ const kindTone = (kind) => {
782
+ switch (kind) {
783
+ case "action": {
784
+ return "violet";
785
+ }
786
+ case "mutation": {
787
+ return "orange";
788
+ }
789
+ case "query": {
790
+ return "emerald";
791
+ }
792
+ default: {
793
+ return "neutral";
794
+ }
795
+ }
796
+ };
797
+ const MethodBadge = (t0) => {
798
+ const $ = c(7);
799
+ const {
800
+ kind,
801
+ method,
802
+ testId
803
+ } = t0;
804
+ let t1;
805
+ if ($[0] !== kind || $[1] !== method) {
806
+ t1 = kind ?? method.toUpperCase();
807
+ $[0] = kind;
808
+ $[1] = method;
809
+ $[2] = t1;
810
+ } else {
811
+ t1 = $[2];
812
+ }
813
+ const label = t1;
814
+ const tone = kind === void 0 ? methodTone(method) : kindTone(kind);
815
+ const t2 = `${TONE_CLASS[tone]} font-mono text-[10px] tracking-wide uppercase`;
816
+ let t3;
817
+ if ($[3] !== label || $[4] !== t2 || $[5] !== testId) {
818
+ t3 = /* @__PURE__ */ jsxDEV(Badge$1, {
819
+ className: t2,
820
+ "data-testid": testId,
821
+ variant: "ghost",
822
+ children: label
823
+ }, void 0, false);
824
+ $[3] = label;
825
+ $[4] = t2;
826
+ $[5] = testId;
827
+ $[6] = t3;
828
+ } else {
829
+ t3 = $[6];
830
+ }
831
+ return t3;
832
+ };
833
+
834
+ const statusToneClass = (status) => {
835
+ if (status.startsWith("2")) {
836
+ return "text-emerald-600 dark:text-emerald-400";
837
+ }
838
+ if (status === "default" || status.startsWith("4") || status.startsWith("5")) {
839
+ return "text-red-600 dark:text-red-400";
840
+ }
841
+ return "text-muted-foreground";
842
+ };
843
+ const statusDotClass = (status) => {
844
+ if (status.startsWith("2")) {
845
+ return "bg-emerald-500";
846
+ }
847
+ if (status === "default" || status.startsWith("4") || status.startsWith("5")) {
848
+ return "bg-red-500";
849
+ }
850
+ return "bg-muted-foreground";
851
+ };
852
+
853
+ const seedArgs = (operation) => JSON.stringify(exampleForSchema(operation.argsSchema) ?? {}, void 0, 2);
854
+ const OperationRunContext = /* @__PURE__ */ createContext(null);
855
+ const useOperationRun = () => {
856
+ const value = use(OperationRunContext);
857
+ if (value === null) {
858
+ throw new Error("useOperationRun must be used within an OperationRunProvider");
859
+ }
860
+ return value;
861
+ };
862
+ const OperationRunProvider = ({
863
+ children,
864
+ operation
865
+ }) => {
866
+ const t = useT();
867
+ const client = useLunora();
868
+ const [argsText, setArgsText] = useState(() => seedArgs(operation));
869
+ const [shardKey, setShardKey] = useState("");
870
+ const [status, setStatus] = useState("idle");
871
+ const [response, setResponse] = useState(void 0);
872
+ const [error, setError] = useState(null);
873
+ const [durationMs, setDurationMs] = useState(null);
874
+ const send = async () => {
875
+ let parsedArgs;
876
+ try {
877
+ parsedArgs = argsText.trim() === "" ? {} : JSON.parse(argsText);
878
+ } catch (parseError) {
879
+ setStatus("error");
880
+ setResponse(void 0);
881
+ setDurationMs(null);
882
+ setError(t("Invalid JSON args: {message}", {
883
+ message: errorMessage(parseError)
884
+ }));
885
+ return;
886
+ }
887
+ setStatus("running");
888
+ setError(null);
889
+ const startedAt = performance.now();
890
+ try {
891
+ let value;
892
+ if (operation.functionPath === void 0) {
893
+ const hasBody = operation.method !== "GET" && operation.method !== "HEAD";
894
+ const fetchResponse = await fetch(operation.httpPath, {
895
+ body: hasBody ? JSON.stringify(parsedArgs) : void 0,
896
+ headers: hasBody ? {
897
+ "content-type": "application/json"
898
+ } : void 0,
899
+ method: operation.method
900
+ });
901
+ const text = await fetchResponse.text();
902
+ try {
903
+ value = JSON.parse(text);
904
+ } catch {
905
+ value = text;
906
+ }
907
+ } else {
908
+ const reference = adminRef(operation.functionPath);
909
+ const options = callOptions(shardKey);
910
+ switch (operation.kind) {
911
+ case "action": {
912
+ value = await client.action(reference, parsedArgs, options);
913
+ break;
914
+ }
915
+ case "mutation": {
916
+ value = await client.mutation(reference, parsedArgs, options);
917
+ break;
918
+ }
919
+ default: {
920
+ value = await client.query(reference, parsedArgs, options);
921
+ }
922
+ }
923
+ }
924
+ setResponse(value);
925
+ setDurationMs(Math.round(performance.now() - startedAt));
926
+ setStatus("success");
927
+ } catch (runError) {
928
+ setResponse(void 0);
929
+ setDurationMs(Math.round(performance.now() - startedAt));
930
+ setError(errorMessage(runError));
931
+ setStatus("error");
932
+ }
933
+ };
934
+ const onSend = () => {
935
+ fireAndForget(send());
936
+ };
937
+ const value_0 = {
938
+ argsText,
939
+ durationMs,
940
+ error,
941
+ operation,
942
+ response,
943
+ send: onSend,
944
+ setArgsText,
945
+ setShardKey,
946
+ shardKey,
947
+ status
948
+ };
949
+ return /* @__PURE__ */ jsxDEV(OperationRunContext, {
950
+ value: value_0,
951
+ children
952
+ }, void 0, false);
953
+ };
954
+
955
+ const TryIt = () => {
956
+ const $ = c(48);
957
+ const t = useT();
958
+ const {
959
+ argsText,
960
+ operation,
961
+ send,
962
+ setArgsText,
963
+ setShardKey,
964
+ shardKey,
965
+ status
966
+ } = useOperationRun();
967
+ let t0;
968
+ if ($[0] !== setArgsText) {
969
+ t0 = (event) => {
970
+ setArgsText(event.target.value);
971
+ };
972
+ $[0] = setArgsText;
973
+ $[1] = t0;
974
+ } else {
975
+ t0 = $[1];
976
+ }
977
+ const onArgsChange = t0;
978
+ let t1;
979
+ if ($[2] !== send) {
980
+ t1 = (event_0) => {
981
+ if (event_0.key === "Enter" && (event_0.metaKey || event_0.ctrlKey)) {
982
+ event_0.preventDefault();
983
+ send();
984
+ }
985
+ };
986
+ $[2] = send;
987
+ $[3] = t1;
988
+ } else {
989
+ t1 = $[3];
990
+ }
991
+ const onArgsKeyDown = t1;
992
+ const running = status === "running";
993
+ let t2;
994
+ if ($[4] !== operation.kind || $[5] !== operation.method) {
995
+ t2 = /* @__PURE__ */ jsxDEV(MethodBadge, {
996
+ kind: operation.kind,
997
+ method: operation.method,
998
+ testId: "api-try-method"
999
+ }, void 0, false);
1000
+ $[4] = operation.kind;
1001
+ $[5] = operation.method;
1002
+ $[6] = t2;
1003
+ } else {
1004
+ t2 = $[6];
1005
+ }
1006
+ const t3 = operation.functionPath ?? operation.httpPath;
1007
+ let t4;
1008
+ if ($[7] !== t3) {
1009
+ t4 = /* @__PURE__ */ jsxDEV("code", {
1010
+ className: "min-w-0 flex-1 truncate font-mono text-xs text-foreground",
1011
+ children: t3
1012
+ }, void 0, false);
1013
+ $[7] = t3;
1014
+ $[8] = t4;
1015
+ } else {
1016
+ t4 = $[8];
1017
+ }
1018
+ const t5 = running ? "animate-pulse" : void 0;
1019
+ let t6;
1020
+ if ($[9] !== t5) {
1021
+ t6 = /* @__PURE__ */ jsxDEV(HugeiconsIcon, {
1022
+ className: t5,
1023
+ icon: SentIcon,
1024
+ strokeWidth: 2
1025
+ }, void 0, false);
1026
+ $[9] = t5;
1027
+ $[10] = t6;
1028
+ } else {
1029
+ t6 = $[10];
1030
+ }
1031
+ let t7;
1032
+ if ($[11] !== running || $[12] !== t) {
1033
+ t7 = running ? t("Sending…") : t("Send");
1034
+ $[11] = running;
1035
+ $[12] = t;
1036
+ $[13] = t7;
1037
+ } else {
1038
+ t7 = $[13];
1039
+ }
1040
+ let t8;
1041
+ if ($[14] !== running || $[15] !== send || $[16] !== t6 || $[17] !== t7) {
1042
+ t8 = /* @__PURE__ */ jsxDEV(Button, {
1043
+ "data-testid": "api-try-send",
1044
+ disabled: running,
1045
+ onClick: send,
1046
+ size: "sm",
1047
+ type: "button",
1048
+ children: [t6, t7]
1049
+ }, void 0, true);
1050
+ $[14] = running;
1051
+ $[15] = send;
1052
+ $[16] = t6;
1053
+ $[17] = t7;
1054
+ $[18] = t8;
1055
+ } else {
1056
+ t8 = $[18];
1057
+ }
1058
+ let t9;
1059
+ if ($[19] !== t2 || $[20] !== t4 || $[21] !== t8) {
1060
+ t9 = /* @__PURE__ */ jsxDEV("div", {
1061
+ className: "flex items-center gap-2 border-b border-border bg-muted px-3 py-2",
1062
+ children: [t2, t4, t8]
1063
+ }, void 0, true);
1064
+ $[19] = t2;
1065
+ $[20] = t4;
1066
+ $[21] = t8;
1067
+ $[22] = t9;
1068
+ } else {
1069
+ t9 = $[22];
1070
+ }
1071
+ let t10;
1072
+ if ($[23] !== t) {
1073
+ t10 = t("Arguments (JSON)");
1074
+ $[23] = t;
1075
+ $[24] = t10;
1076
+ } else {
1077
+ t10 = $[24];
1078
+ }
1079
+ let t11;
1080
+ if ($[25] !== t10) {
1081
+ t11 = /* @__PURE__ */ jsxDEV(Label, {
1082
+ htmlFor: "api-try-args",
1083
+ children: t10
1084
+ }, void 0, false);
1085
+ $[25] = t10;
1086
+ $[26] = t11;
1087
+ } else {
1088
+ t11 = $[26];
1089
+ }
1090
+ let t12;
1091
+ if ($[27] !== argsText) {
1092
+ t12 = argsText.split("\n");
1093
+ $[27] = argsText;
1094
+ $[28] = t12;
1095
+ } else {
1096
+ t12 = $[28];
1097
+ }
1098
+ const t13 = Math.min(12, Math.max(3, t12.length));
1099
+ let t14;
1100
+ if ($[29] !== argsText || $[30] !== onArgsChange || $[31] !== onArgsKeyDown || $[32] !== t13) {
1101
+ t14 = /* @__PURE__ */ jsxDEV(Textarea, {
1102
+ className: "font-mono text-xs",
1103
+ "data-testid": "api-try-args",
1104
+ id: "api-try-args",
1105
+ onChange: onArgsChange,
1106
+ onKeyDown: onArgsKeyDown,
1107
+ rows: t13,
1108
+ spellCheck: false,
1109
+ value: argsText
1110
+ }, void 0, false);
1111
+ $[29] = argsText;
1112
+ $[30] = onArgsChange;
1113
+ $[31] = onArgsKeyDown;
1114
+ $[32] = t13;
1115
+ $[33] = t14;
1116
+ } else {
1117
+ t14 = $[33];
1118
+ }
1119
+ let t15;
1120
+ if ($[34] !== t11 || $[35] !== t14) {
1121
+ t15 = /* @__PURE__ */ jsxDEV("div", {
1122
+ className: "flex flex-col gap-1.5",
1123
+ children: [t11, t14]
1124
+ }, void 0, true);
1125
+ $[34] = t11;
1126
+ $[35] = t14;
1127
+ $[36] = t15;
1128
+ } else {
1129
+ t15 = $[36];
1130
+ }
1131
+ let t16;
1132
+ if ($[37] !== operation.functionPath || $[38] !== setShardKey || $[39] !== shardKey || $[40] !== t) {
1133
+ t16 = operation.functionPath !== void 0 && /* @__PURE__ */ jsxDEV("div", {
1134
+ className: "flex flex-col gap-1.5",
1135
+ children: [/* @__PURE__ */ jsxDEV(Label, {
1136
+ htmlFor: "shard-input",
1137
+ children: t("Shard key (optional)")
1138
+ }, void 0, false), /* @__PURE__ */ jsxDEV(ShardInput, {
1139
+ id: "shard-input",
1140
+ onChange: setShardKey,
1141
+ testId: "shard-input",
1142
+ value: shardKey
1143
+ }, void 0, false)]
1144
+ }, void 0, true);
1145
+ $[37] = operation.functionPath;
1146
+ $[38] = setShardKey;
1147
+ $[39] = shardKey;
1148
+ $[40] = t;
1149
+ $[41] = t16;
1150
+ } else {
1151
+ t16 = $[41];
1152
+ }
1153
+ let t17;
1154
+ if ($[42] !== t15 || $[43] !== t16) {
1155
+ t17 = /* @__PURE__ */ jsxDEV("div", {
1156
+ className: "flex flex-col gap-3 p-3",
1157
+ children: [t15, t16]
1158
+ }, void 0, true);
1159
+ $[42] = t15;
1160
+ $[43] = t16;
1161
+ $[44] = t17;
1162
+ } else {
1163
+ t17 = $[44];
1164
+ }
1165
+ let t18;
1166
+ if ($[45] !== t17 || $[46] !== t9) {
1167
+ t18 = /* @__PURE__ */ jsxDEV("div", {
1168
+ className: "overflow-hidden rounded-xl border border-border bg-card",
1169
+ "data-testid": "api-try-it",
1170
+ children: [t9, t17]
1171
+ }, void 0, true);
1172
+ $[45] = t17;
1173
+ $[46] = t9;
1174
+ $[47] = t18;
1175
+ } else {
1176
+ t18 = $[47];
1177
+ }
1178
+ return t18;
1179
+ };
1180
+
1181
+ const OperationView = (t0) => {
1182
+ const $ = c(51);
1183
+ const {
1184
+ operation
1185
+ } = t0;
1186
+ const t = useT();
1187
+ const t1 = `api-operation-${operation.operationId}`;
1188
+ const t2 = operation.key;
1189
+ let t3;
1190
+ if ($[0] !== operation.kind || $[1] !== operation.method) {
1191
+ t3 = /* @__PURE__ */ jsxDEV(MethodBadge, {
1192
+ kind: operation.kind,
1193
+ method: operation.method,
1194
+ testId: "api-operation-method"
1195
+ }, void 0, false);
1196
+ $[0] = operation.kind;
1197
+ $[1] = operation.method;
1198
+ $[2] = t3;
1199
+ } else {
1200
+ t3 = $[2];
1201
+ }
1202
+ const t4 = operation.functionPath ?? operation.httpPath;
1203
+ let t5;
1204
+ if ($[3] !== t4) {
1205
+ t5 = /* @__PURE__ */ jsxDEV("code", {
1206
+ className: "truncate font-mono text-xs text-muted-foreground",
1207
+ children: t4
1208
+ }, void 0, false);
1209
+ $[3] = t4;
1210
+ $[4] = t5;
1211
+ } else {
1212
+ t5 = $[4];
1213
+ }
1214
+ let t6;
1215
+ if ($[5] !== t3 || $[6] !== t5) {
1216
+ t6 = /* @__PURE__ */ jsxDEV("div", {
1217
+ className: "flex items-center gap-2",
1218
+ children: [t3, t5]
1219
+ }, void 0, true);
1220
+ $[5] = t3;
1221
+ $[6] = t5;
1222
+ $[7] = t6;
1223
+ } else {
1224
+ t6 = $[7];
1225
+ }
1226
+ let t7;
1227
+ if ($[8] !== operation.title) {
1228
+ t7 = /* @__PURE__ */ jsxDEV("h1", {
1229
+ className: "text-lg font-semibold text-foreground",
1230
+ "data-testid": "api-operation-title",
1231
+ children: operation.title
1232
+ }, void 0, false);
1233
+ $[8] = operation.title;
1234
+ $[9] = t7;
1235
+ } else {
1236
+ t7 = $[9];
1237
+ }
1238
+ let t8;
1239
+ if ($[10] !== operation.description) {
1240
+ t8 = operation.description !== void 0 && /* @__PURE__ */ jsxDEV("p", {
1241
+ className: "text-sm text-muted-foreground",
1242
+ children: operation.description
1243
+ }, void 0, false);
1244
+ $[10] = operation.description;
1245
+ $[11] = t8;
1246
+ } else {
1247
+ t8 = $[11];
1248
+ }
1249
+ let t9;
1250
+ if ($[12] !== t6 || $[13] !== t7 || $[14] !== t8) {
1251
+ t9 = /* @__PURE__ */ jsxDEV("header", {
1252
+ className: "sticky top-0 z-10 -mx-6 -mt-6 flex flex-col gap-2 border-b border-border bg-background px-6 pt-6 pb-3",
1253
+ children: [t6, t7, t8]
1254
+ }, void 0, true);
1255
+ $[12] = t6;
1256
+ $[13] = t7;
1257
+ $[14] = t8;
1258
+ $[15] = t9;
1259
+ } else {
1260
+ t9 = $[15];
1261
+ }
1262
+ let t10;
1263
+ if ($[16] !== t) {
1264
+ t10 = t("Try it");
1265
+ $[16] = t;
1266
+ $[17] = t10;
1267
+ } else {
1268
+ t10 = $[17];
1269
+ }
1270
+ let t11;
1271
+ if ($[18] !== t10) {
1272
+ t11 = /* @__PURE__ */ jsxDEV("h2", {
1273
+ className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
1274
+ children: t10
1275
+ }, void 0, false);
1276
+ $[18] = t10;
1277
+ $[19] = t11;
1278
+ } else {
1279
+ t11 = $[19];
1280
+ }
1281
+ let t12;
1282
+ if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1283
+ t12 = /* @__PURE__ */ jsxDEV(TryIt, {}, void 0, false);
1284
+ $[20] = t12;
1285
+ } else {
1286
+ t12 = $[20];
1287
+ }
1288
+ let t13;
1289
+ if ($[21] !== t11) {
1290
+ t13 = /* @__PURE__ */ jsxDEV("section", {
1291
+ className: "flex flex-col gap-2",
1292
+ children: [t11, t12]
1293
+ }, void 0, true);
1294
+ $[21] = t11;
1295
+ $[22] = t13;
1296
+ } else {
1297
+ t13 = $[22];
1298
+ }
1299
+ let t14;
1300
+ if ($[23] !== t) {
1301
+ t14 = t("Request arguments");
1302
+ $[23] = t;
1303
+ $[24] = t14;
1304
+ } else {
1305
+ t14 = $[24];
1306
+ }
1307
+ let t15;
1308
+ if ($[25] !== t14) {
1309
+ t15 = /* @__PURE__ */ jsxDEV("h2", {
1310
+ className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
1311
+ children: t14
1312
+ }, void 0, false);
1313
+ $[25] = t14;
1314
+ $[26] = t15;
1315
+ } else {
1316
+ t15 = $[26];
1317
+ }
1318
+ let t16;
1319
+ if ($[27] !== operation.argsSchema) {
1320
+ t16 = /* @__PURE__ */ jsxDEV(SchemaTable, {
1321
+ schema: operation.argsSchema,
1322
+ testId: "api-operation-args"
1323
+ }, void 0, false);
1324
+ $[27] = operation.argsSchema;
1325
+ $[28] = t16;
1326
+ } else {
1327
+ t16 = $[28];
1328
+ }
1329
+ let t17;
1330
+ if ($[29] !== t15 || $[30] !== t16) {
1331
+ t17 = /* @__PURE__ */ jsxDEV("section", {
1332
+ className: "flex flex-col gap-2",
1333
+ children: [t15, t16]
1334
+ }, void 0, true);
1335
+ $[29] = t15;
1336
+ $[30] = t16;
1337
+ $[31] = t17;
1338
+ } else {
1339
+ t17 = $[31];
1340
+ }
1341
+ let t18;
1342
+ if ($[32] !== t) {
1343
+ t18 = t("Response body");
1344
+ $[32] = t;
1345
+ $[33] = t18;
1346
+ } else {
1347
+ t18 = $[33];
1348
+ }
1349
+ let t19;
1350
+ if ($[34] !== t18) {
1351
+ t19 = /* @__PURE__ */ jsxDEV("h2", {
1352
+ className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
1353
+ children: t18
1354
+ }, void 0, false);
1355
+ $[34] = t18;
1356
+ $[35] = t19;
1357
+ } else {
1358
+ t19 = $[35];
1359
+ }
1360
+ let t20;
1361
+ if ($[36] !== operation.responses || $[37] !== t) {
1362
+ let t212;
1363
+ if ($[39] !== t) {
1364
+ t212 = (response) => /* @__PURE__ */ jsxDEV("div", {
1365
+ className: "flex flex-col gap-1.5 rounded-xl border border-border bg-card p-3",
1366
+ children: [/* @__PURE__ */ jsxDEV("div", {
1367
+ className: "flex items-center justify-between gap-2",
1368
+ children: [/* @__PURE__ */ jsxDEV("span", {
1369
+ className: `inline-flex items-center gap-1.5 font-mono text-xs font-semibold ${statusToneClass(response.status)}`,
1370
+ children: [/* @__PURE__ */ jsxDEV("span", {
1371
+ className: `size-1.5 rounded-full ${statusDotClass(response.status)}`
1372
+ }, void 0, false), response.status]
1373
+ }, void 0, true), response.schema !== void 0 && /* @__PURE__ */ jsxDEV("span", {
1374
+ className: "rounded border border-border px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",
1375
+ children: t("application/json")
1376
+ }, void 0, false)]
1377
+ }, void 0, true), response.description !== void 0 && /* @__PURE__ */ jsxDEV("p", {
1378
+ className: "text-xs text-muted-foreground",
1379
+ children: response.description
1380
+ }, void 0, false), response.schema !== void 0 && /* @__PURE__ */ jsxDEV(SchemaTable, {
1381
+ schema: response.schema,
1382
+ testId: `api-response-${response.status}`
1383
+ }, void 0, false)]
1384
+ }, response.status, true);
1385
+ $[39] = t;
1386
+ $[40] = t212;
1387
+ } else {
1388
+ t212 = $[40];
1389
+ }
1390
+ t20 = operation.responses.map(t212);
1391
+ $[36] = operation.responses;
1392
+ $[37] = t;
1393
+ $[38] = t20;
1394
+ } else {
1395
+ t20 = $[38];
1396
+ }
1397
+ let t21;
1398
+ if ($[41] !== t19 || $[42] !== t20) {
1399
+ t21 = /* @__PURE__ */ jsxDEV("section", {
1400
+ className: "flex flex-col gap-3",
1401
+ children: [t19, t20]
1402
+ }, void 0, true);
1403
+ $[41] = t19;
1404
+ $[42] = t20;
1405
+ $[43] = t21;
1406
+ } else {
1407
+ t21 = $[43];
1408
+ }
1409
+ let t22;
1410
+ if ($[44] !== operation.key || $[45] !== t1 || $[46] !== t13 || $[47] !== t17 || $[48] !== t21 || $[49] !== t9) {
1411
+ t22 = /* @__PURE__ */ jsxDEV("div", {
1412
+ className: "flex flex-col gap-6 duration-200 animate-in fade-in-0 slide-in-from-bottom-1",
1413
+ "data-testid": t1,
1414
+ children: [t9, t13, t17, t21]
1415
+ }, t2, true);
1416
+ $[44] = operation.key;
1417
+ $[45] = t1;
1418
+ $[46] = t13;
1419
+ $[47] = t17;
1420
+ $[48] = t21;
1421
+ $[49] = t9;
1422
+ $[50] = t22;
1423
+ } else {
1424
+ t22 = $[50];
1425
+ }
1426
+ return t22;
1427
+ };
1428
+
1429
+ const KIND_CLASS = {
1430
+ boolean: "text-royal-amethyst",
1431
+ key: "text-sky-sapphire",
1432
+ number: "text-warning",
1433
+ plain: "",
1434
+ string: "text-success"
1435
+ };
1436
+ const TOKEN = /"(?:[^"\\]|\\.)*"|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?/g;
1437
+ const COLON_AHEAD = /^\s*:/;
1438
+ const classify = (code, end, text) => {
1439
+ if (text.startsWith('"')) {
1440
+ return COLON_AHEAD.test(code.slice(end)) ? "key" : "string";
1441
+ }
1442
+ if (text === "true" || text === "false" || text === "null") {
1443
+ return "boolean";
1444
+ }
1445
+ return "number";
1446
+ };
1447
+ const tokenize = (code) => {
1448
+ const tokens = [];
1449
+ let lastIndex = 0;
1450
+ for (const match of code.matchAll(TOKEN)) {
1451
+ const {
1452
+ index
1453
+ } = match;
1454
+ const text = match[0];
1455
+ const end = index + text.length;
1456
+ if (index > lastIndex) {
1457
+ tokens.push({
1458
+ kind: "plain",
1459
+ start: lastIndex,
1460
+ text: code.slice(lastIndex, index)
1461
+ });
1462
+ }
1463
+ tokens.push({
1464
+ kind: classify(code, end, text),
1465
+ start: index,
1466
+ text
1467
+ });
1468
+ lastIndex = end;
1469
+ }
1470
+ if (lastIndex < code.length) {
1471
+ tokens.push({
1472
+ kind: "plain",
1473
+ start: lastIndex,
1474
+ text: code.slice(lastIndex)
1475
+ });
1476
+ }
1477
+ return tokens;
1478
+ };
1479
+ const JsonHighlight = (t0) => {
1480
+ const $ = c(4);
1481
+ const {
1482
+ code
1483
+ } = t0;
1484
+ let t1;
1485
+ if ($[0] !== code) {
1486
+ const tokens = tokenize(code);
1487
+ t1 = tokens.map(_temp$1);
1488
+ $[0] = code;
1489
+ $[1] = t1;
1490
+ } else {
1491
+ t1 = $[1];
1492
+ }
1493
+ let t2;
1494
+ if ($[2] !== t1) {
1495
+ t2 = /* @__PURE__ */ jsxDEV(Fragment, {
1496
+ children: t1
1497
+ }, void 0, false);
1498
+ $[2] = t1;
1499
+ $[3] = t2;
1500
+ } else {
1501
+ t2 = $[3];
1502
+ }
1503
+ return t2;
1504
+ };
1505
+ function _temp$1(token) {
1506
+ return /* @__PURE__ */ jsxDEV("span", {
1507
+ className: KIND_CLASS[token.kind],
1508
+ children: token.text
1509
+ }, token.start, false);
1510
+ }
1511
+
1512
+ const LIVE_TAB = "__live__";
1513
+ const exampleBody = (response) => response.schema === void 0 ? "" : JSON.stringify(exampleForSchema(response.schema), void 0, 2);
1514
+ const liveBody = (error, response, failed) => {
1515
+ if (failed) {
1516
+ return error ?? "";
1517
+ }
1518
+ return response === void 0 ? "" : JSON.stringify(response, void 0, 2);
1519
+ };
1520
+ const ResponseBody = (t0) => {
1521
+ const $ = c(18);
1522
+ const {
1523
+ active,
1524
+ running,
1525
+ showError
1526
+ } = t0;
1527
+ const t = useT();
1528
+ if (running) {
1529
+ let t12;
1530
+ if ($[0] !== t) {
1531
+ t12 = t("Sending…");
1532
+ $[0] = t;
1533
+ $[1] = t12;
1534
+ } else {
1535
+ t12 = $[1];
1536
+ }
1537
+ let t22;
1538
+ if ($[2] !== t12) {
1539
+ t22 = /* @__PURE__ */ jsxDEV("p", {
1540
+ className: "px-3 py-3 text-xs text-muted-foreground",
1541
+ "data-testid": "api-response-running",
1542
+ children: t12
1543
+ }, void 0, false);
1544
+ $[2] = t12;
1545
+ $[3] = t22;
1546
+ } else {
1547
+ t22 = $[3];
1548
+ }
1549
+ return t22;
1550
+ }
1551
+ if (active === void 0 || active.body === "") {
1552
+ let t12;
1553
+ if ($[4] !== active?.live || $[5] !== t) {
1554
+ t12 = active?.live === true ? t("Send a request to see the response.") : t("No example for this response.");
1555
+ $[4] = active?.live;
1556
+ $[5] = t;
1557
+ $[6] = t12;
1558
+ } else {
1559
+ t12 = $[6];
1560
+ }
1561
+ let t22;
1562
+ if ($[7] !== t12) {
1563
+ t22 = /* @__PURE__ */ jsxDEV("p", {
1564
+ className: "px-3 py-3 text-xs text-muted-foreground",
1565
+ "data-testid": "api-response-idle",
1566
+ children: t12
1567
+ }, void 0, false);
1568
+ $[7] = t12;
1569
+ $[8] = t22;
1570
+ } else {
1571
+ t22 = $[8];
1572
+ }
1573
+ return t22;
1574
+ }
1575
+ const t1 = showError && "text-destructive";
1576
+ let t2;
1577
+ if ($[9] !== t1) {
1578
+ t2 = cn("max-h-[28rem] overflow-auto px-3 py-3 font-mono text-xs", t1);
1579
+ $[9] = t1;
1580
+ $[10] = t2;
1581
+ } else {
1582
+ t2 = $[10];
1583
+ }
1584
+ const t3 = showError ? "api-response-error" : "api-response-body";
1585
+ let t4;
1586
+ if ($[11] !== active.body || $[12] !== showError) {
1587
+ t4 = showError ? active.body : /* @__PURE__ */ jsxDEV(JsonHighlight, {
1588
+ code: active.body
1589
+ }, void 0, false);
1590
+ $[11] = active.body;
1591
+ $[12] = showError;
1592
+ $[13] = t4;
1593
+ } else {
1594
+ t4 = $[13];
1595
+ }
1596
+ let t5;
1597
+ if ($[14] !== t2 || $[15] !== t3 || $[16] !== t4) {
1598
+ t5 = /* @__PURE__ */ jsxDEV("pre", {
1599
+ className: t2,
1600
+ "data-testid": t3,
1601
+ children: t4
1602
+ }, void 0, false);
1603
+ $[14] = t2;
1604
+ $[15] = t3;
1605
+ $[16] = t4;
1606
+ $[17] = t5;
1607
+ } else {
1608
+ t5 = $[17];
1609
+ }
1610
+ return t5;
1611
+ };
1612
+ const ResponsePanel = () => {
1613
+ const $ = c(67);
1614
+ const t = useT();
1615
+ const {
1616
+ durationMs,
1617
+ error,
1618
+ operation,
1619
+ response,
1620
+ status
1621
+ } = useOperationRun();
1622
+ const running = status === "running";
1623
+ const failed = status === "error";
1624
+ const ran = status === "success" || failed;
1625
+ let t0;
1626
+ if ($[0] !== durationMs || $[1] !== error || $[2] !== failed || $[3] !== operation.responses || $[4] !== ran || $[5] !== response || $[6] !== t) {
1627
+ bb0: {
1628
+ const documented = operation.responses.map(_temp);
1629
+ if (!ran) {
1630
+ t0 = documented;
1631
+ break bb0;
1632
+ }
1633
+ let t14;
1634
+ if ($[8] !== error || $[9] !== failed || $[10] !== response) {
1635
+ t14 = liveBody(error, response, failed);
1636
+ $[8] = error;
1637
+ $[9] = failed;
1638
+ $[10] = response;
1639
+ $[11] = t14;
1640
+ } else {
1641
+ t14 = $[11];
1642
+ }
1643
+ let t22;
1644
+ if ($[12] !== t) {
1645
+ t22 = t("Live");
1646
+ $[12] = t;
1647
+ $[13] = t22;
1648
+ } else {
1649
+ t22 = $[13];
1650
+ }
1651
+ const t32 = failed ? "error" : "200";
1652
+ let t42;
1653
+ if ($[14] !== durationMs || $[15] !== t14 || $[16] !== t22 || $[17] !== t32) {
1654
+ t42 = {
1655
+ body: t14,
1656
+ durationMs,
1657
+ id: LIVE_TAB,
1658
+ label: t22,
1659
+ live: true,
1660
+ status: t32
1661
+ };
1662
+ $[14] = durationMs;
1663
+ $[15] = t14;
1664
+ $[16] = t22;
1665
+ $[17] = t32;
1666
+ $[18] = t42;
1667
+ } else {
1668
+ t42 = $[18];
1669
+ }
1670
+ const live = t42;
1671
+ t0 = [live, ...documented];
1672
+ }
1673
+ $[0] = durationMs;
1674
+ $[1] = error;
1675
+ $[2] = failed;
1676
+ $[3] = operation.responses;
1677
+ $[4] = ran;
1678
+ $[5] = response;
1679
+ $[6] = t;
1680
+ $[7] = t0;
1681
+ } else {
1682
+ t0 = $[7];
1683
+ }
1684
+ const tabs = t0;
1685
+ let t1;
1686
+ if ($[19] !== ran || $[20] !== tabs) {
1687
+ t1 = ran ? LIVE_TAB : tabs.find(_temp2)?.id ?? tabs[0]?.id ?? "";
1688
+ $[19] = ran;
1689
+ $[20] = tabs;
1690
+ $[21] = t1;
1691
+ } else {
1692
+ t1 = $[21];
1693
+ }
1694
+ const defaultId = t1;
1695
+ const [picked, setPicked] = useState(null);
1696
+ let active;
1697
+ let onCopy;
1698
+ let onSelect;
1699
+ let showError;
1700
+ let t2;
1701
+ let t3;
1702
+ let t4;
1703
+ let t5;
1704
+ let t6;
1705
+ let t7;
1706
+ if ($[22] !== defaultId || $[23] !== picked || $[24] !== t || $[25] !== tabs) {
1707
+ active = tabs.find((tab_0) => tab_0.id === (picked ?? defaultId)) ?? tabs[0];
1708
+ let t82;
1709
+ if ($[36] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1710
+ t82 = (event) => {
1711
+ const {
1712
+ id
1713
+ } = event.currentTarget.dataset;
1714
+ if (id !== void 0) {
1715
+ setPicked(id);
1716
+ }
1717
+ };
1718
+ $[36] = t82;
1719
+ } else {
1720
+ t82 = $[36];
1721
+ }
1722
+ onSelect = t82;
1723
+ onCopy = () => {
1724
+ if (active !== void 0) {
1725
+ copyToClipboard(active.body);
1726
+ }
1727
+ };
1728
+ const liveDurationMs = active?.live === true ? active.durationMs : null;
1729
+ showError = active?.live === true && active.status === "error";
1730
+ t6 = "flex min-h-0 flex-col rounded-xl border border-border bg-card";
1731
+ t7 = "api-response-panel";
1732
+ t4 = "flex items-center justify-between gap-2 border-b border-border px-3 py-2";
1733
+ let t92;
1734
+ if ($[37] !== t) {
1735
+ t92 = t("Response");
1736
+ $[37] = t;
1737
+ $[38] = t92;
1738
+ } else {
1739
+ t92 = $[38];
1740
+ }
1741
+ if ($[39] !== t92) {
1742
+ t5 = /* @__PURE__ */ jsxDEV("span", {
1743
+ className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
1744
+ children: t92
1745
+ }, void 0, false);
1746
+ $[39] = t92;
1747
+ $[40] = t5;
1748
+ } else {
1749
+ t5 = $[40];
1750
+ }
1751
+ t2 = "flex items-center gap-2";
1752
+ t3 = liveDurationMs !== null && /* @__PURE__ */ jsxDEV("span", {
1753
+ className: "font-mono text-[10px] text-muted-foreground",
1754
+ children: t("{ms} ms", {
1755
+ ms: liveDurationMs
1756
+ })
1757
+ }, void 0, false);
1758
+ $[22] = defaultId;
1759
+ $[23] = picked;
1760
+ $[24] = t;
1761
+ $[25] = tabs;
1762
+ $[26] = active;
1763
+ $[27] = onCopy;
1764
+ $[28] = onSelect;
1765
+ $[29] = showError;
1766
+ $[30] = t2;
1767
+ $[31] = t3;
1768
+ $[32] = t4;
1769
+ $[33] = t5;
1770
+ $[34] = t6;
1771
+ $[35] = t7;
1772
+ } else {
1773
+ active = $[26];
1774
+ onCopy = $[27];
1775
+ onSelect = $[28];
1776
+ showError = $[29];
1777
+ t2 = $[30];
1778
+ t3 = $[31];
1779
+ t4 = $[32];
1780
+ t5 = $[33];
1781
+ t6 = $[34];
1782
+ t7 = $[35];
1783
+ }
1784
+ let t8;
1785
+ if ($[41] !== active || $[42] !== onCopy || $[43] !== t) {
1786
+ t8 = active !== void 0 && active.body !== "" && /* @__PURE__ */ jsxDEV(Button, {
1787
+ "aria-label": t("Copy"),
1788
+ "data-testid": "api-response-copy",
1789
+ onClick: onCopy,
1790
+ size: "icon-xs",
1791
+ type: "button",
1792
+ variant: "ghost",
1793
+ children: /* @__PURE__ */ jsxDEV(HugeiconsIcon, {
1794
+ icon: Copy01Icon,
1795
+ strokeWidth: 2
1796
+ }, void 0, false)
1797
+ }, void 0, false);
1798
+ $[41] = active;
1799
+ $[42] = onCopy;
1800
+ $[43] = t;
1801
+ $[44] = t8;
1802
+ } else {
1803
+ t8 = $[44];
1804
+ }
1805
+ let t9;
1806
+ if ($[45] !== t2 || $[46] !== t3 || $[47] !== t8) {
1807
+ t9 = /* @__PURE__ */ jsxDEV("div", {
1808
+ className: t2,
1809
+ children: [t3, t8]
1810
+ }, void 0, true);
1811
+ $[45] = t2;
1812
+ $[46] = t3;
1813
+ $[47] = t8;
1814
+ $[48] = t9;
1815
+ } else {
1816
+ t9 = $[48];
1817
+ }
1818
+ let t10;
1819
+ if ($[49] !== t4 || $[50] !== t5 || $[51] !== t9) {
1820
+ t10 = /* @__PURE__ */ jsxDEV("div", {
1821
+ className: t4,
1822
+ children: [t5, t9]
1823
+ }, void 0, true);
1824
+ $[49] = t4;
1825
+ $[50] = t5;
1826
+ $[51] = t9;
1827
+ $[52] = t10;
1828
+ } else {
1829
+ t10 = $[52];
1830
+ }
1831
+ let t11;
1832
+ if ($[53] !== active?.id || $[54] !== onSelect || $[55] !== tabs) {
1833
+ t11 = tabs.length > 0 && /* @__PURE__ */ jsxDEV("div", {
1834
+ className: "flex gap-1 overflow-x-auto border-b border-border px-2 py-1.5",
1835
+ role: "tablist",
1836
+ children: tabs.map((tab_1) => {
1837
+ const selected = tab_1.id === active?.id;
1838
+ return /* @__PURE__ */ jsxDEV("button", {
1839
+ "aria-selected": selected,
1840
+ className: cn("inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-mono text-xs transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium", selected ? statusToneClass(tab_1.status) : "text-muted-foreground"),
1841
+ "data-id": tab_1.id,
1842
+ "data-testid": tab_1.live ? "api-response-tab-live" : `api-response-tab-${tab_1.status}`,
1843
+ onClick: onSelect,
1844
+ role: "tab",
1845
+ type: "button",
1846
+ children: [/* @__PURE__ */ jsxDEV("span", {
1847
+ className: `size-1.5 rounded-full ${statusDotClass(tab_1.status)}`
1848
+ }, void 0, false), tab_1.label]
1849
+ }, tab_1.id, true);
1850
+ })
1851
+ }, void 0, false);
1852
+ $[53] = active?.id;
1853
+ $[54] = onSelect;
1854
+ $[55] = tabs;
1855
+ $[56] = t11;
1856
+ } else {
1857
+ t11 = $[56];
1858
+ }
1859
+ let t12;
1860
+ if ($[57] !== active || $[58] !== running || $[59] !== showError) {
1861
+ t12 = /* @__PURE__ */ jsxDEV(ResponseBody, {
1862
+ active,
1863
+ running,
1864
+ showError
1865
+ }, void 0, false);
1866
+ $[57] = active;
1867
+ $[58] = running;
1868
+ $[59] = showError;
1869
+ $[60] = t12;
1870
+ } else {
1871
+ t12 = $[60];
1872
+ }
1873
+ let t13;
1874
+ if ($[61] !== t10 || $[62] !== t11 || $[63] !== t12 || $[64] !== t6 || $[65] !== t7) {
1875
+ t13 = /* @__PURE__ */ jsxDEV("div", {
1876
+ className: t6,
1877
+ "data-testid": t7,
1878
+ children: [t10, t11, t12]
1879
+ }, void 0, true);
1880
+ $[61] = t10;
1881
+ $[62] = t11;
1882
+ $[63] = t12;
1883
+ $[64] = t6;
1884
+ $[65] = t7;
1885
+ $[66] = t13;
1886
+ } else {
1887
+ t13 = $[66];
1888
+ }
1889
+ return t13;
1890
+ };
1891
+ function _temp(entry) {
1892
+ return {
1893
+ body: exampleBody(entry),
1894
+ durationMs: null,
1895
+ id: entry.status,
1896
+ label: entry.status,
1897
+ live: false,
1898
+ status: entry.status
1899
+ };
1900
+ }
1901
+ function _temp2(tab) {
1902
+ return tab.status.startsWith("2");
1903
+ }
1904
+
1905
+ const filterGroups = (groups, query) => {
1906
+ const needle = query.trim().toLowerCase();
1907
+ if (needle === "") {
1908
+ return groups;
1909
+ }
1910
+ return groups.map((group) => {
1911
+ return {
1912
+ ...group,
1913
+ operations: group.operations.filter((operation) => `${operation.summary} ${operation.operationId}`.toLowerCase().includes(needle))
1914
+ };
1915
+ }).filter((group) => group.operations.length > 0);
1916
+ };
1917
+ const ReferenceView = (t0) => {
1918
+ const $ = c(53);
1919
+ const {
1920
+ model
1921
+ } = t0;
1922
+ const t = useT();
1923
+ const firstKey = model.groups[0]?.operations[0]?.key ?? "";
1924
+ const [selectedKey, setSelectedKey] = useState(firstKey);
1925
+ const [filter, setFilter] = useState("");
1926
+ let t1;
1927
+ if ($[0] !== firstKey || $[1] !== model.operationByKey || $[2] !== selectedKey) {
1928
+ t1 = model.operationByKey.get(selectedKey) ?? model.operationByKey.get(firstKey);
1929
+ $[0] = firstKey;
1930
+ $[1] = model.operationByKey;
1931
+ $[2] = selectedKey;
1932
+ $[3] = t1;
1933
+ } else {
1934
+ t1 = $[3];
1935
+ }
1936
+ const selected = t1;
1937
+ let groups;
1938
+ let server;
1939
+ let t2;
1940
+ let t3;
1941
+ let t4;
1942
+ let t5;
1943
+ let t6;
1944
+ let t7;
1945
+ let t8;
1946
+ let t9;
1947
+ if ($[4] !== filter || $[5] !== model.groups || $[6] !== model.server || $[7] !== selected?.key || $[8] !== t) {
1948
+ groups = filterGroups(model.groups, filter);
1949
+ let t102;
1950
+ if ($[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1951
+ t102 = (event) => {
1952
+ const {
1953
+ key
1954
+ } = event.currentTarget.dataset;
1955
+ if (key !== void 0) {
1956
+ setSelectedKey(key);
1957
+ }
1958
+ };
1959
+ $[19] = t102;
1960
+ } else {
1961
+ t102 = $[19];
1962
+ }
1963
+ const onSelect = t102;
1964
+ let t112;
1965
+ if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1966
+ t112 = (event_0) => {
1967
+ setFilter(event_0.target.value);
1968
+ };
1969
+ $[20] = t112;
1970
+ } else {
1971
+ t112 = $[20];
1972
+ }
1973
+ const onFilterChange = t112;
1974
+ server = model.server ?? "";
1975
+ t8 = "grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[16rem_minmax(0,1fr)_22rem]";
1976
+ t9 = "api-reference";
1977
+ if ($[21] !== t) {
1978
+ t4 = t("API operations");
1979
+ $[21] = t;
1980
+ $[22] = t4;
1981
+ } else {
1982
+ t4 = $[22];
1983
+ }
1984
+ t5 = "flex min-h-0 flex-col overflow-y-auto border-r border-border";
1985
+ t6 = "api-reference-nav";
1986
+ let t122;
1987
+ if ($[23] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1988
+ t122 = /* @__PURE__ */ jsxDEV(HugeiconsIcon, {
1989
+ className: "pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground",
1990
+ icon: Search01Icon,
1991
+ strokeWidth: 2
1992
+ }, void 0, false);
1993
+ $[23] = t122;
1994
+ } else {
1995
+ t122 = $[23];
1996
+ }
1997
+ let t132;
1998
+ if ($[24] !== t) {
1999
+ t132 = t("Filter operations");
2000
+ $[24] = t;
2001
+ $[25] = t132;
2002
+ } else {
2003
+ t132 = $[25];
2004
+ }
2005
+ if ($[26] !== filter || $[27] !== t132) {
2006
+ t7 = /* @__PURE__ */ jsxDEV("div", {
2007
+ className: "sticky top-0 z-10 border-b border-border bg-sidebar p-2",
2008
+ children: /* @__PURE__ */ jsxDEV("div", {
2009
+ className: "relative",
2010
+ children: [t122, /* @__PURE__ */ jsxDEV(Input, {
2011
+ className: "h-7 pl-7",
2012
+ "data-testid": "api-filter",
2013
+ onChange: onFilterChange,
2014
+ placeholder: t132,
2015
+ value: filter
2016
+ }, void 0, false)]
2017
+ }, void 0, true)
2018
+ }, void 0, false);
2019
+ $[26] = filter;
2020
+ $[27] = t132;
2021
+ $[28] = t7;
2022
+ } else {
2023
+ t7 = $[28];
2024
+ }
2025
+ t2 = "flex flex-col gap-4 p-2";
2026
+ let t142;
2027
+ if ($[29] !== selected?.key || $[30] !== t) {
2028
+ t142 = (group) => /* @__PURE__ */ jsxDEV("div", {
2029
+ className: "flex flex-col gap-1",
2030
+ children: [/* @__PURE__ */ jsxDEV("div", {
2031
+ className: "flex items-center justify-between px-2",
2032
+ children: [/* @__PURE__ */ jsxDEV("span", {
2033
+ className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
2034
+ children: group.name || t("(root)")
2035
+ }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
2036
+ className: "font-mono text-[10px] text-muted-foreground/70",
2037
+ children: group.operations.length
2038
+ }, void 0, false)]
2039
+ }, void 0, true), group.operations.map((operation) => {
2040
+ const active = operation.key === selected?.key;
2041
+ return /* @__PURE__ */ jsxDEV("button", {
2042
+ "aria-current": active ? "page" : void 0,
2043
+ className: "flex items-center justify-between gap-2 rounded-md border-l-2 border-transparent px-2 py-1 text-start text-xs text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground aria-[current=page]:border-primary aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground",
2044
+ "data-key": operation.key,
2045
+ "data-testid": `api-nav-${operation.operationId}`,
2046
+ onClick: onSelect,
2047
+ type: "button",
2048
+ children: [/* @__PURE__ */ jsxDEV("span", {
2049
+ className: "truncate",
2050
+ children: operation.summary
2051
+ }, void 0, false), /* @__PURE__ */ jsxDEV(MethodBadge, {
2052
+ kind: operation.kind,
2053
+ method: operation.method
2054
+ }, void 0, false)]
2055
+ }, operation.key, true);
2056
+ })]
2057
+ }, group.name, true);
2058
+ $[29] = selected?.key;
2059
+ $[30] = t;
2060
+ $[31] = t142;
2061
+ } else {
2062
+ t142 = $[31];
2063
+ }
2064
+ t3 = groups.map(t142);
2065
+ $[4] = filter;
2066
+ $[5] = model.groups;
2067
+ $[6] = model.server;
2068
+ $[7] = selected?.key;
2069
+ $[8] = t;
2070
+ $[9] = groups;
2071
+ $[10] = server;
2072
+ $[11] = t2;
2073
+ $[12] = t3;
2074
+ $[13] = t4;
2075
+ $[14] = t5;
2076
+ $[15] = t6;
2077
+ $[16] = t7;
2078
+ $[17] = t8;
2079
+ $[18] = t9;
2080
+ } else {
2081
+ groups = $[9];
2082
+ server = $[10];
2083
+ t2 = $[11];
2084
+ t3 = $[12];
2085
+ t4 = $[13];
2086
+ t5 = $[14];
2087
+ t6 = $[15];
2088
+ t7 = $[16];
2089
+ t8 = $[17];
2090
+ t9 = $[18];
2091
+ }
2092
+ let t10;
2093
+ if ($[32] !== groups.length || $[33] !== t) {
2094
+ t10 = groups.length === 0 && /* @__PURE__ */ jsxDEV("p", {
2095
+ className: "px-2 py-1 text-xs text-muted-foreground",
2096
+ "data-testid": "api-nav-empty",
2097
+ children: t("No operations match your filter.")
2098
+ }, void 0, false);
2099
+ $[32] = groups.length;
2100
+ $[33] = t;
2101
+ $[34] = t10;
2102
+ } else {
2103
+ t10 = $[34];
2104
+ }
2105
+ let t11;
2106
+ if ($[35] !== t10 || $[36] !== t2 || $[37] !== t3) {
2107
+ t11 = /* @__PURE__ */ jsxDEV("div", {
2108
+ className: t2,
2109
+ children: [t3, t10]
2110
+ }, void 0, true);
2111
+ $[35] = t10;
2112
+ $[36] = t2;
2113
+ $[37] = t3;
2114
+ $[38] = t11;
2115
+ } else {
2116
+ t11 = $[38];
2117
+ }
2118
+ let t12;
2119
+ if ($[39] !== t11 || $[40] !== t4 || $[41] !== t5 || $[42] !== t6 || $[43] !== t7) {
2120
+ t12 = /* @__PURE__ */ jsxDEV("nav", {
2121
+ "aria-label": t4,
2122
+ className: t5,
2123
+ "data-testid": t6,
2124
+ children: [t7, t11]
2125
+ }, void 0, true);
2126
+ $[39] = t11;
2127
+ $[40] = t4;
2128
+ $[41] = t5;
2129
+ $[42] = t6;
2130
+ $[43] = t7;
2131
+ $[44] = t12;
2132
+ } else {
2133
+ t12 = $[44];
2134
+ }
2135
+ let t13;
2136
+ if ($[45] !== selected || $[46] !== server) {
2137
+ t13 = selected === void 0 ? /* @__PURE__ */ jsxDEV("div", {
2138
+ className: "lg:col-span-2"
2139
+ }, void 0, false) : /* @__PURE__ */ jsxDEV(OperationRunProvider, {
2140
+ operation: selected,
2141
+ children: [/* @__PURE__ */ jsxDEV("div", {
2142
+ className: "min-w-0 overflow-y-auto p-6",
2143
+ "data-testid": "api-reference-main",
2144
+ children: /* @__PURE__ */ jsxDEV(OperationView, {
2145
+ operation: selected
2146
+ }, void 0, false)
2147
+ }, void 0, false), /* @__PURE__ */ jsxDEV("aside", {
2148
+ className: "flex min-w-0 flex-col gap-4 overflow-y-auto border-border p-4 lg:border-l",
2149
+ "data-testid": "api-reference-aside",
2150
+ children: [/* @__PURE__ */ jsxDEV(CodeSamples, {
2151
+ operation: selected,
2152
+ server
2153
+ }, void 0, false), /* @__PURE__ */ jsxDEV(ResponsePanel, {}, void 0, false)]
2154
+ }, void 0, true)]
2155
+ }, selected.key, true);
2156
+ $[45] = selected;
2157
+ $[46] = server;
2158
+ $[47] = t13;
2159
+ } else {
2160
+ t13 = $[47];
2161
+ }
2162
+ let t14;
2163
+ if ($[48] !== t12 || $[49] !== t13 || $[50] !== t8 || $[51] !== t9) {
2164
+ t14 = /* @__PURE__ */ jsxDEV("div", {
2165
+ className: t8,
2166
+ "data-testid": t9,
2167
+ children: [t12, t13]
2168
+ }, void 0, true);
2169
+ $[48] = t12;
2170
+ $[49] = t13;
2171
+ $[50] = t8;
2172
+ $[51] = t9;
2173
+ $[52] = t14;
2174
+ } else {
2175
+ t14 = $[52];
2176
+ }
2177
+ return t14;
2178
+ };
2179
+
2180
+ export { ReferenceView as R, Skeleton as S, useAdminSpec as u };