@marvalt/wadapter 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +190 -0
  3. package/dist/client/wordpress-client.d.ts +43 -0
  4. package/dist/client/wordpress-client.d.ts.map +1 -0
  5. package/dist/generators/form-protection/form-protection-generator.d.ts +46 -0
  6. package/dist/generators/form-protection/form-protection-generator.d.ts.map +1 -0
  7. package/dist/generators/gravity-forms/gravity-forms-generator.d.ts +36 -0
  8. package/dist/generators/gravity-forms/gravity-forms-generator.d.ts.map +1 -0
  9. package/dist/generators/wordpress/wordpress-generator.d.ts +53 -0
  10. package/dist/generators/wordpress/wordpress-generator.d.ts.map +1 -0
  11. package/dist/gravity-forms/gravity-forms-client.d.ts +33 -0
  12. package/dist/gravity-forms/gravity-forms-client.d.ts.map +1 -0
  13. package/dist/index.d.ts +1015 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.esm.js +2479 -0
  16. package/dist/index.esm.js.map +1 -0
  17. package/dist/index.js +2524 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/react/components/GravityForm.d.ts +28 -0
  20. package/dist/react/components/GravityForm.d.ts.map +1 -0
  21. package/dist/react/components/WordPressContent.d.ts +28 -0
  22. package/dist/react/components/WordPressContent.d.ts.map +1 -0
  23. package/dist/react/hooks/useGravityForms.d.ts +34 -0
  24. package/dist/react/hooks/useGravityForms.d.ts.map +1 -0
  25. package/dist/react/hooks/useWordPress.d.ts +32 -0
  26. package/dist/react/hooks/useWordPress.d.ts.map +1 -0
  27. package/dist/react/providers/GravityFormsProvider.d.ts +29 -0
  28. package/dist/react/providers/GravityFormsProvider.d.ts.map +1 -0
  29. package/dist/react/providers/WordPressProvider.d.ts +29 -0
  30. package/dist/react/providers/WordPressProvider.d.ts.map +1 -0
  31. package/dist/setupTests.d.ts +18 -0
  32. package/dist/setupTests.d.ts.map +1 -0
  33. package/dist/transformers/wordpress-transformers.d.ts +69 -0
  34. package/dist/transformers/wordpress-transformers.d.ts.map +1 -0
  35. package/dist/types/form-protection.d.ts +47 -0
  36. package/dist/types/form-protection.d.ts.map +1 -0
  37. package/dist/types/gravity-forms.d.ts +110 -0
  38. package/dist/types/gravity-forms.d.ts.map +1 -0
  39. package/dist/types/wordpress.d.ts +350 -0
  40. package/dist/types/wordpress.d.ts.map +1 -0
  41. package/dist/utils/config.d.ts +26 -0
  42. package/dist/utils/config.d.ts.map +1 -0
  43. package/dist/utils/validation.d.ts +28 -0
  44. package/dist/utils/validation.d.ts.map +1 -0
  45. package/package.json +84 -0
@@ -0,0 +1,2479 @@
1
+ import require$$0, { useState, useEffect, useCallback, createContext, useContext } from 'react';
2
+ import { writeFileSync } from 'fs';
3
+ import { join } from 'path';
4
+
5
+ /**
6
+ * @license GPL-3.0-or-later
7
+ *
8
+ * This file is part of the MarVAlt Open SDK.
9
+ * Copyright (c) 2025 Vibune Pty Ltd.
10
+ *
11
+ * This program is free software: you can redistribute it and/or modify
12
+ * it under the terms of the GNU General Public License as published by
13
+ * the Free Software Foundation, either version 3 of the License, or
14
+ * (at your option) any later version.
15
+ *
16
+ * This program is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
+ * See the GNU General Public License for more details.
20
+ */
21
+ class WordPressClient {
22
+ constructor(config) {
23
+ this.config = config;
24
+ }
25
+ async makeRequest(endpoint, params = {}, options = {}) {
26
+ const baseUrl = this.getBaseUrl();
27
+ const queryString = new URLSearchParams();
28
+ Object.entries(params).forEach(([key, value]) => {
29
+ if (value !== undefined && value !== null) {
30
+ if (Array.isArray(value)) {
31
+ value.forEach(v => queryString.append(key, v.toString()));
32
+ }
33
+ else {
34
+ queryString.append(key, value.toString());
35
+ }
36
+ }
37
+ });
38
+ // Construct URL based on auth mode
39
+ let url;
40
+ if (this.config.authMode === 'cloudflare_proxy' || this.config.authMode === 'supabase_proxy') {
41
+ // For proxy modes, pass the endpoint as query parameter (worker expects /wp/v2/ format)
42
+ const fullEndpoint = `${endpoint}?${queryString.toString()}`;
43
+ url = `${baseUrl}?endpoint=${encodeURIComponent(fullEndpoint)}`;
44
+ }
45
+ else {
46
+ // For direct mode, construct the full WordPress API URL
47
+ url = `${baseUrl}/wp-json${endpoint}?${queryString.toString()}`;
48
+ }
49
+ const headers = {
50
+ 'Content-Type': 'application/json',
51
+ };
52
+ // Add authentication based on mode
53
+ if (this.config.authMode === 'cloudflare_proxy') {
54
+ // Add Cloudflare proxy authentication headers
55
+ if (this.config.appId) {
56
+ headers['x-app-id'] = this.config.appId;
57
+ }
58
+ if (this.config.workerSecret) {
59
+ headers['x-app-secret'] = this.config.workerSecret;
60
+ }
61
+ if (this.config.cfAccessClientId && this.config.cfAccessClientSecret) {
62
+ headers['CF-Access-Client-Id'] = this.config.cfAccessClientId;
63
+ headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
64
+ }
65
+ }
66
+ else if (this.config.authMode === 'supabase_proxy') {
67
+ // Add Supabase proxy authentication headers
68
+ if (this.config.supabaseAnonKey) {
69
+ headers['apikey'] = this.config.supabaseAnonKey;
70
+ }
71
+ }
72
+ else {
73
+ // Direct mode - use basic auth
74
+ if (this.config.username && this.config.password) {
75
+ const credentials = btoa(`${this.config.username}:${this.config.password}`);
76
+ headers.Authorization = `Basic ${credentials}`;
77
+ }
78
+ }
79
+ console.log('🔍 WordPress API Request Debug:', {
80
+ url,
81
+ method: options.method || 'GET',
82
+ authMode: this.config.authMode,
83
+ headers: Object.keys(headers),
84
+ });
85
+ const response = await fetch(url, {
86
+ method: options.method || 'GET',
87
+ headers,
88
+ body: options.body,
89
+ signal: AbortSignal.timeout(this.config.timeout || 30000),
90
+ ...options,
91
+ });
92
+ if (!response.ok) {
93
+ console.error('❌ WordPress API Error:', {
94
+ status: response.status,
95
+ statusText: response.statusText,
96
+ url,
97
+ headers: Object.fromEntries(response.headers.entries()),
98
+ });
99
+ throw new Error(`WordPress API request failed: ${response.status} ${response.statusText}`);
100
+ }
101
+ const responseText = await response.text();
102
+ console.log('🔍 WordPress API Response:', {
103
+ status: response.status,
104
+ responseLength: responseText.length,
105
+ responsePreview: responseText.substring(0, 200),
106
+ });
107
+ if (!responseText) {
108
+ // Return empty array for empty responses (common for endpoints with no data)
109
+ return [];
110
+ }
111
+ try {
112
+ return JSON.parse(responseText);
113
+ }
114
+ catch (error) {
115
+ const message = error instanceof Error ? error.message : String(error);
116
+ console.error('❌ JSON Parse Error:', {
117
+ error: message,
118
+ responseText: responseText.substring(0, 500),
119
+ });
120
+ throw new Error(`Failed to parse JSON response: ${message}`);
121
+ }
122
+ }
123
+ getBaseUrl() {
124
+ switch (this.config.authMode) {
125
+ case 'cloudflare_proxy':
126
+ return this.config.cloudflareWorkerUrl || '';
127
+ case 'supabase_proxy':
128
+ return `${this.config.supabaseUrl}/functions/v1/wp-proxy`;
129
+ default:
130
+ return this.config.apiUrl || '';
131
+ }
132
+ }
133
+ async getPosts(params = {}) {
134
+ return this.makeRequest('/wp/v2/posts', params);
135
+ }
136
+ async getPost(id) {
137
+ return this.makeRequest(`/wp/v2/posts/${id}`);
138
+ }
139
+ async getPages(params = {}) {
140
+ return this.makeRequest('/wp/v2/pages', params);
141
+ }
142
+ async getPage(id) {
143
+ return this.makeRequest(`/wp/v2/pages/${id}`);
144
+ }
145
+ async getMedia(params = {}) {
146
+ return this.makeRequest('/wp/v2/media', params);
147
+ }
148
+ async getMediaItem(id) {
149
+ return this.makeRequest(`/wp/v2/media/${id}`);
150
+ }
151
+ async getCategories(params = {}) {
152
+ return this.makeRequest('/wp/v2/categories', params);
153
+ }
154
+ async getTags(params = {}) {
155
+ return this.makeRequest('/wp/v2/tags', params);
156
+ }
157
+ // Gravity Forms endpoints
158
+ async getGravityForms() {
159
+ return this.makeRequest('/gf-api/v1/forms');
160
+ }
161
+ async getGravityForm(formId) {
162
+ return this.makeRequest(`/gf-api/v1/forms/${formId}/config`);
163
+ }
164
+ async submitGravityForm(formId, entry) {
165
+ return this.makeRequest(`/gf-api/v1/forms/${formId}/submit`, {}, {
166
+ method: 'POST',
167
+ body: JSON.stringify(entry),
168
+ });
169
+ }
170
+ // Static data endpoints
171
+ async getStaticDataNonce() {
172
+ return this.makeRequest('/static-data/v1/nonce');
173
+ }
174
+ async getAllData(params = {}) {
175
+ const [posts, pages, media, categories, tags] = await Promise.all([
176
+ this.getPosts(params),
177
+ this.getPages(params),
178
+ this.getMedia(params),
179
+ this.getCategories(params),
180
+ this.getTags(params),
181
+ ]);
182
+ return { posts, pages, media, categories, tags };
183
+ }
184
+ }
185
+
186
+ /**
187
+ * @license GPL-3.0-or-later
188
+ *
189
+ * This file is part of the MarVAlt Open SDK.
190
+ * Copyright (c) 2025 Vibune Pty Ltd.
191
+ *
192
+ * This program is free software: you can redistribute it and/or modify
193
+ * it under the terms of the GNU General Public License as published by
194
+ * the Free Software Foundation, either version 3 of the License, or
195
+ * (at your option) any later version.
196
+ *
197
+ * This program is distributed in the hope that it will be useful,
198
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
199
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
200
+ * See the GNU General Public License for more details.
201
+ */
202
+ function transformWordPressPost(post) {
203
+ return {
204
+ id: post.id,
205
+ title: post.title.rendered,
206
+ content: post.content.rendered,
207
+ excerpt: post.excerpt.rendered,
208
+ slug: post.slug,
209
+ date: post.date,
210
+ modified: post.modified,
211
+ author: post.author,
212
+ featuredMedia: post.featured_media || null,
213
+ categories: post.categories || [],
214
+ tags: post.tags || [],
215
+ link: post.link,
216
+ };
217
+ }
218
+ function transformWordPressPage(page) {
219
+ return {
220
+ id: page.id,
221
+ title: page.title.rendered,
222
+ content: page.content.rendered,
223
+ excerpt: page.excerpt.rendered,
224
+ slug: page.slug,
225
+ date: page.date,
226
+ modified: page.modified,
227
+ author: page.author,
228
+ featuredMedia: page.featured_media || null,
229
+ parent: page.parent,
230
+ menuOrder: page.menu_order,
231
+ link: page.link,
232
+ };
233
+ }
234
+ function transformWordPressMedia(media) {
235
+ const transformedSizes = {};
236
+ if (media.media_details?.sizes) {
237
+ Object.entries(media.media_details.sizes).forEach(([key, size]) => {
238
+ transformedSizes[key] = {
239
+ file: size.file,
240
+ width: size.width,
241
+ height: size.height,
242
+ mimeType: size.mime_type,
243
+ sourceUrl: size.source_url,
244
+ };
245
+ });
246
+ }
247
+ return {
248
+ id: media.id,
249
+ title: media.title.rendered,
250
+ description: media.description.rendered,
251
+ caption: media.caption.rendered,
252
+ altText: media.alt_text,
253
+ sourceUrl: media.source_url,
254
+ mimeType: media.mime_type,
255
+ mediaType: media.media_type,
256
+ sizes: transformedSizes,
257
+ };
258
+ }
259
+ function transformWordPressPosts(posts) {
260
+ return posts.map(transformWordPressPost);
261
+ }
262
+ function transformWordPressPages(pages) {
263
+ return pages.map(transformWordPressPage);
264
+ }
265
+ function transformWordPressMediaItems(media) {
266
+ return media.map(transformWordPressMedia);
267
+ }
268
+
269
+ /**
270
+ * @license GPL-3.0-or-later
271
+ *
272
+ * This file is part of the MarVAlt Open SDK.
273
+ * Copyright (c) 2025 Vibune Pty Ltd.
274
+ *
275
+ * This program is free software: you can redistribute it and/or modify
276
+ * it under the terms of the GNU General Public License as published by
277
+ * the Free Software Foundation, either version 3 of the License, or
278
+ * (at your option) any later version.
279
+ *
280
+ * This program is distributed in the hope that it will be useful,
281
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
282
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
283
+ * See the GNU General Public License for more details.
284
+ */
285
+ class GravityFormsClient {
286
+ constructor(config) {
287
+ this.config = config;
288
+ }
289
+ async makeRequest(endpoint, options = {}) {
290
+ // Construct URL based on auth mode
291
+ let url;
292
+ if (this.config.authMode === 'cloudflare_proxy' || this.config.authMode === 'supabase_proxy') {
293
+ // For proxy modes, pass the endpoint as query parameter
294
+ const baseUrl = this.getBaseUrl();
295
+ url = `${baseUrl}?endpoint=${encodeURIComponent(endpoint)}`;
296
+ }
297
+ else {
298
+ // For direct mode, construct the full API URL
299
+ url = `${this.config.apiUrl}${endpoint}`;
300
+ }
301
+ const headers = {
302
+ 'Content-Type': 'application/json',
303
+ ...options.headers,
304
+ };
305
+ // Add authentication based on mode
306
+ if (this.config.authMode === 'cloudflare_proxy') {
307
+ // Add Cloudflare proxy authentication headers
308
+ if (this.config.appId) {
309
+ headers['x-app-id'] = this.config.appId;
310
+ }
311
+ if (this.config.workerSecret) {
312
+ headers['x-app-secret'] = this.config.workerSecret;
313
+ headers['x-worker-secret'] = this.config.workerSecret; // legacy/alt header supported by Worker
314
+ }
315
+ if (this.config.cfAccessClientId && this.config.cfAccessClientSecret) {
316
+ headers['CF-Access-Client-Id'] = this.config.cfAccessClientId;
317
+ headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
318
+ }
319
+ }
320
+ else if (this.config.authMode === 'supabase_proxy') {
321
+ // Add Supabase proxy authentication headers
322
+ if (this.config.supabaseAnonKey) {
323
+ headers['apikey'] = this.config.supabaseAnonKey;
324
+ }
325
+ }
326
+ else {
327
+ // Direct mode - use basic auth
328
+ if (this.config.username && this.config.password) {
329
+ const credentials = btoa(`${this.config.username}:${this.config.password}`);
330
+ headers.Authorization = `Basic ${credentials}`;
331
+ }
332
+ }
333
+ const response = await fetch(url, {
334
+ ...options,
335
+ headers,
336
+ signal: AbortSignal.timeout(this.config.timeout || 30000),
337
+ });
338
+ if (!response.ok) {
339
+ throw new Error(`Gravity Forms API request failed: ${response.status} ${response.statusText}`);
340
+ }
341
+ const responseText = await response.text();
342
+ if (!responseText) {
343
+ return [];
344
+ }
345
+ try {
346
+ return JSON.parse(responseText);
347
+ }
348
+ catch (error) {
349
+ console.error('❌ Gravity Forms JSON Parse Error:', {
350
+ error: error.message,
351
+ responseText: responseText.substring(0, 500),
352
+ });
353
+ throw new Error(`Failed to parse JSON response: ${error.message}`);
354
+ }
355
+ }
356
+ getBaseUrl() {
357
+ switch (this.config.authMode) {
358
+ case 'cloudflare_proxy':
359
+ return this.config.cloudflareWorkerUrl || '';
360
+ case 'supabase_proxy':
361
+ return `${this.config.supabaseUrl}/functions/v1/wp-proxy`;
362
+ default:
363
+ return this.config.apiUrl || '';
364
+ }
365
+ }
366
+ async getForm(id) {
367
+ return this.makeRequest(`/gf-api/v1/forms/${id}`);
368
+ }
369
+ async getForms() {
370
+ return this.makeRequest('/gf-api/v1/forms');
371
+ }
372
+ async getFormConfig(id) {
373
+ return this.makeRequest(`/gf-api/v1/forms/${id}/config`);
374
+ }
375
+ async submitForm(formId, submission) {
376
+ return this.makeRequest(`/gf-api/v1/forms/${formId}/submit`, {
377
+ method: 'POST',
378
+ body: JSON.stringify(submission),
379
+ });
380
+ }
381
+ async getHealth() {
382
+ return this.makeRequest('/gf-api/v1/health');
383
+ }
384
+ }
385
+
386
+ /**
387
+ * @license GPL-3.0-or-later
388
+ *
389
+ * This file is part of the MarVAlt Open SDK.
390
+ * Copyright (c) 2025 Vibune Pty Ltd.
391
+ *
392
+ * This program is free software: you can redistribute it and/or modify
393
+ * it under the terms of the GNU General Public License as published by
394
+ * the Free Software Foundation, either version 3 of the License, or
395
+ * (at your option) any later version.
396
+ *
397
+ * This program is distributed in the hope that it will be useful,
398
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
399
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
400
+ * See the GNU General Public License for more details.
401
+ */
402
+ // React Hook for WordPress Data
403
+ function useWordPress(endpoint, id, config) {
404
+ const [data, setData] = useState(null);
405
+ const [loading, setLoading] = useState(true);
406
+ const [error, setError] = useState(null);
407
+ const fetchData = async () => {
408
+ if (!config) {
409
+ setError(new Error('WordPress configuration is required'));
410
+ setLoading(false);
411
+ return;
412
+ }
413
+ try {
414
+ setLoading(true);
415
+ setError(null);
416
+ const client = new WordPressClient(config);
417
+ let result;
418
+ switch (endpoint) {
419
+ case 'posts':
420
+ result = id
421
+ ? await client.getPost(id)
422
+ : await client.getPosts();
423
+ break;
424
+ case 'pages':
425
+ result = id
426
+ ? await client.getPage(id)
427
+ : await client.getPages();
428
+ break;
429
+ case 'media':
430
+ result = id
431
+ ? await client.getMediaItem(id)
432
+ : await client.getMedia();
433
+ break;
434
+ case 'categories':
435
+ result = await client.getCategories();
436
+ break;
437
+ case 'tags':
438
+ result = await client.getTags();
439
+ break;
440
+ default:
441
+ throw new Error(`Unknown endpoint: ${endpoint}`);
442
+ }
443
+ setData(result);
444
+ }
445
+ catch (err) {
446
+ setError(err instanceof Error ? err : new Error('Unknown error'));
447
+ }
448
+ finally {
449
+ setLoading(false);
450
+ }
451
+ };
452
+ useEffect(() => {
453
+ fetchData();
454
+ }, [endpoint, id, config?.apiUrl]);
455
+ return {
456
+ data,
457
+ loading,
458
+ error,
459
+ refetch: fetchData,
460
+ };
461
+ }
462
+ // Specific hooks for common use cases
463
+ function useWordPressPosts(config) {
464
+ return useWordPress('posts', undefined, config);
465
+ }
466
+ function useWordPressPost(id, config) {
467
+ return useWordPress('posts', id, config);
468
+ }
469
+ function useWordPressPages(config) {
470
+ return useWordPress('pages', undefined, config);
471
+ }
472
+ function useWordPressPage(id, config) {
473
+ return useWordPress('pages', id, config);
474
+ }
475
+ function useWordPressMedia(config) {
476
+ return useWordPress('media', undefined, config);
477
+ }
478
+ function useWordPressCategories(config) {
479
+ return useWordPress('categories', undefined, config);
480
+ }
481
+ function useWordPressTags(config) {
482
+ return useWordPress('tags', undefined, config);
483
+ }
484
+
485
+ /**
486
+ * @license GPL-3.0-or-later
487
+ *
488
+ * This file is part of the MarVAlt Open SDK.
489
+ * Copyright (c) 2025 Vibune Pty Ltd.
490
+ *
491
+ * This program is free software: you can redistribute it and/or modify
492
+ * it under the terms of the GNU General Public License as published by
493
+ * the Free Software Foundation, either version 3 of the License, or
494
+ * (at your option) any later version.
495
+ *
496
+ * This program is distributed in the hope that it will be useful,
497
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
498
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
499
+ * See the GNU General Public License for more details.
500
+ */
501
+ // React Hook for Gravity Forms
502
+ function useGravityForms(formId, config) {
503
+ const [form, setForm] = useState(null);
504
+ const [loading, setLoading] = useState(true);
505
+ const [error, setError] = useState(null);
506
+ const [submitting, setSubmitting] = useState(false);
507
+ const [result, setResult] = useState(null);
508
+ const fetchForm = useCallback(async () => {
509
+ if (!config) {
510
+ setError(new Error('Gravity Forms configuration is required'));
511
+ setLoading(false);
512
+ return;
513
+ }
514
+ try {
515
+ setLoading(true);
516
+ setError(null);
517
+ const client = new GravityFormsClient(config);
518
+ const formData = await client.getForm(formId);
519
+ setForm(formData);
520
+ }
521
+ catch (err) {
522
+ setError(err instanceof Error ? err : new Error('Unknown error'));
523
+ }
524
+ finally {
525
+ setLoading(false);
526
+ }
527
+ }, [formId, config?.apiUrl]);
528
+ const submitForm = useCallback(async (submission) => {
529
+ if (!config) {
530
+ setError(new Error('Gravity Forms configuration is required'));
531
+ return;
532
+ }
533
+ try {
534
+ setSubmitting(true);
535
+ setError(null);
536
+ setResult(null);
537
+ const client = new GravityFormsClient(config);
538
+ const submissionResult = await client.submitForm(formId, submission);
539
+ setResult(submissionResult);
540
+ }
541
+ catch (err) {
542
+ setError(err instanceof Error ? err : new Error('Unknown error'));
543
+ }
544
+ finally {
545
+ setSubmitting(false);
546
+ }
547
+ }, [formId, config?.apiUrl]);
548
+ return {
549
+ form,
550
+ loading,
551
+ error,
552
+ submitting,
553
+ result,
554
+ submitForm,
555
+ refetch: fetchForm,
556
+ };
557
+ }
558
+ function useGravityFormsConfig(formId, config) {
559
+ const [formConfig, setFormConfig] = useState(null);
560
+ const [loading, setLoading] = useState(true);
561
+ const [error, setError] = useState(null);
562
+ const fetchConfig = useCallback(async () => {
563
+ if (!config) {
564
+ setError(new Error('Gravity Forms configuration is required'));
565
+ setLoading(false);
566
+ return;
567
+ }
568
+ try {
569
+ setLoading(true);
570
+ setError(null);
571
+ const client = new GravityFormsClient(config);
572
+ const configData = await client.getFormConfig(formId);
573
+ setFormConfig(configData);
574
+ }
575
+ catch (err) {
576
+ setError(err instanceof Error ? err : new Error('Unknown error'));
577
+ }
578
+ finally {
579
+ setLoading(false);
580
+ }
581
+ }, [formId, config?.apiUrl]);
582
+ return {
583
+ formConfig,
584
+ loading,
585
+ error,
586
+ refetch: fetchConfig,
587
+ };
588
+ }
589
+
590
+ var jsxRuntime = {exports: {}};
591
+
592
+ var reactJsxRuntime_production_min = {};
593
+
594
+ /**
595
+ * @license React
596
+ * react-jsx-runtime.production.min.js
597
+ *
598
+ * Copyright (c) Facebook, Inc. and its affiliates.
599
+ *
600
+ * This source code is licensed under the MIT license found in the
601
+ * LICENSE file in the root directory of this source tree.
602
+ */
603
+
604
+ var hasRequiredReactJsxRuntime_production_min;
605
+
606
+ function requireReactJsxRuntime_production_min () {
607
+ if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
608
+ hasRequiredReactJsxRuntime_production_min = 1;
609
+ var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:true,ref:true,__self:true,__source:true};
610
+ function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a) void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
611
+ return reactJsxRuntime_production_min;
612
+ }
613
+
614
+ var reactJsxRuntime_development = {};
615
+
616
+ /**
617
+ * @license React
618
+ * react-jsx-runtime.development.js
619
+ *
620
+ * Copyright (c) Facebook, Inc. and its affiliates.
621
+ *
622
+ * This source code is licensed under the MIT license found in the
623
+ * LICENSE file in the root directory of this source tree.
624
+ */
625
+
626
+ var hasRequiredReactJsxRuntime_development;
627
+
628
+ function requireReactJsxRuntime_development () {
629
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
630
+ hasRequiredReactJsxRuntime_development = 1;
631
+
632
+ if (process.env.NODE_ENV !== "production") {
633
+ (function() {
634
+
635
+ var React = require$$0;
636
+
637
+ // ATTENTION
638
+ // When adding new symbols to this file,
639
+ // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
640
+ // The Symbol used to tag the ReactElement-like types.
641
+ var REACT_ELEMENT_TYPE = Symbol.for('react.element');
642
+ var REACT_PORTAL_TYPE = Symbol.for('react.portal');
643
+ var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
644
+ var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
645
+ var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
646
+ var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
647
+ var REACT_CONTEXT_TYPE = Symbol.for('react.context');
648
+ var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
649
+ var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
650
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
651
+ var REACT_MEMO_TYPE = Symbol.for('react.memo');
652
+ var REACT_LAZY_TYPE = Symbol.for('react.lazy');
653
+ var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
654
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
655
+ var FAUX_ITERATOR_SYMBOL = '@@iterator';
656
+ function getIteratorFn(maybeIterable) {
657
+ if (maybeIterable === null || typeof maybeIterable !== 'object') {
658
+ return null;
659
+ }
660
+
661
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
662
+
663
+ if (typeof maybeIterator === 'function') {
664
+ return maybeIterator;
665
+ }
666
+
667
+ return null;
668
+ }
669
+
670
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
671
+
672
+ function error(format) {
673
+ {
674
+ {
675
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
676
+ args[_key2 - 1] = arguments[_key2];
677
+ }
678
+
679
+ printWarning('error', format, args);
680
+ }
681
+ }
682
+ }
683
+
684
+ function printWarning(level, format, args) {
685
+ // When changing this logic, you might want to also
686
+ // update consoleWithStackDev.www.js as well.
687
+ {
688
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
689
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
690
+
691
+ if (stack !== '') {
692
+ format += '%s';
693
+ args = args.concat([stack]);
694
+ } // eslint-disable-next-line react-internal/safe-string-coercion
695
+
696
+
697
+ var argsWithFormat = args.map(function (item) {
698
+ return String(item);
699
+ }); // Careful: RN currently depends on this prefix
700
+
701
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
702
+ // breaks IE9: https://github.com/facebook/react/issues/13610
703
+ // eslint-disable-next-line react-internal/no-production-logging
704
+
705
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
706
+ }
707
+ }
708
+
709
+ // -----------------------------------------------------------------------------
710
+
711
+ var enableScopeAPI = false; // Experimental Create Event Handle API.
712
+ var enableCacheElement = false;
713
+ var enableTransitionTracing = false; // No known bugs, but needs performance testing
714
+
715
+ var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
716
+ // stuff. Intended to enable React core members to more easily debug scheduling
717
+ // issues in DEV builds.
718
+
719
+ var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
720
+
721
+ var REACT_MODULE_REFERENCE;
722
+
723
+ {
724
+ REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
725
+ }
726
+
727
+ function isValidElementType(type) {
728
+ if (typeof type === 'string' || typeof type === 'function') {
729
+ return true;
730
+ } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
731
+
732
+
733
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
734
+ return true;
735
+ }
736
+
737
+ if (typeof type === 'object' && type !== null) {
738
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
739
+ // types supported by any Flight configuration anywhere since
740
+ // we don't know which Flight build this will end up being used
741
+ // with.
742
+ type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
743
+ return true;
744
+ }
745
+ }
746
+
747
+ return false;
748
+ }
749
+
750
+ function getWrappedName(outerType, innerType, wrapperName) {
751
+ var displayName = outerType.displayName;
752
+
753
+ if (displayName) {
754
+ return displayName;
755
+ }
756
+
757
+ var functionName = innerType.displayName || innerType.name || '';
758
+ return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
759
+ } // Keep in sync with react-reconciler/getComponentNameFromFiber
760
+
761
+
762
+ function getContextName(type) {
763
+ return type.displayName || 'Context';
764
+ } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
765
+
766
+
767
+ function getComponentNameFromType(type) {
768
+ if (type == null) {
769
+ // Host root, text node or just invalid type.
770
+ return null;
771
+ }
772
+
773
+ {
774
+ if (typeof type.tag === 'number') {
775
+ error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
776
+ }
777
+ }
778
+
779
+ if (typeof type === 'function') {
780
+ return type.displayName || type.name || null;
781
+ }
782
+
783
+ if (typeof type === 'string') {
784
+ return type;
785
+ }
786
+
787
+ switch (type) {
788
+ case REACT_FRAGMENT_TYPE:
789
+ return 'Fragment';
790
+
791
+ case REACT_PORTAL_TYPE:
792
+ return 'Portal';
793
+
794
+ case REACT_PROFILER_TYPE:
795
+ return 'Profiler';
796
+
797
+ case REACT_STRICT_MODE_TYPE:
798
+ return 'StrictMode';
799
+
800
+ case REACT_SUSPENSE_TYPE:
801
+ return 'Suspense';
802
+
803
+ case REACT_SUSPENSE_LIST_TYPE:
804
+ return 'SuspenseList';
805
+
806
+ }
807
+
808
+ if (typeof type === 'object') {
809
+ switch (type.$$typeof) {
810
+ case REACT_CONTEXT_TYPE:
811
+ var context = type;
812
+ return getContextName(context) + '.Consumer';
813
+
814
+ case REACT_PROVIDER_TYPE:
815
+ var provider = type;
816
+ return getContextName(provider._context) + '.Provider';
817
+
818
+ case REACT_FORWARD_REF_TYPE:
819
+ return getWrappedName(type, type.render, 'ForwardRef');
820
+
821
+ case REACT_MEMO_TYPE:
822
+ var outerName = type.displayName || null;
823
+
824
+ if (outerName !== null) {
825
+ return outerName;
826
+ }
827
+
828
+ return getComponentNameFromType(type.type) || 'Memo';
829
+
830
+ case REACT_LAZY_TYPE:
831
+ {
832
+ var lazyComponent = type;
833
+ var payload = lazyComponent._payload;
834
+ var init = lazyComponent._init;
835
+
836
+ try {
837
+ return getComponentNameFromType(init(payload));
838
+ } catch (x) {
839
+ return null;
840
+ }
841
+ }
842
+
843
+ // eslint-disable-next-line no-fallthrough
844
+ }
845
+ }
846
+
847
+ return null;
848
+ }
849
+
850
+ var assign = Object.assign;
851
+
852
+ // Helpers to patch console.logs to avoid logging during side-effect free
853
+ // replaying on render function. This currently only patches the object
854
+ // lazily which won't cover if the log function was extracted eagerly.
855
+ // We could also eagerly patch the method.
856
+ var disabledDepth = 0;
857
+ var prevLog;
858
+ var prevInfo;
859
+ var prevWarn;
860
+ var prevError;
861
+ var prevGroup;
862
+ var prevGroupCollapsed;
863
+ var prevGroupEnd;
864
+
865
+ function disabledLog() {}
866
+
867
+ disabledLog.__reactDisabledLog = true;
868
+ function disableLogs() {
869
+ {
870
+ if (disabledDepth === 0) {
871
+ /* eslint-disable react-internal/no-production-logging */
872
+ prevLog = console.log;
873
+ prevInfo = console.info;
874
+ prevWarn = console.warn;
875
+ prevError = console.error;
876
+ prevGroup = console.group;
877
+ prevGroupCollapsed = console.groupCollapsed;
878
+ prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
879
+
880
+ var props = {
881
+ configurable: true,
882
+ enumerable: true,
883
+ value: disabledLog,
884
+ writable: true
885
+ }; // $FlowFixMe Flow thinks console is immutable.
886
+
887
+ Object.defineProperties(console, {
888
+ info: props,
889
+ log: props,
890
+ warn: props,
891
+ error: props,
892
+ group: props,
893
+ groupCollapsed: props,
894
+ groupEnd: props
895
+ });
896
+ /* eslint-enable react-internal/no-production-logging */
897
+ }
898
+
899
+ disabledDepth++;
900
+ }
901
+ }
902
+ function reenableLogs() {
903
+ {
904
+ disabledDepth--;
905
+
906
+ if (disabledDepth === 0) {
907
+ /* eslint-disable react-internal/no-production-logging */
908
+ var props = {
909
+ configurable: true,
910
+ enumerable: true,
911
+ writable: true
912
+ }; // $FlowFixMe Flow thinks console is immutable.
913
+
914
+ Object.defineProperties(console, {
915
+ log: assign({}, props, {
916
+ value: prevLog
917
+ }),
918
+ info: assign({}, props, {
919
+ value: prevInfo
920
+ }),
921
+ warn: assign({}, props, {
922
+ value: prevWarn
923
+ }),
924
+ error: assign({}, props, {
925
+ value: prevError
926
+ }),
927
+ group: assign({}, props, {
928
+ value: prevGroup
929
+ }),
930
+ groupCollapsed: assign({}, props, {
931
+ value: prevGroupCollapsed
932
+ }),
933
+ groupEnd: assign({}, props, {
934
+ value: prevGroupEnd
935
+ })
936
+ });
937
+ /* eslint-enable react-internal/no-production-logging */
938
+ }
939
+
940
+ if (disabledDepth < 0) {
941
+ error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
942
+ }
943
+ }
944
+ }
945
+
946
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
947
+ var prefix;
948
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
949
+ {
950
+ if (prefix === undefined) {
951
+ // Extract the VM specific prefix used by each line.
952
+ try {
953
+ throw Error();
954
+ } catch (x) {
955
+ var match = x.stack.trim().match(/\n( *(at )?)/);
956
+ prefix = match && match[1] || '';
957
+ }
958
+ } // We use the prefix to ensure our stacks line up with native stack frames.
959
+
960
+
961
+ return '\n' + prefix + name;
962
+ }
963
+ }
964
+ var reentry = false;
965
+ var componentFrameCache;
966
+
967
+ {
968
+ var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
969
+ componentFrameCache = new PossiblyWeakMap();
970
+ }
971
+
972
+ function describeNativeComponentFrame(fn, construct) {
973
+ // If something asked for a stack inside a fake render, it should get ignored.
974
+ if ( !fn || reentry) {
975
+ return '';
976
+ }
977
+
978
+ {
979
+ var frame = componentFrameCache.get(fn);
980
+
981
+ if (frame !== undefined) {
982
+ return frame;
983
+ }
984
+ }
985
+
986
+ var control;
987
+ reentry = true;
988
+ var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
989
+
990
+ Error.prepareStackTrace = undefined;
991
+ var previousDispatcher;
992
+
993
+ {
994
+ previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
995
+ // for warnings.
996
+
997
+ ReactCurrentDispatcher.current = null;
998
+ disableLogs();
999
+ }
1000
+
1001
+ try {
1002
+ // This should throw.
1003
+ if (construct) {
1004
+ // Something should be setting the props in the constructor.
1005
+ var Fake = function () {
1006
+ throw Error();
1007
+ }; // $FlowFixMe
1008
+
1009
+
1010
+ Object.defineProperty(Fake.prototype, 'props', {
1011
+ set: function () {
1012
+ // We use a throwing setter instead of frozen or non-writable props
1013
+ // because that won't throw in a non-strict mode function.
1014
+ throw Error();
1015
+ }
1016
+ });
1017
+
1018
+ if (typeof Reflect === 'object' && Reflect.construct) {
1019
+ // We construct a different control for this case to include any extra
1020
+ // frames added by the construct call.
1021
+ try {
1022
+ Reflect.construct(Fake, []);
1023
+ } catch (x) {
1024
+ control = x;
1025
+ }
1026
+
1027
+ Reflect.construct(fn, [], Fake);
1028
+ } else {
1029
+ try {
1030
+ Fake.call();
1031
+ } catch (x) {
1032
+ control = x;
1033
+ }
1034
+
1035
+ fn.call(Fake.prototype);
1036
+ }
1037
+ } else {
1038
+ try {
1039
+ throw Error();
1040
+ } catch (x) {
1041
+ control = x;
1042
+ }
1043
+
1044
+ fn();
1045
+ }
1046
+ } catch (sample) {
1047
+ // This is inlined manually because closure doesn't do it for us.
1048
+ if (sample && control && typeof sample.stack === 'string') {
1049
+ // This extracts the first frame from the sample that isn't also in the control.
1050
+ // Skipping one frame that we assume is the frame that calls the two.
1051
+ var sampleLines = sample.stack.split('\n');
1052
+ var controlLines = control.stack.split('\n');
1053
+ var s = sampleLines.length - 1;
1054
+ var c = controlLines.length - 1;
1055
+
1056
+ while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
1057
+ // We expect at least one stack frame to be shared.
1058
+ // Typically this will be the root most one. However, stack frames may be
1059
+ // cut off due to maximum stack limits. In this case, one maybe cut off
1060
+ // earlier than the other. We assume that the sample is longer or the same
1061
+ // and there for cut off earlier. So we should find the root most frame in
1062
+ // the sample somewhere in the control.
1063
+ c--;
1064
+ }
1065
+
1066
+ for (; s >= 1 && c >= 0; s--, c--) {
1067
+ // Next we find the first one that isn't the same which should be the
1068
+ // frame that called our sample function and the control.
1069
+ if (sampleLines[s] !== controlLines[c]) {
1070
+ // In V8, the first line is describing the message but other VMs don't.
1071
+ // If we're about to return the first line, and the control is also on the same
1072
+ // line, that's a pretty good indicator that our sample threw at same line as
1073
+ // the control. I.e. before we entered the sample frame. So we ignore this result.
1074
+ // This can happen if you passed a class to function component, or non-function.
1075
+ if (s !== 1 || c !== 1) {
1076
+ do {
1077
+ s--;
1078
+ c--; // We may still have similar intermediate frames from the construct call.
1079
+ // The next one that isn't the same should be our match though.
1080
+
1081
+ if (c < 0 || sampleLines[s] !== controlLines[c]) {
1082
+ // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
1083
+ var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
1084
+ // but we have a user-provided "displayName"
1085
+ // splice it in to make the stack more readable.
1086
+
1087
+
1088
+ if (fn.displayName && _frame.includes('<anonymous>')) {
1089
+ _frame = _frame.replace('<anonymous>', fn.displayName);
1090
+ }
1091
+
1092
+ {
1093
+ if (typeof fn === 'function') {
1094
+ componentFrameCache.set(fn, _frame);
1095
+ }
1096
+ } // Return the line we found.
1097
+
1098
+
1099
+ return _frame;
1100
+ }
1101
+ } while (s >= 1 && c >= 0);
1102
+ }
1103
+
1104
+ break;
1105
+ }
1106
+ }
1107
+ }
1108
+ } finally {
1109
+ reentry = false;
1110
+
1111
+ {
1112
+ ReactCurrentDispatcher.current = previousDispatcher;
1113
+ reenableLogs();
1114
+ }
1115
+
1116
+ Error.prepareStackTrace = previousPrepareStackTrace;
1117
+ } // Fallback to just using the name if we couldn't make it throw.
1118
+
1119
+
1120
+ var name = fn ? fn.displayName || fn.name : '';
1121
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
1122
+
1123
+ {
1124
+ if (typeof fn === 'function') {
1125
+ componentFrameCache.set(fn, syntheticFrame);
1126
+ }
1127
+ }
1128
+
1129
+ return syntheticFrame;
1130
+ }
1131
+ function describeFunctionComponentFrame(fn, source, ownerFn) {
1132
+ {
1133
+ return describeNativeComponentFrame(fn, false);
1134
+ }
1135
+ }
1136
+
1137
+ function shouldConstruct(Component) {
1138
+ var prototype = Component.prototype;
1139
+ return !!(prototype && prototype.isReactComponent);
1140
+ }
1141
+
1142
+ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
1143
+
1144
+ if (type == null) {
1145
+ return '';
1146
+ }
1147
+
1148
+ if (typeof type === 'function') {
1149
+ {
1150
+ return describeNativeComponentFrame(type, shouldConstruct(type));
1151
+ }
1152
+ }
1153
+
1154
+ if (typeof type === 'string') {
1155
+ return describeBuiltInComponentFrame(type);
1156
+ }
1157
+
1158
+ switch (type) {
1159
+ case REACT_SUSPENSE_TYPE:
1160
+ return describeBuiltInComponentFrame('Suspense');
1161
+
1162
+ case REACT_SUSPENSE_LIST_TYPE:
1163
+ return describeBuiltInComponentFrame('SuspenseList');
1164
+ }
1165
+
1166
+ if (typeof type === 'object') {
1167
+ switch (type.$$typeof) {
1168
+ case REACT_FORWARD_REF_TYPE:
1169
+ return describeFunctionComponentFrame(type.render);
1170
+
1171
+ case REACT_MEMO_TYPE:
1172
+ // Memo may contain any component type so we recursively resolve it.
1173
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
1174
+
1175
+ case REACT_LAZY_TYPE:
1176
+ {
1177
+ var lazyComponent = type;
1178
+ var payload = lazyComponent._payload;
1179
+ var init = lazyComponent._init;
1180
+
1181
+ try {
1182
+ // Lazy may contain any component type so we recursively resolve it.
1183
+ return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
1184
+ } catch (x) {}
1185
+ }
1186
+ }
1187
+ }
1188
+
1189
+ return '';
1190
+ }
1191
+
1192
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
1193
+
1194
+ var loggedTypeFailures = {};
1195
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1196
+
1197
+ function setCurrentlyValidatingElement(element) {
1198
+ {
1199
+ if (element) {
1200
+ var owner = element._owner;
1201
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1202
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
1203
+ } else {
1204
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
1205
+ }
1206
+ }
1207
+ }
1208
+
1209
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
1210
+ {
1211
+ // $FlowFixMe This is okay but Flow doesn't know it.
1212
+ var has = Function.call.bind(hasOwnProperty);
1213
+
1214
+ for (var typeSpecName in typeSpecs) {
1215
+ if (has(typeSpecs, typeSpecName)) {
1216
+ var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
1217
+ // fail the render phase where it didn't fail before. So we log it.
1218
+ // After these have been cleaned up, we'll let them throw.
1219
+
1220
+ try {
1221
+ // This is intentionally an invariant that gets caught. It's the same
1222
+ // behavior as without this statement except with a better message.
1223
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
1224
+ // eslint-disable-next-line react-internal/prod-error-codes
1225
+ var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
1226
+ err.name = 'Invariant Violation';
1227
+ throw err;
1228
+ }
1229
+
1230
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
1231
+ } catch (ex) {
1232
+ error$1 = ex;
1233
+ }
1234
+
1235
+ if (error$1 && !(error$1 instanceof Error)) {
1236
+ setCurrentlyValidatingElement(element);
1237
+
1238
+ error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
1239
+
1240
+ setCurrentlyValidatingElement(null);
1241
+ }
1242
+
1243
+ if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
1244
+ // Only monitor this failure once because there tends to be a lot of the
1245
+ // same error.
1246
+ loggedTypeFailures[error$1.message] = true;
1247
+ setCurrentlyValidatingElement(element);
1248
+
1249
+ error('Failed %s type: %s', location, error$1.message);
1250
+
1251
+ setCurrentlyValidatingElement(null);
1252
+ }
1253
+ }
1254
+ }
1255
+ }
1256
+ }
1257
+
1258
+ var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
1259
+
1260
+ function isArray(a) {
1261
+ return isArrayImpl(a);
1262
+ }
1263
+
1264
+ /*
1265
+ * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
1266
+ * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
1267
+ *
1268
+ * The functions in this module will throw an easier-to-understand,
1269
+ * easier-to-debug exception with a clear errors message message explaining the
1270
+ * problem. (Instead of a confusing exception thrown inside the implementation
1271
+ * of the `value` object).
1272
+ */
1273
+ // $FlowFixMe only called in DEV, so void return is not possible.
1274
+ function typeName(value) {
1275
+ {
1276
+ // toStringTag is needed for namespaced types like Temporal.Instant
1277
+ var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
1278
+ var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
1279
+ return type;
1280
+ }
1281
+ } // $FlowFixMe only called in DEV, so void return is not possible.
1282
+
1283
+
1284
+ function willCoercionThrow(value) {
1285
+ {
1286
+ try {
1287
+ testStringCoercion(value);
1288
+ return false;
1289
+ } catch (e) {
1290
+ return true;
1291
+ }
1292
+ }
1293
+ }
1294
+
1295
+ function testStringCoercion(value) {
1296
+ // If you ended up here by following an exception call stack, here's what's
1297
+ // happened: you supplied an object or symbol value to React (as a prop, key,
1298
+ // DOM attribute, CSS property, string ref, etc.) and when React tried to
1299
+ // coerce it to a string using `'' + value`, an exception was thrown.
1300
+ //
1301
+ // The most common types that will cause this exception are `Symbol` instances
1302
+ // and Temporal objects like `Temporal.Instant`. But any object that has a
1303
+ // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
1304
+ // exception. (Library authors do this to prevent users from using built-in
1305
+ // numeric operators like `+` or comparison operators like `>=` because custom
1306
+ // methods are needed to perform accurate arithmetic or comparison.)
1307
+ //
1308
+ // To fix the problem, coerce this object or symbol value to a string before
1309
+ // passing it to React. The most reliable way is usually `String(value)`.
1310
+ //
1311
+ // To find which value is throwing, check the browser or debugger console.
1312
+ // Before this exception was thrown, there should be `console.error` output
1313
+ // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
1314
+ // problem and how that type was used: key, atrribute, input value prop, etc.
1315
+ // In most cases, this console output also shows the component and its
1316
+ // ancestor components where the exception happened.
1317
+ //
1318
+ // eslint-disable-next-line react-internal/safe-string-coercion
1319
+ return '' + value;
1320
+ }
1321
+ function checkKeyStringCoercion(value) {
1322
+ {
1323
+ if (willCoercionThrow(value)) {
1324
+ error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
1325
+
1326
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
1327
+ }
1328
+ }
1329
+ }
1330
+
1331
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
1332
+ var RESERVED_PROPS = {
1333
+ key: true,
1334
+ ref: true,
1335
+ __self: true,
1336
+ __source: true
1337
+ };
1338
+ var specialPropKeyWarningShown;
1339
+ var specialPropRefWarningShown;
1340
+
1341
+ function hasValidRef(config) {
1342
+ {
1343
+ if (hasOwnProperty.call(config, 'ref')) {
1344
+ var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
1345
+
1346
+ if (getter && getter.isReactWarning) {
1347
+ return false;
1348
+ }
1349
+ }
1350
+ }
1351
+
1352
+ return config.ref !== undefined;
1353
+ }
1354
+
1355
+ function hasValidKey(config) {
1356
+ {
1357
+ if (hasOwnProperty.call(config, 'key')) {
1358
+ var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
1359
+
1360
+ if (getter && getter.isReactWarning) {
1361
+ return false;
1362
+ }
1363
+ }
1364
+ }
1365
+
1366
+ return config.key !== undefined;
1367
+ }
1368
+
1369
+ function warnIfStringRefCannotBeAutoConverted(config, self) {
1370
+ {
1371
+ if (typeof config.ref === 'string' && ReactCurrentOwner.current && self) ;
1372
+ }
1373
+ }
1374
+
1375
+ function defineKeyPropWarningGetter(props, displayName) {
1376
+ {
1377
+ var warnAboutAccessingKey = function () {
1378
+ if (!specialPropKeyWarningShown) {
1379
+ specialPropKeyWarningShown = true;
1380
+
1381
+ error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
1382
+ }
1383
+ };
1384
+
1385
+ warnAboutAccessingKey.isReactWarning = true;
1386
+ Object.defineProperty(props, 'key', {
1387
+ get: warnAboutAccessingKey,
1388
+ configurable: true
1389
+ });
1390
+ }
1391
+ }
1392
+
1393
+ function defineRefPropWarningGetter(props, displayName) {
1394
+ {
1395
+ var warnAboutAccessingRef = function () {
1396
+ if (!specialPropRefWarningShown) {
1397
+ specialPropRefWarningShown = true;
1398
+
1399
+ error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
1400
+ }
1401
+ };
1402
+
1403
+ warnAboutAccessingRef.isReactWarning = true;
1404
+ Object.defineProperty(props, 'ref', {
1405
+ get: warnAboutAccessingRef,
1406
+ configurable: true
1407
+ });
1408
+ }
1409
+ }
1410
+ /**
1411
+ * Factory method to create a new React element. This no longer adheres to
1412
+ * the class pattern, so do not use new to call it. Also, instanceof check
1413
+ * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
1414
+ * if something is a React Element.
1415
+ *
1416
+ * @param {*} type
1417
+ * @param {*} props
1418
+ * @param {*} key
1419
+ * @param {string|object} ref
1420
+ * @param {*} owner
1421
+ * @param {*} self A *temporary* helper to detect places where `this` is
1422
+ * different from the `owner` when React.createElement is called, so that we
1423
+ * can warn. We want to get rid of owner and replace string `ref`s with arrow
1424
+ * functions, and as long as `this` and owner are the same, there will be no
1425
+ * change in behavior.
1426
+ * @param {*} source An annotation object (added by a transpiler or otherwise)
1427
+ * indicating filename, line number, and/or other information.
1428
+ * @internal
1429
+ */
1430
+
1431
+
1432
+ var ReactElement = function (type, key, ref, self, source, owner, props) {
1433
+ var element = {
1434
+ // This tag allows us to uniquely identify this as a React Element
1435
+ $$typeof: REACT_ELEMENT_TYPE,
1436
+ // Built-in properties that belong on the element
1437
+ type: type,
1438
+ key: key,
1439
+ ref: ref,
1440
+ props: props,
1441
+ // Record the component responsible for creating this element.
1442
+ _owner: owner
1443
+ };
1444
+
1445
+ {
1446
+ // The validation flag is currently mutative. We put it on
1447
+ // an external backing store so that we can freeze the whole object.
1448
+ // This can be replaced with a WeakMap once they are implemented in
1449
+ // commonly used development environments.
1450
+ element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
1451
+ // the validation flag non-enumerable (where possible, which should
1452
+ // include every environment we run tests in), so the test framework
1453
+ // ignores it.
1454
+
1455
+ Object.defineProperty(element._store, 'validated', {
1456
+ configurable: false,
1457
+ enumerable: false,
1458
+ writable: true,
1459
+ value: false
1460
+ }); // self and source are DEV only properties.
1461
+
1462
+ Object.defineProperty(element, '_self', {
1463
+ configurable: false,
1464
+ enumerable: false,
1465
+ writable: false,
1466
+ value: self
1467
+ }); // Two elements created in two different places should be considered
1468
+ // equal for testing purposes and therefore we hide it from enumeration.
1469
+
1470
+ Object.defineProperty(element, '_source', {
1471
+ configurable: false,
1472
+ enumerable: false,
1473
+ writable: false,
1474
+ value: source
1475
+ });
1476
+
1477
+ if (Object.freeze) {
1478
+ Object.freeze(element.props);
1479
+ Object.freeze(element);
1480
+ }
1481
+ }
1482
+
1483
+ return element;
1484
+ };
1485
+ /**
1486
+ * https://github.com/reactjs/rfcs/pull/107
1487
+ * @param {*} type
1488
+ * @param {object} props
1489
+ * @param {string} key
1490
+ */
1491
+
1492
+ function jsxDEV(type, config, maybeKey, source, self) {
1493
+ {
1494
+ var propName; // Reserved names are extracted
1495
+
1496
+ var props = {};
1497
+ var key = null;
1498
+ var ref = null; // Currently, key can be spread in as a prop. This causes a potential
1499
+ // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
1500
+ // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
1501
+ // but as an intermediary step, we will use jsxDEV for everything except
1502
+ // <div {...props} key="Hi" />, because we aren't currently able to tell if
1503
+ // key is explicitly declared to be undefined or not.
1504
+
1505
+ if (maybeKey !== undefined) {
1506
+ {
1507
+ checkKeyStringCoercion(maybeKey);
1508
+ }
1509
+
1510
+ key = '' + maybeKey;
1511
+ }
1512
+
1513
+ if (hasValidKey(config)) {
1514
+ {
1515
+ checkKeyStringCoercion(config.key);
1516
+ }
1517
+
1518
+ key = '' + config.key;
1519
+ }
1520
+
1521
+ if (hasValidRef(config)) {
1522
+ ref = config.ref;
1523
+ warnIfStringRefCannotBeAutoConverted(config, self);
1524
+ } // Remaining properties are added to a new props object
1525
+
1526
+
1527
+ for (propName in config) {
1528
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1529
+ props[propName] = config[propName];
1530
+ }
1531
+ } // Resolve default props
1532
+
1533
+
1534
+ if (type && type.defaultProps) {
1535
+ var defaultProps = type.defaultProps;
1536
+
1537
+ for (propName in defaultProps) {
1538
+ if (props[propName] === undefined) {
1539
+ props[propName] = defaultProps[propName];
1540
+ }
1541
+ }
1542
+ }
1543
+
1544
+ if (key || ref) {
1545
+ var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
1546
+
1547
+ if (key) {
1548
+ defineKeyPropWarningGetter(props, displayName);
1549
+ }
1550
+
1551
+ if (ref) {
1552
+ defineRefPropWarningGetter(props, displayName);
1553
+ }
1554
+ }
1555
+
1556
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
1557
+ }
1558
+ }
1559
+
1560
+ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
1561
+ var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
1562
+
1563
+ function setCurrentlyValidatingElement$1(element) {
1564
+ {
1565
+ if (element) {
1566
+ var owner = element._owner;
1567
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1568
+ ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
1569
+ } else {
1570
+ ReactDebugCurrentFrame$1.setExtraStackFrame(null);
1571
+ }
1572
+ }
1573
+ }
1574
+
1575
+ var propTypesMisspellWarningShown;
1576
+
1577
+ {
1578
+ propTypesMisspellWarningShown = false;
1579
+ }
1580
+ /**
1581
+ * Verifies the object is a ReactElement.
1582
+ * See https://reactjs.org/docs/react-api.html#isvalidelement
1583
+ * @param {?object} object
1584
+ * @return {boolean} True if `object` is a ReactElement.
1585
+ * @final
1586
+ */
1587
+
1588
+
1589
+ function isValidElement(object) {
1590
+ {
1591
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1592
+ }
1593
+ }
1594
+
1595
+ function getDeclarationErrorAddendum() {
1596
+ {
1597
+ if (ReactCurrentOwner$1.current) {
1598
+ var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
1599
+
1600
+ if (name) {
1601
+ return '\n\nCheck the render method of `' + name + '`.';
1602
+ }
1603
+ }
1604
+
1605
+ return '';
1606
+ }
1607
+ }
1608
+
1609
+ function getSourceInfoErrorAddendum(source) {
1610
+ {
1611
+
1612
+ return '';
1613
+ }
1614
+ }
1615
+ /**
1616
+ * Warn if there's no key explicitly set on dynamic arrays of children or
1617
+ * object keys are not valid. This allows us to keep track of children between
1618
+ * updates.
1619
+ */
1620
+
1621
+
1622
+ var ownerHasKeyUseWarning = {};
1623
+
1624
+ function getCurrentComponentErrorInfo(parentType) {
1625
+ {
1626
+ var info = getDeclarationErrorAddendum();
1627
+
1628
+ if (!info) {
1629
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
1630
+
1631
+ if (parentName) {
1632
+ info = "\n\nCheck the top-level render call using <" + parentName + ">.";
1633
+ }
1634
+ }
1635
+
1636
+ return info;
1637
+ }
1638
+ }
1639
+ /**
1640
+ * Warn if the element doesn't have an explicit key assigned to it.
1641
+ * This element is in an array. The array could grow and shrink or be
1642
+ * reordered. All children that haven't already been validated are required to
1643
+ * have a "key" property assigned to it. Error statuses are cached so a warning
1644
+ * will only be shown once.
1645
+ *
1646
+ * @internal
1647
+ * @param {ReactElement} element Element that requires a key.
1648
+ * @param {*} parentType element's parent's type.
1649
+ */
1650
+
1651
+
1652
+ function validateExplicitKey(element, parentType) {
1653
+ {
1654
+ if (!element._store || element._store.validated || element.key != null) {
1655
+ return;
1656
+ }
1657
+
1658
+ element._store.validated = true;
1659
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1660
+
1661
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1662
+ return;
1663
+ }
1664
+
1665
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
1666
+ // property, it may be the creator of the child that's responsible for
1667
+ // assigning it a key.
1668
+
1669
+ var childOwner = '';
1670
+
1671
+ if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
1672
+ // Give the component that originally created this child.
1673
+ childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
1674
+ }
1675
+
1676
+ setCurrentlyValidatingElement$1(element);
1677
+
1678
+ error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
1679
+
1680
+ setCurrentlyValidatingElement$1(null);
1681
+ }
1682
+ }
1683
+ /**
1684
+ * Ensure that every element either is passed in a static location, in an
1685
+ * array with an explicit keys property defined, or in an object literal
1686
+ * with valid key property.
1687
+ *
1688
+ * @internal
1689
+ * @param {ReactNode} node Statically passed child of any type.
1690
+ * @param {*} parentType node's parent's type.
1691
+ */
1692
+
1693
+
1694
+ function validateChildKeys(node, parentType) {
1695
+ {
1696
+ if (typeof node !== 'object') {
1697
+ return;
1698
+ }
1699
+
1700
+ if (isArray(node)) {
1701
+ for (var i = 0; i < node.length; i++) {
1702
+ var child = node[i];
1703
+
1704
+ if (isValidElement(child)) {
1705
+ validateExplicitKey(child, parentType);
1706
+ }
1707
+ }
1708
+ } else if (isValidElement(node)) {
1709
+ // This element was passed in a valid location.
1710
+ if (node._store) {
1711
+ node._store.validated = true;
1712
+ }
1713
+ } else if (node) {
1714
+ var iteratorFn = getIteratorFn(node);
1715
+
1716
+ if (typeof iteratorFn === 'function') {
1717
+ // Entry iterators used to provide implicit keys,
1718
+ // but now we print a separate warning for them later.
1719
+ if (iteratorFn !== node.entries) {
1720
+ var iterator = iteratorFn.call(node);
1721
+ var step;
1722
+
1723
+ while (!(step = iterator.next()).done) {
1724
+ if (isValidElement(step.value)) {
1725
+ validateExplicitKey(step.value, parentType);
1726
+ }
1727
+ }
1728
+ }
1729
+ }
1730
+ }
1731
+ }
1732
+ }
1733
+ /**
1734
+ * Given an element, validate that its props follow the propTypes definition,
1735
+ * provided by the type.
1736
+ *
1737
+ * @param {ReactElement} element
1738
+ */
1739
+
1740
+
1741
+ function validatePropTypes(element) {
1742
+ {
1743
+ var type = element.type;
1744
+
1745
+ if (type === null || type === undefined || typeof type === 'string') {
1746
+ return;
1747
+ }
1748
+
1749
+ var propTypes;
1750
+
1751
+ if (typeof type === 'function') {
1752
+ propTypes = type.propTypes;
1753
+ } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1754
+ // Inner props are checked in the reconciler.
1755
+ type.$$typeof === REACT_MEMO_TYPE)) {
1756
+ propTypes = type.propTypes;
1757
+ } else {
1758
+ return;
1759
+ }
1760
+
1761
+ if (propTypes) {
1762
+ // Intentionally inside to avoid triggering lazy initializers:
1763
+ var name = getComponentNameFromType(type);
1764
+ checkPropTypes(propTypes, element.props, 'prop', name, element);
1765
+ } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1766
+ propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
1767
+
1768
+ var _name = getComponentNameFromType(type);
1769
+
1770
+ error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
1771
+ }
1772
+
1773
+ if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
1774
+ error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1775
+ }
1776
+ }
1777
+ }
1778
+ /**
1779
+ * Given a fragment, validate that it can only be provided with fragment props
1780
+ * @param {ReactElement} fragment
1781
+ */
1782
+
1783
+
1784
+ function validateFragmentProps(fragment) {
1785
+ {
1786
+ var keys = Object.keys(fragment.props);
1787
+
1788
+ for (var i = 0; i < keys.length; i++) {
1789
+ var key = keys[i];
1790
+
1791
+ if (key !== 'children' && key !== 'key') {
1792
+ setCurrentlyValidatingElement$1(fragment);
1793
+
1794
+ error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1795
+
1796
+ setCurrentlyValidatingElement$1(null);
1797
+ break;
1798
+ }
1799
+ }
1800
+
1801
+ if (fragment.ref !== null) {
1802
+ setCurrentlyValidatingElement$1(fragment);
1803
+
1804
+ error('Invalid attribute `ref` supplied to `React.Fragment`.');
1805
+
1806
+ setCurrentlyValidatingElement$1(null);
1807
+ }
1808
+ }
1809
+ }
1810
+
1811
+ var didWarnAboutKeySpread = {};
1812
+ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1813
+ {
1814
+ var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
1815
+ // succeed and there will likely be errors in render.
1816
+
1817
+ if (!validType) {
1818
+ var info = '';
1819
+
1820
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1821
+ info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
1822
+ }
1823
+
1824
+ var sourceInfo = getSourceInfoErrorAddendum();
1825
+
1826
+ if (sourceInfo) {
1827
+ info += sourceInfo;
1828
+ } else {
1829
+ info += getDeclarationErrorAddendum();
1830
+ }
1831
+
1832
+ var typeString;
1833
+
1834
+ if (type === null) {
1835
+ typeString = 'null';
1836
+ } else if (isArray(type)) {
1837
+ typeString = 'array';
1838
+ } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1839
+ typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
1840
+ info = ' Did you accidentally export a JSX literal instead of a component?';
1841
+ } else {
1842
+ typeString = typeof type;
1843
+ }
1844
+
1845
+ error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
1846
+ }
1847
+
1848
+ var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
1849
+ // TODO: Drop this when these are no longer allowed as the type argument.
1850
+
1851
+ if (element == null) {
1852
+ return element;
1853
+ } // Skip key warning if the type isn't valid since our key validation logic
1854
+ // doesn't expect a non-string/function type and can throw confusing errors.
1855
+ // We don't want exception behavior to differ between dev and prod.
1856
+ // (Rendering will throw with a helpful message and as soon as the type is
1857
+ // fixed, the key warnings will appear.)
1858
+
1859
+
1860
+ if (validType) {
1861
+ var children = props.children;
1862
+
1863
+ if (children !== undefined) {
1864
+ if (isStaticChildren) {
1865
+ if (isArray(children)) {
1866
+ for (var i = 0; i < children.length; i++) {
1867
+ validateChildKeys(children[i], type);
1868
+ }
1869
+
1870
+ if (Object.freeze) {
1871
+ Object.freeze(children);
1872
+ }
1873
+ } else {
1874
+ error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
1875
+ }
1876
+ } else {
1877
+ validateChildKeys(children, type);
1878
+ }
1879
+ }
1880
+ }
1881
+
1882
+ {
1883
+ if (hasOwnProperty.call(props, 'key')) {
1884
+ var componentName = getComponentNameFromType(type);
1885
+ var keys = Object.keys(props).filter(function (k) {
1886
+ return k !== 'key';
1887
+ });
1888
+ var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';
1889
+
1890
+ if (!didWarnAboutKeySpread[componentName + beforeExample]) {
1891
+ var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';
1892
+
1893
+ error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
1894
+
1895
+ didWarnAboutKeySpread[componentName + beforeExample] = true;
1896
+ }
1897
+ }
1898
+ }
1899
+
1900
+ if (type === REACT_FRAGMENT_TYPE) {
1901
+ validateFragmentProps(element);
1902
+ } else {
1903
+ validatePropTypes(element);
1904
+ }
1905
+
1906
+ return element;
1907
+ }
1908
+ } // These two functions exist to still get child warnings in dev
1909
+ // even with the prod transform. This means that jsxDEV is purely
1910
+ // opt-in behavior for better messages but that we won't stop
1911
+ // giving you warnings if you use production apis.
1912
+
1913
+ function jsxWithValidationStatic(type, props, key) {
1914
+ {
1915
+ return jsxWithValidation(type, props, key, true);
1916
+ }
1917
+ }
1918
+ function jsxWithValidationDynamic(type, props, key) {
1919
+ {
1920
+ return jsxWithValidation(type, props, key, false);
1921
+ }
1922
+ }
1923
+
1924
+ var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
1925
+ // for now we can ship identical prod functions
1926
+
1927
+ var jsxs = jsxWithValidationStatic ;
1928
+
1929
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
1930
+ reactJsxRuntime_development.jsx = jsx;
1931
+ reactJsxRuntime_development.jsxs = jsxs;
1932
+ })();
1933
+ }
1934
+ return reactJsxRuntime_development;
1935
+ }
1936
+
1937
+ if (process.env.NODE_ENV === 'production') {
1938
+ jsxRuntime.exports = requireReactJsxRuntime_production_min();
1939
+ } else {
1940
+ jsxRuntime.exports = requireReactJsxRuntime_development();
1941
+ }
1942
+
1943
+ var jsxRuntimeExports = jsxRuntime.exports;
1944
+
1945
+ const WordPressContent = ({ content, className = '', showExcerpt = false, showDate = true, showAuthor = true, }) => {
1946
+ return (jsxRuntimeExports.jsxs("article", { className: `wordpress-content ${className}`, children: [jsxRuntimeExports.jsxs("header", { className: "content-header", children: [jsxRuntimeExports.jsx("h1", { className: "content-title", dangerouslySetInnerHTML: { __html: content.title.rendered } }), showDate && (jsxRuntimeExports.jsx("time", { className: "content-date", dateTime: content.date, children: new Date(content.date).toLocaleDateString() })), showAuthor && 'author' in content && (jsxRuntimeExports.jsxs("span", { className: "content-author", children: ["Author ID: ", content.author] }))] }), showExcerpt && content.excerpt && (jsxRuntimeExports.jsx("div", { className: "content-excerpt", dangerouslySetInnerHTML: { __html: content.excerpt.rendered } })), jsxRuntimeExports.jsx("div", { className: "content-body", dangerouslySetInnerHTML: { __html: content.content.rendered } })] }));
1947
+ };
1948
+
1949
+ const GravityForm = ({ formId, config, className = '', onSubmit, onError, }) => {
1950
+ const { form, loading, error, submitting, result, submitForm } = useGravityForms(formId, config);
1951
+ const [formData, setFormData] = useState({});
1952
+ const handleSubmit = async (e) => {
1953
+ e.preventDefault();
1954
+ try {
1955
+ const submission = {
1956
+ form_id: formId,
1957
+ field_values: formData,
1958
+ };
1959
+ await submitForm(submission);
1960
+ if (onSubmit && result) {
1961
+ onSubmit(result);
1962
+ }
1963
+ }
1964
+ catch (err) {
1965
+ if (onError) {
1966
+ onError(err instanceof Error ? err : new Error('Unknown error'));
1967
+ }
1968
+ }
1969
+ };
1970
+ const handleFieldChange = (fieldId, value) => {
1971
+ setFormData(prev => ({
1972
+ ...prev,
1973
+ [fieldId]: value,
1974
+ }));
1975
+ };
1976
+ if (loading) {
1977
+ return jsxRuntimeExports.jsx("div", { className: `gravity-form loading ${className}`, children: "Loading form..." });
1978
+ }
1979
+ if (error) {
1980
+ return jsxRuntimeExports.jsxs("div", { className: `gravity-form error ${className}`, children: ["Error: ", error.message] });
1981
+ }
1982
+ if (!form) {
1983
+ return jsxRuntimeExports.jsx("div", { className: `gravity-form not-found ${className}`, children: "Form not found" });
1984
+ }
1985
+ return (jsxRuntimeExports.jsx("div", { className: `gravity-form ${className}`, children: jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, children: [jsxRuntimeExports.jsx("h2", { children: form.title }), form.description && jsxRuntimeExports.jsx("p", { children: form.description }), form.fields.map(field => (jsxRuntimeExports.jsxs("div", { className: `field field-${field.type}`, children: [jsxRuntimeExports.jsxs("label", { htmlFor: `field_${field.id}`, children: [field.label, field.required && jsxRuntimeExports.jsx("span", { className: "required", children: "*" })] }), field.description && (jsxRuntimeExports.jsx("p", { className: "field-description", children: field.description })), field.type === 'text' && (jsxRuntimeExports.jsx("input", { type: "text", id: `field_${field.id}`, name: field.label, required: field.required, placeholder: field.placeholder, onChange: (e) => handleFieldChange(field.id.toString(), e.target.value) })), field.type === 'email' && (jsxRuntimeExports.jsx("input", { type: "email", id: `field_${field.id}`, name: field.label, required: field.required, placeholder: field.placeholder, onChange: (e) => handleFieldChange(field.id.toString(), e.target.value) })), field.type === 'textarea' && (jsxRuntimeExports.jsx("textarea", { id: `field_${field.id}`, name: field.label, required: field.required, placeholder: field.placeholder, onChange: (e) => handleFieldChange(field.id.toString(), e.target.value) })), field.type === 'select' && field.choices && (jsxRuntimeExports.jsxs("select", { id: `field_${field.id}`, name: field.label, required: field.required, onChange: (e) => handleFieldChange(field.id.toString(), e.target.value), children: [jsxRuntimeExports.jsx("option", { value: "", children: "Select an option" }), field.choices.map((choice, index) => (jsxRuntimeExports.jsx("option", { value: choice.value, children: choice.text }, index)))] }))] }, field.id))), jsxRuntimeExports.jsx("button", { type: "submit", disabled: submitting, children: submitting ? 'Submitting...' : 'Submit' }), result && (jsxRuntimeExports.jsx("div", { className: `result ${result.success ? 'success' : 'error'}`, children: result.message }))] }) }));
1986
+ };
1987
+
1988
+ const WordPressContext = createContext(undefined);
1989
+ const WordPressProvider = ({ config, children }) => {
1990
+ return (jsxRuntimeExports.jsx(WordPressContext.Provider, { value: { config }, children: children }));
1991
+ };
1992
+ function useWordPressContext() {
1993
+ const context = useContext(WordPressContext);
1994
+ if (context === undefined) {
1995
+ throw new Error('useWordPressContext must be used within a WordPressProvider');
1996
+ }
1997
+ return context;
1998
+ }
1999
+
2000
+ const GravityFormsContext = createContext(undefined);
2001
+ const GravityFormsProvider = ({ config, children }) => {
2002
+ return (jsxRuntimeExports.jsx(GravityFormsContext.Provider, { value: { config }, children: children }));
2003
+ };
2004
+ function useGravityFormsContext() {
2005
+ const context = useContext(GravityFormsContext);
2006
+ if (context === undefined) {
2007
+ throw new Error('useGravityFormsContext must be used within a GravityFormsProvider');
2008
+ }
2009
+ return context;
2010
+ }
2011
+
2012
+ /**
2013
+ * @license GPL-3.0-or-later
2014
+ *
2015
+ * This file is part of the MarVAlt Open SDK.
2016
+ * Copyright (c) 2025 Vibune Pty Ltd.
2017
+ *
2018
+ * This program is free software: you can redistribute it and/or modify
2019
+ * it under the terms of the GNU General Public License as published by
2020
+ * the Free Software Foundation, either version 3 of the License, or
2021
+ * (at your option) any later version.
2022
+ *
2023
+ * This program is distributed in the hope that it will be useful,
2024
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2025
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2026
+ * See the GNU General Public License for more details.
2027
+ */
2028
+ // WordPress Static Data Generator
2029
+ class WordPressGenerator {
2030
+ constructor(config) {
2031
+ this.config = config;
2032
+ }
2033
+ async generateStaticData() {
2034
+ const client = new WordPressClient(this.config);
2035
+ console.log('🚀 Starting WordPress static data generation...');
2036
+ const frontendId = this.config.frontendId || 'default-frontend';
2037
+ const frontendName = this.config.frontendName || 'Default Frontend';
2038
+ const postTypes = this.config.postTypes || ['posts', 'pages', 'case_studies', 'projects', 'members', 'testimonial', 'faqs', 'products', 'services', 'events'];
2039
+ const data = await client.getAllData({
2040
+ per_page: this.config.maxItems || 100,
2041
+ _embed: this.config.includeEmbedded || false,
2042
+ });
2043
+ // Create the static data structure matching the existing format
2044
+ const staticData = {
2045
+ generated_at: new Date().toISOString(),
2046
+ frontend_id: frontendId,
2047
+ frontend_name: frontendName,
2048
+ config: {
2049
+ frontend_id: frontendId,
2050
+ frontend_name: frontendName,
2051
+ post_types: postTypes.reduce((acc, postType) => {
2052
+ acc[postType] = {
2053
+ max_items: this.config.maxItems || 100,
2054
+ include_embedded: this.config.includeEmbedded || true,
2055
+ orderby: 'date',
2056
+ order: 'desc',
2057
+ };
2058
+ return acc;
2059
+ }, {}),
2060
+ },
2061
+ // Map the data to the expected structure
2062
+ posts: data.posts,
2063
+ pages: data.pages,
2064
+ media: data.media,
2065
+ categories: data.categories,
2066
+ tags: data.tags,
2067
+ };
2068
+ // Write to file
2069
+ this.writeStaticData(staticData);
2070
+ console.log('✅ WordPress static data generation completed');
2071
+ console.log(`📊 Generated data: ${data.posts.length} posts, ${data.pages.length} pages, ${data.media.length} media items`);
2072
+ return staticData;
2073
+ }
2074
+ writeStaticData(data) {
2075
+ try {
2076
+ const outputPath = join(process.cwd(), this.config.outputPath);
2077
+ writeFileSync(outputPath, JSON.stringify(data, null, 2));
2078
+ console.log(`📁 Static data written to: ${outputPath}`);
2079
+ }
2080
+ catch (error) {
2081
+ console.error('❌ Error writing static data:', error);
2082
+ throw error;
2083
+ }
2084
+ }
2085
+ async generatePostsOnly() {
2086
+ const client = new WordPressClient(this.config);
2087
+ return client.getPosts({ per_page: 100 });
2088
+ }
2089
+ async generatePagesOnly() {
2090
+ const client = new WordPressClient(this.config);
2091
+ return client.getPages({ per_page: 100 });
2092
+ }
2093
+ async generateMediaOnly() {
2094
+ const client = new WordPressClient(this.config);
2095
+ return client.getMedia({ per_page: 100 });
2096
+ }
2097
+ }
2098
+ // Convenience function for easy usage
2099
+ async function generateWordPressData(config) {
2100
+ const generator = new WordPressGenerator(config);
2101
+ return generator.generateStaticData();
2102
+ }
2103
+
2104
+ /**
2105
+ * @license GPL-3.0-or-later
2106
+ *
2107
+ * This file is part of the MarVAlt Open SDK.
2108
+ * Copyright (c) 2025 Vibune Pty Ltd.
2109
+ *
2110
+ * This program is free software: you can redistribute it and/or modify
2111
+ * it under the terms of the GNU General Public License as published by
2112
+ * the Free Software Foundation, either version 3 of the License, or
2113
+ * (at your option) any later version.
2114
+ *
2115
+ * This program is distributed in the hope that it will be useful,
2116
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2117
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2118
+ * See the GNU General Public License for more details.
2119
+ */
2120
+ // Gravity Forms Static Data Generator
2121
+ class GravityFormsGenerator {
2122
+ constructor(config) {
2123
+ this.config = config;
2124
+ }
2125
+ async generateStaticData() {
2126
+ const client = new GravityFormsClient(this.config);
2127
+ console.log('🚀 Starting Gravity Forms static data generation...');
2128
+ let forms = [];
2129
+ if (this.config.formIds && this.config.formIds.length > 0) {
2130
+ // Generate specific forms
2131
+ for (const formId of this.config.formIds) {
2132
+ try {
2133
+ const form = await client.getFormConfig(formId);
2134
+ if (this.config.includeInactive || form.is_active) {
2135
+ forms.push(form);
2136
+ }
2137
+ }
2138
+ catch (error) {
2139
+ console.warn(`⚠️ Could not fetch form ${formId}:`, error);
2140
+ }
2141
+ }
2142
+ }
2143
+ else {
2144
+ // Generate all forms
2145
+ const formsList = await client.getForms();
2146
+ console.log('🔍 Gravity Forms Response:', {
2147
+ formsType: typeof formsList,
2148
+ isArray: Array.isArray(formsList),
2149
+ formsLength: formsList?.length,
2150
+ formsPreview: formsList ? JSON.stringify(formsList).substring(0, 200) : 'null',
2151
+ });
2152
+ let formsMetadata = [];
2153
+ if (Array.isArray(formsList)) {
2154
+ formsMetadata = formsList;
2155
+ }
2156
+ else if (formsList && typeof formsList === 'object' && Array.isArray(formsList.forms)) {
2157
+ formsMetadata = formsList.forms;
2158
+ }
2159
+ else if (formsList) {
2160
+ formsMetadata = [formsList];
2161
+ }
2162
+ if (!this.config.includeInactive) {
2163
+ formsMetadata = formsMetadata.filter(form => form.is_active === '1' || form.is_active === true);
2164
+ }
2165
+ // Fetch full form configuration for each form (schema lives under /config)
2166
+ console.log(`🔄 Fetching full data for ${formsMetadata.length} forms...`);
2167
+ forms = [];
2168
+ for (const formMetadata of formsMetadata) {
2169
+ try {
2170
+ const formId = Number(formMetadata.id);
2171
+ const fullForm = await client.getFormConfig(formId);
2172
+ forms.push(fullForm);
2173
+ console.log(`✅ Fetched form: ${fullForm.title} (${fullForm.fields?.length || 0} fields)`);
2174
+ }
2175
+ catch (error) {
2176
+ console.error(`❌ Failed to fetch form ${formMetadata.id} config:`, error);
2177
+ throw error;
2178
+ }
2179
+ }
2180
+ }
2181
+ const staticData = {
2182
+ generated_at: new Date().toISOString(),
2183
+ total_forms: forms.length,
2184
+ forms,
2185
+ };
2186
+ // Write to file
2187
+ this.writeStaticData(staticData);
2188
+ console.log('✅ Gravity Forms static data generation completed');
2189
+ console.log(`📊 Generated data: ${forms.length} forms`);
2190
+ return staticData;
2191
+ }
2192
+ writeStaticData(data) {
2193
+ try {
2194
+ const outputPath = join(process.cwd(), this.config.outputPath);
2195
+ writeFileSync(outputPath, JSON.stringify(data, null, 2));
2196
+ console.log(`📁 Static data written to: ${outputPath}`);
2197
+ }
2198
+ catch (error) {
2199
+ console.error('❌ Error writing static data:', error);
2200
+ throw error;
2201
+ }
2202
+ }
2203
+ async generateFormConfig(formId) {
2204
+ const client = new GravityFormsClient(this.config);
2205
+ return client.getFormConfig(formId);
2206
+ }
2207
+ }
2208
+ // Convenience function for easy usage
2209
+ async function generateGravityFormsData(config) {
2210
+ const generator = new GravityFormsGenerator(config);
2211
+ return generator.generateStaticData();
2212
+ }
2213
+
2214
+ /**
2215
+ * @license GPL-3.0-or-later
2216
+ *
2217
+ * This file is part of the MarVAlt Open SDK.
2218
+ * Copyright (c) 2025 Vibune Pty Ltd.
2219
+ *
2220
+ * This program is free software: you can redistribute it and/or modify
2221
+ * it under the terms of the GNU General Public License as published by
2222
+ * the Free Software Foundation, either version 3 of the License, or
2223
+ * (at your option) any later version.
2224
+ *
2225
+ * This program is distributed in the hope that it will be useful,
2226
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2227
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2228
+ * See the GNU General Public License for more details.
2229
+ */
2230
+ class FormProtectionGenerator {
2231
+ constructor(config) {
2232
+ this.config = config;
2233
+ }
2234
+ async generateStaticData() {
2235
+ console.log('🚀 Starting Form Protection static data generation...');
2236
+ const forms = this.config.forms.map(form => ({
2237
+ id: form.id,
2238
+ name: form.name,
2239
+ protectionLevel: form.protectionLevel,
2240
+ emailVerification: this.config.emailVerification,
2241
+ spamProtection: this.config.spamProtection,
2242
+ rateLimiting: this.config.rateLimiting,
2243
+ }));
2244
+ const staticData = {
2245
+ config: {
2246
+ enabled: this.config.enabled,
2247
+ secret: this.config.secret,
2248
+ emailVerification: this.config.emailVerification,
2249
+ spamProtection: this.config.spamProtection,
2250
+ rateLimiting: this.config.rateLimiting,
2251
+ maxSubmissionsPerHour: this.config.maxSubmissionsPerHour,
2252
+ maxSubmissionsPerDay: this.config.maxSubmissionsPerDay,
2253
+ },
2254
+ forms,
2255
+ generatedAt: new Date().toISOString(),
2256
+ };
2257
+ // Write to file
2258
+ this.writeStaticData(staticData);
2259
+ console.log('✅ Form Protection static data generation completed');
2260
+ console.log(`📊 Generated data: ${forms.length} protected forms`);
2261
+ return staticData;
2262
+ }
2263
+ writeStaticData(data) {
2264
+ try {
2265
+ const outputPath = join(process.cwd(), this.config.outputPath);
2266
+ writeFileSync(outputPath, JSON.stringify(data, null, 2));
2267
+ console.log(`📁 Static data written to: ${outputPath}`);
2268
+ }
2269
+ catch (error) {
2270
+ console.error('❌ Error writing static data:', error);
2271
+ throw error;
2272
+ }
2273
+ }
2274
+ validateFormProtection(formData) {
2275
+ // Basic validation logic for form protection
2276
+ const errors = [];
2277
+ if (this.config.emailVerification && !formData.email) {
2278
+ errors.push('Email verification is required');
2279
+ }
2280
+ if (this.config.spamProtection) {
2281
+ // Basic spam detection logic
2282
+ if (formData.message && formData.message.length < 10) {
2283
+ errors.push('Message too short');
2284
+ }
2285
+ }
2286
+ return {
2287
+ success: errors.length === 0,
2288
+ protected: this.config.enabled,
2289
+ message: errors.length > 0 ? errors.join(', ') : 'Form is protected',
2290
+ verificationRequired: this.config.emailVerification,
2291
+ spamDetected: errors.length > 0,
2292
+ };
2293
+ }
2294
+ }
2295
+ // Convenience function for easy usage
2296
+ async function generateFormProtectionData(config) {
2297
+ const generator = new FormProtectionGenerator(config);
2298
+ return generator.generateStaticData();
2299
+ }
2300
+
2301
+ /**
2302
+ * @license GPL-3.0-or-later
2303
+ *
2304
+ * This file is part of the MarVAlt Open SDK.
2305
+ * Copyright (c) 2025 Vibune Pty Ltd.
2306
+ *
2307
+ * This program is free software: you can redistribute it and/or modify
2308
+ * it under the terms of the GNU General Public License as published by
2309
+ * the Free Software Foundation, either version 3 of the License, or
2310
+ * (at your option) any later version.
2311
+ *
2312
+ * This program is distributed in the hope that it will be useful,
2313
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2314
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2315
+ * See the GNU General Public License for more details.
2316
+ */
2317
+ function createWordPressConfig(overrides = {}) {
2318
+ return {
2319
+ apiUrl: process.env.VITE_WORDPRESS_API_URL || '',
2320
+ authMode: process.env.VITE_WP_AUTH_MODE || 'cloudflare_proxy',
2321
+ cloudflareWorkerUrl: process.env.VITE_CLOUDFLARE_WORKER_URL,
2322
+ supabaseUrl: process.env.VITE_SUPABASE_URL,
2323
+ username: process.env.VITE_WP_API_USERNAME,
2324
+ password: process.env.VITE_WP_APP_PASSWORD,
2325
+ timeout: 30000,
2326
+ retries: 3,
2327
+ ...overrides,
2328
+ };
2329
+ }
2330
+ function createGravityFormsConfig(overrides = {}) {
2331
+ return {
2332
+ apiUrl: process.env.VITE_GRAVITY_FORMS_API_URL || '',
2333
+ authMode: process.env.VITE_WP_AUTH_MODE || 'cloudflare_proxy',
2334
+ cloudflareWorkerUrl: process.env.VITE_CLOUDFLARE_WORKER_URL,
2335
+ supabaseUrl: process.env.VITE_SUPABASE_URL,
2336
+ username: process.env.VITE_GRAVITY_FORMS_USERNAME || '',
2337
+ password: process.env.VITE_GRAVITY_FORMS_PASSWORD || '',
2338
+ timeout: 30000,
2339
+ retries: 3,
2340
+ ...overrides,
2341
+ };
2342
+ }
2343
+ function createFormProtectionConfig(overrides = {}) {
2344
+ return {
2345
+ enabled: process.env.VITE_FORM_PROTECTION_ENABLED === 'true',
2346
+ secret: process.env.VITE_FORM_PROTECTION_SECRET || '',
2347
+ emailVerification: process.env.VITE_FORM_PROTECTION_EMAIL_VERIFICATION === 'true',
2348
+ spamProtection: process.env.VITE_FORM_PROTECTION_SPAM_PROTECTION === 'true',
2349
+ rateLimiting: process.env.VITE_FORM_PROTECTION_RATE_LIMITING === 'true',
2350
+ maxSubmissionsPerHour: parseInt(process.env.VITE_FORM_PROTECTION_MAX_HOURLY || '10'),
2351
+ maxSubmissionsPerDay: parseInt(process.env.VITE_FORM_PROTECTION_MAX_DAILY || '50'),
2352
+ ...overrides,
2353
+ };
2354
+ }
2355
+ function validateWordPressConfig(config) {
2356
+ const errors = [];
2357
+ if (!config.apiUrl) {
2358
+ errors.push('WordPress API URL is required');
2359
+ }
2360
+ if (config.authMode === 'cloudflare_proxy' && !config.cloudflareWorkerUrl) {
2361
+ errors.push('Cloudflare Worker URL is required for cloudflare_proxy mode');
2362
+ }
2363
+ if (config.authMode === 'supabase_proxy' && !config.supabaseUrl) {
2364
+ errors.push('Supabase URL is required for supabase_proxy mode');
2365
+ }
2366
+ return errors;
2367
+ }
2368
+ function validateGravityFormsConfig(config) {
2369
+ const errors = [];
2370
+ if (!config.apiUrl) {
2371
+ errors.push('Gravity Forms API URL is required');
2372
+ }
2373
+ if (!config.username) {
2374
+ errors.push('Gravity Forms username is required');
2375
+ }
2376
+ if (!config.password) {
2377
+ errors.push('Gravity Forms password is required');
2378
+ }
2379
+ return errors;
2380
+ }
2381
+ function validateFormProtectionConfig(config) {
2382
+ const errors = [];
2383
+ if (config.enabled && !config.secret) {
2384
+ errors.push('Form protection secret is required when protection is enabled');
2385
+ }
2386
+ if (config.maxSubmissionsPerHour && config.maxSubmissionsPerHour < 1) {
2387
+ errors.push('Max submissions per hour must be at least 1');
2388
+ }
2389
+ if (config.maxSubmissionsPerDay && config.maxSubmissionsPerDay < 1) {
2390
+ errors.push('Max submissions per day must be at least 1');
2391
+ }
2392
+ return errors;
2393
+ }
2394
+
2395
+ /**
2396
+ * @license GPL-3.0-or-later
2397
+ *
2398
+ * This file is part of the MarVAlt Open SDK.
2399
+ * Copyright (c) 2025 Vibune Pty Ltd.
2400
+ *
2401
+ * This program is free software: you can redistribute it and/or modify
2402
+ * it under the terms of the GNU General Public License as published by
2403
+ * the Free Software Foundation, either version 3 of the License, or
2404
+ * (at your option) any later version.
2405
+ *
2406
+ * This program is distributed in the hope that it will be useful,
2407
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2408
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2409
+ * See the GNU General Public License for more details.
2410
+ */
2411
+ // Validation utilities
2412
+ function validateEmail(email) {
2413
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
2414
+ return emailRegex.test(email);
2415
+ }
2416
+ function validateRequired(value) {
2417
+ return value !== null && value !== undefined && value !== '';
2418
+ }
2419
+ function validateMinLength(value, minLength) {
2420
+ return value.length >= minLength;
2421
+ }
2422
+ function validateMaxLength(value, maxLength) {
2423
+ return value.length <= maxLength;
2424
+ }
2425
+ function validatePhoneNumber(phone) {
2426
+ const phoneRegex = /^[\+]?[1-9][\d]{0,15}$/;
2427
+ return phoneRegex.test(phone.replace(/\s/g, ''));
2428
+ }
2429
+ function validateUrl(url) {
2430
+ try {
2431
+ new URL(url);
2432
+ return true;
2433
+ }
2434
+ catch {
2435
+ return false;
2436
+ }
2437
+ }
2438
+ function sanitizeHtml(html) {
2439
+ // Basic HTML sanitization - in production, use a proper library like DOMPurify
2440
+ return html
2441
+ .replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '')
2442
+ .replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi, '')
2443
+ .replace(/javascript:/gi, '')
2444
+ .replace(/on\w+\s*=/gi, '');
2445
+ }
2446
+ function validateFormData(formData, rules) {
2447
+ const errors = {};
2448
+ let isValid = true;
2449
+ for (const [fieldName, fieldRules] of Object.entries(rules)) {
2450
+ const value = formData[fieldName];
2451
+ const fieldErrors = [];
2452
+ if (fieldRules.required && !validateRequired(value)) {
2453
+ fieldErrors.push(`${fieldName} is required`);
2454
+ }
2455
+ if (value && fieldRules.type === 'email' && !validateEmail(value)) {
2456
+ fieldErrors.push(`${fieldName} must be a valid email address`);
2457
+ }
2458
+ if (value && fieldRules.type === 'url' && !validateUrl(value)) {
2459
+ fieldErrors.push(`${fieldName} must be a valid URL`);
2460
+ }
2461
+ if (value && fieldRules.type === 'phone' && !validatePhoneNumber(value)) {
2462
+ fieldErrors.push(`${fieldName} must be a valid phone number`);
2463
+ }
2464
+ if (value && fieldRules.minLength && !validateMinLength(value, fieldRules.minLength)) {
2465
+ fieldErrors.push(`${fieldName} must be at least ${fieldRules.minLength} characters long`);
2466
+ }
2467
+ if (value && fieldRules.maxLength && !validateMaxLength(value, fieldRules.maxLength)) {
2468
+ fieldErrors.push(`${fieldName} must be no more than ${fieldRules.maxLength} characters long`);
2469
+ }
2470
+ if (fieldErrors.length > 0) {
2471
+ errors[fieldName] = fieldErrors;
2472
+ isValid = false;
2473
+ }
2474
+ }
2475
+ return { isValid, errors };
2476
+ }
2477
+
2478
+ export { FormProtectionGenerator, GravityForm, GravityFormsClient, GravityFormsGenerator, GravityFormsProvider, WordPressClient, WordPressContent, WordPressGenerator, WordPressProvider, createFormProtectionConfig, createGravityFormsConfig, createWordPressConfig, generateFormProtectionData, generateGravityFormsData, generateWordPressData, sanitizeHtml, transformWordPressMedia, transformWordPressMediaItems, transformWordPressPage, transformWordPressPages, transformWordPressPost, transformWordPressPosts, useGravityForms, useGravityFormsConfig, useGravityFormsContext, useWordPress, useWordPressCategories, useWordPressContext, useWordPressMedia, useWordPressPage, useWordPressPages, useWordPressPost, useWordPressPosts, useWordPressTags, validateEmail, validateFormData, validateFormProtectionConfig, validateGravityFormsConfig, validateMaxLength, validateMinLength, validatePhoneNumber, validateRequired, validateUrl, validateWordPressConfig };
2479
+ //# sourceMappingURL=index.esm.js.map