@plasmicapp/react-web 0.2.197 → 0.2.199

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 (37) hide show
  1. package/dist/index.cjs.js +3845 -0
  2. package/dist/index.cjs.js.map +1 -0
  3. package/dist/plume/button/index.d.ts +4 -4
  4. package/dist/plume/checkbox/index.d.ts +1 -1
  5. package/dist/plume/collection-utils.d.ts +7 -7
  6. package/dist/plume/collection-utils.spec.d.ts +1 -0
  7. package/dist/plume/menu/menu.d.ts +1 -1
  8. package/dist/plume/menu-button/menu-button.d.ts +1 -1
  9. package/dist/plume/menu-button/menu-trigger.d.ts +1 -1
  10. package/dist/plume/plume-utils.d.ts +13 -13
  11. package/dist/plume/select/select-option.d.ts +1 -1
  12. package/dist/plume/select/select.d.ts +1 -1
  13. package/dist/plume/switch/index.d.ts +1 -1
  14. package/dist/plume/text-input/index.d.ts +1 -1
  15. package/dist/plume/triggered-overlay/triggered-overlay.d.ts +1 -1
  16. package/dist/react-utils.d.ts +3 -3
  17. package/dist/react-utils.spec.d.ts +1 -0
  18. package/dist/react-web.esm.js +3615 -4538
  19. package/dist/react-web.esm.js.map +1 -1
  20. package/dist/render/PlasmicHead/index.d.ts +2 -2
  21. package/dist/render/PlasmicImg/index.d.ts +1 -1
  22. package/dist/render/Stack.d.ts +1 -1
  23. package/dist/render/elements.d.ts +12 -12
  24. package/dist/render/screen-variants.d.ts +1 -1
  25. package/dist/render/translation.d.ts +2 -2
  26. package/dist/render/triggers.d.ts +1 -1
  27. package/dist/states/helpers.d.ts +1 -1
  28. package/dist/states/types.d.ts +6 -6
  29. package/dist/stories/PlasmicImg.stories.d.ts +3 -2
  30. package/dist/stories/UseDollarState.stories.d.ts +23 -22
  31. package/package.json +15 -42
  32. package/dist/all.d.ts +0 -13357
  33. package/dist/index.js +0 -8
  34. package/dist/react-web.cjs.development.js +0 -4737
  35. package/dist/react-web.cjs.development.js.map +0 -1
  36. package/dist/react-web.cjs.production.min.js +0 -2
  37. package/dist/react-web.cjs.production.min.js.map +0 -1
@@ -0,0 +1,3845 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var classNames$1 = require('classnames');
7
+ var dataSourcesContext = require('@plasmicapp/data-sources-context');
8
+ var React = require('react');
9
+ var get = require('dlv');
10
+ var ReactDOM = require('react-dom');
11
+ var ssr = require('@react-aria/ssr');
12
+ var focus = require('@react-aria/focus');
13
+ var valtio = require('valtio');
14
+ var clone = require('clone');
15
+ var deepEqual = require('fast-deep-equal');
16
+ var checkbox = require('@react-aria/checkbox');
17
+ var visuallyHidden = require('@react-aria/visually-hidden');
18
+ var toggle = require('@react-stately/toggle');
19
+ var menu = require('@react-aria/menu');
20
+ var tree = require('@react-stately/tree');
21
+ var collections = require('@react-stately/collections');
22
+ var separator = require('@react-aria/separator');
23
+ var menu$1 = require('@react-stately/menu');
24
+ var interactions = require('@react-aria/interactions');
25
+ var host = require('@plasmicapp/host');
26
+ var listbox = require('@react-aria/listbox');
27
+ var select$1 = require('@react-aria/select');
28
+ var select = require('@react-stately/select');
29
+ var _switch = require('@react-aria/switch');
30
+ var overlays = require('@react-aria/overlays');
31
+
32
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
33
+
34
+ function _interopNamespace(e) {
35
+ if (e && e.__esModule) return e;
36
+ var n = Object.create(null);
37
+ if (e) {
38
+ Object.keys(e).forEach(function (k) {
39
+ if (k !== 'default') {
40
+ var d = Object.getOwnPropertyDescriptor(e, k);
41
+ Object.defineProperty(n, k, d.get ? d : {
42
+ enumerable: true,
43
+ get: function () {
44
+ return e[k];
45
+ }
46
+ });
47
+ }
48
+ });
49
+ }
50
+ n['default'] = e;
51
+ return Object.freeze(n);
52
+ }
53
+
54
+ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames$1);
55
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
56
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
57
+ var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
58
+ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
59
+ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
60
+ var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
61
+ var deepEqual__default = /*#__PURE__*/_interopDefaultLegacy(deepEqual);
62
+
63
+ /*! *****************************************************************************
64
+ Copyright (c) Microsoft Corporation.
65
+
66
+ Permission to use, copy, modify, and/or distribute this software for any
67
+ purpose with or without fee is hereby granted.
68
+
69
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
70
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
71
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
72
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
73
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
74
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
75
+ PERFORMANCE OF THIS SOFTWARE.
76
+ ***************************************************************************** */
77
+ /* global Reflect, Promise */
78
+
79
+ var extendStatics = function(d, b) {
80
+ extendStatics = Object.setPrototypeOf ||
81
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
82
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
83
+ return extendStatics(d, b);
84
+ };
85
+
86
+ function __extends(d, b) {
87
+ if (typeof b !== "function" && b !== null)
88
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
89
+ extendStatics(d, b);
90
+ function __() { this.constructor = d; }
91
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
92
+ }
93
+
94
+ var __assign = function() {
95
+ __assign = Object.assign || function __assign(t) {
96
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
97
+ s = arguments[i];
98
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
99
+ }
100
+ return t;
101
+ };
102
+ return __assign.apply(this, arguments);
103
+ };
104
+
105
+ function __rest(s, e) {
106
+ var t = {};
107
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
108
+ t[p] = s[p];
109
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
110
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
111
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
112
+ t[p[i]] = s[p[i]];
113
+ }
114
+ return t;
115
+ }
116
+
117
+ function __awaiter(thisArg, _arguments, P, generator) {
118
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
119
+ return new (P || (P = Promise))(function (resolve, reject) {
120
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
121
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
122
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
123
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
124
+ });
125
+ }
126
+
127
+ function __generator(thisArg, body) {
128
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
129
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
130
+ function verb(n) { return function (v) { return step([n, v]); }; }
131
+ function step(op) {
132
+ if (f) throw new TypeError("Generator is already executing.");
133
+ while (_) try {
134
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
135
+ if (y = 0, t) op = [op[0] & 2, t.value];
136
+ switch (op[0]) {
137
+ case 0: case 1: t = op; break;
138
+ case 4: _.label++; return { value: op[1], done: false };
139
+ case 5: _.label++; y = op[1]; op = [0]; continue;
140
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
141
+ default:
142
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
143
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
144
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
145
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
146
+ if (t[2]) _.ops.pop();
147
+ _.trys.pop(); continue;
148
+ }
149
+ op = body.call(thisArg, _);
150
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
151
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
152
+ }
153
+ }
154
+
155
+ function __values(o) {
156
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
157
+ if (m) return m.call(o);
158
+ if (o && typeof o.length === "number") return {
159
+ next: function () {
160
+ if (o && i >= o.length) o = void 0;
161
+ return { value: o && o[i++], done: !o };
162
+ }
163
+ };
164
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
165
+ }
166
+
167
+ function __read(o, n) {
168
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
169
+ if (!m) return o;
170
+ var i = m.call(o), r, ar = [], e;
171
+ try {
172
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
173
+ }
174
+ catch (error) { e = { error: error }; }
175
+ finally {
176
+ try {
177
+ if (r && !r.done && (m = i["return"])) m.call(i);
178
+ }
179
+ finally { if (e) throw e.error; }
180
+ }
181
+ return ar;
182
+ }
183
+
184
+ function __spreadArray(to, from, pack) {
185
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
186
+ if (ar || !(i in from)) {
187
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
188
+ ar[i] = from[i];
189
+ }
190
+ }
191
+ return to.concat(ar || Array.prototype.slice.call(from));
192
+ }
193
+
194
+ // https://stackoverflow.com/a/2117523
195
+ function uuidv4() {
196
+ // @ts-ignore
197
+ return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
198
+ return (c ^
199
+ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16);
200
+ });
201
+ }
202
+ function triggerLogin(appId, authorizeEndpoint, redirectUri) {
203
+ return __awaiter(this, void 0, void 0, function () {
204
+ function sha256(text) {
205
+ return __awaiter(this, void 0, void 0, function () {
206
+ var encoder, data, hashBuffer, hashArray, hashHex;
207
+ return __generator(this, function (_a) {
208
+ switch (_a.label) {
209
+ case 0:
210
+ encoder = new TextEncoder();
211
+ data = encoder.encode(text);
212
+ return [4 /*yield*/, crypto.subtle.digest("SHA-256", data)];
213
+ case 1:
214
+ hashBuffer = _a.sent();
215
+ hashArray = Array.from(new Uint8Array(hashBuffer));
216
+ hashHex = hashArray
217
+ .map(function (b) { return b.toString(16).padStart(2, "0"); })
218
+ .join("");
219
+ return [2 /*return*/, hashHex];
220
+ }
221
+ });
222
+ });
223
+ }
224
+ var continueTo, state, code_verifier, code_challenge, params, url;
225
+ return __generator(this, function (_a) {
226
+ switch (_a.label) {
227
+ case 0:
228
+ continueTo = window.location.href;
229
+ state = JSON.stringify({ continueTo: continueTo });
230
+ code_verifier = uuidv4();
231
+ localStorage.setItem("code_verifier", code_verifier);
232
+ return [4 /*yield*/, sha256(code_verifier)];
233
+ case 1:
234
+ code_challenge = _a.sent();
235
+ params = new URLSearchParams();
236
+ params.set("client_id", appId);
237
+ params.set("state", state);
238
+ params.set("response_type", "code");
239
+ params.set("code_challenge", code_challenge);
240
+ params.set("code_challenge_method", "S256");
241
+ if (redirectUri) {
242
+ params.set("redirect_uri", redirectUri);
243
+ }
244
+ url = "".concat(authorizeEndpoint, "?").concat(params.toString());
245
+ window.location.href = url;
246
+ return [2 /*return*/];
247
+ }
248
+ });
249
+ });
250
+ }
251
+ function PlasmicPageGuard(props) {
252
+ var appId = props.appId, authorizeEndpoint = props.authorizeEndpoint, minRole = props.minRole, canTriggerLogin = props.canTriggerLogin, children = props.children;
253
+ var dataSourceCtxValue = dataSourcesContext.usePlasmicDataSourceContext();
254
+ React__default['default'].useEffect(function () {
255
+ if (canTriggerLogin) {
256
+ if (minRole &&
257
+ dataSourceCtxValue &&
258
+ "isUserLoading" in dataSourceCtxValue &&
259
+ !dataSourceCtxValue.isUserLoading &&
260
+ !dataSourceCtxValue.user) {
261
+ triggerLogin(appId, authorizeEndpoint, dataSourceCtxValue.authRedirectUri);
262
+ }
263
+ }
264
+ }, [dataSourceCtxValue, appId, authorizeEndpoint, canTriggerLogin, minRole]);
265
+ function canUserViewPage() {
266
+ if (!minRole) {
267
+ return true;
268
+ }
269
+ if (!dataSourceCtxValue) {
270
+ return false;
271
+ }
272
+ if (!dataSourceCtxValue.user) {
273
+ return false;
274
+ }
275
+ if (!("roleIds" in dataSourceCtxValue.user)) {
276
+ return false;
277
+ }
278
+ if (!Array.isArray(dataSourceCtxValue.user.roleIds)) {
279
+ return false;
280
+ }
281
+ return dataSourceCtxValue.user.roleIds.includes(minRole);
282
+ }
283
+ if (!dataSourceCtxValue ||
284
+ dataSourceCtxValue.isUserLoading ||
285
+ (!dataSourceCtxValue.user && minRole && canTriggerLogin)) {
286
+ return null;
287
+ }
288
+ if (!canUserViewPage()) {
289
+ return React__default['default'].createElement("div", null, "You don't have access to this page");
290
+ }
291
+ return React__default['default'].createElement(React__default['default'].Fragment, null, children);
292
+ }
293
+ function withPlasmicPageGuard(WrappedComponent, options) {
294
+ var PageGuard = function (props) { return (React__default['default'].createElement(PlasmicPageGuard, __assign({}, options),
295
+ React__default['default'].createElement(WrappedComponent, __assign({}, props)))); };
296
+ return PageGuard;
297
+ }
298
+
299
+ function notNil(x) {
300
+ return x != null;
301
+ }
302
+ function pick(obj) {
303
+ var e_1, _a;
304
+ var keys = [];
305
+ for (var _i = 1; _i < arguments.length; _i++) {
306
+ keys[_i - 1] = arguments[_i];
307
+ }
308
+ if (Object.keys(obj).length === 0) {
309
+ return obj;
310
+ }
311
+ var res = {};
312
+ try {
313
+ for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
314
+ var key = keys_1_1.value;
315
+ if (key in obj) {
316
+ res[key] = obj[key];
317
+ }
318
+ }
319
+ }
320
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
321
+ finally {
322
+ try {
323
+ if (keys_1_1 && !keys_1_1.done && (_a = keys_1["return"])) _a.call(keys_1);
324
+ }
325
+ finally { if (e_1) throw e_1.error; }
326
+ }
327
+ return res;
328
+ }
329
+ function pickBy(obj, func) {
330
+ var e_2, _a;
331
+ var res = {};
332
+ try {
333
+ for (var _b = __values(Object.entries(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
334
+ var _d = __read(_c.value, 2), key = _d[0], val = _d[1];
335
+ if (func(key, val)) {
336
+ res[key] = obj[key];
337
+ }
338
+ }
339
+ }
340
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
341
+ finally {
342
+ try {
343
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
344
+ }
345
+ finally { if (e_2) throw e_2.error; }
346
+ }
347
+ return res;
348
+ }
349
+ function omit(obj) {
350
+ var e_3, _a;
351
+ var keys = [];
352
+ for (var _i = 1; _i < arguments.length; _i++) {
353
+ keys[_i - 1] = arguments[_i];
354
+ }
355
+ if (Object.keys(obj).length === 0) {
356
+ return obj;
357
+ }
358
+ var res = {};
359
+ try {
360
+ for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
361
+ var key = _c.value;
362
+ if (!keys.includes(key)) {
363
+ res[key] = obj[key];
364
+ }
365
+ }
366
+ }
367
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
368
+ finally {
369
+ try {
370
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
371
+ }
372
+ finally { if (e_3) throw e_3.error; }
373
+ }
374
+ return res;
375
+ }
376
+ function isSubset(a1, a2) {
377
+ return a1.every(function (x) { return a2.includes(x); });
378
+ }
379
+ function chainSingleArgFuncs() {
380
+ var funcs = [];
381
+ for (var _i = 0; _i < arguments.length; _i++) {
382
+ funcs[_i] = arguments[_i];
383
+ }
384
+ if (funcs.length === 0) {
385
+ return undefined;
386
+ }
387
+ return function (arg) {
388
+ var e_4, _a;
389
+ var res = arg;
390
+ try {
391
+ for (var funcs_1 = __values(funcs), funcs_1_1 = funcs_1.next(); !funcs_1_1.done; funcs_1_1 = funcs_1.next()) {
392
+ var func = funcs_1_1.value;
393
+ res = func(res);
394
+ }
395
+ }
396
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
397
+ finally {
398
+ try {
399
+ if (funcs_1_1 && !funcs_1_1.done && (_a = funcs_1["return"])) _a.call(funcs_1);
400
+ }
401
+ finally { if (e_4) throw e_4.error; }
402
+ }
403
+ return res;
404
+ };
405
+ }
406
+ function ensure(x) {
407
+ if (x === null || x === undefined) {
408
+ debugger;
409
+ throw new Error("Value must not be undefined or null");
410
+ }
411
+ else {
412
+ return x;
413
+ }
414
+ }
415
+ function isString(x) {
416
+ return typeof x === "string";
417
+ }
418
+ function groupBy(collection, keyFunc) {
419
+ var e_5, _a;
420
+ var result = {};
421
+ try {
422
+ for (var collection_1 = __values(collection), collection_1_1 = collection_1.next(); !collection_1_1.done; collection_1_1 = collection_1.next()) {
423
+ var obj = collection_1_1.value;
424
+ var key = keyFunc(obj);
425
+ if (key in result) {
426
+ result[key].push(obj);
427
+ }
428
+ else {
429
+ result[key] = [obj];
430
+ }
431
+ }
432
+ }
433
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
434
+ finally {
435
+ try {
436
+ if (collection_1_1 && !collection_1_1.done && (_a = collection_1["return"])) _a.call(collection_1);
437
+ }
438
+ finally { if (e_5) throw e_5.error; }
439
+ }
440
+ return result;
441
+ }
442
+ function mapValues(obj, mapper) {
443
+ var result = {};
444
+ for (var key in obj) {
445
+ result[key] = mapper(obj[key]);
446
+ }
447
+ return result;
448
+ }
449
+
450
+ var isBrowser = typeof window !== "undefined";
451
+ var NONE = Symbol("NONE");
452
+ var useIsomorphicLayoutEffect$1 = isBrowser
453
+ ? React__default['default'].useLayoutEffect
454
+ : React__default['default'].useEffect;
455
+ function createElementWithChildren(elementType, props, children) {
456
+ if (Array.isArray(children)) {
457
+ return React__default['default'].createElement.apply(React__default['default'], __spreadArray([elementType,
458
+ props], __read(children), false));
459
+ }
460
+ else if (children || "children" in props) {
461
+ // Only call React.createElement with `children` if there are actual children,
462
+ // or if there was an explicit (albeit undefined) children passed via
463
+ // props. Otherwise, if you pass `undefined` as the children argument
464
+ // to React.createElement, the created element will have prop {children: undefined}.
465
+ // If the `root` is an PlasmicGeneratedComponent, and these props with {children: undefined}
466
+ // are used, then it will be taken as a `children` override, and will thus blank out
467
+ // everything under the root node.
468
+ return React__default['default'].createElement(elementType, props, children);
469
+ }
470
+ else {
471
+ return React__default['default'].createElement(elementType, props);
472
+ }
473
+ }
474
+ function ensureNotArray(children) {
475
+ if (Array.isArray(children)) {
476
+ if (children.length === 1) {
477
+ return children[0];
478
+ }
479
+ else {
480
+ return React__default['default'].createElement.apply(React__default['default'], __spreadArray([React__default['default'].Fragment, {}], __read(children), false));
481
+ }
482
+ }
483
+ else {
484
+ return children;
485
+ }
486
+ }
487
+ /**
488
+ * Flattens ReactNode into an array of ReactChild, but does NOT replace
489
+ * missing keys with array index, as React.Children.toArray() does.
490
+ */
491
+ function toChildArray(children) {
492
+ if (isReactChild(children)) {
493
+ return [children];
494
+ }
495
+ else if (Array.isArray(children)) {
496
+ return children.flatMap(toChildArray);
497
+ }
498
+ else {
499
+ return [];
500
+ }
501
+ }
502
+ function isReactText(child) {
503
+ return typeof child === "string" || typeof child === "number";
504
+ }
505
+ function isReactChild(child) {
506
+ return React__default['default'].isValidElement(child) || isReactText(child);
507
+ }
508
+ function isReactNode(x) {
509
+ return (typeof x === "string" || typeof x === "number" || React__default['default'].isValidElement(x));
510
+ }
511
+ function mergeProps(props) {
512
+ var e_1, _a, e_2, _b;
513
+ var restProps = [];
514
+ for (var _i = 1; _i < arguments.length; _i++) {
515
+ restProps[_i - 1] = arguments[_i];
516
+ }
517
+ if (restProps.every(function (rest) { return Object.keys(rest).length === 0; })) {
518
+ return props;
519
+ }
520
+ var result = __assign({}, props);
521
+ try {
522
+ for (var restProps_1 = __values(restProps), restProps_1_1 = restProps_1.next(); !restProps_1_1.done; restProps_1_1 = restProps_1.next()) {
523
+ var rest = restProps_1_1.value;
524
+ try {
525
+ for (var _c = (e_2 = void 0, __values(Object.keys(rest))), _d = _c.next(); !_d.done; _d = _c.next()) {
526
+ var key = _d.value;
527
+ result[key] = mergePropVals(key, result[key], rest[key]);
528
+ }
529
+ }
530
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
531
+ finally {
532
+ try {
533
+ if (_d && !_d.done && (_b = _c["return"])) _b.call(_c);
534
+ }
535
+ finally { if (e_2) throw e_2.error; }
536
+ }
537
+ }
538
+ }
539
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
540
+ finally {
541
+ try {
542
+ if (restProps_1_1 && !restProps_1_1.done && (_a = restProps_1["return"])) _a.call(restProps_1);
543
+ }
544
+ finally { if (e_1) throw e_1.error; }
545
+ }
546
+ return result;
547
+ }
548
+ function updateRef(ref, value) {
549
+ if (!ref) {
550
+ return;
551
+ }
552
+ if (typeof ref === "function") {
553
+ ref(value);
554
+ }
555
+ else {
556
+ if (!Object.isFrozen(ref)) {
557
+ ref.current = value;
558
+ }
559
+ }
560
+ }
561
+ function mergeRefs() {
562
+ var refs = [];
563
+ for (var _i = 0; _i < arguments.length; _i++) {
564
+ refs[_i] = arguments[_i];
565
+ }
566
+ return function (value) {
567
+ var e_3, _a;
568
+ try {
569
+ for (var refs_1 = __values(refs), refs_1_1 = refs_1.next(); !refs_1_1.done; refs_1_1 = refs_1.next()) {
570
+ var ref = refs_1_1.value;
571
+ updateRef(ref, value);
572
+ }
573
+ }
574
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
575
+ finally {
576
+ try {
577
+ if (refs_1_1 && !refs_1_1.done && (_a = refs_1["return"])) _a.call(refs_1);
578
+ }
579
+ finally { if (e_3) throw e_3.error; }
580
+ }
581
+ };
582
+ }
583
+ function mergePropVals(name, val1, val2) {
584
+ if (val1 === NONE || val2 === NONE) {
585
+ // The NONE sentinel always skips all merging and returns null
586
+ return null;
587
+ }
588
+ else if (val1 == null) {
589
+ // If either of them is nil, prefer the other
590
+ return val2;
591
+ }
592
+ else if (val2 == null) {
593
+ return val1;
594
+ }
595
+ else if (name === "className") {
596
+ // Special case for className -- always combine both class names
597
+ return classNames__default['default'](val1, val2);
598
+ }
599
+ else if (name === "style") {
600
+ // Special case for style -- always shallow-merge style dicts
601
+ return __assign(__assign({}, val1), val2);
602
+ }
603
+ else if (name === "ref") {
604
+ // Special case for ref
605
+ return mergeRefs(val1, val2);
606
+ }
607
+ else if (typeof val1 !== typeof val2) {
608
+ // If the type of the two values are different, then no way to merge them.
609
+ // Prefer val2.
610
+ return val2;
611
+ }
612
+ else if (name.startsWith("on") && typeof val1 === "function") {
613
+ // Special case for event handlers -- always call both handlers
614
+ return function () {
615
+ var args = [];
616
+ for (var _i = 0; _i < arguments.length; _i++) {
617
+ args[_i] = arguments[_i];
618
+ }
619
+ var res;
620
+ if (typeof val1 === "function") {
621
+ res = val1.apply(void 0, __spreadArray([], __read(args), false));
622
+ }
623
+ if (typeof val2 === "function") {
624
+ res = val2.apply(void 0, __spreadArray([], __read(args), false));
625
+ }
626
+ return res;
627
+ };
628
+ }
629
+ else {
630
+ // For all else, prefer val2
631
+ return val2;
632
+ }
633
+ }
634
+ function getElementTypeName(element) {
635
+ var _a, _b, _c, _d;
636
+ if (typeof element.type === "string") {
637
+ return element.type;
638
+ }
639
+ else {
640
+ var comp = element.type;
641
+ return (_d = (_b = (_a = comp.displayName) !== null && _a !== void 0 ? _a : comp.name) !== null && _b !== void 0 ? _b : (_c = comp.render) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "Component";
642
+ }
643
+ }
644
+
645
+ function renderStack(as, props, hasGap, ref) {
646
+ var children = props.children, rest = __rest(props, ["children"]);
647
+ var wrappedChildren = wrapFlexContainerChildren(children, hasGap !== null && hasGap !== void 0 ? hasGap : false);
648
+ return createElementWithChildren(as, __assign({ ref: ref }, rest), wrappedChildren);
649
+ }
650
+ function FlexStack_(props, outerRef) {
651
+ var as = props.as, hasGap = props.hasGap, rest = __rest(props, ["as", "hasGap"]);
652
+ return renderStack(as !== null && as !== void 0 ? as : "div", rest, hasGap, outerRef);
653
+ }
654
+ var FlexStack = React__namespace.forwardRef(FlexStack_);
655
+ var makeStackImpl = function (as) {
656
+ return React__namespace.forwardRef(function (props, ref) {
657
+ var hasGap = props.hasGap, rest = __rest(props, ["hasGap"]);
658
+ return renderStack(as, rest, hasGap, ref);
659
+ });
660
+ };
661
+ var Stack = Object.assign(FlexStack, {
662
+ div: makeStackImpl("div"),
663
+ a: makeStackImpl("a"),
664
+ button: makeStackImpl("button"),
665
+ h1: makeStackImpl("h1"),
666
+ h2: makeStackImpl("h2"),
667
+ h3: makeStackImpl("h3"),
668
+ h4: makeStackImpl("h4"),
669
+ h5: makeStackImpl("h5"),
670
+ h6: makeStackImpl("h6"),
671
+ label: makeStackImpl("label"),
672
+ form: makeStackImpl("form"),
673
+ section: makeStackImpl("section"),
674
+ head: makeStackImpl("head"),
675
+ main: makeStackImpl("main"),
676
+ nav: makeStackImpl("nav")
677
+ });
678
+
679
+ function hasVariant(variants, groupName, variant) {
680
+ if (variants == null) {
681
+ return false;
682
+ }
683
+ var groupVariants = variants[groupName];
684
+ if (groupVariants == null) {
685
+ return false;
686
+ }
687
+ else if (groupVariants === true) {
688
+ return variant === groupName;
689
+ }
690
+ else if (groupVariants === false) {
691
+ return false;
692
+ }
693
+ else if (Array.isArray(groupVariants)) {
694
+ return groupVariants.includes(variant);
695
+ }
696
+ else if (typeof groupVariants === "string") {
697
+ return groupVariants === variant;
698
+ }
699
+ else {
700
+ return (groupVariants[variant] !== undefined && groupVariants[variant] !== false);
701
+ }
702
+ }
703
+ function wrapFlexContainerChildren(children, hasGap) {
704
+ // We need to always wrap the children, even if there are no gaps, because
705
+ // otherwise if we toggle between with and without gap, React reconciliation
706
+ // will blow away the children tree and all state if we switch from having
707
+ // a wrapper and not.
708
+ var className = hasGap ? "__wab_flex-container" : "__wab_passthrough";
709
+ if (!children) {
710
+ return null;
711
+ }
712
+ else if (Array.isArray(children)) {
713
+ return React__namespace.createElement.apply(React__namespace, __spreadArray(["div", { className: className }], __read(children), false));
714
+ }
715
+ else {
716
+ return React__namespace.createElement("div", { className: className }, children);
717
+ }
718
+ }
719
+ function createPlasmicElement(override, defaultRoot, defaultProps, wrapChildrenInFlex) {
720
+ if (!override || Object.keys(override).length === 0) {
721
+ return createElementWithChildren(defaultRoot, defaultProps, defaultProps.children);
722
+ }
723
+ var override2 = deriveOverride(override);
724
+ var props = mergeOverrideProps(defaultProps, override2.props);
725
+ if (override2.type === "render") {
726
+ return override2.render(props, defaultRoot);
727
+ }
728
+ var root = defaultRoot;
729
+ if (override2.type === "as" && override2.as) {
730
+ if (defaultRoot === Stack) {
731
+ // If there was an "as" override specified, but the default type is
732
+ // a Stack, then we don't want to switch to using "as" as the root,
733
+ // because then we'd lose the flex wrapper that Stack provides.
734
+ // Instead, we specify the "as" as the "as" prop to Stack.
735
+ props.as = override2.as;
736
+ }
737
+ else {
738
+ root = override2.as;
739
+ }
740
+ }
741
+ var children = props.children;
742
+ if (override2.wrapChildren) {
743
+ children = override2.wrapChildren(ensureNotArray(children));
744
+ }
745
+ if (wrapChildrenInFlex) {
746
+ // For legacy, we still support data-plasmic-wrap-flex-children
747
+ children = wrapFlexContainerChildren(children, true);
748
+ }
749
+ var result = createElementWithChildren(root, props, children);
750
+ if (override2.wrap) {
751
+ result = override2.wrap(result);
752
+ }
753
+ return result;
754
+ }
755
+ // We use data-plasmic-XXX attributes for custom properties since Typescript doesn't
756
+ // support type check on jsx pragma. See https://github.com/microsoft/TypeScript/issues/21699
757
+ // for more info.
758
+ var seenElements = new Map();
759
+ function createPlasmicElementProxy(defaultElement, props) {
760
+ // We use seenElements to keep track of elements that has been rendered by
761
+ // createPlasmicElementProxy(). When a JSX tree is evaluated, the JSX factory
762
+ // is invoked from the leaf to the root as the last call. So we can store
763
+ // all the elements we've created until we encounter the leaf, at which point
764
+ // we will clear this map. We are guaranteed that this map will only contain
765
+ // elements from one Plasmic* component at a time, because we're just creating
766
+ // elements and not "rendering" at this point; even if this JSX tree references
767
+ // other Plasmic* elements, we'll just create an element referencing that component,
768
+ // rather than following into the content of that component.
769
+ //
770
+ // TODO: is this ConcurrentMode friendly?
771
+ var _a;
772
+ var children = [];
773
+ for (var _i = 2; _i < arguments.length; _i++) {
774
+ children[_i - 2] = arguments[_i];
775
+ }
776
+ if (props == null) {
777
+ props = {};
778
+ }
779
+ var name = props["data-plasmic-name"];
780
+ var isRoot = props["data-plasmic-root"];
781
+ var forNodeName = props["data-plasmic-for-node"];
782
+ delete props["data-plasmic-name"];
783
+ delete props["data-plasmic-root"];
784
+ delete props["data-plasmic-for-node"];
785
+ var element = createPlasmicElementFromJsx.apply(void 0, __spreadArray([defaultElement,
786
+ props], __read(children), false));
787
+ if (name) {
788
+ seenElements.set(name, element);
789
+ }
790
+ if (isRoot) {
791
+ // If this is the root, and we requested a specific node by specifying data-plasmic-for-node,
792
+ // then return that node instead
793
+ var forNode = forNodeName
794
+ ? (_a = seenElements.get(forNodeName)) !== null && _a !== void 0 ? _a : null
795
+ : element;
796
+ // Clear out the seenElements map, as we're done rendering this Plasmic* component.
797
+ seenElements.clear();
798
+ return forNode;
799
+ }
800
+ return element;
801
+ }
802
+ function createPlasmicElementFromJsx(defaultElement, props) {
803
+ var _a;
804
+ var children = [];
805
+ for (var _i = 2; _i < arguments.length; _i++) {
806
+ children[_i - 2] = arguments[_i];
807
+ }
808
+ var override = props["data-plasmic-override"];
809
+ var wrapFlexChild = props["data-plasmic-wrap-flex-child"];
810
+ var triggerProps = ((_a = props["data-plasmic-trigger-props"]) !== null && _a !== void 0 ? _a : []);
811
+ delete props["data-plasmic-override"];
812
+ delete props["data-plasmic-wrap-flex-child"];
813
+ delete props["data-plasmic-trigger-props"];
814
+ return createPlasmicElement(override, defaultElement, mergeProps.apply(void 0, __spreadArray([props,
815
+ children.length === 0
816
+ ? {}
817
+ : { children: children.length === 1 ? children[0] : children }], __read(triggerProps), false)), wrapFlexChild);
818
+ }
819
+ function makeFragment() {
820
+ var children = [];
821
+ for (var _i = 0; _i < arguments.length; _i++) {
822
+ children[_i] = arguments[_i];
823
+ }
824
+ return React__namespace.createElement.apply(React__namespace, __spreadArray([React__namespace.Fragment, {}], __read(children), false));
825
+ }
826
+ var UNSET = Symbol("UNSET");
827
+ function mergeOverrideProps(defaults, overrides) {
828
+ var e_1, _a;
829
+ if (!overrides) {
830
+ return defaults;
831
+ }
832
+ var result = __assign({}, defaults);
833
+ try {
834
+ for (var _b = __values(Object.keys(overrides)), _c = _b.next(); !_c.done; _c = _b.next()) {
835
+ var key = _c.value;
836
+ var defaultVal = defaults[key];
837
+ var overrideVal = overrides[key];
838
+ if (overrideVal === UNSET) {
839
+ delete result[key];
840
+ }
841
+ else {
842
+ // We use the NONE sentinel if the overrideVal is nil, and is not one of the
843
+ // props that we merge by default -- which are className, style, and
844
+ // event handlers. This means for all other "normal" props -- like children,
845
+ // title, etc -- a nil value will unset the default.
846
+ if (overrideVal == null &&
847
+ key !== "className" &&
848
+ key !== "style" &&
849
+ !(key.startsWith("on") && typeof defaultVal === "function")) {
850
+ overrideVal = NONE;
851
+ }
852
+ result[key] = mergePropVals(key, defaultVal, overrideVal);
853
+ }
854
+ }
855
+ }
856
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
857
+ finally {
858
+ try {
859
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
860
+ }
861
+ finally { if (e_1) throw e_1.error; }
862
+ }
863
+ return result;
864
+ }
865
+ function wrapWithClassName(element, className) {
866
+ var key = React__namespace.isValidElement(element)
867
+ ? element.key || undefined
868
+ : undefined;
869
+ return React__namespace.createElement("div", {
870
+ key: key,
871
+ className: className,
872
+ style: {
873
+ display: "grid"
874
+ }
875
+ }, element);
876
+ }
877
+ function deriveOverride(x) {
878
+ if (!x) {
879
+ // undefined Binding is an empty Binding
880
+ return {
881
+ type: "default",
882
+ props: {}
883
+ };
884
+ }
885
+ else if (isReactNode(x)) {
886
+ // If ReactNode, then assume this is the children
887
+ return {
888
+ type: "default",
889
+ props: {
890
+ children: x
891
+ }
892
+ };
893
+ }
894
+ else if (typeof x === "object") {
895
+ // If any of the overrideKeys is a key of this object, then assume
896
+ // this is a full Override
897
+ if ("as" in x) {
898
+ return __assign(__assign({}, x), { props: x.props || {}, type: "as" });
899
+ }
900
+ else if ("render" in x) {
901
+ return __assign(__assign({}, x), { type: "render" });
902
+ }
903
+ else if ("props" in x) {
904
+ return __assign(__assign({}, x), { props: x.props || {}, type: "default" });
905
+ }
906
+ else if (isSubset(Object.keys(x), ["wrap", "wrapChildren"])) {
907
+ // Only twiddling functions present, so assume no props overrides
908
+ // (otherwise we'd assume these were props).
909
+ return __assign(__assign({}, x), { props: {}, type: "default" });
910
+ }
911
+ // Else, assume this is just a props object.
912
+ return {
913
+ type: "default",
914
+ props: x
915
+ };
916
+ }
917
+ else if (typeof x === "function") {
918
+ return {
919
+ type: "render",
920
+ render: x
921
+ };
922
+ }
923
+ throw new Error("Unexpected override: ".concat(x));
924
+ }
925
+ function mergeVariants(v1, v2) {
926
+ if (!v1 || !v2) {
927
+ return v1 || v2 || {};
928
+ }
929
+ return __assign(__assign({}, v1), v2);
930
+ }
931
+ function mergeVariantsWithStates(variants, $state, linkedStates) {
932
+ return __assign(__assign({}, variants), Object.fromEntries(linkedStates.map(function (_a) {
933
+ var variantGroup = _a.variantGroup, statePath = _a.statePath;
934
+ return [
935
+ variantGroup,
936
+ get__default['default']($state, statePath),
937
+ ];
938
+ })));
939
+ }
940
+ function mergeArgs(a1, a2) {
941
+ if (!a1 || !a2) {
942
+ return a1 || a2 || {};
943
+ }
944
+ return __assign(__assign({}, a1), a2);
945
+ }
946
+ function mergeFlexOverrides(o1, o2) {
947
+ var e_2, _a;
948
+ if (!o2) {
949
+ return o1;
950
+ }
951
+ var keys = Array.from(new Set(__spreadArray(__spreadArray([], __read(Object.keys(o1)), false), __read(Object.keys(o2)), false)));
952
+ var merged = {};
953
+ try {
954
+ for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
955
+ var key = keys_1_1.value;
956
+ merged[key] = mergeFlexOverride(o1[key], o2[key]);
957
+ }
958
+ }
959
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
960
+ finally {
961
+ try {
962
+ if (keys_1_1 && !keys_1_1.done && (_a = keys_1["return"])) _a.call(keys_1);
963
+ }
964
+ finally { if (e_2) throw e_2.error; }
965
+ }
966
+ return merged;
967
+ }
968
+ function mergeFlexOverride(fo1, fo2) {
969
+ var _a, _b;
970
+ if (!fo1) {
971
+ return fo2;
972
+ }
973
+ if (!fo2) {
974
+ return fo1;
975
+ }
976
+ var o1 = deriveOverride(fo1);
977
+ var o2 = deriveOverride(fo2);
978
+ var wrap = chainSingleArgFuncs.apply(void 0, __spreadArray([], __read([o1.wrap, o2.wrap].filter(notNil)), false));
979
+ var wrapChildren = chainSingleArgFuncs.apply(void 0, __spreadArray([], __read([o1.wrapChildren, o2.wrapChildren].filter(notNil)), false));
980
+ // "render" type always takes precedence, but we still merge the props
981
+ var props = mergeOverrideProps((_a = o1.props) !== null && _a !== void 0 ? _a : {}, o2.props);
982
+ if (o2.type === "render") {
983
+ return {
984
+ render: o2.render,
985
+ props: props,
986
+ wrap: wrap,
987
+ wrapChildren: wrapChildren
988
+ };
989
+ }
990
+ if (o1.type === "render") {
991
+ return {
992
+ render: o1.render,
993
+ props: props,
994
+ wrap: wrap,
995
+ wrapChildren: wrapChildren
996
+ };
997
+ }
998
+ // "as" will take precedence
999
+ var as = (_b = (o2.type === "as" ? o2.as : undefined)) !== null && _b !== void 0 ? _b : (o1.type === "as" ? o1.as : undefined);
1000
+ return __assign({ props: props, wrap: wrap, wrapChildren: wrapChildren }, (as ? { as: as } : {}));
1001
+ }
1002
+ function deriveRenderOpts(props, config) {
1003
+ var _a;
1004
+ var name = config.name, descendantNames = config.descendantNames, internalVariantPropNames = config.internalVariantPropNames, internalArgPropNames = config.internalArgPropNames;
1005
+ var reservedPropNames = ["variants", "args", "overrides"];
1006
+ var variants = mergeVariants(omit.apply(void 0, __spreadArray([pick.apply(void 0, __spreadArray([props], __read(internalVariantPropNames), false))], __read(reservedPropNames), false)), props.variants);
1007
+ var args = mergeArgs(omit.apply(void 0, __spreadArray([pick.apply(void 0, __spreadArray([props], __read(internalArgPropNames), false))], __read(reservedPropNames), false)), props.args);
1008
+ var overrides = mergeFlexOverrides(omit.apply(void 0, __spreadArray(__spreadArray(__spreadArray([pick.apply(void 0, __spreadArray([props], __read(descendantNames), false))], __read(internalArgPropNames), false), __read(internalVariantPropNames), false), __read(reservedPropNames), false)), props.overrides);
1009
+ var leftoverProps = omit.apply(void 0, __spreadArray(__spreadArray(__spreadArray([props,
1010
+ "variants",
1011
+ "args",
1012
+ "overrides"], __read(descendantNames), false), __read(internalVariantPropNames), false), __read(internalArgPropNames), false));
1013
+ if (Object.keys(leftoverProps).length > 0) {
1014
+ overrides = mergeFlexOverrides(overrides, (_a = {},
1015
+ _a[name] = {
1016
+ props: leftoverProps
1017
+ },
1018
+ _a));
1019
+ }
1020
+ return { variants: variants, args: args, overrides: overrides };
1021
+ }
1022
+
1023
+ var isDefaultValue = function (val) { return val === "PLEASE_RENDER_INSIDE_PROVIDER"; };
1024
+ var seenDefaultVariants = {};
1025
+ function ensureGlobalVariants(globalVariantValues) {
1026
+ Object.entries(globalVariantValues)
1027
+ .filter(function (_a) {
1028
+ var _b = __read(_a, 2); _b[0]; var value = _b[1];
1029
+ return isDefaultValue(value);
1030
+ })
1031
+ .forEach(function (_a) {
1032
+ var _b = __read(_a, 2), key = _b[0]; _b[1];
1033
+ globalVariantValues[key] = undefined;
1034
+ if (!seenDefaultVariants[key] && process.env.NODE_ENV === "development") {
1035
+ seenDefaultVariants[key] = true;
1036
+ var providerName = "".concat(key[0].toUpperCase()).concat(key.substring(1), "Context.Provider");
1037
+ console.warn("Plasmic context value for global variant \"".concat(key, "\" was not provided; please use ").concat(providerName, " at the root of your React app. Learn More: https://www.plasmic.app/learn/other-assets/#global-variants"));
1038
+ }
1039
+ });
1040
+ return globalVariantValues;
1041
+ }
1042
+
1043
+ var PlasmicHeadContext = React__namespace.createContext(undefined);
1044
+ function PlasmicHead(props) {
1045
+ var Head = React__namespace.useContext(PlasmicHeadContext);
1046
+ if (!Head) {
1047
+ console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.");
1048
+ // TODO: Link to doc about Head.
1049
+ return null;
1050
+ }
1051
+ // Helmet does not support React.Fragments, so we need to use `[<meta />,
1052
+ // <meta />]` instead of `<><meta /><meta /></>`.
1053
+ return (React__namespace.createElement(Head, null,
1054
+ props.image ? ([
1055
+ React__namespace.createElement("meta", { key: "twitter:card", name: "twitter:card", content: "summary_large_image" }),
1056
+ React__namespace.createElement("meta", { key: "og:image", property: "og:image", content: props.image }),
1057
+ React__namespace.createElement("meta", { key: "twitter:image", name: "twitter:image", content: props.image }),
1058
+ ]) : (React__namespace.createElement("meta", { key: "twitter:card", name: "twitter:card", content: "summary" })),
1059
+ props.title && [
1060
+ React__namespace.createElement("title", { key: "title" }, props.title),
1061
+ React__namespace.createElement("meta", { key: "og:title", property: "og:title", content: props.title }),
1062
+ React__namespace.createElement("meta", { key: "twitter:title", property: "twitter:title", content: props.title }),
1063
+ ],
1064
+ props.description && [
1065
+ React__namespace.createElement("meta", { key: "description", name: "description", content: props.description }),
1066
+ React__namespace.createElement("meta", { key: "og:description", property: "og:description", content: props.description }),
1067
+ React__namespace.createElement("meta", { key: "twitter:description", name: "twitter:description", content: props.description }),
1068
+ ],
1069
+ props.canonical && (React__namespace.createElement("link", { key: "canonical", ref: "canonical", href: props.canonical }))));
1070
+ }
1071
+ var plasmicHeadMeta = {
1072
+ name: "hostless-plasmic-head",
1073
+ displayName: "Head",
1074
+ description: "Used to add page metadata to HTML <head />.",
1075
+ importName: "PlasmicHead",
1076
+ importPath: "@plasmicapp/react-web",
1077
+ isRepeatable: false,
1078
+ styleSections: false,
1079
+ props: {
1080
+ title: {
1081
+ type: "string",
1082
+ displayName: "Title"
1083
+ },
1084
+ description: {
1085
+ type: "string",
1086
+ displayName: "Description"
1087
+ },
1088
+ image: {
1089
+ type: "imageUrl",
1090
+ displayName: "Image"
1091
+ },
1092
+ canonical: {
1093
+ type: "string",
1094
+ displayName: "Canonical URL"
1095
+ }
1096
+ }
1097
+ };
1098
+
1099
+ function PlasmicIcon(props) {
1100
+ var PlasmicIconType = props.PlasmicIconType, rest = __rest(props, ["PlasmicIconType"]);
1101
+ return React__namespace.createElement(PlasmicIconType, __assign({}, rest));
1102
+ }
1103
+
1104
+ /**
1105
+ * Responsive `<img/>` replacement, based on `next/image`
1106
+ */
1107
+ // Default image sizes to snap to
1108
+ // TODO: make this configurable?
1109
+ var IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
1110
+ var DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
1111
+ var ALL_SIZES = __spreadArray(__spreadArray([], __read(IMG_SIZES), false), __read(DEVICE_SIZES), false);
1112
+ var PlasmicImg = React__default['default'].forwardRef(function PlasmicImg(props, outerRef) {
1113
+ var src = props.src, className = props.className, displayWidth = props.displayWidth, displayHeight = props.displayHeight, displayMinWidth = props.displayMinWidth, displayMinHeight = props.displayMinHeight, displayMaxWidth = props.displayMaxWidth, displayMaxHeight = props.displayMaxHeight, quality = props.quality, loader = props.loader, imgRef = props.imgRef, style = props.style, loading = props.loading, rest = __rest(props, ["src", "className", "displayWidth", "displayHeight", "displayMinWidth", "displayMinHeight", "displayMaxWidth", "displayMaxHeight", "quality", "loader", "imgRef", "style", "loading"]);
1114
+ var imgProps = Object.assign({}, rest, {
1115
+ // Default loading to "lazy" if not specified (which is different from the
1116
+ // html img, which defaults to eager!)
1117
+ loading: loading !== null && loading !== void 0 ? loading : "lazy"
1118
+ });
1119
+ var _a = typeof src === "string" || !src
1120
+ ? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }
1121
+ : src, fullWidth = _a.fullWidth, fullHeight = _a.fullHeight, aspectRatio = _a.aspectRatio;
1122
+ var srcStr = src
1123
+ ? typeof src === "string"
1124
+ ? src
1125
+ : typeof src.src === "string"
1126
+ ? src.src
1127
+ : src.src.src
1128
+ : "";
1129
+ // Assume external image if either dimension is null and use usual <img>
1130
+ if (fullHeight == null || fullWidth == null) {
1131
+ return (React__default['default'].createElement("img", __assign({ src: srcStr, className: className, style: style }, imgProps, { loading: loading, ref: mergeRefs(imgRef, outerRef) })));
1132
+ }
1133
+ if (isSvg(srcStr) &&
1134
+ (displayHeight == null || displayHeight === "auto") &&
1135
+ (displayWidth == null || displayWidth === "auto")) {
1136
+ displayWidth = "100%";
1137
+ }
1138
+ var computedDisplayWidth = displayWidth;
1139
+ if (fullWidth &&
1140
+ fullHeight &&
1141
+ (!displayWidth || displayWidth === "auto") &&
1142
+ !!getPixelLength(displayHeight)) {
1143
+ // If there's a pixel length specified for displayHeight but not displayWidth,
1144
+ // then we can derive the pixel length for displayWidth. Having an explicit
1145
+ // displayWidth makes this a fixed-size image, which makes it possible for us to
1146
+ // generate better markup!
1147
+ if (!isSvg(srcStr)) {
1148
+ // We shouldn't do it for SVGs though, because `fullWidth` and
1149
+ // `fullHeight` might have rounded values so the final
1150
+ // `displayWidth` could differ by 1px or so.
1151
+ computedDisplayWidth =
1152
+ (getPixelLength(displayHeight) * fullWidth) / fullHeight;
1153
+ }
1154
+ }
1155
+ var spacerWidth = fullWidth;
1156
+ var spacerHeight = fullHeight;
1157
+ if (aspectRatio && isFinite(aspectRatio) && isSvg(srcStr)) {
1158
+ // For SVGs, fullWidth and fullHeight can be rounded values, which would
1159
+ // cause some discrepancy between the actual aspect ratio and the aspect
1160
+ // ratio from those values. So, for those cases, we set large width / height
1161
+ // values to get a more precise ratio from the spacer.
1162
+ spacerWidth = DEFAULT_SVG_WIDTH;
1163
+ spacerHeight = Math.round(spacerWidth / aspectRatio);
1164
+ }
1165
+ var _b = getWidths(computedDisplayWidth, fullWidth, {
1166
+ minWidth: displayMinWidth
1167
+ }), sizes = _b.sizes, widthDescs = _b.widthDescs;
1168
+ var imageLoader = getImageLoader(loader);
1169
+ var spacerSvg = "<svg width=\"".concat(spacerWidth, "\" height=\"").concat(spacerHeight, "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>");
1170
+ var spacerSvgBase64 = typeof window === "undefined"
1171
+ ? Buffer.from(spacerSvg).toString("base64")
1172
+ : window.btoa(spacerSvg);
1173
+ var wrapperStyle = __assign({}, (style || {}));
1174
+ var spacerStyle = __assign({}, pick(style || {}, "objectFit", "objectPosition"));
1175
+ if (displayWidth != null && displayWidth !== "auto") {
1176
+ // If width is set, set it on the wrapper along with min/max width
1177
+ // and just use `width: 100%` on the spacer
1178
+ spacerStyle.width = "100%";
1179
+ // Rely on the styles set by `classname` on the wrapper:
1180
+ // wrapperStyle.width = displayWidth;
1181
+ // wrapperStyle.minWidth = displayMinWidth;
1182
+ // wrapperStyle.maxWidth = displayMaxWidth;
1183
+ }
1184
+ else {
1185
+ // Otherwise, we want auto sizing from the spacer, so set width there.
1186
+ //
1187
+ // But if we have min/max width, it should be set in the wrapper and it
1188
+ // can be percentage values (and we add corresponding min/max width to
1189
+ // 100% in the spacer). In general it ends up with the correct effect,
1190
+ // but some edge cases might make `min-width: 100%` shrink the image more
1191
+ // than it should.
1192
+ spacerStyle.width = displayWidth;
1193
+ wrapperStyle.width = "auto";
1194
+ if (displayMinWidth) {
1195
+ spacerStyle.minWidth = "100%";
1196
+ // Rely on min-width set by `classname` on the wrapper:
1197
+ // wrapperStyle.minWidth = displayMinWidth;
1198
+ }
1199
+ if (displayMaxWidth != null && displayMaxWidth !== "none") {
1200
+ spacerStyle.maxWidth = "100%";
1201
+ // Rely on max-width set by `classname` on the wrapper:
1202
+ // wrapperStyle.maxWidth = displayMaxWidth;
1203
+ }
1204
+ }
1205
+ if (displayHeight != null && displayHeight !== "auto") {
1206
+ spacerStyle.height = "100%";
1207
+ // wrapperStyle.height = displayHeight;
1208
+ // wrapperStyle.minHeight = displayMinHeight;
1209
+ // wrapperStyle.maxHeight = displayMaxHeight;
1210
+ }
1211
+ else {
1212
+ spacerStyle.height = displayHeight;
1213
+ wrapperStyle.height = "auto";
1214
+ if (displayMinHeight) {
1215
+ spacerStyle.minHeight = "100%";
1216
+ // wrapperStyle.minHeight = displayMinHeight;
1217
+ }
1218
+ if (displayMaxHeight != null && displayMaxHeight !== "none") {
1219
+ spacerStyle.maxHeight = "100%";
1220
+ // wrapperStyle.maxHeight = displayMaxHeight;
1221
+ }
1222
+ }
1223
+ return (React__default['default'].createElement("div", { className: classNames__default['default'](className, "__wab_img-wrapper"), ref: outerRef, style: wrapperStyle },
1224
+ React__default['default'].createElement("img", { alt: "", "aria-hidden": true, className: "__wab_img-spacer-svg", src: "data:image/svg+xml;base64,".concat(spacerSvgBase64), style: spacerStyle }),
1225
+ makePicture({
1226
+ imageLoader: imageLoader,
1227
+ widthDescs: widthDescs,
1228
+ sizes: sizes,
1229
+ src: srcStr,
1230
+ quality: quality,
1231
+ ref: imgRef,
1232
+ style: style ? pick(style, "objectFit", "objectPosition") : undefined,
1233
+ imgProps: imgProps,
1234
+ className: "__wab_img"
1235
+ })));
1236
+ });
1237
+ function makePicture(opts) {
1238
+ // If imageLoader is undefined, then this renders to just a normal
1239
+ // <img />. Else it will render to a <picture> with a <source> for
1240
+ // webp, and srcSet/sizes set according to width requirements.
1241
+ var imageLoader = opts.imageLoader, widthDescs = opts.widthDescs, src = opts.src, quality = opts.quality, style = opts.style, className = opts.className, sizes = opts.sizes, imgProps = opts.imgProps, ref = opts.ref;
1242
+ return (React__default['default'].createElement("picture", { className: "__wab_picture" },
1243
+ imageLoader && imageLoader.supportsUrl(src) && (React__default['default'].createElement("source", { type: "image/webp", srcSet: widthDescs
1244
+ .map(function (wd) {
1245
+ return "".concat(imageLoader.transformUrl({
1246
+ src: src,
1247
+ quality: quality,
1248
+ width: wd.width,
1249
+ format: "webp"
1250
+ }), " ").concat(wd.desc);
1251
+ })
1252
+ .join(", ") })),
1253
+ React__default['default'].createElement("img", __assign({}, imgProps, { ref: ref, className: className, decoding: "async", src: imageLoader && imageLoader.supportsUrl(src)
1254
+ ? imageLoader.transformUrl({
1255
+ src: src,
1256
+ quality: quality,
1257
+ width: widthDescs[widthDescs.length - 1].width
1258
+ })
1259
+ : src, srcSet: imageLoader && imageLoader.supportsUrl(src)
1260
+ ? widthDescs
1261
+ .map(function (wd) {
1262
+ return "".concat(imageLoader.transformUrl({
1263
+ src: src,
1264
+ quality: quality,
1265
+ width: wd.width
1266
+ }), " ").concat(wd.desc);
1267
+ })
1268
+ .join(", ")
1269
+ : undefined, sizes: imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined, style: __assign(__assign({}, (style ? pick(style, "objectFit", "objectPosition") : {})), { width: 0, height: 0 }) }))));
1270
+ }
1271
+ var DEFAULT_SVG_WIDTH = 10000;
1272
+ function isSvg(src) {
1273
+ return src.endsWith(".svg") || src.startsWith("data:image/svg");
1274
+ }
1275
+ function getClosestPresetSize(width, fullWidth) {
1276
+ var _a;
1277
+ var nextBiggerIndex = (_a = ALL_SIZES.findIndex(function (w) { return w >= width; })) !== null && _a !== void 0 ? _a : ALL_SIZES.length - 1;
1278
+ var nextBigger = ALL_SIZES[nextBiggerIndex];
1279
+ if (nextBigger >= fullWidth) {
1280
+ // If the requested width is larger than the fullWidth,
1281
+ // we just use the original width instead. It's impossible
1282
+ // to make an image bigger than fullWidth!
1283
+ return undefined;
1284
+ }
1285
+ else if (nextBiggerIndex + 1 < ALL_SIZES.length &&
1286
+ fullWidth <= ALL_SIZES[nextBiggerIndex + 1]) {
1287
+ // If the fullWidth is just between nextBigger and the one after that,
1288
+ // then also might as well just use the original size (so, width is 30,
1289
+ // nextBigger is 32, then we just use the original as long as fullWidth is
1290
+ // less than 48)
1291
+ return undefined;
1292
+ }
1293
+ return nextBigger;
1294
+ }
1295
+ /**
1296
+ * Computes the appropriate srcSet and sizes to use
1297
+ */
1298
+ function getWidths(width, fullWidth, extra) {
1299
+ var minWidth = extra === null || extra === void 0 ? void 0 : extra.minWidth;
1300
+ var pixelWidth = getPixelLength(width);
1301
+ var pixelMinWidth = getPixelLength(minWidth);
1302
+ if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {
1303
+ // If there's an exact width, then we just need to display it at 1x and 2x density
1304
+ return {
1305
+ widthDescs: [
1306
+ {
1307
+ width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth !== null && pixelMinWidth !== void 0 ? pixelMinWidth : 0), fullWidth),
1308
+ desc: "1x"
1309
+ },
1310
+ {
1311
+ width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth !== null && pixelMinWidth !== void 0 ? pixelMinWidth : 0) * 2, fullWidth),
1312
+ desc: "2x"
1313
+ },
1314
+ ],
1315
+ sizes: undefined
1316
+ };
1317
+ }
1318
+ // Otherwise we don't know what sizes we'll end up, so we just cap it at
1319
+ // device width. TODO: do better!
1320
+ var usefulSizes = DEVICE_SIZES.filter(function (size) { return !fullWidth || size < fullWidth; });
1321
+ if (!!fullWidth && usefulSizes.length === 0) {
1322
+ // image fullWidth is smaller than all device sizes. So all we can do
1323
+ // is offer 1x
1324
+ return {
1325
+ widthDescs: [
1326
+ {
1327
+ width: getClosestPresetSize(fullWidth, fullWidth),
1328
+ desc: "1x"
1329
+ },
1330
+ ],
1331
+ sizes: undefined
1332
+ };
1333
+ }
1334
+ return {
1335
+ widthDescs: usefulSizes.map(function (size) { return ({
1336
+ width: getClosestPresetSize(size, fullWidth),
1337
+ // If this is the last (buggest) useful width, but it is
1338
+ // still within the bounds set by DEVICE_SIZES, then just
1339
+ // use the original, unresized image. This means if we match
1340
+ // the largest size, we use unresized and best quality image.
1341
+ // We only do this, though, if fullWidth is "reasonable" --
1342
+ // smaller than the largest size we would consider.
1343
+ // i === usefulSizes.length - 1 &&
1344
+ // fullWidth < DEVICE_SIZES[DEVICE_SIZES.length - 1]
1345
+ // ? undefined
1346
+ // : size,
1347
+ desc: "".concat(size, "w")
1348
+ }); }),
1349
+ sizes: "100vw"
1350
+ };
1351
+ }
1352
+ function getPixelLength(length) {
1353
+ if (length == null || length == "") {
1354
+ return undefined;
1355
+ }
1356
+ if (typeof length === "number") {
1357
+ return length;
1358
+ }
1359
+ var parsed = parseNumeric(length);
1360
+ if (parsed && (!parsed.units || parsed.units === "px")) {
1361
+ return parsed.num;
1362
+ }
1363
+ return undefined;
1364
+ }
1365
+ function parseNumeric(val) {
1366
+ // Parse strings like "30", "30px", "30%", "30px /* blah blah */"
1367
+ var res = val.match(/^\s*(-?(?:\d+\.\d*|\d*\.\d+|\d+))\s*([a-z]*|%)\s*(?:\/\*.*)?$/i);
1368
+ if (res == null) {
1369
+ return undefined;
1370
+ }
1371
+ var num = res[1];
1372
+ var units = res[2];
1373
+ return { num: +num, units: units };
1374
+ }
1375
+ function getImageLoader(loader) {
1376
+ if (loader == null) {
1377
+ return undefined;
1378
+ }
1379
+ else if (loader === "plasmic") {
1380
+ return PLASMIC_IMAGE_LOADER;
1381
+ }
1382
+ else {
1383
+ return loader;
1384
+ }
1385
+ }
1386
+ var PLASMIC_IMAGE_LOADER = {
1387
+ supportsUrl: function (src) {
1388
+ return src.startsWith("https://img.plasmic.app") && !isSvg(src);
1389
+ },
1390
+ transformUrl: function (opts) {
1391
+ var _a;
1392
+ var params = [
1393
+ opts.width ? "w=".concat(opts.width) : undefined,
1394
+ "q=".concat((_a = opts.quality) !== null && _a !== void 0 ? _a : 75),
1395
+ opts.format ? "f=".concat(opts.format) : undefined,
1396
+ ].filter(function (x) { return !!x; });
1397
+ return "".concat(opts.src, "?").concat(params.join("&"));
1398
+ }
1399
+ };
1400
+
1401
+ var PlasmicLink = React__default['default'].forwardRef(function PlasmicLink(props, ref) {
1402
+ // props.href is required for nextjs; if no props.href,
1403
+ // then we just render the default anchor element
1404
+ if (props.platform === "nextjs" && props.href) {
1405
+ var nextjsProps = [
1406
+ "href",
1407
+ "replace",
1408
+ "scroll",
1409
+ "shallow",
1410
+ "passHref",
1411
+ "prefetch",
1412
+ "locale",
1413
+ ];
1414
+ return React__default['default'].createElement(props.component, __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(nextjsProps), false))), { legacyBehavior: true }), React__default['default'].createElement("a", __assign({}, omit.apply(void 0, __spreadArray([props, "component", "platform"], __read(nextjsProps), false)), { ref: ref })));
1415
+ }
1416
+ if (props.platform === "gatsby" && isInternalHref(props.href)) {
1417
+ return React__default['default'].createElement(props.component, __assign(__assign({}, omit(props, "component", "platform", "href")), { to: props.href, ref: ref }));
1418
+ }
1419
+ return React__default['default'].createElement("a", __assign({}, omit(props, "component", "platform"), { ref: ref }));
1420
+ });
1421
+ function isInternalHref(href) {
1422
+ return /^\/(?!\/)/.test(href);
1423
+ }
1424
+
1425
+ var PlasmicTranslatorContext = React__default['default'].createContext(undefined);
1426
+ function isIterable(val) {
1427
+ return val != null && typeof val[Symbol.iterator] === "function";
1428
+ }
1429
+ function genTranslatableString(elt) {
1430
+ var components = {};
1431
+ var componentsCount = 0;
1432
+ var getText = function (node) {
1433
+ if (!node) {
1434
+ return "";
1435
+ }
1436
+ if (typeof node === "number" ||
1437
+ typeof node === "boolean" ||
1438
+ typeof node === "string") {
1439
+ return node.toString();
1440
+ }
1441
+ if (typeof node !== "object") {
1442
+ return "";
1443
+ }
1444
+ if (Array.isArray(node) || isIterable(node)) {
1445
+ return Array.from(node)
1446
+ .map(function (child) { return getText(child); })
1447
+ .filter(function (child) { return !!child; })
1448
+ .join("");
1449
+ }
1450
+ var nodeChildren = (hasKey(node, "props") &&
1451
+ hasKey(node.props, "children") &&
1452
+ node.props.children) ||
1453
+ (hasKey(node, "children") && node.children) ||
1454
+ [];
1455
+ var contents = "".concat(React__default['default'].Children.toArray(nodeChildren)
1456
+ .map(function (child) { return getText(child); })
1457
+ .filter(function (child) { return !!child; })
1458
+ .join(""));
1459
+ if (React__default['default'].isValidElement(node) && node.type === React__default['default'].Fragment) {
1460
+ return contents;
1461
+ }
1462
+ var componentId = componentsCount + 1;
1463
+ componentsCount++;
1464
+ components[componentId] = React__default['default'].isValidElement(node)
1465
+ ? React__default['default'].cloneElement(node, {
1466
+ key: componentId,
1467
+ children: undefined
1468
+ })
1469
+ : node;
1470
+ return "<".concat(componentId, ">").concat(contents, "</").concat(componentId, ">");
1471
+ };
1472
+ var str = getText(elt);
1473
+ return {
1474
+ str: str,
1475
+ components: components,
1476
+ componentsCount: componentsCount
1477
+ };
1478
+ }
1479
+ function Trans(_a) {
1480
+ var transKey = _a.transKey, children = _a.children;
1481
+ var _t = React__default['default'].useContext(PlasmicTranslatorContext);
1482
+ if (!_t) {
1483
+ warnNoTranslationFunctionAtMostOnce();
1484
+ return children;
1485
+ }
1486
+ var _b = genTranslatableString(children), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
1487
+ return _t(transKey !== null && transKey !== void 0 ? transKey : str, componentsCount > 0 ? { components: components } : undefined);
1488
+ }
1489
+ var hasWarned = false;
1490
+ function warnNoTranslationFunctionAtMostOnce() {
1491
+ if (!hasWarned) {
1492
+ console.warn("Using Plasmic Translation but no translation function has been provided");
1493
+ hasWarned = true;
1494
+ }
1495
+ }
1496
+ function hasKey(v, key) {
1497
+ return typeof v === "object" && v !== null && key in v;
1498
+ }
1499
+
1500
+ function PlasmicSlot(props) {
1501
+ return renderPlasmicSlot(props);
1502
+ }
1503
+ function renderPlasmicSlot(opts) {
1504
+ var as = opts.as, defaultContents = opts.defaultContents, value = opts.value, rest = __rest(opts, ["as", "defaultContents", "value"]);
1505
+ var content = value === undefined ? defaultContents : value;
1506
+ if (!content || (Array.isArray(content) && content.length === 0)) {
1507
+ return null;
1508
+ }
1509
+ // If the content is a raw string, then we need to wrap the raw string
1510
+ // into an element, in case the slot is inside a flex-gap
1511
+ // container (you cannot apply margin to just a text node).
1512
+ var maybeString = maybeAsString(content);
1513
+ if (maybeString) {
1514
+ content = React__namespace.createElement("span", { className: "__wab_slot-string-wrapper" }, maybeString);
1515
+ }
1516
+ var nonEmptyProps = Object.keys(rest).filter(function (p) { return !!rest[p]; });
1517
+ if (nonEmptyProps.length === 0) {
1518
+ // No attrs to apply to the slot (which means the slot is unstyled), then
1519
+ // just render the content directly; no need for style wrapper.
1520
+ return React__namespace.createElement(React__namespace.Fragment, null, content);
1521
+ }
1522
+ return React__namespace.createElement(as || "span", mergeProps({ className: "__wab_slot" }, rest), content);
1523
+ }
1524
+ function maybeAsString(node) {
1525
+ // Unwrap fragments
1526
+ if (React__namespace.isValidElement(node)) {
1527
+ // Fragment doesn't render DOM elements
1528
+ if (node.type === React__namespace.Fragment) {
1529
+ return maybeAsString(node.props.children);
1530
+ }
1531
+ else if (node.type === Trans) {
1532
+ // Trans also doesn't render DOM elements. But we don't want to just render
1533
+ // its content string, because we want to keep the <Trans/> for the localization.
1534
+ // So we render the same node, to be wrapped into __wab_slot-string-wrapper.
1535
+ return node;
1536
+ }
1537
+ }
1538
+ if (typeof node === "string") {
1539
+ return node;
1540
+ }
1541
+ if (Array.isArray(node) && node.length === 1 && typeof node[0] === "string") {
1542
+ return node[0];
1543
+ }
1544
+ return undefined;
1545
+ }
1546
+
1547
+ var listeners = [];
1548
+ var queries = {};
1549
+ function matchScreenVariants() {
1550
+ if (!isBrowser) {
1551
+ return [];
1552
+ }
1553
+ return Object.entries(queries)
1554
+ .filter(function (_a) {
1555
+ var _b = __read(_a, 2), query = _b[1];
1556
+ return window.matchMedia(query).matches;
1557
+ })
1558
+ .map(function (_a) {
1559
+ var _b = __read(_a, 1), name = _b[0];
1560
+ return name;
1561
+ });
1562
+ }
1563
+ // undefined if screen variants have never been calculated
1564
+ var curScreenVariants = undefined;
1565
+ function recalculateScreenVariants() {
1566
+ var screenVariant = matchScreenVariants();
1567
+ if (!curScreenVariants ||
1568
+ screenVariant.join("") !== curScreenVariants.join("")) {
1569
+ curScreenVariants = screenVariant;
1570
+ ReactDOM__default['default'].unstable_batchedUpdates(function () {
1571
+ return listeners.forEach(function (listener) { return listener(); });
1572
+ });
1573
+ }
1574
+ }
1575
+ function ensureInitCurScreenVariants() {
1576
+ // Initializes curScreenVariants if it hadn't been before. Note that this must
1577
+ // be called from within an effect.
1578
+ if (curScreenVariants === undefined) {
1579
+ curScreenVariants = matchScreenVariants();
1580
+ }
1581
+ }
1582
+ if (isBrowser) {
1583
+ window.addEventListener("resize", recalculateScreenVariants);
1584
+ }
1585
+ function createUseScreenVariants(isMulti, screenQueries) {
1586
+ Object.assign(queries, screenQueries);
1587
+ curScreenVariants = undefined;
1588
+ return function () {
1589
+ // It is important that upon first render, we return [] or undefined, because
1590
+ // that is what SSR will use, and the client must match. In an effect (which
1591
+ // only happens on the client), we then actually ask for the real screen variant
1592
+ // and, if different from [] or undefined, forces a re-render.
1593
+ var _a = __read(React__namespace.useState(), 2), updateState = _a[1];
1594
+ var lastScreenVariantsRef = React__namespace.useRef(curScreenVariants || []);
1595
+ // We do useLayoutEffect instead of useEffect to immediately
1596
+ // register our forceUpdate. This ensures that if there was
1597
+ // a window resize event between render and effects, that the
1598
+ // listener will be registered in time
1599
+ useIsomorphicLayoutEffect$1(function () {
1600
+ var updateIfChanged = function () {
1601
+ if (curScreenVariants &&
1602
+ lastScreenVariantsRef.current.join("") !== curScreenVariants.join("")) {
1603
+ lastScreenVariantsRef.current = curScreenVariants;
1604
+ // Force update
1605
+ updateState({});
1606
+ }
1607
+ };
1608
+ // Listeners are invoked whenever the window is resized
1609
+ listeners.push(updateIfChanged);
1610
+ // Initialize the curScreenVariants for the first time. We don't need
1611
+ // to invoke the listeners here because all components will already
1612
+ // have this effect running and will re-render if the real screen
1613
+ // variant is non-empty.
1614
+ ensureInitCurScreenVariants();
1615
+ // Now, if the curScreenVariants differs from what we returned last,
1616
+ // then force a re-render.
1617
+ updateIfChanged();
1618
+ return function () {
1619
+ // Remove our listener on unmount
1620
+ listeners.splice(listeners.indexOf(updateIfChanged), 1);
1621
+ };
1622
+ }, []);
1623
+ if (isMulti) {
1624
+ return curScreenVariants || [];
1625
+ }
1626
+ else if (curScreenVariants) {
1627
+ return curScreenVariants[curScreenVariants.length - 1];
1628
+ }
1629
+ else {
1630
+ return undefined;
1631
+ }
1632
+ };
1633
+ }
1634
+
1635
+ var PlasmicRootContext = React__namespace.createContext(undefined);
1636
+ function PlasmicRootProvider(props) {
1637
+ var platform = props.platform, children = props.children, userAuthToken = props.userAuthToken, isUserLoading = props.isUserLoading, authRedirectUri = props.authRedirectUri, user = props.user;
1638
+ var context = React__namespace.useMemo(function () { return ({
1639
+ platform: platform
1640
+ }); }, [platform]);
1641
+ var dataSourceContextValue = React__namespace.useMemo(function () { return ({
1642
+ userAuthToken: userAuthToken,
1643
+ user: user,
1644
+ isUserLoading: isUserLoading,
1645
+ authRedirectUri: authRedirectUri
1646
+ }); }, [userAuthToken, isUserLoading, user, authRedirectUri]);
1647
+ return (React__namespace.createElement(PlasmicRootContext.Provider, { value: context },
1648
+ React__namespace.createElement(ssr.SSRProvider, null,
1649
+ React__namespace.createElement(dataSourcesContext.PlasmicDataSourceContextProvider, { value: dataSourceContextValue },
1650
+ React__namespace.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
1651
+ React__namespace.createElement(PlasmicHeadContext.Provider, { value: props.Head }, children))))));
1652
+ }
1653
+ var useIsSSR = ssr.useIsSSR;
1654
+ function useHasPlasmicRoot() {
1655
+ return !!React__namespace.useContext(PlasmicRootContext);
1656
+ }
1657
+ var hasWarnedSSR = false;
1658
+ /**
1659
+ * Warns the user if PlasmicRootProvider is not used
1660
+ */
1661
+ function useEnsureSSRProvider() {
1662
+ var hasRoot = useHasPlasmicRoot();
1663
+ if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
1664
+ return;
1665
+ }
1666
+ hasWarnedSSR = true;
1667
+ console.warn("Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr");
1668
+ }
1669
+
1670
+ function useFocused(opts) {
1671
+ var _a = focus.useFocusRing({
1672
+ within: false,
1673
+ isTextInput: opts.isTextInput
1674
+ }), isFocused = _a.isFocused, focusProps = _a.focusProps;
1675
+ return [isFocused, focusProps];
1676
+ }
1677
+ function useFocusVisible(opts) {
1678
+ var _a = focus.useFocusRing({
1679
+ within: false,
1680
+ isTextInput: opts.isTextInput
1681
+ }), isFocusVisible = _a.isFocusVisible, focusProps = _a.focusProps;
1682
+ return [isFocusVisible, focusProps];
1683
+ }
1684
+ function useFocusedWithin(opts) {
1685
+ var _a = focus.useFocusRing({
1686
+ within: true,
1687
+ isTextInput: opts.isTextInput
1688
+ }), isFocused = _a.isFocused, focusProps = _a.focusProps;
1689
+ return [isFocused, focusProps];
1690
+ }
1691
+ function useFocusVisibleWithin(opts) {
1692
+ var _a = focus.useFocusRing({
1693
+ within: true,
1694
+ isTextInput: opts.isTextInput
1695
+ }), isFocusVisible = _a.isFocusVisible, focusProps = _a.focusProps;
1696
+ return [isFocusVisible, focusProps];
1697
+ }
1698
+ function useHover() {
1699
+ var _a = __read(React__namespace.useState(false), 2), isHover = _a[0], setHover = _a[1];
1700
+ return [
1701
+ isHover,
1702
+ {
1703
+ onMouseEnter: function () { return setHover(true); },
1704
+ onMouseLeave: function () { return setHover(false); }
1705
+ },
1706
+ ];
1707
+ }
1708
+ function usePressed() {
1709
+ var _a = __read(React__namespace.useState(false), 2), isPressed = _a[0], setPressed = _a[1];
1710
+ return [
1711
+ isPressed,
1712
+ {
1713
+ onMouseDown: function () { return setPressed(true); },
1714
+ onMouseUp: function () { return setPressed(false); }
1715
+ },
1716
+ ];
1717
+ }
1718
+ var TRIGGER_TO_HOOK = {
1719
+ useHover: useHover,
1720
+ useFocused: useFocused,
1721
+ useFocusVisible: useFocusVisible,
1722
+ useFocusedWithin: useFocusedWithin,
1723
+ useFocusVisibleWithin: useFocusVisibleWithin,
1724
+ usePressed: usePressed
1725
+ };
1726
+ /**
1727
+ * Installs argment trigger. All the useTrigger calls must use hardcoded `trigger` arg,
1728
+ * as it's not valid to install variable React hooks!
1729
+ */
1730
+ function useTrigger(trigger, opts) {
1731
+ return TRIGGER_TO_HOOK[trigger](opts);
1732
+ }
1733
+
1734
+ var ARRAY_SYMBOL = Symbol("[]");
1735
+ var PLASMIC_STATE_PROXY_SYMBOL = Symbol("plasmic.state.proxy");
1736
+ var UNINITIALIZED = Symbol("plasmic.unitialized");
1737
+
1738
+ /** @class */ ((function (_super) {
1739
+ __extends(CustomError, _super);
1740
+ function CustomError(msg) {
1741
+ var _a;
1742
+ var _this = _super.call(this, msg) || this;
1743
+ _this.name = _this.constructor.name;
1744
+ (_a = _this, _this.message = _a.message, _this.stack = _a.stack);
1745
+ return _this;
1746
+ }
1747
+ return CustomError;
1748
+ })(Error));
1749
+ var CyclicStatesReferencesError = /** @class */ (function (_super) {
1750
+ __extends(CyclicStatesReferencesError, _super);
1751
+ function CyclicStatesReferencesError(stateAccessCycle) {
1752
+ return _super.call(this, "Cyclic reference found in state initialization: " +
1753
+ stateAccessCycle.join(" -> ")) || this;
1754
+ }
1755
+ return CyclicStatesReferencesError;
1756
+ }(Error));
1757
+ var InvalidOperation = /** @class */ (function (_super) {
1758
+ __extends(InvalidOperation, _super);
1759
+ function InvalidOperation(msg) {
1760
+ return _super.call(this, msg) || this;
1761
+ }
1762
+ return InvalidOperation;
1763
+ }(Error));
1764
+ var UnknownError = /** @class */ (function (_super) {
1765
+ __extends(UnknownError, _super);
1766
+ function UnknownError(msg) {
1767
+ return _super.call(this, msg) || this;
1768
+ }
1769
+ return UnknownError;
1770
+ }(Error));
1771
+
1772
+ var StateSpecNode = /** @class */ (function () {
1773
+ function StateSpecNode(specs) {
1774
+ this._specs = specs;
1775
+ this._edges = new Map();
1776
+ }
1777
+ StateSpecNode.prototype.setSpecs = function (specs) {
1778
+ this._specs = specs;
1779
+ };
1780
+ StateSpecNode.prototype.edges = function () {
1781
+ return this._edges;
1782
+ };
1783
+ StateSpecNode.prototype.hasEdge = function (key) {
1784
+ return this._edges.has(key);
1785
+ };
1786
+ StateSpecNode.prototype.addEdge = function (key, node) {
1787
+ this._edges.set(key, node);
1788
+ };
1789
+ StateSpecNode.prototype.clearEdges = function () {
1790
+ this._edges = new Map();
1791
+ };
1792
+ StateSpecNode.prototype.children = function () {
1793
+ return this._edges.values();
1794
+ };
1795
+ StateSpecNode.prototype.makeTransition = function (key) {
1796
+ key = isNum(key) ? ARRAY_SYMBOL : key;
1797
+ return this._edges.get(key);
1798
+ };
1799
+ StateSpecNode.prototype.isLeaf = function () {
1800
+ return this._edges.size === 0 && this.getAllSpecs().length > 0;
1801
+ };
1802
+ StateSpecNode.prototype.hasArrayTransition = function () {
1803
+ return this._edges.has(ARRAY_SYMBOL);
1804
+ };
1805
+ StateSpecNode.prototype.getSpec = function () {
1806
+ return this._specs[0];
1807
+ };
1808
+ StateSpecNode.prototype.getAllSpecs = function () {
1809
+ return this._specs;
1810
+ };
1811
+ return StateSpecNode;
1812
+ }());
1813
+ var transformPathStringToObj = function (str) {
1814
+ var splitStatePathPart = function (state) {
1815
+ return state.endsWith("[]")
1816
+ ? __spreadArray(__spreadArray([], __read(splitStatePathPart(state.slice(0, -2))), false), [ARRAY_SYMBOL], false) : [state];
1817
+ };
1818
+ return str.split(".").flatMap(splitStatePathPart);
1819
+ };
1820
+ function buildTree(specs) {
1821
+ var internalSpec = specs.map(function (spec) {
1822
+ return (__assign(__assign({}, spec), { pathObj: transformPathStringToObj(spec.path), isRepeated: spec.path.split(".").some(function (part) { return part.endsWith("[]"); }) }));
1823
+ });
1824
+ var rec = function (currentPath) {
1825
+ var node = new StateSpecNode(internalSpec.filter(function (spec) {
1826
+ return shallowEqual(currentPath, spec.pathObj.slice(0, currentPath.length));
1827
+ }));
1828
+ node.getAllSpecs().forEach(function (spec) {
1829
+ if (spec.pathObj.length > currentPath.length) {
1830
+ var nextKey = spec.pathObj[currentPath.length];
1831
+ if (!node.hasEdge(nextKey)) {
1832
+ node.addEdge(nextKey, rec(__spreadArray(__spreadArray([], __read(currentPath), false), [nextKey], false)));
1833
+ }
1834
+ }
1835
+ });
1836
+ return node;
1837
+ };
1838
+ return rec([]);
1839
+ }
1840
+ function updateTree(root, specs) {
1841
+ var internalSpec = specs.map(function (spec) {
1842
+ return (__assign(__assign({}, spec), { pathObj: transformPathStringToObj(spec.path), isRepeated: spec.path.split(".").some(function (part) { return part.endsWith("[]"); }) }));
1843
+ });
1844
+ var rec = function (oldNode, currentPath) {
1845
+ var nodeSpecs = internalSpec.filter(function (spec) {
1846
+ return shallowEqual(currentPath, spec.pathObj.slice(0, currentPath.length));
1847
+ });
1848
+ var node = oldNode !== null && oldNode !== void 0 ? oldNode : new StateSpecNode(nodeSpecs);
1849
+ node.setSpecs(nodeSpecs);
1850
+ var oldEdges = oldNode === null || oldNode === void 0 ? void 0 : oldNode.edges();
1851
+ node.clearEdges();
1852
+ node.getAllSpecs().forEach(function (spec) {
1853
+ if (spec.pathObj.length > currentPath.length) {
1854
+ var nextKey = spec.pathObj[currentPath.length];
1855
+ if (!node.hasEdge(nextKey)) {
1856
+ node.addEdge(nextKey, rec(oldEdges === null || oldEdges === void 0 ? void 0 : oldEdges.get(nextKey), __spreadArray(__spreadArray([], __read(currentPath), false), [nextKey], false)));
1857
+ }
1858
+ }
1859
+ });
1860
+ return node;
1861
+ };
1862
+ return rec(root, []);
1863
+ }
1864
+ function getSpecTreeLeaves(root) {
1865
+ var leaves = [];
1866
+ var rec = function (node) {
1867
+ var e_1, _a;
1868
+ try {
1869
+ for (var _b = __values(node.children()), _c = _b.next(); !_c.done; _c = _b.next()) {
1870
+ var child = _c.value;
1871
+ rec(child);
1872
+ }
1873
+ }
1874
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1875
+ finally {
1876
+ try {
1877
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
1878
+ }
1879
+ finally { if (e_1) throw e_1.error; }
1880
+ }
1881
+ if (node.isLeaf() && node.getAllSpecs().length > 0) {
1882
+ leaves.push(node);
1883
+ }
1884
+ };
1885
+ rec(root);
1886
+ return leaves;
1887
+ }
1888
+ function findStateCell(root, pathStr, repetitionIndex) {
1889
+ var e_2, _a;
1890
+ var realPath = [];
1891
+ var pathObj = transformPathStringToObj(pathStr);
1892
+ var currRepIndex = 0;
1893
+ try {
1894
+ for (var pathObj_1 = __values(pathObj), pathObj_1_1 = pathObj_1.next(); !pathObj_1_1.done; pathObj_1_1 = pathObj_1.next()) {
1895
+ var part = pathObj_1_1.value;
1896
+ if (typeof part === "symbol") {
1897
+ if (!root.hasArrayTransition() ||
1898
+ !repetitionIndex ||
1899
+ currRepIndex > repetitionIndex.length) {
1900
+ throw new Error("transition not found: pathStr ".concat(pathStr, " part ").concat(typeof part === "symbol" ? "[]" : part));
1901
+ }
1902
+ realPath.push(repetitionIndex[currRepIndex++]);
1903
+ root = root.makeTransition(ARRAY_SYMBOL);
1904
+ }
1905
+ else {
1906
+ if (!root.hasEdge(part)) {
1907
+ throw new Error("transition not found: pathStr ".concat(pathStr, " part ").concat(typeof part === "symbol" ? "[]" : part));
1908
+ }
1909
+ realPath.push(part);
1910
+ root = root.makeTransition(part);
1911
+ }
1912
+ }
1913
+ }
1914
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1915
+ finally {
1916
+ try {
1917
+ if (pathObj_1_1 && !pathObj_1_1.done && (_a = pathObj_1["return"])) _a.call(pathObj_1);
1918
+ }
1919
+ finally { if (e_2) throw e_2.error; }
1920
+ }
1921
+ return {
1922
+ node: root,
1923
+ realPath: realPath
1924
+ };
1925
+ }
1926
+
1927
+ function isNum$1(value) {
1928
+ return typeof value === "symbol" ? false : !isNaN(+value);
1929
+ }
1930
+ function canProxy(value) {
1931
+ return typeof value === "object" && value != null;
1932
+ }
1933
+ var proxyObjToStateCell = new WeakMap();
1934
+ var valtioSubscriptions = new WeakMap();
1935
+ function ensureStateCell(target, property, path, node) {
1936
+ var _a;
1937
+ if (!proxyObjToStateCell.has(target)) {
1938
+ proxyObjToStateCell.set(target, {});
1939
+ }
1940
+ var stateCell = proxyObjToStateCell.get(target);
1941
+ if (!(property in stateCell)) {
1942
+ stateCell[property] = {
1943
+ listeners: [],
1944
+ initialValue: UNINITIALIZED,
1945
+ path: path,
1946
+ node: node,
1947
+ initFunc: node.getSpec().initFunc,
1948
+ initFuncHash: (_a = node.getSpec().initFuncHash) !== null && _a !== void 0 ? _a : ""
1949
+ };
1950
+ }
1951
+ return stateCell[property];
1952
+ }
1953
+ function getStateCell(target, property) {
1954
+ var _a;
1955
+ return (_a = proxyObjToStateCell.get(target)) === null || _a === void 0 ? void 0 : _a[property];
1956
+ }
1957
+ function tryGetStateCellFrom$StateRoot($state, path) {
1958
+ if (path.length === 0) {
1959
+ throw new UnknownError("expected a path with length greater than 0");
1960
+ }
1961
+ var target = get__default['default']($state, path.slice(0, -1));
1962
+ get__default['default'](target, path.slice(-1)); // create state cell;
1963
+ return getStateCell(target, path.slice(-1)[0]);
1964
+ }
1965
+ function getStateCellFrom$StateRoot($state, path) {
1966
+ return ensure(tryGetStateCellFrom$StateRoot($state, path));
1967
+ }
1968
+ function unsubscribeToValtio($$state, statePath) {
1969
+ var _a;
1970
+ var oldValue = get__default['default']($$state.stateValues, statePath);
1971
+ if (valtio.getVersion(oldValue)) {
1972
+ (_a = valtioSubscriptions.get(oldValue)) === null || _a === void 0 ? void 0 : _a.forEach(function (f) { return f(); });
1973
+ valtioSubscriptions["delete"](oldValue);
1974
+ }
1975
+ }
1976
+ function subscribeToValtio($$state, statePath, node) {
1977
+ var spec = node.getSpec();
1978
+ var maybeValtioProxy = spec.valueProp
1979
+ ? $$state.env.$props[spec.valueProp]
1980
+ : get__default['default']($$state.stateValues, statePath);
1981
+ if (valtio.getVersion(maybeValtioProxy) && spec.onChangeProp) {
1982
+ var unsub = valtio.subscribe(maybeValtioProxy, function () {
1983
+ var _a, _b;
1984
+ (_b = (_a = $$state.env.$props)[spec.onChangeProp]) === null || _b === void 0 ? void 0 : _b.call(_a, spec.valueProp
1985
+ ? $$state.env.$props[spec.valueProp]
1986
+ : get__default['default']($$state.stateValues, statePath));
1987
+ });
1988
+ if (!valtioSubscriptions.has(maybeValtioProxy)) {
1989
+ valtioSubscriptions.set(maybeValtioProxy, []);
1990
+ }
1991
+ ensure(valtioSubscriptions.get(maybeValtioProxy)).push(unsub);
1992
+ }
1993
+ }
1994
+ function initializeStateValue($$state, initialStateCell, proxyRoot) {
1995
+ var _a, _b, _c;
1996
+ var initialStateName = initialStateCell.node.getSpec().path;
1997
+ var stateAccess = new Set();
1998
+ $$state.stateInitializationEnv.visited.add(initialStateName);
1999
+ $$state.stateInitializationEnv.stack.push(initialStateName);
2000
+ var $state = create$StateProxy($$state, function (internalStateCell) { return ({
2001
+ get: function () {
2002
+ var spec = internalStateCell.node.getSpec();
2003
+ if ($$state.stateInitializationEnv.visited.has(spec.path)) {
2004
+ // cyclic reference found
2005
+ var stateAccessCycle = [spec.path];
2006
+ while ($$state.stateInitializationEnv.stack.length > 0) {
2007
+ var curr = $$state.stateInitializationEnv.stack.pop();
2008
+ if (!curr) {
2009
+ break;
2010
+ }
2011
+ stateAccessCycle.push(curr);
2012
+ if (curr === spec.path) {
2013
+ throw new CyclicStatesReferencesError(stateAccessCycle);
2014
+ }
2015
+ }
2016
+ throw new UnknownError("Internal error: cycle not found");
2017
+ }
2018
+ var stateCell = getStateCellFrom$StateRoot(proxyRoot, internalStateCell.path);
2019
+ stateAccess.add({ stateCell: stateCell });
2020
+ if (spec.valueProp) {
2021
+ return $$state.env.$props[spec.valueProp];
2022
+ }
2023
+ else if (spec.initFunc && stateCell.initialValue === UNINITIALIZED) {
2024
+ return initializeStateValue($$state, stateCell, proxyRoot);
2025
+ }
2026
+ return get__default['default'](proxyRoot, stateCell.path);
2027
+ },
2028
+ set: function () {
2029
+ throw new InvalidOperation("Cannot update state values during initialization");
2030
+ }
2031
+ }); });
2032
+ stateAccess.forEach(function (_a) {
2033
+ var stateCell = _a.stateCell;
2034
+ stateCell.listeners.push(function () {
2035
+ var _a;
2036
+ var newValue = invokeInitFuncBackwardsCompatible(initialStateCell.node.getSpec().initFunc, __assign({ $state: $state }, ((_a = initialStateCell.overrideEnv) !== null && _a !== void 0 ? _a : $$state.env)));
2037
+ set(proxyRoot, initialStateCell.path, newValue);
2038
+ });
2039
+ });
2040
+ var initialValue = invokeInitFuncBackwardsCompatible(initialStateCell.initFunc, __assign({ $state: $state }, ((_a = initialStateCell.overrideEnv) !== null && _a !== void 0 ? _a : $$state.env)));
2041
+ initialStateCell.initialValue = clone__default['default'](initialValue);
2042
+ var initialSpec = initialStateCell.node.getSpec();
2043
+ var value = initialSpec.isImmutable
2044
+ ? mkUntrackedValue(initialValue)
2045
+ : clone__default['default'](initialValue);
2046
+ set(proxyRoot, initialStateCell.path, value);
2047
+ //immediately fire onChange
2048
+ if (initialSpec.onChangeProp) {
2049
+ (_c = (_b = $$state.env.$props)[initialSpec.onChangeProp]) === null || _c === void 0 ? void 0 : _c.call(_b, initialValue);
2050
+ }
2051
+ $$state.stateInitializationEnv.visited["delete"](initialStateName);
2052
+ $$state.stateInitializationEnv.stack.pop();
2053
+ return initialValue;
2054
+ }
2055
+ function create$StateProxy($$state, leafHandlers) {
2056
+ var proxyRoot;
2057
+ var rec = function (currPath, currNode) {
2058
+ var getNextPath = function (property) { return __spreadArray(__spreadArray([], __read(currPath), false), [
2059
+ isNum$1(property) ? +property : property,
2060
+ ], false); };
2061
+ var spec = currNode.getSpec();
2062
+ var handlers = {
2063
+ deleteProperty: function (target, property) {
2064
+ var _a, _b;
2065
+ if (!currNode.isLeaf() &&
2066
+ !currNode.hasArrayTransition() &&
2067
+ !isNum$1(property)) {
2068
+ throw new InvalidOperation("Can't delete a property in the middle of the state spec");
2069
+ }
2070
+ delete get__default['default']($$state.stateValues, currPath)[property];
2071
+ if (spec.onChangeProp) {
2072
+ //we are always in a leaf, since we only have two cases:
2073
+ // 1 - delete properties outside the state tree
2074
+ // 2 - delete indices in repeated implicit states, but these can't be exposed, so they don't have onChangeProp
2075
+ (_b = (_a = $$state.env.$props)[spec.onChangeProp]) === null || _b === void 0 ? void 0 : _b.call(_a, get__default['default'](proxyRoot, currPath.slice(spec.pathObj.length)));
2076
+ }
2077
+ return Reflect.deleteProperty(target, property);
2078
+ },
2079
+ get: function (target, property, receiver) {
2080
+ var _a, _b;
2081
+ if (property === PLASMIC_STATE_PROXY_SYMBOL) {
2082
+ return {
2083
+ node: currNode,
2084
+ path: currPath
2085
+ };
2086
+ }
2087
+ var nextPath = getNextPath(property);
2088
+ var nextNode = currNode.makeTransition(property);
2089
+ if (nextNode === null || nextNode === void 0 ? void 0 : nextNode.isLeaf()) {
2090
+ return (_b = (_a = leafHandlers(ensureStateCell(receiver, property, nextPath, nextNode))).get) === null || _b === void 0 ? void 0 : _b.call(_a, target, property, receiver);
2091
+ }
2092
+ else if (nextNode && !(property in target)) {
2093
+ target[property] = rec(nextPath, nextNode);
2094
+ }
2095
+ return Reflect.get(target, property, receiver);
2096
+ },
2097
+ set: function (target, property, value, receiver) {
2098
+ var _a, _b, _c, _d;
2099
+ var nextPath = getNextPath(property);
2100
+ var nextNode = currNode.makeTransition(property);
2101
+ var nextSpec = nextNode === null || nextNode === void 0 ? void 0 : nextNode.getSpec();
2102
+ if (property === "registerInitFunc" && currPath.length === 0) {
2103
+ return Reflect.set(target, property, value, receiver);
2104
+ }
2105
+ if (!nextNode && currNode.hasArrayTransition()) {
2106
+ set($$state.stateValues, nextPath, value);
2107
+ //array can set his own properties such as length, map, ...
2108
+ return Reflect.set(target, property, value, receiver);
2109
+ }
2110
+ if (nextNode === null || nextNode === void 0 ? void 0 : nextNode.isLeaf()) {
2111
+ (_b = (_a = leafHandlers(ensureStateCell(receiver, property, nextPath, nextNode))).set) === null || _b === void 0 ? void 0 : _b.call(_a, target, property, value, receiver);
2112
+ Reflect.set(target, property, value, receiver);
2113
+ if (nextSpec === null || nextSpec === void 0 ? void 0 : nextSpec.onChangeProp) {
2114
+ (_d = (_c = $$state.env.$props)[nextSpec.onChangeProp]) === null || _d === void 0 ? void 0 : _d.call(_c, value);
2115
+ }
2116
+ }
2117
+ if (!nextNode) {
2118
+ // can't set an unknown field in $state
2119
+ return false;
2120
+ }
2121
+ if (canProxy(value) && !nextNode.isLeaf()) {
2122
+ target[property] = rec(nextPath, nextNode);
2123
+ Reflect.ownKeys(value).forEach(function (key) {
2124
+ target[property][key] = value[key];
2125
+ });
2126
+ }
2127
+ else if (!nextNode.isLeaf()) {
2128
+ throw new InvalidOperation("inserting a primitive value into a non-leaf");
2129
+ }
2130
+ var newValue = nextNode.isLeaf() && (nextSpec === null || nextSpec === void 0 ? void 0 : nextSpec.isImmutable)
2131
+ ? mkUntrackedValue(value)
2132
+ : value;
2133
+ unsubscribeToValtio($$state, nextPath);
2134
+ set($$state.stateValues, nextPath, newValue);
2135
+ subscribeToValtio($$state, nextPath, nextNode);
2136
+ return true;
2137
+ }
2138
+ };
2139
+ var baseObject = currNode.hasArrayTransition() ? [] : {};
2140
+ var proxyObj = new Proxy(baseObject, handlers);
2141
+ if (currPath.length === 0) {
2142
+ proxyRoot = proxyObj;
2143
+ }
2144
+ return proxyObj;
2145
+ };
2146
+ return rec([], $$state.rootSpecTree);
2147
+ }
2148
+ var mkUntrackedValue = function (o) {
2149
+ return o != null && typeof o === "object" ? valtio.ref(o) : o;
2150
+ };
2151
+ var envFieldsAreNonNill = function (env) {
2152
+ var _a, _b;
2153
+ return ({
2154
+ $props: env.$props,
2155
+ $ctx: (_a = env.$ctx) !== null && _a !== void 0 ? _a : {},
2156
+ $queries: (_b = env.$queries) !== null && _b !== void 0 ? _b : {}
2157
+ });
2158
+ };
2159
+ /**
2160
+ * We need to support two versions with different parameters to be backward compatible
2161
+ * {
2162
+ * specs: $StateSpec<any>[],
2163
+ * props: Record<string, any>,
2164
+ * $ctx?: Record<string, any>,
2165
+ * opts?: { inCanvas: boolean; }
2166
+ * }
2167
+ * {
2168
+ * specs: $StateSpec<any>[],
2169
+ * env: { $props; $queries; $ctx },
2170
+ * opts?: { inCanvas: boolean }
2171
+ * }
2172
+ */
2173
+ function extractDollarStateParametersBackwardCompatible() {
2174
+ var rest = [];
2175
+ for (var _i = 0; _i < arguments.length; _i++) {
2176
+ rest[_i] = arguments[_i];
2177
+ }
2178
+ if ("$props" in rest[0]) {
2179
+ // latest version
2180
+ return {
2181
+ env: rest[0],
2182
+ opts: rest[1]
2183
+ };
2184
+ }
2185
+ else {
2186
+ return {
2187
+ env: {
2188
+ $props: rest[0],
2189
+ $ctx: rest[1],
2190
+ $queries: {}
2191
+ },
2192
+ opts: rest[2]
2193
+ };
2194
+ }
2195
+ }
2196
+ function invokeInitFuncBackwardsCompatible(initFunc, env) {
2197
+ if (initFunc.length > 1) {
2198
+ return initFunc(env.$props, env.$state, env.$ctx);
2199
+ }
2200
+ else {
2201
+ return initFunc(env);
2202
+ }
2203
+ }
2204
+ function useDollarState(specs) {
2205
+ var rest = [];
2206
+ for (var _i = 1; _i < arguments.length; _i++) {
2207
+ rest[_i - 1] = arguments[_i];
2208
+ }
2209
+ var _a = extractDollarStateParametersBackwardCompatible.apply(void 0, __spreadArray([], __read(rest), false)), env = _a.env, opts = _a.opts;
2210
+ var $$state = React__default['default'].useRef((function () {
2211
+ var rootSpecTree = buildTree(specs);
2212
+ return {
2213
+ rootSpecTree: rootSpecTree,
2214
+ specTreeLeaves: getSpecTreeLeaves(rootSpecTree),
2215
+ stateValues: valtio.proxy({}),
2216
+ env: envFieldsAreNonNill(env),
2217
+ specs: [],
2218
+ registrationsQueue: valtio.proxy([]),
2219
+ stateInitializationEnv: { stack: [], visited: new Set() }
2220
+ };
2221
+ })()).current;
2222
+ $$state.env = envFieldsAreNonNill(env);
2223
+ $$state.specs = specs;
2224
+ var create$State = React__default['default'].useCallback(function () {
2225
+ var $state = Object.assign(create$StateProxy($$state, function (stateCell) {
2226
+ var spec = stateCell.node.getSpec();
2227
+ if (stateCell.initialValue === UNINITIALIZED && spec.initFunc) {
2228
+ initializeStateValue($$state, stateCell, $state);
2229
+ }
2230
+ else if (stateCell.initialValue === UNINITIALIZED &&
2231
+ !spec.valueProp) {
2232
+ stateCell.initialValue = spec.initVal;
2233
+ set($state, stateCell.path, spec.initVal);
2234
+ }
2235
+ return {
2236
+ get: function () {
2237
+ var spec = stateCell.node.getSpec();
2238
+ if (spec.valueProp) {
2239
+ var valueProp = $$state.env.$props[spec.valueProp];
2240
+ subscribeToValtio($$state, stateCell.path, stateCell.node);
2241
+ return valueProp;
2242
+ }
2243
+ else {
2244
+ return get__default['default']($$state.stateValues, stateCell.path);
2245
+ }
2246
+ }
2247
+ };
2248
+ }), {
2249
+ registerInitFunc: function (pathStr, f, repetitionIndex, overrideEnv) {
2250
+ var _a = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex), node = _a.node, realPath = _a.realPath;
2251
+ var stateCell = getStateCellFrom$StateRoot($state, realPath);
2252
+ var env = overrideEnv
2253
+ ? envFieldsAreNonNill(overrideEnv)
2254
+ : $$state.env;
2255
+ if (!deepEqual__default['default'](stateCell.initialValue, f(__assign({ $state: $state }, env)))) {
2256
+ $$state.registrationsQueue.push(mkUntrackedValue({
2257
+ node: node,
2258
+ path: realPath,
2259
+ f: f,
2260
+ overrideEnv: overrideEnv
2261
+ ? envFieldsAreNonNill(overrideEnv)
2262
+ : undefined
2263
+ }));
2264
+ }
2265
+ }
2266
+ });
2267
+ return $state;
2268
+ }, []);
2269
+ var ref = React__default['default'].useRef(undefined);
2270
+ if (!ref.current) {
2271
+ ref.current = create$State();
2272
+ }
2273
+ var $state = ref.current;
2274
+ if (opts === null || opts === void 0 ? void 0 : opts.inCanvas) {
2275
+ $$state.rootSpecTree = updateTree($$state.rootSpecTree, specs);
2276
+ var newLeaves = getSpecTreeLeaves($$state.rootSpecTree);
2277
+ if (!arrayEq(newLeaves, $$state.specTreeLeaves)) {
2278
+ var old$state_1 = $state;
2279
+ $state = ref.current = create$State();
2280
+ $$state.specTreeLeaves = newLeaves;
2281
+ getStateCells(old$state_1, $$state.rootSpecTree).forEach(function (_a) {
2282
+ var path = _a.path;
2283
+ var oldStateCell = tryGetStateCellFrom$StateRoot(old$state_1, path);
2284
+ if (oldStateCell) {
2285
+ set($state, path, get__default['default'](old$state_1, path));
2286
+ var newStateCell = getStateCellFrom$StateRoot($state, path);
2287
+ newStateCell.initialValue = oldStateCell.initialValue;
2288
+ }
2289
+ });
2290
+ }
2291
+ // we need to eager initialize all states in canvas to populate the data picker
2292
+ $$state.specTreeLeaves.forEach(function (node) {
2293
+ var _a, _b;
2294
+ var spec = node.getSpec();
2295
+ if (spec.isRepeated) {
2296
+ return;
2297
+ }
2298
+ var stateCell = getStateCellFrom$StateRoot($state, spec.pathObj);
2299
+ var newSpec = specs.find(function (sp) { return sp.path === spec.path; });
2300
+ if (!newSpec ||
2301
+ (stateCell.initFuncHash === ((_a = newSpec === null || newSpec === void 0 ? void 0 : newSpec.initFuncHash) !== null && _a !== void 0 ? _a : "") &&
2302
+ stateCell.initialValue !== UNINITIALIZED)) {
2303
+ return;
2304
+ }
2305
+ stateCell.initFunc = newSpec.initFunc;
2306
+ stateCell.initFuncHash = (_b = newSpec.initFuncHash) !== null && _b !== void 0 ? _b : "";
2307
+ var init = spec.valueProp
2308
+ ? $$state.env.$props[spec.valueProp]
2309
+ : spec.initFunc
2310
+ ? initializeStateValue($$state, stateCell, $state)
2311
+ : spec.initVal;
2312
+ set($state, spec.pathObj, init);
2313
+ });
2314
+ }
2315
+ // For each spec with an initFunc, evaluate it and see if
2316
+ // the init value has changed. If so, reset its state.
2317
+ var resetSpecs = [];
2318
+ getStateCells($state, $$state.rootSpecTree).forEach(function (stateCell) {
2319
+ var _a;
2320
+ if (stateCell.initFunc) {
2321
+ var newInit = invokeInitFuncBackwardsCompatible(stateCell.initFunc, __assign({ $state: $state }, ((_a = stateCell.overrideEnv) !== null && _a !== void 0 ? _a : envFieldsAreNonNill(env))));
2322
+ if (!deepEqual__default['default'](newInit, stateCell.initialValue)) {
2323
+ resetSpecs.push({ stateCell: stateCell });
2324
+ }
2325
+ }
2326
+ });
2327
+ var reInitializeState = function (stateCell) {
2328
+ var _a, _b;
2329
+ var newInit = initializeStateValue($$state, stateCell, $state);
2330
+ var spec = stateCell.node.getSpec();
2331
+ if (spec.onChangeProp) {
2332
+ (_b = (_a = $$state.env.$props)[spec.onChangeProp]) === null || _b === void 0 ? void 0 : _b.call(_a, newInit);
2333
+ }
2334
+ };
2335
+ useIsomorphicLayoutEffect(function () {
2336
+ resetSpecs.forEach(function (_a) {
2337
+ var stateCell = _a.stateCell;
2338
+ reInitializeState(stateCell);
2339
+ });
2340
+ }, [env.$props, resetSpecs]);
2341
+ useIsomorphicLayoutEffect(function () {
2342
+ while ($$state.registrationsQueue.length) {
2343
+ var _a = $$state.registrationsQueue.shift(), path = _a.path, f = _a.f, overrideEnv = _a.overrideEnv;
2344
+ var stateCell = getStateCellFrom$StateRoot($state, path);
2345
+ stateCell.initFunc = f;
2346
+ stateCell.overrideEnv = overrideEnv;
2347
+ reInitializeState(stateCell);
2348
+ }
2349
+ }, [$$state.registrationsQueue.length]);
2350
+ // immediately initialize exposed non-private states
2351
+ useIsomorphicLayoutEffect(function () {
2352
+ $$state.specTreeLeaves.forEach(function (node) {
2353
+ var spec = node.getSpec();
2354
+ if (!spec.isRepeated && spec.type !== "private" && spec.initFunc) {
2355
+ var stateCell = getStateCellFrom$StateRoot($state, spec.pathObj);
2356
+ initializeStateValue($$state, stateCell, $state);
2357
+ }
2358
+ });
2359
+ }, []);
2360
+ // Re-render if any value changed in one of these objects
2361
+ valtio.useSnapshot($$state.stateValues, { sync: true });
2362
+ valtio.useSnapshot($$state.registrationsQueue, { sync: true });
2363
+ return $state;
2364
+ }
2365
+
2366
+ function initializeCodeComponentStates($state, states, repetitionIndex, componentHelpers, child$Props) {
2367
+ var e_1, _a;
2368
+ var _b, _c;
2369
+ var stateHelpers = (_b = componentHelpers === null || componentHelpers === void 0 ? void 0 : componentHelpers.states) !== null && _b !== void 0 ? _b : {};
2370
+ var _loop_1 = function (name_1, plasmicStateName) {
2371
+ if (name_1 in stateHelpers && "initFunc" in stateHelpers[name_1]) {
2372
+ (_c = $state.registerInitFunc) === null || _c === void 0 ? void 0 : _c.call($state, plasmicStateName, function (_a) {
2373
+ var _b, _c;
2374
+ var $props = _a.$props;
2375
+ return (_c = (_b = stateHelpers[name_1]).initFunc) === null || _c === void 0 ? void 0 : _c.call(_b, $props);
2376
+ }, repetitionIndex !== null && repetitionIndex !== void 0 ? repetitionIndex : [], { $props: child$Props });
2377
+ }
2378
+ };
2379
+ try {
2380
+ for (var states_1 = __values(states), states_1_1 = states_1.next(); !states_1_1.done; states_1_1 = states_1.next()) {
2381
+ var _d = states_1_1.value, name_1 = _d.name, plasmicStateName = _d.plasmicStateName;
2382
+ _loop_1(name_1, plasmicStateName);
2383
+ }
2384
+ }
2385
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2386
+ finally {
2387
+ try {
2388
+ if (states_1_1 && !states_1_1.done && (_a = states_1["return"])) _a.call(states_1);
2389
+ }
2390
+ finally { if (e_1) throw e_1.error; }
2391
+ }
2392
+ }
2393
+ function initializePlasmicStates($state, states, repetitionIndex) {
2394
+ var e_2, _a;
2395
+ var _b;
2396
+ try {
2397
+ for (var states_2 = __values(states), states_2_1 = states_2.next(); !states_2_1.done; states_2_1 = states_2.next()) {
2398
+ var _c = states_2_1.value, name_2 = _c.name, initFunc = _c.initFunc;
2399
+ (_b = $state.registerInitFunc) === null || _b === void 0 ? void 0 : _b.call($state, name_2, initFunc, repetitionIndex !== null && repetitionIndex !== void 0 ? repetitionIndex : []);
2400
+ }
2401
+ }
2402
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2403
+ finally {
2404
+ try {
2405
+ if (states_2_1 && !states_2_1.done && (_a = states_2["return"])) _a.call(states_2);
2406
+ }
2407
+ finally { if (e_2) throw e_2.error; }
2408
+ }
2409
+ }
2410
+ function generateStateOnChangeProp($state, path) {
2411
+ return function (val) { return set($state, path, val); };
2412
+ }
2413
+ function generateStateOnChangePropForCodeComponents($state, stateName, plasmicStatePath, componentHelpers) {
2414
+ var _a, _b;
2415
+ var onChangeArgsToValue = (_b = (_a = componentHelpers === null || componentHelpers === void 0 ? void 0 : componentHelpers.states) === null || _a === void 0 ? void 0 : _a[stateName]) === null || _b === void 0 ? void 0 : _b.onChangeArgsToValue;
2416
+ if (!onChangeArgsToValue || typeof onChangeArgsToValue !== "function") {
2417
+ return generateStateOnChangeProp($state, plasmicStatePath);
2418
+ }
2419
+ return function () {
2420
+ var args = [];
2421
+ for (var _i = 0; _i < arguments.length; _i++) {
2422
+ args[_i] = arguments[_i];
2423
+ }
2424
+ return generateStateOnChangeProp($state, plasmicStatePath)(onChangeArgsToValue.apply(null, args));
2425
+ };
2426
+ }
2427
+ function generateStateValueProp($state, path) {
2428
+ return get__default['default']($state, path);
2429
+ }
2430
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
2431
+ function isPlasmicStateProxy(obj) {
2432
+ return (obj != null && typeof obj === "object" && !!obj[PLASMIC_STATE_PROXY_SYMBOL]);
2433
+ }
2434
+ function is$StateProxy(obj) {
2435
+ return (obj != null &&
2436
+ typeof obj === "object" &&
2437
+ (!!obj[PLASMIC_STATE_PROXY_SYMBOL] || valtio.getVersion(obj)));
2438
+ }
2439
+ function getStateCells($state, root) {
2440
+ var e_3, _a;
2441
+ var _b;
2442
+ if ($state == null || typeof $state !== "object") {
2443
+ return [];
2444
+ }
2445
+ if (root.hasArrayTransition()) {
2446
+ return Object.keys($state).flatMap(function (key) {
2447
+ return getStateCells($state[key], ensure(root.makeTransition(ARRAY_SYMBOL)));
2448
+ });
2449
+ }
2450
+ else {
2451
+ var stateCell = (_b = proxyObjToStateCell.get($state)) !== null && _b !== void 0 ? _b : {};
2452
+ var stateCells = [];
2453
+ try {
2454
+ for (var _c = __values(root.edges().entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
2455
+ var _e = __read(_d.value, 2), key = _e[0], child = _e[1];
2456
+ if (typeof key === "string" && key in $state) {
2457
+ stateCells.push.apply(stateCells, __spreadArray([], __read(getStateCells($state[key], child)), false));
2458
+ if (key in stateCell) {
2459
+ stateCells.push(stateCell[key]);
2460
+ }
2461
+ }
2462
+ }
2463
+ }
2464
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
2465
+ finally {
2466
+ try {
2467
+ if (_d && !_d.done && (_a = _c["return"])) _a.call(_c);
2468
+ }
2469
+ finally { if (e_3) throw e_3.error; }
2470
+ }
2471
+ return stateCells;
2472
+ }
2473
+ }
2474
+ function getStateCellsInPlasmicProxy(obj) {
2475
+ if (!isPlasmicStateProxy(obj)) {
2476
+ return [];
2477
+ }
2478
+ var _a = obj[PLASMIC_STATE_PROXY_SYMBOL], rootNode = _a.node, rootPath = _a.path, isOutside = _a.isOutside;
2479
+ if (isOutside) {
2480
+ return [];
2481
+ }
2482
+ return getStateCells(obj, rootNode).map(function (stateCell) { return ({
2483
+ path: stateCell.node.getSpec().path,
2484
+ realPath: stateCell.path.slice(rootPath.length)
2485
+ }); });
2486
+ }
2487
+ function getStateSpecInPlasmicProxy(obj, path) {
2488
+ obj = get__default['default'](obj, path.slice(0, path.length - 1));
2489
+ if (!isPlasmicStateProxy(obj)) {
2490
+ return undefined;
2491
+ }
2492
+ var node = obj[PLASMIC_STATE_PROXY_SYMBOL].node;
2493
+ var nextNode = node.makeTransition(path[path.length - 1]);
2494
+ if (node.isLeaf() || !nextNode) {
2495
+ return undefined;
2496
+ }
2497
+ return {
2498
+ spec: nextNode.getSpec(),
2499
+ isImplicitStateArray: nextNode.hasArrayTransition()
2500
+ };
2501
+ }
2502
+ function getCurrentInitialValue(obj, path) {
2503
+ var _a;
2504
+ if (!isPlasmicStateProxy(obj)) {
2505
+ return undefined;
2506
+ }
2507
+ return (_a = tryGetStateCellFrom$StateRoot(obj, path)) === null || _a === void 0 ? void 0 : _a.initialValue;
2508
+ }
2509
+ function resetToInitialValue(obj, path) {
2510
+ var stateCell = tryGetStateCellFrom$StateRoot(obj, path);
2511
+ if (stateCell) {
2512
+ set(obj, path, stateCell.initialValue);
2513
+ }
2514
+ }
2515
+ function shallowEqual(a1, a2) {
2516
+ if (a1.length !== a2.length) {
2517
+ return false;
2518
+ }
2519
+ for (var i = 0; i < a1.length; i++) {
2520
+ if (a1[i] !== a2[i]) {
2521
+ return false;
2522
+ }
2523
+ }
2524
+ return true;
2525
+ }
2526
+ /**
2527
+ * Shallow comparison of arrays.
2528
+ */
2529
+ function arrayEq(xs, ys) {
2530
+ return (xs.length === ys.length && xs.every(function (_, index) { return xs[index] === ys[index]; }));
2531
+ }
2532
+ function isNum(value) {
2533
+ return typeof value === "symbol" ? false : !isNaN(+value);
2534
+ }
2535
+ /**
2536
+ * Forked from https://github.com/lukeed/dset
2537
+ * Changes: fixed setting a deep value to a proxy object
2538
+ */
2539
+ function set(obj, keys, val) {
2540
+ keys = keys.split ? keys.split(".") : keys;
2541
+ var i = 0, l = keys.length, t = obj, x, k;
2542
+ while (i < l) {
2543
+ k = keys[i++];
2544
+ if (k === "__proto__" || k === "constructor" || k === "prototype")
2545
+ break;
2546
+ var newValue = i === l
2547
+ ? val
2548
+ : typeof (x = t[k]) === typeof keys
2549
+ ? x
2550
+ : keys[i] * 0 !== 0 || !!~("" + keys[i]).indexOf(".")
2551
+ ? {}
2552
+ : [];
2553
+ assignValue(t, k, newValue);
2554
+ t = t[k];
2555
+ }
2556
+ }
2557
+ /**
2558
+ * Forked from lodash
2559
+ */
2560
+ function baseAssignValue(object, key, value) {
2561
+ if (key == "__proto__") {
2562
+ Object.defineProperty(object, key, {
2563
+ configurable: true,
2564
+ enumerable: true,
2565
+ value: value,
2566
+ writable: true
2567
+ });
2568
+ }
2569
+ else {
2570
+ object[key] = value;
2571
+ }
2572
+ }
2573
+ function eq(value, other) {
2574
+ return value === other || (value !== value && other !== other);
2575
+ }
2576
+ function assignValue(object, key, value) {
2577
+ var objValue = object[key];
2578
+ if (!(Object.prototype.hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2579
+ (value === undefined && !(key in object))) {
2580
+ baseAssignValue(object, key, value);
2581
+ }
2582
+ }
2583
+
2584
+ // Utilities used by generated code
2585
+ var classNames = classNames__default['default'];
2586
+
2587
+ var PLUME_STRICT_MODE = true;
2588
+ function setPlumeStrictMode(mode) {
2589
+ PLUME_STRICT_MODE = mode;
2590
+ }
2591
+ function mergeVariantToggles() {
2592
+ var toggles = [];
2593
+ for (var _i = 0; _i < arguments.length; _i++) {
2594
+ toggles[_i] = arguments[_i];
2595
+ }
2596
+ var definedToggles = toggles.filter(function (x) { return !!x.def; });
2597
+ var grouped = groupBy(definedToggles, function (_a) {
2598
+ var def = _a.def;
2599
+ return def.group;
2600
+ });
2601
+ return mapValues(grouped, function (subToggles) {
2602
+ return Object.fromEntries(subToggles.map(function (_a) {
2603
+ var def = _a.def, active = _a.active;
2604
+ return [def.variant, !!active];
2605
+ }));
2606
+ });
2607
+ }
2608
+ function noOutline() {
2609
+ return { outline: "none" };
2610
+ }
2611
+ function getPlumeType(child) {
2612
+ var _a;
2613
+ if (!React__namespace.isValidElement(child)) {
2614
+ return undefined;
2615
+ }
2616
+ var childType = child.type;
2617
+ return (childType.__plumeType || ((_a = childType.getPlumeType) === null || _a === void 0 ? void 0 : _a.call(childType, child.props)));
2618
+ }
2619
+
2620
+ function useButton(plasmicClass, props, config, ref) {
2621
+ var _a, _b, _c, _d;
2622
+ if (ref === void 0) { ref = null; }
2623
+ var link = props.link, isDisabled = props.isDisabled, startIcon = props.startIcon, endIcon = props.endIcon, showStartIcon = props.showStartIcon, showEndIcon = props.showEndIcon, children = props.children, rest = __rest(props, ["link", "isDisabled", "startIcon", "endIcon", "showStartIcon", "showEndIcon", "children"]);
2624
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.showStartIconVariant, active: showStartIcon }, { def: config.showEndIconVariant, active: showEndIcon }, { def: config.isDisabledVariant, active: isDisabled }));
2625
+ var args = __assign(__assign(__assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (config.startIconSlot && (_a = {}, _a[config.startIconSlot] = startIcon, _a))), (config.endIconSlot && (_b = {}, _b[config.endIconSlot] = endIcon, _b))), (_c = {}, _c[config.contentSlot] = children, _c));
2626
+ var overrides = (_d = {},
2627
+ _d[config.root] = {
2628
+ as: !!link ? "a" : "button",
2629
+ props: __assign(__assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([rest], __read(plasmicClass.internalArgProps), false), __read(plasmicClass.internalVariantProps), false))), { ref: ref, disabled: isDisabled }), (!!link && { href: link }))
2630
+ },
2631
+ _d);
2632
+ return {
2633
+ plasmicProps: {
2634
+ variants: variants,
2635
+ args: args,
2636
+ overrides: overrides
2637
+ }
2638
+ };
2639
+ }
2640
+
2641
+ function getStyleProps(props) {
2642
+ return pick(props, "className", "style");
2643
+ }
2644
+ function getDefaultPlasmicProps(plasmicClass, props) {
2645
+ return {
2646
+ plasmicProps: {
2647
+ variants: pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false)),
2648
+ args: pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false)),
2649
+ overrides: {}
2650
+ }
2651
+ };
2652
+ }
2653
+ var RE_DATA_PROP = /^(data-.*)$/;
2654
+ function getDataProps(props) {
2655
+ return pickBy(props, function (k) { return RE_DATA_PROP.test(k); });
2656
+ }
2657
+
2658
+ function asAriaCheckboxProps(props) {
2659
+ var ariaProps = __assign(__assign({}, props), { isSelected: props.isChecked, defaultSelected: props.defaultChecked });
2660
+ delete ariaProps["isChecked"];
2661
+ delete ariaProps["defaultChecked"];
2662
+ return ariaProps;
2663
+ }
2664
+ function useCheckbox(plasmicClass, props, config, ref) {
2665
+ var _a, _b;
2666
+ if (ref === void 0) { ref = null; }
2667
+ var children = props.children, isDisabled = props.isDisabled, isIndeterminate = props.isIndeterminate;
2668
+ useEnsureSSRProvider();
2669
+ var inputRef = React__namespace.useRef(null);
2670
+ var rootRef = React__namespace.useRef(null);
2671
+ var ariaProps = asAriaCheckboxProps(props);
2672
+ var state = toggle.useToggleState(ariaProps);
2673
+ var inputProps = checkbox.useCheckbox(ariaProps, state, inputRef).inputProps;
2674
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({
2675
+ def: config.isDisabledVariant,
2676
+ active: isDisabled
2677
+ }, {
2678
+ def: config.isCheckedVariant,
2679
+ active: state.isSelected
2680
+ }, {
2681
+ def: config.isIndeterminateVariant,
2682
+ active: isIndeterminate
2683
+ }, {
2684
+ def: config.noLabelVariant,
2685
+ active: !children
2686
+ }));
2687
+ var overrides = (_a = {},
2688
+ _a[config.root] = {
2689
+ as: "label",
2690
+ props: mergeProps(getStyleProps(props), {
2691
+ ref: rootRef
2692
+ }),
2693
+ wrapChildren: function (children) { return (React__namespace.createElement(React__namespace.Fragment, null,
2694
+ React__namespace.createElement(visuallyHidden.VisuallyHidden, null,
2695
+ React__namespace.createElement("input", __assign({}, inputProps, { ref: inputRef }))),
2696
+ children)); }
2697
+ },
2698
+ _a);
2699
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (config.labelSlot ? (_b = {}, _b[config.labelSlot] = children, _b) : {}));
2700
+ var plumeState = React__namespace.useMemo(function () { return ({
2701
+ setChecked: function (checked) { return state.setSelected(checked); }
2702
+ }); }, [state]);
2703
+ React__namespace.useImperativeHandle(ref, function () { return ({
2704
+ getRoot: function () { return rootRef.current; },
2705
+ focus: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2706
+ blur: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2707
+ setChecked: function (checked) { return plumeState.setChecked(checked); }
2708
+ }); }, [rootRef, inputRef, plumeState]);
2709
+ return {
2710
+ plasmicProps: {
2711
+ variants: variants,
2712
+ overrides: overrides,
2713
+ args: args
2714
+ },
2715
+ state: plumeState
2716
+ };
2717
+ }
2718
+
2719
+ /**
2720
+ * In general, we try not to expose react-aria's Collections API to Plume users.
2721
+ * The Collections API is how react-aria users pass data about collections of
2722
+ * things using the built-in Item and Section components, which are abstract,
2723
+ * metadata-only components that don't render anything but only serve to specify
2724
+ * data. For example, here's how you would use react-spectrum's Picker:
2725
+ *
2726
+ * <Picker>
2727
+ * <Section title="Asia">
2728
+ * <Item key="taiwan">Taiwan</Item>
2729
+ * <Item key="japan">Japan</Item>
2730
+ * <Item key="china">China</Item>
2731
+ * </Section>
2732
+ * <Section title="Europe">
2733
+ * <Item key="germany">Germany</Item>
2734
+ * <Item key="france">France</Item>
2735
+ * </Section>
2736
+ * </Picker>
2737
+ *
2738
+ * You would re-use this same Item/Section components to pass similar things to
2739
+ * Menu, Tabs, etc.
2740
+ *
2741
+ * For Plasmic, this API is too abstract. The user has explicitly designed components
2742
+ * like Select.Option and Select.OptionGroup, and it is weird that they don't actually
2743
+ * use these components. It is more natural to do:
2744
+ *
2745
+ * <Select>
2746
+ * <Select.OptionGroup title="Asia">
2747
+ * <Select.Option key="taiwan">Taiwan</Select>
2748
+ * </Select.OptionGroup>
2749
+ * </Select>
2750
+ *
2751
+ * For Plume, we let users directly use the components they designed, both to collect
2752
+ * information and to perform actual rendering. For example, for Plume,
2753
+ * you'd use Select.Option instead of Item, and Select.OptionGroup instead of Section.
2754
+ * This means that the Select.Option props will collect the same information Item
2755
+ * does.
2756
+ *
2757
+ * A component like Select.Option then serves two purposes:
2758
+ *
2759
+ * 1. Allow users to specify the collection of data, like in the above example
2760
+ * Here, we're mainly interested in the props in those ReactElements so
2761
+ * we can pass the Item/Section data onto react-aria's APIs. We are not
2762
+ * actually rendering these elements.
2763
+ * 2. Once react-aria's Collections API has gone through them and built
2764
+ * Collection "nodes", we then create cloned versions of these elements
2765
+ * with the corresponding node passed in as a secret prop. These ReactElements
2766
+ * are then actually used to _render_ the corresponding Option / OptionGroup.
2767
+ *
2768
+ * This file contains helper functions to help with implementing the above.
2769
+ *
2770
+ * Note also that most of the collections-based react-aria components expose
2771
+ * a parallel API that accepts a list of "items" and a render prop, instead
2772
+ * of list of Item/Section elements. This is for efficiency, but we are opting
2773
+ * to only support the composite-component pattern for now for simplicity.
2774
+ */
2775
+ function deriveItemsFromProps(props, opts) {
2776
+ if (opts.itemsProp && opts.itemsProp in props) {
2777
+ if (!opts.ItemComponent || !opts.SectionComponent) {
2778
+ throw new Error("You may need to re-generate your Plasmic* files");
2779
+ }
2780
+ var items = props[opts.itemsProp];
2781
+ return deriveItemsFromItemsProp(items, {
2782
+ ItemComponent: opts.ItemComponent,
2783
+ SectionComponent: opts.SectionComponent
2784
+ });
2785
+ }
2786
+ else {
2787
+ return deriveItemsFromChildren(props.children, opts);
2788
+ }
2789
+ }
2790
+ function deriveItemsFromItemsProp(items, opts) {
2791
+ var _a;
2792
+ var ItemComponent = opts.ItemComponent, SectionComponent = opts.SectionComponent;
2793
+ var disabledKeys = [];
2794
+ var transform = function (item) {
2795
+ var _a;
2796
+ if (typeof item === "string") {
2797
+ return (React__default['default'].createElement(ItemComponent, { key: item, value: item }, item));
2798
+ }
2799
+ else if ("children" in item) {
2800
+ return (React__default['default'].createElement(SectionComponent, { key: item.title, title: item.title }, item.children.map(function (x) { return transform(x); })));
2801
+ }
2802
+ else {
2803
+ if (item.isDisabled) {
2804
+ disabledKeys.push(item.value);
2805
+ }
2806
+ return (React__default['default'].createElement(ItemComponent, { key: item.value, value: item.value, textValue: item.textValue, isDisabled: item.isDisabled }, (_a = item.label) !== null && _a !== void 0 ? _a : item.value));
2807
+ }
2808
+ };
2809
+ return {
2810
+ items: (_a = items === null || items === void 0 ? void 0 : items.map(function (x) { return transform(x); })) !== null && _a !== void 0 ? _a : [],
2811
+ disabledKeys: disabledKeys
2812
+ };
2813
+ }
2814
+ /**
2815
+ * Given children of a component like Select or Menu, derive the items
2816
+ * that we will pass into the Collections API. These will be
2817
+ * ReactElement<ItemLikeProps|SectionLikeProps>[].
2818
+ *
2819
+ * Will also assign keys to items by their index in the collection,
2820
+ * and collect the keys of disabled items.
2821
+ */
2822
+ function deriveItemsFromChildren(children, opts) {
2823
+ if (!children) {
2824
+ return {
2825
+ items: [],
2826
+ disabledKeys: []
2827
+ };
2828
+ }
2829
+ var itemPlumeType = opts.itemPlumeType, sectionPlumeType = opts.sectionPlumeType, invalidChildError = opts.invalidChildError;
2830
+ // For Plume items without an explicit key, we assign a key as the index
2831
+ // of the collection.
2832
+ var itemCount = 0;
2833
+ var sectionCount = 0;
2834
+ var ensureValue = function (element) {
2835
+ if (!propInChild(element, "value")) {
2836
+ if (opts.requireItemValue && PLUME_STRICT_MODE) {
2837
+ throw new Error("Must specify a \"value\" prop for ".concat(getElementTypeName(element)));
2838
+ }
2839
+ else {
2840
+ return cloneChild(element, { value: "".concat(itemCount++) });
2841
+ }
2842
+ }
2843
+ else {
2844
+ // Still increment count even if key is present, so that the
2845
+ // auto-assigned key really reflects the index
2846
+ itemCount++;
2847
+ return element;
2848
+ }
2849
+ };
2850
+ var disabledKeys = [];
2851
+ var flattenedChildren = function (children) {
2852
+ return toChildArray(children).flatMap(function (child) {
2853
+ var _a;
2854
+ if (React__default['default'].isValidElement(child)) {
2855
+ if (child.type === React__default['default'].Fragment) {
2856
+ return flattenedChildren(child.props
2857
+ .children);
2858
+ }
2859
+ var type = getPlumeType(child);
2860
+ if (type === itemPlumeType) {
2861
+ child = ensureValue(child);
2862
+ var childKey = getItemLikeKey(child);
2863
+ if (getChildProp(child, "isDisabled") && !!childKey) {
2864
+ disabledKeys.push(childKey);
2865
+ }
2866
+ return [child];
2867
+ }
2868
+ if (type === sectionPlumeType) {
2869
+ return [
2870
+ cloneChild(child, {
2871
+ // key of section doesn't actually matter, just needs
2872
+ // to be unique
2873
+ key: (_a = child.key) !== null && _a !== void 0 ? _a : "section-".concat(sectionCount++),
2874
+ children: flattenedChildren(getChildProp(child, "children"))
2875
+ }),
2876
+ ];
2877
+ }
2878
+ }
2879
+ if (PLUME_STRICT_MODE) {
2880
+ throw new Error(invalidChildError !== null && invalidChildError !== void 0 ? invalidChildError : "Unexpected child");
2881
+ }
2882
+ else {
2883
+ return [];
2884
+ }
2885
+ });
2886
+ };
2887
+ return { items: flattenedChildren(children), disabledKeys: disabledKeys };
2888
+ }
2889
+ function useDerivedItems(props, opts) {
2890
+ var children = props.children;
2891
+ var itemPlumeType = opts.itemPlumeType, sectionPlumeType = opts.sectionPlumeType, invalidChildError = opts.invalidChildError, requireItemValue = opts.requireItemValue, ItemComponent = opts.ItemComponent, SectionComponent = opts.SectionComponent, itemsProp = opts.itemsProp;
2892
+ var items = itemsProp ? props[itemsProp] : undefined;
2893
+ return React__default['default'].useMemo(function () {
2894
+ return deriveItemsFromProps(props, {
2895
+ itemPlumeType: itemPlumeType,
2896
+ sectionPlumeType: sectionPlumeType,
2897
+ invalidChildError: invalidChildError,
2898
+ requireItemValue: requireItemValue,
2899
+ itemsProp: itemsProp,
2900
+ ItemComponent: ItemComponent,
2901
+ SectionComponent: SectionComponent
2902
+ });
2903
+ }, [
2904
+ children,
2905
+ items,
2906
+ itemPlumeType,
2907
+ sectionPlumeType,
2908
+ invalidChildError,
2909
+ requireItemValue,
2910
+ ItemComponent,
2911
+ SectionComponent,
2912
+ ]);
2913
+ }
2914
+ function useDerivedItemsFromChildren(children, opts) {
2915
+ var itemPlumeType = opts.itemPlumeType, sectionPlumeType = opts.sectionPlumeType, invalidChildError = opts.invalidChildError, requireItemValue = opts.requireItemValue;
2916
+ return React__default['default'].useMemo(function () {
2917
+ return deriveItemsFromChildren(children, {
2918
+ itemPlumeType: itemPlumeType,
2919
+ sectionPlumeType: sectionPlumeType,
2920
+ invalidChildError: invalidChildError,
2921
+ requireItemValue: requireItemValue
2922
+ });
2923
+ }, [
2924
+ children,
2925
+ itemPlumeType,
2926
+ sectionPlumeType,
2927
+ invalidChildError,
2928
+ requireItemValue,
2929
+ ]);
2930
+ }
2931
+ /**
2932
+ * Given a Collection node, create the React element that we should use
2933
+ * to render it.
2934
+ */
2935
+ function renderCollectionNode(node) {
2936
+ // node.rendered should already have our item-like or section-like Plume
2937
+ // component elements, so we just need to clone them with a secret
2938
+ // _node prop that we use to render.
2939
+ return cloneChild(node.rendered, {
2940
+ _node: node,
2941
+ key: node.key
2942
+ });
2943
+ }
2944
+ /**
2945
+ * Renders a item-like or section-like Plume component element into an
2946
+ * Item or a Section element.
2947
+ */
2948
+ function renderAsCollectionChild(child, opts) {
2949
+ var _a;
2950
+ var plumeType = getPlumeType(child);
2951
+ if (plumeType === opts.itemPlumeType) {
2952
+ var option = child;
2953
+ // We look at the children passed to the item-like element, and derive key
2954
+ // or textValue from it if it is a string
2955
+ var content = getChildProp(option, "children");
2956
+ // The children render prop needs to return an <Item/>
2957
+ return (React__default['default'].createElement(collections.Item
2958
+ // We use ItemLike.value if the user explicitly specified a value,
2959
+ // and we fallback to key. If the user specified neither, then
2960
+ // the Collections API will generate a unique key for this item.
2961
+ , {
2962
+ // We use ItemLike.value if the user explicitly specified a value,
2963
+ // and we fallback to key. If the user specified neither, then
2964
+ // the Collections API will generate a unique key for this item.
2965
+ key: getItemLikeKey(option),
2966
+ // textValue is either explicitly specified by the user, or we
2967
+ // try to derive it if `content` is a string.
2968
+ textValue: (_a = getChildProp(option, "textValue")) !== null && _a !== void 0 ? _a : (isString(content)
2969
+ ? content
2970
+ : propInChild(option, "value")
2971
+ ? getChildProp(option, "value")
2972
+ : option.key), "aria-label": getChildProp(option, "aria-label") }, option));
2973
+ }
2974
+ else {
2975
+ var group = child;
2976
+ return (React__default['default'].createElement(collections.Section
2977
+ // Note that we are using the whole section-like element as the title
2978
+ // here, and not group.props.title; we want the entire section-like
2979
+ // Plume element to end up as Node.rendered.
2980
+ , {
2981
+ // Note that we are using the whole section-like element as the title
2982
+ // here, and not group.props.title; we want the entire section-like
2983
+ // Plume element to end up as Node.rendered.
2984
+ title: group, "aria-label": getChildProp(group, "aria-label"),
2985
+ // We are flattening and deriving the descendant Options as items here.
2986
+ // group.props.children should've already been cleaned up by
2987
+ // deriveItemsFromChildren()
2988
+ items: getChildProp(group, "children") }, function (c) { return renderAsCollectionChild(c, opts); }));
2989
+ }
2990
+ }
2991
+ function getItemLikeKey(element) {
2992
+ var _a;
2993
+ return (_a = getChildProp(element, "value")) !== null && _a !== void 0 ? _a : element.key;
2994
+ }
2995
+ // PlasmicLoader-aware function to get prop from child.
2996
+ function getChildProp(child, prop) {
2997
+ return "componentProps" in child.props
2998
+ ? child.props.componentProps[prop]
2999
+ : child.props[prop];
3000
+ }
3001
+ // PlasmicLoader-aware function to check `if (prop in element.props)`.
3002
+ function propInChild(child, prop) {
3003
+ return "componentProps" in child.props
3004
+ ? prop in child.props.componentProps
3005
+ : prop in child.props;
3006
+ }
3007
+ // PlasmicLoader-aware function to clone React element.
3008
+ function cloneChild(child, props) {
3009
+ if (child.type.getPlumeType) {
3010
+ // If React element has getPlumeType(), assume that it is PlasmicLoader,
3011
+ // so add nodeProps to componentProps instead of element props.
3012
+ return React__default['default'].cloneElement(child, __assign({ componentProps: __assign(__assign({}, child.props.componentProps), props) }, (props.key ? { key: props.key } : {})));
3013
+ }
3014
+ return React__default['default'].cloneElement(child, props);
3015
+ }
3016
+
3017
+ var TriggeredOverlayContext = React__namespace.createContext(undefined);
3018
+
3019
+ var MenuContext = React__namespace.createContext(undefined);
3020
+
3021
+ var COLLECTION_OPTS$1 = {
3022
+ itemPlumeType: "menu-item",
3023
+ sectionPlumeType: "menu-group"
3024
+ };
3025
+ /**
3026
+ * Converts props from BaseMenuProps to react-aria's useMenu() props.
3027
+ */
3028
+ function asAriaMenuProps(props) {
3029
+ var children = props.children, rest = __rest(props, ["children"]);
3030
+ var _a = useDerivedItemsFromChildren(children, __assign(__assign({}, COLLECTION_OPTS$1), { invalidChildError: "Can only use Menu.Item and Menu.Group as children to Menu", requireItemValue: false })), items = _a.items, disabledKeys = _a.disabledKeys;
3031
+ var collectionChildRenderer = React__namespace.useCallback(function (child) { return renderAsCollectionChild(child, COLLECTION_OPTS$1); }, []);
3032
+ return {
3033
+ ariaProps: __assign(__assign({}, rest), { children: collectionChildRenderer, items: items, disabledKeys: disabledKeys })
3034
+ };
3035
+ }
3036
+ function useMenu(plasmicClass, props, config, ref) {
3037
+ var _a, _b;
3038
+ if (ref === void 0) { ref = null; }
3039
+ useEnsureSSRProvider();
3040
+ var ariaProps = asAriaMenuProps(props).ariaProps;
3041
+ var triggerContext = React__namespace.useContext(TriggeredOverlayContext);
3042
+ var rootRef = React__namespace.useRef(null);
3043
+ var state = tree.useTreeState(ariaProps);
3044
+ var menuListRef = React__namespace.useRef(null);
3045
+ var menuProps = menu.useMenu(__assign(__assign({}, ariaProps), { autoFocus: triggerContext === null || triggerContext === void 0 ? void 0 : triggerContext.autoFocus }), state, menuListRef).menuProps;
3046
+ var contextValue = React__namespace.useMemo(function () { return ({ state: state, menuProps: props }); }, [
3047
+ state,
3048
+ props,
3049
+ ]);
3050
+ var variants = __assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false)));
3051
+ var overrides = (_a = {},
3052
+ _a[config.root] = {
3053
+ props: mergeProps(getStyleProps(props), {
3054
+ ref: rootRef
3055
+ })
3056
+ },
3057
+ _a[config.itemsContainer] = {
3058
+ as: "ul",
3059
+ props: mergeProps(menuProps, {
3060
+ ref: menuListRef,
3061
+ style: __assign({}, noOutline())
3062
+ })
3063
+ },
3064
+ _a);
3065
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_b = {}, _b[config.itemsSlot] = (React__namespace.createElement(MenuContext.Provider, { value: contextValue }, Array.from(state.collection).map(function (node) { return renderCollectionNode(node); }))), _b));
3066
+ var plumeState = React__namespace.useMemo(function () { return ({
3067
+ getFocusedValue: function () { return state.selectionManager.focusedKey; },
3068
+ setFocusedValue: function (value) {
3069
+ return state.selectionManager.setFocusedKey(value);
3070
+ }
3071
+ }); }, [state]);
3072
+ React__namespace.useImperativeHandle(ref, function () { return ({
3073
+ getRoot: function () { return rootRef.current; },
3074
+ getFocusedValue: function () { return plumeState.getFocusedValue(); },
3075
+ setFocusedValue: function (key) { return plumeState.setFocusedValue(key); }
3076
+ }); }, [rootRef, plumeState]);
3077
+ return {
3078
+ plasmicProps: {
3079
+ variants: variants,
3080
+ args: args,
3081
+ overrides: overrides
3082
+ },
3083
+ state: plumeState
3084
+ };
3085
+ }
3086
+
3087
+ function useMenuGroup(plasmicClass, props, config) {
3088
+ var _a, _b;
3089
+ var context = React__namespace.useContext(MenuContext);
3090
+ var node = props._node;
3091
+ if (!context || !node) {
3092
+ if (PLUME_STRICT_MODE) {
3093
+ throw new Error("You can only use a Menu.Group within a Menu component.");
3094
+ }
3095
+ return getDefaultPlasmicProps(plasmicClass, props);
3096
+ }
3097
+ var _c = menu.useMenuSection({
3098
+ heading: props.title,
3099
+ "aria-label": props["aria-label"]
3100
+ }), headingProps = _c.headingProps, groupProps = _c.groupProps;
3101
+ var separatorProps = separator.useSeparator({
3102
+ elementType: "li"
3103
+ }).separatorProps;
3104
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.noTitleVariant, active: !props.title }, {
3105
+ def: config.isFirstVariant,
3106
+ active: context.state.collection.getFirstKey() === node.key
3107
+ }));
3108
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.titleSlot] = props.title, _a[config.itemsSlot] = Array.from(node.childNodes).map(function (childNode) {
3109
+ return renderCollectionNode(childNode);
3110
+ }), _a));
3111
+ var overrides = (_b = {},
3112
+ _b[config.root] = {
3113
+ props: getStyleProps(props)
3114
+ },
3115
+ _b[config.separator] = {
3116
+ props: __assign({}, separatorProps),
3117
+ as: "li"
3118
+ },
3119
+ _b[config.titleContainer] = __assign({ props: __assign({ role: "presentation" }, headingProps) }, (!props.title && {
3120
+ render: function () { return null; }
3121
+ })),
3122
+ _b[config.itemsContainer] = {
3123
+ props: __assign({}, groupProps),
3124
+ as: "ul"
3125
+ },
3126
+ _b);
3127
+ return {
3128
+ plasmicProps: {
3129
+ variants: variants,
3130
+ args: args,
3131
+ overrides: overrides
3132
+ }
3133
+ };
3134
+ }
3135
+
3136
+ function useMenuItem(plasmicClass, props, config) {
3137
+ var _a, _b;
3138
+ var menuContext = React__namespace.useContext(MenuContext);
3139
+ var triggerContext = React__namespace.useContext(TriggeredOverlayContext);
3140
+ if (!menuContext) {
3141
+ if (PLUME_STRICT_MODE) {
3142
+ throw new Error("You can only use a Menu.Item within a Menu component.");
3143
+ }
3144
+ return getDefaultPlasmicProps(plasmicClass, props);
3145
+ }
3146
+ var children = props.children, onAction = props.onAction;
3147
+ var state = menuContext.state, menuProps = menuContext.menuProps;
3148
+ // We pass in the Node secretly as an undocumented prop from <Select />
3149
+ var node = props._node;
3150
+ var isDisabled = state.disabledKeys.has(node.key);
3151
+ var isHighlighted = state.selectionManager.isFocused &&
3152
+ state.selectionManager.focusedKey === node.key;
3153
+ var ref = React__namespace.useRef(null);
3154
+ var _c = menu.useMenuItem(mergeProps({
3155
+ // We need to merge both the onAction on MenuItem and the onAction
3156
+ // on Menu
3157
+ onAction: onAction
3158
+ }, {
3159
+ onAction: menuProps.onAction,
3160
+ onClose: triggerContext === null || triggerContext === void 0 ? void 0 : triggerContext.state.close
3161
+ }, {
3162
+ isDisabled: isDisabled,
3163
+ "aria-label": node && node["aria-label"],
3164
+ key: node.key,
3165
+ isVirtualized: false,
3166
+ closeOnSelect: true
3167
+ }), state, ref), menuItemProps = _c.menuItemProps, labelProps = _c.labelProps;
3168
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.isDisabledVariant, active: isDisabled }, { def: config.isHighlightedVariant, active: isHighlighted }));
3169
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.labelSlot] = children, _a));
3170
+ var overrides = (_b = {},
3171
+ _b[config.root] = {
3172
+ as: "li",
3173
+ props: mergeProps(menuItemProps, { ref: ref, style: noOutline() })
3174
+ },
3175
+ _b[config.labelContainer] = {
3176
+ props: __assign({}, labelProps)
3177
+ },
3178
+ _b);
3179
+ return {
3180
+ plasmicProps: {
3181
+ variants: variants,
3182
+ args: args,
3183
+ overrides: overrides
3184
+ }
3185
+ };
3186
+ }
3187
+
3188
+ /**
3189
+ * A menu trigger hook that combines react-aria's useMenuTrigger, useAriaMenuTrigger,
3190
+ * useOverlayPosition, useOverlay, and usePress
3191
+ */
3192
+ function useMenuTrigger(opts, state) {
3193
+ var triggerRef = opts.triggerRef, isDisabled = opts.isDisabled, placement = opts.placement, menuMatchTriggerWidth = opts.menuMatchTriggerWidth, menuWidth = opts.menuWidth, menu$1 = opts.menu;
3194
+ var _a = menu.useMenuTrigger({
3195
+ type: "menu",
3196
+ isDisabled: isDisabled
3197
+ }, state, triggerRef), triggerPressProps = _a.menuTriggerProps, menuProps = _a.menuProps;
3198
+ var triggerProps = interactions.usePress(__assign(__assign({}, triggerPressProps), { isDisabled: isDisabled })).pressProps;
3199
+ var makeMenu = function () {
3200
+ var realMenu = typeof menu$1 === "function" ? menu$1() : menu$1;
3201
+ if (!realMenu) {
3202
+ return null;
3203
+ }
3204
+ if (getPlumeType(realMenu) !== "menu") {
3205
+ if (PLUME_STRICT_MODE) {
3206
+ throw new Error("Must use an instance of the Menu component.");
3207
+ }
3208
+ return null;
3209
+ }
3210
+ return React__namespace.cloneElement(realMenu, mergeProps(realMenu.props, menuProps));
3211
+ };
3212
+ var triggerContext = React__namespace.useMemo(function () {
3213
+ var _a;
3214
+ return ({
3215
+ triggerRef: triggerRef,
3216
+ state: state,
3217
+ autoFocus: (_a = state.focusStrategy) !== null && _a !== void 0 ? _a : true,
3218
+ placement: placement,
3219
+ overlayMatchTriggerWidth: menuMatchTriggerWidth,
3220
+ overlayMinTriggerWidth: true,
3221
+ overlayWidth: menuWidth
3222
+ });
3223
+ }, [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]);
3224
+ return {
3225
+ triggerProps: triggerProps,
3226
+ makeMenu: makeMenu,
3227
+ triggerContext: triggerContext
3228
+ };
3229
+ }
3230
+
3231
+ function DropdownMenu(props) {
3232
+ var isOpen = props.isOpen, defaultOpen = props.defaultOpen, onOpenChange = props.onOpenChange, children = props.children, placement = props.placement, menu = props.menu;
3233
+ var triggerRef = React__namespace.useRef(null);
3234
+ var state = menu$1.useMenuTriggerState({
3235
+ isOpen: isOpen,
3236
+ defaultOpen: defaultOpen,
3237
+ onOpenChange: onOpenChange,
3238
+ shouldFlip: true
3239
+ });
3240
+ var _a = useMenuTrigger({
3241
+ triggerRef: triggerRef,
3242
+ placement: placement,
3243
+ menu: menu
3244
+ }, state), triggerProps = _a.triggerProps, makeMenu = _a.makeMenu, triggerContext = _a.triggerContext;
3245
+ return (React__namespace.createElement(TriggeredOverlayContext.Provider, { value: triggerContext },
3246
+ React__namespace.cloneElement(children, mergeProps(children.props, triggerProps, { ref: triggerRef })),
3247
+ state.isOpen && makeMenu()));
3248
+ }
3249
+
3250
+ function useMenuButton(plasmicClass, props, config, outerRef) {
3251
+ var _a, _b;
3252
+ if (outerRef === void 0) { outerRef = null; }
3253
+ var placement = props.placement, isOpen = props.isOpen, defaultOpen = props.defaultOpen, onOpenChange = props.onOpenChange, isDisabled = props.isDisabled, menu = props.menu, autoFocus = props.autoFocus, menuMatchTriggerWidth = props.menuMatchTriggerWidth, menuWidth = props.menuWidth;
3254
+ useEnsureSSRProvider();
3255
+ var rootRef = React__namespace.useRef(null);
3256
+ var triggerRef = React__namespace.useRef(null);
3257
+ var state = menu$1.useMenuTriggerState({
3258
+ isOpen: isOpen,
3259
+ defaultOpen: defaultOpen,
3260
+ onOpenChange: onOpenChange,
3261
+ shouldFlip: true
3262
+ });
3263
+ var _c = useMenuTrigger({
3264
+ isDisabled: isDisabled,
3265
+ triggerRef: triggerRef,
3266
+ placement: placement,
3267
+ menuMatchTriggerWidth: menuMatchTriggerWidth,
3268
+ menuWidth: menuWidth,
3269
+ menu: menu
3270
+ }, state), triggerProps = _c.triggerProps, makeMenu = _c.makeMenu, triggerContext = _c.triggerContext;
3271
+ var triggerFocusProps = focus.useFocusable(props, triggerRef).focusableProps;
3272
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.isOpenVariant, active: state.isOpen }, { def: config.isDisabledVariant, active: isDisabled }));
3273
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.menuSlot] = state.isOpen ? makeMenu() : undefined, _a));
3274
+ var overrides = (_b = {},
3275
+ _b[config.root] = {
3276
+ wrapChildren: function (children) { return (React__namespace.createElement(TriggeredOverlayContext.Provider, { value: triggerContext }, children)); },
3277
+ props: {
3278
+ ref: rootRef
3279
+ }
3280
+ },
3281
+ _b[config.trigger] = {
3282
+ props: mergeProps(triggerProps, triggerFocusProps, getStyleProps(props), pick(props, "title"), {
3283
+ ref: triggerRef,
3284
+ autoFocus: autoFocus,
3285
+ disabled: !!isDisabled,
3286
+ // Make sure this button is not interpreted as submit
3287
+ type: "button"
3288
+ })
3289
+ },
3290
+ _b);
3291
+ var plumeState = React__namespace.useMemo(function () { return ({
3292
+ open: function () { return state.open(); },
3293
+ close: function () { return state.close(); },
3294
+ isOpen: function () { return state.isOpen; }
3295
+ }); }, [state]);
3296
+ React__namespace.useImperativeHandle(outerRef, function () { return ({
3297
+ getRoot: function () { return rootRef.current; },
3298
+ getTrigger: function () { return triggerRef.current; },
3299
+ focus: function () { return triggerRef.current && triggerRef.current.focus(); },
3300
+ blur: function () { return triggerRef.current && triggerRef.current.blur(); },
3301
+ open: plumeState.open,
3302
+ close: plumeState.close,
3303
+ isOpen: plumeState.isOpen
3304
+ }); }, [rootRef, triggerRef, plumeState]);
3305
+ return {
3306
+ plasmicProps: {
3307
+ variants: variants,
3308
+ args: args,
3309
+ overrides: overrides
3310
+ },
3311
+ state: plumeState
3312
+ };
3313
+ }
3314
+
3315
+ var SelectContext = React__namespace.createContext(undefined);
3316
+
3317
+ var COLLECTION_OPTS = {
3318
+ itemPlumeType: "select-option",
3319
+ sectionPlumeType: "select-option-group"
3320
+ };
3321
+ /**
3322
+ * Converts props in our BaseSelectProps into props that react-aria's
3323
+ * useSelect() understands.
3324
+ *
3325
+ * Because we're not exposing the Collections API (see ./index.tsx),
3326
+ * we are converting our own API into props for useSelect.
3327
+ *
3328
+ * Specifically, in Plume's API,
3329
+ * - `children` flattens to a list of ReactElements of type Select.Option
3330
+ * or Select.OptionGroup
3331
+ *
3332
+ * and we map it this way to the Collections API:
3333
+ * - `items` is a list of those flattened ReactElements from `children`!
3334
+ * - `children`, as a render prop, is supposed to take one of the `items`
3335
+ * and return a `Section` or `Item` element. We take an Option/OptionGroup
3336
+ * element, and use its props to render the appropriate `Section` or
3337
+ * `Item`. The "trick" here is that we then stuff the Option element as
3338
+ * `Item.children`, and the OptionGroup element as `Section.title`.
3339
+ *
3340
+ * When the Collections API does its work deriving `Node`s, the corresponding
3341
+ * Option/OptionGroup ReactElements will end up as `Node.rendered`.
3342
+ *
3343
+ * Then, when we are actually rendering the content of the dropdown, we
3344
+ * iterate through each collected `Node`, and renders
3345
+ * React.cloneElement(Node.rendered, {_node: node}). This "secretly" passes
3346
+ * the derived collection `Node` as a prop to Option and OptionGroup, and they
3347
+ * can make use of the derived `Node.key` etc in their rendering functions.
3348
+ *
3349
+ * One thing to note here is that we never "rendered" the Option/OptionGroup
3350
+ * React elements that the user constructed; instead, we just looked at the
3351
+ * props used on those elements, and passed those onto the Collections API.
3352
+ * What gets rendered to the screen is the cloned version of these elements
3353
+ * with the secret derived `_node` prop. That means Option and OptionGroup
3354
+ * render functions can assume that _node is passed in.
3355
+ */
3356
+ function useAriaSelectProps(props, config) {
3357
+ var value = props.value, defaultValue = props.defaultValue; props.children; var onChange = props.onChange; props.placement; props.menuMatchTriggerWidth; props.menuWidth; var rest = __rest(props, ["value", "defaultValue", "children", "onChange", "placement", "menuMatchTriggerWidth", "menuWidth"]);
3358
+ var _a = useDerivedItems(props, __assign(__assign({}, COLLECTION_OPTS), { invalidChildError: "Can only use Select.Option and Select.OptionGroup as children to Select", requireItemValue: true, ItemComponent: config.OptionComponent, SectionComponent: config.OptionGroupComponent, itemsProp: "options" })), items = _a.items, disabledKeys = _a.disabledKeys;
3359
+ var collectionChildRenderer = React__namespace.useCallback(function (child) { return renderAsCollectionChild(child, COLLECTION_OPTS); }, []);
3360
+ var onSelectionChange = React__namespace.useMemo(function () {
3361
+ if (onChange) {
3362
+ return function (val) {
3363
+ return onChange((val == null || val === "null" ? null : val));
3364
+ };
3365
+ }
3366
+ else {
3367
+ return undefined;
3368
+ }
3369
+ }, [onChange]);
3370
+ return {
3371
+ ariaProps: __assign(__assign(__assign({}, rest), { children: collectionChildRenderer, onSelectionChange: onSelectionChange, items: items, disabledKeys: disabledKeys, defaultSelectedKey: defaultValue }), ("value" in props && { selectedKey: value !== null && value !== void 0 ? value : null }))
3372
+ };
3373
+ }
3374
+ function useSelect(plasmicClass, props, config, ref) {
3375
+ var _a, _b;
3376
+ if (ref === void 0) { ref = null; }
3377
+ useEnsureSSRProvider();
3378
+ var ariaProps = useAriaSelectProps(props, config).ariaProps;
3379
+ var placement = props.placement;
3380
+ var state = select.useSelectState(ariaProps);
3381
+ var triggerRef = React__namespace.useRef(null);
3382
+ var rootRef = React__namespace.useRef(null);
3383
+ var isDisabled = props.isDisabled, name = props.name, menuWidth = props.menuWidth, menuMatchTriggerWidth = props.menuMatchTriggerWidth, autoFocus = props.autoFocus, placeholder = props.placeholder, selectedContent = props.selectedContent;
3384
+ var canvasCtx = host.usePlasmicCanvasContext();
3385
+ var _c = select$1.useSelect(ariaProps, state, triggerRef), triggerPressProps = _c.triggerProps, menuProps = _c.menuProps;
3386
+ var triggerProps = interactions.usePress(__assign(__assign({}, triggerPressProps), { isDisabled: isDisabled })).pressProps;
3387
+ var triggerContent = state.selectedItem
3388
+ ? selectedContent !== null && selectedContent !== void 0 ? selectedContent : getChildProp(state.selectedItem.value, "children")
3389
+ : null;
3390
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.isOpenVariant, active: state.isOpen }, { def: config.placeholderVariant, active: !state.selectedItem }, { def: config.isDisabledVariant, active: isDisabled }));
3391
+ var triggerContext = React__namespace.useMemo(function () { return ({
3392
+ triggerRef: triggerRef,
3393
+ state: state,
3394
+ placement: placement,
3395
+ overlayMatchTriggerWidth: menuMatchTriggerWidth,
3396
+ overlayMinTriggerWidth: true,
3397
+ overlayWidth: menuWidth
3398
+ }); }, [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]);
3399
+ var overrides = (_a = {},
3400
+ _a[config.root] = {
3401
+ props: mergeProps(getStyleProps(props), {
3402
+ ref: rootRef
3403
+ }),
3404
+ wrapChildren: function (children) { return (React__namespace.createElement(React__namespace.Fragment, null,
3405
+ !canvasCtx && (React__namespace.createElement(select$1.HiddenSelect, { state: state, triggerRef: triggerRef, name: name, isDisabled: isDisabled })),
3406
+ children)); }
3407
+ },
3408
+ _a[config.trigger] = {
3409
+ props: mergeProps(canvasCtx ? {} : triggerProps, {
3410
+ ref: triggerRef,
3411
+ autoFocus: autoFocus,
3412
+ disabled: !!isDisabled,
3413
+ // Don't trigger form submission!
3414
+ type: "button"
3415
+ })
3416
+ },
3417
+ _a[config.overlay] = {
3418
+ wrap: function (content) { return (React__namespace.createElement(TriggeredOverlayContext.Provider, { value: triggerContext }, content)); }
3419
+ },
3420
+ _a[config.optionsContainer] = {
3421
+ wrap: function (content) { return (React__namespace.createElement(ListBoxWrapper, { state: state, menuProps: menuProps }, content)); }
3422
+ },
3423
+ _a);
3424
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_b = {}, _b[config.triggerContentSlot] = triggerContent, _b[config.placeholderSlot] = placeholder, _b[config.optionsSlot] = (React__namespace.createElement(SelectContext.Provider, { value: state }, Array.from(state.collection).map(function (node) { return renderCollectionNode(node); }))), _b));
3425
+ var plumeState = React__namespace.useMemo(function () { return ({
3426
+ open: function () { return state.open(); },
3427
+ close: function () { return state.close(); },
3428
+ isOpen: function () { return state.isOpen; },
3429
+ getSelectedValue: function () {
3430
+ return state.selectedKey ? "".concat(state.selectedKey) : null;
3431
+ },
3432
+ setSelectedValue: function (key) { return state.setSelectedKey(key); }
3433
+ }); }, [state]);
3434
+ React__namespace.useImperativeHandle(ref, function () { return ({
3435
+ getRoot: function () { return rootRef.current; },
3436
+ getTrigger: function () { return triggerRef.current; },
3437
+ focus: function () { var _a; return (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
3438
+ blur: function () { var _a; return (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
3439
+ open: function () { return plumeState.open(); },
3440
+ close: function () { return plumeState.close(); },
3441
+ isOpen: function () { return plumeState.isOpen(); },
3442
+ getSelectedValue: function () { return plumeState.getSelectedValue(); },
3443
+ setSelectedValue: function (key) { return plumeState.setSelectedValue(key); }
3444
+ }); }, [rootRef, triggerRef, plumeState]);
3445
+ return {
3446
+ plasmicProps: {
3447
+ variants: variants,
3448
+ args: args,
3449
+ overrides: overrides
3450
+ },
3451
+ state: plumeState
3452
+ };
3453
+ }
3454
+ function ListBoxWrapper(props) {
3455
+ var state = props.state, menuProps = props.menuProps, children = props.children;
3456
+ var ref = React__namespace.useRef(null);
3457
+ var canvasCtx = host.usePlasmicCanvasContext();
3458
+ var listBoxProps = listbox.useListBox(__assign(__assign({}, menuProps), { isVirtualized: false, autoFocus: state.focusStrategy || true, disallowEmptySelection: true }), state, ref).listBoxProps;
3459
+ return React__namespace.cloneElement(children, mergeProps(children.props, canvasCtx ? {} : listBoxProps, {
3460
+ style: noOutline(),
3461
+ ref: ref
3462
+ }));
3463
+ }
3464
+
3465
+ function useSelectOption(plasmicClass, props, config, outerRef) {
3466
+ var _a, _b;
3467
+ if (outerRef === void 0) { outerRef = null; }
3468
+ var state = React__namespace.useContext(SelectContext);
3469
+ if (!state) {
3470
+ // If no context, then we are being incorrectly used. Complain or just don't
3471
+ // bother installing any hooks. It's okay to violate rules of hooks here
3472
+ // because this instance won't suddenly be used correctly in another render.
3473
+ if (PLUME_STRICT_MODE) {
3474
+ throw new Error("You can only use a Select.Option within a Select component.");
3475
+ }
3476
+ return getDefaultPlasmicProps(plasmicClass, props);
3477
+ }
3478
+ var children = props.children;
3479
+ var canvasCtx = host.usePlasmicCanvasContext();
3480
+ var rootRef = React__namespace.useRef(null);
3481
+ var onRef = mergeRefs(rootRef, outerRef);
3482
+ // We pass in the Node secretly as an undocumented prop from <Select />
3483
+ var node = props._node;
3484
+ var isSelected = state.selectionManager.isSelected(node.key);
3485
+ var isDisabled = state.disabledKeys.has(node.key);
3486
+ var isHighlighted = state.selectionManager.isFocused &&
3487
+ state.selectionManager.focusedKey === node.key;
3488
+ var _c = listbox.useOption({
3489
+ isSelected: isSelected,
3490
+ isDisabled: isDisabled,
3491
+ "aria-label": node && node["aria-label"],
3492
+ key: node.key,
3493
+ shouldSelectOnPressUp: true,
3494
+ shouldFocusOnHover: true,
3495
+ isVirtualized: false,
3496
+ shouldUseVirtualFocus: !!canvasCtx
3497
+ }, state, rootRef), optionProps = _c.optionProps, labelProps = _c.labelProps;
3498
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.isSelectedVariant, active: isSelected }, { def: config.isDisabledVariant, active: isDisabled }, { def: config.isHighlightedVariant, active: isHighlighted }));
3499
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.labelSlot] = children, _a));
3500
+ var overrides = (_b = {},
3501
+ _b[config.root] = {
3502
+ props: mergeProps(canvasCtx ? {} : optionProps, getStyleProps(props), {
3503
+ ref: onRef,
3504
+ style: noOutline()
3505
+ })
3506
+ },
3507
+ _b[config.labelContainer] = {
3508
+ props: labelProps
3509
+ },
3510
+ _b);
3511
+ return {
3512
+ plasmicProps: {
3513
+ variants: variants,
3514
+ args: args,
3515
+ overrides: overrides
3516
+ }
3517
+ };
3518
+ }
3519
+
3520
+ function useSelectOptionGroup(plasmicClass, props, config) {
3521
+ var _a, _b;
3522
+ var state = React__namespace.useContext(SelectContext);
3523
+ // `node` should exist if the OptionGroup was instantiated properly
3524
+ // within a Select
3525
+ var node = props._node;
3526
+ if (!state || !node) {
3527
+ if (PLUME_STRICT_MODE) {
3528
+ throw new Error("You can only use a Select.OptionGroup within a Select component.");
3529
+ }
3530
+ return getDefaultPlasmicProps(plasmicClass, props);
3531
+ }
3532
+ var _c = listbox.useListBoxSection({
3533
+ heading: props.title,
3534
+ "aria-label": props["aria-label"]
3535
+ }), headingProps = _c.headingProps, groupProps = _c.groupProps;
3536
+ var separatorProps = separator.useSeparator({
3537
+ elementType: "li"
3538
+ }).separatorProps;
3539
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.noTitleVariant, active: !props.title }, {
3540
+ def: config.isFirstVariant,
3541
+ active: state.collection.getFirstKey() === node.key
3542
+ }));
3543
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.titleSlot] = props.title, _a[config.optionsSlot] = Array.from(node.childNodes).map(function (childNode) {
3544
+ return renderCollectionNode(childNode);
3545
+ }), _a));
3546
+ var overrides = (_b = {},
3547
+ _b[config.root] = {
3548
+ props: getStyleProps(props)
3549
+ },
3550
+ _b[config.separator] = {
3551
+ props: __assign({}, separatorProps)
3552
+ },
3553
+ _b[config.titleContainer] = __assign({ props: __assign({ role: "presentation" }, headingProps) }, (!props.title && {
3554
+ render: function () { return null; }
3555
+ })),
3556
+ _b[config.optionsContainer] = {
3557
+ props: __assign({}, groupProps)
3558
+ },
3559
+ _b);
3560
+ return {
3561
+ plasmicProps: {
3562
+ variants: variants,
3563
+ args: args,
3564
+ overrides: overrides
3565
+ }
3566
+ };
3567
+ }
3568
+
3569
+ function asAriaSwitchProps(props) {
3570
+ var ariaProps = __assign(__assign({}, props), { isSelected: props.isChecked, defaultSelected: props.defaultChecked });
3571
+ delete ariaProps["isChecked"];
3572
+ delete ariaProps["defaultChecked"];
3573
+ return ariaProps;
3574
+ }
3575
+ function useSwitch(plasmicClass, props, config, ref) {
3576
+ var _a, _b;
3577
+ if (ref === void 0) { ref = null; }
3578
+ var children = props.children, isDisabled = props.isDisabled;
3579
+ useEnsureSSRProvider();
3580
+ var inputRef = React__namespace.useRef(null);
3581
+ var rootRef = React__namespace.useRef(null);
3582
+ var ariaProps = asAriaSwitchProps(props);
3583
+ var state = toggle.useToggleState(ariaProps);
3584
+ var inputProps = _switch.useSwitch(ariaProps, state, inputRef).inputProps;
3585
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({
3586
+ def: config.isDisabledVariant,
3587
+ active: isDisabled
3588
+ }, {
3589
+ def: config.isCheckedVariant,
3590
+ active: state.isSelected
3591
+ }, {
3592
+ def: config.noLabelVariant,
3593
+ active: !children
3594
+ }));
3595
+ var overrides = (_a = {},
3596
+ _a[config.root] = {
3597
+ as: "label",
3598
+ props: mergeProps(getStyleProps(props), {
3599
+ ref: rootRef
3600
+ }),
3601
+ wrapChildren: function (children) { return (React__namespace.createElement(React__namespace.Fragment, null,
3602
+ React__namespace.createElement(visuallyHidden.VisuallyHidden, null,
3603
+ React__namespace.createElement("input", __assign({}, inputProps, { ref: inputRef }))),
3604
+ children)); }
3605
+ },
3606
+ _a);
3607
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (config.labelSlot ? (_b = {}, _b[config.labelSlot] = children, _b) : {}));
3608
+ var plumeState = React__namespace.useMemo(function () { return ({
3609
+ setChecked: function (checked) { return state.setSelected(checked); }
3610
+ }); }, [state]);
3611
+ React__namespace.useImperativeHandle(ref, function () { return ({
3612
+ getRoot: function () { return rootRef.current; },
3613
+ focus: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
3614
+ blur: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
3615
+ setChecked: function (checked) { return plumeState.setChecked(checked); }
3616
+ }); }, [rootRef, inputRef, plumeState]);
3617
+ return {
3618
+ plasmicProps: {
3619
+ variants: variants,
3620
+ overrides: overrides,
3621
+ args: args
3622
+ },
3623
+ state: plumeState
3624
+ };
3625
+ }
3626
+
3627
+ function useTextInput(plasmicClass, props, config, ref) {
3628
+ var _a, _b, _c;
3629
+ if (ref === void 0) { ref = null; }
3630
+ var isDisabled = props.isDisabled, startIcon = props.startIcon, endIcon = props.endIcon, showStartIcon = props.showStartIcon, showEndIcon = props.showEndIcon, className = props.className, style = props.style, inputClassName = props.inputClassName, inputStyle = props.inputStyle, rest = __rest(props, ["isDisabled", "startIcon", "endIcon", "showStartIcon", "showEndIcon", "className", "style", "inputClassName", "inputStyle"]);
3631
+ var rootRef = React__namespace.useRef(null);
3632
+ var inputRef = React__namespace.useRef(null);
3633
+ React__namespace.useImperativeHandle(ref, function () { return ({
3634
+ focus: function () {
3635
+ var _a;
3636
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
3637
+ },
3638
+ blur: function () {
3639
+ var _a;
3640
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
3641
+ },
3642
+ getRoot: function () {
3643
+ return rootRef.current;
3644
+ },
3645
+ getInput: function () {
3646
+ return inputRef.current;
3647
+ }
3648
+ }); }, [rootRef, inputRef]);
3649
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.showStartIconVariant, active: showStartIcon }, { def: config.showEndIconVariant, active: showEndIcon }, { def: config.isDisabledVariant, active: isDisabled }));
3650
+ var args = __assign(__assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (config.startIconSlot && (_a = {}, _a[config.startIconSlot] = startIcon, _a))), (config.endIconSlot && (_b = {}, _b[config.endIconSlot] = endIcon, _b)));
3651
+ var overrides = (_c = {},
3652
+ _c[config.root] = {
3653
+ props: {
3654
+ ref: rootRef,
3655
+ className: className,
3656
+ style: style
3657
+ }
3658
+ },
3659
+ _c[config.input] = {
3660
+ props: __assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([rest], __read(plasmicClass.internalArgProps.filter(function (prop) { return prop !== "required"; })), false), __read(plasmicClass.internalVariantProps), false))), { disabled: isDisabled, ref: inputRef, className: inputClassName, style: inputStyle })
3661
+ },
3662
+ _c);
3663
+ return {
3664
+ plasmicProps: {
3665
+ variants: variants,
3666
+ args: args,
3667
+ overrides: overrides
3668
+ }
3669
+ };
3670
+ }
3671
+
3672
+ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissable) {
3673
+ var _a, _b;
3674
+ if (outerRef === void 0) { outerRef = null; }
3675
+ if (isDismissable === void 0) { isDismissable = true; }
3676
+ var overlayRef = React__namespace.useRef(null);
3677
+ var onOverlayRef = mergeRefs(overlayRef, outerRef);
3678
+ var context = React__namespace.useContext(TriggeredOverlayContext);
3679
+ if (!context) {
3680
+ // If no context, then we are not being correctly used. Either complain, or
3681
+ // exit early. It's okay to exit early and break the rules of React hooks
3682
+ // because we won't suddenly have the appropriate context anyway for this instance.
3683
+ if (PLUME_STRICT_MODE) {
3684
+ throw new Error("You can only use a triggered overlay with a TriggeredOverlayContext");
3685
+ }
3686
+ return getDefaultPlasmicProps(plasmicClass, props);
3687
+ }
3688
+ var children = props.children;
3689
+ var triggerRef = context.triggerRef, placement = context.placement, overlayMatchTriggerWidth = context.overlayMatchTriggerWidth, overlayMinTriggerWidth = context.overlayMinTriggerWidth, overlayWidth = context.overlayWidth, state = context.state;
3690
+ // Measure the width of the trigger to inform the width of the menu (below).
3691
+ var _c = __read(React__namespace.useState(false), 2), isRendered = _c[0], setRendered = _c[1];
3692
+ var triggerWidth = triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth)
3693
+ ? triggerRef.current.offsetWidth
3694
+ : undefined;
3695
+ useIsomorphicLayoutEffect$1(function () {
3696
+ if (!isRendered &&
3697
+ triggerRef.current &&
3698
+ (overlayMatchTriggerWidth || overlayMinTriggerWidth)) {
3699
+ setRendered(true);
3700
+ }
3701
+ }, [
3702
+ triggerRef,
3703
+ isRendered,
3704
+ overlayMatchTriggerWidth,
3705
+ overlayMinTriggerWidth,
3706
+ ]);
3707
+ var overlayAriaProps = overlays.useOverlay({
3708
+ isOpen: state.isOpen,
3709
+ onClose: state.close,
3710
+ isDismissable: isDismissable,
3711
+ shouldCloseOnBlur: true
3712
+ }, overlayRef).overlayProps;
3713
+ var _d = overlays.useOverlayPosition({
3714
+ targetRef: triggerRef,
3715
+ overlayRef: overlayRef,
3716
+ placement: placement !== null && placement !== void 0 ? placement : "bottom left",
3717
+ shouldFlip: true,
3718
+ isOpen: state.isOpen,
3719
+ onClose: state.close,
3720
+ containerPadding: 0
3721
+ }), overlayPositionProps = _d.overlayProps, updatePosition = _d.updatePosition, placementAxis = _d.placement;
3722
+ useIsomorphicLayoutEffect$1(function () {
3723
+ if (state.isOpen) {
3724
+ requestAnimationFrame(function () {
3725
+ updatePosition();
3726
+ });
3727
+ }
3728
+ }, [state.isOpen, updatePosition]);
3729
+ var overlayProps = mergeProps({
3730
+ style: {
3731
+ left: "auto",
3732
+ right: "auto",
3733
+ top: "auto",
3734
+ bottom: "auto",
3735
+ position: "absolute",
3736
+ width: overlayWidth !== null && overlayWidth !== void 0 ? overlayWidth : (overlayMatchTriggerWidth ? triggerWidth : "auto"),
3737
+ minWidth: overlayMinTriggerWidth ? triggerWidth : "auto"
3738
+ }
3739
+ }, overlayAriaProps, overlayPositionProps);
3740
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.isPlacedTopVariant, active: placementAxis === "top" }, { def: config.isPlacedBottomVariant, active: placementAxis === "bottom" }, { def: config.isPlacedLeftVariant, active: placementAxis === "left" }, { def: config.isPlacedRightVariant, active: placementAxis === "right" }));
3741
+ var canvasCtx = host.usePlasmicCanvasContext();
3742
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.contentSlot] = canvasCtx ? (children) : (React__namespace.createElement(focus.FocusScope, { restoreFocus: true },
3743
+ React__namespace.createElement(overlays.DismissButton, { onDismiss: state.close }),
3744
+ children)), _a));
3745
+ var overrides = (_b = {},
3746
+ _b[config.root] = {
3747
+ props: mergeProps(overlayProps, getStyleProps(props), {
3748
+ ref: onOverlayRef
3749
+ }),
3750
+ wrap: function (root) {
3751
+ if (typeof document !== "undefined") {
3752
+ return ReactDOM__namespace.createPortal(root, document.body);
3753
+ }
3754
+ else {
3755
+ // Possibly being invoked on the server during SSR; no need to
3756
+ // bother with a portal in that case.
3757
+ return root;
3758
+ }
3759
+ }
3760
+ },
3761
+ _b);
3762
+ return {
3763
+ plasmicProps: {
3764
+ variants: variants,
3765
+ args: args,
3766
+ overrides: overrides
3767
+ }
3768
+ };
3769
+ }
3770
+
3771
+ Object.defineProperty(exports, 'PlasmicDataSourceContextProvider', {
3772
+ enumerable: true,
3773
+ get: function () {
3774
+ return dataSourcesContext.PlasmicDataSourceContextProvider;
3775
+ }
3776
+ });
3777
+ Object.defineProperty(exports, 'useCurrentUser', {
3778
+ enumerable: true,
3779
+ get: function () {
3780
+ return dataSourcesContext.useCurrentUser;
3781
+ }
3782
+ });
3783
+ Object.defineProperty(exports, 'get', {
3784
+ enumerable: true,
3785
+ get: function () {
3786
+ return get__default['default'];
3787
+ }
3788
+ });
3789
+ exports.DropdownMenu = DropdownMenu;
3790
+ exports.PlasmicHead = PlasmicHead;
3791
+ exports.PlasmicIcon = PlasmicIcon;
3792
+ exports.PlasmicImg = PlasmicImg;
3793
+ exports.PlasmicLink = PlasmicLink;
3794
+ exports.PlasmicPageGuard = PlasmicPageGuard;
3795
+ exports.PlasmicRootProvider = PlasmicRootProvider;
3796
+ exports.PlasmicSlot = PlasmicSlot;
3797
+ exports.SelectContext = SelectContext;
3798
+ exports.Stack = Stack;
3799
+ exports.Trans = Trans;
3800
+ exports.TriggeredOverlayContext = TriggeredOverlayContext;
3801
+ exports.classNames = classNames;
3802
+ exports.createPlasmicElementProxy = createPlasmicElementProxy;
3803
+ exports.createUseScreenVariants = createUseScreenVariants;
3804
+ exports.deriveRenderOpts = deriveRenderOpts;
3805
+ exports.ensureGlobalVariants = ensureGlobalVariants;
3806
+ exports.genTranslatableString = genTranslatableString;
3807
+ exports.generateStateOnChangeProp = generateStateOnChangeProp;
3808
+ exports.generateStateOnChangePropForCodeComponents = generateStateOnChangePropForCodeComponents;
3809
+ exports.generateStateValueProp = generateStateValueProp;
3810
+ exports.getCurrentInitialValue = getCurrentInitialValue;
3811
+ exports.getDataProps = getDataProps;
3812
+ exports.getStateCellsInPlasmicProxy = getStateCellsInPlasmicProxy;
3813
+ exports.getStateSpecInPlasmicProxy = getStateSpecInPlasmicProxy;
3814
+ exports.hasVariant = hasVariant;
3815
+ exports.initializeCodeComponentStates = initializeCodeComponentStates;
3816
+ exports.initializePlasmicStates = initializePlasmicStates;
3817
+ exports.is$StateProxy = is$StateProxy;
3818
+ exports.isPlasmicStateProxy = isPlasmicStateProxy;
3819
+ exports.makeFragment = makeFragment;
3820
+ exports.mergeVariantsWithStates = mergeVariantsWithStates;
3821
+ exports.omit = omit;
3822
+ exports.pick = pick;
3823
+ exports.plasmicHeadMeta = plasmicHeadMeta;
3824
+ exports.renderPlasmicSlot = renderPlasmicSlot;
3825
+ exports.resetToInitialValue = resetToInitialValue;
3826
+ exports.set = set;
3827
+ exports.setPlumeStrictMode = setPlumeStrictMode;
3828
+ exports.useButton = useButton;
3829
+ exports.useCheckbox = useCheckbox;
3830
+ exports.useDollarState = useDollarState;
3831
+ exports.useIsSSR = useIsSSR;
3832
+ exports.useMenu = useMenu;
3833
+ exports.useMenuButton = useMenuButton;
3834
+ exports.useMenuGroup = useMenuGroup;
3835
+ exports.useMenuItem = useMenuItem;
3836
+ exports.useSelect = useSelect;
3837
+ exports.useSelectOption = useSelectOption;
3838
+ exports.useSelectOptionGroup = useSelectOptionGroup;
3839
+ exports.useSwitch = useSwitch;
3840
+ exports.useTextInput = useTextInput;
3841
+ exports.useTrigger = useTrigger;
3842
+ exports.useTriggeredOverlay = useTriggeredOverlay;
3843
+ exports.withPlasmicPageGuard = withPlasmicPageGuard;
3844
+ exports.wrapWithClassName = wrapWithClassName;
3845
+ //# sourceMappingURL=index.cjs.js.map