@schematichq/schematic-react 0.2.0-rc.1 → 0.2.0-rc.3

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.
@@ -67,6 +67,728 @@ var require_shallowequal = __commonJS({
67
67
  }
68
68
  });
69
69
 
70
+ // node_modules/lodash.merge/index.js
71
+ var require_lodash = __commonJS({
72
+ "node_modules/lodash.merge/index.js"(exports, module2) {
73
+ var LARGE_ARRAY_SIZE = 200;
74
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
75
+ var HOT_COUNT = 800;
76
+ var HOT_SPAN = 16;
77
+ var MAX_SAFE_INTEGER = 9007199254740991;
78
+ var argsTag = "[object Arguments]";
79
+ var arrayTag = "[object Array]";
80
+ var asyncTag = "[object AsyncFunction]";
81
+ var boolTag = "[object Boolean]";
82
+ var dateTag = "[object Date]";
83
+ var errorTag = "[object Error]";
84
+ var funcTag = "[object Function]";
85
+ var genTag = "[object GeneratorFunction]";
86
+ var mapTag = "[object Map]";
87
+ var numberTag = "[object Number]";
88
+ var nullTag = "[object Null]";
89
+ var objectTag = "[object Object]";
90
+ var proxyTag = "[object Proxy]";
91
+ var regexpTag = "[object RegExp]";
92
+ var setTag = "[object Set]";
93
+ var stringTag = "[object String]";
94
+ var undefinedTag = "[object Undefined]";
95
+ var weakMapTag = "[object WeakMap]";
96
+ var arrayBufferTag = "[object ArrayBuffer]";
97
+ var dataViewTag = "[object DataView]";
98
+ var float32Tag = "[object Float32Array]";
99
+ var float64Tag = "[object Float64Array]";
100
+ var int8Tag = "[object Int8Array]";
101
+ var int16Tag = "[object Int16Array]";
102
+ var int32Tag = "[object Int32Array]";
103
+ var uint8Tag = "[object Uint8Array]";
104
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
105
+ var uint16Tag = "[object Uint16Array]";
106
+ var uint32Tag = "[object Uint32Array]";
107
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
108
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
109
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
110
+ var typedArrayTags = {};
111
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
112
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
113
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
114
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
115
+ var root = freeGlobal || freeSelf || Function("return this")();
116
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
117
+ var freeModule = freeExports && typeof module2 == "object" && module2 && !module2.nodeType && module2;
118
+ var moduleExports = freeModule && freeModule.exports === freeExports;
119
+ var freeProcess = moduleExports && freeGlobal.process;
120
+ var nodeUtil = function() {
121
+ try {
122
+ var types = freeModule && freeModule.require && freeModule.require("util").types;
123
+ if (types) {
124
+ return types;
125
+ }
126
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
127
+ } catch (e) {
128
+ }
129
+ }();
130
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
131
+ function apply(func, thisArg, args) {
132
+ switch (args.length) {
133
+ case 0:
134
+ return func.call(thisArg);
135
+ case 1:
136
+ return func.call(thisArg, args[0]);
137
+ case 2:
138
+ return func.call(thisArg, args[0], args[1]);
139
+ case 3:
140
+ return func.call(thisArg, args[0], args[1], args[2]);
141
+ }
142
+ return func.apply(thisArg, args);
143
+ }
144
+ function baseTimes(n, iteratee) {
145
+ var index = -1, result = Array(n);
146
+ while (++index < n) {
147
+ result[index] = iteratee(index);
148
+ }
149
+ return result;
150
+ }
151
+ function baseUnary(func) {
152
+ return function(value) {
153
+ return func(value);
154
+ };
155
+ }
156
+ function getValue(object, key) {
157
+ return object == null ? void 0 : object[key];
158
+ }
159
+ function overArg(func, transform) {
160
+ return function(arg) {
161
+ return func(transform(arg));
162
+ };
163
+ }
164
+ var arrayProto = Array.prototype;
165
+ var funcProto = Function.prototype;
166
+ var objectProto = Object.prototype;
167
+ var coreJsData = root["__core-js_shared__"];
168
+ var funcToString = funcProto.toString;
169
+ var hasOwnProperty = objectProto.hasOwnProperty;
170
+ var maskSrcKey = function() {
171
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
172
+ return uid ? "Symbol(src)_1." + uid : "";
173
+ }();
174
+ var nativeObjectToString = objectProto.toString;
175
+ var objectCtorString = funcToString.call(Object);
176
+ var reIsNative = RegExp(
177
+ "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
178
+ );
179
+ var Buffer2 = moduleExports ? root.Buffer : void 0;
180
+ var Symbol2 = root.Symbol;
181
+ var Uint8Array2 = root.Uint8Array;
182
+ var allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0;
183
+ var getPrototype = overArg(Object.getPrototypeOf, Object);
184
+ var objectCreate = Object.create;
185
+ var propertyIsEnumerable = objectProto.propertyIsEnumerable;
186
+ var splice = arrayProto.splice;
187
+ var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
188
+ var defineProperty = function() {
189
+ try {
190
+ var func = getNative(Object, "defineProperty");
191
+ func({}, "", {});
192
+ return func;
193
+ } catch (e) {
194
+ }
195
+ }();
196
+ var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
197
+ var nativeMax = Math.max;
198
+ var nativeNow = Date.now;
199
+ var Map2 = getNative(root, "Map");
200
+ var nativeCreate = getNative(Object, "create");
201
+ var baseCreate = /* @__PURE__ */ function() {
202
+ function object() {
203
+ }
204
+ return function(proto) {
205
+ if (!isObject(proto)) {
206
+ return {};
207
+ }
208
+ if (objectCreate) {
209
+ return objectCreate(proto);
210
+ }
211
+ object.prototype = proto;
212
+ var result = new object();
213
+ object.prototype = void 0;
214
+ return result;
215
+ };
216
+ }();
217
+ function Hash(entries) {
218
+ var index = -1, length2 = entries == null ? 0 : entries.length;
219
+ this.clear();
220
+ while (++index < length2) {
221
+ var entry = entries[index];
222
+ this.set(entry[0], entry[1]);
223
+ }
224
+ }
225
+ function hashClear() {
226
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
227
+ this.size = 0;
228
+ }
229
+ function hashDelete(key) {
230
+ var result = this.has(key) && delete this.__data__[key];
231
+ this.size -= result ? 1 : 0;
232
+ return result;
233
+ }
234
+ function hashGet(key) {
235
+ var data = this.__data__;
236
+ if (nativeCreate) {
237
+ var result = data[key];
238
+ return result === HASH_UNDEFINED ? void 0 : result;
239
+ }
240
+ return hasOwnProperty.call(data, key) ? data[key] : void 0;
241
+ }
242
+ function hashHas(key) {
243
+ var data = this.__data__;
244
+ return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key);
245
+ }
246
+ function hashSet(key, value) {
247
+ var data = this.__data__;
248
+ this.size += this.has(key) ? 0 : 1;
249
+ data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
250
+ return this;
251
+ }
252
+ Hash.prototype.clear = hashClear;
253
+ Hash.prototype["delete"] = hashDelete;
254
+ Hash.prototype.get = hashGet;
255
+ Hash.prototype.has = hashHas;
256
+ Hash.prototype.set = hashSet;
257
+ function ListCache(entries) {
258
+ var index = -1, length2 = entries == null ? 0 : entries.length;
259
+ this.clear();
260
+ while (++index < length2) {
261
+ var entry = entries[index];
262
+ this.set(entry[0], entry[1]);
263
+ }
264
+ }
265
+ function listCacheClear() {
266
+ this.__data__ = [];
267
+ this.size = 0;
268
+ }
269
+ function listCacheDelete(key) {
270
+ var data = this.__data__, index = assocIndexOf(data, key);
271
+ if (index < 0) {
272
+ return false;
273
+ }
274
+ var lastIndex = data.length - 1;
275
+ if (index == lastIndex) {
276
+ data.pop();
277
+ } else {
278
+ splice.call(data, index, 1);
279
+ }
280
+ --this.size;
281
+ return true;
282
+ }
283
+ function listCacheGet(key) {
284
+ var data = this.__data__, index = assocIndexOf(data, key);
285
+ return index < 0 ? void 0 : data[index][1];
286
+ }
287
+ function listCacheHas(key) {
288
+ return assocIndexOf(this.__data__, key) > -1;
289
+ }
290
+ function listCacheSet(key, value) {
291
+ var data = this.__data__, index = assocIndexOf(data, key);
292
+ if (index < 0) {
293
+ ++this.size;
294
+ data.push([key, value]);
295
+ } else {
296
+ data[index][1] = value;
297
+ }
298
+ return this;
299
+ }
300
+ ListCache.prototype.clear = listCacheClear;
301
+ ListCache.prototype["delete"] = listCacheDelete;
302
+ ListCache.prototype.get = listCacheGet;
303
+ ListCache.prototype.has = listCacheHas;
304
+ ListCache.prototype.set = listCacheSet;
305
+ function MapCache(entries) {
306
+ var index = -1, length2 = entries == null ? 0 : entries.length;
307
+ this.clear();
308
+ while (++index < length2) {
309
+ var entry = entries[index];
310
+ this.set(entry[0], entry[1]);
311
+ }
312
+ }
313
+ function mapCacheClear() {
314
+ this.size = 0;
315
+ this.__data__ = {
316
+ "hash": new Hash(),
317
+ "map": new (Map2 || ListCache)(),
318
+ "string": new Hash()
319
+ };
320
+ }
321
+ function mapCacheDelete(key) {
322
+ var result = getMapData(this, key)["delete"](key);
323
+ this.size -= result ? 1 : 0;
324
+ return result;
325
+ }
326
+ function mapCacheGet(key) {
327
+ return getMapData(this, key).get(key);
328
+ }
329
+ function mapCacheHas(key) {
330
+ return getMapData(this, key).has(key);
331
+ }
332
+ function mapCacheSet(key, value) {
333
+ var data = getMapData(this, key), size = data.size;
334
+ data.set(key, value);
335
+ this.size += data.size == size ? 0 : 1;
336
+ return this;
337
+ }
338
+ MapCache.prototype.clear = mapCacheClear;
339
+ MapCache.prototype["delete"] = mapCacheDelete;
340
+ MapCache.prototype.get = mapCacheGet;
341
+ MapCache.prototype.has = mapCacheHas;
342
+ MapCache.prototype.set = mapCacheSet;
343
+ function Stack(entries) {
344
+ var data = this.__data__ = new ListCache(entries);
345
+ this.size = data.size;
346
+ }
347
+ function stackClear() {
348
+ this.__data__ = new ListCache();
349
+ this.size = 0;
350
+ }
351
+ function stackDelete(key) {
352
+ var data = this.__data__, result = data["delete"](key);
353
+ this.size = data.size;
354
+ return result;
355
+ }
356
+ function stackGet(key) {
357
+ return this.__data__.get(key);
358
+ }
359
+ function stackHas(key) {
360
+ return this.__data__.has(key);
361
+ }
362
+ function stackSet(key, value) {
363
+ var data = this.__data__;
364
+ if (data instanceof ListCache) {
365
+ var pairs = data.__data__;
366
+ if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
367
+ pairs.push([key, value]);
368
+ this.size = ++data.size;
369
+ return this;
370
+ }
371
+ data = this.__data__ = new MapCache(pairs);
372
+ }
373
+ data.set(key, value);
374
+ this.size = data.size;
375
+ return this;
376
+ }
377
+ Stack.prototype.clear = stackClear;
378
+ Stack.prototype["delete"] = stackDelete;
379
+ Stack.prototype.get = stackGet;
380
+ Stack.prototype.has = stackHas;
381
+ Stack.prototype.set = stackSet;
382
+ function arrayLikeKeys(value, inherited) {
383
+ var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length2 = result.length;
384
+ for (var key in value) {
385
+ if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
386
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
387
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
388
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
389
+ isIndex(key, length2)))) {
390
+ result.push(key);
391
+ }
392
+ }
393
+ return result;
394
+ }
395
+ function assignMergeValue(object, key, value) {
396
+ if (value !== void 0 && !eq(object[key], value) || value === void 0 && !(key in object)) {
397
+ baseAssignValue(object, key, value);
398
+ }
399
+ }
400
+ function assignValue(object, key, value) {
401
+ var objValue = object[key];
402
+ if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
403
+ baseAssignValue(object, key, value);
404
+ }
405
+ }
406
+ function assocIndexOf(array, key) {
407
+ var length2 = array.length;
408
+ while (length2--) {
409
+ if (eq(array[length2][0], key)) {
410
+ return length2;
411
+ }
412
+ }
413
+ return -1;
414
+ }
415
+ function baseAssignValue(object, key, value) {
416
+ if (key == "__proto__" && defineProperty) {
417
+ defineProperty(object, key, {
418
+ "configurable": true,
419
+ "enumerable": true,
420
+ "value": value,
421
+ "writable": true
422
+ });
423
+ } else {
424
+ object[key] = value;
425
+ }
426
+ }
427
+ var baseFor = createBaseFor();
428
+ function baseGetTag(value) {
429
+ if (value == null) {
430
+ return value === void 0 ? undefinedTag : nullTag;
431
+ }
432
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
433
+ }
434
+ function baseIsArguments(value) {
435
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
436
+ }
437
+ function baseIsNative(value) {
438
+ if (!isObject(value) || isMasked(value)) {
439
+ return false;
440
+ }
441
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
442
+ return pattern.test(toSource(value));
443
+ }
444
+ function baseIsTypedArray(value) {
445
+ return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
446
+ }
447
+ function baseKeysIn(object) {
448
+ if (!isObject(object)) {
449
+ return nativeKeysIn(object);
450
+ }
451
+ var isProto = isPrototype(object), result = [];
452
+ for (var key in object) {
453
+ if (!(key == "constructor" && (isProto || !hasOwnProperty.call(object, key)))) {
454
+ result.push(key);
455
+ }
456
+ }
457
+ return result;
458
+ }
459
+ function baseMerge(object, source, srcIndex, customizer, stack) {
460
+ if (object === source) {
461
+ return;
462
+ }
463
+ baseFor(source, function(srcValue, key) {
464
+ stack || (stack = new Stack());
465
+ if (isObject(srcValue)) {
466
+ baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
467
+ } else {
468
+ var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : void 0;
469
+ if (newValue === void 0) {
470
+ newValue = srcValue;
471
+ }
472
+ assignMergeValue(object, key, newValue);
473
+ }
474
+ }, keysIn);
475
+ }
476
+ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
477
+ var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack.get(srcValue);
478
+ if (stacked) {
479
+ assignMergeValue(object, key, stacked);
480
+ return;
481
+ }
482
+ var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : void 0;
483
+ var isCommon = newValue === void 0;
484
+ if (isCommon) {
485
+ var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue);
486
+ newValue = srcValue;
487
+ if (isArr || isBuff || isTyped) {
488
+ if (isArray(objValue)) {
489
+ newValue = objValue;
490
+ } else if (isArrayLikeObject(objValue)) {
491
+ newValue = copyArray(objValue);
492
+ } else if (isBuff) {
493
+ isCommon = false;
494
+ newValue = cloneBuffer(srcValue, true);
495
+ } else if (isTyped) {
496
+ isCommon = false;
497
+ newValue = cloneTypedArray(srcValue, true);
498
+ } else {
499
+ newValue = [];
500
+ }
501
+ } else if (isPlainObject(srcValue) || isArguments(srcValue)) {
502
+ newValue = objValue;
503
+ if (isArguments(objValue)) {
504
+ newValue = toPlainObject(objValue);
505
+ } else if (!isObject(objValue) || isFunction(objValue)) {
506
+ newValue = initCloneObject(srcValue);
507
+ }
508
+ } else {
509
+ isCommon = false;
510
+ }
511
+ }
512
+ if (isCommon) {
513
+ stack.set(srcValue, newValue);
514
+ mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
515
+ stack["delete"](srcValue);
516
+ }
517
+ assignMergeValue(object, key, newValue);
518
+ }
519
+ function baseRest(func, start) {
520
+ return setToString(overRest(func, start, identity), func + "");
521
+ }
522
+ var baseSetToString = !defineProperty ? identity : function(func, string) {
523
+ return defineProperty(func, "toString", {
524
+ "configurable": true,
525
+ "enumerable": false,
526
+ "value": constant(string),
527
+ "writable": true
528
+ });
529
+ };
530
+ function cloneBuffer(buffer, isDeep) {
531
+ if (isDeep) {
532
+ return buffer.slice();
533
+ }
534
+ var length2 = buffer.length, result = allocUnsafe ? allocUnsafe(length2) : new buffer.constructor(length2);
535
+ buffer.copy(result);
536
+ return result;
537
+ }
538
+ function cloneArrayBuffer(arrayBuffer) {
539
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
540
+ new Uint8Array2(result).set(new Uint8Array2(arrayBuffer));
541
+ return result;
542
+ }
543
+ function cloneTypedArray(typedArray, isDeep) {
544
+ var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
545
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
546
+ }
547
+ function copyArray(source, array) {
548
+ var index = -1, length2 = source.length;
549
+ array || (array = Array(length2));
550
+ while (++index < length2) {
551
+ array[index] = source[index];
552
+ }
553
+ return array;
554
+ }
555
+ function copyObject(source, props, object, customizer) {
556
+ var isNew = !object;
557
+ object || (object = {});
558
+ var index = -1, length2 = props.length;
559
+ while (++index < length2) {
560
+ var key = props[index];
561
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
562
+ if (newValue === void 0) {
563
+ newValue = source[key];
564
+ }
565
+ if (isNew) {
566
+ baseAssignValue(object, key, newValue);
567
+ } else {
568
+ assignValue(object, key, newValue);
569
+ }
570
+ }
571
+ return object;
572
+ }
573
+ function createAssigner(assigner) {
574
+ return baseRest(function(object, sources) {
575
+ var index = -1, length2 = sources.length, customizer = length2 > 1 ? sources[length2 - 1] : void 0, guard = length2 > 2 ? sources[2] : void 0;
576
+ customizer = assigner.length > 3 && typeof customizer == "function" ? (length2--, customizer) : void 0;
577
+ if (guard && isIterateeCall(sources[0], sources[1], guard)) {
578
+ customizer = length2 < 3 ? void 0 : customizer;
579
+ length2 = 1;
580
+ }
581
+ object = Object(object);
582
+ while (++index < length2) {
583
+ var source = sources[index];
584
+ if (source) {
585
+ assigner(object, source, index, customizer);
586
+ }
587
+ }
588
+ return object;
589
+ });
590
+ }
591
+ function createBaseFor(fromRight) {
592
+ return function(object, iteratee, keysFunc) {
593
+ var index = -1, iterable = Object(object), props = keysFunc(object), length2 = props.length;
594
+ while (length2--) {
595
+ var key = props[fromRight ? length2 : ++index];
596
+ if (iteratee(iterable[key], key, iterable) === false) {
597
+ break;
598
+ }
599
+ }
600
+ return object;
601
+ };
602
+ }
603
+ function getMapData(map, key) {
604
+ var data = map.__data__;
605
+ return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
606
+ }
607
+ function getNative(object, key) {
608
+ var value = getValue(object, key);
609
+ return baseIsNative(value) ? value : void 0;
610
+ }
611
+ function getRawTag(value) {
612
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
613
+ try {
614
+ value[symToStringTag] = void 0;
615
+ var unmasked = true;
616
+ } catch (e) {
617
+ }
618
+ var result = nativeObjectToString.call(value);
619
+ if (unmasked) {
620
+ if (isOwn) {
621
+ value[symToStringTag] = tag;
622
+ } else {
623
+ delete value[symToStringTag];
624
+ }
625
+ }
626
+ return result;
627
+ }
628
+ function initCloneObject(object) {
629
+ return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
630
+ }
631
+ function isIndex(value, length2) {
632
+ var type = typeof value;
633
+ length2 = length2 == null ? MAX_SAFE_INTEGER : length2;
634
+ return !!length2 && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
635
+ }
636
+ function isIterateeCall(value, index, object) {
637
+ if (!isObject(object)) {
638
+ return false;
639
+ }
640
+ var type = typeof index;
641
+ if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) {
642
+ return eq(object[index], value);
643
+ }
644
+ return false;
645
+ }
646
+ function isKeyable(value) {
647
+ var type = typeof value;
648
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
649
+ }
650
+ function isMasked(func) {
651
+ return !!maskSrcKey && maskSrcKey in func;
652
+ }
653
+ function isPrototype(value) {
654
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto;
655
+ return value === proto;
656
+ }
657
+ function nativeKeysIn(object) {
658
+ var result = [];
659
+ if (object != null) {
660
+ for (var key in Object(object)) {
661
+ result.push(key);
662
+ }
663
+ }
664
+ return result;
665
+ }
666
+ function objectToString(value) {
667
+ return nativeObjectToString.call(value);
668
+ }
669
+ function overRest(func, start, transform) {
670
+ start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
671
+ return function() {
672
+ var args = arguments, index = -1, length2 = nativeMax(args.length - start, 0), array = Array(length2);
673
+ while (++index < length2) {
674
+ array[index] = args[start + index];
675
+ }
676
+ index = -1;
677
+ var otherArgs = Array(start + 1);
678
+ while (++index < start) {
679
+ otherArgs[index] = args[index];
680
+ }
681
+ otherArgs[start] = transform(array);
682
+ return apply(func, this, otherArgs);
683
+ };
684
+ }
685
+ function safeGet(object, key) {
686
+ if (key === "constructor" && typeof object[key] === "function") {
687
+ return;
688
+ }
689
+ if (key == "__proto__") {
690
+ return;
691
+ }
692
+ return object[key];
693
+ }
694
+ var setToString = shortOut(baseSetToString);
695
+ function shortOut(func) {
696
+ var count = 0, lastCalled = 0;
697
+ return function() {
698
+ var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
699
+ lastCalled = stamp;
700
+ if (remaining > 0) {
701
+ if (++count >= HOT_COUNT) {
702
+ return arguments[0];
703
+ }
704
+ } else {
705
+ count = 0;
706
+ }
707
+ return func.apply(void 0, arguments);
708
+ };
709
+ }
710
+ function toSource(func) {
711
+ if (func != null) {
712
+ try {
713
+ return funcToString.call(func);
714
+ } catch (e) {
715
+ }
716
+ try {
717
+ return func + "";
718
+ } catch (e) {
719
+ }
720
+ }
721
+ return "";
722
+ }
723
+ function eq(value, other) {
724
+ return value === other || value !== value && other !== other;
725
+ }
726
+ var isArguments = baseIsArguments(/* @__PURE__ */ function() {
727
+ return arguments;
728
+ }()) ? baseIsArguments : function(value) {
729
+ return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
730
+ };
731
+ var isArray = Array.isArray;
732
+ function isArrayLike(value) {
733
+ return value != null && isLength(value.length) && !isFunction(value);
734
+ }
735
+ function isArrayLikeObject(value) {
736
+ return isObjectLike(value) && isArrayLike(value);
737
+ }
738
+ var isBuffer = nativeIsBuffer || stubFalse;
739
+ function isFunction(value) {
740
+ if (!isObject(value)) {
741
+ return false;
742
+ }
743
+ var tag = baseGetTag(value);
744
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
745
+ }
746
+ function isLength(value) {
747
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
748
+ }
749
+ function isObject(value) {
750
+ var type = typeof value;
751
+ return value != null && (type == "object" || type == "function");
752
+ }
753
+ function isObjectLike(value) {
754
+ return value != null && typeof value == "object";
755
+ }
756
+ function isPlainObject(value) {
757
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
758
+ return false;
759
+ }
760
+ var proto = getPrototype(value);
761
+ if (proto === null) {
762
+ return true;
763
+ }
764
+ var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
765
+ return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
766
+ }
767
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
768
+ function toPlainObject(value) {
769
+ return copyObject(value, keysIn(value));
770
+ }
771
+ function keysIn(object) {
772
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
773
+ }
774
+ var merge2 = createAssigner(function(object, source, srcIndex) {
775
+ baseMerge(object, source, srcIndex);
776
+ });
777
+ function constant(value) {
778
+ return function() {
779
+ return value;
780
+ };
781
+ }
782
+ function identity(value) {
783
+ return value;
784
+ }
785
+ function stubFalse() {
786
+ return false;
787
+ }
788
+ module2.exports = merge2;
789
+ }
790
+ });
791
+
70
792
  // node_modules/classnames/index.js
71
793
  var require_classnames = __commonJS({
72
794
  "node_modules/classnames/index.js"(exports, module2) {
@@ -133,6 +855,7 @@ __export(src_exports, {
133
855
  Box: () => Box,
134
856
  Button: () => Button2,
135
857
  Card: () => Card,
858
+ Column: () => Column,
136
859
  EmbedContext: () => EmbedContext,
137
860
  EmbedProvider: () => EmbedProvider,
138
861
  Flex: () => Flex,
@@ -141,14 +864,19 @@ __export(src_exports, {
141
864
  IncludedFeatures: () => IncludedFeatures,
142
865
  Invoices: () => Invoices,
143
866
  MeteredFeatures: () => MeteredFeatures,
867
+ OverlayHeader: () => OverlayHeader,
868
+ OverlaySideBar: () => OverlaySideBar,
869
+ OverlayWrapper: () => OverlayWrapper,
144
870
  PaymentMethod: () => PaymentMethod,
145
871
  PlanManager: () => PlanManager,
146
872
  ProgressBar: () => ProgressBar,
873
+ Root: () => Root,
147
874
  Schematic: () => Schematic,
148
875
  SchematicEmbed: () => SchematicEmbed,
149
876
  SchematicProvider: () => SchematicProvider,
150
877
  Text: () => Text,
151
878
  UpcomingBill: () => UpcomingBill,
879
+ Viewport: () => Viewport,
152
880
  defaultSettings: () => defaultSettings,
153
881
  defaultTheme: () => defaultTheme,
154
882
  useEmbed: () => useEmbed,
@@ -4972,7 +5700,7 @@ var unitlessKeys = {
4972
5700
  var f = "undefined" != typeof process && void 0 !== process.env && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || "data-styled";
4973
5701
  var m = "active";
4974
5702
  var y = "data-styled-version";
4975
- var v = "6.1.12";
5703
+ var v = "6.1.13";
4976
5704
  var g = "/*!sc*/\n";
4977
5705
  var S = "undefined" != typeof window && "HTMLElement" in window;
4978
5706
  var w = Boolean("boolean" == typeof SC_DISABLE_SPEEDY ? SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.REACT_APP_SC_DISABLE_SPEEDY && "" !== process.env.REACT_APP_SC_DISABLE_SPEEDY ? "false" !== process.env.REACT_APP_SC_DISABLE_SPEEDY && process.env.REACT_APP_SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.SC_DISABLE_SPEEDY && "" !== process.env.SC_DISABLE_SPEEDY ? "false" !== process.env.SC_DISABLE_SPEEDY && process.env.SC_DISABLE_SPEEDY : true);
@@ -5652,6 +6380,146 @@ var vt = function() {
5652
6380
  var St = "__sc-".concat(f, "__");
5653
6381
  "undefined" != typeof window && (window[St] || (window[St] = 0), 1 === window[St] && console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."), window[St] += 1);
5654
6382
 
6383
+ // src/context/embed.tsx
6384
+ var import_lodash = __toESM(require_lodash());
6385
+
6386
+ // node_modules/@stripe/stripe-js/dist/index.mjs
6387
+ var V3_URL = "https://js.stripe.com/v3";
6388
+ var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
6389
+ var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
6390
+ var findScript = function findScript2() {
6391
+ var scripts = document.querySelectorAll('script[src^="'.concat(V3_URL, '"]'));
6392
+ for (var i2 = 0; i2 < scripts.length; i2++) {
6393
+ var script = scripts[i2];
6394
+ if (!V3_URL_REGEX.test(script.src)) {
6395
+ continue;
6396
+ }
6397
+ return script;
6398
+ }
6399
+ return null;
6400
+ };
6401
+ var injectScript = function injectScript2(params) {
6402
+ var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
6403
+ var script = document.createElement("script");
6404
+ script.src = "".concat(V3_URL).concat(queryString);
6405
+ var headOrBody = document.head || document.body;
6406
+ if (!headOrBody) {
6407
+ throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
6408
+ }
6409
+ headOrBody.appendChild(script);
6410
+ return script;
6411
+ };
6412
+ var registerWrapper = function registerWrapper2(stripe, startTime) {
6413
+ if (!stripe || !stripe._registerWrapper) {
6414
+ return;
6415
+ }
6416
+ stripe._registerWrapper({
6417
+ name: "stripe-js",
6418
+ version: "4.3.0",
6419
+ startTime
6420
+ });
6421
+ };
6422
+ var stripePromise = null;
6423
+ var onErrorListener = null;
6424
+ var onLoadListener = null;
6425
+ var onError = function onError2(reject) {
6426
+ return function() {
6427
+ reject(new Error("Failed to load Stripe.js"));
6428
+ };
6429
+ };
6430
+ var onLoad = function onLoad2(resolve, reject) {
6431
+ return function() {
6432
+ if (window.Stripe) {
6433
+ resolve(window.Stripe);
6434
+ } else {
6435
+ reject(new Error("Stripe.js not available"));
6436
+ }
6437
+ };
6438
+ };
6439
+ var loadScript = function loadScript2(params) {
6440
+ if (stripePromise !== null) {
6441
+ return stripePromise;
6442
+ }
6443
+ stripePromise = new Promise(function(resolve, reject) {
6444
+ if (typeof window === "undefined" || typeof document === "undefined") {
6445
+ resolve(null);
6446
+ return;
6447
+ }
6448
+ if (window.Stripe && params) {
6449
+ console.warn(EXISTING_SCRIPT_MESSAGE);
6450
+ }
6451
+ if (window.Stripe) {
6452
+ resolve(window.Stripe);
6453
+ return;
6454
+ }
6455
+ try {
6456
+ var script = findScript();
6457
+ if (script && params) {
6458
+ console.warn(EXISTING_SCRIPT_MESSAGE);
6459
+ } else if (!script) {
6460
+ script = injectScript(params);
6461
+ } else if (script && onLoadListener !== null && onErrorListener !== null) {
6462
+ var _script$parentNode;
6463
+ script.removeEventListener("load", onLoadListener);
6464
+ script.removeEventListener("error", onErrorListener);
6465
+ (_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
6466
+ script = injectScript(params);
6467
+ }
6468
+ onLoadListener = onLoad(resolve, reject);
6469
+ onErrorListener = onError(reject);
6470
+ script.addEventListener("load", onLoadListener);
6471
+ script.addEventListener("error", onErrorListener);
6472
+ } catch (error) {
6473
+ reject(error);
6474
+ return;
6475
+ }
6476
+ });
6477
+ return stripePromise["catch"](function(error) {
6478
+ stripePromise = null;
6479
+ return Promise.reject(error);
6480
+ });
6481
+ };
6482
+ var initStripe = function initStripe2(maybeStripe, args, startTime) {
6483
+ if (maybeStripe === null) {
6484
+ return null;
6485
+ }
6486
+ var stripe = maybeStripe.apply(void 0, args);
6487
+ registerWrapper(stripe, startTime);
6488
+ return stripe;
6489
+ };
6490
+ var stripePromise$1;
6491
+ var loadCalled = false;
6492
+ var getStripePromise = function getStripePromise2() {
6493
+ if (stripePromise$1) {
6494
+ return stripePromise$1;
6495
+ }
6496
+ stripePromise$1 = loadScript(null)["catch"](function(error) {
6497
+ stripePromise$1 = null;
6498
+ return Promise.reject(error);
6499
+ });
6500
+ return stripePromise$1;
6501
+ };
6502
+ Promise.resolve().then(function() {
6503
+ return getStripePromise();
6504
+ })["catch"](function(error) {
6505
+ if (!loadCalled) {
6506
+ console.warn(error);
6507
+ }
6508
+ });
6509
+ var loadStripe = function loadStripe2() {
6510
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6511
+ args[_key] = arguments[_key];
6512
+ }
6513
+ loadCalled = true;
6514
+ var startTime = Date.now();
6515
+ return getStripePromise().then(function(maybeStripe) {
6516
+ return initStripe(maybeStripe, args, startTime);
6517
+ });
6518
+ };
6519
+
6520
+ // src/context/embed.tsx
6521
+ var import_react_stripe_js = require("@stripe/react-stripe-js");
6522
+
5655
6523
  // src/api/runtime.ts
5656
6524
  var BASE_PATH = "https://api.schematichq.com".replace(/\/+$/, "");
5657
6525
  var Configuration = class {
@@ -5968,6 +6836,30 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
5968
6836
  };
5969
6837
  }
5970
6838
 
6839
+ // src/api/models/BillingProductForSubscriptionResponseData.ts
6840
+ function BillingProductForSubscriptionResponseDataFromJSON(json) {
6841
+ return BillingProductForSubscriptionResponseDataFromJSONTyped(json, false);
6842
+ }
6843
+ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6844
+ if (json == null) {
6845
+ return json;
6846
+ }
6847
+ return {
6848
+ accountId: json["account_id"],
6849
+ createdAt: new Date(json["created_at"]),
6850
+ currency: json["currency"],
6851
+ environmentId: json["environment_id"],
6852
+ externalId: json["external_id"],
6853
+ id: json["id"],
6854
+ interval: json["interval"] == null ? void 0 : json["interval"],
6855
+ name: json["name"],
6856
+ price: json["price"],
6857
+ quantity: json["quantity"],
6858
+ subscriptionId: json["subscription_id"],
6859
+ updatedAt: new Date(json["updated_at"])
6860
+ };
6861
+ }
6862
+
5971
6863
  // src/api/models/BillingSubscriptionResponseData.ts
5972
6864
  function BillingSubscriptionResponseDataFromJSON(json) {
5973
6865
  return BillingSubscriptionResponseDataFromJSONTyped(json, false);
@@ -5990,7 +6882,6 @@ function ChangeSubscriptionRequestBodyToJSON(value) {
5990
6882
  return value;
5991
6883
  }
5992
6884
  return {
5993
- action: value["action"],
5994
6885
  new_plan_id: value["newPlanId"],
5995
6886
  new_price_id: value["newPriceId"]
5996
6887
  };
@@ -6402,40 +7293,115 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6402
7293
  };
6403
7294
  }
6404
7295
 
6405
- // src/api/models/ComponentResponseData.ts
6406
- function ComponentResponseDataFromJSON(json) {
6407
- return ComponentResponseDataFromJSONTyped(json, false);
7296
+ // src/api/models/InvoiceResponseData.ts
7297
+ function InvoiceResponseDataFromJSON(json) {
7298
+ return InvoiceResponseDataFromJSONTyped(json, false);
6408
7299
  }
6409
- function ComponentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7300
+ function InvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6410
7301
  if (json == null) {
6411
7302
  return json;
6412
7303
  }
6413
7304
  return {
6414
- ast: json["ast"] == null ? void 0 : json["ast"],
7305
+ amountDue: json["amount_due"],
7306
+ amountPaid: json["amount_paid"],
7307
+ amountRemaining: json["amount_remaining"],
7308
+ collectionMethod: json["collection_method"],
7309
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
6415
7310
  createdAt: new Date(json["created_at"]),
7311
+ currency: json["currency"],
7312
+ customerExternalId: json["customer_external_id"],
7313
+ dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
7314
+ environmentId: json["environment_id"],
7315
+ externalId: json["external_id"],
6416
7316
  id: json["id"],
6417
- name: json["name"],
6418
- state: json["state"],
6419
- type: json["type"],
7317
+ subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7318
+ subtotal: json["subtotal"],
6420
7319
  updatedAt: new Date(json["updated_at"])
6421
7320
  };
6422
7321
  }
6423
7322
 
6424
- // src/api/models/FeatureUsageResponseData.ts
6425
- function FeatureUsageResponseDataFromJSON(json) {
6426
- return FeatureUsageResponseDataFromJSONTyped(json, false);
7323
+ // src/api/models/PaymentMethodResponseData.ts
7324
+ function PaymentMethodResponseDataFromJSON(json) {
7325
+ return PaymentMethodResponseDataFromJSONTyped(json, false);
6427
7326
  }
6428
- function FeatureUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7327
+ function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6429
7328
  if (json == null) {
6430
7329
  return json;
6431
7330
  }
6432
7331
  return {
6433
- access: json["access"],
6434
- allocation: json["allocation"] == null ? void 0 : json["allocation"],
6435
- allocationType: json["allocation_type"],
6436
- entitlementId: json["entitlement_id"],
6437
- entitlementType: json["entitlement_type"],
6438
- feature: json["feature"] == null ? void 0 : FeatureDetailResponseDataFromJSON(json["feature"]),
7332
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
7333
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
7334
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
7335
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
7336
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7337
+ createdAt: new Date(json["created_at"]),
7338
+ customerExternalId: json["customer_external_id"],
7339
+ environmentId: json["environment_id"],
7340
+ externalId: json["external_id"],
7341
+ id: json["id"],
7342
+ invoiceExternalId: json["invoice_external_id"] == null ? void 0 : json["invoice_external_id"],
7343
+ paymentMethodType: json["payment_method_type"],
7344
+ subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7345
+ updatedAt: new Date(json["updated_at"])
7346
+ };
7347
+ }
7348
+
7349
+ // src/api/models/CompanySubscriptionResponseData.ts
7350
+ function CompanySubscriptionResponseDataFromJSON(json) {
7351
+ return CompanySubscriptionResponseDataFromJSONTyped(json, false);
7352
+ }
7353
+ function CompanySubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7354
+ if (json == null) {
7355
+ return json;
7356
+ }
7357
+ return {
7358
+ customerExternalId: json["customer_external_id"],
7359
+ expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
7360
+ interval: json["interval"],
7361
+ latestInvoice: json["latest_invoice"] == null ? void 0 : InvoiceResponseDataFromJSON(json["latest_invoice"]),
7362
+ paymentMethod: json["payment_method"] == null ? void 0 : PaymentMethodResponseDataFromJSON(json["payment_method"]),
7363
+ products: json["products"].map(
7364
+ BillingProductForSubscriptionResponseDataFromJSON
7365
+ ),
7366
+ subscriptionExternalId: json["subscription_external_id"],
7367
+ totalPrice: json["total_price"]
7368
+ };
7369
+ }
7370
+
7371
+ // src/api/models/ComponentResponseData.ts
7372
+ function ComponentResponseDataFromJSON(json) {
7373
+ return ComponentResponseDataFromJSONTyped(json, false);
7374
+ }
7375
+ function ComponentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7376
+ if (json == null) {
7377
+ return json;
7378
+ }
7379
+ return {
7380
+ ast: json["ast"] == null ? void 0 : json["ast"],
7381
+ createdAt: new Date(json["created_at"]),
7382
+ id: json["id"],
7383
+ name: json["name"],
7384
+ state: json["state"],
7385
+ type: json["type"],
7386
+ updatedAt: new Date(json["updated_at"])
7387
+ };
7388
+ }
7389
+
7390
+ // src/api/models/FeatureUsageResponseData.ts
7391
+ function FeatureUsageResponseDataFromJSON(json) {
7392
+ return FeatureUsageResponseDataFromJSONTyped(json, false);
7393
+ }
7394
+ function FeatureUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7395
+ if (json == null) {
7396
+ return json;
7397
+ }
7398
+ return {
7399
+ access: json["access"],
7400
+ allocation: json["allocation"] == null ? void 0 : json["allocation"],
7401
+ allocationType: json["allocation_type"],
7402
+ entitlementId: json["entitlement_id"],
7403
+ entitlementType: json["entitlement_type"],
7404
+ feature: json["feature"] == null ? void 0 : FeatureDetailResponseDataFromJSON(json["feature"]),
6439
7405
  period: json["period"] == null ? void 0 : json["period"],
6440
7406
  plan: json["plan"] == null ? void 0 : PlanResponseDataFromJSON(json["plan"]),
6441
7407
  usage: json["usage"] == null ? void 0 : json["usage"]
@@ -6466,7 +7432,7 @@ function StripeEmbedInfoFromJSONTyped(json, ignoreDiscriminator) {
6466
7432
  return json;
6467
7433
  }
6468
7434
  return {
6469
- customerEkey: json["customer_ekey"],
7435
+ customerEkey: json["customer_ekey"] == null ? void 0 : json["customer_ekey"],
6470
7436
  publishableKey: json["publishable_key"]
6471
7437
  };
6472
7438
  }
@@ -6486,7 +7452,9 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6486
7452
  company: json["company"] == null ? void 0 : CompanyDetailResponseDataFromJSON(json["company"]),
6487
7453
  component: json["component"] == null ? void 0 : ComponentResponseDataFromJSON(json["component"]),
6488
7454
  featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"]),
6489
- stripeEmbed: json["stripe_embed"] == null ? void 0 : StripeEmbedInfoFromJSON(json["stripe_embed"])
7455
+ stripeEmbed: json["stripe_embed"] == null ? void 0 : StripeEmbedInfoFromJSON(json["stripe_embed"]),
7456
+ subscription: json["subscription"] == null ? void 0 : CompanySubscriptionResponseDataFromJSON(json["subscription"]),
7457
+ upcomingInvoice: json["upcoming_invoice"] == null ? void 0 : InvoiceResponseDataFromJSON(json["upcoming_invoice"])
6490
7458
  };
6491
7459
  }
6492
7460
 
@@ -6687,11 +7655,9 @@ function parseEditorState(data) {
6687
7655
  });
6688
7656
  return arr;
6689
7657
  }
6690
- async function fetchComponent(id, accessToken, options) {
7658
+ async function fetchComponent(id, api) {
6691
7659
  const settings = { ...defaultSettings };
6692
7660
  const nodes = [];
6693
- const config = new Configuration({ ...options, apiKey: accessToken });
6694
- const api = new CheckoutApi(config);
6695
7661
  const response = await api.hydrateComponent({ componentId: id });
6696
7662
  const { data } = response;
6697
7663
  if (data.component?.ast) {
@@ -6699,28 +7665,39 @@ async function fetchComponent(id, accessToken, options) {
6699
7665
  const json = inflate_1(Uint8Array.from(Object.values(compressed)), {
6700
7666
  to: "string"
6701
7667
  });
6702
- const ast = getEditorState(JSON.stringify(json));
7668
+ const ast = getEditorState(json);
6703
7669
  if (ast) {
6704
7670
  Object.assign(settings, ast.ROOT.props);
6705
7671
  nodes.push(...parseEditorState(ast));
6706
7672
  }
6707
7673
  }
7674
+ let stripe = null;
7675
+ if (data.stripeEmbed?.publishableKey) {
7676
+ stripe = loadStripe(data.stripeEmbed.publishableKey);
7677
+ }
6708
7678
  return {
6709
7679
  data,
6710
7680
  nodes,
6711
- settings
7681
+ settings,
7682
+ stripe
6712
7683
  };
6713
7684
  }
6714
7685
  var EmbedContext = (0, import_react2.createContext)({
6715
- data: {},
7686
+ api: null,
7687
+ data: {
7688
+ activePlans: []
7689
+ },
6716
7690
  nodes: [],
6717
7691
  settings: { ...defaultSettings },
7692
+ stripe: null,
6718
7693
  layout: "portal",
6719
7694
  error: void 0,
6720
7695
  setData: () => {
6721
7696
  },
6722
7697
  updateSettings: () => {
6723
7698
  },
7699
+ setStripe: () => {
7700
+ },
6724
7701
  setLayout: () => {
6725
7702
  }
6726
7703
  });
@@ -6733,15 +7710,21 @@ var EmbedProvider = ({
6733
7710
  const styleRef = (0, import_react2.useRef)(null);
6734
7711
  const [state, setState] = (0, import_react2.useState)(() => {
6735
7712
  return {
6736
- data: {},
7713
+ api: null,
7714
+ data: {
7715
+ activePlans: []
7716
+ },
6737
7717
  nodes: [],
6738
7718
  settings: { ...defaultSettings },
7719
+ stripe: null,
6739
7720
  layout: "portal",
6740
7721
  error: void 0,
6741
7722
  setData: () => {
6742
7723
  },
6743
7724
  updateSettings: () => {
6744
7725
  },
7726
+ setStripe: () => {
7727
+ },
6745
7728
  setLayout: () => {
6746
7729
  }
6747
7730
  };
@@ -6758,13 +7741,21 @@ var EmbedProvider = ({
6758
7741
  styleRef.current = style;
6759
7742
  }, []);
6760
7743
  (0, import_react2.useEffect)(() => {
6761
- if (!id || !accessToken) {
7744
+ if (!accessToken) {
7745
+ return;
7746
+ }
7747
+ const config = new Configuration({ ...apiConfig, apiKey: accessToken });
7748
+ const api = new CheckoutApi(config);
7749
+ setState((prev2) => ({ ...prev2, api }));
7750
+ }, [accessToken, apiConfig]);
7751
+ (0, import_react2.useEffect)(() => {
7752
+ if (!id || !state.api) {
6762
7753
  return;
6763
7754
  }
6764
- fetchComponent(id, accessToken, apiConfig).then((resolvedData) => {
7755
+ fetchComponent(id, state.api).then(async (resolvedData) => {
6765
7756
  setState((prev2) => ({ ...prev2, ...resolvedData }));
6766
7757
  }).catch((error) => setState((prev2) => ({ ...prev2, error })));
6767
- }, [id, accessToken, apiConfig]);
7758
+ }, [id, state.api]);
6768
7759
  (0, import_react2.useEffect)(() => {
6769
7760
  const fontSet = /* @__PURE__ */ new Set([]);
6770
7761
  Object.values(state.settings.theme.typography).forEach(({ fontFamily }) => {
@@ -6779,18 +7770,29 @@ var EmbedProvider = ({
6779
7770
  }, [state.settings.theme.typography]);
6780
7771
  const setData = (0, import_react2.useCallback)(
6781
7772
  (data) => {
6782
- setState((prev2) => ({
6783
- ...prev2,
6784
- data: Object.assign({}, data)
6785
- }));
7773
+ setState((prev2) => {
7774
+ const updated = { ...prev2 };
7775
+ (0, import_lodash.default)(updated.data, data);
7776
+ return updated;
7777
+ });
6786
7778
  },
6787
7779
  [setState]
6788
7780
  );
6789
7781
  const updateSettings = (0, import_react2.useCallback)(
6790
7782
  (settings) => {
7783
+ setState((prev2) => {
7784
+ const updated = { ...prev2 };
7785
+ (0, import_lodash.default)(updated.settings, settings);
7786
+ return updated;
7787
+ });
7788
+ },
7789
+ [setState]
7790
+ );
7791
+ const setStripe = (0, import_react2.useCallback)(
7792
+ (stripe) => {
6791
7793
  setState((prev2) => ({
6792
7794
  ...prev2,
6793
- settings: Object.assign({}, prev2.settings, settings)
7795
+ stripe
6794
7796
  }));
6795
7797
  },
6796
7798
  [setState]
@@ -6804,20 +7806,64 @@ var EmbedProvider = ({
6804
7806
  },
6805
7807
  [setState]
6806
7808
  );
7809
+ const renderChildren = () => {
7810
+ if (state.stripe) {
7811
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
7812
+ import_react_stripe_js.Elements,
7813
+ {
7814
+ stripe: state.stripe,
7815
+ options: {
7816
+ appearance: {
7817
+ theme: "stripe",
7818
+ variables: {
7819
+ // Base
7820
+ spacingUnit: ".25rem",
7821
+ colorPrimary: "#0570de",
7822
+ colorBackground: "#FFFFFF",
7823
+ colorText: "#30313d",
7824
+ colorDanger: "#df1b41",
7825
+ fontFamily: "Public Sans, system-ui, sans-serif",
7826
+ borderRadius: ".5rem",
7827
+ // Layout
7828
+ gridRowSpacing: "1.5rem",
7829
+ gridColumnSpacing: "1.5rem"
7830
+ },
7831
+ rules: {
7832
+ ".Label": {
7833
+ color: "#020202",
7834
+ fontWeight: "400",
7835
+ fontSize: "16px",
7836
+ marginBottom: "12px"
7837
+ }
7838
+ }
7839
+ },
7840
+ ...state.data.stripeEmbed?.customerEkey ? {
7841
+ clientSecret: state.data.stripeEmbed.customerEkey
7842
+ } : { mode: "payment", currency: "usd", amount: 999999 }
7843
+ },
7844
+ children
7845
+ }
7846
+ );
7847
+ }
7848
+ return children;
7849
+ };
6807
7850
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
6808
7851
  EmbedContext.Provider,
6809
7852
  {
6810
7853
  value: {
7854
+ api: state.api,
6811
7855
  data: state.data,
6812
7856
  nodes: state.nodes,
6813
7857
  settings: state.settings,
7858
+ stripe: state.stripe,
6814
7859
  layout: state.layout,
6815
7860
  error: state.error,
6816
7861
  setData,
6817
7862
  updateSettings,
7863
+ setStripe,
6818
7864
  setLayout
6819
7865
  },
6820
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ot, { theme: state.settings.theme, children })
7866
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ot, { theme: state.settings.theme, children: renderChildren() })
6821
7867
  }
6822
7868
  );
6823
7869
  };
@@ -6852,11 +7898,11 @@ var require_browser_polyfill = __commonJS2({
6852
7898
  "node_modules/cross-fetch/dist/browser-polyfill.js"(exports) {
6853
7899
  (function(self2) {
6854
7900
  var irrelevant = function(exports2) {
6855
- var global = typeof globalThis !== "undefined" && globalThis || typeof self2 !== "undefined" && self2 || typeof global !== "undefined" && global;
7901
+ var global2 = typeof globalThis !== "undefined" && globalThis || typeof self2 !== "undefined" && self2 || typeof global2 !== "undefined" && global2;
6856
7902
  var support = {
6857
- searchParams: "URLSearchParams" in global,
6858
- iterable: "Symbol" in global && "iterator" in Symbol,
6859
- blob: "FileReader" in global && "Blob" in global && function() {
7903
+ searchParams: "URLSearchParams" in global2,
7904
+ iterable: "Symbol" in global2 && "iterator" in Symbol,
7905
+ blob: "FileReader" in global2 && "Blob" in global2 && function() {
6860
7906
  try {
6861
7907
  new Blob();
6862
7908
  return true;
@@ -6864,8 +7910,8 @@ var require_browser_polyfill = __commonJS2({
6864
7910
  return false;
6865
7911
  }
6866
7912
  }(),
6867
- formData: "FormData" in global,
6868
- arrayBuffer: "ArrayBuffer" in global
7913
+ formData: "FormData" in global2,
7914
+ arrayBuffer: "ArrayBuffer" in global2
6869
7915
  };
6870
7916
  function isDataView(obj) {
6871
7917
  return obj && DataView.prototype.isPrototypeOf(obj);
@@ -7242,7 +8288,7 @@ var require_browser_polyfill = __commonJS2({
7242
8288
  }
7243
8289
  return new Response(null, { status, headers: { location: url } });
7244
8290
  };
7245
- exports2.DOMException = global.DOMException;
8291
+ exports2.DOMException = global2.DOMException;
7246
8292
  try {
7247
8293
  new exports2.DOMException();
7248
8294
  } catch (err2) {
@@ -7294,7 +8340,7 @@ var require_browser_polyfill = __commonJS2({
7294
8340
  };
7295
8341
  function fixUrl(url) {
7296
8342
  try {
7297
- return url === "" && global.location.href ? global.location.href : url;
8343
+ return url === "" && global2.location.href ? global2.location.href : url;
7298
8344
  } catch (e) {
7299
8345
  return url;
7300
8346
  }
@@ -7333,11 +8379,11 @@ var require_browser_polyfill = __commonJS2({
7333
8379
  });
7334
8380
  }
7335
8381
  fetch2.polyfill = true;
7336
- if (!global.fetch) {
7337
- global.fetch = fetch2;
7338
- global.Headers = Headers;
7339
- global.Request = Request;
7340
- global.Response = Response;
8382
+ if (!global2.fetch) {
8383
+ global2.fetch = fetch2;
8384
+ global2.Headers = Headers;
8385
+ global2.Request = Request;
8386
+ global2.Response = Response;
7341
8387
  }
7342
8388
  exports2.Headers = Headers;
7343
8389
  exports2.Request = Request;
@@ -7755,11 +8801,9 @@ var useSchematicFlag = (key, opts) => {
7755
8801
  return value;
7756
8802
  };
7757
8803
 
7758
- // src/components/elements/card/Card.tsx
7759
- var import_react6 = require("react");
7760
-
7761
- // src/const/index.ts
7762
- var TEXT_BASE_SIZE = 16;
8804
+ // src/components/elements/plan-manager/PlanManager.tsx
8805
+ var import_react7 = require("react");
8806
+ var import_react_dom = require("react-dom");
7763
8807
 
7764
8808
  // src/utils/color.ts
7765
8809
  function hexToHSL(color) {
@@ -7871,6 +8915,9 @@ function camelToHyphen(str) {
7871
8915
  return str.replace(/([a-z][A-Z])/g, (g2) => `${g2[0]}-${g2[1].toLowerCase()}`);
7872
8916
  }
7873
8917
 
8918
+ // src/const/index.ts
8919
+ var TEXT_BASE_SIZE = 16;
8920
+
7874
8921
  // src/utils/style.ts
7875
8922
  function attr(key, value) {
7876
8923
  return typeof value !== "undefined" && lt`
@@ -7888,88 +8935,6 @@ attr.rem = function propAsRem(key, value) {
7888
8935
  `;
7889
8936
  };
7890
8937
 
7891
- // src/components/elements/card/styles.ts
7892
- var StyledCard = dt.div(
7893
- ({
7894
- theme,
7895
- $sectionLayout = "merged",
7896
- $borderRadius = 8,
7897
- $padding = 48,
7898
- $shadow = true
7899
- }) => {
7900
- return lt`
7901
- box-sizing: border-box;
7902
- font-size: ${TEXT_BASE_SIZE}px;
7903
-
7904
- *,
7905
- *::before,
7906
- *::after {
7907
- box-sizing: inherit;
7908
- }
7909
-
7910
- > * {
7911
- padding: ${$padding * 0.75 / TEXT_BASE_SIZE}rem
7912
- ${$padding / TEXT_BASE_SIZE}rem;
7913
- color: ${theme.typography.text.color};
7914
- }
7915
-
7916
- ${() => {
7917
- const { l: l2 } = hexToHSL(theme.card.background);
7918
- const borderColor = l2 > 50 ? darken(theme.card.background, 10) : lighten(theme.card.background, 30);
7919
- const borderRadius = `${$borderRadius / TEXT_BASE_SIZE}rem`;
7920
- const boxShadow = "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A";
7921
- if ($sectionLayout === "merged") {
7922
- return lt`
7923
- background: ${({ theme: theme2 }) => theme2.card.background};
7924
- border-radius: ${borderRadius};
7925
-
7926
- ${$shadow && `box-shadow: ${boxShadow};`}
7927
-
7928
- > :not(:last-child) {
7929
- border-bottom: 1px solid ${borderColor};
7930
- }
7931
- `;
7932
- }
7933
- return lt`
7934
- > :not(:last-child) {
7935
- margin-bottom: 1rem;
7936
- }
7937
-
7938
- > * {
7939
- background: ${theme.card.background};
7940
- border-radius: ${borderRadius};
7941
- ${$shadow && `box-shadow: ${boxShadow};`}
7942
- }
7943
- `;
7944
- }}
7945
- `;
7946
- }
7947
- );
7948
-
7949
- // src/components/elements/card/Card.tsx
7950
- var import_jsx_runtime3 = require("react/jsx-runtime");
7951
- var Card = (0, import_react6.forwardRef)(
7952
- ({ children, className }, ref) => {
7953
- const { settings } = useEmbed();
7954
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
7955
- StyledCard,
7956
- {
7957
- ref,
7958
- className,
7959
- $sectionLayout: settings.theme?.sectionLayout,
7960
- $borderRadius: settings.theme?.card?.borderRadius,
7961
- $padding: settings.theme?.card?.padding,
7962
- $shadow: settings.theme?.card?.hasShadow,
7963
- children
7964
- }
7965
- );
7966
- }
7967
- );
7968
-
7969
- // src/components/elements/plan-manager/PlanManager.tsx
7970
- var import_react7 = require("react");
7971
- var import_react_dom = require("react-dom");
7972
-
7973
8938
  // src/components/ui/box/styles.ts
7974
8939
  var Box = dt.div((props) => {
7975
8940
  const initialStyles = [];
@@ -8087,7 +9052,7 @@ var Button = dt.button`
8087
9052
  `;
8088
9053
 
8089
9054
  // src/components/ui/button/Button.tsx
8090
- var import_jsx_runtime4 = require("react/jsx-runtime");
9055
+ var import_jsx_runtime3 = require("react/jsx-runtime");
8091
9056
  var Button2 = ({
8092
9057
  color = "white",
8093
9058
  size = "md",
@@ -8096,7 +9061,7 @@ var Button2 = ({
8096
9061
  children,
8097
9062
  ...props
8098
9063
  }) => {
8099
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
9064
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8100
9065
  Button,
8101
9066
  {
8102
9067
  $color: color,
@@ -8127,6 +9092,7 @@ var Container = dt.div`
8127
9092
  display: flex;
8128
9093
  justify-content: center;
8129
9094
  align-items: center;
9095
+ flex-shrink: 0;
8130
9096
  border-radius: 9999px;
8131
9097
  ${({ $size }) => {
8132
9098
  const base = 24;
@@ -8163,13 +9129,13 @@ var Container = dt.div`
8163
9129
  `;
8164
9130
 
8165
9131
  // src/components/ui/icon/Icon.tsx
8166
- var import_jsx_runtime5 = require("react/jsx-runtime");
9132
+ var import_jsx_runtime4 = require("react/jsx-runtime");
8167
9133
  var Icon2 = ({ name, className, ...props }) => {
8168
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { className: (0, import_classnames.default)("i", `i-${name}`, className), ...props });
9134
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { className: (0, import_classnames.default)("i", `i-${name}`, className), ...props });
8169
9135
  };
8170
9136
 
8171
9137
  // src/components/ui/icon/IconRound.tsx
8172
- var import_jsx_runtime6 = require("react/jsx-runtime");
9138
+ var import_jsx_runtime5 = require("react/jsx-runtime");
8173
9139
  var IconRound = ({
8174
9140
  name,
8175
9141
  variant = "filled",
@@ -8177,7 +9143,7 @@ var IconRound = ({
8177
9143
  colors = ["white", "#e5e7eb"],
8178
9144
  ...props
8179
9145
  }) => {
8180
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Container, { $size: size, $variant: variant, $colors: colors, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon2, { name }) });
9146
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Container, { $size: size, $variant: variant, $colors: colors, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon2, { name }) });
8181
9147
  };
8182
9148
 
8183
9149
  // src/components/ui/progress-bar/styles.ts
@@ -8186,7 +9152,7 @@ var Container2 = dt(Flex)`
8186
9152
  `;
8187
9153
 
8188
9154
  // src/components/ui/progress-bar/ProgressBar.tsx
8189
- var import_jsx_runtime7 = require("react/jsx-runtime");
9155
+ var import_jsx_runtime6 = require("react/jsx-runtime");
8190
9156
  var ProgressBar = ({
8191
9157
  progress,
8192
9158
  value,
@@ -8202,21 +9168,21 @@ var ProgressBar = ({
8202
9168
  orange: "#DB6769",
8203
9169
  red: "#EF4444"
8204
9170
  };
8205
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
9171
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8206
9172
  Container2,
8207
9173
  {
8208
9174
  $alignItems: "center",
8209
9175
  $gap: `${16 / TEXT_BASE_SIZE}rem`,
8210
9176
  ...props,
8211
9177
  children: [
8212
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
9178
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8213
9179
  Flex,
8214
9180
  {
8215
9181
  $position: "relative",
8216
9182
  $alignItems: "center",
8217
9183
  $width: `${barWidth}`,
8218
9184
  $maxWidth: "100%",
8219
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
9185
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8220
9186
  Flex,
8221
9187
  {
8222
9188
  $position: "relative",
@@ -8225,7 +9191,7 @@ var ProgressBar = ({
8225
9191
  $height: `${8 / TEXT_BASE_SIZE}rem`,
8226
9192
  $background: "#F2F4F7",
8227
9193
  $borderRadius: "9999px",
8228
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
9194
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8229
9195
  Box,
8230
9196
  {
8231
9197
  $width: `${Math.min(progress, 100)}%`,
@@ -8238,7 +9204,7 @@ var ProgressBar = ({
8238
9204
  )
8239
9205
  }
8240
9206
  ),
8241
- total !== 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { $size: 14, $weight: 500, children: [
9207
+ total !== 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { $size: 14, $weight: 500, children: [
8242
9208
  value,
8243
9209
  "/",
8244
9210
  total
@@ -8248,41 +9214,61 @@ var ProgressBar = ({
8248
9214
  );
8249
9215
  };
8250
9216
 
9217
+ // src/components/elements/plan-manager/CheckoutForm.tsx
9218
+ var import_react6 = require("react");
9219
+ var import_react_stripe_js2 = require("@stripe/react-stripe-js");
9220
+ var import_react_stripe_js3 = require("@stripe/react-stripe-js");
9221
+
8251
9222
  // src/components/elements/plan-manager/styles.ts
8252
9223
  var StyledButton = dt(Button2)`
8253
9224
  font-family: "Public Sans", sans-serif;
8254
9225
  font-weight: 500;
8255
9226
  text-align: center;
8256
9227
  width: 100%;
8257
- ${({ $color = "primary", theme }) => {
9228
+ ${({ disabled, $color = "primary", theme }) => {
8258
9229
  const { l: l2 } = hexToHSL(theme[$color]);
8259
- const color = l2 > 50 ? "#000000" : "#FFFFFF";
9230
+ const textColor = disabled ? "#989898" : l2 > 50 ? "#000000" : "#FFFFFF";
8260
9231
  return lt`
8261
- color: ${color};
9232
+ color: ${textColor};
8262
9233
 
8263
9234
  ${Text} {
8264
- color: ${color};
9235
+ color: ${textColor};
8265
9236
  }
8266
9237
  `;
8267
9238
  }};
8268
9239
 
8269
- ${({ $color = "primary", theme }) => {
8270
- const color = theme[$color];
8271
- return lt`
8272
- background-color: ${color};
8273
- border-color: ${color};
8274
- `;
9240
+ ${({ disabled, $color = "primary", theme, $variant = "filled" }) => {
9241
+ const color = disabled ? "#EEEEEE" : theme[$color];
9242
+ return $variant === "filled" ? lt`
9243
+ background-color: ${color};
9244
+ border-color: ${color};
9245
+ ` : lt`
9246
+ background-color: transparent;
9247
+ border-color: #d2d2d2;
9248
+ color: #194bfb;
9249
+ ${Text} {
9250
+ color: #194bfb;
9251
+ }
9252
+ `;
8275
9253
  }}
8276
9254
 
8277
9255
  &:hover {
8278
- ${({ $color = "primary", theme }) => {
9256
+ ${({ disabled }) => disabled && "cursor: not-allowed;"}
9257
+ ${({ disabled, $color = "primary", theme, $variant = "filled" }) => {
8279
9258
  const specified = theme[$color];
8280
9259
  const lightened = lighten(specified, 15);
8281
- const color = specified === lightened ? darken(specified, 15) : lightened;
8282
- return lt`
8283
- background-color: ${color};
8284
- border-color: ${color};
8285
- `;
9260
+ const color = disabled ? "#EEEEEE" : specified === lightened ? darken(specified, 15) : lightened;
9261
+ return $variant === "filled" ? lt`
9262
+ background-color: ${color};
9263
+ border-color: ${color};
9264
+ ` : lt`
9265
+ background-color: ${color};
9266
+ border-color: ${color};
9267
+ color: #ffffff;
9268
+ ${Text} {
9269
+ color: #ffffff;
9270
+ }
9271
+ `;
8286
9272
  }}
8287
9273
  }
8288
9274
 
@@ -8292,168 +9278,547 @@ var StyledButton = dt(Button2)`
8292
9278
  return lt`
8293
9279
  font-size: ${15 / 16}rem;
8294
9280
  padding: ${12 / 16}rem 0;
8295
- border-radius: ${8 / 16}rem;
9281
+ border-radius: ${6 / 16}rem;
8296
9282
  `;
8297
9283
  case "md":
8298
9284
  return lt`
8299
9285
  font-size: ${17 / 16}rem;
8300
9286
  padding: ${16 / 16}rem 0;
8301
- border-radius: ${10 / 16}rem;
9287
+ border-radius: ${8 / 16}rem;
8302
9288
  `;
8303
9289
  case "lg":
8304
9290
  return lt`
8305
9291
  font-size: ${19 / 16}rem;
8306
9292
  padding: ${20 / 16}rem 0;
8307
- border-radius: ${12 / 16}rem;
9293
+ border-radius: ${10 / 16}rem;
8308
9294
  `;
8309
9295
  }
8310
9296
  }}
8311
9297
  `;
8312
9298
 
8313
- // src/components/elements/plan-manager/PlanManager.tsx
8314
- var import_jsx_runtime8 = require("react/jsx-runtime");
8315
- var resolveDesignProps = (props) => {
8316
- return {
8317
- header: {
8318
- isVisible: props.header?.isVisible ?? true,
8319
- title: {
8320
- fontStyle: props.header?.title?.fontStyle ?? "heading1"
8321
- },
8322
- description: {
8323
- isVisible: props.header?.description?.isVisible ?? true,
8324
- fontStyle: props.header?.description?.fontStyle ?? "text"
8325
- },
8326
- price: {
8327
- isVisible: props.header?.price?.isVisible ?? true,
8328
- fontStyle: props.header?.price?.fontStyle ?? "text"
9299
+ // src/components/elements/plan-manager/CheckoutForm.tsx
9300
+ var import_jsx_runtime7 = require("react/jsx-runtime");
9301
+ var CheckoutForm = ({ plan, period }) => {
9302
+ const stripe = (0, import_react_stripe_js3.useStripe)();
9303
+ const elements = (0, import_react_stripe_js3.useElements)();
9304
+ const { api, data } = useEmbed();
9305
+ const [message, setMessage] = (0, import_react6.useState)(null);
9306
+ const [isLoading, setIsLoading] = (0, import_react6.useState)(false);
9307
+ const handleSubmit = async (event) => {
9308
+ event.preventDefault();
9309
+ const priceId = period === "month" ? plan.monthlyPrice?.id : plan.yearlyPrice?.id;
9310
+ if (!api || !stripe || !elements || !priceId) {
9311
+ return;
9312
+ }
9313
+ setIsLoading(true);
9314
+ const { error } = await stripe.confirmPayment({
9315
+ elements,
9316
+ confirmParams: {
9317
+ return_url: window.location.href
8329
9318
  }
8330
- },
8331
- addOns: {
8332
- isVisible: props.addOns?.isVisible ?? true,
8333
- fontStyle: props.addOns?.fontStyle ?? "heading4",
8334
- showLabel: props.addOns?.showLabel ?? true
8335
- },
8336
- callToAction: {
8337
- isVisible: props.callToAction?.isVisible ?? true,
8338
- buttonSize: props.callToAction?.buttonSize ?? "md",
8339
- buttonStyle: props.callToAction?.buttonStyle ?? "secondary"
9319
+ });
9320
+ if (error.type === "card_error" || error.type === "validation_error") {
9321
+ setMessage(error.message);
9322
+ } else {
9323
+ setMessage("An unexpected error occured.");
8340
9324
  }
9325
+ setIsLoading(false);
8341
9326
  };
8342
- };
8343
- var PlanManager = (0, import_react7.forwardRef)(({ children, className, portal, ...rest }, ref) => {
8344
- const props = resolveDesignProps(rest);
8345
- const { data, settings, layout, setLayout } = useEmbed();
8346
- const { plan, plans, addOns } = (0, import_react7.useMemo)(() => {
8347
- return {
8348
- plan: data.company?.plan || {},
8349
- plans: data.company?.plans?.map(({ name, description }) => ({
8350
- name,
8351
- description,
8352
- price: void 0
8353
- })) || [],
8354
- addOns: data.company?.addOns?.map(({ name, description }) => ({
8355
- name,
8356
- description,
8357
- price: void 0
8358
- })) || []
8359
- };
8360
- }, [data.company]);
8361
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref, className, children: [
8362
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Flex, { $flexDirection: "column", $gap: "0.75rem", $margin: "0 0 3rem", children: [
8363
- props.header.isVisible && plan && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
8364
- Flex,
8365
- {
8366
- $justifyContent: "space-between",
8367
- $alignItems: "center",
8368
- $width: "100%",
8369
- $margin: "0 0 1.5rem",
8370
- children: [
8371
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
8372
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { $margin: "0 0 0.75rem", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
8373
- Text,
8374
- {
8375
- $font: settings.theme.typography[props.header.title.fontStyle].fontFamily,
8376
- $size: settings.theme.typography[props.header.title.fontStyle].fontSize,
8377
- $weight: settings.theme.typography[props.header.title.fontStyle].fontWeight,
8378
- $color: settings.theme.typography[props.header.title.fontStyle].color,
8379
- $lineHeight: 1,
8380
- children: plan.name
8381
- }
8382
- ) }),
8383
- props.header.description.isVisible && plan.description && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
8384
- Text,
8385
- {
8386
- $font: settings.theme.typography[props.header.description.fontStyle].fontFamily,
8387
- $size: settings.theme.typography[props.header.description.fontStyle].fontSize,
8388
- $weight: settings.theme.typography[props.header.description.fontStyle].fontWeight,
8389
- $color: settings.theme.typography[props.header.description.fontStyle].color,
8390
- children: plan.description
8391
- }
8392
- )
8393
- ] }),
8394
- props.header.price.isVisible && plan.planPrice >= 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
8395
- Text,
8396
- {
8397
- $font: settings.theme.typography[props.header.price.fontStyle].fontFamily,
8398
- $size: settings.theme.typography[props.header.price.fontStyle].fontSize,
8399
- $weight: settings.theme.typography[props.header.price.fontStyle].fontWeight,
8400
- $color: settings.theme.typography[props.header.price.fontStyle].color,
8401
- children: [
8402
- "$",
8403
- plan.planPrice,
8404
- "/",
8405
- plan.planPeriod
8406
- ]
8407
- }
8408
- )
8409
- ]
8410
- }
8411
- ),
8412
- props.addOns.isVisible && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
8413
- props.addOns.showLabel && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
8414
- Text,
9327
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
9328
+ "form",
9329
+ {
9330
+ id: "payment-form",
9331
+ onSubmit: handleSubmit,
9332
+ style: {
9333
+ display: "flex",
9334
+ flexDirection: "column",
9335
+ height: "100%"
9336
+ },
9337
+ children: [
9338
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
9339
+ Box,
8415
9340
  {
8416
- $font: settings.theme.typography.text.fontFamily,
8417
- $size: settings.theme.typography.text.fontSize,
8418
- $weight: 500,
8419
- $color: darken(settings.theme.typography.text.color, 20),
8420
- children: "Add-Ons"
9341
+ $fontSize: "18px",
9342
+ $marginBottom: "1.5rem",
9343
+ $display: "inline-block",
9344
+ $width: "100%",
9345
+ children: [
9346
+ "Add payment method",
9347
+ " "
9348
+ ]
8421
9349
  }
8422
9350
  ),
8423
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { $width: "100%", $margin: "0 0 1rem", children: addOns.map((addOn, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9351
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
9352
+ Flex,
9353
+ {
9354
+ $flexDirection: "column",
9355
+ $gap: "1.5rem",
9356
+ $marginBottom: "1.5rem",
9357
+ $width: "100%",
9358
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
9359
+ import_react_stripe_js2.LinkAuthenticationElement,
9360
+ {
9361
+ id: "link-authentication-element"
9362
+ }
9363
+ )
9364
+ }
9365
+ ),
9366
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Flex, { $flexDirection: "column", $width: "100%", $flex: "1", $height: "100%", children: [
9367
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_stripe_js2.PaymentElement, { id: "payment-element" }),
9368
+ message && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { id: "payment-message", children: message })
9369
+ ] }),
9370
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
9371
+ StyledButton,
9372
+ {
9373
+ id: "submit",
9374
+ disabled: isLoading || !stripe || !elements || !data.stripeEmbed?.publishableKey || !data.stripeEmbed?.customerEkey,
9375
+ $size: "md",
9376
+ $color: "secondary",
9377
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { id: "button-text", children: isLoading ? "Loading" : "Save payment method" })
9378
+ }
9379
+ ) })
9380
+ ]
9381
+ }
9382
+ );
9383
+ };
9384
+
9385
+ // src/components/elements/plan-manager/PlanManager.tsx
9386
+ var import_jsx_runtime8 = require("react/jsx-runtime");
9387
+ var OverlayHeader = ({
9388
+ children,
9389
+ onClose
9390
+ }) => {
9391
+ const { setLayout } = useEmbed();
9392
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9393
+ Flex,
9394
+ {
9395
+ $paddingLeft: "2.5rem",
9396
+ $paddingRight: "2.5rem",
9397
+ $padding: ".75rem 2.5rem",
9398
+ $flexDirection: "row",
9399
+ $justifyContent: "space-between",
9400
+ $alignItems: "center",
9401
+ $borderBottom: "1px solid #DEDEDE",
9402
+ $gap: "1rem",
9403
+ $backgroundColor: "#FFFFFF",
9404
+ $borderRadius: ".5rem .5rem 0 0",
9405
+ children: [
9406
+ children,
9407
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9408
+ Box,
9409
+ {
9410
+ $cursor: "pointer",
9411
+ onClick: () => {
9412
+ setLayout("portal");
9413
+ if (onClose) {
9414
+ onClose();
9415
+ }
9416
+ },
9417
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon2, { name: "close", style: { fontSize: 36, color: "#B8B8B8" } })
9418
+ }
9419
+ ) })
9420
+ ]
9421
+ }
9422
+ );
9423
+ };
9424
+ var OverlayWrapper = ({
9425
+ children,
9426
+ size = "lg"
9427
+ }) => {
9428
+ const sizeWidthMap = {
9429
+ md: "700px",
9430
+ lg: "75%"
9431
+ };
9432
+ const sizeHeighthMap = {
9433
+ md: "auto",
9434
+ lg: "75%"
9435
+ };
9436
+ const sizeMaxWidthMap = {
9437
+ md: "auto",
9438
+ lg: "1140px"
9439
+ };
9440
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9441
+ Box,
9442
+ {
9443
+ $position: "absolute",
9444
+ $top: "50%",
9445
+ $left: "50%",
9446
+ $zIndex: "999999",
9447
+ $transform: "translate(-50%, -50%)",
9448
+ $width: "100%",
9449
+ $height: "100%",
9450
+ $backgroundColor: "#D9D9D9",
9451
+ $overflow: "hidden",
9452
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9453
+ Flex,
9454
+ {
9455
+ $position: "relative",
9456
+ $top: "50%",
9457
+ $left: "50%",
9458
+ $transform: "translate(-50%, -50%)",
9459
+ $flexDirection: "column",
9460
+ $maxWidth: sizeMaxWidthMap[size],
9461
+ $width: sizeWidthMap[size],
9462
+ $height: sizeHeighthMap[size],
9463
+ $backgroundColor: "#FBFBFB",
9464
+ $borderBottom: "1px solid #DEDEDE",
9465
+ $borderRadius: "8px",
9466
+ $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
9467
+ id: "select-plan-dialog",
9468
+ role: "dialog",
9469
+ "aria-labelledby": "select-plan-dialog-label",
9470
+ "aria-modal": "true",
9471
+ children
9472
+ }
9473
+ )
9474
+ }
9475
+ );
9476
+ };
9477
+ var OverlaySideBar = ({
9478
+ pricePeriod,
9479
+ setPricePeriod,
9480
+ checkoutStage,
9481
+ setCheckoutStage,
9482
+ currentPlan,
9483
+ selectedPlan
9484
+ }) => {
9485
+ const { api } = useEmbed();
9486
+ const savingsPercentage = (0, import_react7.useMemo)(() => {
9487
+ if (selectedPlan && pricePeriod === "month") {
9488
+ const monthly = (selectedPlan?.monthlyPrice?.price || 0) * 12;
9489
+ const yearly = selectedPlan?.yearlyPrice?.price || 0;
9490
+ return (monthly - yearly) / monthly * 100;
9491
+ }
9492
+ return 0;
9493
+ }, [selectedPlan, pricePeriod]);
9494
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9495
+ Flex,
9496
+ {
9497
+ $flexDirection: "column",
9498
+ $background: "white",
9499
+ $borderRadius: "0 0 0.5rem",
9500
+ $maxWidth: "275px",
9501
+ $height: "100%",
9502
+ $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
9503
+ children: [
9504
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9505
+ Flex,
9506
+ {
9507
+ $flexDirection: "column",
9508
+ $position: "relative",
9509
+ $gap: "1rem",
9510
+ $width: "100%",
9511
+ $height: "auto",
9512
+ $padding: "1.5rem",
9513
+ $borderBottom: "1px solid #DEDEDE",
9514
+ children: [
9515
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Flex, { $flexDirection: "row", $justifyContent: "space-between", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { $size: 20, $weight: 600, children: "Subscription" }) }),
9516
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9517
+ Flex,
9518
+ {
9519
+ $flexDirection: "row",
9520
+ $border: "1px solid #D9D9D9",
9521
+ $borderRadius: "40px",
9522
+ $fontSize: "12px",
9523
+ $textAlign: "center",
9524
+ $cursor: "pointer",
9525
+ children: [
9526
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9527
+ Box,
9528
+ {
9529
+ onClick: () => setPricePeriod("month"),
9530
+ $padding: ".25rem .5rem",
9531
+ $flex: "1",
9532
+ $fontWeight: pricePeriod === "month" ? "600" : "400",
9533
+ $backgroundColor: pricePeriod === "month" ? "#DDDDDD" : "white",
9534
+ $borderRadius: "40px",
9535
+ children: "Billed monthly"
9536
+ }
9537
+ ),
9538
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9539
+ Box,
9540
+ {
9541
+ onClick: () => setPricePeriod("year"),
9542
+ $padding: ".25rem .5rem",
9543
+ $flex: "1",
9544
+ $fontWeight: pricePeriod === "year" ? "600" : "400",
9545
+ $backgroundColor: pricePeriod === "year" ? "#DDDDDD" : "white",
9546
+ $borderRadius: "40px",
9547
+ children: "Billed yearly"
9548
+ }
9549
+ )
9550
+ ]
9551
+ }
9552
+ ),
9553
+ savingsPercentage > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { $fontSize: "11px", $color: "#194BFB", children: [
9554
+ "Save up to ",
9555
+ savingsPercentage,
9556
+ "% with yearly billing"
9557
+ ] })
9558
+ ]
9559
+ }
9560
+ ),
9561
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9562
+ Flex,
9563
+ {
9564
+ $flexDirection: "column",
9565
+ $position: "relative",
9566
+ $gap: "1rem",
9567
+ $width: "100%",
9568
+ $height: "auto",
9569
+ $padding: "1.5rem",
9570
+ $flex: "1",
9571
+ $borderBottom: "1px solid #DEDEDE",
9572
+ children: [
9573
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { $fontSize: "14px", $color: "#5D5D5D", children: "Plan" }),
9574
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9575
+ Flex,
9576
+ {
9577
+ $flexDirection: "column",
9578
+ $fontSize: "14px",
9579
+ $color: "#5D5D5D",
9580
+ $gap: ".5rem",
9581
+ children: [
9582
+ currentPlan && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9583
+ Flex,
9584
+ {
9585
+ $flexDirection: "row",
9586
+ $alignItems: "center",
9587
+ $justifyContent: "space-between",
9588
+ $fontSize: "14px",
9589
+ $color: "#5D5D5D",
9590
+ children: [
9591
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Flex, { $fontSize: "14px", $color: "#5D5D5D", children: currentPlan.name }),
9592
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Flex, { $fontSize: "12px", $color: "#000000", children: [
9593
+ "$",
9594
+ currentPlan.planPrice,
9595
+ "/",
9596
+ currentPlan.planPeriod
9597
+ ] })
9598
+ ]
9599
+ }
9600
+ ),
9601
+ selectedPlan && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
9602
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9603
+ Box,
9604
+ {
9605
+ $width: "100%",
9606
+ $textAlign: "left",
9607
+ $opacity: "50%",
9608
+ $marginBottom: "-.25rem",
9609
+ $marginTop: "-.25rem",
9610
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9611
+ Icon2,
9612
+ {
9613
+ name: "arrow-down",
9614
+ style: {
9615
+ display: "inline-block"
9616
+ }
9617
+ }
9618
+ )
9619
+ }
9620
+ ),
9621
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9622
+ Flex,
9623
+ {
9624
+ $flexDirection: "row",
9625
+ $alignItems: "center",
9626
+ $justifyContent: "space-between",
9627
+ $fontSize: "14px",
9628
+ $color: "#5D5D5D",
9629
+ children: [
9630
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Flex, { $fontSize: "14px", $color: "#000000", $fontWeight: "600", children: selectedPlan.name }),
9631
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Flex, { $fontSize: "12px", $color: "#000000", children: [
9632
+ "$",
9633
+ pricePeriod === "month" ? selectedPlan.monthlyPrice?.price : selectedPlan.yearlyPrice?.price,
9634
+ "/",
9635
+ pricePeriod
9636
+ ] })
9637
+ ]
9638
+ }
9639
+ )
9640
+ ] })
9641
+ ]
9642
+ }
9643
+ )
9644
+ ]
9645
+ }
9646
+ ),
9647
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9648
+ Flex,
9649
+ {
9650
+ $flexDirection: "column",
9651
+ $position: "relative",
9652
+ $gap: ".75rem",
9653
+ $width: "100%",
9654
+ $height: "auto",
9655
+ $padding: "1.5rem",
9656
+ children: [
9657
+ selectedPlan && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9658
+ Flex,
9659
+ {
9660
+ $fontSize: "12px",
9661
+ $color: "#5D5D5D",
9662
+ $justifyContent: "space-between",
9663
+ children: [
9664
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { $fontSize: "12px", $color: "#5D5D5D", children: [
9665
+ "Monthly total:",
9666
+ " "
9667
+ ] }),
9668
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { $fontSize: "12px", $color: "#000000", children: [
9669
+ "$",
9670
+ pricePeriod === "month" ? selectedPlan.monthlyPrice?.price : selectedPlan.yearlyPrice?.price,
9671
+ "/",
9672
+ pricePeriod
9673
+ ] })
9674
+ ]
9675
+ }
9676
+ ),
9677
+ checkoutStage === "plan" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9678
+ StyledButton,
9679
+ {
9680
+ $size: "sm",
9681
+ onClick: () => {
9682
+ setCheckoutStage("checkout");
9683
+ },
9684
+ ...!selectedPlan && { disabled: true },
9685
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Flex, { $gap: "0.5rem", $alignItems: "center", $justifyContent: "center", children: [
9686
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "Next: Checkout" }),
9687
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon2, { name: "arrow-right" })
9688
+ ] })
9689
+ }
9690
+ ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9691
+ StyledButton,
9692
+ {
9693
+ disabled: !api || !selectedPlan || selectedPlan?.id === currentPlan?.id,
9694
+ onClick: async () => {
9695
+ const priceId = pricePeriod === "month" ? selectedPlan?.monthlyPrice?.id : selectedPlan?.yearlyPrice?.id;
9696
+ if (!api || !selectedPlan || !priceId)
9697
+ return;
9698
+ await api.checkout({
9699
+ changeSubscriptionRequestBody: {
9700
+ newPlanId: selectedPlan.id,
9701
+ newPriceId: priceId
9702
+ }
9703
+ });
9704
+ },
9705
+ $size: "md",
9706
+ children: "Pay now"
9707
+ }
9708
+ ),
9709
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Discounts & credits applied at checkout" })
9710
+ ]
9711
+ }
9712
+ )
9713
+ ]
9714
+ }
9715
+ );
9716
+ };
9717
+ var resolveDesignProps = (props) => {
9718
+ return {
9719
+ header: {
9720
+ isVisible: props.header?.isVisible ?? true,
9721
+ title: {
9722
+ fontStyle: props.header?.title?.fontStyle ?? "heading1"
9723
+ },
9724
+ description: {
9725
+ isVisible: props.header?.description?.isVisible ?? true,
9726
+ fontStyle: props.header?.description?.fontStyle ?? "text"
9727
+ },
9728
+ price: {
9729
+ isVisible: props.header?.price?.isVisible ?? true,
9730
+ fontStyle: props.header?.price?.fontStyle ?? "text"
9731
+ }
9732
+ },
9733
+ addOns: {
9734
+ isVisible: props.addOns?.isVisible ?? true,
9735
+ fontStyle: props.addOns?.fontStyle ?? "heading4",
9736
+ showLabel: props.addOns?.showLabel ?? true
9737
+ },
9738
+ callToAction: {
9739
+ isVisible: props.callToAction?.isVisible ?? true,
9740
+ buttonSize: props.callToAction?.buttonSize ?? "md",
9741
+ buttonStyle: props.callToAction?.buttonStyle ?? "secondary"
9742
+ }
9743
+ };
9744
+ };
9745
+ var PlanManager = (0, import_react7.forwardRef)(({ children, className, portal, ...rest }, ref) => {
9746
+ const props = resolveDesignProps(rest);
9747
+ const [checkoutStage, setCheckoutStage] = (0, import_react7.useState)(
9748
+ "plan"
9749
+ );
9750
+ const [planPeriod, setPlanPeriod] = (0, import_react7.useState)("month");
9751
+ const [selectedPlan, setSelectedPlan] = (0, import_react7.useState)();
9752
+ const { data, settings, layout, stripe, setLayout } = useEmbed();
9753
+ const { currentPlan, canChangePlan, availablePlans } = (0, import_react7.useMemo)(() => {
9754
+ return {
9755
+ currentPlan: data.company?.plan,
9756
+ canChangePlan: stripe !== null,
9757
+ availablePlans: data.activePlans
9758
+ };
9759
+ }, [data.company, data.activePlans, stripe]);
9760
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref, className, children: [
9761
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9762
+ Flex,
9763
+ {
9764
+ $flexDirection: "column",
9765
+ $gap: "0.75rem",
9766
+ ...canChangePlan && { $margin: "0 0 0.5rem" },
9767
+ children: props.header.isVisible && currentPlan && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
8424
9768
  Flex,
8425
9769
  {
8426
9770
  $justifyContent: "space-between",
8427
9771
  $alignItems: "center",
8428
9772
  $width: "100%",
9773
+ ...canChangePlan && { $margin: "0 0 1.5rem" },
8429
9774
  children: [
8430
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9775
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
9776
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { $margin: "0 0 0.75rem", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9777
+ Text,
9778
+ {
9779
+ $font: settings.theme.typography[props.header.title.fontStyle].fontFamily,
9780
+ $size: settings.theme.typography[props.header.title.fontStyle].fontSize,
9781
+ $weight: settings.theme.typography[props.header.title.fontStyle].fontWeight,
9782
+ $color: settings.theme.typography[props.header.title.fontStyle].color,
9783
+ $lineHeight: 1,
9784
+ children: currentPlan.name
9785
+ }
9786
+ ) }),
9787
+ props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9788
+ Text,
9789
+ {
9790
+ $font: settings.theme.typography[props.header.description.fontStyle].fontFamily,
9791
+ $size: settings.theme.typography[props.header.description.fontStyle].fontSize,
9792
+ $weight: settings.theme.typography[props.header.description.fontStyle].fontWeight,
9793
+ $color: settings.theme.typography[props.header.description.fontStyle].color,
9794
+ children: currentPlan.description
9795
+ }
9796
+ )
9797
+ ] }),
9798
+ props.header.price.isVisible && currentPlan.planPrice >= 0 && currentPlan.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
8431
9799
  Text,
8432
9800
  {
8433
- $font: settings.theme.typography[props.addOns.fontStyle].fontFamily,
8434
- $size: settings.theme.typography[props.addOns.fontStyle].fontSize,
8435
- $weight: settings.theme.typography[props.addOns.fontStyle].fontWeight,
8436
- $color: settings.theme.typography[props.addOns.fontStyle].color,
8437
- children: addOn.name
9801
+ $font: settings.theme.typography[props.header.price.fontStyle].fontFamily,
9802
+ $size: settings.theme.typography[props.header.price.fontStyle].fontSize,
9803
+ $weight: settings.theme.typography[props.header.price.fontStyle].fontWeight,
9804
+ $color: settings.theme.typography[props.header.price.fontStyle].color,
9805
+ children: [
9806
+ "$",
9807
+ currentPlan.planPrice,
9808
+ "/",
9809
+ currentPlan.planPeriod
9810
+ ]
8438
9811
  }
8439
- ),
8440
- addOn.price >= 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { $weight: 500, children: [
8441
- "$",
8442
- addOn.price,
8443
- "/mo"
8444
- ] })
9812
+ )
8445
9813
  ]
8446
- },
8447
- index
8448
- )) })
8449
- ] })
8450
- ] }),
8451
- props.callToAction.isVisible && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9814
+ }
9815
+ )
9816
+ }
9817
+ ),
9818
+ canChangePlan && props.callToAction.isVisible && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
8452
9819
  StyledButton,
8453
9820
  {
8454
9821
  onClick: () => {
8455
- if (layout !== "checkout")
8456
- return;
8457
9822
  setLayout("checkout");
8458
9823
  },
8459
9824
  $size: props.callToAction.buttonSize,
@@ -8469,83 +9834,298 @@ var PlanManager = (0, import_react7.forwardRef)(({ children, className, portal,
8469
9834
  )
8470
9835
  }
8471
9836
  ),
8472
- children,
8473
- layout === "checkout" && (0, import_react_dom.createPortal)(
8474
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
8475
- Box,
8476
- {
8477
- $position: "absolute",
8478
- $top: "50%",
8479
- $left: "50%",
8480
- $zIndex: "999999",
8481
- $transform: "translate(-50%, -50%)",
8482
- $width: "100%",
8483
- $height: "100%",
8484
- $backgroundColor: "#B5B5B580",
8485
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9837
+ canChangePlan && layout === "checkout" && (0, import_react_dom.createPortal)(
9838
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(OverlayWrapper, { children: [
9839
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OverlayHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Flex, { $gap: "1rem", children: [
9840
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Flex, { $flexDirection: "row", $gap: "0.5rem", $alignItems: "center", children: [
9841
+ checkoutStage === "plan" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9842
+ Box,
9843
+ {
9844
+ $width: "15px",
9845
+ $height: "15px",
9846
+ $backgroundColor: "white",
9847
+ $border: "2px solid #DDDDDD",
9848
+ $borderRadius: "999px"
9849
+ }
9850
+ ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9851
+ IconRound,
9852
+ {
9853
+ name: "check",
9854
+ style: {
9855
+ color: "#FFFFFF",
9856
+ backgroundColor: "#DDDDDD",
9857
+ fontSize: 16,
9858
+ width: "1rem",
9859
+ height: "1rem"
9860
+ }
9861
+ }
9862
+ ),
9863
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9864
+ "div",
9865
+ {
9866
+ tabIndex: 0,
9867
+ ...checkoutStage === "plan" ? {
9868
+ style: {
9869
+ fontWeight: "700"
9870
+ }
9871
+ } : {
9872
+ style: {
9873
+ cursor: "pointer"
9874
+ },
9875
+ onClick: () => setCheckoutStage("plan")
9876
+ },
9877
+ children: "1. Select plan"
9878
+ }
9879
+ ),
9880
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9881
+ Icon2,
9882
+ {
9883
+ name: "chevron-right",
9884
+ style: { fontSize: 16, color: "#D0D0D0" }
9885
+ }
9886
+ )
9887
+ ] }),
9888
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Flex, { $flexDirection: "row", $gap: "0.5rem", $alignItems: "center", children: [
9889
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9890
+ Box,
9891
+ {
9892
+ $width: "15px",
9893
+ $height: "15px",
9894
+ $border: "2px solid #DDDDDD",
9895
+ $borderRadius: "999px",
9896
+ $backgroundColor: "white"
9897
+ }
9898
+ ),
9899
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9900
+ "div",
9901
+ {
9902
+ tabIndex: 0,
9903
+ ...checkoutStage === "checkout" && {
9904
+ style: {
9905
+ fontWeight: "700"
9906
+ }
9907
+ },
9908
+ children: "2. Checkout"
9909
+ }
9910
+ )
9911
+ ] })
9912
+ ] }) }),
9913
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Flex, { $flexDirection: "row", $height: "100%", children: [
9914
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
8486
9915
  Flex,
8487
9916
  {
8488
- $position: "relative",
8489
- $top: "50%",
8490
- $left: "50%",
8491
- $transform: "translate(-50%, -50%)",
8492
- $width: "956px",
8493
- $height: "700px",
9917
+ $flexDirection: "column",
9918
+ $gap: "1rem",
9919
+ $padding: "2rem 2.5rem 2rem 2.5rem",
8494
9920
  $backgroundColor: "#FBFBFB",
8495
- $borderRadius: "8px",
8496
- $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
8497
- id: "select-plan-dialog",
8498
- role: "dialog",
8499
- "aria-labelledby": "select-plan-dialog-label",
8500
- "aria-modal": "true",
9921
+ $borderRadius: "0 0.5rem 0",
9922
+ $flex: "1",
9923
+ $height: "100%",
8501
9924
  children: [
8502
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
8503
- Box,
8504
- {
8505
- $position: "absolute",
8506
- $top: "0.25rem",
8507
- $right: "0.75rem",
8508
- $cursor: "pointer",
8509
- onClick: () => {
8510
- setLayout("portal");
8511
- },
8512
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon2, { name: "close", style: { fontSize: 36, color: "#B8B8B8" } })
8513
- }
8514
- ),
8515
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
8516
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
8517
- Text,
9925
+ checkoutStage === "plan" && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
9926
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9927
+ Flex,
8518
9928
  {
8519
- as: "h1",
8520
- id: "select-plan-dialog-label",
8521
- $size: 24,
8522
- $weight: 800,
8523
- children: "Select plan"
9929
+ $flexDirection: "column",
9930
+ $gap: "1rem",
9931
+ $marginBottom: "1rem",
9932
+ children: [
9933
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9934
+ Text,
9935
+ {
9936
+ as: "h1",
9937
+ id: "select-plan-dialog-label",
9938
+ $size: 18,
9939
+ $marginBottom: ".5rem",
9940
+ children: "Select plan"
9941
+ }
9942
+ ),
9943
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9944
+ Text,
9945
+ {
9946
+ as: "p",
9947
+ id: "select-plan-dialog-description",
9948
+ $size: 14,
9949
+ $weight: 400,
9950
+ children: "Choose your base plan"
9951
+ }
9952
+ )
9953
+ ]
8524
9954
  }
8525
9955
  ),
8526
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Flex, { $flexDirection: "column", $gap: "1rem", children: plans.map((plan2, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9956
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
8527
9957
  Flex,
8528
9958
  {
8529
- $justifyContent: "space-between",
8530
- $alignItems: "center",
8531
- $width: "100%",
8532
- children: [
8533
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { $size: 20, $weight: 800, children: plan2.name }),
8534
- plan2.price >= 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { children: [
8535
- "$",
8536
- plan2.price,
8537
- "/mo"
8538
- ] })
8539
- ]
8540
- },
8541
- index
8542
- )) })
8543
- ] })
9959
+ $flexDirection: "row",
9960
+ $gap: "1rem",
9961
+ $flex: "1",
9962
+ $height: "100%",
9963
+ children: availablePlans?.map((plan) => {
9964
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9965
+ Flex,
9966
+ {
9967
+ $height: "100%",
9968
+ $flexDirection: "column",
9969
+ $backgroundColor: "white",
9970
+ $flex: "1",
9971
+ $border: `2px solid ${plan.id === selectedPlan?.id ? "#194BFB" : "transparent"}`,
9972
+ $borderRadius: ".5rem",
9973
+ $boxShadow: "0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 20px rgba(16, 24, 40, 0.06)",
9974
+ children: [
9975
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
9976
+ Flex,
9977
+ {
9978
+ $flexDirection: "column",
9979
+ $position: "relative",
9980
+ $gap: "1rem",
9981
+ $width: "100%",
9982
+ $height: "auto",
9983
+ $padding: "2rem 1.5rem 1.5rem",
9984
+ $borderBottom: "1px solid #DEDEDE",
9985
+ children: [
9986
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { $size: 20, $weight: 600, children: plan.name }),
9987
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { $size: 14, children: plan.description }),
9988
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { children: [
9989
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { $display: "inline-block", $fontSize: ".90rem", children: "$" }),
9990
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { $display: "inline-block", $fontSize: "1.5rem", children: (planPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price }),
9991
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { $display: "inline-block", $fontSize: ".75rem", children: [
9992
+ "/",
9993
+ planPeriod
9994
+ ] })
9995
+ ] }),
9996
+ (plan.current || plan.id === currentPlan?.id) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9997
+ Flex,
9998
+ {
9999
+ $position: "absolute",
10000
+ $right: "1rem",
10001
+ $top: "1rem",
10002
+ $fontSize: ".625rem",
10003
+ $color: "white",
10004
+ $backgroundColor: "#194BFB",
10005
+ $borderRadius: "999px",
10006
+ $padding: ".125rem .85rem",
10007
+ children: "Current plan"
10008
+ }
10009
+ )
10010
+ ]
10011
+ }
10012
+ ),
10013
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
10014
+ Flex,
10015
+ {
10016
+ $flexDirection: "column",
10017
+ $position: "relative",
10018
+ $gap: "0.5rem",
10019
+ $flex: "1",
10020
+ $width: "100%",
10021
+ $height: "auto",
10022
+ $padding: "1.5rem",
10023
+ children: plan.features.map((feature) => {
10024
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
10025
+ Flex,
10026
+ {
10027
+ $flexShrink: "0",
10028
+ $gap: "1rem",
10029
+ children: [
10030
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
10031
+ IconRound,
10032
+ {
10033
+ name: feature.icon,
10034
+ size: "tn",
10035
+ colors: ["#000000", "#F5F5F5"]
10036
+ }
10037
+ ),
10038
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { $size: ".75rem", $color: "#00000", children: feature.name }) })
10039
+ ]
10040
+ },
10041
+ feature.id
10042
+ );
10043
+ })
10044
+ }
10045
+ ),
10046
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
10047
+ Flex,
10048
+ {
10049
+ $flexDirection: "column",
10050
+ $position: "relative",
10051
+ $gap: "1rem",
10052
+ $width: "100%",
10053
+ $height: "auto",
10054
+ $padding: "1.5rem",
10055
+ children: [
10056
+ plan.id === selectedPlan?.id && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
10057
+ Flex,
10058
+ {
10059
+ $justifyContent: "center",
10060
+ $alignItems: "center",
10061
+ $gap: "0.25rem",
10062
+ $fontSize: "0.9375rem",
10063
+ $padding: "0.625rem 0",
10064
+ children: [
10065
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
10066
+ Icon2,
10067
+ {
10068
+ name: "check-rounded",
10069
+ style: {
10070
+ fontSize: 20,
10071
+ lineHeight: "1",
10072
+ color: "#194BFB"
10073
+ }
10074
+ }
10075
+ ),
10076
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
10077
+ "span",
10078
+ {
10079
+ style: {
10080
+ color: "#7B7B7B",
10081
+ lineHeight: "1.4"
10082
+ },
10083
+ children: "Selected"
10084
+ }
10085
+ )
10086
+ ]
10087
+ }
10088
+ ),
10089
+ !(plan.current || plan.id === currentPlan?.id) && plan.id !== selectedPlan?.id && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
10090
+ StyledButton,
10091
+ {
10092
+ $size: "sm",
10093
+ $color: "secondary",
10094
+ $variant: "outline",
10095
+ onClick: () => {
10096
+ setSelectedPlan(plan);
10097
+ },
10098
+ children: "Select"
10099
+ }
10100
+ )
10101
+ ]
10102
+ }
10103
+ )
10104
+ ]
10105
+ },
10106
+ plan.id
10107
+ );
10108
+ })
10109
+ }
10110
+ )
10111
+ ] }),
10112
+ selectedPlan && checkoutStage === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CheckoutForm, { plan: selectedPlan, period: planPeriod })
8544
10113
  ]
8545
10114
  }
10115
+ ),
10116
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
10117
+ OverlaySideBar,
10118
+ {
10119
+ pricePeriod: planPeriod,
10120
+ setPricePeriod: setPlanPeriod,
10121
+ checkoutStage,
10122
+ setCheckoutStage,
10123
+ currentPlan,
10124
+ selectedPlan
10125
+ }
8546
10126
  )
8547
- }
8548
- ),
10127
+ ] })
10128
+ ] }),
8549
10129
  portal || document.body
8550
10130
  )
8551
10131
  ] });
@@ -8587,7 +10167,7 @@ var IncludedFeatures = (0, import_react8.forwardRef)(({ className, ...rest }, re
8587
10167
  allocationType,
8588
10168
  feature,
8589
10169
  period,
8590
- usage,
10170
+ usage = 0,
8591
10171
  ...props2
8592
10172
  }) => {
8593
10173
  return {
@@ -8632,7 +10212,7 @@ var IncludedFeatures = (0, import_react8.forwardRef)(({ className, ...rest }, re
8632
10212
  $alignItems: "center",
8633
10213
  $gap: "1rem",
8634
10214
  children: [
8635
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Flex, { $flexShrink: "0", $gap: "1rem", children: [
10215
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Flex, { $gap: "1rem", children: [
8636
10216
  props.icons.isVisible && feature?.icon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
8637
10217
  IconRound,
8638
10218
  {
@@ -8651,7 +10231,6 @@ var IncludedFeatures = (0, import_react8.forwardRef)(({ className, ...rest }, re
8651
10231
  $size: settings.theme.typography[props.icons.fontStyle].fontSize,
8652
10232
  $weight: settings.theme.typography[props.icons.fontStyle].fontWeight,
8653
10233
  $color: settings.theme.typography[props.icons.fontStyle].color,
8654
- $align: "center",
8655
10234
  children: feature.name
8656
10235
  }
8657
10236
  ) })
@@ -8852,19 +10431,27 @@ function resolveDesignProps4(props) {
8852
10431
  }
8853
10432
  var UpcomingBill = (0, import_react10.forwardRef)(({ className, ...rest }, ref) => {
8854
10433
  const props = resolveDesignProps4(rest);
8855
- const { settings } = useEmbed();
8856
- const { bill } = (0, import_react10.useMemo)(() => {
10434
+ const { data, settings, stripe } = useEmbed();
10435
+ const { upcomingInvoice } = (0, import_react10.useMemo)(() => {
8857
10436
  return {
8858
- bill: {
8859
- amount: 200,
8860
- period: "monthly",
8861
- dueDate: toPrettyDate(/* @__PURE__ */ new Date("2024-06-12")),
8862
- endDate: (/* @__PURE__ */ new Date("2025-05-12")).toLocaleDateString()
10437
+ upcomingInvoice: {
10438
+ ...data.upcomingInvoice?.amountDue && {
10439
+ amountDue: data.upcomingInvoice.amountDue
10440
+ },
10441
+ ...data.subscription?.interval && {
10442
+ interval: data.subscription.interval
10443
+ },
10444
+ ...data.upcomingInvoice?.dueDate && {
10445
+ dueDate: toPrettyDate(new Date(data.upcomingInvoice.dueDate))
10446
+ }
8863
10447
  }
8864
10448
  };
8865
- }, []);
10449
+ }, [data.subscription, data.upcomingInvoice]);
10450
+ if (!stripe || !data.upcomingInvoice) {
10451
+ return null;
10452
+ }
8866
10453
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { ref, className, children: [
8867
- props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10454
+ props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
8868
10455
  Flex,
8869
10456
  {
8870
10457
  $justifyContent: "space-between",
@@ -8880,13 +10467,13 @@ var UpcomingBill = (0, import_react10.forwardRef)(({ className, ...rest }, ref)
8880
10467
  children: [
8881
10468
  props.header.prefix,
8882
10469
  " ",
8883
- bill.dueDate
10470
+ upcomingInvoice.dueDate
8884
10471
  ]
8885
10472
  }
8886
10473
  )
8887
10474
  }
8888
10475
  ),
8889
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
10476
+ upcomingInvoice.amountDue && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
8890
10477
  props.price.isVisible && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
8891
10478
  Text,
8892
10479
  {
@@ -8904,27 +10491,18 @@ var UpcomingBill = (0, import_react10.forwardRef)(({ className, ...rest }, ref)
8904
10491
  children: "$"
8905
10492
  }
8906
10493
  ),
8907
- bill.amount
10494
+ upcomingInvoice.amountDue
8908
10495
  ]
8909
10496
  }
8910
10497
  ) }),
8911
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Box, { $maxWidth: "140px", $lineHeight: "1", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
10498
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Box, { $maxWidth: "10rem", $lineHeight: "1", $textAlign: "right", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
8912
10499
  Text,
8913
10500
  {
8914
10501
  $font: settings.theme.typography[props.contractEndDate.fontStyle].fontFamily,
8915
10502
  $size: settings.theme.typography[props.contractEndDate.fontStyle].fontSize,
8916
10503
  $weight: settings.theme.typography[props.contractEndDate.fontStyle].fontWeight,
8917
10504
  $color: settings.theme.typography[props.contractEndDate.fontStyle].color,
8918
- children: [
8919
- "Estimated monthly bill.",
8920
- props.contractEndDate.isVisible && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
8921
- "\xA0",
8922
- props.contractEndDate.prefix,
8923
- " ",
8924
- bill.endDate,
8925
- "."
8926
- ] })
8927
- ]
10505
+ children: "Estimated monthly bill."
8928
10506
  }
8929
10507
  ) })
8930
10508
  ] })
@@ -8948,21 +10526,26 @@ var resolveDesignProps5 = (props) => {
8948
10526
  };
8949
10527
  var PaymentMethod = (0, import_react11.forwardRef)(({ children, className, portal, ...rest }, ref) => {
8950
10528
  const props = resolveDesignProps5(rest);
8951
- const { settings, layout, setLayout } = useEmbed();
10529
+ const { data, settings, stripe, layout } = useEmbed();
8952
10530
  const paymentMethod = (0, import_react11.useMemo)(() => {
8953
- const cardNumber = "4512";
8954
- const expirationDate = "2024-12-22";
8955
- const timeToExpiration = Math.round(
8956
- +new Date(expirationDate) - +/* @__PURE__ */ new Date()
8957
- );
8958
- const monthsToExpiration = Math.round(
8959
- timeToExpiration / (1e3 * 60 * 60 * 24 * 30)
8960
- );
10531
+ const { cardLast4, cardExpMonth, cardExpYear } = data.subscription?.paymentMethod || {};
10532
+ let monthsToExpiration;
10533
+ if (typeof cardExpYear === "number" && typeof cardExpMonth === "number") {
10534
+ const timeToExpiration = Math.round(
10535
+ +new Date(cardExpYear, cardExpMonth - 1) - +/* @__PURE__ */ new Date()
10536
+ );
10537
+ monthsToExpiration = Math.round(
10538
+ timeToExpiration / (1e3 * 60 * 60 * 24 * 30)
10539
+ );
10540
+ }
8961
10541
  return {
8962
- cardNumber,
10542
+ cardLast4,
8963
10543
  monthsToExpiration
8964
10544
  };
8965
- }, []);
10545
+ }, [data.subscription?.paymentMethod]);
10546
+ if (!stripe || !data.subscription?.paymentMethod) {
10547
+ return null;
10548
+ }
8966
10549
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ref, className, children: [
8967
10550
  props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
8968
10551
  Flex,
@@ -8981,7 +10564,7 @@ var PaymentMethod = (0, import_react11.forwardRef)(({ children, className, porta
8981
10564
  children: "Payment Method"
8982
10565
  }
8983
10566
  ),
8984
- Math.abs(paymentMethod.monthsToExpiration) < 4 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10567
+ typeof paymentMethod.monthsToExpiration === "number" && Math.abs(paymentMethod.monthsToExpiration) < 4 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
8985
10568
  Text,
8986
10569
  {
8987
10570
  $font: settings.theme.typography.text.fontFamily,
@@ -8993,7 +10576,7 @@ var PaymentMethod = (0, import_react11.forwardRef)(({ children, className, porta
8993
10576
  ]
8994
10577
  }
8995
10578
  ),
8996
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
10579
+ paymentMethod.cardLast4 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
8997
10580
  Flex,
8998
10581
  {
8999
10582
  $justifyContent: "space-between",
@@ -9002,87 +10585,253 @@ var PaymentMethod = (0, import_react11.forwardRef)(({ children, className, porta
9002
10585
  $background: `${hexToHSL(settings.theme.card.background).l > 50 ? darken(settings.theme.card.background, 10) : lighten(settings.theme.card.background, 20)}`,
9003
10586
  $padding: "0.375rem 1rem",
9004
10587
  $borderRadius: "9999px",
9005
- children: [
9006
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Text, { $font: settings.theme.typography.text.fontFamily, $size: 14, children: [
9007
- "\u{1F4B3} Card ending in ",
9008
- paymentMethod.cardNumber
9009
- ] }),
9010
- props.functions.allowEdit && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
9011
- Text,
9012
- {
9013
- tabIndex: 0,
9014
- onClick: () => {
9015
- if (layout !== "payment")
9016
- return;
9017
- setLayout("payment");
9018
- },
9019
- $font: settings.theme.typography.link.fontFamily,
9020
- $size: settings.theme.typography.link.fontSize,
9021
- $weight: settings.theme.typography.link.fontWeight,
9022
- $color: settings.theme.typography.link.color,
9023
- children: "Edit"
9024
- }
9025
- )
9026
- ]
10588
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Text, { $font: settings.theme.typography.text.fontFamily, $size: 14, children: [
10589
+ "\u{1F4B3} Card ending in ",
10590
+ paymentMethod.cardLast4
10591
+ ] })
9027
10592
  }
9028
10593
  ),
9029
10594
  layout === "payment" && (0, import_react_dom2.createPortal)(
9030
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
9031
- Box,
9032
- {
9033
- $position: "absolute",
9034
- $top: "50%",
9035
- $left: "50%",
9036
- $zIndex: "999999",
9037
- $transform: "translate(-50%, -50%)",
9038
- $width: "100%",
9039
- $height: "100%",
9040
- $backgroundColor: "#B5B5B580",
9041
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
9042
- Flex,
9043
- {
9044
- $position: "relative",
9045
- $top: "50%",
9046
- $left: "50%",
9047
- $transform: "translate(-50%, -50%)",
9048
- $width: "956px",
9049
- $height: "700px",
9050
- $backgroundColor: "#FBFBFB",
9051
- $borderRadius: "8px",
9052
- $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
9053
- id: "select-plan-dialog",
9054
- role: "dialog",
9055
- "aria-labelledby": "select-plan-dialog-label",
9056
- "aria-modal": "true",
9057
- children: [
9058
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
9059
- Box,
9060
- {
9061
- $position: "absolute",
9062
- $top: "0.25rem",
9063
- $right: "0.75rem",
9064
- $cursor: "pointer",
9065
- onClick: () => {
9066
- setLayout("portal");
9067
- },
9068
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon2, { name: "close", style: { fontSize: 36, color: "#B8B8B8" } })
9069
- }
9070
- ),
9071
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Flex, { $flexDirection: "column", $gap: "1rem", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
9072
- Text,
9073
- {
9074
- as: "h1",
9075
- id: "select-plan-dialog-label",
9076
- $size: 24,
9077
- $weight: 800,
9078
- children: "Add payment method"
9079
- }
9080
- ) })
9081
- ]
9082
- }
9083
- )
9084
- }
9085
- ),
10595
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(OverlayWrapper, { size: "md", children: [
10596
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(OverlayHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $fontWeight: "600", children: "Edit payment method" }) }),
10597
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
10598
+ Flex,
10599
+ {
10600
+ $flexDirection: "column",
10601
+ $padding: "2.5rem",
10602
+ $height: "100%",
10603
+ $gap: "1.5rem",
10604
+ children: [
10605
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10606
+ Flex,
10607
+ {
10608
+ $flexDirection: "column",
10609
+ $gap: "1rem",
10610
+ $backgroundColor: "#FBFBFB",
10611
+ $borderRadius: "0 0 0.5rem 0.5rem",
10612
+ $flex: "1",
10613
+ $height: "100%",
10614
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Flex, { $flexDirection: "column", $height: "100%", children: [
10615
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10616
+ Box,
10617
+ {
10618
+ $fontSize: "18px",
10619
+ $marginBottom: "1.5rem",
10620
+ $display: "inline-block",
10621
+ $width: "100%",
10622
+ children: "Default"
10623
+ }
10624
+ ),
10625
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Flex, { $gap: "1rem", children: [
10626
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10627
+ Flex,
10628
+ {
10629
+ $alignItems: "center",
10630
+ $padding: ".5rem 1rem",
10631
+ $border: "1px solid #E2E5E9",
10632
+ $borderRadius: ".5rem",
10633
+ $backgroundColor: "#ffffff",
10634
+ $flexDirection: "row",
10635
+ $gap: "1rem",
10636
+ $width: "100%",
10637
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
10638
+ Flex,
10639
+ {
10640
+ $flexDirection: "row",
10641
+ $justifyContent: "space-between",
10642
+ $flex: "1",
10643
+ children: [
10644
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
10645
+ Flex,
10646
+ {
10647
+ $flexDirection: "row",
10648
+ $alignItems: "center",
10649
+ $gap: "1rem",
10650
+ children: [
10651
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $display: "inline-block", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10652
+ "svg",
10653
+ {
10654
+ viewBox: "0 0 24 16",
10655
+ fill: "none",
10656
+ xmlns: "http://www.w3.org/2000/svg",
10657
+ width: "26px",
10658
+ height: "auto",
10659
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
10660
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10661
+ "rect",
10662
+ {
10663
+ stroke: "#DDD",
10664
+ fill: "#FFF",
10665
+ x: ".25",
10666
+ y: ".25",
10667
+ width: "23",
10668
+ height: "15.5",
10669
+ rx: "2"
10670
+ }
10671
+ ),
10672
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10673
+ "path",
10674
+ {
10675
+ d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
10676
+ fill: "#1434CB"
10677
+ }
10678
+ )
10679
+ ] })
10680
+ }
10681
+ ) }),
10682
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $whiteSpace: "nowrap", children: "Visa **** 4242" })
10683
+ ]
10684
+ }
10685
+ ),
10686
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
10687
+ ]
10688
+ }
10689
+ )
10690
+ }
10691
+ ),
10692
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10693
+ StyledButton,
10694
+ {
10695
+ $size: "sm",
10696
+ $color: "secondary",
10697
+ $variant: "outline",
10698
+ style: {
10699
+ whiteSpace: "nowrap",
10700
+ paddingLeft: "1rem",
10701
+ paddingRight: "1rem"
10702
+ },
10703
+ children: "Edit"
10704
+ }
10705
+ ) })
10706
+ ] })
10707
+ ] })
10708
+ }
10709
+ ),
10710
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10711
+ Flex,
10712
+ {
10713
+ $flexDirection: "column",
10714
+ $gap: "1rem",
10715
+ $backgroundColor: "#FBFBFB",
10716
+ $borderRadius: "0 0 0.5rem 0.5rem",
10717
+ $flex: "1",
10718
+ $height: "100%",
10719
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Flex, { $flexDirection: "column", $height: "100%", children: [
10720
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10721
+ Box,
10722
+ {
10723
+ $fontSize: "18px",
10724
+ $marginBottom: "1.5rem",
10725
+ $display: "inline-block",
10726
+ $width: "100%",
10727
+ children: "Others"
10728
+ }
10729
+ ),
10730
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Flex, { $gap: "1rem", children: [
10731
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10732
+ Flex,
10733
+ {
10734
+ $alignItems: "center",
10735
+ $padding: ".5rem 1rem",
10736
+ $border: "1px solid #E2E5E9",
10737
+ $borderRadius: ".5rem",
10738
+ $backgroundColor: "#ffffff",
10739
+ $flexDirection: "row",
10740
+ $gap: "1rem",
10741
+ $width: "100%",
10742
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
10743
+ Flex,
10744
+ {
10745
+ $flexDirection: "row",
10746
+ $justifyContent: "space-between",
10747
+ $flex: "1",
10748
+ children: [
10749
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
10750
+ Flex,
10751
+ {
10752
+ $flexDirection: "row",
10753
+ $alignItems: "center",
10754
+ $gap: "1rem",
10755
+ children: [
10756
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $display: "inline-block", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10757
+ "svg",
10758
+ {
10759
+ viewBox: "0 0 24 16",
10760
+ fill: "none",
10761
+ xmlns: "http://www.w3.org/2000/svg",
10762
+ width: "26px",
10763
+ height: "auto",
10764
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("g", { children: [
10765
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10766
+ "rect",
10767
+ {
10768
+ stroke: "#DDD",
10769
+ fill: "#FFF",
10770
+ x: ".25",
10771
+ y: ".25",
10772
+ width: "23",
10773
+ height: "15.5",
10774
+ rx: "2"
10775
+ }
10776
+ ),
10777
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10778
+ "path",
10779
+ {
10780
+ d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
10781
+ fill: "#1434CB"
10782
+ }
10783
+ )
10784
+ ] })
10785
+ }
10786
+ ) }),
10787
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $whiteSpace: "nowrap", children: "Visa **** 2929" })
10788
+ ]
10789
+ }
10790
+ ),
10791
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
10792
+ ]
10793
+ }
10794
+ )
10795
+ }
10796
+ ),
10797
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Flex, { $gap: "1rem", children: [
10798
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10799
+ StyledButton,
10800
+ {
10801
+ $size: "sm",
10802
+ $color: "secondary",
10803
+ $variant: "outline",
10804
+ style: {
10805
+ whiteSpace: "nowrap",
10806
+ paddingLeft: "1rem",
10807
+ paddingRight: "1rem"
10808
+ },
10809
+ children: "Make Default"
10810
+ }
10811
+ ),
10812
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10813
+ StyledButton,
10814
+ {
10815
+ $size: "sm",
10816
+ $color: "secondary",
10817
+ $variant: "outline",
10818
+ style: {
10819
+ whiteSpace: "nowrap",
10820
+ paddingLeft: "1rem",
10821
+ paddingRight: "1rem"
10822
+ },
10823
+ children: "Edit"
10824
+ }
10825
+ )
10826
+ ] })
10827
+ ] })
10828
+ ] })
10829
+ }
10830
+ )
10831
+ ]
10832
+ }
10833
+ )
10834
+ ] }),
9086
10835
  portal || document.body
9087
10836
  )
9088
10837
  ] });
@@ -9190,20 +10939,159 @@ var Invoices = (0, import_react12.forwardRef)(({ className, ...rest }, ref) => {
9190
10939
  });
9191
10940
 
9192
10941
  // src/components/embed/ComponentTree.tsx
9193
- var import_react14 = require("react");
10942
+ var import_react18 = require("react");
9194
10943
 
9195
10944
  // src/components/embed/renderer.ts
10945
+ var import_react17 = require("react");
10946
+
10947
+ // src/components/layout/root/Root.tsx
9196
10948
  var import_react13 = require("react");
10949
+ var import_jsx_runtime14 = require("react/jsx-runtime");
10950
+ var Root = (0, import_react13.forwardRef)(
10951
+ (props, ref) => {
10952
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref, ...props });
10953
+ }
10954
+ );
10955
+
10956
+ // src/components/layout/viewport/Viewport.tsx
10957
+ var import_react14 = require("react");
10958
+
10959
+ // src/components/layout/viewport/styles.ts
10960
+ var StyledViewport = dt.div`
10961
+ display: flex;
10962
+ flex-wrap: wrap;
10963
+ margin-left: auto;
10964
+ margin-right: auto;
10965
+ `;
10966
+
10967
+ // src/components/layout/viewport/Viewport.tsx
10968
+ var import_jsx_runtime15 = require("react/jsx-runtime");
10969
+ var Viewport = (0, import_react14.forwardRef)(
10970
+ ({ children, ...props }, ref) => {
10971
+ const { settings, layout } = useEmbed();
10972
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
10973
+ StyledViewport,
10974
+ {
10975
+ ref,
10976
+ $numberOfColumns: settings.theme.numberOfColumns,
10977
+ ...props,
10978
+ children: layout === "disabled" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "", children: "DISABLED" }) : children
10979
+ }
10980
+ );
10981
+ }
10982
+ );
10983
+
10984
+ // src/components/layout/column/Column.tsx
10985
+ var import_react16 = require("react");
10986
+
10987
+ // src/components/layout/card/Card.tsx
10988
+ var import_react15 = require("react");
10989
+
10990
+ // src/components/layout/card/styles.ts
10991
+ var StyledCard = dt.div(
10992
+ ({
10993
+ theme,
10994
+ $sectionLayout = "merged",
10995
+ $borderRadius = 8,
10996
+ $padding = 48,
10997
+ $shadow = true
10998
+ }) => {
10999
+ return lt`
11000
+ box-sizing: border-box;
11001
+ font-size: ${TEXT_BASE_SIZE}px;
11002
+
11003
+ *,
11004
+ *::before,
11005
+ *::after {
11006
+ box-sizing: inherit;
11007
+ }
11008
+
11009
+ > * {
11010
+ padding: ${$padding * 0.75 / TEXT_BASE_SIZE}rem
11011
+ ${$padding / TEXT_BASE_SIZE}rem;
11012
+ color: ${theme.typography.text.color};
11013
+ }
11014
+
11015
+ ${() => {
11016
+ const { l: l2 } = hexToHSL(theme.card.background);
11017
+ const borderColor = l2 > 50 ? darken(theme.card.background, 10) : lighten(theme.card.background, 30);
11018
+ const borderRadius = `${$borderRadius / TEXT_BASE_SIZE}rem`;
11019
+ const boxShadow = "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A";
11020
+ if ($sectionLayout === "merged") {
11021
+ return lt`
11022
+ background: ${({ theme: theme2 }) => theme2.card.background};
11023
+ border-radius: ${borderRadius};
11024
+
11025
+ ${$shadow && `box-shadow: ${boxShadow};`}
11026
+
11027
+ > :not(:last-child) {
11028
+ border-bottom: 1px solid ${borderColor};
11029
+ }
11030
+ `;
11031
+ }
11032
+ return lt`
11033
+ > :not(:last-child) {
11034
+ margin-bottom: 1rem;
11035
+ }
11036
+
11037
+ > * {
11038
+ background: ${theme.card.background};
11039
+ border-radius: ${borderRadius};
11040
+ ${$shadow && `box-shadow: ${boxShadow};`}
11041
+ }
11042
+ `;
11043
+ }}
11044
+ `;
11045
+ }
11046
+ );
11047
+
11048
+ // src/components/layout/card/Card.tsx
11049
+ var import_jsx_runtime16 = require("react/jsx-runtime");
11050
+ var Card = (0, import_react15.forwardRef)(
11051
+ ({ children, className }, ref) => {
11052
+ const { settings } = useEmbed();
11053
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
11054
+ StyledCard,
11055
+ {
11056
+ ref,
11057
+ className,
11058
+ $sectionLayout: settings.theme?.sectionLayout,
11059
+ $borderRadius: settings.theme?.card?.borderRadius,
11060
+ $padding: settings.theme?.card?.padding,
11061
+ $shadow: settings.theme?.card?.hasShadow,
11062
+ children
11063
+ }
11064
+ );
11065
+ }
11066
+ );
11067
+
11068
+ // src/components/layout/column/styles.ts
11069
+ var StyledColumn = dt.div`
11070
+ flex-grow: 1;
11071
+ padding: 0.75rem;
11072
+ `;
11073
+
11074
+ // src/components/layout/column/Column.tsx
11075
+ var import_jsx_runtime17 = require("react/jsx-runtime");
11076
+ var Column = (0, import_react16.forwardRef)(
11077
+ ({ children, ...props }, ref) => {
11078
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(StyledColumn, { ref, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Card, { children }) });
11079
+ }
11080
+ );
11081
+
11082
+ // src/components/embed/renderer.ts
9197
11083
  var components = {
11084
+ Root,
11085
+ Viewport,
11086
+ Column,
9198
11087
  Card,
9199
11088
  PlanManager,
9200
11089
  IncludedFeatures,
9201
11090
  UpcomingBill,
9202
- PaymentMethod,
9203
- MeteredFeatures
11091
+ PaymentMethod
9204
11092
  };
9205
11093
  function createRenderer(options) {
9206
- const { useFallback = true } = options || {};
11094
+ const { useFallback = false } = options || {};
9207
11095
  return function renderNode(node2, index) {
9208
11096
  const { type, props = {}, custom = {}, children } = node2;
9209
11097
  const name = typeof type !== "string" ? type.resolvedName : type;
@@ -9220,12 +11108,12 @@ function createRenderer(options) {
9220
11108
  const { className, ...rest } = props;
9221
11109
  const resolvedProps = component === "div" ? rest : props;
9222
11110
  const resolvedChildren = children.map(renderNode);
9223
- return (0, import_react13.createElement)(
11111
+ return (0, import_react17.createElement)(
9224
11112
  component,
9225
11113
  {
9226
11114
  className,
9227
- ...component !== "div" && { resolvedProps },
9228
- ...Object.keys(custom).length > 0 && { custom },
11115
+ ...component !== "div" && { ...resolvedProps },
11116
+ ...component !== "div" && Object.keys(custom).length > 0 && { custom },
9229
11117
  key: index
9230
11118
  },
9231
11119
  resolvedChildren
@@ -9234,30 +11122,30 @@ function createRenderer(options) {
9234
11122
  }
9235
11123
 
9236
11124
  // src/components/embed/ComponentTree.tsx
9237
- var import_jsx_runtime14 = require("react/jsx-runtime");
11125
+ var import_jsx_runtime18 = require("react/jsx-runtime");
9238
11126
  var ComponentTree = () => {
9239
- const [children, setChildren] = (0, import_react14.useState)("Loading");
11127
+ const [children, setChildren] = (0, import_react18.useState)("Loading");
9240
11128
  const { error, nodes } = useEmbed();
9241
- (0, import_react14.useEffect)(() => {
11129
+ (0, import_react18.useEffect)(() => {
9242
11130
  const renderer = createRenderer();
9243
11131
  setChildren(nodes.map(renderer));
9244
11132
  }, [nodes]);
9245
11133
  if (error) {
9246
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { children: error.message });
11134
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { children: error.message });
9247
11135
  }
9248
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children });
11136
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
9249
11137
  };
9250
11138
 
9251
11139
  // src/components/embed/Embed.tsx
9252
- var import_jsx_runtime15 = require("react/jsx-runtime");
11140
+ var import_jsx_runtime19 = require("react/jsx-runtime");
9253
11141
  var SchematicEmbed = ({ id, accessToken, apiConfig }) => {
9254
11142
  if (accessToken?.length === 0) {
9255
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { children: "Please provide an access token." });
11143
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: "Please provide an access token." });
9256
11144
  }
9257
11145
  if (!accessToken?.startsWith("token_")) {
9258
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { children: 'Invalid access token; your temporary access token will start with "token_".' });
11146
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: 'Invalid access token; your temporary access token will start with "token_".' });
9259
11147
  }
9260
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(EmbedProvider, { id, accessToken, apiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ComponentTree, {}) });
11148
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EmbedProvider, { id, accessToken, apiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ComponentTree, {}) });
9261
11149
  };
9262
11150
  /*! Bundled license information:
9263
11151