@shipengine/alchemy 3.0.2 → 4.0.0

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.
package/index.js CHANGED
@@ -4,10 +4,10 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
4
4
 
5
5
  const React = require('react');
6
6
  const jsxRuntime = require('react/jsx-runtime');
7
+ const react = require('@emotion/react');
7
8
  const giger = require('@packlink/giger');
8
9
  const gigerTheme = require('@packlink/giger-theme');
9
- const reactQuery = require('react-query');
10
- const react = require('@emotion/react');
10
+ const reactQuery = require('@tanstack/react-query');
11
11
  const reactI18next = require('react-i18next');
12
12
  const i18n = require('i18next');
13
13
 
@@ -2462,6 +2462,13 @@ function jsx(type, props, key) {
2462
2462
 
2463
2463
  return jsxRuntime.jsx(Emotion, createEmotionProps(type, props), key);
2464
2464
  }
2465
+ function jsxs(type, props, key) {
2466
+ if (!hasOwnProperty.call(props, 'css')) {
2467
+ return jsxRuntime.jsxs(type, props, key);
2468
+ }
2469
+
2470
+ return jsxRuntime.jsxs(Emotion, createEmotionProps(type, props), key);
2471
+ }
2465
2472
 
2466
2473
  var dist = {};
2467
2474
 
@@ -5247,7 +5254,7 @@ var ipaddr = {
5247
5254
  }).call(commonjsGlobal);
5248
5255
  } (ipaddr));
5249
5256
 
5250
- var __async$v = (__this, __arguments, generator) => {
5257
+ var __async$w = (__this, __arguments, generator) => {
5251
5258
  return new Promise((resolve, reject) => {
5252
5259
  var fulfilled = (value) => {
5253
5260
  try {
@@ -5267,7 +5274,7 @@ var __async$v = (__this, __arguments, generator) => {
5267
5274
  step((generator = generator.apply(__this, __arguments)).next());
5268
5275
  });
5269
5276
  };
5270
- const getEndUserIpAddress = () => __async$v(void 0, null, function* () {
5277
+ const getEndUserIpAddress = () => __async$w(void 0, null, function* () {
5271
5278
  try {
5272
5279
  const response = yield axios.get("https://api.ipify.org/?format=json");
5273
5280
  if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
@@ -5310,7 +5317,7 @@ var __objRest$7 = (source, exclude) => {
5310
5317
  }
5311
5318
  return target;
5312
5319
  };
5313
- var __async$u = (__this, __arguments, generator) => {
5320
+ var __async$v = (__this, __arguments, generator) => {
5314
5321
  return new Promise((resolve, reject) => {
5315
5322
  var fulfilled = (value) => {
5316
5323
  try {
@@ -5348,7 +5355,7 @@ class CarriersAPI {
5348
5355
  /**
5349
5356
  * The `connect` method connects a carrier account to a user's ShipEngine account.
5350
5357
  */
5351
- this.connect = (_a) => __async$u(this, null, function* () {
5358
+ this.connect = (_a) => __async$v(this, null, function* () {
5352
5359
  var _b = _a, { carrierCode } = _b, connection = __objRest$7(_b, ["carrierCode"]);
5353
5360
  const endUserIpAddress = yield getEndUserIpAddress();
5354
5361
  if (!endUserIpAddress)
@@ -7651,7 +7658,7 @@ var __spreadValues$4 = (a, b) => {
7651
7658
  }
7652
7659
  return a;
7653
7660
  };
7654
- var __async$t = (__this, __arguments, generator) => {
7661
+ var __async$u = (__this, __arguments, generator) => {
7655
7662
  return new Promise((resolve, reject) => {
7656
7663
  var fulfilled = (value) => {
7657
7664
  try {
@@ -7690,7 +7697,7 @@ class FundingSourcesAPI {
7690
7697
  * The `create` method creates a new funding source for a given user. This requires
7691
7698
  * payment information to be collected from the user.
7692
7699
  */
7693
- this.create = (createFundingSource) => __async$t(this, null, function* () {
7700
+ this.create = (createFundingSource) => __async$u(this, null, function* () {
7694
7701
  const endUserIpAddress = yield getEndUserIpAddress();
7695
7702
  if (!endUserIpAddress)
7696
7703
  return Promise.reject([new CodedError("Unable to get IP address")]);
@@ -7703,7 +7710,7 @@ class FundingSourcesAPI {
7703
7710
  * user to update the billing address or payment information associated with the
7704
7711
  * funding source.
7705
7712
  */
7706
- this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$t(this, null, function* () {
7713
+ this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$u(this, null, function* () {
7707
7714
  const endUserIpAddress = yield getEndUserIpAddress();
7708
7715
  if (!endUserIpAddress)
7709
7716
  return Promise.reject([new CodedError("Unable to get IP address")]);
@@ -7720,7 +7727,7 @@ class FundingSourcesAPI {
7720
7727
  * The `registerCarrier` method registers a carrier account and associates
7721
7728
  * it with a given funding source.
7722
7729
  */
7723
- this.registerCarrier = (carrier) => __async$t(this, null, function* () {
7730
+ this.registerCarrier = (carrier) => __async$u(this, null, function* () {
7724
7731
  const endUserIpAddress = yield getEndUserIpAddress();
7725
7732
  if (!endUserIpAddress)
7726
7733
  return Promise.reject([new CodedError("Unable to get IP address")]);
@@ -7731,7 +7738,7 @@ class FundingSourcesAPI {
7731
7738
  /**
7732
7739
  * The `addFunds` method allows you to add funds to a funding source.
7733
7740
  */
7734
- this.addFunds = (amount, fundingSourceId) => __async$t(this, null, function* () {
7741
+ this.addFunds = (amount, fundingSourceId) => __async$u(this, null, function* () {
7735
7742
  return yield this.client.put(
7736
7743
  `/v1/funding_sources/${fundingSourceId}/add_funds`,
7737
7744
  amount
@@ -7965,7 +7972,7 @@ class SalesOrdersAPI {
7965
7972
  }
7966
7973
  }
7967
7974
 
7968
- var __async$s = (__this, __arguments, generator) => {
7975
+ var __async$t = (__this, __arguments, generator) => {
7969
7976
  return new Promise((resolve, reject) => {
7970
7977
  var fulfilled = (value) => {
7971
7978
  try {
@@ -8008,7 +8015,7 @@ class ShipmentsAPI {
8008
8015
  * The `create` method allows for creating shipments based on a list of shipment
8009
8016
  * items passed into this method.
8010
8017
  */
8011
- this.create = (...shipments) => __async$s(this, null, function* () {
8018
+ this.create = (...shipments) => __async$t(this, null, function* () {
8012
8019
  return this.client.post("/v1/shipments", {
8013
8020
  shipments
8014
8021
  });
@@ -8071,7 +8078,7 @@ var __spreadValues$3 = (a, b) => {
8071
8078
  return a;
8072
8079
  };
8073
8080
  var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
8074
- var __async$r = (__this, __arguments, generator) => {
8081
+ var __async$s = (__this, __arguments, generator) => {
8075
8082
  return new Promise((resolve, reject) => {
8076
8083
  var fulfilled = (value) => {
8077
8084
  try {
@@ -8165,7 +8172,7 @@ class ShipEngineAPI {
8165
8172
  );
8166
8173
  return res;
8167
8174
  },
8168
- (err) => __async$r(this, null, function* () {
8175
+ (err) => __async$s(this, null, function* () {
8169
8176
  var _a, _b, _c, _d, _e, _f, _g;
8170
8177
  logger$1.error(
8171
8178
  { err, req: err.config, res: err.response },
@@ -8454,7 +8461,7 @@ const useGetAccountSettings = () => {
8454
8461
  });
8455
8462
  };
8456
8463
 
8457
- var __async$q = (__this, __arguments, generator) => {
8464
+ var __async$r = (__this, __arguments, generator) => {
8458
8465
  return new Promise((resolve, reject) => {
8459
8466
  var fulfilled = (value) => {
8460
8467
  try {
@@ -8477,7 +8484,7 @@ var __async$q = (__this, __arguments, generator) => {
8477
8484
  const useUpdateAccountSettings = () => {
8478
8485
  const { client } = useShipEngine();
8479
8486
  return reactQuery.useMutation({
8480
- mutationFn: (settings) => __async$q(void 0, null, function* () {
8487
+ mutationFn: (settings) => __async$r(void 0, null, function* () {
8481
8488
  const result = yield client.accountSettings.update(settings);
8482
8489
  return result.data;
8483
8490
  }),
@@ -8486,7 +8493,7 @@ const useUpdateAccountSettings = () => {
8486
8493
  });
8487
8494
  };
8488
8495
 
8489
- var __async$p = (__this, __arguments, generator) => {
8496
+ var __async$q = (__this, __arguments, generator) => {
8490
8497
  return new Promise((resolve, reject) => {
8491
8498
  var fulfilled = (value) => {
8492
8499
  try {
@@ -8509,7 +8516,7 @@ var __async$p = (__this, __arguments, generator) => {
8509
8516
  const useParseAddress = () => {
8510
8517
  const { client } = useShipEngine();
8511
8518
  return reactQuery.useMutation({
8512
- mutationFn: (_0) => __async$p(void 0, [_0], function* ({ address, text }) {
8519
+ mutationFn: (_0) => __async$q(void 0, [_0], function* ({ address, text }) {
8513
8520
  const result = yield client.addresses.parse(text, address);
8514
8521
  return result.data;
8515
8522
  }),
@@ -8518,7 +8525,7 @@ const useParseAddress = () => {
8518
8525
  });
8519
8526
  };
8520
8527
 
8521
- var __async$o = (__this, __arguments, generator) => {
8528
+ var __async$p = (__this, __arguments, generator) => {
8522
8529
  return new Promise((resolve, reject) => {
8523
8530
  var fulfilled = (value) => {
8524
8531
  try {
@@ -8541,7 +8548,7 @@ var __async$o = (__this, __arguments, generator) => {
8541
8548
  const useValidateAddresses = () => {
8542
8549
  const { client } = useShipEngine();
8543
8550
  return reactQuery.useMutation({
8544
- mutationFn: (addresses) => __async$o(void 0, null, function* () {
8551
+ mutationFn: (addresses) => __async$p(void 0, null, function* () {
8545
8552
  const result = yield client.addresses.validate(addresses);
8546
8553
  return result.data;
8547
8554
  }),
@@ -8550,7 +8557,7 @@ const useValidateAddresses = () => {
8550
8557
  });
8551
8558
  };
8552
8559
 
8553
- var __async$n = (__this, __arguments, generator) => {
8560
+ var __async$o = (__this, __arguments, generator) => {
8554
8561
  return new Promise((resolve, reject) => {
8555
8562
  var fulfilled = (value) => {
8556
8563
  try {
@@ -8573,7 +8580,7 @@ var __async$n = (__this, __arguments, generator) => {
8573
8580
  const useAddFunds = (carrierId) => {
8574
8581
  const { client } = useShipEngine();
8575
8582
  return reactQuery.useMutation({
8576
- mutationFn: (funds) => __async$n(void 0, null, function* () {
8583
+ mutationFn: (funds) => __async$o(void 0, null, function* () {
8577
8584
  const result = yield client.carriers.addFunds(carrierId, funds);
8578
8585
  return result.data;
8579
8586
  }),
@@ -8582,7 +8589,7 @@ const useAddFunds = (carrierId) => {
8582
8589
  });
8583
8590
  };
8584
8591
 
8585
- var __async$m = (__this, __arguments, generator) => {
8592
+ var __async$n = (__this, __arguments, generator) => {
8586
8593
  return new Promise((resolve, reject) => {
8587
8594
  var fulfilled = (value) => {
8588
8595
  try {
@@ -8605,7 +8612,7 @@ var __async$m = (__this, __arguments, generator) => {
8605
8612
  const useConnectCarrier = () => {
8606
8613
  const { client } = useShipEngine();
8607
8614
  return reactQuery.useMutation({
8608
- mutationFn: (params) => __async$m(void 0, null, function* () {
8615
+ mutationFn: (params) => __async$n(void 0, null, function* () {
8609
8616
  const result = yield client.carriers.connect(params);
8610
8617
  return result.data;
8611
8618
  }),
@@ -8742,7 +8749,7 @@ const useListCarriers = () => {
8742
8749
  });
8743
8750
  };
8744
8751
 
8745
- var __async$l = (__this, __arguments, generator) => {
8752
+ var __async$m = (__this, __arguments, generator) => {
8746
8753
  return new Promise((resolve, reject) => {
8747
8754
  var fulfilled = (value) => {
8748
8755
  try {
@@ -8766,7 +8773,7 @@ const useUpdateAutoFunding = (carrierId) => {
8766
8773
  const { client } = useShipEngine();
8767
8774
  const queryClient = reactQuery.useQueryClient();
8768
8775
  return reactQuery.useMutation({
8769
- mutationFn: (options) => __async$l(void 0, null, function* () {
8776
+ mutationFn: (options) => __async$m(void 0, null, function* () {
8770
8777
  const result = yield client.carriers.updateAutoFunding(carrierId, options);
8771
8778
  return result.data;
8772
8779
  }),
@@ -8805,7 +8812,7 @@ const useListCustomPackageTypes = () => {
8805
8812
  });
8806
8813
  };
8807
8814
 
8808
- var __async$k = (__this, __arguments, generator) => {
8815
+ var __async$l = (__this, __arguments, generator) => {
8809
8816
  return new Promise((resolve, reject) => {
8810
8817
  var fulfilled = (value) => {
8811
8818
  try {
@@ -8828,7 +8835,7 @@ var __async$k = (__this, __arguments, generator) => {
8828
8835
  const useCreateFundingSource = () => {
8829
8836
  const { client } = useShipEngine();
8830
8837
  return reactQuery.useMutation({
8831
- mutationFn: (fundingSource) => __async$k(void 0, null, function* () {
8838
+ mutationFn: (fundingSource) => __async$l(void 0, null, function* () {
8832
8839
  const result = yield client.fundingSources.create(fundingSource);
8833
8840
  return result.data;
8834
8841
  }),
@@ -8837,7 +8844,7 @@ const useCreateFundingSource = () => {
8837
8844
  });
8838
8845
  };
8839
8846
 
8840
- var __async$j = (__this, __arguments, generator) => {
8847
+ var __async$k = (__this, __arguments, generator) => {
8841
8848
  return new Promise((resolve, reject) => {
8842
8849
  var fulfilled = (value) => {
8843
8850
  try {
@@ -8860,7 +8867,7 @@ var __async$j = (__this, __arguments, generator) => {
8860
8867
  const useFundingSourcesAddFunds = (fundingSourceId) => {
8861
8868
  const { client } = useShipEngine();
8862
8869
  return reactQuery.useMutation({
8863
- mutationFn: (funds) => __async$j(void 0, null, function* () {
8870
+ mutationFn: (funds) => __async$k(void 0, null, function* () {
8864
8871
  const result = yield client.fundingSources.addFunds(funds, fundingSourceId);
8865
8872
  return result.data;
8866
8873
  }),
@@ -8889,7 +8896,7 @@ const useListFundingSources = () => {
8889
8896
  });
8890
8897
  };
8891
8898
 
8892
- var __async$i = (__this, __arguments, generator) => {
8899
+ var __async$j = (__this, __arguments, generator) => {
8893
8900
  return new Promise((resolve, reject) => {
8894
8901
  var fulfilled = (value) => {
8895
8902
  try {
@@ -8912,7 +8919,7 @@ var __async$i = (__this, __arguments, generator) => {
8912
8919
  const useRegisterCarrier = () => {
8913
8920
  const { client } = useShipEngine();
8914
8921
  return reactQuery.useMutation({
8915
- mutationFn: (carrier) => __async$i(void 0, null, function* () {
8922
+ mutationFn: (carrier) => __async$j(void 0, null, function* () {
8916
8923
  const result = yield client.fundingSources.registerCarrier(carrier);
8917
8924
  return result.data;
8918
8925
  }),
@@ -8921,7 +8928,7 @@ const useRegisterCarrier = () => {
8921
8928
  });
8922
8929
  };
8923
8930
 
8924
- var __async$h = (__this, __arguments, generator) => {
8931
+ var __async$i = (__this, __arguments, generator) => {
8925
8932
  return new Promise((resolve, reject) => {
8926
8933
  var fulfilled = (value) => {
8927
8934
  try {
@@ -8944,7 +8951,7 @@ var __async$h = (__this, __arguments, generator) => {
8944
8951
  const useUpdateFundingSource = () => {
8945
8952
  const { client } = useShipEngine();
8946
8953
  return reactQuery.useMutation({
8947
- mutationFn: (_0) => __async$h(void 0, [_0], function* ({
8954
+ mutationFn: (_0) => __async$i(void 0, [_0], function* ({
8948
8955
  billingInfo,
8949
8956
  creditCardInfo,
8950
8957
  fundingSourceId
@@ -8991,7 +8998,7 @@ var __objRest$6 = (source, exclude) => {
8991
8998
  }
8992
8999
  return target;
8993
9000
  };
8994
- var __async$g = (__this, __arguments, generator) => {
9001
+ var __async$h = (__this, __arguments, generator) => {
8995
9002
  return new Promise((resolve, reject) => {
8996
9003
  var fulfilled = (value) => {
8997
9004
  try {
@@ -9014,7 +9021,7 @@ var __async$g = (__this, __arguments, generator) => {
9014
9021
  const useCreateLabel = () => {
9015
9022
  const { client } = useShipEngine();
9016
9023
  return reactQuery.useMutation({
9017
- mutationFn: (_a) => __async$g(void 0, null, function* () {
9024
+ mutationFn: (_a) => __async$h(void 0, null, function* () {
9018
9025
  var _b = _a, { rateId } = _b, options = __objRest$6(_b, ["rateId"]);
9019
9026
  const result = yield client.labels.createByRateId(rateId, options);
9020
9027
  return result.data;
@@ -9050,7 +9057,7 @@ const useListLabels = (params) => {
9050
9057
  });
9051
9058
  };
9052
9059
 
9053
- var __async$f = (__this, __arguments, generator) => {
9060
+ var __async$g = (__this, __arguments, generator) => {
9054
9061
  return new Promise((resolve, reject) => {
9055
9062
  var fulfilled = (value) => {
9056
9063
  try {
@@ -9073,7 +9080,7 @@ var __async$f = (__this, __arguments, generator) => {
9073
9080
  const useVoidLabel = () => {
9074
9081
  const { client } = useShipEngine();
9075
9082
  return reactQuery.useMutation({
9076
- mutationFn: (labelId) => __async$f(void 0, null, function* () {
9083
+ mutationFn: (labelId) => __async$g(void 0, null, function* () {
9077
9084
  const result = yield client.labels.void(labelId);
9078
9085
  return result.data;
9079
9086
  }),
@@ -9092,7 +9099,7 @@ const useListOrderSources = () => {
9092
9099
  });
9093
9100
  };
9094
9101
 
9095
- var __async$e = (__this, __arguments, generator) => {
9102
+ var __async$f = (__this, __arguments, generator) => {
9096
9103
  return new Promise((resolve, reject) => {
9097
9104
  var fulfilled = (value) => {
9098
9105
  try {
@@ -9115,7 +9122,7 @@ var __async$e = (__this, __arguments, generator) => {
9115
9122
  const useRefreshOrderSourceAsync = () => {
9116
9123
  const { client } = useShipEngine();
9117
9124
  return reactQuery.useMutation({
9118
- mutationFn: (orderSourceId) => __async$e(void 0, null, function* () {
9125
+ mutationFn: (orderSourceId) => __async$f(void 0, null, function* () {
9119
9126
  const result = yield client.orderSources.refresh(orderSourceId);
9120
9127
  return result.data;
9121
9128
  }),
@@ -9126,9 +9133,9 @@ const useRefreshOrderSource = () => {
9126
9133
  const { client } = useShipEngine();
9127
9134
  const { mutateAsync: refreshOrderSourceAsync } = useRefreshOrderSourceAsync();
9128
9135
  return reactQuery.useMutation({
9129
- mutationFn: (orderSourceId) => __async$e(void 0, null, function* () {
9136
+ mutationFn: (orderSourceId) => __async$f(void 0, null, function* () {
9130
9137
  yield refreshOrderSourceAsync(orderSourceId);
9131
- const waitResult = yield retryUntil(() => __async$e(void 0, null, function* () {
9138
+ const waitResult = yield retryUntil(() => __async$f(void 0, null, function* () {
9132
9139
  const { data: checkResult } = yield client.orderSources.get(orderSourceId);
9133
9140
  if (["preparing_update", "updating"].includes(checkResult.refreshInfo.status)) {
9134
9141
  throw new CodedError("Order source is still refreshing");
@@ -9142,7 +9149,7 @@ const useRefreshOrderSource = () => {
9142
9149
  });
9143
9150
  };
9144
9151
 
9145
- var __async$d = (__this, __arguments, generator) => {
9152
+ var __async$e = (__this, __arguments, generator) => {
9146
9153
  return new Promise((resolve, reject) => {
9147
9154
  var fulfilled = (value) => {
9148
9155
  try {
@@ -9165,7 +9172,7 @@ var __async$d = (__this, __arguments, generator) => {
9165
9172
  const useCreateRateCard = () => {
9166
9173
  const { client } = useShipEngine();
9167
9174
  return reactQuery.useMutation({
9168
- mutationFn: (rateCard) => __async$d(void 0, null, function* () {
9175
+ mutationFn: (rateCard) => __async$e(void 0, null, function* () {
9169
9176
  const result = yield client.rateCards.create(rateCard);
9170
9177
  return result.data;
9171
9178
  }),
@@ -9212,7 +9219,7 @@ const useListRateCards = (carrierIds) => {
9212
9219
  });
9213
9220
  };
9214
9221
 
9215
- var __async$c = (__this, __arguments, generator) => {
9222
+ var __async$d = (__this, __arguments, generator) => {
9216
9223
  return new Promise((resolve, reject) => {
9217
9224
  var fulfilled = (value) => {
9218
9225
  try {
@@ -9235,7 +9242,7 @@ var __async$c = (__this, __arguments, generator) => {
9235
9242
  const usePublishRateCard = () => {
9236
9243
  const { client } = useShipEngine();
9237
9244
  return reactQuery.useMutation({
9238
- mutationFn: (rateCardId) => __async$c(void 0, null, function* () {
9245
+ mutationFn: (rateCardId) => __async$d(void 0, null, function* () {
9239
9246
  return yield client.rateCards.publish(rateCardId);
9240
9247
  }),
9241
9248
  mutationKey: ["usePublishRateCard"],
@@ -9243,7 +9250,7 @@ const usePublishRateCard = () => {
9243
9250
  });
9244
9251
  };
9245
9252
 
9246
- var __async$b = (__this, __arguments, generator) => {
9253
+ var __async$c = (__this, __arguments, generator) => {
9247
9254
  return new Promise((resolve, reject) => {
9248
9255
  var fulfilled = (value) => {
9249
9256
  try {
@@ -9266,7 +9273,7 @@ var __async$b = (__this, __arguments, generator) => {
9266
9273
  const useUpdateRateCard = () => {
9267
9274
  const { client } = useShipEngine();
9268
9275
  return reactQuery.useMutation({
9269
- mutationFn: (rateCard) => __async$b(void 0, null, function* () {
9276
+ mutationFn: (rateCard) => __async$c(void 0, null, function* () {
9270
9277
  const result = yield client.rateCards.update(rateCard);
9271
9278
  return result.data;
9272
9279
  }),
@@ -9275,7 +9282,7 @@ const useUpdateRateCard = () => {
9275
9282
  });
9276
9283
  };
9277
9284
 
9278
- var __async$a = (__this, __arguments, generator) => {
9285
+ var __async$b = (__this, __arguments, generator) => {
9279
9286
  return new Promise((resolve, reject) => {
9280
9287
  var fulfilled = (value) => {
9281
9288
  try {
@@ -9298,7 +9305,7 @@ var __async$a = (__this, __arguments, generator) => {
9298
9305
  const useUploadRateCard = () => {
9299
9306
  const { client } = useShipEngine();
9300
9307
  return reactQuery.useMutation({
9301
- mutationFn: (_0) => __async$a(void 0, [_0], function* ({ rateCardId, file }) {
9308
+ mutationFn: (_0) => __async$b(void 0, [_0], function* ({ rateCardId, file }) {
9302
9309
  const result = yield client.rateCards.upload(rateCardId, file);
9303
9310
  return result.data;
9304
9311
  }),
@@ -9307,7 +9314,7 @@ const useUploadRateCard = () => {
9307
9314
  });
9308
9315
  };
9309
9316
 
9310
- var __async$9 = (__this, __arguments, generator) => {
9317
+ var __async$a = (__this, __arguments, generator) => {
9311
9318
  return new Promise((resolve, reject) => {
9312
9319
  var fulfilled = (value) => {
9313
9320
  try {
@@ -9330,7 +9337,7 @@ var __async$9 = (__this, __arguments, generator) => {
9330
9337
  const useDeleteRateCard = () => {
9331
9338
  const { client } = useShipEngine();
9332
9339
  return reactQuery.useMutation({
9333
- mutationFn: (rateCardId) => __async$9(void 0, null, function* () {
9340
+ mutationFn: (rateCardId) => __async$a(void 0, null, function* () {
9334
9341
  const result = yield client.rateCards.delete(rateCardId);
9335
9342
  return result.data;
9336
9343
  }),
@@ -9339,7 +9346,7 @@ const useDeleteRateCard = () => {
9339
9346
  });
9340
9347
  };
9341
9348
 
9342
- var __async$8 = (__this, __arguments, generator) => {
9349
+ var __async$9 = (__this, __arguments, generator) => {
9343
9350
  return new Promise((resolve, reject) => {
9344
9351
  var fulfilled = (value) => {
9345
9352
  try {
@@ -9362,7 +9369,7 @@ var __async$8 = (__this, __arguments, generator) => {
9362
9369
  const useCalculateRates = () => {
9363
9370
  const { client } = useShipEngine();
9364
9371
  return reactQuery.useMutation({
9365
- mutationFn: (_0) => __async$8(void 0, [_0], function* ({ rateOptions, shipmentId }) {
9372
+ mutationFn: (_0) => __async$9(void 0, [_0], function* ({ rateOptions, shipmentId }) {
9366
9373
  const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
9367
9374
  return result.data;
9368
9375
  }),
@@ -9412,7 +9419,7 @@ var __objRest$5 = (source, exclude) => {
9412
9419
  }
9413
9420
  return target;
9414
9421
  };
9415
- var __async$7 = (__this, __arguments, generator) => {
9422
+ var __async$8 = (__this, __arguments, generator) => {
9416
9423
  return new Promise((resolve, reject) => {
9417
9424
  var fulfilled = (value) => {
9418
9425
  try {
@@ -9435,7 +9442,7 @@ var __async$7 = (__this, __arguments, generator) => {
9435
9442
  const useNotifySalesOrderShipped = () => {
9436
9443
  const { client } = useShipEngine();
9437
9444
  return reactQuery.useMutation({
9438
- mutationFn: (_a) => __async$7(void 0, null, function* () {
9445
+ mutationFn: (_a) => __async$8(void 0, null, function* () {
9439
9446
  var _b = _a, { salesOrderId } = _b, tracking = __objRest$5(_b, ["salesOrderId"]);
9440
9447
  const result = yield client.salesOrders.notifyShipped(salesOrderId, tracking);
9441
9448
  return result.data;
@@ -9460,7 +9467,7 @@ var __objRest$4 = (source, exclude) => {
9460
9467
  }
9461
9468
  return target;
9462
9469
  };
9463
- var __async$6 = (__this, __arguments, generator) => {
9470
+ var __async$7 = (__this, __arguments, generator) => {
9464
9471
  return new Promise((resolve, reject) => {
9465
9472
  var fulfilled = (value) => {
9466
9473
  try {
@@ -9483,7 +9490,7 @@ var __async$6 = (__this, __arguments, generator) => {
9483
9490
  const useCreateSalesOrderShipment = () => {
9484
9491
  const { client } = useShipEngine();
9485
9492
  return reactQuery.useMutation({
9486
- mutationFn: (_a) => __async$6(void 0, null, function* () {
9493
+ mutationFn: (_a) => __async$7(void 0, null, function* () {
9487
9494
  var _b = _a, { salesOrderId } = _b, shipment = __objRest$4(_b, ["salesOrderId"]);
9488
9495
  const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
9489
9496
  return result.data;
@@ -9534,7 +9541,7 @@ var __objRest$3 = (source, exclude) => {
9534
9541
  }
9535
9542
  return target;
9536
9543
  };
9537
- var __async$5 = (__this, __arguments, generator) => {
9544
+ var __async$6 = (__this, __arguments, generator) => {
9538
9545
  return new Promise((resolve, reject) => {
9539
9546
  var fulfilled = (value) => {
9540
9547
  try {
@@ -9557,7 +9564,7 @@ var __async$5 = (__this, __arguments, generator) => {
9557
9564
  const useUpdateSalesOrderShipment = () => {
9558
9565
  const { client } = useShipEngine();
9559
9566
  return reactQuery.useMutation({
9560
- mutationFn: (_a) => __async$5(void 0, null, function* () {
9567
+ mutationFn: (_a) => __async$6(void 0, null, function* () {
9561
9568
  var _b = _a, { shipmentId } = _b, shipment = __objRest$3(_b, ["shipmentId"]);
9562
9569
  const result = yield client.salesOrderShipments.update(shipmentId, shipment);
9563
9570
  return result.data;
@@ -9586,7 +9593,7 @@ var __spreadValues$1 = (a, b) => {
9586
9593
  return a;
9587
9594
  };
9588
9595
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9589
- var __async$4 = (__this, __arguments, generator) => {
9596
+ var __async$5 = (__this, __arguments, generator) => {
9590
9597
  return new Promise((resolve, reject) => {
9591
9598
  var fulfilled = (value) => {
9592
9599
  try {
@@ -9609,7 +9616,7 @@ var __async$4 = (__this, __arguments, generator) => {
9609
9616
  const useCreateShipment = () => {
9610
9617
  const { client } = useShipEngine();
9611
9618
  return reactQuery.useMutation({
9612
- mutationFn: (shipment) => __async$4(void 0, null, function* () {
9619
+ mutationFn: (shipment) => __async$5(void 0, null, function* () {
9613
9620
  var _a;
9614
9621
  if (shipment.warehouseId === void 0) {
9615
9622
  throw new CodedError("errorMessages.noWarehouses", {
@@ -9695,7 +9702,7 @@ const useListShipments = (_params) => {
9695
9702
  });
9696
9703
  };
9697
9704
 
9698
- var __async$3 = (__this, __arguments, generator) => {
9705
+ var __async$4 = (__this, __arguments, generator) => {
9699
9706
  return new Promise((resolve, reject) => {
9700
9707
  var fulfilled = (value) => {
9701
9708
  try {
@@ -9718,7 +9725,7 @@ var __async$3 = (__this, __arguments, generator) => {
9718
9725
  const useCreateWarehouse = () => {
9719
9726
  const { client } = useShipEngine();
9720
9727
  return reactQuery.useMutation({
9721
- mutationFn: (data) => __async$3(void 0, null, function* () {
9728
+ mutationFn: (data) => __async$4(void 0, null, function* () {
9722
9729
  const result = yield client.warehouses.create(data);
9723
9730
  return result.data;
9724
9731
  }),
@@ -9727,7 +9734,7 @@ const useCreateWarehouse = () => {
9727
9734
  });
9728
9735
  };
9729
9736
 
9730
- var __async$2 = (__this, __arguments, generator) => {
9737
+ var __async$3 = (__this, __arguments, generator) => {
9731
9738
  return new Promise((resolve, reject) => {
9732
9739
  var fulfilled = (value) => {
9733
9740
  try {
@@ -9750,7 +9757,7 @@ var __async$2 = (__this, __arguments, generator) => {
9750
9757
  const useDeleteWarehouse = () => {
9751
9758
  const { client } = useShipEngine();
9752
9759
  return reactQuery.useMutation({
9753
- mutationFn: (_0) => __async$2(void 0, [_0], function* ({ warehouseId }) {
9760
+ mutationFn: (_0) => __async$3(void 0, [_0], function* ({ warehouseId }) {
9754
9761
  const result = yield client.warehouses.delete(warehouseId);
9755
9762
  return result.data;
9756
9763
  }),
@@ -9786,7 +9793,7 @@ var __objRest$1 = (source, exclude) => {
9786
9793
  }
9787
9794
  return target;
9788
9795
  };
9789
- var __async$1 = (__this, __arguments, generator) => {
9796
+ var __async$2 = (__this, __arguments, generator) => {
9790
9797
  return new Promise((resolve, reject) => {
9791
9798
  var fulfilled = (value) => {
9792
9799
  try {
@@ -9809,7 +9816,7 @@ var __async$1 = (__this, __arguments, generator) => {
9809
9816
  const useUpdateWarehouse = () => {
9810
9817
  const { client } = useShipEngine();
9811
9818
  return reactQuery.useMutation({
9812
- mutationFn: (_a) => __async$1(void 0, null, function* () {
9819
+ mutationFn: (_a) => __async$2(void 0, null, function* () {
9813
9820
  var _b = _a, { warehouseId } = _b, warehouse = __objRest$1(_b, ["warehouseId"]);
9814
9821
  const result = yield client.warehouses.update(warehouseId, warehouse);
9815
9822
  return result.data;
@@ -10179,6 +10186,56 @@ const themeData = {
10179
10186
  fallback: fallbackThemeData
10180
10187
  };
10181
10188
 
10189
+ var __async$1 = (__this, __arguments, generator) => {
10190
+ return new Promise((resolve, reject) => {
10191
+ var fulfilled = (value) => {
10192
+ try {
10193
+ step(generator.next(value));
10194
+ } catch (e) {
10195
+ reject(e);
10196
+ }
10197
+ };
10198
+ var rejected = (value) => {
10199
+ try {
10200
+ step(generator.throw(value));
10201
+ } catch (e) {
10202
+ reject(e);
10203
+ }
10204
+ };
10205
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
10206
+ step((generator = generator.apply(__this, __arguments)).next());
10207
+ });
10208
+ };
10209
+ const useLoadFonts = ({ cdnURL = "/", scope, theme }) => {
10210
+ const [fontFamily, setFontFamily] = React.useState();
10211
+ React.useEffect(() => {
10212
+ (() => __async$1(void 0, null, function* () {
10213
+ var _a;
10214
+ try {
10215
+ const fontFaces = (_a = theme == null ? void 0 : theme.fontFaces) != null ? _a : [];
10216
+ yield Promise.all(
10217
+ fontFaces.map((_0) => __async$1(void 0, [_0], function* ({ family, source, descriptors }) {
10218
+ const fontSources = source.map((url) => `url(${url.replace("$cdnUrl", cdnURL)})`).join(", ");
10219
+ try {
10220
+ const font = new FontFace(family, fontSources, descriptors);
10221
+ const loadedFont = yield font.load();
10222
+ document.fonts.add(loadedFont);
10223
+ } catch (err) {
10224
+ console.error(err);
10225
+ }
10226
+ }))
10227
+ );
10228
+ setFontFamily(theme == null ? void 0 : theme.defaultFontFamily);
10229
+ } catch (error) {
10230
+ logger.error({ error }, `Error loading fonts`);
10231
+ }
10232
+ }))();
10233
+ }, [cdnURL, theme]);
10234
+ return react.css({
10235
+ [`.${scope}`]: { fontFamily }
10236
+ });
10237
+ };
10238
+
10182
10239
  const fallbackBrandName = "fallback";
10183
10240
  const constants = {
10184
10241
  fallbackBrandName
@@ -10221,47 +10278,28 @@ const useLoadIcons = ({ cdnURL = "/" }) => {
10221
10278
  );
10222
10279
  };
10223
10280
 
10224
- const DEFAULT_LOCALE = "en-US";
10225
10281
  const AlchemyContext = React.createContext(void 0);
10226
- const getDefaultLocale = () => {
10227
- var _a;
10228
- if (typeof window === "undefined") {
10229
- return DEFAULT_LOCALE;
10230
- }
10231
- return (_a = navigator == null ? void 0 : navigator.language) != null ? _a : DEFAULT_LOCALE;
10232
- };
10233
10282
  const AlchemyProvider = ({
10234
10283
  baseURL = "https://api.shipengine.com",
10235
10284
  cdnURL = "/",
10236
10285
  children,
10237
10286
  getToken,
10238
- locale: localeProp,
10287
+ locale = ((_a) => (_a = navigator == null ? void 0 : navigator.language) != null ? _a : "en-US")(),
10239
10288
  onError = _default,
10240
10289
  scope = "lmnt",
10241
10290
  themeConfig
10242
10291
  }) => {
10243
- const locale = localeProp || getDefaultLocale();
10244
- const resolveIcon = useLoadIcons({ cdnURL });
10245
10292
  const theme = new gigerTheme.Theme(themeConfig != null ? themeConfig : themeData.fallback);
10246
- const contextValue = {
10247
- baseURL,
10248
- cdnURL,
10249
- getToken,
10250
- locale,
10251
- onError,
10252
- scope,
10253
- theme
10254
- };
10255
- return /* @__PURE__ */ jsx(AlchemyContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
10256
- giger.GigerProvider,
10257
- {
10258
- reference: scope || void 0,
10259
- cdnUrl: cdnURL,
10260
- resolveIcon,
10261
- theme,
10262
- children: /* @__PURE__ */ jsx(ShipEngine, { baseURL, getToken, children })
10263
- }
10264
- ) });
10293
+ const fontStyles = useLoadFonts({ cdnURL, scope, theme });
10294
+ const resolveIcon = useLoadIcons({ cdnURL });
10295
+ const iconCache = React.useMemo(giger.createIconCache, []);
10296
+ if (!theme)
10297
+ return null;
10298
+ const contextValue = { baseURL, cdnURL, getToken, locale, onError, scope, theme };
10299
+ return /* @__PURE__ */ jsx(AlchemyContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(react.ThemeProvider, { theme, children: [
10300
+ /* @__PURE__ */ jsx(react.Global, { styles: [giger.getEmotionResetStyles(scope), fontStyles] }),
10301
+ /* @__PURE__ */ jsx(giger.GigerConfigProvider, { iconCache, resolveIcon, children: /* @__PURE__ */ jsx(ShipEngine, { baseURL, getToken, children }) })
10302
+ ] }) });
10265
10303
  };
10266
10304
  const useAlchemy = () => {
10267
10305
  const context = React.useContext(AlchemyContext);
@@ -10970,6 +11008,7 @@ exports.useListSalesOrderShipments = useListSalesOrderShipments;
10970
11008
  exports.useListSalesOrders = useListSalesOrders;
10971
11009
  exports.useListShipments = useListShipments;
10972
11010
  exports.useListWarehouses = useListWarehouses;
11011
+ exports.useLoadFonts = useLoadFonts;
10973
11012
  exports.useLoadIcons = useLoadIcons;
10974
11013
  exports.useNotifySalesOrderShipped = useNotifySalesOrderShipped;
10975
11014
  exports.useParseAddress = useParseAddress;