@uniformdev/next-app-router 20.7.1-alpha.118

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.
@@ -0,0 +1,1384 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
28
+ var require_yocto_queue = __commonJS({
29
+ "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports, module) {
30
+ "use strict";
31
+ var Node = class {
32
+ /// value;
33
+ /// next;
34
+ constructor(value) {
35
+ this.value = value;
36
+ this.next = void 0;
37
+ }
38
+ };
39
+ var Queue = class {
40
+ // TODO: Use private class fields when targeting Node.js 12.
41
+ // #_head;
42
+ // #_tail;
43
+ // #_size;
44
+ constructor() {
45
+ this.clear();
46
+ }
47
+ enqueue(value) {
48
+ const node = new Node(value);
49
+ if (this._head) {
50
+ this._tail.next = node;
51
+ this._tail = node;
52
+ } else {
53
+ this._head = node;
54
+ this._tail = node;
55
+ }
56
+ this._size++;
57
+ }
58
+ dequeue() {
59
+ const current = this._head;
60
+ if (!current) {
61
+ return;
62
+ }
63
+ this._head = this._head.next;
64
+ this._size--;
65
+ return current.value;
66
+ }
67
+ clear() {
68
+ this._head = void 0;
69
+ this._tail = void 0;
70
+ this._size = 0;
71
+ }
72
+ get size() {
73
+ return this._size;
74
+ }
75
+ *[Symbol.iterator]() {
76
+ let current = this._head;
77
+ while (current) {
78
+ yield current.value;
79
+ current = current.next;
80
+ }
81
+ }
82
+ };
83
+ module.exports = Queue;
84
+ }
85
+ });
86
+
87
+ // ../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js
88
+ var require_p_limit = __commonJS({
89
+ "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports, module) {
90
+ "use strict";
91
+ var Queue = require_yocto_queue();
92
+ var pLimit2 = (concurrency) => {
93
+ if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
94
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
95
+ }
96
+ const queue = new Queue();
97
+ let activeCount = 0;
98
+ const next = () => {
99
+ activeCount--;
100
+ if (queue.size > 0) {
101
+ queue.dequeue()();
102
+ }
103
+ };
104
+ const run = async (fn, resolve, ...args) => {
105
+ activeCount++;
106
+ const result = (async () => fn(...args))();
107
+ resolve(result);
108
+ try {
109
+ await result;
110
+ } catch (e) {
111
+ }
112
+ next();
113
+ };
114
+ const enqueue = (fn, resolve, ...args) => {
115
+ queue.enqueue(run.bind(null, fn, resolve, ...args));
116
+ (async () => {
117
+ await Promise.resolve();
118
+ if (activeCount < concurrency && queue.size > 0) {
119
+ queue.dequeue()();
120
+ }
121
+ })();
122
+ };
123
+ const generator = (fn, ...args) => new Promise((resolve) => {
124
+ enqueue(fn, resolve, ...args);
125
+ });
126
+ Object.defineProperties(generator, {
127
+ activeCount: {
128
+ get: () => activeCount
129
+ },
130
+ pendingCount: {
131
+ get: () => queue.size
132
+ },
133
+ clearQueue: {
134
+ value: () => {
135
+ queue.clear();
136
+ }
137
+ }
138
+ });
139
+ return generator;
140
+ };
141
+ module.exports = pLimit2;
142
+ }
143
+ });
144
+
145
+ // src/components/getUniformSlot.ts
146
+ var getUniformSlot = ({ slot, children }) => {
147
+ const resolved = [];
148
+ if (slot) {
149
+ for (let i = 0; i < slot.items.length; i++) {
150
+ const child = slot.items[i];
151
+ if (!child) continue;
152
+ if (!children) {
153
+ resolved.push(child.component);
154
+ } else {
155
+ const result = children({
156
+ child: child.component,
157
+ _id: child._id,
158
+ key: `inner-${i}`,
159
+ slotName: slot.name,
160
+ slotIndex: i
161
+ });
162
+ resolved.push(result);
163
+ }
164
+ }
165
+ }
166
+ return resolved.length > 0 ? resolved : void 0;
167
+ };
168
+
169
+ // src/components/UniformSlot.tsx
170
+ var UniformSlot = ({ slot, children }) => {
171
+ const resolved = [];
172
+ if (slot) {
173
+ for (let i = 0; i < slot.items.length; i++) {
174
+ const child = slot.items[i];
175
+ if (!children) {
176
+ resolved.push(child.component);
177
+ } else {
178
+ const result = children({
179
+ child: child.component,
180
+ _id: child._id,
181
+ key: `inner-${i}`,
182
+ slotName: slot.name,
183
+ slotIndex: i
184
+ });
185
+ resolved.push(result);
186
+ }
187
+ }
188
+ }
189
+ return resolved.length > 0 ? resolved : null;
190
+ };
191
+
192
+ // src/component.ts
193
+ import {
194
+ createClientUniformContext,
195
+ useInitUniformContext,
196
+ useQuirks,
197
+ useScores,
198
+ useUniformContext
199
+ } from "@uniformdev/next-app-router-client";
200
+
201
+ // ../context/dist/api/api.mjs
202
+ var import_p_limit = __toESM(require_p_limit(), 1);
203
+ var __defProp2 = Object.defineProperty;
204
+ var __typeError = (msg) => {
205
+ throw TypeError(msg);
206
+ };
207
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
208
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
209
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
210
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
211
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
212
+ var defaultLimitPolicy = (0, import_p_limit.default)(6);
213
+ var ApiClientError = class _ApiClientError extends Error {
214
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
215
+ super(
216
+ `${errorMessage}
217
+ ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
218
+ );
219
+ this.errorMessage = errorMessage;
220
+ this.fetchMethod = fetchMethod;
221
+ this.fetchUri = fetchUri;
222
+ this.statusCode = statusCode;
223
+ this.statusText = statusText;
224
+ this.requestId = requestId;
225
+ Object.setPrototypeOf(this, _ApiClientError.prototype);
226
+ }
227
+ };
228
+ var ApiClient = class _ApiClient {
229
+ constructor(options) {
230
+ __publicField(this, "options");
231
+ var _a, _b, _c, _d, _e;
232
+ if (!options.apiKey && !options.bearerToken) {
233
+ throw new Error("You must provide an API key or a bearer token");
234
+ }
235
+ let leFetch = options.fetch;
236
+ if (!leFetch) {
237
+ if (typeof window !== "undefined") {
238
+ leFetch = window.fetch.bind(window);
239
+ } else if (typeof fetch !== "undefined") {
240
+ leFetch = fetch;
241
+ } else {
242
+ throw new Error("You must provide or polyfill a fetch implementation when not in a browser");
243
+ }
244
+ }
245
+ this.options = {
246
+ ...options,
247
+ fetch: leFetch,
248
+ apiHost: this.ensureApiHost(options.apiHost),
249
+ apiKey: (_a = options.apiKey) != null ? _a : null,
250
+ projectId: (_b = options.projectId) != null ? _b : null,
251
+ bearerToken: (_c = options.bearerToken) != null ? _c : null,
252
+ limitPolicy: (_d = options.limitPolicy) != null ? _d : defaultLimitPolicy,
253
+ bypassCache: (_e = options.bypassCache) != null ? _e : false
254
+ };
255
+ }
256
+ async apiClient(fetchUri, options) {
257
+ return (await this.apiClientWithResponse(fetchUri, options)).body;
258
+ }
259
+ async apiClientWithResponse(fetchUri, options) {
260
+ return this.options.limitPolicy(async () => {
261
+ var _a;
262
+ const coreHeaders = this.options.apiKey ? {
263
+ "x-api-key": this.options.apiKey
264
+ } : {
265
+ Authorization: `Bearer ${this.options.bearerToken}`
266
+ };
267
+ if (this.options.bypassCache) {
268
+ coreHeaders["x-bypass-cache"] = "true";
269
+ }
270
+ const { fetch: fetch2, signal } = this.options;
271
+ const callApi = () => fetch2(fetchUri.toString(), {
272
+ ...options,
273
+ signal,
274
+ headers: {
275
+ ...options == null ? void 0 : options.headers,
276
+ ...coreHeaders
277
+ }
278
+ });
279
+ const apiResponse = await handleRateLimits(callApi);
280
+ if (!apiResponse.ok) {
281
+ let message = "";
282
+ try {
283
+ const responseText = await apiResponse.text();
284
+ try {
285
+ const parsed = JSON.parse(responseText);
286
+ if (parsed.errorMessage) {
287
+ message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
288
+ } else {
289
+ message = responseText;
290
+ }
291
+ } catch (e) {
292
+ message = responseText;
293
+ }
294
+ } catch (e) {
295
+ message = `General error`;
296
+ }
297
+ throw new ApiClientError(
298
+ message,
299
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
300
+ fetchUri.toString(),
301
+ apiResponse.status,
302
+ apiResponse.statusText,
303
+ _ApiClient.getRequestId(apiResponse)
304
+ );
305
+ }
306
+ if (options == null ? void 0 : options.expectNoContent) {
307
+ return { response: apiResponse, body: null };
308
+ }
309
+ return {
310
+ response: apiResponse,
311
+ body: await apiResponse.json()
312
+ };
313
+ });
314
+ }
315
+ createUrl(path, queryParams, hostOverride) {
316
+ const url = new URL(`${hostOverride != null ? hostOverride : this.options.apiHost}${path}`);
317
+ Object.entries(queryParams != null ? queryParams : {}).forEach(([key, value]) => {
318
+ var _a;
319
+ if (typeof value !== "undefined" && value !== null) {
320
+ url.searchParams.append(key, Array.isArray(value) ? value.join(",") : (_a = value == null ? void 0 : value.toString()) != null ? _a : "");
321
+ }
322
+ });
323
+ return url;
324
+ }
325
+ ensureApiHost(apiHost) {
326
+ if (!apiHost) return "https://uniform.app";
327
+ if (!(apiHost == null ? void 0 : apiHost.startsWith("http"))) {
328
+ throw new Error('Your apiHost must start with "http"');
329
+ }
330
+ if (apiHost.indexOf("/", 8) > -1) {
331
+ throw new Error("Your apiHost must not contain a path element after the domain");
332
+ }
333
+ if (apiHost.indexOf("?") > -1) {
334
+ throw new Error("Your apiHost must not contain a query string");
335
+ }
336
+ if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
337
+ apiHost = apiHost.substring(0, apiHost.length - 1);
338
+ }
339
+ return apiHost;
340
+ }
341
+ static getRequestId(response) {
342
+ const apigRequestId = response.headers.get("apigw-requestid");
343
+ if (apigRequestId) {
344
+ return apigRequestId;
345
+ }
346
+ return void 0;
347
+ }
348
+ };
349
+ async function handleRateLimits(callApi) {
350
+ var _a;
351
+ const backoffRetries = 5;
352
+ let backoffRetriesLeft = backoffRetries;
353
+ let response;
354
+ while (backoffRetriesLeft > 0) {
355
+ response = await callApi();
356
+ if (response.status !== 429) {
357
+ break;
358
+ }
359
+ let resetWait = 0;
360
+ try {
361
+ const responseClone = response.clone();
362
+ const dateHeader = responseClone.headers.get("date");
363
+ const serverTime = dateHeader ? new Date(dateHeader).getTime() : void 0;
364
+ const body = await responseClone.json();
365
+ const resetTime = (_a = body == null ? void 0 : body.info) == null ? void 0 : _a.reset;
366
+ if (typeof serverTime === "number" && typeof resetTime === "number") {
367
+ resetWait = Math.max(0, Math.min(Math.round(1.1 * (resetTime - serverTime)), 1e4));
368
+ }
369
+ } catch (e) {
370
+ }
371
+ const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
372
+ const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
373
+ await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
374
+ backoffRetriesLeft -= 1;
375
+ }
376
+ return response;
377
+ }
378
+ var _url;
379
+ var _AggregateClient = class _AggregateClient2 extends ApiClient {
380
+ constructor(options) {
381
+ super(options);
382
+ }
383
+ /** Fetches all aggregates for a project */
384
+ async get(options) {
385
+ const { projectId } = this.options;
386
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url), { ...options, projectId });
387
+ return await this.apiClient(fetchUri);
388
+ }
389
+ /** Updates or creates (based on id) an Aggregate */
390
+ async upsert(body) {
391
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
392
+ await this.apiClient(fetchUri, {
393
+ method: "PUT",
394
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
395
+ expectNoContent: true
396
+ });
397
+ }
398
+ /** Deletes an Aggregate */
399
+ async remove(body) {
400
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
401
+ await this.apiClient(fetchUri, {
402
+ method: "DELETE",
403
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
404
+ expectNoContent: true
405
+ });
406
+ }
407
+ };
408
+ _url = /* @__PURE__ */ new WeakMap();
409
+ __privateAdd(_AggregateClient, _url, "/api/v2/aggregate");
410
+ var _url2;
411
+ var _DimensionClient = class _DimensionClient2 extends ApiClient {
412
+ constructor(options) {
413
+ super(options);
414
+ }
415
+ /** Fetches the known score dimensions for a project */
416
+ async get(options) {
417
+ const { projectId } = this.options;
418
+ const fetchUri = this.createUrl(__privateGet(_DimensionClient2, _url2), { ...options, projectId });
419
+ return await this.apiClient(fetchUri);
420
+ }
421
+ };
422
+ _url2 = /* @__PURE__ */ new WeakMap();
423
+ __privateAdd(_DimensionClient, _url2, "/api/v2/dimension");
424
+ var _url3;
425
+ var _valueUrl;
426
+ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
427
+ constructor(options) {
428
+ super(options);
429
+ }
430
+ /** Fetches all enrichments and values for a project, grouped by category */
431
+ async get(options) {
432
+ const { projectId } = this.options;
433
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3), { ...options, projectId });
434
+ return await this.apiClient(fetchUri);
435
+ }
436
+ /** Updates or creates (based on id) an enrichment category */
437
+ async upsertCategory(body) {
438
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
439
+ await this.apiClient(fetchUri, {
440
+ method: "PUT",
441
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
442
+ expectNoContent: true
443
+ });
444
+ }
445
+ /** Deletes an enrichment category */
446
+ async removeCategory(body) {
447
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
448
+ await this.apiClient(fetchUri, {
449
+ method: "DELETE",
450
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
451
+ expectNoContent: true
452
+ });
453
+ }
454
+ /** Updates or creates (based on id) an enrichment value within an enrichment category */
455
+ async upsertValue(body) {
456
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
457
+ await this.apiClient(fetchUri, {
458
+ method: "PUT",
459
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
460
+ expectNoContent: true
461
+ });
462
+ }
463
+ /** Deletes an enrichment value within an enrichment category. The category is left alone. */
464
+ async removeValue(body) {
465
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
466
+ await this.apiClient(fetchUri, {
467
+ method: "DELETE",
468
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
469
+ expectNoContent: true
470
+ });
471
+ }
472
+ };
473
+ _url3 = /* @__PURE__ */ new WeakMap();
474
+ _valueUrl = /* @__PURE__ */ new WeakMap();
475
+ __privateAdd(_EnrichmentClient, _url3, "/api/v1/enrichments");
476
+ __privateAdd(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
477
+ var _url4;
478
+ var _ManifestClient = class _ManifestClient2 extends ApiClient {
479
+ constructor(options) {
480
+ super(options);
481
+ }
482
+ /** Fetches the Context manifest for a project */
483
+ async get(options) {
484
+ const { projectId } = this.options;
485
+ const fetchUri = this.createUrl(__privateGet(_ManifestClient2, _url4), { ...options, projectId });
486
+ return await this.apiClient(fetchUri);
487
+ }
488
+ /** Publishes the Context manifest for a project */
489
+ async publish() {
490
+ const { projectId } = this.options;
491
+ const fetchUri = this.createUrl("/api/v1/publish", { siteId: projectId });
492
+ await this.apiClient(fetchUri, {
493
+ method: "POST",
494
+ expectNoContent: true
495
+ });
496
+ }
497
+ };
498
+ _url4 = /* @__PURE__ */ new WeakMap();
499
+ __privateAdd(_ManifestClient, _url4, "/api/v2/manifest");
500
+ var _url5;
501
+ var _QuirkClient = class _QuirkClient2 extends ApiClient {
502
+ constructor(options) {
503
+ super(options);
504
+ }
505
+ /** Fetches all Quirks for a project */
506
+ async get(options) {
507
+ const { projectId } = this.options;
508
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5), { ...options, projectId });
509
+ return await this.apiClient(fetchUri);
510
+ }
511
+ /** Updates or creates (based on id) a Quirk */
512
+ async upsert(body) {
513
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
514
+ await this.apiClient(fetchUri, {
515
+ method: "PUT",
516
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
517
+ expectNoContent: true
518
+ });
519
+ }
520
+ /** Deletes a Quirk */
521
+ async remove(body) {
522
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
523
+ await this.apiClient(fetchUri, {
524
+ method: "DELETE",
525
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
526
+ expectNoContent: true
527
+ });
528
+ }
529
+ };
530
+ _url5 = /* @__PURE__ */ new WeakMap();
531
+ __privateAdd(_QuirkClient, _url5, "/api/v2/quirk");
532
+ var _url6;
533
+ var _SignalClient = class _SignalClient2 extends ApiClient {
534
+ constructor(options) {
535
+ super(options);
536
+ }
537
+ /** Fetches all Signals for a project */
538
+ async get(options) {
539
+ const { projectId } = this.options;
540
+ const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6), { ...options, projectId });
541
+ return await this.apiClient(fetchUri);
542
+ }
543
+ /** Updates or creates (based on id) a Signal */
544
+ async upsert(body) {
545
+ const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
546
+ await this.apiClient(fetchUri, {
547
+ method: "PUT",
548
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
549
+ expectNoContent: true
550
+ });
551
+ }
552
+ /** Deletes a Signal */
553
+ async remove(body) {
554
+ const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
555
+ await this.apiClient(fetchUri, {
556
+ method: "DELETE",
557
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
558
+ expectNoContent: true
559
+ });
560
+ }
561
+ };
562
+ _url6 = /* @__PURE__ */ new WeakMap();
563
+ __privateAdd(_SignalClient, _url6, "/api/v2/signal");
564
+ var _url7;
565
+ var _TestClient = class _TestClient2 extends ApiClient {
566
+ constructor(options) {
567
+ super(options);
568
+ }
569
+ /** Fetches all Tests for a project */
570
+ async get(options) {
571
+ const { projectId } = this.options;
572
+ const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7), { ...options, projectId });
573
+ return await this.apiClient(fetchUri);
574
+ }
575
+ /** Updates or creates (based on id) a Test */
576
+ async upsert(body) {
577
+ const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
578
+ await this.apiClient(fetchUri, {
579
+ method: "PUT",
580
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
581
+ expectNoContent: true
582
+ });
583
+ }
584
+ /** Deletes a Test */
585
+ async remove(body) {
586
+ const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
587
+ await this.apiClient(fetchUri, {
588
+ method: "DELETE",
589
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
590
+ expectNoContent: true
591
+ });
592
+ }
593
+ };
594
+ _url7 = /* @__PURE__ */ new WeakMap();
595
+ __privateAdd(_TestClient, _url7, "/api/v2/test");
596
+
597
+ // ../canvas/dist/index.mjs
598
+ var __create2 = Object.create;
599
+ var __defProp3 = Object.defineProperty;
600
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
601
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
602
+ var __getProtoOf2 = Object.getPrototypeOf;
603
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
604
+ var __typeError2 = (msg) => {
605
+ throw TypeError(msg);
606
+ };
607
+ var __commonJS2 = (cb, mod) => function __require() {
608
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
609
+ };
610
+ var __copyProps2 = (to, from, except, desc) => {
611
+ if (from && typeof from === "object" || typeof from === "function") {
612
+ for (let key of __getOwnPropNames2(from))
613
+ if (!__hasOwnProp2.call(to, key) && key !== except)
614
+ __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
615
+ }
616
+ return to;
617
+ };
618
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
619
+ // If the importer is in node compatibility mode or this is not an ESM
620
+ // file that has been converted to a CommonJS file using a Babel-
621
+ // compatible transform (i.e. "__esModule" has not been set), then set
622
+ // "default" to the CommonJS "module.exports" for node compatibility.
623
+ isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target,
624
+ mod
625
+ ));
626
+ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
627
+ var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
628
+ var __privateAdd2 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
629
+ var require_yocto_queue2 = __commonJS2({
630
+ "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports, module) {
631
+ "use strict";
632
+ var Node = class {
633
+ /// value;
634
+ /// next;
635
+ constructor(value) {
636
+ this.value = value;
637
+ this.next = void 0;
638
+ }
639
+ };
640
+ var Queue = class {
641
+ // TODO: Use private class fields when targeting Node.js 12.
642
+ // #_head;
643
+ // #_tail;
644
+ // #_size;
645
+ constructor() {
646
+ this.clear();
647
+ }
648
+ enqueue(value) {
649
+ const node = new Node(value);
650
+ if (this._head) {
651
+ this._tail.next = node;
652
+ this._tail = node;
653
+ } else {
654
+ this._head = node;
655
+ this._tail = node;
656
+ }
657
+ this._size++;
658
+ }
659
+ dequeue() {
660
+ const current = this._head;
661
+ if (!current) {
662
+ return;
663
+ }
664
+ this._head = this._head.next;
665
+ this._size--;
666
+ return current.value;
667
+ }
668
+ clear() {
669
+ this._head = void 0;
670
+ this._tail = void 0;
671
+ this._size = 0;
672
+ }
673
+ get size() {
674
+ return this._size;
675
+ }
676
+ *[Symbol.iterator]() {
677
+ let current = this._head;
678
+ while (current) {
679
+ yield current.value;
680
+ current = current.next;
681
+ }
682
+ }
683
+ };
684
+ module.exports = Queue;
685
+ }
686
+ });
687
+ var require_p_limit2 = __commonJS2({
688
+ "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports, module) {
689
+ "use strict";
690
+ var Queue = require_yocto_queue2();
691
+ var pLimit2 = (concurrency) => {
692
+ if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
693
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
694
+ }
695
+ const queue = new Queue();
696
+ let activeCount = 0;
697
+ const next = () => {
698
+ activeCount--;
699
+ if (queue.size > 0) {
700
+ queue.dequeue()();
701
+ }
702
+ };
703
+ const run = async (fn, resolve, ...args) => {
704
+ activeCount++;
705
+ const result = (async () => fn(...args))();
706
+ resolve(result);
707
+ try {
708
+ await result;
709
+ } catch (e) {
710
+ }
711
+ next();
712
+ };
713
+ const enqueue = (fn, resolve, ...args) => {
714
+ queue.enqueue(run.bind(null, fn, resolve, ...args));
715
+ (async () => {
716
+ await Promise.resolve();
717
+ if (activeCount < concurrency && queue.size > 0) {
718
+ queue.dequeue()();
719
+ }
720
+ })();
721
+ };
722
+ const generator = (fn, ...args) => new Promise((resolve) => {
723
+ enqueue(fn, resolve, ...args);
724
+ });
725
+ Object.defineProperties(generator, {
726
+ activeCount: {
727
+ get: () => activeCount
728
+ },
729
+ pendingCount: {
730
+ get: () => queue.size
731
+ },
732
+ clearQueue: {
733
+ value: () => {
734
+ queue.clear();
735
+ }
736
+ }
737
+ });
738
+ return generator;
739
+ };
740
+ module.exports = pLimit2;
741
+ }
742
+ });
743
+ var require_retry_operation = __commonJS2({
744
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module) {
745
+ "use strict";
746
+ function RetryOperation(timeouts, options) {
747
+ if (typeof options === "boolean") {
748
+ options = { forever: options };
749
+ }
750
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
751
+ this._timeouts = timeouts;
752
+ this._options = options || {};
753
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
754
+ this._fn = null;
755
+ this._errors = [];
756
+ this._attempts = 1;
757
+ this._operationTimeout = null;
758
+ this._operationTimeoutCb = null;
759
+ this._timeout = null;
760
+ this._operationStart = null;
761
+ this._timer = null;
762
+ if (this._options.forever) {
763
+ this._cachedTimeouts = this._timeouts.slice(0);
764
+ }
765
+ }
766
+ module.exports = RetryOperation;
767
+ RetryOperation.prototype.reset = function() {
768
+ this._attempts = 1;
769
+ this._timeouts = this._originalTimeouts.slice(0);
770
+ };
771
+ RetryOperation.prototype.stop = function() {
772
+ if (this._timeout) {
773
+ clearTimeout(this._timeout);
774
+ }
775
+ if (this._timer) {
776
+ clearTimeout(this._timer);
777
+ }
778
+ this._timeouts = [];
779
+ this._cachedTimeouts = null;
780
+ };
781
+ RetryOperation.prototype.retry = function(err) {
782
+ if (this._timeout) {
783
+ clearTimeout(this._timeout);
784
+ }
785
+ if (!err) {
786
+ return false;
787
+ }
788
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
789
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
790
+ this._errors.push(err);
791
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
792
+ return false;
793
+ }
794
+ this._errors.push(err);
795
+ var timeout = this._timeouts.shift();
796
+ if (timeout === void 0) {
797
+ if (this._cachedTimeouts) {
798
+ this._errors.splice(0, this._errors.length - 1);
799
+ timeout = this._cachedTimeouts.slice(-1);
800
+ } else {
801
+ return false;
802
+ }
803
+ }
804
+ var self = this;
805
+ this._timer = setTimeout(function() {
806
+ self._attempts++;
807
+ if (self._operationTimeoutCb) {
808
+ self._timeout = setTimeout(function() {
809
+ self._operationTimeoutCb(self._attempts);
810
+ }, self._operationTimeout);
811
+ if (self._options.unref) {
812
+ self._timeout.unref();
813
+ }
814
+ }
815
+ self._fn(self._attempts);
816
+ }, timeout);
817
+ if (this._options.unref) {
818
+ this._timer.unref();
819
+ }
820
+ return true;
821
+ };
822
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
823
+ this._fn = fn;
824
+ if (timeoutOps) {
825
+ if (timeoutOps.timeout) {
826
+ this._operationTimeout = timeoutOps.timeout;
827
+ }
828
+ if (timeoutOps.cb) {
829
+ this._operationTimeoutCb = timeoutOps.cb;
830
+ }
831
+ }
832
+ var self = this;
833
+ if (this._operationTimeoutCb) {
834
+ this._timeout = setTimeout(function() {
835
+ self._operationTimeoutCb();
836
+ }, self._operationTimeout);
837
+ }
838
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
839
+ this._fn(this._attempts);
840
+ };
841
+ RetryOperation.prototype.try = function(fn) {
842
+ console.log("Using RetryOperation.try() is deprecated");
843
+ this.attempt(fn);
844
+ };
845
+ RetryOperation.prototype.start = function(fn) {
846
+ console.log("Using RetryOperation.start() is deprecated");
847
+ this.attempt(fn);
848
+ };
849
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
850
+ RetryOperation.prototype.errors = function() {
851
+ return this._errors;
852
+ };
853
+ RetryOperation.prototype.attempts = function() {
854
+ return this._attempts;
855
+ };
856
+ RetryOperation.prototype.mainError = function() {
857
+ if (this._errors.length === 0) {
858
+ return null;
859
+ }
860
+ var counts = {};
861
+ var mainError = null;
862
+ var mainErrorCount = 0;
863
+ for (var i = 0; i < this._errors.length; i++) {
864
+ var error = this._errors[i];
865
+ var message = error.message;
866
+ var count = (counts[message] || 0) + 1;
867
+ counts[message] = count;
868
+ if (count >= mainErrorCount) {
869
+ mainError = error;
870
+ mainErrorCount = count;
871
+ }
872
+ }
873
+ return mainError;
874
+ };
875
+ }
876
+ });
877
+ var require_retry = __commonJS2({
878
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
879
+ "use strict";
880
+ var RetryOperation = require_retry_operation();
881
+ exports.operation = function(options) {
882
+ var timeouts = exports.timeouts(options);
883
+ return new RetryOperation(timeouts, {
884
+ forever: options && (options.forever || options.retries === Infinity),
885
+ unref: options && options.unref,
886
+ maxRetryTime: options && options.maxRetryTime
887
+ });
888
+ };
889
+ exports.timeouts = function(options) {
890
+ if (options instanceof Array) {
891
+ return [].concat(options);
892
+ }
893
+ var opts = {
894
+ retries: 10,
895
+ factor: 2,
896
+ minTimeout: 1 * 1e3,
897
+ maxTimeout: Infinity,
898
+ randomize: false
899
+ };
900
+ for (var key in options) {
901
+ opts[key] = options[key];
902
+ }
903
+ if (opts.minTimeout > opts.maxTimeout) {
904
+ throw new Error("minTimeout is greater than maxTimeout");
905
+ }
906
+ var timeouts = [];
907
+ for (var i = 0; i < opts.retries; i++) {
908
+ timeouts.push(this.createTimeout(i, opts));
909
+ }
910
+ if (options && options.forever && !timeouts.length) {
911
+ timeouts.push(this.createTimeout(i, opts));
912
+ }
913
+ timeouts.sort(function(a, b) {
914
+ return a - b;
915
+ });
916
+ return timeouts;
917
+ };
918
+ exports.createTimeout = function(attempt, opts) {
919
+ var random = opts.randomize ? Math.random() + 1 : 1;
920
+ var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
921
+ timeout = Math.min(timeout, opts.maxTimeout);
922
+ return timeout;
923
+ };
924
+ exports.wrap = function(obj, options, methods) {
925
+ if (options instanceof Array) {
926
+ methods = options;
927
+ options = null;
928
+ }
929
+ if (!methods) {
930
+ methods = [];
931
+ for (var key in obj) {
932
+ if (typeof obj[key] === "function") {
933
+ methods.push(key);
934
+ }
935
+ }
936
+ }
937
+ for (var i = 0; i < methods.length; i++) {
938
+ var method = methods[i];
939
+ var original = obj[method];
940
+ obj[method] = function retryWrapper(original2) {
941
+ var op = exports.operation(options);
942
+ var args = Array.prototype.slice.call(arguments, 1);
943
+ var callback = args.pop();
944
+ args.push(function(err) {
945
+ if (op.retry(err)) {
946
+ return;
947
+ }
948
+ if (err) {
949
+ arguments[0] = op.mainError();
950
+ }
951
+ callback.apply(this, arguments);
952
+ });
953
+ op.attempt(function() {
954
+ original2.apply(obj, args);
955
+ });
956
+ }.bind(obj, original);
957
+ obj[method].options = options;
958
+ }
959
+ };
960
+ }
961
+ });
962
+ var require_retry2 = __commonJS2({
963
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module) {
964
+ "use strict";
965
+ module.exports = require_retry();
966
+ }
967
+ });
968
+ var import_p_limit2 = __toESM2(require_p_limit2());
969
+ var import_retry = __toESM2(require_retry2(), 1);
970
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
971
+ function rewriteFilters(filters) {
972
+ return Object.entries(filters != null ? filters : {}).reduce(
973
+ (acc, [key, value]) => {
974
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
975
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
976
+ return {
977
+ ...acc,
978
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
979
+ };
980
+ },
981
+ {}
982
+ );
983
+ }
984
+ var _contentTypesUrl;
985
+ var _entriesUrl;
986
+ var _ContentClient = class _ContentClient2 extends ApiClient {
987
+ constructor(options) {
988
+ var _a;
989
+ super(options);
990
+ this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
991
+ }
992
+ getContentTypes(options) {
993
+ const { projectId } = this.options;
994
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl), { ...options, projectId });
995
+ return this.apiClient(fetchUri);
996
+ }
997
+ getEntries(options) {
998
+ const { projectId } = this.options;
999
+ const { skipDataResolution, filters, ...params } = options;
1000
+ const rewrittenFilters = rewriteFilters(filters);
1001
+ if (skipDataResolution) {
1002
+ const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1003
+ return this.apiClient(url);
1004
+ }
1005
+ const edgeUrl = this.createUrl(
1006
+ __privateGet2(_ContentClient2, _entriesUrl),
1007
+ { ...this.getEdgeOptions(params), ...rewrittenFilters },
1008
+ this.edgeApiHost
1009
+ );
1010
+ return this.apiClient(
1011
+ edgeUrl,
1012
+ this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
1013
+ );
1014
+ }
1015
+ /** Fetches historical versions of an entry */
1016
+ async getEntryHistory(options) {
1017
+ const historyUrl = this.createUrl("/api/v1/entries-history", {
1018
+ ...options,
1019
+ projectId: this.options.projectId
1020
+ });
1021
+ return this.apiClient(historyUrl);
1022
+ }
1023
+ async upsertContentType(body, opts = {}) {
1024
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1025
+ if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
1026
+ delete body.contentType.slugSettings;
1027
+ }
1028
+ await this.apiClient(fetchUri, {
1029
+ method: "PUT",
1030
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1031
+ expectNoContent: true,
1032
+ headers: opts.autogenerateDataTypes ? { "x-uniform-autogenerate-data-types": "true" } : {}
1033
+ });
1034
+ }
1035
+ async upsertEntry(body, options) {
1036
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1037
+ const headers = {};
1038
+ if (options == null ? void 0 : options.ifUnmodifiedSince) {
1039
+ headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
1040
+ }
1041
+ const { response } = await this.apiClientWithResponse(fetchUri, {
1042
+ method: "PUT",
1043
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1044
+ expectNoContent: true,
1045
+ headers
1046
+ });
1047
+ return { modified: response.headers.get("x-modified-at") };
1048
+ }
1049
+ async deleteContentType(body) {
1050
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1051
+ await this.apiClient(fetchUri, {
1052
+ method: "DELETE",
1053
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1054
+ expectNoContent: true
1055
+ });
1056
+ }
1057
+ async deleteEntry(body) {
1058
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1059
+ await this.apiClient(fetchUri, {
1060
+ method: "DELETE",
1061
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1062
+ expectNoContent: true
1063
+ });
1064
+ }
1065
+ getEdgeOptions(options) {
1066
+ const { projectId } = this.options;
1067
+ const { skipDataResolution, ...params } = options;
1068
+ return {
1069
+ projectId,
1070
+ ...params,
1071
+ diagnostics: typeof options.diagnostics === "boolean" ? options.diagnostics : options.diagnostics === "no-data" ? "no-data" : void 0
1072
+ };
1073
+ }
1074
+ };
1075
+ _contentTypesUrl = /* @__PURE__ */ new WeakMap();
1076
+ _entriesUrl = /* @__PURE__ */ new WeakMap();
1077
+ __privateAdd2(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1078
+ __privateAdd2(_ContentClient, _entriesUrl, "/api/v1/entries");
1079
+ var _url8;
1080
+ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1081
+ constructor(options) {
1082
+ super(options);
1083
+ }
1084
+ /** Fetches all DataTypes for a project */
1085
+ async get(options) {
1086
+ const { projectId } = this.options;
1087
+ const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8), { ...options, projectId });
1088
+ return await this.apiClient(fetchUri);
1089
+ }
1090
+ /** Updates or creates (based on id) a DataType */
1091
+ async upsert(body) {
1092
+ const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1093
+ await this.apiClient(fetchUri, {
1094
+ method: "PUT",
1095
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1096
+ expectNoContent: true
1097
+ });
1098
+ }
1099
+ /** Deletes a DataType */
1100
+ async remove(body) {
1101
+ const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1102
+ await this.apiClient(fetchUri, {
1103
+ method: "DELETE",
1104
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1105
+ expectNoContent: true
1106
+ });
1107
+ }
1108
+ };
1109
+ _url8 = /* @__PURE__ */ new WeakMap();
1110
+ __privateAdd2(_DataTypeClient, _url8, "/api/v1/data-types");
1111
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1112
+ var _baseUrl;
1113
+ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2 extends ApiClient {
1114
+ constructor(options) {
1115
+ super(options);
1116
+ this.teamId = options.teamId;
1117
+ }
1118
+ /**
1119
+ * Gets a list of property type and hook names for the current team, including public integrations' hooks.
1120
+ */
1121
+ get(options) {
1122
+ const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl), {
1123
+ ...options,
1124
+ teamId: this.teamId
1125
+ });
1126
+ return this.apiClient(fetchUri);
1127
+ }
1128
+ /**
1129
+ * Creates or updates a custom AI property editor on a Mesh app.
1130
+ */
1131
+ async deploy(body) {
1132
+ const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1133
+ await this.apiClient(fetchUri, {
1134
+ method: "PUT",
1135
+ body: JSON.stringify({ ...body, teamId: this.teamId }),
1136
+ expectNoContent: true
1137
+ });
1138
+ }
1139
+ /**
1140
+ * Removes a custom AI property editor from a Mesh app.
1141
+ */
1142
+ async delete(body) {
1143
+ const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1144
+ await this.apiClient(fetchUri, {
1145
+ method: "DELETE",
1146
+ body: JSON.stringify({ ...body, teamId: this.teamId }),
1147
+ expectNoContent: true
1148
+ });
1149
+ }
1150
+ };
1151
+ _baseUrl = /* @__PURE__ */ new WeakMap();
1152
+ __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1153
+ var _url22;
1154
+ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1155
+ constructor(options) {
1156
+ super({ ...options, bypassCache: true });
1157
+ }
1158
+ /** Fetches single Project */
1159
+ async get(options) {
1160
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1161
+ return await this.apiClient(fetchUri);
1162
+ }
1163
+ /** Updates or creates (based on id) a Project */
1164
+ async upsert(body) {
1165
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1166
+ return await this.apiClient(fetchUri, {
1167
+ method: "PUT",
1168
+ body: JSON.stringify({ ...body })
1169
+ });
1170
+ }
1171
+ /** Deletes a Project */
1172
+ async delete(body) {
1173
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1174
+ await this.apiClient(fetchUri, {
1175
+ method: "DELETE",
1176
+ body: JSON.stringify({ ...body }),
1177
+ expectNoContent: true
1178
+ });
1179
+ }
1180
+ };
1181
+ _url22 = /* @__PURE__ */ new WeakMap();
1182
+ __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1183
+ var ATTRIBUTE_COMPONENT_ID = "data-uniform-component-id";
1184
+ var ATTRIBUTE_PARAMETER_ID = "data-uniform-parameter-id";
1185
+ var ATTRIBUTE_PARAMETER_TYPE = "data-uniform-parameter-type";
1186
+
1187
+ // src/components/UniformRichText.tsx
1188
+ import {
1189
+ isRichTextValue,
1190
+ isRichTextValueConsideredEmpty
1191
+ } from "@uniformdev/richtext";
1192
+ import React12 from "react";
1193
+
1194
+ // src/components/UniformRichTextNode.tsx
1195
+ import { isRichTextNode } from "@uniformdev/richtext";
1196
+ import React11 from "react";
1197
+
1198
+ // src/components/nodes/AssetRichTextNode.tsx
1199
+ import React from "react";
1200
+ var AssetRichTextNode = ({ node }) => {
1201
+ var _a, _b;
1202
+ const { __asset } = node;
1203
+ if (__asset === void 0) {
1204
+ return null;
1205
+ }
1206
+ if (__asset.type === "image") {
1207
+ return /* @__PURE__ */ React.createElement("figure", null, /* @__PURE__ */ React.createElement("img", { src: __asset.fields.url.value, alt: (_a = __asset.fields.title) == null ? void 0 : _a.value }), ((_b = __asset.fields.description) == null ? void 0 : _b.value) ? /* @__PURE__ */ React.createElement("figcaption", null, __asset.fields.description.value) : null);
1208
+ }
1209
+ if (__asset.type === "video") {
1210
+ return /* @__PURE__ */ React.createElement("video", { src: __asset.fields.url.value, controls: true });
1211
+ }
1212
+ if (__asset.type === "audio") {
1213
+ return /* @__PURE__ */ React.createElement("audio", { src: __asset.fields.url.value, controls: true });
1214
+ }
1215
+ return null;
1216
+ };
1217
+
1218
+ // src/components/nodes/HeadingRichTextNode.tsx
1219
+ import React2 from "react";
1220
+ var HeadingRichTextNode = ({ children, node }) => {
1221
+ const { tag } = node;
1222
+ const HTag = tag != null ? tag : "h1";
1223
+ return /* @__PURE__ */ React2.createElement(HTag, null, children);
1224
+ };
1225
+
1226
+ // src/components/nodes/LinebreakRichTextNode.tsx
1227
+ import React3 from "react";
1228
+ var LinebreakRichTextNode = () => {
1229
+ return /* @__PURE__ */ React3.createElement("br", null);
1230
+ };
1231
+
1232
+ // src/components/nodes/LinkRichTextNode.tsx
1233
+ import { linkParamValueToHref } from "@uniformdev/richtext";
1234
+ import React4 from "react";
1235
+ var LinkRichTextNode = ({ children, node }) => {
1236
+ const { link } = node;
1237
+ return /* @__PURE__ */ React4.createElement("a", { href: linkParamValueToHref(link) }, children);
1238
+ };
1239
+
1240
+ // src/components/nodes/ListItemRichTextNode.tsx
1241
+ import React5 from "react";
1242
+ var ListItemRichTextNode = ({ children, node }) => {
1243
+ const { value } = node;
1244
+ return /* @__PURE__ */ React5.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
1245
+ };
1246
+
1247
+ // src/components/nodes/ListRichTextNode.tsx
1248
+ import React6 from "react";
1249
+ var ListRichTextNode = ({ children, node }) => {
1250
+ const { tag, start } = node;
1251
+ const ListTag = tag != null ? tag : "ul";
1252
+ return /* @__PURE__ */ React6.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
1253
+ };
1254
+
1255
+ // src/components/nodes/ParagraphRichTextNode.tsx
1256
+ import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
1257
+ import React7 from "react";
1258
+ var ParagraphRichTextNode = ({ children, node }) => {
1259
+ const { format, direction } = node;
1260
+ return /* @__PURE__ */ React7.createElement(
1261
+ "p",
1262
+ {
1263
+ dir: isPureDirection(direction) ? direction : void 0,
1264
+ style: isPureTextAlign(format) ? { textAlign: format } : void 0
1265
+ },
1266
+ children
1267
+ );
1268
+ };
1269
+
1270
+ // src/components/nodes/TableCellRichTextNode.tsx
1271
+ import { getRichTextTagFromTableCellHeaderState } from "@uniformdev/richtext";
1272
+ import React8 from "react";
1273
+ var TableCellRichTextNode = ({ children, node }) => {
1274
+ const { headerState } = node;
1275
+ const TableCellTag = getRichTextTagFromTableCellHeaderState(headerState);
1276
+ return /* @__PURE__ */ React8.createElement(TableCellTag, null, children);
1277
+ };
1278
+
1279
+ // src/components/nodes/TabRichTextNode.tsx
1280
+ import React9 from "react";
1281
+ var TabRichTextNode = () => {
1282
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, " ");
1283
+ };
1284
+
1285
+ // src/components/nodes/TextRichTextNode.tsx
1286
+ import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
1287
+ import React10 from "react";
1288
+ var TextRichTextNode = ({ node }) => {
1289
+ const { text, format } = node;
1290
+ const tags = getRichTextTagsFromTextFormat(format);
1291
+ return /* @__PURE__ */ React10.createElement(React10.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React10.createElement(Tag, null, children), text) : text);
1292
+ };
1293
+
1294
+ // src/components/UniformRichTextNode.tsx
1295
+ function UniformRichTextNode({ node, ...props }) {
1296
+ var _a;
1297
+ if (!isRichTextNode(node)) return null;
1298
+ let NodeRenderer = (_a = props.resolveRichTextRenderer) == null ? void 0 : _a.call(props, node);
1299
+ if (typeof NodeRenderer === "undefined") {
1300
+ NodeRenderer = resolveRichTextDefaultRenderer(node);
1301
+ }
1302
+ if (!NodeRenderer) {
1303
+ return null;
1304
+ }
1305
+ const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React11.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
1306
+ return /* @__PURE__ */ React11.createElement(NodeRenderer, { node }, children);
1307
+ }
1308
+ var rendererMap = /* @__PURE__ */ new Map([
1309
+ ["heading", HeadingRichTextNode],
1310
+ ["linebreak", LinebreakRichTextNode],
1311
+ ["link", LinkRichTextNode],
1312
+ ["list", ListRichTextNode],
1313
+ ["listitem", ListItemRichTextNode],
1314
+ ["paragraph", ParagraphRichTextNode],
1315
+ ["quote", ({ children }) => /* @__PURE__ */ React11.createElement("blockquote", null, children)],
1316
+ [
1317
+ "code",
1318
+ ({ children }) => /* @__PURE__ */ React11.createElement("pre", null, /* @__PURE__ */ React11.createElement("code", null, children))
1319
+ ],
1320
+ ["root", ({ children }) => /* @__PURE__ */ React11.createElement(React11.Fragment, null, children)],
1321
+ ["text", TextRichTextNode],
1322
+ ["tab", TabRichTextNode],
1323
+ [
1324
+ "table",
1325
+ ({ children }) => /* @__PURE__ */ React11.createElement("table", null, /* @__PURE__ */ React11.createElement("tbody", null, children))
1326
+ ],
1327
+ ["tablerow", ({ children }) => /* @__PURE__ */ React11.createElement("tr", null, children)],
1328
+ ["tablecell", TableCellRichTextNode],
1329
+ ["asset", AssetRichTextNode]
1330
+ ]);
1331
+ var resolveRichTextDefaultRenderer = (node) => {
1332
+ return rendererMap.get(node.type);
1333
+ };
1334
+
1335
+ // src/components/UniformRichText.tsx
1336
+ var UniformRichText = React12.forwardRef(function UniformRichText2({
1337
+ component,
1338
+ resolveRichTextRenderer,
1339
+ as: Tag = "div",
1340
+ parameter,
1341
+ placeholder,
1342
+ ...props
1343
+ }, ref) {
1344
+ var _a;
1345
+ const isContextualEditing = (_a = parameter == null ? void 0 : parameter._contextualEditing) != null ? _a : false;
1346
+ if (!parameter) {
1347
+ return null;
1348
+ }
1349
+ const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameter.parameterId }) : placeholder;
1350
+ const value = parameter.value;
1351
+ if (!value || !isRichTextValue(value)) return null;
1352
+ if (!isContextualEditing && isRichTextValueConsideredEmpty(value)) return null;
1353
+ return Tag === null ? /* @__PURE__ */ React12.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React12.createElement(
1354
+ Tag,
1355
+ {
1356
+ ref,
1357
+ ...props,
1358
+ ...isContextualEditing ? {
1359
+ [ATTRIBUTE_COMPONENT_ID]: component._id,
1360
+ [ATTRIBUTE_PARAMETER_ID]: parameter.parameterId,
1361
+ [ATTRIBUTE_PARAMETER_TYPE]: "richText"
1362
+ } : {}
1363
+ },
1364
+ isRichTextValueConsideredEmpty(value) ? /* @__PURE__ */ React12.createElement("p", null, /* @__PURE__ */ React12.createElement("i", null, computedPlaceholder)) : /* @__PURE__ */ React12.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
1365
+ );
1366
+ });
1367
+
1368
+ // src/components/UniformText.tsx
1369
+ import { ClientUniformText } from "@uniformdev/next-app-router-client";
1370
+ import React13 from "react";
1371
+ var UniformText = (props) => {
1372
+ return /* @__PURE__ */ React13.createElement(ClientUniformText, { ...props });
1373
+ };
1374
+ export {
1375
+ UniformRichText,
1376
+ UniformSlot,
1377
+ UniformText,
1378
+ createClientUniformContext,
1379
+ getUniformSlot,
1380
+ useInitUniformContext,
1381
+ useQuirks,
1382
+ useScores,
1383
+ useUniformContext
1384
+ };