@nice2dev/ui-api 1.1.9 → 1.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/index.mjs CHANGED
@@ -1,7 +1,2402 @@
1
- import { N as r, a as s, b as a, c } from "./index-COUwI_-v.js";
1
+ import { jsxs as n, jsx as e, Fragment as B } from "react/jsx-runtime";
2
+ import { NiceAppShell as be, NiceButton as j, NiceTextInput as K, NiceTextArea as ae, NiceSelect as te, NiceCheckbox as ve, NiceIcon as Z } from "@nice2dev/ui";
3
+ import { NiceTutorialButton as se, resolveTutorial as re, NiceIcon as z, createId as ee } from "@nice2dev/ui-core";
4
+ import { useState as k, useCallback as I, useRef as ue, useEffect as we, forwardRef as Ce, useMemo as ke } from "react";
5
+ const Te = [
6
+ {
7
+ target: ".nice-api-designer",
8
+ titleKey: "tutorial.apiDesigner.intro.title",
9
+ title: "API designer",
10
+ contentKey: "tutorial.apiDesigner.intro.content",
11
+ content: "Define endpoints, parameters, request/response schemas and security for your OpenAPI document.",
12
+ placement: "auto"
13
+ }
14
+ ], he = {
15
+ openapi: "3.0.3",
16
+ info: {
17
+ title: "Pet Store API",
18
+ version: "1.0.0",
19
+ description: "A sample API that manages a small pet store — list, create and fetch pets. Edit any field; the JSON preview and validation update live."
20
+ },
21
+ servers: [
22
+ { url: "https://api.petstore.example.com/v1", description: "Production" },
23
+ { url: "https://staging.petstore.example.com/v1", description: "Staging" }
24
+ ],
25
+ paths: {
26
+ "/pets": {
27
+ get: {
28
+ operationId: "listPets",
29
+ summary: "List all pets",
30
+ description: "Returns a paged list of pets.",
31
+ tags: ["pets"],
32
+ parameters: [
33
+ {
34
+ name: "limit",
35
+ in: "query",
36
+ description: "Max items to return",
37
+ required: !1,
38
+ schema: { type: "integer", format: "int32" }
39
+ }
40
+ ],
41
+ responses: {
42
+ 200: {
43
+ description: "A paged array of pets",
44
+ content: { "application/json": { schema: { $ref: "#/components/schemas/Pet" } } }
45
+ }
46
+ }
47
+ },
48
+ post: {
49
+ operationId: "createPet",
50
+ summary: "Create a pet",
51
+ tags: ["pets"],
52
+ requestBody: {
53
+ required: !0,
54
+ content: { "application/json": { schema: { $ref: "#/components/schemas/NewPet" } } }
55
+ },
56
+ responses: { 201: { description: "Created" } }
57
+ }
58
+ },
59
+ "/pets/{petId}": {
60
+ get: {
61
+ operationId: "getPetById",
62
+ summary: "Get a pet by id",
63
+ tags: ["pets"],
64
+ parameters: [
65
+ {
66
+ name: "petId",
67
+ in: "path",
68
+ description: "Id of the pet",
69
+ required: !0,
70
+ schema: { type: "string" }
71
+ }
72
+ ],
73
+ responses: {
74
+ 200: {
75
+ description: "A pet",
76
+ content: { "application/json": { schema: { $ref: "#/components/schemas/Pet" } } }
77
+ },
78
+ 404: { description: "Not found" }
79
+ }
80
+ }
81
+ }
82
+ },
83
+ components: {
84
+ schemas: {
85
+ Pet: {
86
+ type: "object",
87
+ description: "A pet in the store.",
88
+ required: ["id", "name"],
89
+ properties: {
90
+ id: { type: "integer", format: "int64" },
91
+ name: { type: "string" },
92
+ tag: { type: "string" },
93
+ status: { type: "string", enum: ["available", "pending", "sold"] }
94
+ }
95
+ },
96
+ NewPet: {
97
+ type: "object",
98
+ required: ["name"],
99
+ properties: {
100
+ name: { type: "string" },
101
+ tag: { type: "string" }
102
+ }
103
+ }
104
+ },
105
+ securitySchemes: {
106
+ apiKey: { type: "apiKey", name: "X-API-Key", in: "header", description: "API key auth." },
107
+ bearerAuth: {
108
+ type: "http",
109
+ scheme: "bearer",
110
+ bearerFormat: "JWT",
111
+ description: "JWT bearer token."
112
+ }
113
+ }
114
+ },
115
+ tags: [{ name: "pets", description: "Pet operations" }]
116
+ }, ye = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], Ee = [
117
+ "object",
118
+ "array",
119
+ "string",
120
+ "number",
121
+ "integer",
122
+ "boolean"
123
+ ], Se = ["query", "path", "header", "cookie"], Pe = ["apiKey", "http", "oauth2", "openIdConnect"];
124
+ function le(t) {
125
+ var o, i;
126
+ const a = [];
127
+ return t.openapi || a.push({ path: "openapi", message: "OpenAPI version is required", severity: "error" }), (o = t.info) != null && o.title || a.push({ path: "info.title", message: "API title is required", severity: "error" }), (i = t.info) != null && i.version || a.push({ path: "info.version", message: "API version is required", severity: "error" }), Object.entries(t.paths || {}).forEach(([c, l]) => {
128
+ c.startsWith("/") || a.push({ path: `paths.${c}`, message: "Path must start with /", severity: "error" }), ye.forEach((d) => {
129
+ const p = l[d.toLowerCase()];
130
+ p && !p.responses && a.push({
131
+ path: `paths.${c}.${d.toLowerCase()}.responses`,
132
+ message: "Responses are required",
133
+ severity: "error"
134
+ });
135
+ });
136
+ }), a;
137
+ }
138
+ const me = Ee.map((t) => ({ value: String(t), label: String(t) }));
139
+ function st({
140
+ schema: t,
141
+ onChange: a,
142
+ onSave: o,
143
+ readOnly: i = !1,
144
+ className: c = "",
145
+ tutorial: l
146
+ }) {
147
+ var H, M;
148
+ const [d, p] = k(t || he), [g, u] = k("/pets"), [f, _] = k("get"), [b, N] = k("paths"), [m, T] = k(
149
+ () => le(t || he)
150
+ ), y = I(
151
+ (w) => {
152
+ p((v) => {
153
+ const x = w(v);
154
+ return a == null || a(x), T(le(x)), x;
155
+ });
156
+ },
157
+ [a]
158
+ ), A = I(() => {
159
+ const w = "/new-endpoint";
160
+ y((v) => ({
161
+ ...v,
162
+ paths: {
163
+ ...v.paths,
164
+ [w]: {
165
+ ...v.paths[w],
166
+ get: { summary: "New endpoint", responses: { 200: { description: "Success" } } }
167
+ }
168
+ }
169
+ })), u(w), _("get");
170
+ }, [y]), U = I(
171
+ (w) => {
172
+ y((v) => {
173
+ const { [w]: x, ...D } = v.paths;
174
+ return { ...v, paths: D };
175
+ }), u(null), _(null);
176
+ },
177
+ [y]
178
+ ), F = I(() => {
179
+ let w = "NewSchema";
180
+ y((v) => {
181
+ var D, L, $;
182
+ let x = 1;
183
+ for (; (L = (D = v.components) == null ? void 0 : D.schemas) != null && L[w]; )
184
+ w = `NewSchema${x++}`;
185
+ return {
186
+ ...v,
187
+ components: {
188
+ ...v.components,
189
+ schemas: { ...($ = v.components) == null ? void 0 : $.schemas, [w]: { type: "object", properties: {} } }
190
+ }
191
+ };
192
+ });
193
+ }, [y]), R = I(() => {
194
+ const w = le(d);
195
+ T(w), w.filter((v) => v.severity === "error").length === 0 && (o == null || o(d));
196
+ }, [d, o]), O = Object.entries(d.paths).flatMap(
197
+ ([w, v]) => ye.filter((x) => v[x.toLowerCase()]).map(
198
+ (x) => ({
199
+ path: w,
200
+ method: x,
201
+ operation: v[x.toLowerCase()]
202
+ })
203
+ )
204
+ ), q = ["info", "paths", "schemas", "security", "preview"];
205
+ return /* @__PURE__ */ n("div", { style: { position: "relative", height: "100%" }, children: [
206
+ l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(se, { steps: re(l, Te) }) }),
207
+ /* @__PURE__ */ e(
208
+ be,
209
+ {
210
+ flush: !0,
211
+ className: `nice-api-designer ${c}`,
212
+ height: "100%",
213
+ style: { minHeight: 600 },
214
+ toolbar: /* @__PURE__ */ n("div", { className: "nice-api-designer__toolbar", children: [
215
+ /* @__PURE__ */ e("div", { className: "nice-api-designer__tabs", children: q.map((w) => /* @__PURE__ */ e(
216
+ j,
217
+ {
218
+ size: "sm",
219
+ variant: b === w ? "primary" : "ghost",
220
+ onClick: () => N(w),
221
+ children: w.charAt(0).toUpperCase() + w.slice(1)
222
+ },
223
+ w
224
+ )) }),
225
+ !i && /* @__PURE__ */ e(
226
+ j,
227
+ {
228
+ size: "sm",
229
+ variant: "primary",
230
+ leftIcon: /* @__PURE__ */ e(z, { name: "check", size: 14 }),
231
+ onClick: R,
232
+ children: "Save"
233
+ }
234
+ )
235
+ ] }),
236
+ bottomPanel: m.length > 0 ? /* @__PURE__ */ e("div", { className: "nice-api-designer__errors", children: m.map((w, v) => /* @__PURE__ */ n(
237
+ "div",
238
+ {
239
+ className: `nice-api-designer__error nice-api-designer__error--${w.severity}`,
240
+ children: [
241
+ /* @__PURE__ */ n("strong", { children: [
242
+ w.path,
243
+ ":"
244
+ ] }),
245
+ " ",
246
+ w.message
247
+ ]
248
+ },
249
+ v
250
+ )) }) : void 0,
251
+ children: /* @__PURE__ */ n("div", { className: "nice-api-designer__content", children: [
252
+ b === "info" && /* @__PURE__ */ e(Ae, { schema: d, onChange: y, readOnly: i }),
253
+ b === "paths" && /* @__PURE__ */ e(
254
+ xe,
255
+ {
256
+ endpoints: O,
257
+ schema: d,
258
+ selectedPath: g,
259
+ selectedMethod: f,
260
+ onSelectEndpoint: (w, v) => {
261
+ u(w), _(v);
262
+ },
263
+ onAdd: A,
264
+ onDelete: U,
265
+ onChange: y,
266
+ readOnly: i
267
+ }
268
+ ),
269
+ b === "schemas" && /* @__PURE__ */ e(
270
+ Ie,
271
+ {
272
+ schemas: ((H = d.components) == null ? void 0 : H.schemas) || {},
273
+ onAdd: F,
274
+ onChange: (w) => y((v) => ({
275
+ ...v,
276
+ components: { ...v.components, schemas: w }
277
+ })),
278
+ readOnly: i
279
+ }
280
+ ),
281
+ b === "security" && /* @__PURE__ */ e(
282
+ $e,
283
+ {
284
+ schemes: ((M = d.components) == null ? void 0 : M.securitySchemes) || {},
285
+ onChange: (w) => y((v) => ({
286
+ ...v,
287
+ components: { ...v.components, securitySchemes: w }
288
+ })),
289
+ readOnly: i
290
+ }
291
+ ),
292
+ b === "preview" && /* @__PURE__ */ e(Re, { schema: d })
293
+ ] })
294
+ }
295
+ )
296
+ ] });
297
+ }
298
+ function Ae({ schema: t, onChange: a, readOnly: o }) {
299
+ return /* @__PURE__ */ n("div", { className: "nice-api-designer__info-editor", children: [
300
+ /* @__PURE__ */ e("h3", { children: "API information" }),
301
+ /* @__PURE__ */ e(
302
+ K,
303
+ {
304
+ label: "Title",
305
+ value: t.info.title,
306
+ onChange: (i) => a((c) => ({ ...c, info: { ...c.info, title: i } })),
307
+ readOnly: o
308
+ }
309
+ ),
310
+ /* @__PURE__ */ e(
311
+ K,
312
+ {
313
+ label: "Version",
314
+ value: t.info.version,
315
+ onChange: (i) => a((c) => ({ ...c, info: { ...c.info, version: i } })),
316
+ readOnly: o
317
+ }
318
+ ),
319
+ /* @__PURE__ */ e(
320
+ ae,
321
+ {
322
+ label: "Description",
323
+ value: t.info.description || "",
324
+ onChange: (i) => a((c) => ({ ...c, info: { ...c.info, description: i } })),
325
+ readOnly: o,
326
+ rows: 4
327
+ }
328
+ ),
329
+ /* @__PURE__ */ e("h4", { children: "Servers" }),
330
+ (t.servers || []).map((i, c) => /* @__PURE__ */ n("div", { className: "nice-api-designer__server", children: [
331
+ /* @__PURE__ */ e(
332
+ K,
333
+ {
334
+ value: i.url,
335
+ placeholder: "Server URL",
336
+ onChange: (l) => a((d) => {
337
+ var p;
338
+ return {
339
+ ...d,
340
+ servers: (p = d.servers) == null ? void 0 : p.map((g, u) => u === c ? { ...g, url: l } : g)
341
+ };
342
+ }),
343
+ readOnly: o
344
+ }
345
+ ),
346
+ /* @__PURE__ */ e(
347
+ K,
348
+ {
349
+ value: i.description || "",
350
+ placeholder: "Description",
351
+ onChange: (l) => a((d) => {
352
+ var p;
353
+ return {
354
+ ...d,
355
+ servers: (p = d.servers) == null ? void 0 : p.map((g, u) => u === c ? { ...g, description: l } : g)
356
+ };
357
+ }),
358
+ readOnly: o
359
+ }
360
+ ),
361
+ !o && /* @__PURE__ */ e(
362
+ j,
363
+ {
364
+ size: "sm",
365
+ variant: "ghost",
366
+ onClick: () => a((l) => {
367
+ var d;
368
+ return {
369
+ ...l,
370
+ servers: (d = l.servers) == null ? void 0 : d.filter((p, g) => g !== c)
371
+ };
372
+ }),
373
+ "aria-label": "Remove server",
374
+ children: /* @__PURE__ */ e(z, { name: "close", size: 14 })
375
+ }
376
+ )
377
+ ] }, c)),
378
+ !o && /* @__PURE__ */ e(
379
+ j,
380
+ {
381
+ size: "sm",
382
+ variant: "outline",
383
+ leftIcon: /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
384
+ onClick: () => a((i) => ({
385
+ ...i,
386
+ servers: [...i.servers || [], { url: "https://api.example.com" }]
387
+ })),
388
+ children: "Add server"
389
+ }
390
+ )
391
+ ] });
392
+ }
393
+ function xe({
394
+ endpoints: t,
395
+ schema: a,
396
+ selectedPath: o,
397
+ selectedMethod: i,
398
+ onSelectEndpoint: c,
399
+ onAdd: l,
400
+ onDelete: d,
401
+ onChange: p,
402
+ readOnly: g
403
+ }) {
404
+ var b;
405
+ const u = o && i ? (b = a.paths[o]) == null ? void 0 : b[i] : null, f = (N) => {
406
+ !o || !i || !u || p((m) => ({
407
+ ...m,
408
+ paths: {
409
+ ...m.paths,
410
+ [o]: {
411
+ ...m.paths[o],
412
+ [i]: { ...u, ...N }
413
+ }
414
+ }
415
+ }));
416
+ }, _ = (u == null ? void 0 : u.parameters) ?? [];
417
+ return /* @__PURE__ */ n("div", { className: "nice-api-designer__paths-editor", children: [
418
+ /* @__PURE__ */ n("div", { className: "nice-api-designer__endpoints-list", children: [
419
+ /* @__PURE__ */ n("div", { className: "nice-api-designer__list-header", children: [
420
+ /* @__PURE__ */ e("h3", { children: "Endpoints" }),
421
+ !g && /* @__PURE__ */ n(j, { size: "sm", variant: "ghost", onClick: l, children: [
422
+ /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
423
+ " Add"
424
+ ] })
425
+ ] }),
426
+ t.map(({ path: N, method: m }) => /* @__PURE__ */ n(
427
+ "div",
428
+ {
429
+ className: `nice-api-designer__endpoint ${o === N && i === m.toLowerCase() ? "nice-api-designer__endpoint--selected" : ""}`,
430
+ onClick: () => c(N, m.toLowerCase()),
431
+ children: [
432
+ /* @__PURE__ */ e(
433
+ "span",
434
+ {
435
+ className: `nice-api-designer__method nice-api-designer__method--${m.toLowerCase()}`,
436
+ children: m
437
+ }
438
+ ),
439
+ /* @__PURE__ */ e("span", { className: "nice-api-designer__path", children: N })
440
+ ]
441
+ },
442
+ `${m}-${N}`
443
+ ))
444
+ ] }),
445
+ u && o && i && /* @__PURE__ */ n("div", { className: "nice-api-designer__operation-editor", children: [
446
+ /* @__PURE__ */ n("h3", { children: [
447
+ /* @__PURE__ */ e(
448
+ "span",
449
+ {
450
+ className: `nice-api-designer__method nice-api-designer__method--${i}`,
451
+ children: i.toUpperCase()
452
+ }
453
+ ),
454
+ " ",
455
+ o
456
+ ] }),
457
+ /* @__PURE__ */ e(
458
+ K,
459
+ {
460
+ label: "Summary",
461
+ value: u.summary || "",
462
+ onChange: (N) => f({ summary: N }),
463
+ readOnly: g
464
+ }
465
+ ),
466
+ /* @__PURE__ */ e(
467
+ ae,
468
+ {
469
+ label: "Description",
470
+ value: u.description || "",
471
+ onChange: (N) => f({ description: N }),
472
+ readOnly: g,
473
+ rows: 3
474
+ }
475
+ ),
476
+ /* @__PURE__ */ e(
477
+ K,
478
+ {
479
+ label: "Operation ID",
480
+ value: u.operationId || "",
481
+ onChange: (N) => f({ operationId: N }),
482
+ readOnly: g
483
+ }
484
+ ),
485
+ /* @__PURE__ */ n("div", { className: "nice-api-designer__subhead", children: [
486
+ /* @__PURE__ */ e("h4", { children: "Parameters" }),
487
+ !g && /* @__PURE__ */ n(
488
+ j,
489
+ {
490
+ size: "sm",
491
+ variant: "ghost",
492
+ onClick: () => f({
493
+ parameters: [
494
+ ..._,
495
+ { name: "param", in: "query", required: !1, schema: { type: "string" } }
496
+ ]
497
+ }),
498
+ children: [
499
+ /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
500
+ " Add"
501
+ ]
502
+ }
503
+ )
504
+ ] }),
505
+ _.length === 0 && /* @__PURE__ */ e("p", { className: "nice-api-designer__muted", children: "No parameters." }),
506
+ _.map((N, m) => /* @__PURE__ */ n("div", { className: "nice-api-designer__param-row", children: [
507
+ /* @__PURE__ */ e(
508
+ K,
509
+ {
510
+ size: "sm",
511
+ value: N.name,
512
+ placeholder: "name",
513
+ onChange: (T) => f({ parameters: _.map((y, A) => A === m ? { ...y, name: T } : y) }),
514
+ readOnly: g
515
+ }
516
+ ),
517
+ /* @__PURE__ */ e(
518
+ te,
519
+ {
520
+ size: "sm",
521
+ value: N.in,
522
+ options: Se.map((T) => ({ value: String(T), label: String(T) })),
523
+ onChange: (T) => f({
524
+ parameters: _.map(
525
+ (y, A) => A === m ? { ...y, in: T } : y
526
+ )
527
+ })
528
+ }
529
+ ),
530
+ /* @__PURE__ */ e(
531
+ ve,
532
+ {
533
+ checked: !!N.required,
534
+ onChange: (T) => f({
535
+ parameters: _.map((y, A) => A === m ? { ...y, required: T } : y)
536
+ }),
537
+ label: "required"
538
+ }
539
+ ),
540
+ !g && /* @__PURE__ */ e(
541
+ j,
542
+ {
543
+ size: "sm",
544
+ variant: "ghost",
545
+ onClick: () => f({ parameters: _.filter((T, y) => y !== m) }),
546
+ "aria-label": `Remove ${N.name}`,
547
+ children: /* @__PURE__ */ e(z, { name: "close", size: 14 })
548
+ }
549
+ )
550
+ ] }, m)),
551
+ !g && /* @__PURE__ */ e(
552
+ j,
553
+ {
554
+ className: "nice-api-designer__delete-btn",
555
+ size: "sm",
556
+ variant: "danger",
557
+ leftIcon: /* @__PURE__ */ e(z, { name: "trash", size: 14 }),
558
+ onClick: () => d(o),
559
+ children: "Delete endpoint"
560
+ }
561
+ )
562
+ ] })
563
+ ] });
564
+ }
565
+ function Ie({
566
+ schemas: t,
567
+ onAdd: a,
568
+ onChange: o,
569
+ readOnly: i
570
+ }) {
571
+ const c = Object.keys(t), [l, d] = k(c[0] ?? null), p = l ? t[l] : null, g = (p == null ? void 0 : p.properties) ?? {}, u = (_) => {
572
+ !l || !p || o({ ...t, [l]: { ...p, ..._ } });
573
+ }, f = (_, b) => {
574
+ u({ properties: { ...g, [_]: b } });
575
+ };
576
+ return /* @__PURE__ */ n("div", { className: "nice-api-designer__schemas-editor", children: [
577
+ /* @__PURE__ */ n("div", { className: "nice-api-designer__schemas-list", children: [
578
+ /* @__PURE__ */ n("div", { className: "nice-api-designer__list-header", children: [
579
+ /* @__PURE__ */ e("h3", { children: "Schemas" }),
580
+ !i && /* @__PURE__ */ n(j, { size: "sm", variant: "ghost", onClick: a, children: [
581
+ /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
582
+ " Add"
583
+ ] })
584
+ ] }),
585
+ c.map((_) => /* @__PURE__ */ e(
586
+ "div",
587
+ {
588
+ className: `nice-api-designer__schema-item ${l === _ ? "nice-api-designer__schema-item--selected" : ""}`,
589
+ onClick: () => d(_),
590
+ children: _
591
+ },
592
+ _
593
+ ))
594
+ ] }),
595
+ l && p && /* @__PURE__ */ n("div", { className: "nice-api-designer__schema-editor", children: [
596
+ /* @__PURE__ */ e("h3", { children: l }),
597
+ /* @__PURE__ */ e(
598
+ te,
599
+ {
600
+ label: "Type",
601
+ value: p.type || "object",
602
+ options: me,
603
+ onChange: (_) => u({ type: _ })
604
+ }
605
+ ),
606
+ /* @__PURE__ */ e(
607
+ ae,
608
+ {
609
+ label: "Description",
610
+ value: p.description || "",
611
+ onChange: (_) => u({ description: _ }),
612
+ readOnly: i,
613
+ rows: 2
614
+ }
615
+ ),
616
+ /* @__PURE__ */ n("div", { className: "nice-api-designer__subhead", children: [
617
+ /* @__PURE__ */ e("h4", { children: "Properties" }),
618
+ !i && /* @__PURE__ */ n(
619
+ j,
620
+ {
621
+ size: "sm",
622
+ variant: "ghost",
623
+ onClick: () => {
624
+ let _ = "field", b = 1;
625
+ for (; g[_]; )
626
+ _ = `field${b++}`;
627
+ f(_, { type: "string" });
628
+ },
629
+ children: [
630
+ /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
631
+ " Add"
632
+ ]
633
+ }
634
+ )
635
+ ] }),
636
+ Object.keys(g).length === 0 && /* @__PURE__ */ e("p", { className: "nice-api-designer__muted", children: "No properties." }),
637
+ Object.entries(g).map(([_, b]) => {
638
+ const N = (p.required || []).includes(_);
639
+ return /* @__PURE__ */ n("div", { className: "nice-api-designer__param-row", children: [
640
+ /* @__PURE__ */ e(
641
+ K,
642
+ {
643
+ size: "sm",
644
+ value: _,
645
+ onChange: (m) => {
646
+ if (!m || m === _ || g[m])
647
+ return;
648
+ const T = {};
649
+ Object.entries(g).forEach(([y, A]) => {
650
+ T[y === _ ? m : y] = A;
651
+ }), u({
652
+ properties: T,
653
+ required: (p.required || []).map((y) => y === _ ? m : y)
654
+ });
655
+ },
656
+ readOnly: i
657
+ }
658
+ ),
659
+ /* @__PURE__ */ e(
660
+ te,
661
+ {
662
+ size: "sm",
663
+ value: b.type || "string",
664
+ options: me,
665
+ onChange: (m) => f(_, { ...b, type: m })
666
+ }
667
+ ),
668
+ /* @__PURE__ */ e(
669
+ ve,
670
+ {
671
+ checked: N,
672
+ onChange: (m) => u({
673
+ required: m ? [...p.required || [], _] : (p.required || []).filter((T) => T !== _)
674
+ }),
675
+ label: "required"
676
+ }
677
+ ),
678
+ !i && /* @__PURE__ */ e(
679
+ j,
680
+ {
681
+ size: "sm",
682
+ variant: "ghost",
683
+ onClick: () => {
684
+ const { [_]: m, ...T } = g;
685
+ u({
686
+ properties: T,
687
+ required: (p.required || []).filter((y) => y !== _)
688
+ });
689
+ },
690
+ "aria-label": `Remove ${_}`,
691
+ children: /* @__PURE__ */ e(z, { name: "close", size: 14 })
692
+ }
693
+ )
694
+ ] }, _);
695
+ }),
696
+ /* @__PURE__ */ n("details", { className: "nice-api-designer__raw", children: [
697
+ /* @__PURE__ */ e("summary", { children: "Raw JSON schema" }),
698
+ /* @__PURE__ */ e(
699
+ ae,
700
+ {
701
+ value: JSON.stringify(p, null, 2),
702
+ onChange: (_) => {
703
+ try {
704
+ const b = JSON.parse(_);
705
+ o({ ...t, [l]: b });
706
+ } catch {
707
+ }
708
+ },
709
+ readOnly: i,
710
+ rows: 8,
711
+ className: "nice-api-designer__code"
712
+ }
713
+ )
714
+ ] })
715
+ ] })
716
+ ] });
717
+ }
718
+ function $e({ schemes: t, onChange: a, readOnly: o }) {
719
+ const i = (c, l) => a({ ...t, [c]: l });
720
+ return /* @__PURE__ */ n("div", { className: "nice-api-designer__security-editor", children: [
721
+ /* @__PURE__ */ n("div", { className: "nice-api-designer__list-header", children: [
722
+ /* @__PURE__ */ e("h3", { children: "Security schemes" }),
723
+ !o && /* @__PURE__ */ n(
724
+ j,
725
+ {
726
+ size: "sm",
727
+ variant: "ghost",
728
+ onClick: () => {
729
+ let c = "newScheme", l = 1;
730
+ for (; t[c]; )
731
+ c = `newScheme${l++}`;
732
+ i(c, { type: "apiKey", name: "X-API-Key", in: "header" });
733
+ },
734
+ children: [
735
+ /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
736
+ " Add"
737
+ ]
738
+ }
739
+ )
740
+ ] }),
741
+ Object.entries(t).map(([c, l]) => /* @__PURE__ */ n("div", { className: "nice-api-designer__security-item", children: [
742
+ /* @__PURE__ */ n("div", { className: "nice-api-designer__subhead", children: [
743
+ /* @__PURE__ */ e("h4", { children: c }),
744
+ !o && /* @__PURE__ */ e(
745
+ j,
746
+ {
747
+ size: "sm",
748
+ variant: "ghost",
749
+ onClick: () => {
750
+ const { [c]: d, ...p } = t;
751
+ a(p);
752
+ },
753
+ "aria-label": `Remove ${c}`,
754
+ children: /* @__PURE__ */ e(z, { name: "close", size: 14 })
755
+ }
756
+ )
757
+ ] }),
758
+ /* @__PURE__ */ n("div", { className: "nice-api-designer__param-row", children: [
759
+ /* @__PURE__ */ e(
760
+ te,
761
+ {
762
+ size: "sm",
763
+ value: l.type,
764
+ options: Pe.map((d) => ({ value: String(d), label: String(d) })),
765
+ onChange: (d) => i(c, { ...l, type: d })
766
+ }
767
+ ),
768
+ l.type === "apiKey" && /* @__PURE__ */ n(B, { children: [
769
+ /* @__PURE__ */ e(
770
+ K,
771
+ {
772
+ size: "sm",
773
+ value: l.name || "",
774
+ placeholder: "header/param name",
775
+ onChange: (d) => i(c, { ...l, name: d }),
776
+ readOnly: o
777
+ }
778
+ ),
779
+ /* @__PURE__ */ e(
780
+ te,
781
+ {
782
+ size: "sm",
783
+ value: l.in || "header",
784
+ options: ["header", "query", "cookie"].map((d) => ({ value: d, label: d })),
785
+ onChange: (d) => i(c, { ...l, in: d })
786
+ }
787
+ )
788
+ ] }),
789
+ l.type === "http" && /* @__PURE__ */ n(B, { children: [
790
+ /* @__PURE__ */ e(
791
+ K,
792
+ {
793
+ size: "sm",
794
+ value: l.scheme || "",
795
+ placeholder: "scheme (bearer/basic)",
796
+ onChange: (d) => i(c, { ...l, scheme: d }),
797
+ readOnly: o
798
+ }
799
+ ),
800
+ /* @__PURE__ */ e(
801
+ K,
802
+ {
803
+ size: "sm",
804
+ value: l.bearerFormat || "",
805
+ placeholder: "bearerFormat (JWT)",
806
+ onChange: (d) => i(c, { ...l, bearerFormat: d }),
807
+ readOnly: o
808
+ }
809
+ )
810
+ ] })
811
+ ] }),
812
+ /* @__PURE__ */ e(
813
+ K,
814
+ {
815
+ size: "sm",
816
+ value: l.description || "",
817
+ placeholder: "Description",
818
+ onChange: (d) => i(c, { ...l, description: d }),
819
+ readOnly: o
820
+ }
821
+ )
822
+ ] }, c))
823
+ ] });
824
+ }
825
+ function Re({ schema: t }) {
826
+ return /* @__PURE__ */ n("div", { className: "nice-api-designer__json-preview", children: [
827
+ /* @__PURE__ */ e("h3", { children: "OpenAPI specification" }),
828
+ /* @__PURE__ */ e("pre", { className: "nice-api-designer__code", children: JSON.stringify(t, null, 2) })
829
+ ] });
830
+ }
831
+ const qe = [
832
+ {
833
+ target: ".nice-api-tester",
834
+ titleKey: "tutorial.apiTester.intro.title",
835
+ title: "API tester",
836
+ contentKey: "tutorial.apiTester.intro.content",
837
+ content: "Build requests with collections and environment variables, send them and assert on the responses.",
838
+ placement: "auto"
839
+ }
840
+ ], De = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], ze = {
841
+ id: "",
842
+ name: "New Request",
843
+ method: "GET",
844
+ url: "",
845
+ headers: {},
846
+ queryParams: {}
847
+ };
848
+ function de(t, a) {
849
+ return t.replace(/\{\{(\w+)\}\}/g, (o, i) => a[i] || `{{${i}}}`);
850
+ }
851
+ function je(t, a) {
852
+ const o = Object.entries(a).filter(([, i]) => i).map(([i, c]) => `${encodeURIComponent(i)}=${encodeURIComponent(c)}`).join("&");
853
+ return o ? `${t}?${o}` : t;
854
+ }
855
+ function rt({
856
+ collections: t = [],
857
+ environments: a = [],
858
+ onRequest: o,
859
+ onSaveCollection: i,
860
+ className: c = "",
861
+ tutorial: l
862
+ }) {
863
+ const [d, p] = k(t), [g, u] = k(a), [f, _] = k(
864
+ a.find((s) => s.isActive) || null
865
+ ), [b, N] = k({
866
+ ...ze,
867
+ id: ee()
868
+ }), [m, T] = k(null), [y, A] = k(!1), [U, F] = k("none"), [R, O] = k(
869
+ "params"
870
+ ), [q, H] = k("body"), [M, w] = k(""), [v, x] = k(""), [D, L] = k([]), [$, J] = k([]), V = ue(null), Y = I(async () => {
871
+ var S;
872
+ if (!b.url)
873
+ return;
874
+ A(!0), T(null), L([]);
875
+ const s = Object.fromEntries(
876
+ Object.entries((f == null ? void 0 : f.variables) || {}).map(([E, P]) => [E, P.value])
877
+ ), r = {
878
+ ...b,
879
+ url: de(b.url, s),
880
+ headers: Object.fromEntries(
881
+ Object.entries(b.headers).map(([E, P]) => [E, de(P, s)])
882
+ ),
883
+ queryParams: Object.fromEntries(
884
+ Object.entries(b.queryParams).map(([E, P]) => [
885
+ E,
886
+ de(P, s)
887
+ ])
888
+ )
889
+ }, C = performance.now();
890
+ try {
891
+ let E;
892
+ if (o)
893
+ E = await o(r);
894
+ else {
895
+ V.current = new AbortController();
896
+ const P = { ...r.headers };
897
+ b.auth && Oe(P, b.auth);
898
+ const ie = je(r.url, r.queryParams), G = {
899
+ method: r.method,
900
+ headers: P,
901
+ signal: V.current.signal
902
+ };
903
+ ["POST", "PUT", "PATCH"].includes(r.method) && ((S = b.body) != null && S.content) && (G.body = typeof b.body.content == "string" ? b.body.content : JSON.stringify(b.body.content), b.body.type === "json" && (P["Content-Type"] = "application/json"));
904
+ const ne = await fetch(ie, G), oe = await ne.text();
905
+ let ce;
906
+ try {
907
+ ce = JSON.parse(oe);
908
+ } catch {
909
+ ce = oe;
910
+ }
911
+ const Ne = performance.now();
912
+ E = {
913
+ status: ne.status,
914
+ statusText: ne.statusText,
915
+ headers: Object.fromEntries(ne.headers.entries()),
916
+ body: ce,
917
+ time: Math.round(Ne - C),
918
+ size: new Blob([oe]).size,
919
+ timestamp: /* @__PURE__ */ new Date()
920
+ };
921
+ }
922
+ if (T(E), J(
923
+ (P) => [...P, { request: b, response: E }].slice(-50)
924
+ ), v) {
925
+ const P = He(v, E);
926
+ L(P);
927
+ }
928
+ } catch (E) {
929
+ E.name !== "AbortError" && T({
930
+ status: 0,
931
+ statusText: "Error",
932
+ headers: {},
933
+ body: { error: E.message },
934
+ time: Math.round(performance.now() - C),
935
+ size: 0,
936
+ timestamp: /* @__PURE__ */ new Date()
937
+ });
938
+ } finally {
939
+ A(!1), V.current = null;
940
+ }
941
+ }, [b, f, o, v]), W = I(() => {
942
+ var s;
943
+ (s = V.current) == null || s.abort(), A(!1);
944
+ }, []), X = I(() => {
945
+ N((s) => ({
946
+ ...s,
947
+ headers: { ...s.headers, "": "" }
948
+ }));
949
+ }, []), Q = I(() => {
950
+ N((s) => ({
951
+ ...s,
952
+ queryParams: { ...s.queryParams, "": "" }
953
+ }));
954
+ }, []), h = I(() => {
955
+ if (d.length === 0) {
956
+ const s = {
957
+ id: ee(),
958
+ name: "My Collection",
959
+ requests: [b]
960
+ };
961
+ p([s]), i == null || i(s);
962
+ } else {
963
+ const s = {
964
+ ...d[0],
965
+ requests: [...d[0].requests, b]
966
+ };
967
+ p((r) => [s, ...r.slice(1)]), i == null || i(s);
968
+ }
969
+ }, [d, b, i]);
970
+ return /* @__PURE__ */ n("div", { className: `nice-api-tester ${c}`, style: { position: "relative" }, children: [
971
+ l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(se, { steps: re(l, qe) }) }),
972
+ /* @__PURE__ */ e("div", { className: "nice-api-tester__toolbar", children: /* @__PURE__ */ e("div", { className: "nice-api-tester__env-selector", children: /* @__PURE__ */ n(
973
+ "select",
974
+ {
975
+ value: (f == null ? void 0 : f.id) || "",
976
+ onChange: (s) => _(g.find((r) => r.id === s.target.value) || null),
977
+ children: [
978
+ /* @__PURE__ */ e("option", { value: "", children: "No Environment" }),
979
+ g.map((s) => /* @__PURE__ */ e("option", { value: s.id, children: s.name }, s.id))
980
+ ]
981
+ }
982
+ ) }) }),
983
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__request-bar", children: [
984
+ /* @__PURE__ */ e(
985
+ "select",
986
+ {
987
+ value: b.method,
988
+ onChange: (s) => N((r) => ({
989
+ ...r,
990
+ method: s.target.value
991
+ })),
992
+ className: `nice-api-tester__method nice-api-tester__method--${b.method.toLowerCase()}`,
993
+ children: De.map((s) => /* @__PURE__ */ e("option", { value: s, children: s }, s))
994
+ }
995
+ ),
996
+ /* @__PURE__ */ e(
997
+ "input",
998
+ {
999
+ type: "text",
1000
+ value: b.url,
1001
+ onChange: (s) => N((r) => ({ ...r, url: s.target.value })),
1002
+ placeholder: "Enter request URL",
1003
+ className: "nice-api-tester__url-input"
1004
+ }
1005
+ ),
1006
+ /* @__PURE__ */ e(
1007
+ "button",
1008
+ {
1009
+ onClick: y ? W : Y,
1010
+ className: `nice-api-tester__send-btn ${y ? "nice-api-tester__send-btn--loading" : ""}`,
1011
+ children: y ? "Cancel" : "Send"
1012
+ }
1013
+ ),
1014
+ /* @__PURE__ */ e("button", { onClick: h, className: "nice-api-tester__save-btn", children: "Save" })
1015
+ ] }),
1016
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__main", children: [
1017
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__request-panel", children: [
1018
+ /* @__PURE__ */ e("div", { className: "nice-api-tester__tabs", children: ["params", "headers", "body", "auth", "tests"].map((s) => /* @__PURE__ */ e(
1019
+ "button",
1020
+ {
1021
+ className: `nice-api-tester__tab ${R === s ? "nice-api-tester__tab--active" : ""}`,
1022
+ onClick: () => O(s),
1023
+ children: s.charAt(0).toUpperCase() + s.slice(1)
1024
+ },
1025
+ s
1026
+ )) }),
1027
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__tab-content", children: [
1028
+ R === "params" && /* @__PURE__ */ e(
1029
+ Le,
1030
+ {
1031
+ params: b.queryParams,
1032
+ onChange: (s) => N((r) => ({ ...r, queryParams: s })),
1033
+ onAdd: Q
1034
+ }
1035
+ ),
1036
+ R === "headers" && /* @__PURE__ */ e(
1037
+ Ue,
1038
+ {
1039
+ headers: b.headers,
1040
+ onChange: (s) => N((r) => ({ ...r, headers: s })),
1041
+ onAdd: X
1042
+ }
1043
+ ),
1044
+ R === "body" && /* @__PURE__ */ e(
1045
+ Me,
1046
+ {
1047
+ body: b.body,
1048
+ bodyTab: U,
1049
+ onBodyTabChange: F,
1050
+ onChange: (s) => N((r) => ({ ...r, body: s }))
1051
+ }
1052
+ ),
1053
+ R === "auth" && /* @__PURE__ */ e(
1054
+ Be,
1055
+ {
1056
+ auth: b.auth,
1057
+ onChange: (s) => N((r) => ({ ...r, auth: s }))
1058
+ }
1059
+ ),
1060
+ R === "tests" && /* @__PURE__ */ e(
1061
+ Ve,
1062
+ {
1063
+ preRequestScript: M,
1064
+ testScript: v,
1065
+ onPreRequestChange: w,
1066
+ onTestChange: x
1067
+ }
1068
+ )
1069
+ ] })
1070
+ ] }),
1071
+ /* @__PURE__ */ e("div", { className: "nice-api-tester__response-panel", children: m ? /* @__PURE__ */ n(B, { children: [
1072
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__response-meta", children: [
1073
+ /* @__PURE__ */ n(
1074
+ "span",
1075
+ {
1076
+ className: `nice-api-tester__status nice-api-tester__status--${Math.floor(m.status / 100)}`,
1077
+ children: [
1078
+ m.status,
1079
+ " ",
1080
+ m.statusText
1081
+ ]
1082
+ }
1083
+ ),
1084
+ /* @__PURE__ */ n("span", { className: "nice-api-tester__time", children: [
1085
+ m.time,
1086
+ "ms"
1087
+ ] }),
1088
+ /* @__PURE__ */ e("span", { className: "nice-api-tester__size", children: Ke(m.size) })
1089
+ ] }),
1090
+ /* @__PURE__ */ e("div", { className: "nice-api-tester__tabs", children: ["body", "headers", "tests"].map((s) => /* @__PURE__ */ n(
1091
+ "button",
1092
+ {
1093
+ className: `nice-api-tester__tab ${q === s ? "nice-api-tester__tab--active" : ""}`,
1094
+ onClick: () => H(s),
1095
+ children: [
1096
+ s.charAt(0).toUpperCase() + s.slice(1),
1097
+ s === "tests" && D.length > 0 && /* @__PURE__ */ n("span", { className: "nice-api-tester__test-badge", children: [
1098
+ D.filter((r) => r.passed).length,
1099
+ "/",
1100
+ D.length
1101
+ ] })
1102
+ ]
1103
+ },
1104
+ s
1105
+ )) }),
1106
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__response-content", children: [
1107
+ q === "body" && /* @__PURE__ */ e("pre", { className: "nice-api-tester__response-body", children: typeof m.body == "string" ? m.body : JSON.stringify(m.body, null, 2) }),
1108
+ q === "headers" && /* @__PURE__ */ e("div", { className: "nice-api-tester__response-headers", children: Object.entries(m.headers).map(([s, r]) => /* @__PURE__ */ n("div", { className: "nice-api-tester__header-row", children: [
1109
+ /* @__PURE__ */ e("span", { className: "nice-api-tester__header-key", children: s }),
1110
+ /* @__PURE__ */ e("span", { className: "nice-api-tester__header-value", children: r })
1111
+ ] }, s)) }),
1112
+ q === "tests" && /* @__PURE__ */ e("div", { className: "nice-api-tester__test-results", children: D.map((s, r) => /* @__PURE__ */ n(
1113
+ "div",
1114
+ {
1115
+ className: `nice-api-tester__test-result nice-api-tester__test-result--${s.passed ? "pass" : "fail"}`,
1116
+ children: [
1117
+ /* @__PURE__ */ e("span", { className: "nice-api-tester__test-icon", children: /* @__PURE__ */ e(z, { name: s.passed ? "check" : "close", size: 14 }) }),
1118
+ /* @__PURE__ */ e("span", { className: "nice-api-tester__test-name", children: s.name }),
1119
+ s.message && /* @__PURE__ */ e("span", { className: "nice-api-tester__test-message", children: s.message })
1120
+ ]
1121
+ },
1122
+ r
1123
+ )) })
1124
+ ] })
1125
+ ] }) : /* @__PURE__ */ e("div", { className: "nice-api-tester__empty-response", children: y ? "Loading..." : "Send a request to see the response" }) })
1126
+ ] }),
1127
+ $.length > 0 && /* @__PURE__ */ n("div", { className: "nice-api-tester__history", children: [
1128
+ /* @__PURE__ */ e("h4", { children: "History" }),
1129
+ /* @__PURE__ */ e("div", { className: "nice-api-tester__history-list", children: $.slice().reverse().map(({ request: s, response: r }, C) => /* @__PURE__ */ n(
1130
+ "div",
1131
+ {
1132
+ className: "nice-api-tester__history-item",
1133
+ onClick: () => N(s),
1134
+ children: [
1135
+ /* @__PURE__ */ e(
1136
+ "span",
1137
+ {
1138
+ className: `nice-api-tester__method nice-api-tester__method--${s.method.toLowerCase()}`,
1139
+ children: s.method
1140
+ }
1141
+ ),
1142
+ /* @__PURE__ */ e("span", { className: "nice-api-tester__history-url", children: s.url }),
1143
+ /* @__PURE__ */ e(
1144
+ "span",
1145
+ {
1146
+ className: `nice-api-tester__status nice-api-tester__status--${Math.floor(
1147
+ r.status / 100
1148
+ )}`,
1149
+ children: r.status
1150
+ }
1151
+ )
1152
+ ]
1153
+ },
1154
+ C
1155
+ )) })
1156
+ ] })
1157
+ ] });
1158
+ }
1159
+ function Oe(t, a) {
1160
+ var o, i, c, l, d;
1161
+ switch (a.type) {
1162
+ case "bearer":
1163
+ t.Authorization = `${((o = a.bearer) == null ? void 0 : o.prefix) || "Bearer"} ${(i = a.bearer) == null ? void 0 : i.token}`;
1164
+ break;
1165
+ case "basic":
1166
+ t.Authorization = `Basic ${btoa(`${(c = a.basic) == null ? void 0 : c.username}:${(l = a.basic) == null ? void 0 : l.password}`)}`;
1167
+ break;
1168
+ case "api-key":
1169
+ ((d = a.apiKey) == null ? void 0 : d.in) === "header" && (t[a.apiKey.key] = a.apiKey.value);
1170
+ break;
1171
+ }
1172
+ }
1173
+ function Ke(t) {
1174
+ return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
1175
+ }
1176
+ function He(t, a) {
1177
+ const o = [], i = {
1178
+ response: {
1179
+ code: a.status,
1180
+ status: a.statusText,
1181
+ headers: a.headers,
1182
+ json: () => a.body,
1183
+ text: () => typeof a.body == "string" ? a.body : JSON.stringify(a.body),
1184
+ responseTime: a.time
1185
+ },
1186
+ test: (c, l) => {
1187
+ const d = performance.now();
1188
+ try {
1189
+ l(), o.push({ name: c, passed: !0, duration: performance.now() - d });
1190
+ } catch (p) {
1191
+ o.push({
1192
+ name: c,
1193
+ passed: !1,
1194
+ message: p.message,
1195
+ duration: performance.now() - d
1196
+ });
1197
+ }
1198
+ },
1199
+ expect: (c) => ({
1200
+ to: {
1201
+ equal: (l) => {
1202
+ if (c !== l)
1203
+ throw new Error(`Expected ${l} but got ${c}`);
1204
+ },
1205
+ be: {
1206
+ oneOf: (l) => {
1207
+ if (!l.includes(c))
1208
+ throw new Error(`Expected ${c} to be one of ${l}`);
1209
+ }
1210
+ },
1211
+ have: {
1212
+ property: (l) => {
1213
+ if (typeof c != "object" || c === null || !(l in c))
1214
+ throw new Error(`Expected object to have property ${l}`);
1215
+ }
1216
+ }
1217
+ }
1218
+ })
1219
+ };
1220
+ try {
1221
+ new Function("pm", t)(i);
1222
+ } catch (c) {
1223
+ o.push({
1224
+ name: "Script Error",
1225
+ passed: !1,
1226
+ message: c.message,
1227
+ duration: 0
1228
+ });
1229
+ }
1230
+ return o;
1231
+ }
1232
+ function fe({
1233
+ items: t,
1234
+ onChange: a,
1235
+ onAdd: o,
1236
+ keyPlaceholder: i = "Key",
1237
+ valuePlaceholder: c = "Value"
1238
+ }) {
1239
+ return /* @__PURE__ */ n("div", { className: "nice-api-tester__kv-editor", children: [
1240
+ Object.entries(t).map(([l, d], p) => /* @__PURE__ */ n("div", { className: "nice-api-tester__kv-row", children: [
1241
+ /* @__PURE__ */ e(
1242
+ "input",
1243
+ {
1244
+ type: "text",
1245
+ value: l,
1246
+ placeholder: i,
1247
+ onChange: (g) => {
1248
+ const u = Object.entries(t);
1249
+ u[p] = [g.target.value, d], a(Object.fromEntries(u));
1250
+ }
1251
+ }
1252
+ ),
1253
+ /* @__PURE__ */ e(
1254
+ "input",
1255
+ {
1256
+ type: "text",
1257
+ value: d,
1258
+ placeholder: c,
1259
+ onChange: (g) => a({ ...t, [l]: g.target.value })
1260
+ }
1261
+ ),
1262
+ /* @__PURE__ */ e(
1263
+ "button",
1264
+ {
1265
+ onClick: () => {
1266
+ const { [l]: g, ...u } = t;
1267
+ a(u);
1268
+ },
1269
+ children: "×"
1270
+ }
1271
+ )
1272
+ ] }, p)),
1273
+ /* @__PURE__ */ e("button", { onClick: o, className: "nice-api-tester__add-btn", children: "+ Add" })
1274
+ ] });
1275
+ }
1276
+ function Le({
1277
+ params: t,
1278
+ onChange: a,
1279
+ onAdd: o
1280
+ }) {
1281
+ return /* @__PURE__ */ e(
1282
+ fe,
1283
+ {
1284
+ items: t,
1285
+ onChange: a,
1286
+ onAdd: o,
1287
+ keyPlaceholder: "Parameter",
1288
+ valuePlaceholder: "Value"
1289
+ }
1290
+ );
1291
+ }
1292
+ function Ue({
1293
+ headers: t,
1294
+ onChange: a,
1295
+ onAdd: o
1296
+ }) {
1297
+ return /* @__PURE__ */ e(
1298
+ fe,
1299
+ {
1300
+ items: t,
1301
+ onChange: a,
1302
+ onAdd: o,
1303
+ keyPlaceholder: "Header",
1304
+ valuePlaceholder: "Value"
1305
+ }
1306
+ );
1307
+ }
1308
+ function Me({
1309
+ body: t,
1310
+ bodyTab: a,
1311
+ onBodyTabChange: o,
1312
+ onChange: i
1313
+ }) {
1314
+ return /* @__PURE__ */ n("div", { className: "nice-api-tester__body-editor", children: [
1315
+ /* @__PURE__ */ e("div", { className: "nice-api-tester__body-tabs", children: ["none", "json", "form-data", "raw"].map((c) => /* @__PURE__ */ n("label", { children: [
1316
+ /* @__PURE__ */ e(
1317
+ "input",
1318
+ {
1319
+ type: "radio",
1320
+ checked: a === c,
1321
+ onChange: () => {
1322
+ o(c), i({ type: c, content: "" });
1323
+ }
1324
+ }
1325
+ ),
1326
+ c
1327
+ ] }, c)) }),
1328
+ a !== "none" && /* @__PURE__ */ e(
1329
+ "textarea",
1330
+ {
1331
+ value: typeof (t == null ? void 0 : t.content) == "string" ? t.content : JSON.stringify(t == null ? void 0 : t.content, null, 2),
1332
+ onChange: (c) => i({ type: a, content: c.target.value }),
1333
+ placeholder: a === "json" ? '{ "key": "value" }' : "Enter body content",
1334
+ rows: 10,
1335
+ className: "nice-api-tester__body-textarea"
1336
+ }
1337
+ )
1338
+ ] });
1339
+ }
1340
+ function Be({
1341
+ auth: t,
1342
+ onChange: a
1343
+ }) {
1344
+ var o, i, c, l, d, p;
1345
+ return /* @__PURE__ */ n("div", { className: "nice-api-tester__auth-editor", children: [
1346
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
1347
+ /* @__PURE__ */ e("label", { children: "Type" }),
1348
+ /* @__PURE__ */ n(
1349
+ "select",
1350
+ {
1351
+ value: (t == null ? void 0 : t.type) || "none",
1352
+ onChange: (g) => a({ type: g.target.value }),
1353
+ children: [
1354
+ /* @__PURE__ */ e("option", { value: "none", children: "No Auth" }),
1355
+ /* @__PURE__ */ e("option", { value: "api-key", children: "API Key" }),
1356
+ /* @__PURE__ */ e("option", { value: "bearer", children: "Bearer Token" }),
1357
+ /* @__PURE__ */ e("option", { value: "basic", children: "Basic Auth" }),
1358
+ /* @__PURE__ */ e("option", { value: "oauth2", children: "OAuth 2.0" })
1359
+ ]
1360
+ }
1361
+ )
1362
+ ] }),
1363
+ (t == null ? void 0 : t.type) === "api-key" && /* @__PURE__ */ n(B, { children: [
1364
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
1365
+ /* @__PURE__ */ e("label", { children: "Key" }),
1366
+ /* @__PURE__ */ e(
1367
+ "input",
1368
+ {
1369
+ type: "text",
1370
+ value: ((o = t.apiKey) == null ? void 0 : o.key) || "",
1371
+ onChange: (g) => {
1372
+ var u, f;
1373
+ return a({
1374
+ ...t,
1375
+ apiKey: {
1376
+ ...t.apiKey,
1377
+ key: g.target.value,
1378
+ value: ((u = t.apiKey) == null ? void 0 : u.value) || "",
1379
+ in: ((f = t.apiKey) == null ? void 0 : f.in) || "header"
1380
+ }
1381
+ });
1382
+ },
1383
+ placeholder: "X-API-Key"
1384
+ }
1385
+ )
1386
+ ] }),
1387
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
1388
+ /* @__PURE__ */ e("label", { children: "Value" }),
1389
+ /* @__PURE__ */ e(
1390
+ "input",
1391
+ {
1392
+ type: "text",
1393
+ value: ((i = t.apiKey) == null ? void 0 : i.value) || "",
1394
+ onChange: (g) => {
1395
+ var u, f;
1396
+ return a({
1397
+ ...t,
1398
+ apiKey: {
1399
+ ...t.apiKey,
1400
+ value: g.target.value,
1401
+ key: ((u = t.apiKey) == null ? void 0 : u.key) || "",
1402
+ in: ((f = t.apiKey) == null ? void 0 : f.in) || "header"
1403
+ }
1404
+ });
1405
+ },
1406
+ placeholder: "your-api-key"
1407
+ }
1408
+ )
1409
+ ] }),
1410
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
1411
+ /* @__PURE__ */ e("label", { children: "Add to" }),
1412
+ /* @__PURE__ */ n(
1413
+ "select",
1414
+ {
1415
+ value: ((c = t.apiKey) == null ? void 0 : c.in) || "header",
1416
+ onChange: (g) => {
1417
+ var u, f;
1418
+ return a({
1419
+ ...t,
1420
+ apiKey: {
1421
+ ...t.apiKey,
1422
+ in: g.target.value,
1423
+ key: ((u = t.apiKey) == null ? void 0 : u.key) || "",
1424
+ value: ((f = t.apiKey) == null ? void 0 : f.value) || ""
1425
+ }
1426
+ });
1427
+ },
1428
+ children: [
1429
+ /* @__PURE__ */ e("option", { value: "header", children: "Header" }),
1430
+ /* @__PURE__ */ e("option", { value: "query", children: "Query Params" })
1431
+ ]
1432
+ }
1433
+ )
1434
+ ] })
1435
+ ] }),
1436
+ (t == null ? void 0 : t.type) === "bearer" && /* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
1437
+ /* @__PURE__ */ e("label", { children: "Token" }),
1438
+ /* @__PURE__ */ e(
1439
+ "input",
1440
+ {
1441
+ type: "text",
1442
+ value: ((l = t.bearer) == null ? void 0 : l.token) || "",
1443
+ onChange: (g) => a({ ...t, bearer: { token: g.target.value } }),
1444
+ placeholder: "your-bearer-token"
1445
+ }
1446
+ )
1447
+ ] }),
1448
+ (t == null ? void 0 : t.type) === "basic" && /* @__PURE__ */ n(B, { children: [
1449
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
1450
+ /* @__PURE__ */ e("label", { children: "Username" }),
1451
+ /* @__PURE__ */ e(
1452
+ "input",
1453
+ {
1454
+ type: "text",
1455
+ value: ((d = t.basic) == null ? void 0 : d.username) || "",
1456
+ onChange: (g) => {
1457
+ var u;
1458
+ return a({
1459
+ ...t,
1460
+ basic: {
1461
+ ...t.basic,
1462
+ username: g.target.value,
1463
+ password: ((u = t.basic) == null ? void 0 : u.password) || ""
1464
+ }
1465
+ });
1466
+ }
1467
+ }
1468
+ )
1469
+ ] }),
1470
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
1471
+ /* @__PURE__ */ e("label", { children: "Password" }),
1472
+ /* @__PURE__ */ e(
1473
+ "input",
1474
+ {
1475
+ type: "password",
1476
+ value: ((p = t.basic) == null ? void 0 : p.password) || "",
1477
+ onChange: (g) => {
1478
+ var u;
1479
+ return a({
1480
+ ...t,
1481
+ basic: {
1482
+ ...t.basic,
1483
+ password: g.target.value,
1484
+ username: ((u = t.basic) == null ? void 0 : u.username) || ""
1485
+ }
1486
+ });
1487
+ }
1488
+ }
1489
+ )
1490
+ ] })
1491
+ ] })
1492
+ ] });
1493
+ }
1494
+ function Ve({
1495
+ preRequestScript: t,
1496
+ testScript: a,
1497
+ onPreRequestChange: o,
1498
+ onTestChange: i
1499
+ }) {
1500
+ return /* @__PURE__ */ n("div", { className: "nice-api-tester__tests-editor", children: [
1501
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__script-section", children: [
1502
+ /* @__PURE__ */ e("h4", { children: "Pre-request Script" }),
1503
+ /* @__PURE__ */ e(
1504
+ "textarea",
1505
+ {
1506
+ value: t,
1507
+ onChange: (c) => o(c.target.value),
1508
+ placeholder: "// Code to run before the request",
1509
+ rows: 5
1510
+ }
1511
+ )
1512
+ ] }),
1513
+ /* @__PURE__ */ n("div", { className: "nice-api-tester__script-section", children: [
1514
+ /* @__PURE__ */ e("h4", { children: "Tests" }),
1515
+ /* @__PURE__ */ e(
1516
+ "textarea",
1517
+ {
1518
+ value: a,
1519
+ onChange: (c) => i(c.target.value),
1520
+ placeholder: `pm.test("Status code is 200", function () {
1521
+ pm.expect(pm.response.code).to.equal(200);
1522
+ });`,
1523
+ rows: 8
1524
+ }
1525
+ )
1526
+ ] })
1527
+ ] });
1528
+ }
1529
+ const Fe = [
1530
+ {
1531
+ target: ".nice-integration-builder",
1532
+ titleKey: "tutorial.integrationBuilder.intro.title",
1533
+ title: "Integration builder",
1534
+ contentKey: "tutorial.integrationBuilder.intro.content",
1535
+ content: "Wire a flow of nodes (triggers → actions → error handling) and connect them to build an integration.",
1536
+ placement: "auto"
1537
+ }
1538
+ ], pe = [
1539
+ { type: "trigger", label: "Trigger", icon: "zap", category: "Control" },
1540
+ { type: "http-request", label: "HTTP Request", icon: "globe", category: "Actions" },
1541
+ { type: "transform", label: "Transform", icon: "shuffle", category: "Data" },
1542
+ { type: "filter", label: "Filter", icon: "filter", category: "Data" },
1543
+ { type: "switch", label: "Switch", icon: "git-branch", category: "Control" },
1544
+ { type: "loop", label: "Loop", icon: "refresh", category: "Control" },
1545
+ { type: "delay", label: "Delay", icon: "clock", category: "Control" },
1546
+ { type: "set-variable", label: "Set Variable", icon: "edit", category: "Data" },
1547
+ { type: "database", label: "Database", icon: "database", category: "Actions" },
1548
+ { type: "email", label: "Email", icon: "mail", category: "Actions" },
1549
+ { type: "webhook", label: "Webhook", icon: "link", category: "Actions" },
1550
+ { type: "function", label: "Function", icon: "code", category: "Actions" },
1551
+ { type: "error-handler", label: "Error Handler", icon: "warning", category: "Control" }
1552
+ ], Je = {
1553
+ id: "",
1554
+ name: "New Flow",
1555
+ nodes: [],
1556
+ connections: [],
1557
+ variables: {},
1558
+ triggers: [],
1559
+ errorHandling: { strategy: "stop" }
1560
+ };
1561
+ function ot({
1562
+ flow: t,
1563
+ connectors: a = [],
1564
+ onChange: o,
1565
+ onSave: i,
1566
+ onRun: c,
1567
+ className: l = "",
1568
+ tutorial: d
1569
+ }) {
1570
+ const [p, g] = k(
1571
+ t || { ...Je, id: ee() }
1572
+ ), [u, f] = k(null), [_, b] = k(!0), [N, m] = k("canvas"), [T, y] = k(!1), [A, U] = k(null), [F, R] = k(!1), [O, q] = k(null), [H, M] = k(!1), w = ue(null), v = I(
1573
+ (h) => {
1574
+ g((s) => {
1575
+ const r = h(s);
1576
+ return o == null || o(r), r;
1577
+ });
1578
+ },
1579
+ [o]
1580
+ ), x = I(
1581
+ (h, s) => {
1582
+ var C;
1583
+ const r = {
1584
+ id: ee(),
1585
+ type: h,
1586
+ name: ((C = pe.find((S) => S.type === h)) == null ? void 0 : C.label) || h,
1587
+ position: s,
1588
+ config: We(h),
1589
+ inputs: h !== "trigger" ? ["input"] : [],
1590
+ outputs: ["output"]
1591
+ };
1592
+ v((S) => ({
1593
+ ...S,
1594
+ nodes: [...S.nodes, r]
1595
+ })), f(r);
1596
+ },
1597
+ [v]
1598
+ ), D = I(
1599
+ (h) => {
1600
+ v((s) => ({
1601
+ ...s,
1602
+ nodes: s.nodes.filter((r) => r.id !== h),
1603
+ connections: s.connections.filter(
1604
+ (r) => r.sourceNodeId !== h && r.targetNodeId !== h
1605
+ )
1606
+ })), f(null);
1607
+ },
1608
+ [v]
1609
+ ), L = I(
1610
+ (h, s) => {
1611
+ v((r) => ({
1612
+ ...r,
1613
+ nodes: r.nodes.map((C) => C.id === h ? { ...C, ...s } : C)
1614
+ })), (u == null ? void 0 : u.id) === h && f((r) => r ? { ...r, ...s } : null);
1615
+ },
1616
+ [v, u]
1617
+ ), $ = I(
1618
+ (h, s, r, C) => {
1619
+ h === r || p.connections.some(
1620
+ (E) => E.sourceNodeId === h && E.targetNodeId === r && E.sourceOutput === s && E.targetInput === C
1621
+ ) || v((E) => ({
1622
+ ...E,
1623
+ connections: [
1624
+ ...E.connections,
1625
+ {
1626
+ id: ee(),
1627
+ sourceNodeId: h,
1628
+ sourceOutput: s,
1629
+ targetNodeId: r,
1630
+ targetInput: C
1631
+ }
1632
+ ]
1633
+ }));
1634
+ },
1635
+ [p.connections, v]
1636
+ ), J = I(
1637
+ (h) => {
1638
+ v((s) => ({
1639
+ ...s,
1640
+ connections: s.connections.filter((r) => r.id !== h)
1641
+ }));
1642
+ },
1643
+ [v]
1644
+ ), V = I(
1645
+ (h) => {
1646
+ if (h.preventDefault(), !A || !w.current)
1647
+ return;
1648
+ const s = w.current.getBoundingClientRect(), r = h.clientX - s.left, C = h.clientY - s.top;
1649
+ x(A, { x: r, y: C }), y(!1), U(null);
1650
+ },
1651
+ [A, x]
1652
+ ), Y = I(async () => {
1653
+ if (c) {
1654
+ M(!0);
1655
+ try {
1656
+ await c(p);
1657
+ } finally {
1658
+ M(!1);
1659
+ }
1660
+ }
1661
+ }, [p, c]), W = I(() => {
1662
+ i == null || i(p);
1663
+ }, [p, i]), X = _ && N === "canvas" ? /* @__PURE__ */ n("div", { className: "nice-integration-builder__palette", children: [
1664
+ /* @__PURE__ */ e("h4", { children: "Nodes" }),
1665
+ ["Control", "Actions", "Data"].map((h) => /* @__PURE__ */ n("div", { className: "nice-integration-builder__category", children: [
1666
+ /* @__PURE__ */ e("h5", { children: h }),
1667
+ pe.filter((s) => s.category === h).map((s) => /* @__PURE__ */ n(
1668
+ "div",
1669
+ {
1670
+ className: "nice-integration-builder__palette-item",
1671
+ draggable: !0,
1672
+ onDragStart: () => {
1673
+ y(!0), U(s.type);
1674
+ },
1675
+ onDragEnd: () => {
1676
+ y(!1), U(null);
1677
+ },
1678
+ children: [
1679
+ /* @__PURE__ */ e("span", { className: "nice-integration-builder__palette-icon", children: /* @__PURE__ */ e(Z, { name: s.icon, size: 14 }) }),
1680
+ /* @__PURE__ */ e("span", { children: s.label })
1681
+ ]
1682
+ },
1683
+ s.type
1684
+ ))
1685
+ ] }, h)),
1686
+ a.length > 0 && /* @__PURE__ */ n("div", { className: "nice-integration-builder__category", children: [
1687
+ /* @__PURE__ */ e("h5", { children: "Connectors" }),
1688
+ a.map((h) => /* @__PURE__ */ n("div", { className: "nice-integration-builder__palette-item", children: [
1689
+ /* @__PURE__ */ e("span", { className: "nice-integration-builder__palette-icon", children: /* @__PURE__ */ e(Z, { name: "plug", size: 14 }) }),
1690
+ /* @__PURE__ */ e("span", { children: h.name })
1691
+ ] }, h.id))
1692
+ ] })
1693
+ ] }) : void 0, Q = u && N === "canvas" ? /* @__PURE__ */ e(
1694
+ Ye,
1695
+ {
1696
+ node: u,
1697
+ onChange: (h) => L(u.id, h),
1698
+ onClose: () => f(null)
1699
+ }
1700
+ ) : void 0;
1701
+ return /* @__PURE__ */ n("div", { style: { position: "relative", height: "100%" }, children: [
1702
+ d && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(se, { steps: re(d, Fe) }) }),
1703
+ /* @__PURE__ */ n(
1704
+ be,
1705
+ {
1706
+ flush: !0,
1707
+ className: `nice-integration-builder ${l}`,
1708
+ height: "100%",
1709
+ style: { minHeight: 600 },
1710
+ sidebar: X,
1711
+ rightSidebar: Q,
1712
+ toolbar: /* @__PURE__ */ n("div", { className: "nice-integration-builder__toolbar", children: [
1713
+ /* @__PURE__ */ e(
1714
+ "input",
1715
+ {
1716
+ type: "text",
1717
+ value: p.name,
1718
+ onChange: (h) => v((s) => ({ ...s, name: h.target.value })),
1719
+ className: "nice-integration-builder__name-input"
1720
+ }
1721
+ ),
1722
+ /* @__PURE__ */ e("div", { className: "nice-integration-builder__tabs", children: ["canvas", "code", "variables", "settings"].map((h) => /* @__PURE__ */ e(
1723
+ "button",
1724
+ {
1725
+ className: `nice-integration-builder__tab ${N === h ? "nice-integration-builder__tab--active" : ""}`,
1726
+ onClick: () => m(h),
1727
+ children: h.charAt(0).toUpperCase() + h.slice(1)
1728
+ },
1729
+ h
1730
+ )) }),
1731
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__actions", children: [
1732
+ /* @__PURE__ */ n(
1733
+ "button",
1734
+ {
1735
+ onClick: Y,
1736
+ disabled: H,
1737
+ className: "nice-integration-builder__run-btn",
1738
+ children: [
1739
+ /* @__PURE__ */ e(Z, { name: H ? "clock" : "play", size: 14 }),
1740
+ " ",
1741
+ H ? "Running..." : "Run"
1742
+ ]
1743
+ }
1744
+ ),
1745
+ /* @__PURE__ */ n("button", { onClick: W, className: "nice-integration-builder__save-btn", children: [
1746
+ /* @__PURE__ */ e(Z, { name: "save", size: 14 }),
1747
+ " Save"
1748
+ ] })
1749
+ ] })
1750
+ ] }),
1751
+ children: [
1752
+ N === "canvas" && /* @__PURE__ */ n(
1753
+ "div",
1754
+ {
1755
+ ref: w,
1756
+ className: `nice-integration-builder__canvas ${T ? "nice-integration-builder__canvas--dragging" : ""}`,
1757
+ onDragOver: (h) => h.preventDefault(),
1758
+ onDrop: V,
1759
+ onClick: () => f(null),
1760
+ children: [
1761
+ /* @__PURE__ */ e("svg", { className: "nice-integration-builder__connections", children: p.connections.map((h) => {
1762
+ const s = p.nodes.find((G) => G.id === h.sourceNodeId), r = p.nodes.find((G) => G.id === h.targetNodeId);
1763
+ if (!s || !r)
1764
+ return null;
1765
+ const C = s.position.x + 150, S = s.position.y + 30, E = r.position.x, P = r.position.y + 30, ie = (C + E) / 2;
1766
+ return /* @__PURE__ */ e("g", { onClick: () => J(h.id), children: /* @__PURE__ */ e(
1767
+ "path",
1768
+ {
1769
+ d: `M ${C} ${S} C ${ie} ${S}, ${ie} ${P}, ${E} ${P}`,
1770
+ className: "nice-integration-builder__connection"
1771
+ }
1772
+ ) }, h.id);
1773
+ }) }),
1774
+ p.nodes.map((h) => /* @__PURE__ */ e(
1775
+ Ge,
1776
+ {
1777
+ node: h,
1778
+ isSelected: (u == null ? void 0 : u.id) === h.id,
1779
+ onSelect: () => f(h),
1780
+ onDelete: () => D(h.id),
1781
+ onPositionChange: (s) => L(h.id, { position: s }),
1782
+ onStartConnection: (s) => {
1783
+ R(!0), q({ nodeId: h.id, output: s });
1784
+ },
1785
+ onEndConnection: (s) => {
1786
+ O && $(O.nodeId, O.output, h.id, s), R(!1), q(null);
1787
+ }
1788
+ },
1789
+ h.id
1790
+ )),
1791
+ p.nodes.length === 0 && /* @__PURE__ */ e("div", { className: "nice-integration-builder__empty", children: "Drag nodes from the palette to build your flow" })
1792
+ ]
1793
+ }
1794
+ ),
1795
+ N === "code" && /* @__PURE__ */ e("div", { className: "nice-integration-builder__code-view", children: /* @__PURE__ */ e("pre", { children: JSON.stringify(p, null, 2) }) }),
1796
+ N === "variables" && /* @__PURE__ */ e(
1797
+ Xe,
1798
+ {
1799
+ variables: p.variables,
1800
+ onChange: (h) => v((s) => ({ ...s, variables: h }))
1801
+ }
1802
+ ),
1803
+ N === "settings" && /* @__PURE__ */ e(
1804
+ Qe,
1805
+ {
1806
+ errorHandling: p.errorHandling,
1807
+ schedule: p.schedule,
1808
+ onChange: (h, s) => v((r) => ({ ...r, errorHandling: h, schedule: s }))
1809
+ }
1810
+ )
1811
+ ]
1812
+ }
1813
+ )
1814
+ ] });
1815
+ }
1816
+ function We(t) {
1817
+ switch (t) {
1818
+ case "http-request":
1819
+ return { method: "GET", url: "", headers: {}, body: "" };
1820
+ case "transform":
1821
+ return { mapping: [] };
1822
+ case "filter":
1823
+ return { condition: "" };
1824
+ case "switch":
1825
+ return { cases: [] };
1826
+ case "loop":
1827
+ return { collection: "", itemVariable: "item" };
1828
+ case "delay":
1829
+ return { duration: 1e3 };
1830
+ case "set-variable":
1831
+ return { name: "", value: "" };
1832
+ case "database":
1833
+ return { operation: "query", query: "" };
1834
+ case "email":
1835
+ return { to: "", subject: "", body: "" };
1836
+ case "webhook":
1837
+ return { method: "POST", url: "" };
1838
+ case "function":
1839
+ return { code: `// Your code here
1840
+ return input;` };
1841
+ case "error-handler":
1842
+ return { strategy: "retry", maxRetries: 3 };
1843
+ default:
1844
+ return {};
1845
+ }
1846
+ }
1847
+ function Ge({
1848
+ node: t,
1849
+ isSelected: a,
1850
+ onSelect: o,
1851
+ onDelete: i,
1852
+ onPositionChange: c,
1853
+ onStartConnection: l,
1854
+ onEndConnection: d
1855
+ }) {
1856
+ const [p, g] = k(!1), [u, f] = k({ x: 0, y: 0 }), _ = ue(null), b = pe.find((m) => m.type === t.type), N = (m) => {
1857
+ m.button === 0 && (m.stopPropagation(), g(!0), f({
1858
+ x: m.clientX - t.position.x,
1859
+ y: m.clientY - t.position.y
1860
+ }), o());
1861
+ };
1862
+ return we(() => {
1863
+ if (!p)
1864
+ return;
1865
+ const m = (y) => {
1866
+ c({
1867
+ x: y.clientX - u.x,
1868
+ y: y.clientY - u.y
1869
+ });
1870
+ }, T = () => {
1871
+ g(!1);
1872
+ };
1873
+ return window.addEventListener("mousemove", m), window.addEventListener("mouseup", T), () => {
1874
+ window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", T);
1875
+ };
1876
+ }, [p, u, c]), /* @__PURE__ */ n(
1877
+ "div",
1878
+ {
1879
+ ref: _,
1880
+ className: `nice-integration-builder__node nice-integration-builder__node--${t.type} ${a ? "nice-integration-builder__node--selected" : ""}`,
1881
+ style: {
1882
+ left: t.position.x,
1883
+ top: t.position.y
1884
+ },
1885
+ onMouseDown: N,
1886
+ children: [
1887
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__node-header", children: [
1888
+ /* @__PURE__ */ e("span", { className: "nice-integration-builder__node-icon", children: /* @__PURE__ */ e(Z, { name: (b == null ? void 0 : b.icon) || "box", size: 14 }) }),
1889
+ /* @__PURE__ */ e("span", { className: "nice-integration-builder__node-name", children: t.name }),
1890
+ /* @__PURE__ */ e(
1891
+ "button",
1892
+ {
1893
+ className: "nice-integration-builder__node-delete",
1894
+ onClick: (m) => {
1895
+ m.stopPropagation(), i();
1896
+ },
1897
+ children: "×"
1898
+ }
1899
+ )
1900
+ ] }),
1901
+ t.inputs.map((m) => /* @__PURE__ */ n(
1902
+ "div",
1903
+ {
1904
+ className: "nice-integration-builder__port nice-integration-builder__port--input",
1905
+ onMouseUp: () => d(m),
1906
+ children: [
1907
+ /* @__PURE__ */ e("span", { className: "nice-integration-builder__port-dot" }),
1908
+ /* @__PURE__ */ e("span", { className: "nice-integration-builder__port-label", children: m })
1909
+ ]
1910
+ },
1911
+ m
1912
+ )),
1913
+ t.outputs.map((m) => /* @__PURE__ */ n(
1914
+ "div",
1915
+ {
1916
+ className: "nice-integration-builder__port nice-integration-builder__port--output",
1917
+ onMouseDown: (T) => {
1918
+ T.stopPropagation(), l(m);
1919
+ },
1920
+ children: [
1921
+ /* @__PURE__ */ e("span", { className: "nice-integration-builder__port-label", children: m }),
1922
+ /* @__PURE__ */ e("span", { className: "nice-integration-builder__port-dot" })
1923
+ ]
1924
+ },
1925
+ m
1926
+ ))
1927
+ ]
1928
+ }
1929
+ );
1930
+ }
1931
+ function Ye({
1932
+ node: t,
1933
+ onChange: a,
1934
+ onClose: o
1935
+ }) {
1936
+ return /* @__PURE__ */ n("div", { className: "nice-integration-builder__properties", children: [
1937
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__properties-header", children: [
1938
+ /* @__PURE__ */ e("h4", { children: t.name }),
1939
+ /* @__PURE__ */ e("button", { onClick: o, children: "×" })
1940
+ ] }),
1941
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__properties-content", children: [
1942
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
1943
+ /* @__PURE__ */ e("label", { children: "Name" }),
1944
+ /* @__PURE__ */ e(
1945
+ "input",
1946
+ {
1947
+ type: "text",
1948
+ value: t.name,
1949
+ onChange: (i) => a({ name: i.target.value })
1950
+ }
1951
+ )
1952
+ ] }),
1953
+ t.type === "http-request" && /* @__PURE__ */ n(B, { children: [
1954
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
1955
+ /* @__PURE__ */ e("label", { children: "Method" }),
1956
+ /* @__PURE__ */ e(
1957
+ "select",
1958
+ {
1959
+ value: t.config.method || "GET",
1960
+ onChange: (i) => a({ config: { ...t.config, method: i.target.value } }),
1961
+ children: ["GET", "POST", "PUT", "PATCH", "DELETE"].map((i) => /* @__PURE__ */ e("option", { value: i, children: i }, i))
1962
+ }
1963
+ )
1964
+ ] }),
1965
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
1966
+ /* @__PURE__ */ e("label", { children: "URL" }),
1967
+ /* @__PURE__ */ e(
1968
+ "input",
1969
+ {
1970
+ type: "text",
1971
+ value: t.config.url || "",
1972
+ onChange: (i) => a({ config: { ...t.config, url: i.target.value } }),
1973
+ placeholder: "https://api.example.com/endpoint"
1974
+ }
1975
+ )
1976
+ ] })
1977
+ ] }),
1978
+ t.type === "delay" && /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
1979
+ /* @__PURE__ */ e("label", { children: "Duration (ms)" }),
1980
+ /* @__PURE__ */ e(
1981
+ "input",
1982
+ {
1983
+ type: "number",
1984
+ value: t.config.duration || 1e3,
1985
+ onChange: (i) => a({ config: { ...t.config, duration: parseInt(i.target.value, 10) } })
1986
+ }
1987
+ )
1988
+ ] }),
1989
+ t.type === "set-variable" && /* @__PURE__ */ n(B, { children: [
1990
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
1991
+ /* @__PURE__ */ e("label", { children: "Variable Name" }),
1992
+ /* @__PURE__ */ e(
1993
+ "input",
1994
+ {
1995
+ type: "text",
1996
+ value: t.config.name || "",
1997
+ onChange: (i) => a({ config: { ...t.config, name: i.target.value } })
1998
+ }
1999
+ )
2000
+ ] }),
2001
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
2002
+ /* @__PURE__ */ e("label", { children: "Value" }),
2003
+ /* @__PURE__ */ e(
2004
+ "input",
2005
+ {
2006
+ type: "text",
2007
+ value: t.config.value || "",
2008
+ onChange: (i) => a({ config: { ...t.config, value: i.target.value } })
2009
+ }
2010
+ )
2011
+ ] })
2012
+ ] }),
2013
+ t.type === "function" && /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
2014
+ /* @__PURE__ */ e("label", { children: "Code" }),
2015
+ /* @__PURE__ */ e(
2016
+ "textarea",
2017
+ {
2018
+ value: t.config.code || "",
2019
+ onChange: (i) => a({ config: { ...t.config, code: i.target.value } }),
2020
+ rows: 10,
2021
+ className: "nice-integration-builder__code-input"
2022
+ }
2023
+ )
2024
+ ] }),
2025
+ t.type === "email" && /* @__PURE__ */ n(B, { children: [
2026
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
2027
+ /* @__PURE__ */ e("label", { children: "To" }),
2028
+ /* @__PURE__ */ e(
2029
+ "input",
2030
+ {
2031
+ type: "text",
2032
+ value: t.config.to || "",
2033
+ onChange: (i) => a({ config: { ...t.config, to: i.target.value } })
2034
+ }
2035
+ )
2036
+ ] }),
2037
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
2038
+ /* @__PURE__ */ e("label", { children: "Subject" }),
2039
+ /* @__PURE__ */ e(
2040
+ "input",
2041
+ {
2042
+ type: "text",
2043
+ value: t.config.subject || "",
2044
+ onChange: (i) => a({ config: { ...t.config, subject: i.target.value } })
2045
+ }
2046
+ )
2047
+ ] }),
2048
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
2049
+ /* @__PURE__ */ e("label", { children: "Body" }),
2050
+ /* @__PURE__ */ e(
2051
+ "textarea",
2052
+ {
2053
+ value: t.config.body || "",
2054
+ onChange: (i) => a({ config: { ...t.config, body: i.target.value } }),
2055
+ rows: 5
2056
+ }
2057
+ )
2058
+ ] })
2059
+ ] })
2060
+ ] })
2061
+ ] });
2062
+ }
2063
+ function Xe({ variables: t, onChange: a }) {
2064
+ const o = () => {
2065
+ a({ ...t, newVariable: "" });
2066
+ };
2067
+ return /* @__PURE__ */ n("div", { className: "nice-integration-builder__variables", children: [
2068
+ /* @__PURE__ */ e("h4", { children: "Flow Variables" }),
2069
+ /* @__PURE__ */ e("div", { className: "nice-integration-builder__variables-list", children: Object.entries(t).map(([i, c]) => /* @__PURE__ */ n("div", { className: "nice-integration-builder__variable-row", children: [
2070
+ /* @__PURE__ */ e(
2071
+ "input",
2072
+ {
2073
+ type: "text",
2074
+ value: i,
2075
+ onChange: (l) => {
2076
+ const { [i]: d, ...p } = t;
2077
+ a({ ...p, [l.target.value]: c });
2078
+ },
2079
+ placeholder: "Name"
2080
+ }
2081
+ ),
2082
+ /* @__PURE__ */ e(
2083
+ "input",
2084
+ {
2085
+ type: "text",
2086
+ value: String(c),
2087
+ onChange: (l) => a({ ...t, [i]: l.target.value }),
2088
+ placeholder: "Value"
2089
+ }
2090
+ ),
2091
+ /* @__PURE__ */ e(
2092
+ "button",
2093
+ {
2094
+ onClick: () => {
2095
+ const { [i]: l, ...d } = t;
2096
+ a(d);
2097
+ },
2098
+ children: "×"
2099
+ }
2100
+ )
2101
+ ] }, i)) }),
2102
+ /* @__PURE__ */ e("button", { onClick: o, children: "+ Add Variable" })
2103
+ ] });
2104
+ }
2105
+ function Qe({
2106
+ errorHandling: t,
2107
+ schedule: a,
2108
+ onChange: o
2109
+ }) {
2110
+ return /* @__PURE__ */ n("div", { className: "nice-integration-builder__settings", children: [
2111
+ /* @__PURE__ */ e("h4", { children: "Error Handling" }),
2112
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
2113
+ /* @__PURE__ */ e("label", { children: "Strategy" }),
2114
+ /* @__PURE__ */ n(
2115
+ "select",
2116
+ {
2117
+ value: t.strategy,
2118
+ onChange: (i) => o(
2119
+ { ...t, strategy: i.target.value },
2120
+ a
2121
+ ),
2122
+ children: [
2123
+ /* @__PURE__ */ e("option", { value: "stop", children: "Stop on error" }),
2124
+ /* @__PURE__ */ e("option", { value: "continue", children: "Continue on error" }),
2125
+ /* @__PURE__ */ e("option", { value: "retry", children: "Retry on error" })
2126
+ ]
2127
+ }
2128
+ )
2129
+ ] }),
2130
+ t.strategy === "retry" && /* @__PURE__ */ n(B, { children: [
2131
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
2132
+ /* @__PURE__ */ e("label", { children: "Max Retries" }),
2133
+ /* @__PURE__ */ e(
2134
+ "input",
2135
+ {
2136
+ type: "number",
2137
+ value: t.maxRetries || 3,
2138
+ onChange: (i) => o({ ...t, maxRetries: parseInt(i.target.value, 10) }, a)
2139
+ }
2140
+ )
2141
+ ] }),
2142
+ /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
2143
+ /* @__PURE__ */ e("label", { children: "Retry Delay (ms)" }),
2144
+ /* @__PURE__ */ e(
2145
+ "input",
2146
+ {
2147
+ type: "number",
2148
+ value: t.retryDelay || 1e3,
2149
+ onChange: (i) => o({ ...t, retryDelay: parseInt(i.target.value, 10) }, a)
2150
+ }
2151
+ )
2152
+ ] })
2153
+ ] }),
2154
+ /* @__PURE__ */ e("h4", { children: "Schedule" }),
2155
+ /* @__PURE__ */ e("div", { className: "nice-integration-builder__field", children: /* @__PURE__ */ n("label", { children: [
2156
+ /* @__PURE__ */ e(
2157
+ "input",
2158
+ {
2159
+ type: "checkbox",
2160
+ checked: (a == null ? void 0 : a.enabled) || !1,
2161
+ onChange: (i) => o(t, { ...a, enabled: i.target.checked })
2162
+ }
2163
+ ),
2164
+ "Enable scheduled execution"
2165
+ ] }) }),
2166
+ (a == null ? void 0 : a.enabled) && /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
2167
+ /* @__PURE__ */ e("label", { children: "Cron Expression" }),
2168
+ /* @__PURE__ */ e(
2169
+ "input",
2170
+ {
2171
+ type: "text",
2172
+ value: a.cron || "",
2173
+ onChange: (i) => o(t, { ...a, cron: i.target.value }),
2174
+ placeholder: "0 0 * * *"
2175
+ }
2176
+ )
2177
+ ] })
2178
+ ] });
2179
+ }
2180
+ const Ze = [
2181
+ {
2182
+ target: ".nice-webhook-tester",
2183
+ titleKey: "tutorial.webhookTester.intro.title",
2184
+ title: "Webhook tester",
2185
+ contentKey: "tutorial.webhookTester.intro.content",
2186
+ content: "Pick a saved payload (or write one), optionally sign it, send it to the endpoint and inspect the response.",
2187
+ placement: "auto"
2188
+ }
2189
+ ];
2190
+ function ge(t) {
2191
+ return t ? Object.entries(t).map(([a, o]) => ({ key: a, value: o })) : [];
2192
+ }
2193
+ function _e(t) {
2194
+ const a = {};
2195
+ for (const o of t)
2196
+ o.key.trim() !== "" && (a[o.key] = o.value);
2197
+ return a;
2198
+ }
2199
+ async function et(t, a) {
2200
+ var d;
2201
+ const o = (d = globalThis.crypto) == null ? void 0 : d.subtle;
2202
+ if (!o)
2203
+ throw new Error("Web Crypto (crypto.subtle) is unavailable in this environment");
2204
+ const i = new TextEncoder(), c = await o.importKey(
2205
+ "raw",
2206
+ i.encode(t),
2207
+ { name: "HMAC", hash: "SHA-256" },
2208
+ !1,
2209
+ ["sign"]
2210
+ ), l = await o.sign("HMAC", c, i.encode(a));
2211
+ return [...new Uint8Array(l)].map((p) => p.toString(16).padStart(2, "0")).join("");
2212
+ }
2213
+ const ct = Ce(
2214
+ function(a, o) {
2215
+ const {
2216
+ url: i = "",
2217
+ method: c = "POST",
2218
+ headers: l,
2219
+ payload: d = "",
2220
+ samples: p = [],
2221
+ onSend: g,
2222
+ signing: u,
2223
+ onSaveSample: f,
2224
+ tutorial: _,
2225
+ className: b,
2226
+ style: N,
2227
+ id: m,
2228
+ "data-testid": T
2229
+ } = a, [y, A] = k(i), [U, F] = k(c), [R, O] = k(() => ge(l)), [q, H] = k(d), [M, w] = k(""), [v, x] = k(!1), [D, L] = k(null), [$, J] = k(null), V = ke(() => {
2230
+ const r = /* @__PURE__ */ new Map();
2231
+ for (const C of p)
2232
+ r.set(C.id, C);
2233
+ return r;
2234
+ }, [p]), Y = (r) => {
2235
+ w(r);
2236
+ const C = V.get(r);
2237
+ C && (H(C.payload), C.headers && O(ge(C.headers)));
2238
+ }, W = (r, C) => {
2239
+ O((S) => S.map((E, P) => P === r ? { ...E, ...C } : E));
2240
+ }, X = async () => {
2241
+ x(!0), L(null), J(null);
2242
+ try {
2243
+ const r = _e(R);
2244
+ if (u && u.secret) {
2245
+ const P = await et(u.secret, q);
2246
+ r[u.header] = `${u.prefix ?? ""}${P}`;
2247
+ }
2248
+ const C = typeof performance < "u" ? performance.now() : Date.now(), S = await g({ url: y, method: U ?? "POST", headers: r, body: q }), E = Math.round(
2249
+ (typeof performance < "u" ? performance.now() : Date.now()) - C
2250
+ );
2251
+ J({ ...S, durationMs: S.durationMs ?? E });
2252
+ } catch (r) {
2253
+ L(r instanceof Error ? r.message : String(r));
2254
+ } finally {
2255
+ x(!1);
2256
+ }
2257
+ }, Q = () => {
2258
+ var C;
2259
+ if (!f)
2260
+ return;
2261
+ const r = typeof window < "u" && ((C = window.prompt) == null ? void 0 : C.call(window, "Sample name")) || "";
2262
+ r && f({
2263
+ id: `sample_${Date.now().toString(36)}`,
2264
+ name: r,
2265
+ payload: q,
2266
+ headers: _e(R)
2267
+ });
2268
+ }, h = $ == null ? "" : $.status >= 200 && $.status < 300 ? " nice-webhook-tester__status--ok" : " nice-webhook-tester__status--error", s = "nice-webhook-tester" + (b ? ` ${b}` : "");
2269
+ return /* @__PURE__ */ n("div", { ref: o, id: m, className: s, style: N, "data-testid": T, children: [
2270
+ _ && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__tutorial", children: /* @__PURE__ */ e(se, { steps: re(_, Ze) }) }),
2271
+ /* @__PURE__ */ n("div", { className: "nice-webhook-tester__bar", children: [
2272
+ /* @__PURE__ */ e(
2273
+ "select",
2274
+ {
2275
+ className: "nice-webhook-tester__method",
2276
+ value: U,
2277
+ onChange: (r) => F(r.target.value),
2278
+ "aria-label": "Method",
2279
+ children: ["POST", "PUT", "GET", "PATCH", "DELETE"].map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
2280
+ }
2281
+ ),
2282
+ /* @__PURE__ */ e(
2283
+ "input",
2284
+ {
2285
+ type: "text",
2286
+ className: "nice-webhook-tester__url",
2287
+ value: y,
2288
+ placeholder: "https://example.com/api/payments/stripe/webhook",
2289
+ onChange: (r) => A(r.target.value),
2290
+ "aria-label": "URL"
2291
+ }
2292
+ ),
2293
+ /* @__PURE__ */ e(
2294
+ "button",
2295
+ {
2296
+ type: "button",
2297
+ className: "nice-webhook-tester__send",
2298
+ onClick: () => void X(),
2299
+ disabled: v || y.trim() === "",
2300
+ children: v ? "Sending…" : "Send"
2301
+ }
2302
+ )
2303
+ ] }),
2304
+ p.length > 0 && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__samples", children: /* @__PURE__ */ n("label", { children: [
2305
+ "Sample:",
2306
+ " ",
2307
+ /* @__PURE__ */ n("select", { value: M, onChange: (r) => Y(r.target.value), children: [
2308
+ /* @__PURE__ */ e("option", { value: "", children: "— choose a saved payload —" }),
2309
+ p.map((r) => /* @__PURE__ */ e("option", { value: r.id, children: r.name }, r.id))
2310
+ ] })
2311
+ ] }) }),
2312
+ /* @__PURE__ */ n("div", { className: "nice-webhook-tester__headers", children: [
2313
+ /* @__PURE__ */ n("div", { className: "nice-webhook-tester__section-label", children: [
2314
+ "Headers",
2315
+ u && /* @__PURE__ */ n("span", { className: "nice-webhook-tester__signed", children: [
2316
+ " ",
2317
+ "· auto-signs ",
2318
+ /* @__PURE__ */ e("code", { children: u.header })
2319
+ ] })
2320
+ ] }),
2321
+ R.map((r, C) => /* @__PURE__ */ n("div", { className: "nice-webhook-tester__header-row", children: [
2322
+ /* @__PURE__ */ e(
2323
+ "input",
2324
+ {
2325
+ type: "text",
2326
+ value: r.key,
2327
+ placeholder: "Header",
2328
+ onChange: (S) => W(C, { key: S.target.value }),
2329
+ "aria-label": "Header name"
2330
+ }
2331
+ ),
2332
+ /* @__PURE__ */ e(
2333
+ "input",
2334
+ {
2335
+ type: "text",
2336
+ value: r.value,
2337
+ placeholder: "Value",
2338
+ onChange: (S) => W(C, { value: S.target.value }),
2339
+ "aria-label": "Header value"
2340
+ }
2341
+ ),
2342
+ /* @__PURE__ */ e(
2343
+ "button",
2344
+ {
2345
+ type: "button",
2346
+ onClick: () => O((S) => S.filter((E, P) => P !== C)),
2347
+ "aria-label": "Remove header",
2348
+ children: /* @__PURE__ */ e(z, { name: "close", size: 12 })
2349
+ }
2350
+ )
2351
+ ] }, C)),
2352
+ /* @__PURE__ */ e(
2353
+ "button",
2354
+ {
2355
+ type: "button",
2356
+ className: "nice-webhook-tester__add-header",
2357
+ onClick: () => O((r) => [...r, { key: "", value: "" }]),
2358
+ children: "+ Header"
2359
+ }
2360
+ )
2361
+ ] }),
2362
+ /* @__PURE__ */ n("div", { className: "nice-webhook-tester__payload", children: [
2363
+ /* @__PURE__ */ n("div", { className: "nice-webhook-tester__section-label", children: [
2364
+ "Payload",
2365
+ f && /* @__PURE__ */ e("button", { type: "button", className: "nice-webhook-tester__save", onClick: Q, children: "Save as sample" })
2366
+ ] }),
2367
+ /* @__PURE__ */ e(
2368
+ "textarea",
2369
+ {
2370
+ className: "nice-webhook-tester__textarea",
2371
+ value: q,
2372
+ spellCheck: !1,
2373
+ rows: 8,
2374
+ placeholder: '{ "type": "payment.succeeded", "data": { ... } }',
2375
+ onChange: (r) => H(r.target.value),
2376
+ "aria-label": "Payload"
2377
+ }
2378
+ )
2379
+ ] }),
2380
+ D && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__error", children: D }),
2381
+ $ && /* @__PURE__ */ n("div", { className: "nice-webhook-tester__response", children: [
2382
+ /* @__PURE__ */ n("div", { className: "nice-webhook-tester__section-label", children: [
2383
+ "Response",
2384
+ " ",
2385
+ /* @__PURE__ */ e("span", { className: "nice-webhook-tester__status" + h, children: $.status }),
2386
+ $.durationMs != null && /* @__PURE__ */ n("span", { className: "nice-webhook-tester__time", children: [
2387
+ " · ",
2388
+ $.durationMs,
2389
+ " ms"
2390
+ ] })
2391
+ ] }),
2392
+ $.body != null && /* @__PURE__ */ e("pre", { className: "nice-webhook-tester__response-body", children: $.body })
2393
+ ] })
2394
+ ] });
2395
+ }
2396
+ );
2
2397
  export {
3
- r as NiceAPIDesigner,
4
- s as NiceAPITester,
5
- a as NiceIntegrationBuilder,
6
- c as NiceWebhookTester
2398
+ st as NiceAPIDesigner,
2399
+ rt as NiceAPITester,
2400
+ ot as NiceIntegrationBuilder,
2401
+ ct as NiceWebhookTester
7
2402
  };