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

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.
@@ -122,7 +122,7 @@ var require_classnames = __commonJS({
122
122
  });
123
123
 
124
124
  // src/context/embed.tsx
125
- import { createContext, useCallback, useEffect, useState } from "react";
125
+ import { createContext, useCallback, useEffect, useRef, useState } from "react";
126
126
 
127
127
  // node_modules/pako/dist/pako.esm.mjs
128
128
  var Z_FIXED$1 = 4;
@@ -5871,6 +5871,107 @@ var JSONApiResponse = class {
5871
5871
  }
5872
5872
  };
5873
5873
 
5874
+ // src/api/models/BillingPlan.ts
5875
+ function BillingPlanFromJSON(json) {
5876
+ return BillingPlanFromJSONTyped(json, false);
5877
+ }
5878
+ function BillingPlanFromJSONTyped(json, ignoreDiscriminator) {
5879
+ if (json == null) {
5880
+ return json;
5881
+ }
5882
+ return {
5883
+ description: json["description"] == null ? void 0 : json["description"],
5884
+ id: json["id"],
5885
+ imageUrl: json["image_url"] == null ? void 0 : json["image_url"],
5886
+ name: json["name"],
5887
+ planPeriod: json["plan_period"] == null ? void 0 : json["plan_period"],
5888
+ planPrice: json["plan_price"] == null ? void 0 : json["plan_price"]
5889
+ };
5890
+ }
5891
+
5892
+ // src/api/models/BillingPriceResponseData.ts
5893
+ function BillingPriceResponseDataFromJSON(json) {
5894
+ return BillingPriceResponseDataFromJSONTyped(json, false);
5895
+ }
5896
+ function BillingPriceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
5897
+ if (json == null) {
5898
+ return json;
5899
+ }
5900
+ return {
5901
+ externalPriceId: json["external_price_id"],
5902
+ id: json["id"],
5903
+ interval: json["interval"],
5904
+ price: json["price"]
5905
+ };
5906
+ }
5907
+
5908
+ // src/api/models/BillingProductDetailResponseData.ts
5909
+ function BillingProductDetailResponseDataFromJSON(json) {
5910
+ return BillingProductDetailResponseDataFromJSONTyped(json, false);
5911
+ }
5912
+ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
5913
+ if (json == null) {
5914
+ return json;
5915
+ }
5916
+ return {
5917
+ prices: json["Prices"].map(
5918
+ BillingPriceResponseDataFromJSON
5919
+ ),
5920
+ accountId: json["account_id"],
5921
+ createdAt: new Date(json["created_at"]),
5922
+ currency: json["currency"],
5923
+ environmentId: json["environment_id"],
5924
+ externalId: json["external_id"],
5925
+ name: json["name"],
5926
+ price: json["price"],
5927
+ productId: json["product_id"],
5928
+ quantity: json["quantity"],
5929
+ updatedAt: new Date(json["updated_at"])
5930
+ };
5931
+ }
5932
+
5933
+ // src/api/models/BillingSubscriptionResponseData.ts
5934
+ function BillingSubscriptionResponseDataFromJSON(json) {
5935
+ return BillingSubscriptionResponseDataFromJSONTyped(json, false);
5936
+ }
5937
+ function BillingSubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
5938
+ if (json == null) {
5939
+ return json;
5940
+ }
5941
+ return {
5942
+ expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
5943
+ externalId: json["external_id"],
5944
+ id: json["id"],
5945
+ updatedAt: new Date(json["updated_at"])
5946
+ };
5947
+ }
5948
+
5949
+ // src/api/models/ChangeSubscriptionRequestBody.ts
5950
+ function ChangeSubscriptionRequestBodyToJSON(value) {
5951
+ if (value == null) {
5952
+ return value;
5953
+ }
5954
+ return {
5955
+ action: value["action"],
5956
+ new_plan_id: value["newPlanId"],
5957
+ new_price_id: value["newPriceId"]
5958
+ };
5959
+ }
5960
+
5961
+ // src/api/models/CheckoutResponse.ts
5962
+ function CheckoutResponseFromJSON(json) {
5963
+ return CheckoutResponseFromJSONTyped(json, false);
5964
+ }
5965
+ function CheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
5966
+ if (json == null) {
5967
+ return json;
5968
+ }
5969
+ return {
5970
+ data: BillingSubscriptionResponseDataFromJSON(json["data"]),
5971
+ params: json["params"]
5972
+ };
5973
+ }
5974
+
5874
5975
  // src/api/models/PreviewObject.ts
5875
5976
  function PreviewObjectFromJSON(json) {
5876
5977
  return PreviewObjectFromJSONTyped(json, false);
@@ -5973,7 +6074,7 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
5973
6074
  return json;
5974
6075
  }
5975
6076
  return {
5976
- addOns: json["add_ons"].map(PreviewObjectFromJSON),
6077
+ addOns: json["add_ons"].map(BillingPlanFromJSON),
5977
6078
  createdAt: new Date(json["created_at"]),
5978
6079
  entityTraits: json["entity_traits"].map(
5979
6080
  EntityTraitDetailResponseDataFromJSON
@@ -5984,7 +6085,7 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
5984
6085
  lastSeenAt: json["last_seen_at"] == null ? void 0 : new Date(json["last_seen_at"]),
5985
6086
  logoUrl: json["logo_url"] == null ? void 0 : json["logo_url"],
5986
6087
  name: json["name"],
5987
- plan: json["plan"] == null ? void 0 : PreviewObjectFromJSON(json["plan"]),
6088
+ plan: json["plan"] == null ? void 0 : BillingPlanFromJSON(json["plan"]),
5988
6089
  plans: json["plans"].map(PreviewObjectFromJSON),
5989
6090
  traits: json["traits"] == null ? void 0 : json["traits"],
5990
6091
  updatedAt: new Date(json["updated_at"]),
@@ -5992,25 +6093,6 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
5992
6093
  };
5993
6094
  }
5994
6095
 
5995
- // src/api/models/ComponentResponseData.ts
5996
- function ComponentResponseDataFromJSON(json) {
5997
- return ComponentResponseDataFromJSONTyped(json, false);
5998
- }
5999
- function ComponentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6000
- if (json == null) {
6001
- return json;
6002
- }
6003
- return {
6004
- ast: json["ast"],
6005
- createdAt: new Date(json["created_at"]),
6006
- id: json["id"],
6007
- name: json["name"],
6008
- state: json["state"],
6009
- type: json["type"],
6010
- updatedAt: new Date(json["updated_at"])
6011
- };
6012
- }
6013
-
6014
6096
  // src/api/models/EventSummaryResponseData.ts
6015
6097
  function EventSummaryResponseDataFromJSON(json) {
6016
6098
  return EventSummaryResponseDataFromJSONTyped(json, false);
@@ -6212,13 +6294,91 @@ function PlanResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6212
6294
  return json;
6213
6295
  }
6214
6296
  return {
6215
- audienceType: json["audience_type"],
6297
+ audienceType: json["audience_type"] == null ? void 0 : json["audience_type"],
6298
+ createdAt: new Date(json["created_at"]),
6299
+ description: json["description"],
6300
+ icon: json["icon"],
6301
+ id: json["id"],
6302
+ name: json["name"],
6303
+ planType: json["plan_type"],
6304
+ updatedAt: new Date(json["updated_at"])
6305
+ };
6306
+ }
6307
+
6308
+ // src/api/models/PlanEntitlementResponseData.ts
6309
+ function PlanEntitlementResponseDataFromJSON(json) {
6310
+ return PlanEntitlementResponseDataFromJSONTyped(json, false);
6311
+ }
6312
+ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6313
+ if (json == null) {
6314
+ return json;
6315
+ }
6316
+ return {
6317
+ createdAt: new Date(json["created_at"]),
6318
+ environmentId: json["environment_id"],
6319
+ feature: json["feature"] == null ? void 0 : FeatureResponseDataFromJSON(json["feature"]),
6320
+ featureId: json["feature_id"],
6321
+ id: json["id"],
6322
+ metricPeriod: json["metric_period"] == null ? void 0 : json["metric_period"],
6323
+ plan: json["plan"] == null ? void 0 : PlanResponseDataFromJSON(json["plan"]),
6324
+ planId: json["plan_id"],
6325
+ ruleId: json["rule_id"],
6326
+ updatedAt: new Date(json["updated_at"]),
6327
+ valueBool: json["value_bool"] == null ? void 0 : json["value_bool"],
6328
+ valueNumeric: json["value_numeric"] == null ? void 0 : json["value_numeric"],
6329
+ valueTrait: json["value_trait"] == null ? void 0 : EntityTraitDefinitionResponseDataFromJSON(json["value_trait"]),
6330
+ valueTraitId: json["value_trait_id"] == null ? void 0 : json["value_trait_id"],
6331
+ valueType: json["value_type"]
6332
+ };
6333
+ }
6334
+
6335
+ // src/api/models/CompanyPlanDetailResponseData.ts
6336
+ function CompanyPlanDetailResponseDataFromJSON(json) {
6337
+ return CompanyPlanDetailResponseDataFromJSONTyped(json, false);
6338
+ }
6339
+ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6340
+ if (json == null) {
6341
+ return json;
6342
+ }
6343
+ return {
6344
+ audienceType: json["audience_type"] == null ? void 0 : json["audience_type"],
6345
+ billingProduct: json["billing_product"] == null ? void 0 : BillingProductDetailResponseDataFromJSON(json["billing_product"]),
6346
+ companyCount: json["company_count"],
6216
6347
  createdAt: new Date(json["created_at"]),
6348
+ current: json["current"],
6217
6349
  description: json["description"],
6350
+ entitlements: json["entitlements"].map(
6351
+ PlanEntitlementResponseDataFromJSON
6352
+ ),
6353
+ features: json["features"].map(
6354
+ FeatureDetailResponseDataFromJSON
6355
+ ),
6218
6356
  icon: json["icon"],
6219
6357
  id: json["id"],
6358
+ monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["monthly_price"]),
6220
6359
  name: json["name"],
6221
6360
  planType: json["plan_type"],
6361
+ updatedAt: new Date(json["updated_at"]),
6362
+ valid: json["valid"],
6363
+ yearlyPrice: json["yearly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["yearly_price"])
6364
+ };
6365
+ }
6366
+
6367
+ // src/api/models/ComponentResponseData.ts
6368
+ function ComponentResponseDataFromJSON(json) {
6369
+ return ComponentResponseDataFromJSONTyped(json, false);
6370
+ }
6371
+ function ComponentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6372
+ if (json == null) {
6373
+ return json;
6374
+ }
6375
+ return {
6376
+ ast: json["ast"] == null ? void 0 : json["ast"],
6377
+ createdAt: new Date(json["created_at"]),
6378
+ id: json["id"],
6379
+ name: json["name"],
6380
+ state: json["state"],
6381
+ type: json["type"],
6222
6382
  updatedAt: new Date(json["updated_at"])
6223
6383
  };
6224
6384
  }
@@ -6259,6 +6419,20 @@ function FeatureUsageDetailResponseDataFromJSONTyped(json, ignoreDiscriminator)
6259
6419
  };
6260
6420
  }
6261
6421
 
6422
+ // src/api/models/StripeEmbedInfo.ts
6423
+ function StripeEmbedInfoFromJSON(json) {
6424
+ return StripeEmbedInfoFromJSONTyped(json, false);
6425
+ }
6426
+ function StripeEmbedInfoFromJSONTyped(json, ignoreDiscriminator) {
6427
+ if (json == null) {
6428
+ return json;
6429
+ }
6430
+ return {
6431
+ customerEkey: json["customer_ekey"],
6432
+ publishableKey: json["publishable_key"]
6433
+ };
6434
+ }
6435
+
6262
6436
  // src/api/models/ComponentHydrateResponseData.ts
6263
6437
  function ComponentHydrateResponseDataFromJSON(json) {
6264
6438
  return ComponentHydrateResponseDataFromJSONTyped(json, false);
@@ -6268,9 +6442,13 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6268
6442
  return json;
6269
6443
  }
6270
6444
  return {
6445
+ activePlans: json["active_plans"].map(
6446
+ CompanyPlanDetailResponseDataFromJSON
6447
+ ),
6271
6448
  company: json["company"] == null ? void 0 : CompanyDetailResponseDataFromJSON(json["company"]),
6272
6449
  component: json["component"] == null ? void 0 : ComponentResponseDataFromJSON(json["component"]),
6273
- featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"])
6450
+ featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"]),
6451
+ stripeEmbed: json["stripe_embed"] == null ? void 0 : StripeEmbedInfoFromJSON(json["stripe_embed"])
6274
6452
  };
6275
6453
  }
6276
6454
 
@@ -6288,8 +6466,50 @@ function HydrateComponentResponseFromJSONTyped(json, ignoreDiscriminator) {
6288
6466
  };
6289
6467
  }
6290
6468
 
6291
- // src/api/apis/ComponentsApi.ts
6292
- var ComponentsApi = class extends BaseAPI {
6469
+ // src/api/apis/CheckoutApi.ts
6470
+ var CheckoutApi = class extends BaseAPI {
6471
+ /**
6472
+ * Checkout
6473
+ */
6474
+ async checkoutRaw(requestParameters, initOverrides) {
6475
+ if (requestParameters["changeSubscriptionRequestBody"] == null) {
6476
+ throw new RequiredError(
6477
+ "changeSubscriptionRequestBody",
6478
+ 'Required parameter "changeSubscriptionRequestBody" was null or undefined when calling checkout().'
6479
+ );
6480
+ }
6481
+ const queryParameters = {};
6482
+ const headerParameters = {};
6483
+ headerParameters["Content-Type"] = "application/json";
6484
+ if (this.configuration && this.configuration.apiKey) {
6485
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
6486
+ "X-Schematic-Api-Key"
6487
+ );
6488
+ }
6489
+ const response = await this.request(
6490
+ {
6491
+ path: `/checkout`,
6492
+ method: "POST",
6493
+ headers: headerParameters,
6494
+ query: queryParameters,
6495
+ body: ChangeSubscriptionRequestBodyToJSON(
6496
+ requestParameters["changeSubscriptionRequestBody"]
6497
+ )
6498
+ },
6499
+ initOverrides
6500
+ );
6501
+ return new JSONApiResponse(
6502
+ response,
6503
+ (jsonValue) => CheckoutResponseFromJSON(jsonValue)
6504
+ );
6505
+ }
6506
+ /**
6507
+ * Checkout
6508
+ */
6509
+ async checkout(requestParameters, initOverrides) {
6510
+ const response = await this.checkoutRaw(requestParameters, initOverrides);
6511
+ return await response.value();
6512
+ }
6293
6513
  /**
6294
6514
  * Hydrate component
6295
6515
  */
@@ -6336,30 +6556,73 @@ var ComponentsApi = class extends BaseAPI {
6336
6556
  }
6337
6557
  };
6338
6558
 
6339
- // src/components/theme.ts
6340
- var light = {
6341
- text: "#000000",
6342
- textDetail: "#767676",
6343
- background: "#FFFFFF",
6344
- button: "#000000"
6345
- };
6346
- var dark = {
6347
- text: "#FFFFFF",
6348
- textDetail: "#A5A5A5",
6349
- background: "#000000",
6350
- button: "#194BFB"
6351
- };
6352
-
6353
6559
  // src/context/embed.tsx
6354
6560
  import { jsx } from "react/jsx-runtime";
6355
- var defaultSettings = {
6356
- theme: "light",
6561
+ var defaultTheme = {
6562
+ numberOfColumns: 2,
6357
6563
  sectionLayout: "merged",
6358
- borderWidth: 0,
6359
- borderColor: "#E9E9E9",
6360
- borderRadius: 10,
6361
- boxShadow: "none",
6362
- boxPadding: 50
6564
+ colorMode: "light",
6565
+ primary: "#000000",
6566
+ secondary: "#000000",
6567
+ card: {
6568
+ background: "#FFFFFF",
6569
+ borderRadius: 10,
6570
+ hasShadow: true,
6571
+ padding: 45
6572
+ },
6573
+ typography: {
6574
+ heading1: {
6575
+ fontFamily: "Manrope",
6576
+ fontSize: 37,
6577
+ fontWeight: 800,
6578
+ color: "#000000"
6579
+ },
6580
+ heading2: {
6581
+ fontFamily: "Manrope",
6582
+ fontSize: 29,
6583
+ fontWeight: 800,
6584
+ color: "#000000"
6585
+ },
6586
+ heading3: {
6587
+ fontFamily: "Manrope",
6588
+ fontSize: 20,
6589
+ fontWeight: 600,
6590
+ color: "#000000"
6591
+ },
6592
+ heading4: {
6593
+ fontFamily: "Manrope",
6594
+ fontSize: 18,
6595
+ fontWeight: 800,
6596
+ color: "#000000"
6597
+ },
6598
+ heading5: {
6599
+ fontFamily: "Public Sans",
6600
+ fontSize: 17,
6601
+ fontWeight: 500,
6602
+ color: "#000000"
6603
+ },
6604
+ heading6: {
6605
+ fontFamily: "Public Sans",
6606
+ fontSize: 14,
6607
+ fontWeight: 400,
6608
+ color: "#8A8A8A"
6609
+ },
6610
+ text: {
6611
+ fontFamily: "Public Sans",
6612
+ fontSize: 16,
6613
+ fontWeight: 400,
6614
+ color: "#000000"
6615
+ },
6616
+ link: {
6617
+ fontFamily: "Inter",
6618
+ fontSize: 16,
6619
+ fontWeight: 400,
6620
+ color: "#194BFB"
6621
+ }
6622
+ }
6623
+ };
6624
+ var defaultSettings = {
6625
+ theme: defaultTheme
6363
6626
  };
6364
6627
  function isEditorState(obj) {
6365
6628
  return Object.entries(obj).every(([key, value]) => {
@@ -6386,11 +6649,11 @@ function parseEditorState(data) {
6386
6649
  });
6387
6650
  return arr;
6388
6651
  }
6389
- async function fetchComponent(id, accessToken) {
6652
+ async function fetchComponent(id, accessToken, options) {
6390
6653
  const settings = { ...defaultSettings };
6391
6654
  const nodes = [];
6392
- const config = new Configuration({ apiKey: accessToken });
6393
- const api = new ComponentsApi(config);
6655
+ const config = new Configuration({ ...options, apiKey: accessToken });
6656
+ const api = new CheckoutApi(config);
6394
6657
  const response = await api.hydrateComponent({ componentId: id });
6395
6658
  const { data } = response;
6396
6659
  if (data.component?.ast) {
@@ -6398,7 +6661,7 @@ async function fetchComponent(id, accessToken) {
6398
6661
  const json = inflate_1(Uint8Array.from(Object.values(compressed)), {
6399
6662
  to: "string"
6400
6663
  });
6401
- const ast = getEditorState(json);
6664
+ const ast = getEditorState(JSON.stringify(json));
6402
6665
  if (ast) {
6403
6666
  Object.assign(settings, ast.ROOT.props);
6404
6667
  nodes.push(...parseEditorState(ast));
@@ -6413,61 +6676,92 @@ async function fetchComponent(id, accessToken) {
6413
6676
  var EmbedContext = createContext({
6414
6677
  data: {},
6415
6678
  nodes: [],
6416
- settings: {},
6679
+ settings: { ...defaultSettings },
6680
+ layout: "portal",
6681
+ error: void 0,
6417
6682
  setData: () => {
6418
6683
  },
6419
- setSettings: () => {
6420
- },
6421
6684
  updateSettings: () => {
6685
+ },
6686
+ setLayout: () => {
6422
6687
  }
6423
6688
  });
6424
6689
  var EmbedProvider = ({
6425
6690
  id,
6426
6691
  accessToken,
6692
+ apiConfig,
6427
6693
  children
6428
6694
  }) => {
6429
- const [state, setState] = useState({
6430
- data: {},
6431
- nodes: [],
6432
- settings: { ...defaultSettings },
6433
- setData: () => {
6434
- },
6435
- setSettings: () => {
6436
- },
6437
- updateSettings: () => {
6438
- }
6695
+ const styleRef = useRef(null);
6696
+ const [state, setState] = useState(() => {
6697
+ return {
6698
+ data: {},
6699
+ nodes: [],
6700
+ settings: { ...defaultSettings },
6701
+ layout: "portal",
6702
+ error: void 0,
6703
+ setData: () => {
6704
+ },
6705
+ updateSettings: () => {
6706
+ },
6707
+ setLayout: () => {
6708
+ }
6709
+ };
6439
6710
  });
6711
+ useEffect(() => {
6712
+ const element = document.getElementById("schematic-fonts");
6713
+ if (element) {
6714
+ return void (styleRef.current = element);
6715
+ }
6716
+ const style = document.createElement("link");
6717
+ style.id = "schematic-fonts";
6718
+ style.rel = "stylesheet";
6719
+ document.head.appendChild(style);
6720
+ styleRef.current = style;
6721
+ }, []);
6440
6722
  useEffect(() => {
6441
6723
  if (!id || !accessToken) {
6442
6724
  return;
6443
6725
  }
6444
- fetchComponent(id, accessToken).then((resolvedData) => {
6726
+ fetchComponent(id, accessToken, apiConfig).then((resolvedData) => {
6445
6727
  setState((prev2) => ({ ...prev2, ...resolvedData }));
6446
6728
  }).catch((error) => setState((prev2) => ({ ...prev2, error })));
6447
- }, [id, accessToken]);
6729
+ }, [id, accessToken, apiConfig]);
6730
+ useEffect(() => {
6731
+ const fontSet = /* @__PURE__ */ new Set([]);
6732
+ Object.values(state.settings.theme.typography).forEach(({ fontFamily }) => {
6733
+ fontSet.add(fontFamily);
6734
+ });
6735
+ if (fontSet.size > 0) {
6736
+ const src = `https://fonts.googleapis.com/css2?${[...fontSet].map((fontFamily) => `family=${fontFamily}&display=swap`).join("&")}`;
6737
+ if (styleRef.current) {
6738
+ styleRef.current.href = src;
6739
+ }
6740
+ }
6741
+ }, [state.settings.theme.typography]);
6448
6742
  const setData = useCallback(
6449
6743
  (data) => {
6450
6744
  setState((prev2) => ({
6451
6745
  ...prev2,
6452
- data
6746
+ data: Object.assign({}, data)
6453
6747
  }));
6454
6748
  },
6455
6749
  [setState]
6456
6750
  );
6457
- const setSettings = useCallback(
6751
+ const updateSettings = useCallback(
6458
6752
  (settings) => {
6459
6753
  setState((prev2) => ({
6460
6754
  ...prev2,
6461
- settings
6755
+ settings: Object.assign({}, prev2.settings, settings)
6462
6756
  }));
6463
6757
  },
6464
6758
  [setState]
6465
6759
  );
6466
- const updateSettings = useCallback(
6467
- (settings) => {
6760
+ const setLayout = useCallback(
6761
+ (layout) => {
6468
6762
  setState((prev2) => ({
6469
6763
  ...prev2,
6470
- settings: { ...prev2.settings, ...settings }
6764
+ layout
6471
6765
  }));
6472
6766
  },
6473
6767
  [setState]
@@ -6479,75 +6773,602 @@ var EmbedProvider = ({
6479
6773
  data: state.data,
6480
6774
  nodes: state.nodes,
6481
6775
  settings: state.settings,
6776
+ layout: state.layout,
6482
6777
  error: state.error,
6483
6778
  setData,
6484
- setSettings,
6485
- updateSettings
6779
+ updateSettings,
6780
+ setLayout
6486
6781
  },
6487
- children: /* @__PURE__ */ jsx(ot, { theme: state.settings.theme === "dark" ? dark : light, children })
6782
+ children: /* @__PURE__ */ jsx(ot, { theme: state.settings.theme, children })
6488
6783
  }
6489
6784
  );
6490
6785
  };
6491
6786
 
6492
6787
  // node_modules/@schematichq/schematic-js/dist/schematic.esm.js
6493
- var getRandomValues;
6494
- var rnds8 = new Uint8Array(16);
6495
- function rng() {
6496
- if (!getRandomValues) {
6497
- getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
6498
- if (!getRandomValues) {
6499
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
6500
- }
6788
+ var __create2 = Object.create;
6789
+ var __defProp2 = Object.defineProperty;
6790
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6791
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
6792
+ var __getProtoOf2 = Object.getPrototypeOf;
6793
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
6794
+ var __commonJS2 = (cb, mod) => function __require() {
6795
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6796
+ };
6797
+ var __copyProps2 = (to, from2, except, desc) => {
6798
+ if (from2 && typeof from2 === "object" || typeof from2 === "function") {
6799
+ for (let key of __getOwnPropNames2(from2))
6800
+ if (!__hasOwnProp2.call(to, key) && key !== except)
6801
+ __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable });
6501
6802
  }
6502
- return getRandomValues(rnds8);
6503
- }
6504
- var byteToHex = [];
6505
- for (let i2 = 0; i2 < 256; ++i2) {
6506
- byteToHex.push((i2 + 256).toString(16).slice(1));
6507
- }
6508
- function unsafeStringify(arr, offset = 0) {
6509
- return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
6510
- }
6511
- var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
6512
- var native_default = {
6513
- randomUUID
6803
+ return to;
6514
6804
  };
6515
- function v4(options, buf, offset) {
6516
- if (native_default.randomUUID && !buf && !options) {
6517
- return native_default.randomUUID();
6518
- }
6519
- options = options || {};
6520
- const rnds = options.random || (options.rng || rng)();
6521
- rnds[6] = rnds[6] & 15 | 64;
6522
- rnds[8] = rnds[8] & 63 | 128;
6523
- if (buf) {
6524
- offset = offset || 0;
6525
- for (let i2 = 0; i2 < 16; ++i2) {
6526
- buf[offset + i2] = rnds[i2];
6527
- }
6528
- return buf;
6529
- }
6530
- return unsafeStringify(rnds);
6531
- }
6532
- var v4_default = v4;
6533
- var anonymousIdKey = "schematicId";
6534
- var Schematic = class {
6535
- apiKey;
6536
- apiUrl = "https://api.schematichq.com";
6537
- webSocketUrl = "wss://api.schematichq.com";
6538
- eventUrl = "https://c.schematichq.com";
6539
- conn = null;
6540
- context = {};
6541
- eventQueue;
6542
- storage;
6543
- useWebSocket = false;
6544
- values = {};
6545
- flagListener;
6546
- constructor(apiKey, options) {
6547
- this.apiKey = apiKey;
6548
- this.eventQueue = [];
6549
- this.useWebSocket = options?.useWebSocket ?? false;
6550
- this.flagListener = options?.flagListener;
6805
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
6806
+ // If the importer is in node compatibility mode or this is not an ESM
6807
+ // file that has been converted to a CommonJS file using a Babel-
6808
+ // compatible transform (i.e. "__esModule" has not been set), then set
6809
+ // "default" to the CommonJS "module.exports" for node compatibility.
6810
+ isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
6811
+ mod
6812
+ ));
6813
+ var require_browser_polyfill = __commonJS2({
6814
+ "node_modules/cross-fetch/dist/browser-polyfill.js"(exports) {
6815
+ (function(self2) {
6816
+ var irrelevant = function(exports2) {
6817
+ var global = typeof globalThis !== "undefined" && globalThis || typeof self2 !== "undefined" && self2 || typeof global !== "undefined" && global;
6818
+ var support = {
6819
+ searchParams: "URLSearchParams" in global,
6820
+ iterable: "Symbol" in global && "iterator" in Symbol,
6821
+ blob: "FileReader" in global && "Blob" in global && function() {
6822
+ try {
6823
+ new Blob();
6824
+ return true;
6825
+ } catch (e) {
6826
+ return false;
6827
+ }
6828
+ }(),
6829
+ formData: "FormData" in global,
6830
+ arrayBuffer: "ArrayBuffer" in global
6831
+ };
6832
+ function isDataView(obj) {
6833
+ return obj && DataView.prototype.isPrototypeOf(obj);
6834
+ }
6835
+ if (support.arrayBuffer) {
6836
+ var viewClasses = [
6837
+ "[object Int8Array]",
6838
+ "[object Uint8Array]",
6839
+ "[object Uint8ClampedArray]",
6840
+ "[object Int16Array]",
6841
+ "[object Uint16Array]",
6842
+ "[object Int32Array]",
6843
+ "[object Uint32Array]",
6844
+ "[object Float32Array]",
6845
+ "[object Float64Array]"
6846
+ ];
6847
+ var isArrayBufferView = ArrayBuffer.isView || function(obj) {
6848
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
6849
+ };
6850
+ }
6851
+ function normalizeName(name) {
6852
+ if (typeof name !== "string") {
6853
+ name = String(name);
6854
+ }
6855
+ if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
6856
+ throw new TypeError('Invalid character in header field name: "' + name + '"');
6857
+ }
6858
+ return name.toLowerCase();
6859
+ }
6860
+ function normalizeValue(value) {
6861
+ if (typeof value !== "string") {
6862
+ value = String(value);
6863
+ }
6864
+ return value;
6865
+ }
6866
+ function iteratorFor(items) {
6867
+ var iterator = {
6868
+ next: function() {
6869
+ var value = items.shift();
6870
+ return { done: value === void 0, value };
6871
+ }
6872
+ };
6873
+ if (support.iterable) {
6874
+ iterator[Symbol.iterator] = function() {
6875
+ return iterator;
6876
+ };
6877
+ }
6878
+ return iterator;
6879
+ }
6880
+ function Headers(headers) {
6881
+ this.map = {};
6882
+ if (headers instanceof Headers) {
6883
+ headers.forEach(function(value, name) {
6884
+ this.append(name, value);
6885
+ }, this);
6886
+ } else if (Array.isArray(headers)) {
6887
+ headers.forEach(function(header) {
6888
+ this.append(header[0], header[1]);
6889
+ }, this);
6890
+ } else if (headers) {
6891
+ Object.getOwnPropertyNames(headers).forEach(function(name) {
6892
+ this.append(name, headers[name]);
6893
+ }, this);
6894
+ }
6895
+ }
6896
+ Headers.prototype.append = function(name, value) {
6897
+ name = normalizeName(name);
6898
+ value = normalizeValue(value);
6899
+ var oldValue = this.map[name];
6900
+ this.map[name] = oldValue ? oldValue + ", " + value : value;
6901
+ };
6902
+ Headers.prototype["delete"] = function(name) {
6903
+ delete this.map[normalizeName(name)];
6904
+ };
6905
+ Headers.prototype.get = function(name) {
6906
+ name = normalizeName(name);
6907
+ return this.has(name) ? this.map[name] : null;
6908
+ };
6909
+ Headers.prototype.has = function(name) {
6910
+ return this.map.hasOwnProperty(normalizeName(name));
6911
+ };
6912
+ Headers.prototype.set = function(name, value) {
6913
+ this.map[normalizeName(name)] = normalizeValue(value);
6914
+ };
6915
+ Headers.prototype.forEach = function(callback, thisArg) {
6916
+ for (var name in this.map) {
6917
+ if (this.map.hasOwnProperty(name)) {
6918
+ callback.call(thisArg, this.map[name], name, this);
6919
+ }
6920
+ }
6921
+ };
6922
+ Headers.prototype.keys = function() {
6923
+ var items = [];
6924
+ this.forEach(function(value, name) {
6925
+ items.push(name);
6926
+ });
6927
+ return iteratorFor(items);
6928
+ };
6929
+ Headers.prototype.values = function() {
6930
+ var items = [];
6931
+ this.forEach(function(value) {
6932
+ items.push(value);
6933
+ });
6934
+ return iteratorFor(items);
6935
+ };
6936
+ Headers.prototype.entries = function() {
6937
+ var items = [];
6938
+ this.forEach(function(value, name) {
6939
+ items.push([name, value]);
6940
+ });
6941
+ return iteratorFor(items);
6942
+ };
6943
+ if (support.iterable) {
6944
+ Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
6945
+ }
6946
+ function consumed(body) {
6947
+ if (body.bodyUsed) {
6948
+ return Promise.reject(new TypeError("Already read"));
6949
+ }
6950
+ body.bodyUsed = true;
6951
+ }
6952
+ function fileReaderReady(reader) {
6953
+ return new Promise(function(resolve, reject) {
6954
+ reader.onload = function() {
6955
+ resolve(reader.result);
6956
+ };
6957
+ reader.onerror = function() {
6958
+ reject(reader.error);
6959
+ };
6960
+ });
6961
+ }
6962
+ function readBlobAsArrayBuffer(blob) {
6963
+ var reader = new FileReader();
6964
+ var promise = fileReaderReady(reader);
6965
+ reader.readAsArrayBuffer(blob);
6966
+ return promise;
6967
+ }
6968
+ function readBlobAsText(blob) {
6969
+ var reader = new FileReader();
6970
+ var promise = fileReaderReady(reader);
6971
+ reader.readAsText(blob);
6972
+ return promise;
6973
+ }
6974
+ function readArrayBufferAsText(buf) {
6975
+ var view = new Uint8Array(buf);
6976
+ var chars = new Array(view.length);
6977
+ for (var i2 = 0; i2 < view.length; i2++) {
6978
+ chars[i2] = String.fromCharCode(view[i2]);
6979
+ }
6980
+ return chars.join("");
6981
+ }
6982
+ function bufferClone(buf) {
6983
+ if (buf.slice) {
6984
+ return buf.slice(0);
6985
+ } else {
6986
+ var view = new Uint8Array(buf.byteLength);
6987
+ view.set(new Uint8Array(buf));
6988
+ return view.buffer;
6989
+ }
6990
+ }
6991
+ function Body() {
6992
+ this.bodyUsed = false;
6993
+ this._initBody = function(body) {
6994
+ this.bodyUsed = this.bodyUsed;
6995
+ this._bodyInit = body;
6996
+ if (!body) {
6997
+ this._bodyText = "";
6998
+ } else if (typeof body === "string") {
6999
+ this._bodyText = body;
7000
+ } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
7001
+ this._bodyBlob = body;
7002
+ } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
7003
+ this._bodyFormData = body;
7004
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
7005
+ this._bodyText = body.toString();
7006
+ } else if (support.arrayBuffer && support.blob && isDataView(body)) {
7007
+ this._bodyArrayBuffer = bufferClone(body.buffer);
7008
+ this._bodyInit = new Blob([this._bodyArrayBuffer]);
7009
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
7010
+ this._bodyArrayBuffer = bufferClone(body);
7011
+ } else {
7012
+ this._bodyText = body = Object.prototype.toString.call(body);
7013
+ }
7014
+ if (!this.headers.get("content-type")) {
7015
+ if (typeof body === "string") {
7016
+ this.headers.set("content-type", "text/plain;charset=UTF-8");
7017
+ } else if (this._bodyBlob && this._bodyBlob.type) {
7018
+ this.headers.set("content-type", this._bodyBlob.type);
7019
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
7020
+ this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
7021
+ }
7022
+ }
7023
+ };
7024
+ if (support.blob) {
7025
+ this.blob = function() {
7026
+ var rejected = consumed(this);
7027
+ if (rejected) {
7028
+ return rejected;
7029
+ }
7030
+ if (this._bodyBlob) {
7031
+ return Promise.resolve(this._bodyBlob);
7032
+ } else if (this._bodyArrayBuffer) {
7033
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]));
7034
+ } else if (this._bodyFormData) {
7035
+ throw new Error("could not read FormData body as blob");
7036
+ } else {
7037
+ return Promise.resolve(new Blob([this._bodyText]));
7038
+ }
7039
+ };
7040
+ this.arrayBuffer = function() {
7041
+ if (this._bodyArrayBuffer) {
7042
+ var isConsumed = consumed(this);
7043
+ if (isConsumed) {
7044
+ return isConsumed;
7045
+ }
7046
+ if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
7047
+ return Promise.resolve(
7048
+ this._bodyArrayBuffer.buffer.slice(
7049
+ this._bodyArrayBuffer.byteOffset,
7050
+ this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
7051
+ )
7052
+ );
7053
+ } else {
7054
+ return Promise.resolve(this._bodyArrayBuffer);
7055
+ }
7056
+ } else {
7057
+ return this.blob().then(readBlobAsArrayBuffer);
7058
+ }
7059
+ };
7060
+ }
7061
+ this.text = function() {
7062
+ var rejected = consumed(this);
7063
+ if (rejected) {
7064
+ return rejected;
7065
+ }
7066
+ if (this._bodyBlob) {
7067
+ return readBlobAsText(this._bodyBlob);
7068
+ } else if (this._bodyArrayBuffer) {
7069
+ return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
7070
+ } else if (this._bodyFormData) {
7071
+ throw new Error("could not read FormData body as text");
7072
+ } else {
7073
+ return Promise.resolve(this._bodyText);
7074
+ }
7075
+ };
7076
+ if (support.formData) {
7077
+ this.formData = function() {
7078
+ return this.text().then(decode);
7079
+ };
7080
+ }
7081
+ this.json = function() {
7082
+ return this.text().then(JSON.parse);
7083
+ };
7084
+ return this;
7085
+ }
7086
+ var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
7087
+ function normalizeMethod(method) {
7088
+ var upcased = method.toUpperCase();
7089
+ return methods.indexOf(upcased) > -1 ? upcased : method;
7090
+ }
7091
+ function Request(input, options) {
7092
+ if (!(this instanceof Request)) {
7093
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
7094
+ }
7095
+ options = options || {};
7096
+ var body = options.body;
7097
+ if (input instanceof Request) {
7098
+ if (input.bodyUsed) {
7099
+ throw new TypeError("Already read");
7100
+ }
7101
+ this.url = input.url;
7102
+ this.credentials = input.credentials;
7103
+ if (!options.headers) {
7104
+ this.headers = new Headers(input.headers);
7105
+ }
7106
+ this.method = input.method;
7107
+ this.mode = input.mode;
7108
+ this.signal = input.signal;
7109
+ if (!body && input._bodyInit != null) {
7110
+ body = input._bodyInit;
7111
+ input.bodyUsed = true;
7112
+ }
7113
+ } else {
7114
+ this.url = String(input);
7115
+ }
7116
+ this.credentials = options.credentials || this.credentials || "same-origin";
7117
+ if (options.headers || !this.headers) {
7118
+ this.headers = new Headers(options.headers);
7119
+ }
7120
+ this.method = normalizeMethod(options.method || this.method || "GET");
7121
+ this.mode = options.mode || this.mode || null;
7122
+ this.signal = options.signal || this.signal;
7123
+ this.referrer = null;
7124
+ if ((this.method === "GET" || this.method === "HEAD") && body) {
7125
+ throw new TypeError("Body not allowed for GET or HEAD requests");
7126
+ }
7127
+ this._initBody(body);
7128
+ if (this.method === "GET" || this.method === "HEAD") {
7129
+ if (options.cache === "no-store" || options.cache === "no-cache") {
7130
+ var reParamSearch = /([?&])_=[^&]*/;
7131
+ if (reParamSearch.test(this.url)) {
7132
+ this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
7133
+ } else {
7134
+ var reQueryString = /\?/;
7135
+ this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
7136
+ }
7137
+ }
7138
+ }
7139
+ }
7140
+ Request.prototype.clone = function() {
7141
+ return new Request(this, { body: this._bodyInit });
7142
+ };
7143
+ function decode(body) {
7144
+ var form = new FormData();
7145
+ body.trim().split("&").forEach(function(bytes) {
7146
+ if (bytes) {
7147
+ var split = bytes.split("=");
7148
+ var name = split.shift().replace(/\+/g, " ");
7149
+ var value = split.join("=").replace(/\+/g, " ");
7150
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
7151
+ }
7152
+ });
7153
+ return form;
7154
+ }
7155
+ function parseHeaders(rawHeaders) {
7156
+ var headers = new Headers();
7157
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
7158
+ preProcessedHeaders.split("\r").map(function(header) {
7159
+ return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header;
7160
+ }).forEach(function(line2) {
7161
+ var parts = line2.split(":");
7162
+ var key = parts.shift().trim();
7163
+ if (key) {
7164
+ var value = parts.join(":").trim();
7165
+ headers.append(key, value);
7166
+ }
7167
+ });
7168
+ return headers;
7169
+ }
7170
+ Body.call(Request.prototype);
7171
+ function Response(bodyInit, options) {
7172
+ if (!(this instanceof Response)) {
7173
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
7174
+ }
7175
+ if (!options) {
7176
+ options = {};
7177
+ }
7178
+ this.type = "default";
7179
+ this.status = options.status === void 0 ? 200 : options.status;
7180
+ this.ok = this.status >= 200 && this.status < 300;
7181
+ this.statusText = options.statusText === void 0 ? "" : "" + options.statusText;
7182
+ this.headers = new Headers(options.headers);
7183
+ this.url = options.url || "";
7184
+ this._initBody(bodyInit);
7185
+ }
7186
+ Body.call(Response.prototype);
7187
+ Response.prototype.clone = function() {
7188
+ return new Response(this._bodyInit, {
7189
+ status: this.status,
7190
+ statusText: this.statusText,
7191
+ headers: new Headers(this.headers),
7192
+ url: this.url
7193
+ });
7194
+ };
7195
+ Response.error = function() {
7196
+ var response = new Response(null, { status: 0, statusText: "" });
7197
+ response.type = "error";
7198
+ return response;
7199
+ };
7200
+ var redirectStatuses = [301, 302, 303, 307, 308];
7201
+ Response.redirect = function(url, status) {
7202
+ if (redirectStatuses.indexOf(status) === -1) {
7203
+ throw new RangeError("Invalid status code");
7204
+ }
7205
+ return new Response(null, { status, headers: { location: url } });
7206
+ };
7207
+ exports2.DOMException = global.DOMException;
7208
+ try {
7209
+ new exports2.DOMException();
7210
+ } catch (err2) {
7211
+ exports2.DOMException = function(message, name) {
7212
+ this.message = message;
7213
+ this.name = name;
7214
+ var error = Error(message);
7215
+ this.stack = error.stack;
7216
+ };
7217
+ exports2.DOMException.prototype = Object.create(Error.prototype);
7218
+ exports2.DOMException.prototype.constructor = exports2.DOMException;
7219
+ }
7220
+ function fetch2(input, init) {
7221
+ return new Promise(function(resolve, reject) {
7222
+ var request = new Request(input, init);
7223
+ if (request.signal && request.signal.aborted) {
7224
+ return reject(new exports2.DOMException("Aborted", "AbortError"));
7225
+ }
7226
+ var xhr = new XMLHttpRequest();
7227
+ function abortXhr() {
7228
+ xhr.abort();
7229
+ }
7230
+ xhr.onload = function() {
7231
+ var options = {
7232
+ status: xhr.status,
7233
+ statusText: xhr.statusText,
7234
+ headers: parseHeaders(xhr.getAllResponseHeaders() || "")
7235
+ };
7236
+ options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
7237
+ var body = "response" in xhr ? xhr.response : xhr.responseText;
7238
+ setTimeout(function() {
7239
+ resolve(new Response(body, options));
7240
+ }, 0);
7241
+ };
7242
+ xhr.onerror = function() {
7243
+ setTimeout(function() {
7244
+ reject(new TypeError("Network request failed"));
7245
+ }, 0);
7246
+ };
7247
+ xhr.ontimeout = function() {
7248
+ setTimeout(function() {
7249
+ reject(new TypeError("Network request failed"));
7250
+ }, 0);
7251
+ };
7252
+ xhr.onabort = function() {
7253
+ setTimeout(function() {
7254
+ reject(new exports2.DOMException("Aborted", "AbortError"));
7255
+ }, 0);
7256
+ };
7257
+ function fixUrl(url) {
7258
+ try {
7259
+ return url === "" && global.location.href ? global.location.href : url;
7260
+ } catch (e) {
7261
+ return url;
7262
+ }
7263
+ }
7264
+ xhr.open(request.method, fixUrl(request.url), true);
7265
+ if (request.credentials === "include") {
7266
+ xhr.withCredentials = true;
7267
+ } else if (request.credentials === "omit") {
7268
+ xhr.withCredentials = false;
7269
+ }
7270
+ if ("responseType" in xhr) {
7271
+ if (support.blob) {
7272
+ xhr.responseType = "blob";
7273
+ } else if (support.arrayBuffer && request.headers.get("Content-Type") && request.headers.get("Content-Type").indexOf("application/octet-stream") !== -1) {
7274
+ xhr.responseType = "arraybuffer";
7275
+ }
7276
+ }
7277
+ if (init && typeof init.headers === "object" && !(init.headers instanceof Headers)) {
7278
+ Object.getOwnPropertyNames(init.headers).forEach(function(name) {
7279
+ xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
7280
+ });
7281
+ } else {
7282
+ request.headers.forEach(function(value, name) {
7283
+ xhr.setRequestHeader(name, value);
7284
+ });
7285
+ }
7286
+ if (request.signal) {
7287
+ request.signal.addEventListener("abort", abortXhr);
7288
+ xhr.onreadystatechange = function() {
7289
+ if (xhr.readyState === 4) {
7290
+ request.signal.removeEventListener("abort", abortXhr);
7291
+ }
7292
+ };
7293
+ }
7294
+ xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit);
7295
+ });
7296
+ }
7297
+ fetch2.polyfill = true;
7298
+ if (!global.fetch) {
7299
+ global.fetch = fetch2;
7300
+ global.Headers = Headers;
7301
+ global.Request = Request;
7302
+ global.Response = Response;
7303
+ }
7304
+ exports2.Headers = Headers;
7305
+ exports2.Request = Request;
7306
+ exports2.Response = Response;
7307
+ exports2.fetch = fetch2;
7308
+ return exports2;
7309
+ }({});
7310
+ })(typeof self !== "undefined" ? self : exports);
7311
+ }
7312
+ });
7313
+ var getRandomValues;
7314
+ var rnds8 = new Uint8Array(16);
7315
+ function rng() {
7316
+ if (!getRandomValues) {
7317
+ getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
7318
+ if (!getRandomValues) {
7319
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
7320
+ }
7321
+ }
7322
+ return getRandomValues(rnds8);
7323
+ }
7324
+ var byteToHex = [];
7325
+ for (let i2 = 0; i2 < 256; ++i2) {
7326
+ byteToHex.push((i2 + 256).toString(16).slice(1));
7327
+ }
7328
+ function unsafeStringify(arr, offset = 0) {
7329
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
7330
+ }
7331
+ var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
7332
+ var native_default = {
7333
+ randomUUID
7334
+ };
7335
+ function v4(options, buf, offset) {
7336
+ if (native_default.randomUUID && !buf && !options) {
7337
+ return native_default.randomUUID();
7338
+ }
7339
+ options = options || {};
7340
+ const rnds = options.random || (options.rng || rng)();
7341
+ rnds[6] = rnds[6] & 15 | 64;
7342
+ rnds[8] = rnds[8] & 63 | 128;
7343
+ if (buf) {
7344
+ offset = offset || 0;
7345
+ for (let i2 = 0; i2 < 16; ++i2) {
7346
+ buf[offset + i2] = rnds[i2];
7347
+ }
7348
+ return buf;
7349
+ }
7350
+ return unsafeStringify(rnds);
7351
+ }
7352
+ var v4_default = v4;
7353
+ var import_polyfill = __toESM2(require_browser_polyfill());
7354
+ var anonymousIdKey = "schematicId";
7355
+ var Schematic = class {
7356
+ apiKey;
7357
+ apiUrl = "https://api.schematichq.com";
7358
+ webSocketUrl = "wss://api.schematichq.com";
7359
+ eventUrl = "https://c.schematichq.com";
7360
+ conn = null;
7361
+ context = {};
7362
+ eventQueue;
7363
+ storage;
7364
+ useWebSocket = false;
7365
+ values = {};
7366
+ flagListener;
7367
+ constructor(apiKey, options) {
7368
+ this.apiKey = apiKey;
7369
+ this.eventQueue = [];
7370
+ this.useWebSocket = options?.useWebSocket ?? false;
7371
+ this.flagListener = options?.flagListener;
6551
7372
  if (options?.storage) {
6552
7373
  this.storage = options.storage;
6553
7374
  } else if (typeof localStorage !== "undefined") {
@@ -6901,17 +7722,11 @@ var useSchematicFlag = (key, opts) => {
6901
7722
  return value;
6902
7723
  };
6903
7724
 
6904
- // src/components/embed/ComponentTree.tsx
6905
- import {
6906
- useEffect as useEffect4,
6907
- useState as useState5
6908
- } from "react";
6909
-
6910
- // src/components/embed/renderer.ts
6911
- import { createElement } from "react";
7725
+ // src/components/elements/card/Card.tsx
7726
+ import { forwardRef } from "react";
6912
7727
 
6913
- // src/components/elements/included-features/IncludedFeatures.tsx
6914
- import { useMemo as useMemo2, useState as useState4 } from "react";
7728
+ // src/const/index.ts
7729
+ var TEXT_BASE_SIZE = 16;
6915
7730
 
6916
7731
  // src/utils/color.ts
6917
7732
  function hexToHSL(color) {
@@ -6998,15 +7813,24 @@ function hslToHex({ h, s: s2, l: l2 }) {
6998
7813
  bs = "0" + bs;
6999
7814
  return "#" + rs + gs + bs;
7000
7815
  }
7001
- function adjustHexLightness(color, amount) {
7816
+ function adjustLightness(color, amount) {
7002
7817
  const { h, s: s2, l: l2 } = hexToHSL(color);
7003
7818
  return hslToHex({ h, s: s2, l: Math.max(Math.min(l2 + amount, 100), 0) });
7004
7819
  }
7005
7820
  function lighten(color, amount) {
7006
- return adjustHexLightness(color, amount);
7821
+ return adjustLightness(color, amount);
7007
7822
  }
7008
7823
  function darken(color, amount) {
7009
- return adjustHexLightness(color, -amount);
7824
+ return adjustLightness(color, -amount);
7825
+ }
7826
+
7827
+ // src/utils/date.ts
7828
+ function toPrettyDate(date) {
7829
+ return new Intl.DateTimeFormat("en-US", {
7830
+ month: "long",
7831
+ day: "numeric",
7832
+ year: "numeric"
7833
+ }).format(new Date(date));
7010
7834
  }
7011
7835
 
7012
7836
  // src/utils/string.ts
@@ -7014,9 +7838,6 @@ function camelToHyphen(str) {
7014
7838
  return str.replace(/([a-z][A-Z])/g, (g2) => `${g2[0]}-${g2[1].toLowerCase()}`);
7015
7839
  }
7016
7840
 
7017
- // src/const/index.ts
7018
- var TEXT_BASE_SIZE = 16;
7019
-
7020
7841
  // src/utils/style.ts
7021
7842
  function attr(key, value) {
7022
7843
  return typeof value !== "undefined" && lt`
@@ -7034,6 +7855,88 @@ attr.rem = function propAsRem(key, value) {
7034
7855
  `;
7035
7856
  };
7036
7857
 
7858
+ // src/components/elements/card/styles.ts
7859
+ var StyledCard = dt.div(
7860
+ ({
7861
+ theme,
7862
+ $sectionLayout = "merged",
7863
+ $borderRadius = 8,
7864
+ $padding = 48,
7865
+ $shadow = true
7866
+ }) => {
7867
+ return lt`
7868
+ box-sizing: border-box;
7869
+ font-size: ${TEXT_BASE_SIZE}px;
7870
+
7871
+ *,
7872
+ *::before,
7873
+ *::after {
7874
+ box-sizing: inherit;
7875
+ }
7876
+
7877
+ > * {
7878
+ padding: ${$padding * 0.75 / TEXT_BASE_SIZE}rem
7879
+ ${$padding / TEXT_BASE_SIZE}rem;
7880
+ color: ${theme.typography.text.color};
7881
+ }
7882
+
7883
+ ${() => {
7884
+ const { l: l2 } = hexToHSL(theme.card.background);
7885
+ const borderColor = l2 > 50 ? darken(theme.card.background, 10) : lighten(theme.card.background, 30);
7886
+ const borderRadius = `${$borderRadius / TEXT_BASE_SIZE}rem`;
7887
+ const boxShadow = "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A";
7888
+ if ($sectionLayout === "merged") {
7889
+ return lt`
7890
+ background: ${({ theme: theme2 }) => theme2.card.background};
7891
+ border-radius: ${borderRadius};
7892
+
7893
+ ${$shadow && `box-shadow: ${boxShadow};`}
7894
+
7895
+ > :not(:last-child) {
7896
+ border-bottom: 1px solid ${borderColor};
7897
+ }
7898
+ `;
7899
+ }
7900
+ return lt`
7901
+ > :not(:last-child) {
7902
+ margin-bottom: 1rem;
7903
+ }
7904
+
7905
+ > * {
7906
+ background: ${theme.card.background};
7907
+ border-radius: ${borderRadius};
7908
+ ${$shadow && `box-shadow: ${boxShadow};`}
7909
+ }
7910
+ `;
7911
+ }}
7912
+ `;
7913
+ }
7914
+ );
7915
+
7916
+ // src/components/elements/card/Card.tsx
7917
+ import { jsx as jsx3 } from "react/jsx-runtime";
7918
+ var Card = forwardRef(
7919
+ ({ children, className }, ref) => {
7920
+ const { settings } = useEmbed();
7921
+ return /* @__PURE__ */ jsx3(
7922
+ StyledCard,
7923
+ {
7924
+ ref,
7925
+ className,
7926
+ $sectionLayout: settings.theme?.sectionLayout,
7927
+ $borderRadius: settings.theme?.card?.borderRadius,
7928
+ $padding: settings.theme?.card?.padding,
7929
+ $shadow: settings.theme?.card?.hasShadow,
7930
+ children
7931
+ }
7932
+ );
7933
+ }
7934
+ );
7935
+
7936
+ // src/components/elements/plan-manager/PlanManager.tsx
7937
+ import { forwardRef as forwardRef2, useMemo as useMemo2 } from "react";
7938
+ import { createPortal } from "react-dom";
7939
+
7037
7940
  // src/components/ui/box/styles.ts
7038
7941
  var Box = dt.div((props) => {
7039
7942
  const initialStyles = [];
@@ -7052,10 +7955,13 @@ var Box = dt.div((props) => {
7052
7955
  var Text = dt.span`
7053
7956
  font-family: ${({ $font = "Inter" }) => `${$font}, sans-serif`};
7054
7957
  font-size: ${({ $size = 16 }) => typeof $size === "number" ? `${$size / TEXT_BASE_SIZE}rem` : $size};
7055
- font-weight: ${({ $weight = 400 }) => $weight};
7056
- line-height: 1.25;
7958
+ ${({ $weight = 400 }) => lt`
7959
+ font-weight: ${$weight};
7960
+ font-variation-settings: "wght" ${$weight};
7961
+ `};
7962
+ line-height: ${({ $lineHeight = 1.25 }) => $lineHeight};
7057
7963
  ${({ $align }) => attr("text-align", $align)};
7058
- color: ${({ $color, theme }) => $color || theme.text};
7964
+ color: ${({ $color, theme }) => $color || theme.typography.text.color};
7059
7965
 
7060
7966
  &:focus-visible {
7061
7967
  outline: 2px solid ${({ theme }) => theme.primary};
@@ -7080,46 +7986,46 @@ var Button = dt.button`
7080
7986
  switch ($size) {
7081
7987
  case "sm":
7082
7988
  return lt`
7083
- font-size: ${12 / 16}rem;
7989
+ font-size: ${12 / TEXT_BASE_SIZE}rem;
7084
7990
  ${$variant !== "link" && lt`
7085
- padding: ${7 / 16}rem ${20 / 16}rem;
7991
+ padding: ${7 / TEXT_BASE_SIZE}rem ${20 / TEXT_BASE_SIZE}rem;
7086
7992
  `}
7087
- border-radius: ${4 / 16}rem;
7993
+ border-radius: ${4 / TEXT_BASE_SIZE}rem;
7088
7994
  `;
7089
7995
  case "md":
7090
7996
  default:
7091
7997
  return lt`
7092
- font-size: ${14 / 16}rem;
7998
+ font-size: ${14 / TEXT_BASE_SIZE}rem;
7093
7999
  ${$variant !== "link" && lt`
7094
- padding: ${8 / 16}rem ${24 / 16}rem;
8000
+ padding: ${8 / TEXT_BASE_SIZE}rem ${24 / TEXT_BASE_SIZE}rem;
7095
8001
  `}
7096
- border-radius: ${8 / 16}rem;
8002
+ border-radius: ${8 / TEXT_BASE_SIZE}rem;
7097
8003
  `;
7098
8004
  case "lg":
7099
8005
  return lt`
7100
- font-size: ${16 / 16}rem;
8006
+ font-size: ${16 / TEXT_BASE_SIZE}rem;
7101
8007
  ${$variant !== "link" && lt`
7102
- padding: ${9 / 16}rem ${28 / 16}rem;
8008
+ padding: ${9 / TEXT_BASE_SIZE}rem ${28 / TEXT_BASE_SIZE}rem;
7103
8009
  `}
7104
- border-radius: ${12 / 16}rem;
8010
+ border-radius: ${12 / TEXT_BASE_SIZE}rem;
7105
8011
  `;
7106
8012
  }
7107
8013
  }}
7108
8014
 
7109
8015
  ${({ $color, $variant }) => {
7110
- let color = "#ffffff";
8016
+ let color = "#FFFFFF";
7111
8017
  let bgColor;
7112
8018
  switch ($color) {
7113
8019
  case "blue":
7114
8020
  default:
7115
- bgColor = "#194bfb";
8021
+ bgColor = "#194BFB";
7116
8022
  break;
7117
8023
  case "red":
7118
- bgColor = "#ef4444";
8024
+ bgColor = "#EF4444";
7119
8025
  break;
7120
8026
  case "white":
7121
8027
  color = "#000000";
7122
- bgColor = "#ffffff";
8028
+ bgColor = "#FFFFFF";
7123
8029
  break;
7124
8030
  case "black":
7125
8031
  bgColor = "#000000";
@@ -7148,7 +8054,7 @@ var Button = dt.button`
7148
8054
  `;
7149
8055
 
7150
8056
  // src/components/ui/button/Button.tsx
7151
- import { jsx as jsx3 } from "react/jsx-runtime";
8057
+ import { jsx as jsx4 } from "react/jsx-runtime";
7152
8058
  var Button2 = ({
7153
8059
  color = "white",
7154
8060
  size = "md",
@@ -7157,7 +8063,7 @@ var Button2 = ({
7157
8063
  children,
7158
8064
  ...props
7159
8065
  }) => {
7160
- return /* @__PURE__ */ jsx3(
8066
+ return /* @__PURE__ */ jsx4(
7161
8067
  Button,
7162
8068
  {
7163
8069
  $color: color,
@@ -7170,72 +8076,6 @@ var Button2 = ({
7170
8076
  );
7171
8077
  };
7172
8078
 
7173
- // src/components/ui/card/Card.tsx
7174
- import { forwardRef } from "react";
7175
-
7176
- // src/components/ui/card/styles.ts
7177
- var StyledCard = dt.div`
7178
- box-sizing: border-box;
7179
- font-size: ${TEXT_BASE_SIZE}px;
7180
-
7181
- *,
7182
- *::before,
7183
- *::after {
7184
- box-sizing: inherit;
7185
- }
7186
-
7187
- > * {
7188
- padding: ${40 / 16}rem ${50 / 16}rem;
7189
- color: ${({ theme }) => theme.color};
7190
- background: ${({ theme }) => theme.background};
7191
- box-shadow:
7192
- 0px 1px 20px 0px #1018280f,
7193
- 0px 1px 3px 0px #1018281a;
7194
- }
7195
-
7196
- ${({ $sectionLayout = "merged", $borderRadius = 8 }) => $sectionLayout === "merged" ? lt`
7197
- > :first-child {
7198
- border-top-left-radius: ${$borderRadius / 16}rem;
7199
- border-top-right-radius: ${$borderRadius / 16}rem;
7200
- }
7201
-
7202
- > :last-child {
7203
- border-bottom-left-radius: ${$borderRadius / 16}rem;
7204
- border-bottom-right-radius: ${$borderRadius / 16}rem;
7205
- }
7206
-
7207
- > :not(:last-child) {
7208
- border-bottom: 1px solid #eaeaea;
7209
- }
7210
- ` : lt`
7211
- > :not(:last-child) {
7212
- margin-bottom: 2rem;
7213
- }
7214
-
7215
- > * {
7216
- border-radius: ${$borderRadius / 16}rem;
7217
- }
7218
- `}
7219
- `;
7220
-
7221
- // src/components/ui/card/Card.tsx
7222
- import { jsx as jsx4 } from "react/jsx-runtime";
7223
- var Card = forwardRef(
7224
- ({ children, className }, ref) => {
7225
- const { settings } = useEmbed();
7226
- return /* @__PURE__ */ jsx4(
7227
- StyledCard,
7228
- {
7229
- ref,
7230
- className,
7231
- $sectionLayout: settings.sectionLayout,
7232
- $borderRadius: settings.borderRadius,
7233
- children
7234
- }
7235
- );
7236
- }
7237
- );
7238
-
7239
8079
  // src/components/ui/flex/styles.ts
7240
8080
  var Flex = dt(Box)`
7241
8081
  display: flex;
@@ -7254,9 +8094,7 @@ var Container = dt.div`
7254
8094
  display: flex;
7255
8095
  justify-content: center;
7256
8096
  align-items: center;
7257
- border-width: 1px;
7258
- border-style: solid;
7259
- border-radius: 100%;
8097
+ border-radius: 9999px;
7260
8098
  ${({ $size }) => {
7261
8099
  const base = 24;
7262
8100
  let scale = 1;
@@ -7276,18 +8114,18 @@ var Container = dt.div`
7276
8114
  break;
7277
8115
  }
7278
8116
  return lt`
7279
- font-size: ${base * scale / 16}rem;
8117
+ font-size: ${base * scale / TEXT_BASE_SIZE}rem;
7280
8118
  line-height: 1;
7281
- width: ${(base + 8) * scale / 16}rem;
7282
- height: ${(base + 8) * scale / 16}rem;
8119
+ width: ${(base + 8) * scale / TEXT_BASE_SIZE}rem;
8120
+ height: ${(base + 8) * scale / TEXT_BASE_SIZE}rem;
7283
8121
  `;
7284
8122
  }}
7285
- ${({ $style }) => $style === "outline" ? lt`
8123
+ ${({ $variant, $colors }) => $variant === "outline" ? lt`
8124
+ color: ${$colors[0]};
7286
8125
  background-color: transparent;
7287
- border-color: #d1d5db;
7288
8126
  ` : lt`
7289
- background-color: #e5e7eb;
7290
- border-color: #e5e7eb;
8127
+ color: ${$colors[0]};
8128
+ background-color: ${$colors[1]};
7291
8129
  `}
7292
8130
  `;
7293
8131
 
@@ -7301,10 +8139,12 @@ var Icon2 = ({ name, className, ...props }) => {
7301
8139
  import { jsx as jsx6 } from "react/jsx-runtime";
7302
8140
  var IconRound = ({
7303
8141
  name,
7304
- style = "filled",
7305
- size = "md"
8142
+ variant = "filled",
8143
+ size = "md",
8144
+ colors = ["white", "#e5e7eb"],
8145
+ ...props
7306
8146
  }) => {
7307
- return /* @__PURE__ */ jsx6(Container, { $size: size, $style: style, children: /* @__PURE__ */ jsx6(Icon2, { name }) });
8147
+ return /* @__PURE__ */ jsx6(Container, { $size: size, $variant: variant, $colors: colors, ...props, children: /* @__PURE__ */ jsx6(Icon2, { name }) });
7308
8148
  };
7309
8149
 
7310
8150
  // src/components/ui/progress-bar/styles.ts
@@ -7319,7 +8159,7 @@ var ProgressBar = ({
7319
8159
  value,
7320
8160
  total = 0,
7321
8161
  color = "gray",
7322
- barWidth,
8162
+ barWidth = "100%",
7323
8163
  ...props
7324
8164
  }) => {
7325
8165
  const barColorMap = {
@@ -7329,287 +8169,72 @@ var ProgressBar = ({
7329
8169
  orange: "#DB6769",
7330
8170
  red: "#EF4444"
7331
8171
  };
7332
- return /* @__PURE__ */ jsxs(Container2, { $alignItems: "center", $gap: `${16 / 16}rem`, ...props, children: [
7333
- /* @__PURE__ */ jsx7(Flex, { $alignItems: "center", $width: `${barWidth}`, $position: "relative", children: /* @__PURE__ */ jsx7(
7334
- Flex,
7335
- {
7336
- $position: "relative",
7337
- $overflow: "hidden",
7338
- $width: "100%",
7339
- $height: `${8 / TEXT_BASE_SIZE}rem`,
7340
- $background: "#F2F4F7",
7341
- $borderRadius: "9999px",
7342
- children: /* @__PURE__ */ jsx7(
7343
- Box,
8172
+ return /* @__PURE__ */ jsxs(
8173
+ Container2,
8174
+ {
8175
+ $alignItems: "center",
8176
+ $gap: `${16 / TEXT_BASE_SIZE}rem`,
8177
+ ...props,
8178
+ children: [
8179
+ /* @__PURE__ */ jsx7(
8180
+ Flex,
7344
8181
  {
7345
- $width: `${Math.min(progress, 100)}%`,
7346
- $height: "100%",
7347
- $background: barColorMap[color],
7348
- $borderRadius: "9999px"
8182
+ $position: "relative",
8183
+ $alignItems: "center",
8184
+ $width: `${barWidth}`,
8185
+ $maxWidth: "100%",
8186
+ children: /* @__PURE__ */ jsx7(
8187
+ Flex,
8188
+ {
8189
+ $position: "relative",
8190
+ $overflow: "hidden",
8191
+ $width: "100%",
8192
+ $height: `${8 / TEXT_BASE_SIZE}rem`,
8193
+ $background: "#F2F4F7",
8194
+ $borderRadius: "9999px",
8195
+ children: /* @__PURE__ */ jsx7(
8196
+ Box,
8197
+ {
8198
+ $width: `${Math.min(progress, 100)}%`,
8199
+ $height: "100%",
8200
+ $background: barColorMap[color],
8201
+ $borderRadius: "9999px"
8202
+ }
8203
+ )
8204
+ }
8205
+ )
7349
8206
  }
7350
- )
7351
- }
7352
- ) }),
7353
- total !== 0 && /* @__PURE__ */ jsxs(Text, { $size: `${14 / 16}rem`, $weight: "500", children: [
7354
- value,
7355
- "/",
7356
- total
7357
- ] })
7358
- ] });
7359
- };
7360
-
7361
- // src/components/elements/included-features/IncludedFeatures.tsx
7362
- import { jsx as jsx8, jsxs as jsxs2 } from "react/jsx-runtime";
7363
- function resolveDesignProps(props) {
7364
- return {
7365
- name: {
7366
- text: props.name?.text || "Included features",
7367
- style: {
7368
- fontFamily: props.name?.style?.fontFamily || "Inter",
7369
- fontSize: props.name?.style?.fontSize || 16,
7370
- fontWeight: props.name?.style?.fontWeight || 500,
7371
- color: props.name?.style?.color || "#000000"
7372
- }
7373
- },
7374
- limits: {
7375
- isVisible: props.limits?.isVisible || true
7376
- },
7377
- usage: {
7378
- isVisible: props.usage?.isVisible || true
7379
- },
7380
- count: props.count || 3
7381
- };
7382
- }
7383
- var LimitFeature = ({
7384
- feature,
7385
- allocation,
7386
- usage
7387
- }) => {
7388
- if (!feature) {
7389
- return null;
7390
- }
7391
- return /* @__PURE__ */ jsxs2(Flex, { $justifyContent: "space-between", $margin: "0 0 1.5rem", children: [
7392
- /* @__PURE__ */ jsxs2(Flex, { $gap: `${16 / 16}rem`, children: [
7393
- /* @__PURE__ */ jsx8(IconRound, { name: feature.icon, size: "sm" }),
7394
- /* @__PURE__ */ jsx8(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx8(
7395
- Text,
7396
- {
7397
- $font: "Public Sans",
7398
- $size: `${18 / 16}rem`,
7399
- $weight: "500",
7400
- $align: "center",
7401
- children: feature.name
7402
- }
7403
- ) })
7404
- ] }),
7405
- typeof allocation === "number" && /* @__PURE__ */ jsx8(
7406
- ProgressBar,
7407
- {
7408
- progress: (usage || 0) / allocation * 100,
7409
- value: usage || 0,
7410
- total: allocation,
7411
- color: "blue",
7412
- barWidth: "140px"
7413
- }
7414
- )
7415
- ] });
7416
- };
7417
- var UsageFeature = ({
7418
- feature,
7419
- usage
7420
- }) => {
7421
- if (!feature) {
7422
- return null;
7423
- }
7424
- return /* @__PURE__ */ jsxs2(Flex, { $justifyContent: "space-between", $margin: "0 0 1.5rem", children: [
7425
- /* @__PURE__ */ jsxs2(Flex, { $gap: `${16 / 16}rem`, children: [
7426
- /* @__PURE__ */ jsx8(IconRound, { name: feature.icon, size: "sm" }),
7427
- /* @__PURE__ */ jsx8(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx8(
7428
- Text,
7429
- {
7430
- $font: "Public Sans",
7431
- $size: `${18 / 16}rem`,
7432
- $weight: "500",
7433
- $align: "center",
7434
- children: feature.name
7435
- }
7436
- ) })
7437
- ] }),
7438
- /* @__PURE__ */ jsx8(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsxs2(Text, { as: Box, $font: "Public Sans", $weight: "500", $align: "right", children: [
7439
- usage,
7440
- " ",
7441
- feature.featureType,
7442
- " used"
7443
- ] }) })
7444
- ] });
7445
- };
7446
- var AddonFeature = ({
7447
- feature
7448
- }) => {
7449
- if (!feature) {
7450
- return null;
7451
- }
7452
- return /* @__PURE__ */ jsx8(Flex, { $justifyContent: "space-between", $margin: "0 0 1.5rem", children: /* @__PURE__ */ jsxs2(Flex, { $gap: `${16 / 16}rem`, children: [
7453
- feature.icon && /* @__PURE__ */ jsx8(IconRound, { name: feature.icon, size: "sm" }),
7454
- /* @__PURE__ */ jsx8(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx8(
7455
- Text,
7456
- {
7457
- $font: "Public Sans",
7458
- $size: `${18 / 16}rem`,
7459
- $weight: "500",
7460
- $align: "center",
7461
- children: feature.name
7462
- }
7463
- ) })
7464
- ] }) });
7465
- };
7466
- var IncludedFeatures = ({
7467
- className,
7468
- ...props
7469
- }) => {
7470
- const designPropsWithDefaults = resolveDesignProps(props);
7471
- const { data } = useEmbed();
7472
- const [numVisible, setNumVisible] = useState4(designPropsWithDefaults.count);
7473
- const isExpanded = useMemo2(
7474
- () => numVisible > designPropsWithDefaults.count,
7475
- [numVisible, designPropsWithDefaults.count]
8207
+ ),
8208
+ total !== 0 && /* @__PURE__ */ jsxs(Text, { $size: 14, $weight: 500, children: [
8209
+ value,
8210
+ "/",
8211
+ total
8212
+ ] })
8213
+ ]
8214
+ }
7476
8215
  );
7477
- const features = useMemo2(() => {
7478
- return (data.featureUsage?.features || []).map(
7479
- ({
7480
- access,
7481
- allocation,
7482
- allocationType,
7483
- feature,
7484
- period,
7485
- usage,
7486
- ...props2
7487
- }) => {
7488
- return {
7489
- access,
7490
- allocation,
7491
- allocationType,
7492
- feature,
7493
- period,
7494
- /**
7495
- * @TODO: resolve feature price
7496
- */
7497
- price: void 0,
7498
- usage,
7499
- ...props2
7500
- };
7501
- }
7502
- );
7503
- }, [data.featureUsage]);
7504
- const resize = () => {
7505
- setNumVisible(
7506
- (prev2) => prev2 > designPropsWithDefaults.count ? designPropsWithDefaults.count : features.length
7507
- );
7508
- };
7509
- return /* @__PURE__ */ jsxs2("div", { className, children: [
7510
- /* @__PURE__ */ jsx8(Box, { $margin: "0 0 1.5rem", children: /* @__PURE__ */ jsx8(
7511
- Text,
7512
- {
7513
- $font: "Inter",
7514
- $size: `${15 / 16}rem`,
7515
- $weight: "500",
7516
- $color: "#767676",
7517
- children: designPropsWithDefaults.name.text
7518
- }
7519
- ) }),
7520
- features.slice(0, numVisible).reduce((acc, feature, index) => {
7521
- if (feature.allocationType === "boolean") {
7522
- return [...acc, /* @__PURE__ */ jsx8(AddonFeature, { ...feature }, index)];
7523
- }
7524
- if (feature.allocationType === "numeric" || feature.allocationType === "trait" || feature.allocationType === "unlimited") {
7525
- if (typeof feature.allocation === "number") {
7526
- return [...acc, /* @__PURE__ */ jsx8(LimitFeature, { ...feature }, index)];
7527
- }
7528
- return [...acc, /* @__PURE__ */ jsx8(UsageFeature, { ...feature }, index)];
7529
- }
7530
- return acc;
7531
- }, []),
7532
- /* @__PURE__ */ jsxs2(Flex, { $alignItems: "center", $gap: `${4 / 16}rem`, children: [
7533
- /* @__PURE__ */ jsx8(
7534
- Icon2,
7535
- {
7536
- name: isExpanded ? "chevron-up" : "chevron-down",
7537
- style: { fontSize: "1.25rem", color: "#D0D0D0" }
7538
- }
7539
- ),
7540
- /* @__PURE__ */ jsx8(Button2, { onClick: resize, color: "blue", variant: "link", children: /* @__PURE__ */ jsx8(Text, { $weight: "500", children: "See all" }) })
7541
- ] })
7542
- ] });
7543
- };
7544
-
7545
- // src/components/elements/invoices/Invoices.tsx
7546
- import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
7547
- var Invoices = () => {
7548
- return /* @__PURE__ */ jsx9("div", { className: "p-8", children: /* @__PURE__ */ jsxs3("div", { className: "relative z-[1] bg-white flex flex-col space-y-4", children: [
7549
- /* @__PURE__ */ jsx9("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsx9("div", { className: "font-bold text-base", children: "Invoices" }) }),
7550
- /* @__PURE__ */ jsxs3("div", { className: "flex flex-col space-y-2", children: [
7551
- /* @__PURE__ */ jsxs3("div", { className: "flex justify-between text-sm", children: [
7552
- /* @__PURE__ */ jsx9("span", { className: "text-blue-400", children: "May 12, 2024" }),
7553
- /* @__PURE__ */ jsx9("span", { className: "text-gray-400", children: "$315.00" })
7554
- ] }),
7555
- /* @__PURE__ */ jsxs3("div", { className: "flex justify-between text-sm", children: [
7556
- /* @__PURE__ */ jsx9("span", { className: "text-blue-400", children: "May 12, 2024" }),
7557
- /* @__PURE__ */ jsx9("span", { className: "text-gray-400", children: "$315.00" })
7558
- ] })
7559
- ] }),
7560
- /* @__PURE__ */ jsxs3("div", { className: "flex flex-row space-x-2 items-center", children: [
7561
- /* @__PURE__ */ jsx9(Icon2, { name: "chevron-down", className: "text-gray-400 leading-none" }),
7562
- /* @__PURE__ */ jsx9("span", { className: "text-blue-400 font-medium font-display text-sm", children: "See all" })
7563
- ] })
7564
- ] }) });
7565
- };
7566
-
7567
- // src/components/elements/next-bill-due/NextBillDue.tsx
7568
- import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
7569
- var NextBillDue = () => {
7570
- return /* @__PURE__ */ jsxs4("div", { className: "bg-white p-8", children: [
7571
- /* @__PURE__ */ jsx10("div", { className: "flex items-center justify-between mb-3", children: /* @__PURE__ */ jsx10("div", { className: "font-bold text-base", children: "Next bill due June 12, 2024" }) }),
7572
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center leading-none justify-between", children: [
7573
- /* @__PURE__ */ jsxs4("div", { className: "flex flex-row items-end flex-1 font-medium font-display text-gray-700", children: [
7574
- /* @__PURE__ */ jsx10("div", { className: "text-lg mr-0.5 translate-y-[3px]", children: "$" }),
7575
- /* @__PURE__ */ jsx10("div", { className: "text-3xl", children: "315.00" })
7576
- ] }),
7577
- /* @__PURE__ */ jsxs4("div", { className: "text-gray-400 text-xs max-w-[160px]", children: [
7578
- "Estimated monthly bill, ",
7579
- /* @__PURE__ */ jsx10("br", {}),
7580
- "Contract ends 5/12/24."
7581
- ] })
7582
- ] })
7583
- ] });
7584
8216
  };
7585
8217
 
7586
- // src/components/elements/payment-method/PaymentMethod.tsx
7587
- import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
7588
- var PaymentMethod = () => {
7589
- return /* @__PURE__ */ jsx11("div", { className: "relative px-8 py-8 bg-white", children: /* @__PURE__ */ jsxs5("div", { className: "relative z-[1] bg-white", children: [
7590
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between mb-4", children: [
7591
- /* @__PURE__ */ jsx11("div", { className: "font-bold text-base", children: "Payment Method" }),
7592
- /* @__PURE__ */ jsx11("div", { className: "text-xs text-red-400", children: "Expires in 4 mo" })
7593
- ] }),
7594
- /* @__PURE__ */ jsxs5("div", { className: "flex flex-row justify-between bg-gray-50 text-sm px-4 py-1.5 rounded-full", children: [
7595
- /* @__PURE__ */ jsx11("div", { className: "", children: "\u{1F4B3} Card ending 4512" }),
7596
- /* @__PURE__ */ jsx11("span", { className: "text-blue-400", children: "Edit" })
7597
- ] })
7598
- ] }) });
7599
- };
7600
-
7601
- // src/components/elements/plan-manager/PlanManager.tsx
7602
- import { useMemo as useMemo3 } from "react";
7603
-
7604
8218
  // src/components/elements/plan-manager/styles.ts
7605
- var Button3 = dt(Button2)`
8219
+ var StyledButton = dt(Button2)`
7606
8220
  font-family: "Public Sans", sans-serif;
7607
8221
  font-weight: 500;
7608
8222
  text-align: center;
7609
8223
  width: 100%;
7610
- color: ${({ $color, theme }) => $color || theme.text};
7611
- ${({ $backgroundColor, theme }) => {
7612
- const color = $backgroundColor || theme.button;
8224
+ ${({ $color = "primary", theme }) => {
8225
+ const { l: l2 } = hexToHSL(theme[$color]);
8226
+ const color = l2 > 50 ? "#000000" : "#FFFFFF";
8227
+ return lt`
8228
+ color: ${color};
8229
+
8230
+ ${Text} {
8231
+ color: ${color};
8232
+ }
8233
+ `;
8234
+ }};
8235
+
8236
+ ${({ $color = "primary", theme }) => {
8237
+ const color = theme[$color];
7613
8238
  return lt`
7614
8239
  background-color: ${color};
7615
8240
  border-color: ${color};
@@ -7617,10 +8242,10 @@ var Button3 = dt(Button2)`
7617
8242
  }}
7618
8243
 
7619
8244
  &:hover {
7620
- ${({ $backgroundColor, theme }) => {
7621
- const specified = $backgroundColor || theme.button;
7622
- const lightened = lighten(specified, 12.5);
7623
- const color = specified === lightened ? darken(specified, 12.5) : lightened;
8245
+ ${({ $color = "primary", theme }) => {
8246
+ const specified = theme[$color];
8247
+ const lightened = lighten(specified, 15);
8248
+ const color = specified === lightened ? darken(specified, 15) : lightened;
7624
8249
  return lt`
7625
8250
  background-color: ${color};
7626
8251
  border-color: ${color};
@@ -7653,66 +8278,56 @@ var Button3 = dt(Button2)`
7653
8278
  `;
7654
8279
 
7655
8280
  // src/components/elements/plan-manager/PlanManager.tsx
7656
- import { Fragment, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
7657
- function resolveDesignProps2(props) {
8281
+ import { Fragment, jsx as jsx8, jsxs as jsxs2 } from "react/jsx-runtime";
8282
+ var resolveDesignProps = (props) => {
7658
8283
  return {
7659
8284
  header: {
7660
- isVisible: props.header?.isVisible || true,
8285
+ isVisible: props.header?.isVisible ?? true,
7661
8286
  title: {
7662
- fontFamily: props.header?.title?.fontFamily || "Manrope",
7663
- fontSize: props.header?.title?.fontSize || 37,
7664
- fontWeight: props.header?.title?.fontWeight || 800,
7665
- color: props.header?.title?.color || "black"
8287
+ fontStyle: props.header?.title?.fontStyle ?? "heading1"
7666
8288
  },
7667
8289
  description: {
7668
- isVisible: props.header?.description?.isVisible || true,
7669
- fontFamily: props.header?.description?.fontFamily || "Public Sans",
7670
- fontSize: props.header?.description?.fontSize || 16,
7671
- fontWeight: props.header?.description?.fontWeight || 400,
7672
- color: props.header?.description?.color || "black"
8290
+ isVisible: props.header?.description?.isVisible ?? true,
8291
+ fontStyle: props.header?.description?.fontStyle ?? "text"
7673
8292
  },
7674
8293
  price: {
7675
- isVisible: props.header?.price?.isVisible || true,
7676
- fontFamily: props.header?.price?.fontFamily || "Inter",
7677
- fontSize: props.header?.price?.fontSize || 16,
7678
- fontWeight: props.header?.price?.fontWeight || 500,
7679
- color: props.header?.price?.color || "black"
8294
+ isVisible: props.header?.price?.isVisible ?? true,
8295
+ fontStyle: props.header?.price?.fontStyle ?? "text"
7680
8296
  }
7681
8297
  },
7682
8298
  addOns: {
7683
- isVisible: props.addOns?.isVisible || true
7684
- },
7685
- usageBased: {
7686
- isVisible: props.usageBased?.isVisible || true
8299
+ isVisible: props.addOns?.isVisible ?? true,
8300
+ fontStyle: props.addOns?.fontStyle ?? "heading4",
8301
+ showLabel: props.addOns?.showLabel ?? true
7687
8302
  },
7688
8303
  callToAction: {
7689
- isVisible: props.callToAction?.isVisible || true,
7690
- size: props.callToAction?.size || "md",
7691
- color: props.callToAction?.color || "white",
7692
- backgroundColor: props.callToAction?.backgroundColor || "black"
8304
+ isVisible: props.callToAction?.isVisible ?? true,
8305
+ buttonSize: props.callToAction?.buttonSize ?? "md",
8306
+ buttonStyle: props.callToAction?.buttonStyle ?? "secondary"
7693
8307
  }
7694
8308
  };
7695
- }
7696
- var PlanManager = ({ className, ...props }) => {
7697
- const designPropsWithDefaults = resolveDesignProps2(props);
7698
- const { data } = useEmbed();
7699
- const plans = useMemo3(() => {
7700
- return (data.company?.plans || []).map(({ name, description }) => {
7701
- return {
8309
+ };
8310
+ var PlanManager = forwardRef2(({ children, className, portal, ...rest }, ref) => {
8311
+ const props = resolveDesignProps(rest);
8312
+ const { data, settings, layout, setLayout } = useEmbed();
8313
+ const { plan, plans, addOns } = useMemo2(() => {
8314
+ return {
8315
+ plan: data.company?.plan || {},
8316
+ plans: data.company?.plans?.map(({ name, description }) => ({
7702
8317
  name,
7703
8318
  description,
7704
- /**
7705
- * @TODO: resolve plan/addon prices
7706
- */
7707
8319
  price: void 0
7708
- };
7709
- });
7710
- }, [data.company?.plans]);
7711
- const plan = plans.at(0);
7712
- const addons = plans.slice(1);
7713
- return /* @__PURE__ */ jsxs6("div", { className, children: [
7714
- /* @__PURE__ */ jsxs6(Flex, { $flexDirection: "column", $gap: `${12 / 16}rem`, $margin: "0 0 3rem", children: [
7715
- designPropsWithDefaults.header.isVisible && plan && /* @__PURE__ */ jsxs6(
8320
+ })) || [],
8321
+ addOns: data.company?.addOns?.map(({ name, description }) => ({
8322
+ name,
8323
+ description,
8324
+ price: void 0
8325
+ })) || []
8326
+ };
8327
+ }, [data.company]);
8328
+ return /* @__PURE__ */ jsxs2("div", { ref, className, children: [
8329
+ /* @__PURE__ */ jsxs2(Flex, { $flexDirection: "column", $gap: "0.75rem", $margin: "0 0 3rem", children: [
8330
+ props.header.isVisible && plan && /* @__PURE__ */ jsxs2(
7716
8331
  Flex,
7717
8332
  {
7718
8333
  $justifyContent: "space-between",
@@ -7720,58 +8335,78 @@ var PlanManager = ({ className, ...props }) => {
7720
8335
  $width: "100%",
7721
8336
  $margin: "0 0 1.5rem",
7722
8337
  children: [
7723
- /* @__PURE__ */ jsxs6("div", { children: [
7724
- /* @__PURE__ */ jsx12(Box, { $margin: "0 0 0.75rem", children: /* @__PURE__ */ jsx12(
8338
+ /* @__PURE__ */ jsxs2("div", { children: [
8339
+ /* @__PURE__ */ jsx8(Box, { $margin: "0 0 0.75rem", children: /* @__PURE__ */ jsx8(
7725
8340
  Text,
7726
8341
  {
7727
- $font: designPropsWithDefaults.header.title.fontFamily,
7728
- $size: `${designPropsWithDefaults.header.title.fontSize / 16}rem`,
7729
- $weight: `${designPropsWithDefaults.header.title.fontWeight}`,
7730
- $color: designPropsWithDefaults.header.title.color,
8342
+ $font: settings.theme.typography[props.header.title.fontStyle].fontFamily,
8343
+ $size: settings.theme.typography[props.header.title.fontStyle].fontSize,
8344
+ $weight: settings.theme.typography[props.header.title.fontStyle].fontWeight,
8345
+ $color: settings.theme.typography[props.header.title.fontStyle].color,
8346
+ $lineHeight: 1,
7731
8347
  children: plan.name
7732
8348
  }
7733
8349
  ) }),
7734
- designPropsWithDefaults.header.description.isVisible && plan.description && /* @__PURE__ */ jsx12(
8350
+ props.header.description.isVisible && plan.description && /* @__PURE__ */ jsx8(
7735
8351
  Text,
7736
8352
  {
7737
- $font: designPropsWithDefaults.header.description.fontFamily,
7738
- $size: `${designPropsWithDefaults.header.description.fontSize / 16}rem`,
7739
- $weight: `${designPropsWithDefaults.header.description.fontWeight}`,
7740
- $color: designPropsWithDefaults.header.description.color,
8353
+ $font: settings.theme.typography[props.header.description.fontStyle].fontFamily,
8354
+ $size: settings.theme.typography[props.header.description.fontStyle].fontSize,
8355
+ $weight: settings.theme.typography[props.header.description.fontStyle].fontWeight,
8356
+ $color: settings.theme.typography[props.header.description.fontStyle].color,
7741
8357
  children: plan.description
7742
8358
  }
7743
8359
  )
7744
8360
  ] }),
7745
- designPropsWithDefaults.header.price.isVisible && plan.price >= 0 && /* @__PURE__ */ jsxs6(
8361
+ props.header.price.isVisible && plan.planPrice >= 0 && /* @__PURE__ */ jsxs2(
7746
8362
  Text,
7747
8363
  {
7748
- $font: designPropsWithDefaults.header.price.fontFamily,
7749
- $size: `${designPropsWithDefaults.header.price.fontSize / 16}`,
7750
- $weight: `${designPropsWithDefaults.header.price.fontWeight}`,
7751
- $color: designPropsWithDefaults.header.price.color,
8364
+ $font: settings.theme.typography[props.header.price.fontStyle].fontFamily,
8365
+ $size: settings.theme.typography[props.header.price.fontStyle].fontSize,
8366
+ $weight: settings.theme.typography[props.header.price.fontStyle].fontWeight,
8367
+ $color: settings.theme.typography[props.header.price.fontStyle].color,
7752
8368
  children: [
7753
8369
  "$",
7754
- plan.price,
7755
- "/mo"
8370
+ plan.planPrice,
8371
+ "/",
8372
+ plan.planPeriod
7756
8373
  ]
7757
8374
  }
7758
8375
  )
7759
8376
  ]
7760
8377
  }
7761
8378
  ),
7762
- designPropsWithDefaults.addOns.isVisible && /* @__PURE__ */ jsxs6(Fragment, { children: [
7763
- /* @__PURE__ */ jsx12(Text, { $size: `${15 / 16}rem`, $weight: "500", children: "Add-Ons" }),
7764
- /* @__PURE__ */ jsx12(Box, { $width: "100%", $margin: "0 0 1rem", children: addons.map((addon, index) => /* @__PURE__ */ jsxs6(
8379
+ props.addOns.isVisible && /* @__PURE__ */ jsxs2(Fragment, { children: [
8380
+ props.addOns.showLabel && /* @__PURE__ */ jsx8(
8381
+ Text,
8382
+ {
8383
+ $font: settings.theme.typography.text.fontFamily,
8384
+ $size: settings.theme.typography.text.fontSize,
8385
+ $weight: 500,
8386
+ $color: darken(settings.theme.typography.text.color, 20),
8387
+ children: "Add-Ons"
8388
+ }
8389
+ ),
8390
+ /* @__PURE__ */ jsx8(Box, { $width: "100%", $margin: "0 0 1rem", children: addOns.map((addOn, index) => /* @__PURE__ */ jsxs2(
7765
8391
  Flex,
7766
8392
  {
7767
8393
  $justifyContent: "space-between",
7768
8394
  $alignItems: "center",
7769
8395
  $width: "100%",
7770
8396
  children: [
7771
- /* @__PURE__ */ jsx12(Text, { $font: "Manrope", $size: `${18 / 16}rem`, $weight: "800", children: addon.name }),
7772
- addon.price >= 0 && /* @__PURE__ */ jsxs6(Text, { $weight: "500", children: [
8397
+ /* @__PURE__ */ jsx8(
8398
+ Text,
8399
+ {
8400
+ $font: settings.theme.typography[props.addOns.fontStyle].fontFamily,
8401
+ $size: settings.theme.typography[props.addOns.fontStyle].fontSize,
8402
+ $weight: settings.theme.typography[props.addOns.fontStyle].fontWeight,
8403
+ $color: settings.theme.typography[props.addOns.fontStyle].color,
8404
+ children: addOn.name
8405
+ }
8406
+ ),
8407
+ addOn.price >= 0 && /* @__PURE__ */ jsxs2(Text, { $weight: 500, children: [
7773
8408
  "$",
7774
- addon.price,
8409
+ addOn.price,
7775
8410
  "/mo"
7776
8411
  ] })
7777
8412
  ]
@@ -7780,23 +8415,759 @@ var PlanManager = ({ className, ...props }) => {
7780
8415
  )) })
7781
8416
  ] })
7782
8417
  ] }),
7783
- designPropsWithDefaults.callToAction.isVisible && /* @__PURE__ */ jsx12(
7784
- Button3,
8418
+ props.callToAction.isVisible && /* @__PURE__ */ jsx8(
8419
+ StyledButton,
7785
8420
  {
7786
- $size: designPropsWithDefaults.callToAction.size,
7787
- $color: designPropsWithDefaults.callToAction.color,
7788
- $backgroundColor: designPropsWithDefaults.callToAction.backgroundColor,
7789
- children: "Change Plan"
8421
+ onClick: () => {
8422
+ if (layout !== "checkout")
8423
+ return;
8424
+ setLayout("checkout");
8425
+ },
8426
+ $size: props.callToAction.buttonSize,
8427
+ $color: props.callToAction.buttonStyle,
8428
+ children: /* @__PURE__ */ jsx8(
8429
+ Text,
8430
+ {
8431
+ $font: settings.theme.typography.text.fontFamily,
8432
+ $size: settings.theme.typography.text.fontSize,
8433
+ $weight: settings.theme.typography.text.fontWeight,
8434
+ children: "Change Plan"
8435
+ }
8436
+ )
7790
8437
  }
8438
+ ),
8439
+ children,
8440
+ layout === "checkout" && createPortal(
8441
+ /* @__PURE__ */ jsx8(
8442
+ Box,
8443
+ {
8444
+ $position: "absolute",
8445
+ $top: "50%",
8446
+ $left: "50%",
8447
+ $zIndex: "999999",
8448
+ $transform: "translate(-50%, -50%)",
8449
+ $width: "100%",
8450
+ $height: "100%",
8451
+ $backgroundColor: "#B5B5B580",
8452
+ children: /* @__PURE__ */ jsxs2(
8453
+ Flex,
8454
+ {
8455
+ $position: "relative",
8456
+ $top: "50%",
8457
+ $left: "50%",
8458
+ $transform: "translate(-50%, -50%)",
8459
+ $width: "956px",
8460
+ $height: "700px",
8461
+ $backgroundColor: "#FBFBFB",
8462
+ $borderRadius: "8px",
8463
+ $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
8464
+ id: "select-plan-dialog",
8465
+ role: "dialog",
8466
+ "aria-labelledby": "select-plan-dialog-label",
8467
+ "aria-modal": "true",
8468
+ children: [
8469
+ /* @__PURE__ */ jsx8(
8470
+ Box,
8471
+ {
8472
+ $position: "absolute",
8473
+ $top: "0.25rem",
8474
+ $right: "0.75rem",
8475
+ $cursor: "pointer",
8476
+ onClick: () => {
8477
+ setLayout("portal");
8478
+ },
8479
+ children: /* @__PURE__ */ jsx8(Icon2, { name: "close", style: { fontSize: 36, color: "#B8B8B8" } })
8480
+ }
8481
+ ),
8482
+ /* @__PURE__ */ jsxs2(Flex, { $flexDirection: "column", $gap: "1rem", children: [
8483
+ /* @__PURE__ */ jsx8(
8484
+ Text,
8485
+ {
8486
+ as: "h1",
8487
+ id: "select-plan-dialog-label",
8488
+ $size: 24,
8489
+ $weight: 800,
8490
+ children: "Select plan"
8491
+ }
8492
+ ),
8493
+ /* @__PURE__ */ jsx8(Flex, { $flexDirection: "column", $gap: "1rem", children: plans.map((plan2, index) => /* @__PURE__ */ jsxs2(
8494
+ Flex,
8495
+ {
8496
+ $justifyContent: "space-between",
8497
+ $alignItems: "center",
8498
+ $width: "100%",
8499
+ children: [
8500
+ /* @__PURE__ */ jsx8(Text, { $size: 20, $weight: 800, children: plan2.name }),
8501
+ plan2.price >= 0 && /* @__PURE__ */ jsxs2(Text, { children: [
8502
+ "$",
8503
+ plan2.price,
8504
+ "/mo"
8505
+ ] })
8506
+ ]
8507
+ },
8508
+ index
8509
+ )) })
8510
+ ] })
8511
+ ]
8512
+ }
8513
+ )
8514
+ }
8515
+ ),
8516
+ portal || document.body
7791
8517
  )
7792
8518
  ] });
8519
+ });
8520
+
8521
+ // src/components/elements/included-features/IncludedFeatures.tsx
8522
+ import { forwardRef as forwardRef3, useMemo as useMemo3 } from "react";
8523
+ import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
8524
+ function resolveDesignProps2(props) {
8525
+ return {
8526
+ header: {
8527
+ isVisible: props.header?.isVisible ?? true,
8528
+ fontStyle: props.header?.fontStyle ?? "heading4",
8529
+ text: props.header?.text ?? "Included features"
8530
+ },
8531
+ icons: {
8532
+ isVisible: props.icons?.isVisible ?? true,
8533
+ fontStyle: props.icons?.fontStyle ?? "heading3",
8534
+ style: props.icons?.style ?? "light"
8535
+ },
8536
+ entitlement: {
8537
+ isVisible: props.entitlement?.isVisible ?? true,
8538
+ fontStyle: props.entitlement?.fontStyle ?? "heading5"
8539
+ },
8540
+ usage: {
8541
+ isVisible: props.usage?.isVisible ?? true,
8542
+ fontStyle: props.usage?.fontStyle ?? "heading6"
8543
+ }
8544
+ };
8545
+ }
8546
+ var IncludedFeatures = forwardRef3(({ className, ...rest }, ref) => {
8547
+ const props = resolveDesignProps2(rest);
8548
+ const { data, settings } = useEmbed();
8549
+ const features = useMemo3(() => {
8550
+ return (data.featureUsage?.features || []).map(
8551
+ ({
8552
+ access,
8553
+ allocation,
8554
+ allocationType,
8555
+ feature,
8556
+ period,
8557
+ usage,
8558
+ ...props2
8559
+ }) => {
8560
+ return {
8561
+ access,
8562
+ allocation,
8563
+ allocationType,
8564
+ feature,
8565
+ period,
8566
+ /**
8567
+ * @TODO: resolve feature price
8568
+ */
8569
+ price: void 0,
8570
+ usage,
8571
+ ...props2
8572
+ };
8573
+ }
8574
+ );
8575
+ }, [data.featureUsage]);
8576
+ return /* @__PURE__ */ jsxs3(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: [
8577
+ props.header.isVisible && /* @__PURE__ */ jsx9(Box, { children: /* @__PURE__ */ jsx9(
8578
+ Text,
8579
+ {
8580
+ $font: settings.theme.typography[props.header.fontStyle].fontFamily,
8581
+ $size: settings.theme.typography[props.header.fontStyle].fontSize,
8582
+ $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
8583
+ $color: settings.theme.typography[props.header.fontStyle].color,
8584
+ children: props.header.text
8585
+ }
8586
+ ) }),
8587
+ features.reduce(
8588
+ (acc, { allocation, allocationType, feature, usage }, index) => {
8589
+ if (!allocationType) {
8590
+ return acc;
8591
+ }
8592
+ return [
8593
+ ...acc,
8594
+ /* @__PURE__ */ jsxs3(
8595
+ Flex,
8596
+ {
8597
+ $flexWrap: "wrap",
8598
+ $justifyContent: "space-between",
8599
+ $alignItems: "center",
8600
+ $gap: "1rem",
8601
+ children: [
8602
+ /* @__PURE__ */ jsxs3(Flex, { $flexShrink: "0", $gap: "1rem", children: [
8603
+ props.icons.isVisible && feature?.icon && /* @__PURE__ */ jsx9(
8604
+ IconRound,
8605
+ {
8606
+ name: feature.icon,
8607
+ size: "sm",
8608
+ colors: [
8609
+ settings.theme.card.background,
8610
+ settings.theme.primary
8611
+ ]
8612
+ }
8613
+ ),
8614
+ feature?.name && /* @__PURE__ */ jsx9(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx9(
8615
+ Text,
8616
+ {
8617
+ $font: settings.theme.typography[props.icons.fontStyle].fontFamily,
8618
+ $size: settings.theme.typography[props.icons.fontStyle].fontSize,
8619
+ $weight: settings.theme.typography[props.icons.fontStyle].fontWeight,
8620
+ $color: settings.theme.typography[props.icons.fontStyle].color,
8621
+ $align: "center",
8622
+ children: feature.name
8623
+ }
8624
+ ) })
8625
+ ] }),
8626
+ allocationType === "numeric" && feature?.name && /* @__PURE__ */ jsxs3(Box, { $textAlign: "right", children: [
8627
+ props.entitlement.isVisible && /* @__PURE__ */ jsx9(
8628
+ Text,
8629
+ {
8630
+ as: Box,
8631
+ $font: settings.theme.typography[props.entitlement.fontStyle].fontFamily,
8632
+ $size: settings.theme.typography[props.entitlement.fontStyle].fontSize,
8633
+ $weight: settings.theme.typography[props.entitlement.fontStyle].fontWeight,
8634
+ $color: settings.theme.typography[props.entitlement.fontStyle].color,
8635
+ children: typeof allocation === "number" ? `${allocation} ${feature.name}` : `Unlimited ${feature.name}`
8636
+ }
8637
+ ),
8638
+ props.usage.isVisible && /* @__PURE__ */ jsx9(
8639
+ Text,
8640
+ {
8641
+ as: Box,
8642
+ $font: settings.theme.typography[props.usage.fontStyle].fontFamily,
8643
+ $size: settings.theme.typography[props.usage.fontStyle].fontSize,
8644
+ $weight: settings.theme.typography[props.usage.fontStyle].fontWeight,
8645
+ $color: settings.theme.typography[props.usage.fontStyle].color,
8646
+ children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
8647
+ }
8648
+ )
8649
+ ] })
8650
+ ]
8651
+ },
8652
+ index
8653
+ )
8654
+ ];
8655
+ },
8656
+ []
8657
+ )
8658
+ ] });
8659
+ });
8660
+
8661
+ // src/components/elements/metered-features/MeteredFeatures.tsx
8662
+ import { forwardRef as forwardRef4, useMemo as useMemo4 } from "react";
8663
+ import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
8664
+ function resolveDesignProps3(props) {
8665
+ return {
8666
+ isVisible: props.isVisible ?? true,
8667
+ header: {
8668
+ fontStyle: props.header?.fontStyle ?? "heading2"
8669
+ },
8670
+ description: {
8671
+ isVisible: props.description?.isVisible ?? true,
8672
+ fontStyle: props.description?.fontStyle ?? "text"
8673
+ },
8674
+ icon: {
8675
+ isVisible: props.icon?.isVisible ?? true
8676
+ },
8677
+ allocation: {
8678
+ isVisible: props.allocation?.isVisible ?? true,
8679
+ fontStyle: props.allocation?.fontStyle ?? "heading4"
8680
+ },
8681
+ usage: {
8682
+ isVisible: props.usage?.isVisible ?? true,
8683
+ fontStyle: props.usage?.fontStyle ?? "heading5"
8684
+ },
8685
+ callToAction: {
8686
+ isVisible: props.callToAction?.isVisible ?? true,
8687
+ buttonSize: props.callToAction?.buttonSize ?? "md",
8688
+ buttonStyle: props.callToAction?.buttonStyle ?? "secondary"
8689
+ }
8690
+ };
8691
+ }
8692
+ var MeteredFeatures = forwardRef4(({ className, ...rest }, ref) => {
8693
+ const props = resolveDesignProps3(rest);
8694
+ const { data, settings } = useEmbed();
8695
+ const features = useMemo4(() => {
8696
+ return (data.featureUsage?.features || []).map(
8697
+ ({
8698
+ access,
8699
+ allocation,
8700
+ allocationType,
8701
+ feature,
8702
+ period,
8703
+ usage,
8704
+ ...props2
8705
+ }) => {
8706
+ return {
8707
+ access,
8708
+ allocation,
8709
+ allocationType,
8710
+ feature,
8711
+ period,
8712
+ /**
8713
+ * @TODO: resolve feature price
8714
+ */
8715
+ price: void 0,
8716
+ usage,
8717
+ ...props2
8718
+ };
8719
+ }
8720
+ );
8721
+ }, [data.featureUsage]);
8722
+ return /* @__PURE__ */ jsx10(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: features.reduce(
8723
+ (acc, { allocation, allocationType, feature, usage }, index) => {
8724
+ if (!props.isVisible || allocationType !== "numeric" || typeof allocation !== "number") {
8725
+ return acc;
8726
+ }
8727
+ return [
8728
+ ...acc,
8729
+ /* @__PURE__ */ jsxs4(Flex, { $gap: "1.5rem", children: [
8730
+ props.icon.isVisible && feature?.icon && /* @__PURE__ */ jsx10(Box, { $flexShrink: "0", children: /* @__PURE__ */ jsx10(IconRound, { name: feature.icon, size: "sm" }) }),
8731
+ /* @__PURE__ */ jsxs4(Box, { $flexGrow: "1", children: [
8732
+ /* @__PURE__ */ jsxs4(Flex, { children: [
8733
+ feature?.name && /* @__PURE__ */ jsxs4(Box, { $flexGrow: "1", children: [
8734
+ /* @__PURE__ */ jsx10(
8735
+ Text,
8736
+ {
8737
+ as: Box,
8738
+ $font: settings.theme.typography[props.header.fontStyle].fontFamily,
8739
+ $size: settings.theme.typography[props.header.fontStyle].fontSize,
8740
+ $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
8741
+ $color: settings.theme.typography[props.header.fontStyle].color,
8742
+ children: feature.name
8743
+ }
8744
+ ),
8745
+ props.description.isVisible && /* @__PURE__ */ jsx10(
8746
+ Text,
8747
+ {
8748
+ as: Box,
8749
+ $font: settings.theme.typography[props.description.fontStyle].fontFamily,
8750
+ $size: settings.theme.typography[props.description.fontStyle].fontSize,
8751
+ $weight: settings.theme.typography[props.description.fontStyle].fontWeight,
8752
+ $color: settings.theme.typography[props.description.fontStyle].color,
8753
+ children: feature.description
8754
+ }
8755
+ )
8756
+ ] }),
8757
+ allocationType === "numeric" && feature?.name && /* @__PURE__ */ jsxs4(Box, { $textAlign: "right", children: [
8758
+ props.allocation.isVisible && /* @__PURE__ */ jsx10(
8759
+ Text,
8760
+ {
8761
+ as: Box,
8762
+ $font: settings.theme.typography[props.allocation.fontStyle].fontFamily,
8763
+ $size: settings.theme.typography[props.allocation.fontStyle].fontSize,
8764
+ $weight: settings.theme.typography[props.allocation.fontStyle].fontWeight,
8765
+ $color: settings.theme.typography[props.allocation.fontStyle].color,
8766
+ children: typeof allocation === "number" ? `${allocation} ${feature.name}` : `Unlimited ${feature.name}`
8767
+ }
8768
+ ),
8769
+ props.usage.isVisible && /* @__PURE__ */ jsx10(
8770
+ Text,
8771
+ {
8772
+ as: Box,
8773
+ $font: settings.theme.typography[props.usage.fontStyle].fontFamily,
8774
+ $size: settings.theme.typography[props.usage.fontStyle].fontSize,
8775
+ $weight: settings.theme.typography[props.usage.fontStyle].fontWeight,
8776
+ $color: settings.theme.typography[props.usage.fontStyle].color,
8777
+ children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
8778
+ }
8779
+ )
8780
+ ] })
8781
+ ] }),
8782
+ typeof usage === "number" && typeof allocation === "number" && /* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsx10(
8783
+ ProgressBar,
8784
+ {
8785
+ progress: usage / allocation * 100,
8786
+ value: usage,
8787
+ total: allocation,
8788
+ color: "blue"
8789
+ }
8790
+ ) })
8791
+ ] })
8792
+ ] }, index)
8793
+ ];
8794
+ },
8795
+ []
8796
+ ) });
8797
+ });
8798
+
8799
+ // src/components/elements/upcoming-bill/UpcomingBill.tsx
8800
+ import { forwardRef as forwardRef5, useMemo as useMemo5 } from "react";
8801
+ import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
8802
+ function resolveDesignProps4(props) {
8803
+ return {
8804
+ header: {
8805
+ isVisible: props.header?.isVisible ?? true,
8806
+ fontStyle: props.header?.fontStyle ?? "heading4",
8807
+ prefix: props.header?.prefix ?? "Next bill due"
8808
+ },
8809
+ price: {
8810
+ isVisible: props.price?.isVisible ?? true,
8811
+ fontStyle: props.price?.fontStyle ?? "heading1"
8812
+ },
8813
+ contractEndDate: {
8814
+ isVisible: props.contractEndDate?.isVisible ?? true,
8815
+ fontStyle: props.contractEndDate?.fontStyle ?? "heading6",
8816
+ prefix: props.contractEndDate?.prefix ?? "Contract ends"
8817
+ }
8818
+ };
8819
+ }
8820
+ var UpcomingBill = forwardRef5(({ className, ...rest }, ref) => {
8821
+ const props = resolveDesignProps4(rest);
8822
+ const { settings } = useEmbed();
8823
+ const { bill } = useMemo5(() => {
8824
+ return {
8825
+ bill: {
8826
+ amount: 200,
8827
+ period: "monthly",
8828
+ dueDate: toPrettyDate(/* @__PURE__ */ new Date("2024-06-12")),
8829
+ endDate: (/* @__PURE__ */ new Date("2025-05-12")).toLocaleDateString()
8830
+ }
8831
+ };
8832
+ }, []);
8833
+ return /* @__PURE__ */ jsxs5("div", { ref, className, children: [
8834
+ props.header.isVisible && /* @__PURE__ */ jsx11(
8835
+ Flex,
8836
+ {
8837
+ $justifyContent: "space-between",
8838
+ $alignItems: "center",
8839
+ $margin: "0 0 0.75rem",
8840
+ children: /* @__PURE__ */ jsxs5(
8841
+ Text,
8842
+ {
8843
+ $font: settings.theme.typography[props.header.fontStyle].fontFamily,
8844
+ $size: settings.theme.typography[props.header.fontStyle].fontSize,
8845
+ $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
8846
+ $color: settings.theme.typography[props.header.fontStyle].color,
8847
+ children: [
8848
+ props.header.prefix,
8849
+ " ",
8850
+ bill.dueDate
8851
+ ]
8852
+ }
8853
+ )
8854
+ }
8855
+ ),
8856
+ /* @__PURE__ */ jsxs5(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
8857
+ props.price.isVisible && /* @__PURE__ */ jsx11(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ jsxs5(
8858
+ Text,
8859
+ {
8860
+ $font: settings.theme.typography[props.price.fontStyle].fontFamily,
8861
+ $size: settings.theme.typography[props.price.fontStyle].fontSize,
8862
+ $weight: settings.theme.typography[props.price.fontStyle].fontWeight,
8863
+ $color: settings.theme.typography[props.price.fontStyle].color,
8864
+ $lineHeight: 1,
8865
+ children: [
8866
+ /* @__PURE__ */ jsx11(
8867
+ Text,
8868
+ {
8869
+ $size: "0.75em",
8870
+ $color: settings.theme.typography[props.price.fontStyle].color,
8871
+ children: "$"
8872
+ }
8873
+ ),
8874
+ bill.amount
8875
+ ]
8876
+ }
8877
+ ) }),
8878
+ /* @__PURE__ */ jsx11(Box, { $maxWidth: "140px", $lineHeight: "1", children: /* @__PURE__ */ jsxs5(
8879
+ Text,
8880
+ {
8881
+ $font: settings.theme.typography[props.contractEndDate.fontStyle].fontFamily,
8882
+ $size: settings.theme.typography[props.contractEndDate.fontStyle].fontSize,
8883
+ $weight: settings.theme.typography[props.contractEndDate.fontStyle].fontWeight,
8884
+ $color: settings.theme.typography[props.contractEndDate.fontStyle].color,
8885
+ children: [
8886
+ "Estimated monthly bill.",
8887
+ props.contractEndDate.isVisible && /* @__PURE__ */ jsxs5(Fragment2, { children: [
8888
+ "\xA0",
8889
+ props.contractEndDate.prefix,
8890
+ " ",
8891
+ bill.endDate,
8892
+ "."
8893
+ ] })
8894
+ ]
8895
+ }
8896
+ ) })
8897
+ ] })
8898
+ ] });
8899
+ });
8900
+
8901
+ // src/components/elements/payment-method/PaymentMethod.tsx
8902
+ import { forwardRef as forwardRef6, useMemo as useMemo6 } from "react";
8903
+ import { createPortal as createPortal2 } from "react-dom";
8904
+ import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
8905
+ var resolveDesignProps5 = (props) => {
8906
+ return {
8907
+ header: {
8908
+ isVisible: props.header?.isVisible ?? true,
8909
+ fontStyle: props.header?.fontStyle ?? "heading4"
8910
+ },
8911
+ functions: {
8912
+ allowEdit: props.functions?.allowEdit ?? true
8913
+ }
8914
+ };
7793
8915
  };
8916
+ var PaymentMethod = forwardRef6(({ children, className, portal, ...rest }, ref) => {
8917
+ const props = resolveDesignProps5(rest);
8918
+ const { settings, layout, setLayout } = useEmbed();
8919
+ const paymentMethod = useMemo6(() => {
8920
+ const cardNumber = "4512";
8921
+ const expirationDate = "2024-12-22";
8922
+ const timeToExpiration = Math.round(
8923
+ +new Date(expirationDate) - +/* @__PURE__ */ new Date()
8924
+ );
8925
+ const monthsToExpiration = Math.round(
8926
+ timeToExpiration / (1e3 * 60 * 60 * 24 * 30)
8927
+ );
8928
+ return {
8929
+ cardNumber,
8930
+ monthsToExpiration
8931
+ };
8932
+ }, []);
8933
+ return /* @__PURE__ */ jsxs6("div", { ref, className, children: [
8934
+ props.header.isVisible && /* @__PURE__ */ jsxs6(
8935
+ Flex,
8936
+ {
8937
+ $justifyContent: "space-between",
8938
+ $alignItems: "center",
8939
+ $margin: "0 0 1rem",
8940
+ children: [
8941
+ /* @__PURE__ */ jsx12(
8942
+ Text,
8943
+ {
8944
+ $font: settings.theme.typography[props.header.fontStyle].fontFamily,
8945
+ $size: settings.theme.typography[props.header.fontStyle].fontSize,
8946
+ $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
8947
+ $color: settings.theme.typography[props.header.fontStyle].color,
8948
+ children: "Payment Method"
8949
+ }
8950
+ ),
8951
+ Math.abs(paymentMethod.monthsToExpiration) < 4 && /* @__PURE__ */ jsx12(
8952
+ Text,
8953
+ {
8954
+ $font: settings.theme.typography.text.fontFamily,
8955
+ $size: 14,
8956
+ $color: "#DB6769",
8957
+ children: paymentMethod.monthsToExpiration > 0 ? `Expires in ${paymentMethod.monthsToExpiration} mo` : "Expired"
8958
+ }
8959
+ )
8960
+ ]
8961
+ }
8962
+ ),
8963
+ /* @__PURE__ */ jsxs6(
8964
+ Flex,
8965
+ {
8966
+ $justifyContent: "space-between",
8967
+ $alignItems: "center",
8968
+ $margin: "0 0 1rem",
8969
+ $background: `${hexToHSL(settings.theme.card.background).l > 50 ? darken(settings.theme.card.background, 10) : lighten(settings.theme.card.background, 20)}`,
8970
+ $padding: "0.375rem 1rem",
8971
+ $borderRadius: "9999px",
8972
+ children: [
8973
+ /* @__PURE__ */ jsxs6(Text, { $font: settings.theme.typography.text.fontFamily, $size: 14, children: [
8974
+ "\u{1F4B3} Card ending in ",
8975
+ paymentMethod.cardNumber
8976
+ ] }),
8977
+ props.functions.allowEdit && /* @__PURE__ */ jsx12(
8978
+ Text,
8979
+ {
8980
+ tabIndex: 0,
8981
+ onClick: () => {
8982
+ if (layout !== "payment")
8983
+ return;
8984
+ setLayout("payment");
8985
+ },
8986
+ $font: settings.theme.typography.link.fontFamily,
8987
+ $size: settings.theme.typography.link.fontSize,
8988
+ $weight: settings.theme.typography.link.fontWeight,
8989
+ $color: settings.theme.typography.link.color,
8990
+ children: "Edit"
8991
+ }
8992
+ )
8993
+ ]
8994
+ }
8995
+ ),
8996
+ layout === "payment" && createPortal2(
8997
+ /* @__PURE__ */ jsx12(
8998
+ Box,
8999
+ {
9000
+ $position: "absolute",
9001
+ $top: "50%",
9002
+ $left: "50%",
9003
+ $zIndex: "999999",
9004
+ $transform: "translate(-50%, -50%)",
9005
+ $width: "100%",
9006
+ $height: "100%",
9007
+ $backgroundColor: "#B5B5B580",
9008
+ children: /* @__PURE__ */ jsxs6(
9009
+ Flex,
9010
+ {
9011
+ $position: "relative",
9012
+ $top: "50%",
9013
+ $left: "50%",
9014
+ $transform: "translate(-50%, -50%)",
9015
+ $width: "956px",
9016
+ $height: "700px",
9017
+ $backgroundColor: "#FBFBFB",
9018
+ $borderRadius: "8px",
9019
+ $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
9020
+ id: "select-plan-dialog",
9021
+ role: "dialog",
9022
+ "aria-labelledby": "select-plan-dialog-label",
9023
+ "aria-modal": "true",
9024
+ children: [
9025
+ /* @__PURE__ */ jsx12(
9026
+ Box,
9027
+ {
9028
+ $position: "absolute",
9029
+ $top: "0.25rem",
9030
+ $right: "0.75rem",
9031
+ $cursor: "pointer",
9032
+ onClick: () => {
9033
+ setLayout("portal");
9034
+ },
9035
+ children: /* @__PURE__ */ jsx12(Icon2, { name: "close", style: { fontSize: 36, color: "#B8B8B8" } })
9036
+ }
9037
+ ),
9038
+ /* @__PURE__ */ jsx12(Flex, { $flexDirection: "column", $gap: "1rem", children: /* @__PURE__ */ jsx12(
9039
+ Text,
9040
+ {
9041
+ as: "h1",
9042
+ id: "select-plan-dialog-label",
9043
+ $size: 24,
9044
+ $weight: 800,
9045
+ children: "Add payment method"
9046
+ }
9047
+ ) })
9048
+ ]
9049
+ }
9050
+ )
9051
+ }
9052
+ ),
9053
+ portal || document.body
9054
+ )
9055
+ ] });
9056
+ });
9057
+
9058
+ // src/components/elements/invoices/Invoices.tsx
9059
+ import { forwardRef as forwardRef7, useMemo as useMemo7 } from "react";
9060
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
9061
+ function resolveDesignProps6(props) {
9062
+ return {
9063
+ header: {
9064
+ isVisible: props.header?.isVisible ?? true,
9065
+ fontStyle: props.header?.fontStyle ?? "heading4"
9066
+ },
9067
+ date: {
9068
+ isVisible: props.date?.isVisible ?? true,
9069
+ fontStyle: props.date?.fontStyle ?? "link"
9070
+ },
9071
+ amount: {
9072
+ isVisible: props.amount?.isVisible ?? true,
9073
+ fontStyle: props.amount?.fontStyle ?? "text"
9074
+ },
9075
+ limit: {
9076
+ isVisible: props.limit?.isVisible ?? true,
9077
+ number: props.limit?.number ?? 2
9078
+ },
9079
+ collapse: {
9080
+ isVisible: props.collapse?.isVisible ?? true,
9081
+ fontStyle: props.collapse?.fontStyle ?? "link"
9082
+ }
9083
+ };
9084
+ }
9085
+ var Invoices = forwardRef7(({ className, ...rest }, ref) => {
9086
+ const props = resolveDesignProps6(rest);
9087
+ const { settings } = useEmbed();
9088
+ const { invoices } = useMemo7(() => {
9089
+ return {
9090
+ invoices: [
9091
+ {
9092
+ date: toPrettyDate(/* @__PURE__ */ new Date("2024-05-12")),
9093
+ amount: 200
9094
+ },
9095
+ {
9096
+ date: toPrettyDate(/* @__PURE__ */ new Date("2024-04-12")),
9097
+ amount: 200
9098
+ }
9099
+ ]
9100
+ };
9101
+ }, []);
9102
+ return /* @__PURE__ */ jsx13("div", { ref, className, children: /* @__PURE__ */ jsxs7(Flex, { $flexDirection: "column", $gap: "1rem", children: [
9103
+ props.header.isVisible && /* @__PURE__ */ jsx13(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ jsx13(
9104
+ Text,
9105
+ {
9106
+ $font: settings.theme.typography[props.header.fontStyle].fontFamily,
9107
+ $size: settings.theme.typography[props.header.fontStyle].fontSize,
9108
+ $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
9109
+ $color: settings.theme.typography[props.header.fontStyle].color,
9110
+ children: "Invoices"
9111
+ }
9112
+ ) }),
9113
+ /* @__PURE__ */ jsx13(Flex, { $flexDirection: "column", $gap: "0.5rem", children: invoices.slice(
9114
+ 0,
9115
+ props.limit.isVisible && props.limit.number || invoices.length
9116
+ ).map(({ date, amount }, index) => {
9117
+ return /* @__PURE__ */ jsxs7(Flex, { $justifyContent: "space-between", children: [
9118
+ props.date.isVisible && /* @__PURE__ */ jsx13(
9119
+ Text,
9120
+ {
9121
+ $font: settings.theme.typography[props.date.fontStyle].fontFamily,
9122
+ $size: settings.theme.typography[props.date.fontStyle].fontSize,
9123
+ $weight: settings.theme.typography[props.date.fontStyle].fontWeight,
9124
+ $color: settings.theme.typography[props.date.fontStyle].color,
9125
+ children: toPrettyDate(date)
9126
+ }
9127
+ ),
9128
+ props.amount.isVisible && /* @__PURE__ */ jsxs7(
9129
+ Text,
9130
+ {
9131
+ $font: settings.theme.typography[props.amount.fontStyle].fontFamily,
9132
+ $size: settings.theme.typography[props.amount.fontStyle].fontSize,
9133
+ $weight: settings.theme.typography[props.amount.fontStyle].fontWeight,
9134
+ $color: settings.theme.typography[props.amount.fontStyle].color,
9135
+ children: [
9136
+ "$",
9137
+ amount
9138
+ ]
9139
+ }
9140
+ )
9141
+ ] }, index);
9142
+ }) }),
9143
+ props.collapse.isVisible && /* @__PURE__ */ jsxs7(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
9144
+ /* @__PURE__ */ jsx13(Icon2, { name: "chevron-down", style: { color: "#D0D0D0" } }),
9145
+ /* @__PURE__ */ jsx13(
9146
+ Text,
9147
+ {
9148
+ $font: settings.theme.typography[props.collapse.fontStyle].fontFamily,
9149
+ $size: settings.theme.typography[props.collapse.fontStyle].fontSize,
9150
+ $weight: settings.theme.typography[props.collapse.fontStyle].fontWeight,
9151
+ $color: settings.theme.typography[props.collapse.fontStyle].color,
9152
+ children: "See all"
9153
+ }
9154
+ )
9155
+ ] })
9156
+ ] }) });
9157
+ });
9158
+
9159
+ // src/components/embed/ComponentTree.tsx
9160
+ import { useEffect as useEffect4, useState as useState4 } from "react";
7794
9161
 
7795
9162
  // src/components/embed/renderer.ts
9163
+ import { createElement } from "react";
7796
9164
  var components = {
7797
9165
  Card,
9166
+ PlanManager,
7798
9167
  IncludedFeatures,
7799
- PlanManager
9168
+ UpcomingBill,
9169
+ PaymentMethod,
9170
+ MeteredFeatures
7800
9171
  };
7801
9172
  function createRenderer(options) {
7802
9173
  const { useFallback = true } = options || {};
@@ -7813,13 +9184,14 @@ function createRenderer(options) {
7813
9184
  if (!component) {
7814
9185
  return null;
7815
9186
  }
7816
- const { className, style, ...rootProps } = props;
7817
- const resolvedProps = node2.id === "ROOT" ? rootProps : props;
9187
+ const { className, ...rest } = props;
9188
+ const resolvedProps = component === "div" ? rest : props;
7818
9189
  const resolvedChildren = children.map(renderNode);
7819
9190
  return createElement(
7820
9191
  component,
7821
9192
  {
7822
- ...resolvedProps,
9193
+ className,
9194
+ ...component !== "div" && { resolvedProps },
7823
9195
  ...Object.keys(custom).length > 0 && { custom },
7824
9196
  key: index
7825
9197
  },
@@ -7829,30 +9201,30 @@ function createRenderer(options) {
7829
9201
  }
7830
9202
 
7831
9203
  // src/components/embed/ComponentTree.tsx
7832
- import { Fragment as Fragment2, jsx as jsx13 } from "react/jsx-runtime";
9204
+ import { Fragment as Fragment3, jsx as jsx14 } from "react/jsx-runtime";
7833
9205
  var ComponentTree = () => {
7834
- const [children, setChildren] = useState5("Loading");
9206
+ const [children, setChildren] = useState4("Loading");
7835
9207
  const { error, nodes } = useEmbed();
7836
9208
  useEffect4(() => {
7837
9209
  const renderer = createRenderer();
7838
9210
  setChildren(nodes.map(renderer));
7839
9211
  }, [nodes]);
7840
9212
  if (error) {
7841
- return /* @__PURE__ */ jsx13("div", { children: error.message });
9213
+ return /* @__PURE__ */ jsx14("div", { children: error.message });
7842
9214
  }
7843
- return /* @__PURE__ */ jsx13(Fragment2, { children });
9215
+ return /* @__PURE__ */ jsx14(Fragment3, { children });
7844
9216
  };
7845
9217
 
7846
9218
  // src/components/embed/Embed.tsx
7847
- import { jsx as jsx14 } from "react/jsx-runtime";
7848
- var SchematicEmbed = ({ id, accessToken }) => {
9219
+ import { jsx as jsx15 } from "react/jsx-runtime";
9220
+ var SchematicEmbed = ({ id, accessToken, apiConfig }) => {
7849
9221
  if (accessToken?.length === 0) {
7850
- return /* @__PURE__ */ jsx14("div", { children: "Please provide an access token." });
9222
+ return /* @__PURE__ */ jsx15("div", { children: "Please provide an access token." });
7851
9223
  }
7852
9224
  if (!accessToken?.startsWith("token_")) {
7853
- return /* @__PURE__ */ jsx14("div", { children: 'Invalid access token; your temporary access token will start with "token_".' });
9225
+ return /* @__PURE__ */ jsx15("div", { children: 'Invalid access token; your temporary access token will start with "token_".' });
7854
9226
  }
7855
- return /* @__PURE__ */ jsx14(EmbedProvider, { id, accessToken, children: /* @__PURE__ */ jsx14(ComponentTree, {}) });
9227
+ return /* @__PURE__ */ jsx15(EmbedProvider, { id, accessToken, apiConfig, children: /* @__PURE__ */ jsx15(ComponentTree, {}) });
7856
9228
  };
7857
9229
  export {
7858
9230
  Box,
@@ -7865,7 +9237,7 @@ export {
7865
9237
  IconRound,
7866
9238
  IncludedFeatures,
7867
9239
  Invoices,
7868
- NextBillDue,
9240
+ MeteredFeatures,
7869
9241
  PaymentMethod,
7870
9242
  PlanManager,
7871
9243
  ProgressBar,
@@ -7873,6 +9245,9 @@ export {
7873
9245
  SchematicEmbed,
7874
9246
  SchematicProvider,
7875
9247
  Text,
9248
+ UpcomingBill,
9249
+ defaultSettings,
9250
+ defaultTheme,
7876
9251
  useEmbed,
7877
9252
  useSchematic,
7878
9253
  useSchematicContext,