@layerfi/components 0.1.106 → 0.1.107-alpha

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.
@@ -3785,7 +3785,7 @@ var require_lodash = __commonJS({
3785
3785
  }
3786
3786
  function reject(collection, predicate) {
3787
3787
  var func = isArray(collection) ? arrayFilter : baseFilter;
3788
- return func(collection, negate(getIteratee(predicate, 3)));
3788
+ return func(collection, negate2(getIteratee(predicate, 3)));
3789
3789
  }
3790
3790
  function sample(collection) {
3791
3791
  var func = isArray(collection) ? arraySample : baseSample;
@@ -3899,17 +3899,17 @@ var require_lodash = __commonJS({
3899
3899
  result2.placeholder = curryRight.placeholder;
3900
3900
  return result2;
3901
3901
  }
3902
- function debounce7(func, wait, options) {
3902
+ function debounce7(func, wait, options2) {
3903
3903
  var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
3904
3904
  if (typeof func != "function") {
3905
3905
  throw new TypeError2(FUNC_ERROR_TEXT);
3906
3906
  }
3907
3907
  wait = toNumber(wait) || 0;
3908
- if (isObject(options)) {
3909
- leading = !!options.leading;
3910
- maxing = "maxWait" in options;
3911
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
3912
- trailing = "trailing" in options ? !!options.trailing : trailing;
3908
+ if (isObject(options2)) {
3909
+ leading = !!options2.leading;
3910
+ maxing = "maxWait" in options2;
3911
+ maxWait = maxing ? nativeMax(toNumber(options2.maxWait) || 0, wait) : maxWait;
3912
+ trailing = "trailing" in options2 ? !!options2.trailing : trailing;
3913
3913
  }
3914
3914
  function invokeFunc(time) {
3915
3915
  var args = lastArgs, thisArg = lastThis;
@@ -4006,7 +4006,7 @@ var require_lodash = __commonJS({
4006
4006
  return memoized;
4007
4007
  }
4008
4008
  memoize.Cache = MapCache;
4009
- function negate(predicate) {
4009
+ function negate2(predicate) {
4010
4010
  if (typeof predicate != "function") {
4011
4011
  throw new TypeError2(FUNC_ERROR_TEXT);
4012
4012
  }
@@ -4070,14 +4070,14 @@ var require_lodash = __commonJS({
4070
4070
  return apply(func, this, otherArgs);
4071
4071
  });
4072
4072
  }
4073
- function throttle(func, wait, options) {
4073
+ function throttle(func, wait, options2) {
4074
4074
  var leading = true, trailing = true;
4075
4075
  if (typeof func != "function") {
4076
4076
  throw new TypeError2(FUNC_ERROR_TEXT);
4077
4077
  }
4078
- if (isObject(options)) {
4079
- leading = "leading" in options ? !!options.leading : leading;
4080
- trailing = "trailing" in options ? !!options.trailing : trailing;
4078
+ if (isObject(options2)) {
4079
+ leading = "leading" in options2 ? !!options2.leading : leading;
4080
+ trailing = "trailing" in options2 ? !!options2.trailing : trailing;
4081
4081
  }
4082
4082
  return debounce7(func, wait, {
4083
4083
  "leading": leading,
@@ -4167,7 +4167,7 @@ var require_lodash = __commonJS({
4167
4167
  function isEqual2(value, other) {
4168
4168
  return baseIsEqual(value, other);
4169
4169
  }
4170
- function isEqualWith(value, other, customizer) {
4170
+ function isEqualWith2(value, other, customizer) {
4171
4171
  customizer = typeof customizer == "function" ? customizer : undefined2;
4172
4172
  var result2 = customizer ? customizer(value, other) : undefined2;
4173
4173
  return result2 === undefined2 ? baseIsEqual(value, other, undefined2, customizer) : !!result2;
@@ -4475,7 +4475,7 @@ var require_lodash = __commonJS({
4475
4475
  return result2;
4476
4476
  });
4477
4477
  function omitBy(object, predicate) {
4478
- return pickBy(object, negate(getIteratee(predicate)));
4478
+ return pickBy(object, negate2(getIteratee(predicate)));
4479
4479
  }
4480
4480
  var pick = flatRest(function(object, paths) {
4481
4481
  return object == null ? {} : basePick(object, paths);
@@ -4720,20 +4720,20 @@ var require_lodash = __commonJS({
4720
4720
  target = baseToString(target);
4721
4721
  return string.slice(position, position + target.length) == target;
4722
4722
  }
4723
- function template(string, options, guard) {
4723
+ function template(string, options2, guard) {
4724
4724
  var settings = lodash.templateSettings;
4725
- if (guard && isIterateeCall(string, options, guard)) {
4726
- options = undefined2;
4725
+ if (guard && isIterateeCall(string, options2, guard)) {
4726
+ options2 = undefined2;
4727
4727
  }
4728
4728
  string = toString(string);
4729
- options = assignInWith({}, options, settings, customDefaultsAssignIn);
4730
- var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys);
4731
- var isEscaping, isEvaluating, index = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '";
4729
+ options2 = assignInWith({}, options2, settings, customDefaultsAssignIn);
4730
+ var imports = assignInWith({}, options2.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys);
4731
+ var isEscaping, isEvaluating, index = 0, interpolate = options2.interpolate || reNoMatch, source = "__p += '";
4732
4732
  var reDelimiters = RegExp2(
4733
- (options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$",
4733
+ (options2.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options2.evaluate || reNoMatch).source + "|$",
4734
4734
  "g"
4735
4735
  );
4736
- var sourceURL = "//# sourceURL=" + (hasOwnProperty.call(options, "sourceURL") ? (options.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
4736
+ var sourceURL = "//# sourceURL=" + (hasOwnProperty.call(options2, "sourceURL") ? (options2.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
4737
4737
  string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset2) {
4738
4738
  interpolateValue || (interpolateValue = esTemplateValue);
4739
4739
  source += string.slice(index, offset2).replace(reUnescapedString, escapeStringChar);
@@ -4752,7 +4752,7 @@ var require_lodash = __commonJS({
4752
4752
  return match;
4753
4753
  });
4754
4754
  source += "';\n";
4755
- var variable = hasOwnProperty.call(options, "variable") && options.variable;
4755
+ var variable = hasOwnProperty.call(options2, "variable") && options2.variable;
4756
4756
  if (!variable) {
4757
4757
  source = "with (obj) {\n" + source + "\n}\n";
4758
4758
  } else if (reForbiddenIdentifierChars.test(variable)) {
@@ -4808,12 +4808,12 @@ var require_lodash = __commonJS({
4808
4808
  var strSymbols = stringToArray(string), start = charsStartIndex(strSymbols, stringToArray(chars));
4809
4809
  return castSlice(strSymbols, start).join("");
4810
4810
  }
4811
- function truncate(string, options) {
4811
+ function truncate(string, options2) {
4812
4812
  var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
4813
- if (isObject(options)) {
4814
- var separator = "separator" in options ? options.separator : separator;
4815
- length = "length" in options ? toInteger(options.length) : length;
4816
- omission = "omission" in options ? baseToString(options.omission) : omission;
4813
+ if (isObject(options2)) {
4814
+ var separator = "separator" in options2 ? options2.separator : separator;
4815
+ length = "length" in options2 ? toInteger(options2.length) : length;
4816
+ omission = "omission" in options2 ? baseToString(options2.omission) : omission;
4817
4817
  }
4818
4818
  string = toString(string);
4819
4819
  var strLength = string.length;
@@ -4938,15 +4938,15 @@ var require_lodash = __commonJS({
4938
4938
  return baseInvoke(object, path, args);
4939
4939
  };
4940
4940
  });
4941
- function mixin(object, source, options) {
4941
+ function mixin(object, source, options2) {
4942
4942
  var props = keys(source), methodNames = baseFunctions(source, props);
4943
- if (options == null && !(isObject(source) && (methodNames.length || !props.length))) {
4944
- options = source;
4943
+ if (options2 == null && !(isObject(source) && (methodNames.length || !props.length))) {
4944
+ options2 = source;
4945
4945
  source = object;
4946
4946
  object = this;
4947
4947
  methodNames = baseFunctions(source, keys(source));
4948
4948
  }
4949
- var chain2 = !(isObject(options) && "chain" in options) || !!options.chain, isFunc = isFunction(object);
4949
+ var chain2 = !(isObject(options2) && "chain" in options2) || !!options2.chain, isFunc = isFunction(object);
4950
4950
  arrayEach(methodNames, function(methodName) {
4951
4951
  var func = source[methodName];
4952
4952
  object[methodName] = func;
@@ -5142,7 +5142,7 @@ var require_lodash = __commonJS({
5142
5142
  lodash.method = method;
5143
5143
  lodash.methodOf = methodOf;
5144
5144
  lodash.mixin = mixin;
5145
- lodash.negate = negate;
5145
+ lodash.negate = negate2;
5146
5146
  lodash.nthArg = nthArg;
5147
5147
  lodash.omit = omit;
5148
5148
  lodash.omitBy = omitBy;
@@ -5278,7 +5278,7 @@ var require_lodash = __commonJS({
5278
5278
  lodash.isElement = isElement;
5279
5279
  lodash.isEmpty = isEmpty;
5280
5280
  lodash.isEqual = isEqual2;
5281
- lodash.isEqualWith = isEqualWith;
5281
+ lodash.isEqualWith = isEqualWith2;
5282
5282
  lodash.isError = isError;
5283
5283
  lodash.isFinite = isFinite;
5284
5284
  lodash.isFunction = isFunction;
@@ -5449,7 +5449,7 @@ var require_lodash = __commonJS({
5449
5449
  });
5450
5450
  });
5451
5451
  LazyWrapper.prototype.reject = function(predicate) {
5452
- return this.filter(negate(getIteratee(predicate)));
5452
+ return this.filter(negate2(getIteratee(predicate)));
5453
5453
  };
5454
5454
  LazyWrapper.prototype.slice = function(start, end) {
5455
5455
  start = toInteger(start);
@@ -5603,7 +5603,7 @@ var import_react12 = require("react");
5603
5603
  var import_react10 = require("react");
5604
5604
 
5605
5605
  // package.json
5606
- var version = "0.1.106";
5606
+ var version = "0.1.107-alpha";
5607
5607
 
5608
5608
  // src/models/APIError.ts
5609
5609
  var APIError = class _APIError extends Error {
@@ -5649,21 +5649,21 @@ var CUSTOM_PREFIX = "Layer-";
5649
5649
  var CUSTOM_HEADERS = {
5650
5650
  [`${CUSTOM_PREFIX}React-Version`]: version
5651
5651
  };
5652
- var get = (url) => (baseUrl, accessToken, options) => () => fetch(`${baseUrl}${url((options == null ? void 0 : options.params) || {})}`, {
5652
+ var get = (url) => (baseUrl, accessToken, options2) => () => fetch(`${baseUrl}${url((options2 == null ? void 0 : options2.params) || {})}`, {
5653
5653
  headers: __spreadValues({
5654
5654
  "Authorization": "Bearer " + (accessToken || ""),
5655
5655
  "Content-Type": "application/json"
5656
5656
  }, CUSTOM_HEADERS),
5657
5657
  method: "GET"
5658
5658
  }).then((res) => handleResponse(res)).catch((error) => handleException(error));
5659
- var request = (verb) => (url) => (baseUrl, accessToken, options) => fetch(`${baseUrl}${url((options == null ? void 0 : options.params) || {})}`, {
5659
+ var request = (verb) => (url) => (baseUrl, accessToken, options2) => fetch(`${baseUrl}${url((options2 == null ? void 0 : options2.params) || {})}`, {
5660
5660
  headers: __spreadValues({
5661
5661
  "Authorization": "Bearer " + (accessToken || ""),
5662
5662
  "Content-Type": "application/json",
5663
5663
  "Cache-Control": "no-cache"
5664
5664
  }, CUSTOM_HEADERS),
5665
5665
  method: verb.toUpperCase(),
5666
- body: JSON.stringify(options == null ? void 0 : options.body)
5666
+ body: JSON.stringify(options2 == null ? void 0 : options2.body)
5667
5667
  }).then((res) => handleResponse(res)).catch((error) => handleException(error));
5668
5668
  var patch = request("patch");
5669
5669
  var post = request("post");
@@ -5970,6 +5970,7 @@ var breakPlaidItemConnection = post(
5970
5970
 
5971
5971
  // src/utils/time/timeUtils.ts
5972
5972
  var import_date_fns2 = require("date-fns");
5973
+ var import_date = require("@internationalized/date");
5973
5974
  var toLocalDateString = (date) => (0, import_date_fns2.formatISO)(date.valueOf(), { representation: "date" });
5974
5975
  function getDueDifference(dueDate) {
5975
5976
  const today = /* @__PURE__ */ new Date();
@@ -5978,6 +5979,9 @@ function getDueDifference(dueDate) {
5978
5979
  normalizedDue.setHours(0, 0, 0, 0);
5979
5980
  return (0, import_date_fns2.differenceInDays)(normalizedDue, today);
5980
5981
  }
5982
+ function isZonedDateTime(val) {
5983
+ return val instanceof import_date.ZonedDateTime;
5984
+ }
5981
5985
 
5982
5986
  // src/api/layer/profit_and_loss.ts
5983
5987
  var getProfitAndLoss = (apiUrl, accessToken, params) => {
@@ -7144,12 +7148,12 @@ var RANGE_MODE_LOOKUP = {
7144
7148
  }
7145
7149
  };
7146
7150
  function withCorrectedRange(fn) {
7147
- return (options) => {
7148
- const { start, end } = options;
7151
+ return (options2) => {
7152
+ const { start, end } = options2;
7149
7153
  if (start > end) {
7150
- return fn(__spreadProps(__spreadValues({}, options), { start: end, end: start }));
7154
+ return fn(__spreadProps(__spreadValues({}, options2), { start: end, end: start }));
7151
7155
  }
7152
- return fn(__spreadProps(__spreadValues({}, options), { start, end }));
7156
+ return fn(__spreadProps(__spreadValues({}, options2), { start, end }));
7153
7157
  };
7154
7158
  }
7155
7159
  function buildStore() {
@@ -7382,7 +7386,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
7382
7386
  connection_external_id: "11111",
7383
7387
  connection_needs_repair_as_of: null,
7384
7388
  is_syncing: true,
7385
- user_created: false
7389
+ user_created: false,
7390
+ reconnect_with_new_credentials: false
7386
7391
  },
7387
7392
  {
7388
7393
  id: "f98ec50a-c370-484d-a35b-d00207436075",
@@ -7407,7 +7412,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
7407
7412
  connection_external_id: "11111",
7408
7413
  connection_needs_repair_as_of: null,
7409
7414
  is_syncing: false,
7410
- user_created: false
7415
+ user_created: false,
7416
+ reconnect_with_new_credentials: false
7411
7417
  },
7412
7418
  {
7413
7419
  id: "843f1748-fdaa-422d-a73d-2489a40c8dc7",
@@ -7432,7 +7438,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
7432
7438
  connection_external_id: "11111",
7433
7439
  connection_needs_repair_as_of: "2024-03-06T16:44:35.715458Z",
7434
7440
  is_syncing: false,
7435
- user_created: false
7441
+ user_created: false,
7442
+ reconnect_with_new_credentials: false
7436
7443
  },
7437
7444
  {
7438
7445
  id: "8f430e29-e339-4d71-a08a-fce469c7a7c1",
@@ -7457,7 +7464,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
7457
7464
  connection_external_id: "11111",
7458
7465
  connection_needs_repair_as_of: null,
7459
7466
  is_syncing: false,
7460
- user_created: false
7467
+ user_created: false,
7468
+ reconnect_with_new_credentials: false
7461
7469
  }
7462
7470
  ];
7463
7471
 
@@ -9221,10 +9229,10 @@ var import_jsx_runtime21 = require("react/jsx-runtime");
9221
9229
  var Tooltip = (_a) => {
9222
9230
  var _b = _a, {
9223
9231
  children
9224
- } = _b, options = __objRest(_b, [
9232
+ } = _b, options2 = __objRest(_b, [
9225
9233
  "children"
9226
9234
  ]);
9227
- const tooltip = useTooltip(options);
9235
+ const tooltip = useTooltip(options2);
9228
9236
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TooltipContext.Provider, { value: tooltip, children });
9229
9237
  };
9230
9238
  var TooltipTrigger = (0, import_react25.forwardRef)(function TooltipTrigger2(_a, propRef) {
@@ -10413,6 +10421,7 @@ var DataState = ({
10413
10421
  icon,
10414
10422
  spacing,
10415
10423
  inline,
10424
+ titleSize = inline ? "sm" /* sm */ : "lg" /* lg */,
10416
10425
  className
10417
10426
  }) => {
10418
10427
  const baseClassName = (0, import_classnames18.default)(
@@ -10430,7 +10439,7 @@ var DataState = ({
10430
10439
  Text,
10431
10440
  {
10432
10441
  as: "span",
10433
- size: inline ? "sm" /* sm */ : "lg" /* lg */,
10442
+ size: titleSize,
10434
10443
  weight: "bold" /* bold */,
10435
10444
  className: "Layer__data-state__title",
10436
10445
  children: title
@@ -11809,6 +11818,7 @@ var LinkedAccountItemThumb = ({
11809
11818
  }) => {
11810
11819
  var _a;
11811
11820
  const {
11821
+ addConnection,
11812
11822
  removeConnection,
11813
11823
  repairConnection,
11814
11824
  confirmAccount: confirmAccount2,
@@ -11845,10 +11855,16 @@ var LinkedAccountItemThumb = ({
11845
11855
  name: "Repair connection",
11846
11856
  action: () => {
11847
11857
  if (account.connection_external_id) {
11848
- void repairConnection(
11849
- account.external_account_source,
11850
- account.connection_external_id
11851
- );
11858
+ if (account.reconnect_with_new_credentials) {
11859
+ addConnection(
11860
+ account.external_account_source
11861
+ );
11862
+ } else {
11863
+ repairConnection(
11864
+ account.external_account_source,
11865
+ account.connection_external_id
11866
+ );
11867
+ }
11852
11868
  }
11853
11869
  }
11854
11870
  }
@@ -12580,7 +12596,7 @@ var import_classnames28 = __toESM(require("classnames"));
12580
12596
  var import_jsx_runtime84 = require("react/jsx-runtime");
12581
12597
  var Select = ({
12582
12598
  name,
12583
- options,
12599
+ options: options2,
12584
12600
  className,
12585
12601
  classNamePrefix = "Layer__select",
12586
12602
  value,
@@ -12608,7 +12624,7 @@ var Select = ({
12608
12624
  className: baseClassName,
12609
12625
  classNamePrefix,
12610
12626
  placeholder: placeholder != null ? placeholder : "Select...",
12611
- options,
12627
+ options: options2,
12612
12628
  formatOptionLabel: formatOptionLabel2,
12613
12629
  value,
12614
12630
  onChange: (newValue) => newValue && onChange(newValue),
@@ -12634,7 +12650,7 @@ var import_classnames30 = __toESM(require("classnames"));
12634
12650
  var import_jsx_runtime86 = require("react/jsx-runtime");
12635
12651
  var MultiSelect = ({
12636
12652
  name,
12637
- options,
12653
+ options: options2,
12638
12654
  className,
12639
12655
  classNamePrefix = "Layer__select",
12640
12656
  value,
@@ -12663,7 +12679,7 @@ var MultiSelect = ({
12663
12679
  className: baseClassName,
12664
12680
  classNamePrefix,
12665
12681
  placeholder: placeholder != null ? placeholder : "Select...",
12666
- options,
12682
+ options: options2,
12667
12683
  value,
12668
12684
  defaultValue: defaultValue2,
12669
12685
  onChange: (newValue) => newValue && onChange(newValue),
@@ -13386,7 +13402,7 @@ function useBulkSetOpeningBalanceAndDate(data, { onSuccess }) {
13386
13402
  // src/utils/format.ts
13387
13403
  var import_date_fns10 = require("date-fns");
13388
13404
  var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
13389
- var formatPercent = (value, options) => {
13405
+ var formatPercent = (value, options2) => {
13390
13406
  if (!value && value !== 0) {
13391
13407
  return;
13392
13408
  }
@@ -13413,7 +13429,7 @@ var formatPercent = (value, options) => {
13413
13429
  maximumFractionDigits: 0
13414
13430
  };
13415
13431
  }
13416
- return val.toLocaleString("en-US", __spreadValues(__spreadValues({}, defaultOptions), options));
13432
+ return val.toLocaleString("en-US", __spreadValues(__spreadValues({}, defaultOptions), options2));
13417
13433
  };
13418
13434
  var humanizeEnum = (text) => {
13419
13435
  return capitalizeFirstLetter(text.replace(/_/gi, " ").toLowerCase());
@@ -14128,12 +14144,12 @@ var import_react59 = require("react");
14128
14144
  var import_classnames33 = __toESM(require("classnames"));
14129
14145
  var import_jsx_runtime100 = require("react/jsx-runtime");
14130
14146
  var ActionableList = ({
14131
- options,
14147
+ options: options2,
14132
14148
  onClick,
14133
14149
  selectedId,
14134
14150
  showDescriptions = false
14135
14151
  }) => {
14136
- return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("ul", { className: "Layer__actionable-list", children: options.map((x, idx) => /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(
14152
+ return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("ul", { className: "Layer__actionable-list", children: options2.map((x, idx) => /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(
14137
14153
  "li",
14138
14154
  {
14139
14155
  role: "button",
@@ -14565,7 +14581,7 @@ var CategorySelect = ({
14565
14581
  }
14566
14582
  ] : [];
14567
14583
  const categoryOptions = flattenCategories2(categories != null ? categories : []);
14568
- const options = [
14584
+ const options2 = [
14569
14585
  ...matchOptions,
14570
14586
  ...suggestedOptions,
14571
14587
  ...allCategoriesDivider,
@@ -14592,7 +14608,7 @@ var CategorySelect = ({
14592
14608
  classNames: {
14593
14609
  menu: () => "Layer__select__menu--lg"
14594
14610
  },
14595
- options,
14611
+ options: options2,
14596
14612
  isSearchable: true,
14597
14613
  placeholder,
14598
14614
  defaultValue: selected,
@@ -15461,7 +15477,7 @@ var import_jsx_runtime114 = require("react/jsx-runtime");
15461
15477
  var import_react66 = require("react");
15462
15478
  var Toggle = ({
15463
15479
  name,
15464
- options,
15480
+ options: options2,
15465
15481
  selected,
15466
15482
  onChange,
15467
15483
  size = "medium" /* medium */
@@ -15470,8 +15486,8 @@ var Toggle = ({
15470
15486
  const [thumbPos, setThumbPos] = (0, import_react65.useState)({ left: 0, width: 0 });
15471
15487
  const [initialized, setInitialized] = (0, import_react65.useState)(false);
15472
15488
  const activeOption = (0, import_react65.useMemo)(() => {
15473
- return selected ? selected : options.length > 0 ? options[0].value : void 0;
15474
- }, [selected, options]);
15489
+ return selected ? selected : options2.length > 0 ? options2[0].value : void 0;
15490
+ }, [selected, options2]);
15475
15491
  const toggleRef = useElementSize((_a, _b, c) => {
15476
15492
  if (c.width && (c == null ? void 0 : c.width) !== currentWidth) {
15477
15493
  setCurrentWidth(c.width);
@@ -15521,7 +15537,7 @@ var Toggle = ({
15521
15537
  updateThumbPosition(selectedIndex);
15522
15538
  }, [currentWidth]);
15523
15539
  const getSelectedIndex = () => {
15524
- const selectedIndex = options.findIndex(
15540
+ const selectedIndex = options2.findIndex(
15525
15541
  (option) => option.value === activeOption
15526
15542
  );
15527
15543
  if (selectedIndex === -1) {
@@ -15530,7 +15546,7 @@ var Toggle = ({
15530
15546
  return selectedIndex;
15531
15547
  };
15532
15548
  return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)("div", { className: baseClassName, ref: toggleRef, children: [
15533
- options.map((option, index) => {
15549
+ options2.map((option, index) => {
15534
15550
  var _a;
15535
15551
  return /* @__PURE__ */ (0, import_react66.createElement)(
15536
15552
  ToggleOption,
@@ -16475,7 +16491,7 @@ function ComboBox(_a) {
16475
16491
  className,
16476
16492
  selectedValue,
16477
16493
  onSelectedValueChange,
16478
- options,
16494
+ options: options2,
16479
16495
  groups,
16480
16496
  onInputValueChange,
16481
16497
  placeholder,
@@ -16487,6 +16503,7 @@ function ComboBox(_a) {
16487
16503
  isMutating,
16488
16504
  isSearchable = true,
16489
16505
  isClearable = true,
16506
+ isReadOnly = false,
16490
16507
  displayDisabledAsSelected
16491
16508
  } = _b, ariaProps = __objRest(_b, [
16492
16509
  "className",
@@ -16504,6 +16521,7 @@ function ComboBox(_a) {
16504
16521
  "isMutating",
16505
16522
  "isSearchable",
16506
16523
  "isClearable",
16524
+ "isReadOnly",
16507
16525
  "displayDisabledAsSelected"
16508
16526
  ]);
16509
16527
  const internalInputId = (0, import_react71.useId)();
@@ -16537,7 +16555,7 @@ function ComboBox(_a) {
16537
16555
  }, ariaProps), {
16538
16556
  value: selectedValue,
16539
16557
  onChange: onSelectedValueChange,
16540
- options: options != null ? options : groups,
16558
+ options: options2 != null ? options2 : groups,
16541
16559
  onInputChange: onInputValueChange,
16542
16560
  escapeClearsValue: true,
16543
16561
  placeholder,
@@ -16549,11 +16567,15 @@ function ComboBox(_a) {
16549
16567
  control: ({ isFocused, isDisabled: isDisabled2 }) => (0, import_classnames41.default)(
16550
16568
  COMBO_BOX_CLASS_NAMES.CONTROL,
16551
16569
  isFocused && `${COMBO_BOX_CLASS_NAMES.CONTROL}--focused`,
16552
- isDisabled2 && `${COMBO_BOX_CLASS_NAMES.CONTROL}--disabled`
16570
+ isDisabled2 && `${COMBO_BOX_CLASS_NAMES.CONTROL}--disabled`,
16571
+ isReadOnly && `${COMBO_BOX_CLASS_NAMES.CONTROL}--readonly`
16553
16572
  ),
16554
16573
  valueContainer: () => COMBO_BOX_CLASS_NAMES.VALUE_CONTAINER,
16555
16574
  placeholder: () => COMBO_BOX_CLASS_NAMES.PLACEHOLDER,
16556
- indicatorsContainer: () => COMBO_BOX_CLASS_NAMES.INDICATORS_CONTAINER,
16575
+ indicatorsContainer: () => (0, import_classnames41.default)(
16576
+ COMBO_BOX_CLASS_NAMES.INDICATORS_CONTAINER,
16577
+ isReadOnly && `${COMBO_BOX_CLASS_NAMES.INDICATORS_CONTAINER}--readonly`
16578
+ ),
16557
16579
  menu: () => COMBO_BOX_CLASS_NAMES.MENU,
16558
16580
  menuList: () => COMBO_BOX_CLASS_NAMES.MENU_LIST,
16559
16581
  group: () => COMBO_BOX_CLASS_NAMES.GROUP
@@ -16568,10 +16590,11 @@ function ComboBox(_a) {
16568
16590
  DropdownIndicator: CustomDropdownIndicatorRef.current,
16569
16591
  SingleValue: CustomSingleValue
16570
16592
  },
16571
- isClearable,
16593
+ isClearable: isClearable && !isReadOnly,
16572
16594
  isDisabled,
16573
16595
  isLoading: isLoading || isMutating,
16574
- isSearchable
16596
+ isSearchable: isSearchable && !isReadOnly,
16597
+ openMenuOnClick: !isReadOnly
16575
16598
  })
16576
16599
  ),
16577
16600
  isError ? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(HStack, { justify: "end", children: ErrorMessage != null ? ErrorMessage : /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
@@ -18093,7 +18116,6 @@ var ExpandedBankTransactionRow = (0, import_react85.forwardRef)(
18093
18116
  TextButton,
18094
18117
  {
18095
18118
  onClick: addSplit,
18096
- disabled: rowState.splits.length > 5,
18097
18119
  children: "Add new split"
18098
18120
  }
18099
18121
  ) : /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
@@ -18102,7 +18124,6 @@ var ExpandedBankTransactionRow = (0, import_react85.forwardRef)(
18102
18124
  onClick: addSplit,
18103
18125
  rightIcon: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(ScissorsFullOpen_default, { size: 14 }),
18104
18126
  variant: "secondary" /* secondary */,
18105
- disabled: rowState.splits.length > 5,
18106
18127
  children: "Split"
18107
18128
  }
18108
18129
  ) }) : /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(import_jsx_runtime128.Fragment, {})
@@ -19094,16 +19115,16 @@ var BusinessForm = ({
19094
19115
  setShowRetry(true);
19095
19116
  }
19096
19117
  }, [bankTransaction.error]);
19097
- const options = (0, import_react89.useMemo)(() => {
19118
+ const options2 = (0, import_react89.useMemo)(() => {
19098
19119
  var _a;
19099
- const options2 = ((_a = bankTransaction == null ? void 0 : bankTransaction.categorization_flow) == null ? void 0 : _a.type) === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? bankTransaction.categorization_flow.suggestions.map(
19120
+ const options3 = ((_a = bankTransaction == null ? void 0 : bankTransaction.categorization_flow) == null ? void 0 : _a.type) === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? bankTransaction.categorization_flow.suggestions.map(
19100
19121
  (x) => mapCategoryToOption(x)
19101
19122
  ) : [];
19102
- if (selectedCategory && !options2.find((x) => x.id === (selectedCategory == null ? void 0 : selectedCategory.id))) {
19103
- options2.unshift(selectedCategory);
19123
+ if (selectedCategory && !options3.find((x) => x.id === (selectedCategory == null ? void 0 : selectedCategory.id))) {
19124
+ options3.unshift(selectedCategory);
19104
19125
  }
19105
- if (options2.length) {
19106
- options2.push({
19126
+ if (options3.length) {
19127
+ options3.push({
19107
19128
  label: "See all categories",
19108
19129
  id: "SELECT_CATEGORY",
19109
19130
  value: {
@@ -19113,7 +19134,7 @@ var BusinessForm = ({
19113
19134
  asLink: true
19114
19135
  });
19115
19136
  }
19116
- return options2;
19137
+ return options3;
19117
19138
  }, [bankTransaction, selectedCategory]);
19118
19139
  const onDrawerCategorySelect = (value) => {
19119
19140
  close2();
@@ -19168,7 +19189,7 @@ var BusinessForm = ({
19168
19189
  showCategorization ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
19169
19190
  ActionableList,
19170
19191
  {
19171
- options,
19192
+ options: options2,
19172
19193
  onClick: onCategorySelect,
19173
19194
  selectedId: selectedCategory == null ? void 0 : selectedCategory.id,
19174
19195
  showDescriptions: showTooltips
@@ -19212,7 +19233,7 @@ var BusinessForm = ({
19212
19233
  icon: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(Paperclip_default, {})
19213
19234
  }
19214
19235
  ),
19215
- options.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
19236
+ options2.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
19216
19237
  Button,
19217
19238
  {
19218
19239
  onClick: openDrawer,
@@ -19221,7 +19242,7 @@ var BusinessForm = ({
19221
19242
  children: "Select category"
19222
19243
  }
19223
19244
  ) : null,
19224
- showCategorization && options.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
19245
+ showCategorization && options2.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
19225
19246
  Button,
19226
19247
  {
19227
19248
  onClick: save,
@@ -19658,7 +19679,7 @@ var SplitForm = ({
19658
19679
  TextButton,
19659
19680
  {
19660
19681
  onClick: addSplit,
19661
- disabled: rowState.splits.length > 5 || isLoading,
19682
+ disabled: isLoading,
19662
19683
  className: "Layer__add-new-split",
19663
19684
  children: "Add new split"
19664
19685
  }
@@ -20584,9 +20605,9 @@ function runDelayedSync(block, delayMs = DEFAULT_DELAY_MS) {
20584
20605
  var import_jsx_runtime159 = require("react/jsx-runtime");
20585
20606
  function useInvisibleDownload() {
20586
20607
  const invisibleDownloadRef = (0, import_react99.useRef)(null);
20587
- const triggerInvisibleDownload = (0, import_react99.useCallback)((options) => {
20608
+ const triggerInvisibleDownload = (0, import_react99.useCallback)((options2) => {
20588
20609
  var _a;
20589
- void ((_a = invisibleDownloadRef.current) == null ? void 0 : _a.trigger(options));
20610
+ void ((_a = invisibleDownloadRef.current) == null ? void 0 : _a.trigger(options2));
20590
20611
  }, []);
20591
20612
  return { invisibleDownloadRef, triggerInvisibleDownload };
20592
20613
  }
@@ -20777,7 +20798,7 @@ var import_classnames53 = __toESM(require("classnames"));
20777
20798
  var import_jsx_runtime162 = require("react/jsx-runtime");
20778
20799
  var CreatableSelect = ({
20779
20800
  name,
20780
- options,
20801
+ options: options2,
20781
20802
  className,
20782
20803
  classNamePrefix = "Layer__select",
20783
20804
  value,
@@ -20810,7 +20831,7 @@ var CreatableSelect = ({
20810
20831
  className: baseClassName,
20811
20832
  classNamePrefix,
20812
20833
  placeholder: placeholder != null ? placeholder : "Select...",
20813
- options,
20834
+ options: options2,
20814
20835
  formatOptionLabel: formatOptionLabel2,
20815
20836
  value,
20816
20837
  onChange: (newValue) => onChange(newValue),
@@ -21552,7 +21573,12 @@ var MAX_NUM_ROWS = 8;
21552
21573
  var HEADER_HEIGHT = 41;
21553
21574
  var CONTAINER_HEIGHT = ROW_HEIGHT * MAX_NUM_ROWS + HEADER_HEIGHT - 1;
21554
21575
  var CSS_PREFIX = "Layer__csv-upload__validate-csv-table";
21555
- function ValidateCsvTable({ data, headers, formatters: formatters2, className }) {
21576
+ function ValidateCsvTable({
21577
+ data,
21578
+ headers,
21579
+ formatters: formatters2,
21580
+ className
21581
+ }) {
21556
21582
  const columns = (0, import_react107.useMemo)(
21557
21583
  () => {
21558
21584
  const columnDefs = [{
@@ -21567,8 +21593,9 @@ function ValidateCsvTable({ data, headers, formatters: formatters2, className })
21567
21593
  header: () => /* @__PURE__ */ (0, import_jsx_runtime169.jsx)("span", { className: `${CSS_PREFIX}__header-cell-content`, children: headers[key] }),
21568
21594
  cell: (info) => {
21569
21595
  const field = info.row.original[key];
21570
- let value = field.raw;
21571
- if (field.is_valid) {
21596
+ let value = field == null ? void 0 : field.raw;
21597
+ const isValid2 = field && field.is_valid;
21598
+ if (isValid2) {
21572
21599
  const formatter2 = formatters2 == null ? void 0 : formatters2[key];
21573
21600
  value = formatter2 ? formatter2(field.parsed) : field.parsed;
21574
21601
  }
@@ -21578,7 +21605,7 @@ function ValidateCsvTable({ data, headers, formatters: formatters2, className })
21578
21605
  className: (0, import_classnames57.default)(
21579
21606
  "Layer__table-cell-content",
21580
21607
  `${CSS_PREFIX}__cell-content`,
21581
- !field.is_valid && `${CSS_PREFIX}__cell-content--error`
21608
+ !isValid2 && `${CSS_PREFIX}__cell-content--error`
21582
21609
  ),
21583
21610
  children: value
21584
21611
  }
@@ -21655,7 +21682,11 @@ function ValidateCsvTable({ data, headers, formatters: formatters2, className })
21655
21682
  ] })
21656
21683
  ] }) });
21657
21684
  }
21658
- var ValidateCsvTableRow = ({ row, virtualRow, rowVirtualizer }) => /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
21685
+ var ValidateCsvTableRow = ({
21686
+ row,
21687
+ virtualRow,
21688
+ rowVirtualizer
21689
+ }) => /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
21659
21690
  "tr",
21660
21691
  {
21661
21692
  className: (0, import_classnames57.default)(
@@ -21694,6 +21725,21 @@ var formatters = {
21694
21725
  return (_a = convertCentsToCurrency(parsed)) != null ? _a : "";
21695
21726
  }
21696
21727
  };
21728
+ var generateDynamicHeaders = (transactionsPreview) => {
21729
+ const hasExternalId = transactionsPreview.some(
21730
+ (transaction) => {
21731
+ var _a;
21732
+ return ((_a = transaction.external_id) == null ? void 0 : _a.parsed) != null;
21733
+ }
21734
+ );
21735
+ const hasReferenceNumber = transactionsPreview.some(
21736
+ (transaction) => {
21737
+ var _a;
21738
+ return ((_a = transaction.reference_number) == null ? void 0 : _a.parsed) != null;
21739
+ }
21740
+ );
21741
+ return __spreadValues(__spreadValues(__spreadValues({}, hasExternalId && { external_id: "External ID" }), hasReferenceNumber && { reference_number: "Reference No." }), templateHeaders);
21742
+ };
21697
21743
  function UploadTransactionsValidateCsvStep({ parseCsvResponse, selectedAccountId, onSelectFile, onUploadTransactionsSuccess }) {
21698
21744
  const { previous, next } = useWizard();
21699
21745
  const { trigger: uploadTransactions, isMutating, error: uploadTransactionsError } = useCreateCustomAccountTransactions();
@@ -21708,6 +21754,7 @@ function UploadTransactionsValidateCsvStep({ parseCsvResponse, selectedAccountId
21708
21754
  invalid_transactions_count: invalidTransactionsCount,
21709
21755
  total_transactions_count: totalTransactionsCount
21710
21756
  } = parseCsvResponse;
21757
+ const dynamicHeaders = generateDynamicHeaders(transactionsPreview);
21711
21758
  const onClickUploadTransactions = (0, import_react108.useCallback)(() => {
21712
21759
  void uploadTransactions(__spreadProps(__spreadValues({}, transactionsRequest), {
21713
21760
  customAccountId: selectedAccountId
@@ -21729,7 +21776,7 @@ function UploadTransactionsValidateCsvStep({ parseCsvResponse, selectedAccountId
21729
21776
  {
21730
21777
  className: "Layer__upload-transactions__preview_table",
21731
21778
  data: transactionsPreview,
21732
- headers: templateHeaders,
21779
+ headers: dynamicHeaders,
21733
21780
  formatters
21734
21781
  }
21735
21782
  )
@@ -23577,15 +23624,15 @@ function useProfitAndLossComparison({
23577
23624
  const effectiveComparePeriods = isPeriodsSelectEnabled ? comparePeriods : 1;
23578
23625
  const compareModeActive = (0, import_react129.useMemo)(() => effectiveComparePeriods > 1 || selectedCompareOptions.length > 1 || selectedCompareOptions.length === 1 && isNotOnlyNoneTag(selectedCompareOptions), [effectiveComparePeriods, selectedCompareOptions]);
23579
23626
  const setSelectedCompareOptions = (values) => {
23580
- const options = values.map(
23627
+ const options2 = values.map(
23581
23628
  (option) => comparisonConfig == null ? void 0 : comparisonConfig.tagComparisonOptions.find(
23582
23629
  (t) => JSON.stringify(t.tagFilterConfig) === option.value
23583
23630
  )
23584
23631
  ).filter(Boolean);
23585
- if (options.length === 0 && (comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter)) {
23632
+ if (options2.length === 0 && (comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter)) {
23586
23633
  setSelectedCompareOptionsState([comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter]);
23587
23634
  } else {
23588
- setSelectedCompareOptionsState(options);
23635
+ setSelectedCompareOptionsState(options2);
23589
23636
  }
23590
23637
  };
23591
23638
  const { businessId } = useLayerContext();
@@ -26633,7 +26680,7 @@ var ProfitAndLossTableComponent = ({
26633
26680
  } = (0, import_react150.useContext)(ProfitAndLoss.Context);
26634
26681
  const { isOpen, setIsOpen } = useTableExpandRow();
26635
26682
  (0, import_react150.useEffect)(() => {
26636
- setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
26683
+ setIsOpen(["income", "cost_of_goods_sold", "expenses", "other_activity"]);
26637
26684
  }, []);
26638
26685
  const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
26639
26686
  if (isLoading || actualData === void 0) {
@@ -26653,7 +26700,8 @@ var ProfitAndLossTableComponent = ({
26653
26700
  depth,
26654
26701
  rowKey,
26655
26702
  rowIndex,
26656
- variant
26703
+ variant,
26704
+ showValue = true
26657
26705
  }) => {
26658
26706
  const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
26659
26707
  const expanded = expandable ? isOpen(rowKey) : true;
@@ -26676,7 +26724,7 @@ var ProfitAndLossTableComponent = ({
26676
26724
  children: lineItem.display_name
26677
26725
  }
26678
26726
  ),
26679
- /* @__PURE__ */ (0, import_jsx_runtime228.jsx)(TableCell, { isCurrency: true, primary: true, align: "right" /* RIGHT */, children: Number.isNaN(lineItem.value) ? 0 : lineItem.value })
26727
+ showValue && /* @__PURE__ */ (0, import_jsx_runtime228.jsx)(TableCell, { isCurrency: true, primary: true, align: "right" /* RIGHT */, children: Number.isNaN(lineItem.value) ? 0 : lineItem.value })
26680
26728
  ]
26681
26729
  }
26682
26730
  ),
@@ -26697,12 +26745,12 @@ var ProfitAndLossTableComponent = ({
26697
26745
  rowKey: "income",
26698
26746
  rowIndex: 0
26699
26747
  }),
26700
- data.cost_of_goods_sold ? renderLineItem({
26748
+ data.cost_of_goods_sold && renderLineItem({
26701
26749
  lineItem: data.cost_of_goods_sold,
26702
26750
  depth: 0,
26703
26751
  rowKey: "cost_of_goods_sold",
26704
26752
  rowIndex: 1
26705
- }) : null,
26753
+ }),
26706
26754
  renderLineItem({
26707
26755
  lineItem: {
26708
26756
  value: data.gross_profit,
@@ -26742,21 +26790,28 @@ var ProfitAndLossTableComponent = ({
26742
26790
  },
26743
26791
  depth: 0,
26744
26792
  rowKey: "net_profit",
26745
- rowIndex: 5,
26793
+ rowIndex: 6,
26746
26794
  variant: "summation"
26747
26795
  }),
26748
- data.personal_expenses ? renderLineItem({
26796
+ data.personal_expenses && renderLineItem({
26749
26797
  lineItem: data.personal_expenses,
26750
26798
  depth: 0,
26751
26799
  rowKey: "personal_expenses",
26752
26800
  rowIndex: 7
26753
- }) : null,
26754
- data.other_outflows ? renderLineItem({
26801
+ }),
26802
+ data.other_outflows && renderLineItem({
26755
26803
  lineItem: data.other_outflows,
26756
26804
  depth: 0,
26757
26805
  rowKey: "other_outflows",
26758
- rowIndex: 6
26759
- }) : null
26806
+ rowIndex: 8
26807
+ }),
26808
+ data.custom_line_items && renderLineItem({
26809
+ lineItem: data.custom_line_items,
26810
+ depth: 0,
26811
+ rowKey: "other_activity",
26812
+ rowIndex: 9,
26813
+ showValue: false
26814
+ })
26760
26815
  ] }) });
26761
26816
  };
26762
26817
 
@@ -30719,7 +30774,7 @@ var JournalEntryDetails = () => {
30719
30774
  ]
30720
30775
  }
30721
30776
  ) }),
30722
- /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("div", { className: "Layer__journal__entry-details__reverse-btn-container", children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
30777
+ (entry == null ? void 0 : entry.entry_type) === "MANUAL" && /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("div", { className: "Layer__journal__entry-details__reverse-btn-container", children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
30723
30778
  Button,
30724
30779
  {
30725
30780
  rightIcon: reverseEntryError ? /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(AlertCircle_default, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(RefreshCcw_default, { size: 12 }),
@@ -32713,11 +32768,11 @@ var import_classnames81 = __toESM(require("classnames"));
32713
32768
  var import_jsx_runtime278 = require("react/jsx-runtime");
32714
32769
  var import_react192 = require("react");
32715
32770
  var STARTING_PADDING = 12;
32716
- var Tabs = ({ name, options, selected, onChange }) => {
32771
+ var Tabs = ({ name, options: options2, selected, onChange }) => {
32717
32772
  const [initialized, setInitialized] = (0, import_react191.useState)(false);
32718
32773
  const [thumbPos, setThumbPos] = (0, import_react191.useState)({ left: 0, width: 0 });
32719
32774
  const [currentWidth, setCurrentWidth] = (0, import_react191.useState)(0);
32720
- const selectedValue = selected || options[0].value;
32775
+ const selectedValue = selected || options2[0].value;
32721
32776
  const baseClassName = (0, import_classnames81.default)(
32722
32777
  "Layer__tabs",
32723
32778
  initialized && "Layer__tabs--initialized"
@@ -32763,7 +32818,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
32763
32818
  updateSelectPosition(selectedIndex);
32764
32819
  }, [selectedValue, currentWidth]);
32765
32820
  const getSelectedIndex = () => {
32766
- const selectedIndex = options.findIndex(
32821
+ const selectedIndex = options2.findIndex(
32767
32822
  (option) => option.value === selectedValue
32768
32823
  );
32769
32824
  if (selectedIndex === -1) {
@@ -32772,7 +32827,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
32772
32827
  return selectedIndex;
32773
32828
  };
32774
32829
  return /* @__PURE__ */ (0, import_jsx_runtime278.jsx)("div", { className: "Layer__tabs__container", children: /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)("div", { className: baseClassName, ref: elementRef, children: [
32775
- options.map((option, index) => {
32830
+ options2.map((option, index) => {
32776
32831
  var _a;
32777
32832
  return /* @__PURE__ */ (0, import_react192.createElement)(
32778
32833
  Tab,
@@ -33804,11 +33859,11 @@ var FormSection = ({ children, title }) => {
33804
33859
 
33805
33860
  // src/components/Input/BusinessTypeSelect.tsx
33806
33861
  var import_jsx_runtime292 = require("react/jsx-runtime");
33807
- var findSelectOption = (options, value) => {
33862
+ var findSelectOption = (options2, value) => {
33808
33863
  if (!value) {
33809
33864
  return void 0;
33810
33865
  }
33811
- return options.find((o) => o.value === value);
33866
+ return options2.find((o) => o.value === value);
33812
33867
  };
33813
33868
  var BusinessTypeSelect = ({ value, onChange }) => {
33814
33869
  const entityTypeOptions = ENTITY_TYPES;
@@ -33880,11 +33935,11 @@ var US_STATES = [
33880
33935
 
33881
33936
  // src/components/Input/USStateSelect.tsx
33882
33937
  var import_jsx_runtime293 = require("react/jsx-runtime");
33883
- var findSelectOption2 = (options, selected) => {
33938
+ var findSelectOption2 = (options2, selected) => {
33884
33939
  if (!selected) {
33885
33940
  return void 0;
33886
33941
  }
33887
- return options.find(
33942
+ return options2.find(
33888
33943
  (o) => String(o.value).toLowerCase() === String(selected).toLowerCase() || String(o.label).toLowerCase() === String(selected).toLowerCase()
33889
33944
  );
33890
33945
  };
@@ -37010,8 +37065,8 @@ var Reports = ({
37010
37065
  var _a;
37011
37066
  const [activeTab, setActiveTab] = (0, import_react218.useState)(enabledReports[0]);
37012
37067
  const { view, containerRef } = useElementViewSize();
37013
- const options = getOptions(enabledReports);
37014
- const defaultTitle4 = enabledReports.length > 1 ? "Reports" : (_a = options.find((option) => option.value === enabledReports[0])) == null ? void 0 : _a.label;
37068
+ const options2 = getOptions(enabledReports);
37069
+ const defaultTitle4 = enabledReports.length > 1 ? "Reports" : (_a = options2.find((option) => option.value === enabledReports[0])) == null ? void 0 : _a.label;
37015
37070
  const initialModeForProfitAndLoss = profitAndLossConfig ? getInitialDateRangePickerMode(profitAndLossConfig) : "monthPicker";
37016
37071
  const initialModeForStatementOfCashFlows = statementOfCashFlowConfig ? getInitialDateRangePickerMode(statementOfCashFlowConfig) : "monthPicker";
37017
37072
  const initialModes = {
@@ -37029,7 +37084,7 @@ var Reports = ({
37029
37084
  Toggle,
37030
37085
  {
37031
37086
  name: "reports-tabs",
37032
- options,
37087
+ options: options2,
37033
37088
  selected: activeTab,
37034
37089
  onChange: (opt) => setActiveTab(opt.target.value)
37035
37090
  }
@@ -37171,10 +37226,10 @@ var Components = ({
37171
37226
  };
37172
37227
 
37173
37228
  // src/components/Invoices/Invoices.tsx
37174
- var import_react238 = require("react");
37229
+ var import_react240 = require("react");
37175
37230
 
37176
37231
  // src/components/Invoices/InvoiceDetail/InvoiceDetail.tsx
37177
- var import_react232 = require("react");
37232
+ var import_react234 = require("react");
37178
37233
 
37179
37234
  // src/components/BaseDetailView/BaseDetailView.tsx
37180
37235
  var import_jsx_runtime327 = require("react/jsx-runtime");
@@ -37189,8 +37244,12 @@ var BaseDetailView = ({ name, onGoBack, slots, children }) => {
37189
37244
  ] });
37190
37245
  };
37191
37246
 
37247
+ // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
37248
+ var import_react233 = require("react");
37249
+ var import_classnames92 = __toESM(require("classnames"));
37250
+
37192
37251
  // src/components/Invoices/InvoiceForm/useInvoiceForm.ts
37193
- var import_react230 = require("react");
37252
+ var import_react231 = require("react");
37194
37253
  var import_react_form7 = require("@tanstack/react-form");
37195
37254
 
37196
37255
  // src/features/forms/hooks/useForm.tsx
@@ -37227,11 +37286,12 @@ var FieldError = (0, import_react220.forwardRef)(
37227
37286
  var import_jsx_runtime329 = require("react/jsx-runtime");
37228
37287
  function BaseFormTextField({
37229
37288
  label,
37230
- className,
37231
37289
  inline = false,
37232
37290
  showLabel = true,
37233
37291
  showFieldError = true,
37234
37292
  isTextArea = false,
37293
+ isReadOnly = false,
37294
+ className,
37235
37295
  children
37236
37296
  }) {
37237
37297
  const field = useFieldContext();
@@ -37241,11 +37301,32 @@ function BaseFormTextField({
37241
37301
  const errorMessage = errors.length !== 0 ? errors[0] : void 0;
37242
37302
  const shouldShowErrorMessage = showFieldError && errorMessage;
37243
37303
  const additionalAriaProps = !showLabel && { "aria-label": label };
37244
- return /* @__PURE__ */ (0, import_jsx_runtime329.jsxs)(TextField, __spreadProps(__spreadValues({ name, isInvalid: !isValid2, inline, className, textarea: isTextArea }, additionalAriaProps), { children: [
37245
- showLabel && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(Label, __spreadProps(__spreadValues({ size: "sm", htmlFor: name }, !inline && { pbe: "3xs" }), { children: label })),
37246
- children,
37247
- shouldShowErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(FieldError, { children: errorMessage })
37248
- ] }));
37304
+ return /* @__PURE__ */ (0, import_jsx_runtime329.jsxs)(
37305
+ TextField,
37306
+ __spreadProps(__spreadValues({
37307
+ name,
37308
+ isInvalid: !isValid2,
37309
+ inline,
37310
+ className,
37311
+ textarea: isTextArea,
37312
+ isReadOnly
37313
+ }, additionalAriaProps), {
37314
+ children: [
37315
+ showLabel && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(
37316
+ Label,
37317
+ __spreadProps(__spreadValues({
37318
+ slot: "label",
37319
+ size: "sm",
37320
+ htmlFor: name
37321
+ }, !inline && { pbe: "3xs" }), {
37322
+ children: label
37323
+ })
37324
+ ),
37325
+ children,
37326
+ shouldShowErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(FieldError, { children: errorMessage })
37327
+ ]
37328
+ })
37329
+ );
37249
37330
  }
37250
37331
 
37251
37332
  // src/features/forms/components/FormBigDecimalField.tsx
@@ -37296,9 +37377,19 @@ var Input2 = (0, import_react222.forwardRef)(
37296
37377
  var import_effect9 = require("effect");
37297
37378
  var BIG_DECIMAL_ZERO = import_effect9.BigDecimal.fromBigInt(BigInt(0));
37298
37379
  var BIG_DECIMAL_ONE = import_effect9.BigDecimal.fromBigInt(BigInt(1));
37380
+ var BIG_DECIMAL_NEG_ONE = import_effect9.BigDecimal.fromBigInt(BigInt(-1));
37299
37381
  var BIG_DECIMAL_ONE_HUNDRED = import_effect9.BigDecimal.fromBigInt(BigInt(100));
37300
- var DECIMAL_CHARS_REGEX = /^[\d.,-]+$/;
37301
- var NON_NEGATIVE_DECIMAL_CHARS_REGEX = /^[\d.,]+$/;
37382
+ var buildDecimalCharRegex = ({
37383
+ allowNegative = true,
37384
+ allowPercent = false,
37385
+ allowDollar = false
37386
+ } = {}) => {
37387
+ let allowed = "\\d.,";
37388
+ if (allowNegative) allowed += "\\-";
37389
+ if (allowPercent) allowed += "%";
37390
+ if (allowDollar) allowed += "\\$";
37391
+ return new RegExp(`^[${allowed}]+$`);
37392
+ };
37302
37393
  var convertBigDecimalToCents = (amount) => {
37303
37394
  const scaled = import_effect9.BigDecimal.multiply(amount, BIG_DECIMAL_ONE_HUNDRED);
37304
37395
  const rounded = import_effect9.BigDecimal.round(scaled, { scale: 0 });
@@ -37308,14 +37399,38 @@ var convertCentsToBigDecimal = (cents) => {
37308
37399
  const decimalCents = import_effect9.BigDecimal.fromBigInt(BigInt(cents));
37309
37400
  return import_effect9.BigDecimal.unsafeDivide(decimalCents, BIG_DECIMAL_ONE_HUNDRED);
37310
37401
  };
37311
- function formatBigDecimalToString(value, maxDecimalPlaces = 10) {
37402
+ var convertPercentToDecimal = (percent) => {
37403
+ return import_effect9.BigDecimal.unsafeDivide(percent, BIG_DECIMAL_ONE_HUNDRED);
37404
+ };
37405
+ var roundDecimalToCents = (decimal) => {
37406
+ return import_effect9.BigDecimal.round(decimal, { scale: 2 });
37407
+ };
37408
+ var safeDivide = (dividend, divisor) => {
37409
+ const maybeQuotient = import_effect9.BigDecimal.divide(dividend, divisor);
37410
+ const quotient = import_effect9.Option.match(maybeQuotient, {
37411
+ onNone: () => BIG_DECIMAL_ZERO,
37412
+ onSome: (innerQuotient) => innerQuotient
37413
+ });
37414
+ return quotient;
37415
+ };
37416
+ var negate = (value) => {
37417
+ return import_effect9.BigDecimal.multiply(value, BIG_DECIMAL_NEG_ONE);
37418
+ };
37419
+ function formatBigDecimalToString(value, options2 = {
37420
+ mode: "decimal",
37421
+ minDecimalPlaces: 0,
37422
+ maxDecimalPlaces: 3
37423
+ }) {
37312
37424
  const normalizedBigDecimal = import_effect9.BigDecimal.normalize(value);
37425
+ const { mode, minDecimalPlaces, maxDecimalPlaces } = options2;
37313
37426
  const formatter2 = new Intl.NumberFormat(
37314
37427
  "en-US",
37315
- {
37316
- minimumFractionDigits: 0,
37428
+ __spreadProps(__spreadValues(__spreadValues({
37429
+ style: "decimal"
37430
+ }, mode === "percent" && { style: "percent" }), mode === "currency" && { style: "currency", currency: "USD" }), {
37431
+ minimumFractionDigits: minDecimalPlaces,
37317
37432
  maximumFractionDigits: maxDecimalPlaces
37318
- }
37433
+ })
37319
37434
  );
37320
37435
  let decimalAsNumber = 0;
37321
37436
  try {
@@ -37327,37 +37442,59 @@ function formatBigDecimalToString(value, maxDecimalPlaces = 10) {
37327
37442
 
37328
37443
  // src/features/forms/components/FormBigDecimalField.tsx
37329
37444
  var import_jsx_runtime332 = require("react/jsx-runtime");
37330
- var DEFAULT_MAX_INPUT_LENGTH = 10;
37445
+ var DEFAULT_MAX_VALUE = 1e7;
37446
+ var DEFAULT_MIN_DECIMAL_PLACES = 0;
37447
+ var DEFAULT_MAX_DECIMAL_PLACES = 3;
37448
+ var DECORATOR_CHARS_REGEX = /[,%$]/g;
37449
+ var withForceUpdate = (value) => __spreadProps(__spreadValues({}, value), {
37450
+ __forceUpdate: Symbol()
37451
+ });
37331
37452
  function FormBigDecimalField(_a) {
37332
37453
  var _b = _a, {
37333
- maxInputLength = DEFAULT_MAX_INPUT_LENGTH,
37334
- allowNegative = false
37454
+ mode = "decimal",
37455
+ allowNegative = false,
37456
+ maxValue = mode === "percent" ? 1 : DEFAULT_MAX_VALUE,
37457
+ minDecimalPlaces = mode === "currency" ? 2 : DEFAULT_MIN_DECIMAL_PLACES,
37458
+ maxDecimalPlaces = mode === "currency" ? 2 : DEFAULT_MAX_DECIMAL_PLACES
37335
37459
  } = _b, restProps = __objRest(_b, [
37336
- "maxInputLength",
37337
- "allowNegative"
37460
+ "mode",
37461
+ "allowNegative",
37462
+ "maxValue",
37463
+ "minDecimalPlaces",
37464
+ "maxDecimalPlaces"
37338
37465
  ]);
37339
37466
  const field = useFieldContext();
37340
37467
  const { name, state, handleChange, handleBlur } = field;
37341
37468
  const { value } = state;
37342
- const [inputValue, setInputValue] = (0, import_react223.useState)(formatBigDecimalToString(value, maxInputLength));
37469
+ const maxBigDecimalValue = import_effect10.BigDecimal.unsafeFromNumber(maxValue);
37470
+ const formattingProps = (0, import_react223.useMemo)(() => ({
37471
+ minDecimalPlaces,
37472
+ maxDecimalPlaces,
37473
+ mode
37474
+ }), [maxDecimalPlaces, minDecimalPlaces, mode]);
37475
+ const [inputValue, setInputValue] = (0, import_react223.useState)(formatBigDecimalToString(value, formattingProps));
37343
37476
  const onInputChange = (0, import_react223.useCallback)((e) => {
37344
37477
  setInputValue(e.target.value);
37345
37478
  }, []);
37346
37479
  const onInputBlur = (0, import_react223.useCallback)(() => {
37347
- const cleaned = inputValue.replace(/,/g, "");
37348
- const maybeDecimal = import_effect10.BigDecimal.fromString(cleaned);
37480
+ const sanitizedInput = inputValue.replace(DECORATOR_CHARS_REGEX, "");
37481
+ const maybeDecimal = import_effect10.BigDecimal.fromString(sanitizedInput);
37349
37482
  const decimal = import_effect10.Option.match(maybeDecimal, {
37350
37483
  onNone: () => BIG_DECIMAL_ZERO,
37351
- onSome: (amount) => amount
37484
+ onSome: (value2) => value2
37352
37485
  });
37353
- const normalizedDecimal = import_effect10.BigDecimal.normalize(decimal);
37354
- handleChange(normalizedDecimal);
37486
+ const adjustedForPercent = mode === "percent" ? convertPercentToDecimal(decimal) : decimal;
37487
+ const normalized = import_effect10.BigDecimal.normalize(adjustedForPercent);
37488
+ const clamped = import_effect10.BigDecimal.min(normalized, maxBigDecimalValue);
37489
+ if (!import_effect10.BigDecimal.equals(clamped, value)) {
37490
+ handleChange(withForceUpdate(clamped));
37491
+ }
37355
37492
  handleBlur();
37356
- setInputValue(formatBigDecimalToString(normalizedDecimal, maxInputLength));
37357
- }, [inputValue, handleBlur, handleChange, maxInputLength]);
37493
+ setInputValue(formatBigDecimalToString(clamped, formattingProps));
37494
+ }, [inputValue, mode, maxBigDecimalValue, value, handleBlur, formattingProps, handleChange]);
37358
37495
  const allowedChars = (0, import_react223.useMemo)(
37359
- () => allowNegative ? DECIMAL_CHARS_REGEX : NON_NEGATIVE_DECIMAL_CHARS_REGEX,
37360
- [allowNegative]
37496
+ () => buildDecimalCharRegex({ allowNegative, allowPercent: mode === "percent", allowDollar: mode === "currency" }),
37497
+ [allowNegative, mode]
37361
37498
  );
37362
37499
  const onBeforeInput = (0, import_react223.useCallback)((e) => {
37363
37500
  if (e.data && !allowedChars.test(e.data)) {
@@ -37371,9 +37508,9 @@ function FormBigDecimalField(_a) {
37371
37508
  }
37372
37509
  }, [allowedChars]);
37373
37510
  (0, import_react223.useEffect)(() => {
37374
- setInputValue(formatBigDecimalToString(value, maxInputLength));
37375
- }, [value, maxInputLength]);
37376
- return /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, restProps), { inputMode: "decimal", children: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(InputGroup2, { children: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(
37511
+ setInputValue(formatBigDecimalToString(value, formattingProps));
37512
+ }, [value, formattingProps]);
37513
+ return /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, restProps), { inputMode: "decimal", children: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(InputGroup2, { slot: "input", children: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(
37377
37514
  Input2,
37378
37515
  {
37379
37516
  inset: true,
@@ -37382,7 +37519,6 @@ function FormBigDecimalField(_a) {
37382
37519
  value: inputValue,
37383
37520
  onChange: onInputChange,
37384
37521
  onBlur: onInputBlur,
37385
- maxLength: maxInputLength,
37386
37522
  onBeforeInput,
37387
37523
  onPaste
37388
37524
  }
@@ -37390,7 +37526,6 @@ function FormBigDecimalField(_a) {
37390
37526
  }
37391
37527
 
37392
37528
  // src/features/forms/components/FormCheckboxField.tsx
37393
- var import_react224 = require("react");
37394
37529
  var import_classnames89 = __toESM(require("classnames"));
37395
37530
  var import_jsx_runtime333 = require("react/jsx-runtime");
37396
37531
  var FORM_CHECKBOX_FIELD_CLASSNAME = "Layer__FormCheckboxField";
@@ -37399,89 +37534,146 @@ function FormCheckboxField({
37399
37534
  className,
37400
37535
  inline = false,
37401
37536
  showLabel = true,
37402
- showErrorInTooltip = true
37537
+ showFieldError = true,
37538
+ isReadOnly = false
37403
37539
  }) {
37404
37540
  const field = useFieldContext();
37405
37541
  const { name, state, handleChange, handleBlur } = field;
37406
37542
  const { meta, value } = state;
37407
37543
  const { errors, isValid: isValid2 } = meta;
37408
37544
  const errorMessage = errors.length !== 0 ? errors[0] : void 0;
37409
- const tooltipProps = showErrorInTooltip ? { tooltip: errorMessage } : {};
37545
+ const tooltipProps = showFieldError ? { tooltip: errorMessage } : {};
37410
37546
  const additionalAriaProps = !showLabel && { "aria-label": label };
37411
37547
  const checkboxClassNames = (0, import_classnames89.default)(
37412
37548
  FORM_CHECKBOX_FIELD_CLASSNAME,
37413
37549
  inline && `${FORM_CHECKBOX_FIELD_CLASSNAME}--inline`,
37414
37550
  className
37415
37551
  );
37416
- const onChange = (0, import_react224.useCallback)((isSelected) => {
37417
- handleChange(isSelected);
37418
- }, [handleChange]);
37419
37552
  return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
37420
37553
  CheckboxWithTooltip,
37421
37554
  __spreadProps(__spreadValues(__spreadValues(__spreadValues({
37422
37555
  className: checkboxClassNames,
37423
37556
  isSelected: value,
37424
37557
  isInvalid: !isValid2,
37425
- onChange,
37558
+ onChange: handleChange,
37426
37559
  onBlur: handleBlur,
37427
37560
  name,
37428
37561
  value: name,
37429
- size: "lg"
37562
+ size: "lg",
37563
+ isReadOnly
37430
37564
  }, tooltipProps), additionalAriaProps), !isValid2 && { variant: "error" }), {
37431
37565
  children: showLabel && /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(Label, { slot: "label", size: "sm", htmlFor: name, children: label })
37432
37566
  })
37433
37567
  );
37434
37568
  }
37435
37569
 
37436
- // src/features/forms/components/FormCurrencyField.tsx
37570
+ // src/features/forms/components/FormDateField.tsx
37437
37571
  var import_react225 = require("react");
37438
- var import_react_currency_input_field2 = __toESM(require("react-currency-input-field"));
37439
- var import_effect11 = require("effect");
37572
+
37573
+ // src/components/ui/Date/Date.tsx
37574
+ var import_react224 = require("react");
37575
+ var import_classnames90 = __toESM(require("classnames"));
37576
+ var import_react_aria_components17 = require("react-aria-components");
37440
37577
  var import_jsx_runtime334 = require("react/jsx-runtime");
37441
- var ZERO_CENTS_INPUT_VALUE = "0.00";
37442
- var getCurrencyInputValueFromCents = (cents) => !Number.isNaN(cents) ? centsToDollarsWithoutCommas(cents) : ZERO_CENTS_INPUT_VALUE;
37443
- function FormCurrencyField(props) {
37578
+ var DATE_FIELD_CLASS_NAME = "Layer__UI__DateField";
37579
+ var DateField = (0, import_react224.forwardRef)(
37580
+ function DateField2(_a, ref) {
37581
+ var _b = _a, { inline, className, isReadOnly } = _b, restProps = __objRest(_b, ["inline", "className", "isReadOnly"]);
37582
+ const dataProperties = toDataProperties({ inline, readonly: isReadOnly });
37583
+ return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
37584
+ import_react_aria_components17.DateField,
37585
+ __spreadProps(__spreadValues(__spreadValues({}, dataProperties), restProps), {
37586
+ isReadOnly,
37587
+ className: (0, import_classnames90.default)(DATE_FIELD_CLASS_NAME, className),
37588
+ ref
37589
+ })
37590
+ );
37591
+ }
37592
+ );
37593
+ var DATE_INPUT_CLASS_NAME = "Layer__UI__DateInput";
37594
+ var DateInput = (0, import_react224.forwardRef)(
37595
+ function DateInput2(_a, ref) {
37596
+ var _b = _a, { inset } = _b, restProps = __objRest(_b, ["inset"]);
37597
+ const dataProperties = toDataProperties({ inset });
37598
+ return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
37599
+ import_react_aria_components17.DateInput,
37600
+ __spreadProps(__spreadValues(__spreadValues({}, dataProperties), restProps), {
37601
+ className: (0, import_classnames90.default)(DATE_INPUT_CLASS_NAME),
37602
+ ref
37603
+ })
37604
+ );
37605
+ }
37606
+ );
37607
+ var DATE_SEGMENT_CLASS_NAME = "Layer__UI__DateSegment";
37608
+ var DateSegment = (0, import_react224.forwardRef)(
37609
+ function DateSegment2(_a, ref) {
37610
+ var _b = _a, { isReadOnly } = _b, restProps = __objRest(_b, ["isReadOnly"]);
37611
+ const dataProperties = toDataProperties({ interactive: !isReadOnly });
37612
+ return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
37613
+ import_react_aria_components17.DateSegment,
37614
+ __spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), {
37615
+ className: DATE_SEGMENT_CLASS_NAME,
37616
+ ref
37617
+ })
37618
+ );
37619
+ }
37620
+ );
37621
+
37622
+ // src/features/forms/components/FormDateField.tsx
37623
+ var import_jsx_runtime335 = require("react/jsx-runtime");
37624
+ function FormDateField({
37625
+ label,
37626
+ className,
37627
+ inline = false,
37628
+ showLabel = true,
37629
+ showFieldError = true,
37630
+ isReadOnly = false
37631
+ }) {
37444
37632
  const field = useFieldContext();
37445
- const { label } = props;
37446
37633
  const { name, state, handleChange, handleBlur } = field;
37447
- const { value } = state;
37448
- const [inputValue, setInputValue] = (0, import_react225.useState)(getCurrencyInputValueFromCents(value));
37449
- const onInputChange = (0, import_react225.useCallback)((newValue) => {
37450
- setInputValue(newValue != null ? newValue : ZERO_CENTS_INPUT_VALUE);
37451
- }, []);
37452
- const onInputBlur = (0, import_react225.useCallback)(() => {
37453
- const maybeAmount = import_effect11.BigDecimal.fromString(inputValue);
37454
- const cents = import_effect11.Option.match(maybeAmount, {
37455
- onNone: () => 0,
37456
- onSome: (amount) => convertBigDecimalToCents(amount)
37457
- });
37458
- handleChange(cents);
37459
- handleBlur();
37460
- setInputValue(getCurrencyInputValueFromCents(cents));
37461
- }, [inputValue, handleChange, handleBlur]);
37634
+ const { meta, value } = state;
37635
+ const { errors, isValid: isValid2 } = meta;
37636
+ const [localDate, setLocalDate] = (0, import_react225.useState)(value);
37462
37637
  (0, import_react225.useEffect)(() => {
37463
- setInputValue(getCurrencyInputValueFromCents(value));
37638
+ setLocalDate(value);
37464
37639
  }, [value]);
37465
- return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(InputGroup2, { children: /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
37466
- import_react_currency_input_field2.default,
37467
- {
37640
+ const onBlur = (0, import_react225.useCallback)(() => {
37641
+ const nextDate = isZonedDateTime(localDate) ? localDate : null;
37642
+ handleChange(nextDate);
37643
+ handleBlur();
37644
+ }, [handleBlur, handleChange, localDate]);
37645
+ const errorMessage = errors.length !== 0 ? errors[0] : void 0;
37646
+ const shouldShowErrorMessage = showFieldError && errorMessage;
37647
+ const additionalAriaProps = !showLabel && { "aria-label": label };
37648
+ return /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)(
37649
+ DateField,
37650
+ __spreadProps(__spreadValues({
37468
37651
  name,
37469
- intlConfig: {
37470
- locale: "en-US",
37471
- currency: "USD"
37472
- },
37473
- prefix: "$",
37474
- decimalScale: 2,
37475
- decimalsLimit: 2,
37476
- disableAbbreviations: true,
37477
- value: inputValue,
37478
- onValueChange: onInputChange,
37479
- onBlur: onInputBlur,
37480
- className: "Layer__UI__Input",
37481
- "data-inset": "true",
37482
- "aria-label": label
37483
- }
37484
- ) }) }));
37652
+ granularity: "day",
37653
+ value: localDate,
37654
+ isInvalid: !isValid2,
37655
+ inline,
37656
+ className,
37657
+ onChange: setLocalDate,
37658
+ onBlur,
37659
+ isReadOnly
37660
+ }, additionalAriaProps), {
37661
+ children: [
37662
+ showLabel && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(
37663
+ Label,
37664
+ __spreadProps(__spreadValues({
37665
+ slot: "label",
37666
+ size: "sm",
37667
+ htmlFor: name
37668
+ }, !inline && { pbe: "3xs" }), {
37669
+ children: label
37670
+ })
37671
+ ),
37672
+ /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(InputGroup2, { slot: "input", children: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(DateInput, { inset: true, children: (segment) => /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(DateSegment, { isReadOnly, segment }) }) }),
37673
+ shouldShowErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(FieldError, { children: errorMessage })
37674
+ ]
37675
+ })
37676
+ );
37485
37677
  }
37486
37678
 
37487
37679
  // src/features/forms/components/FormTextAreaField.tsx
@@ -37489,15 +37681,15 @@ var import_react227 = require("react");
37489
37681
 
37490
37682
  // src/components/ui/Input/TextArea.tsx
37491
37683
  var import_react226 = require("react");
37492
- var import_react_aria_components17 = require("react-aria-components");
37493
- var import_jsx_runtime335 = require("react/jsx-runtime");
37684
+ var import_react_aria_components18 = require("react-aria-components");
37685
+ var import_jsx_runtime336 = require("react/jsx-runtime");
37494
37686
  var TEXTAREA_CLASS_NAME = "Layer__UI__TextArea";
37495
37687
  var TextArea = (0, import_react226.forwardRef)(
37496
37688
  function TextArea2(_a, ref) {
37497
37689
  var _b = _a, { resize = "none" } = _b, restProps = __objRest(_b, ["resize"]);
37498
37690
  const dataProperties = toDataProperties({ resize });
37499
- return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(
37500
- import_react_aria_components17.TextArea,
37691
+ return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(
37692
+ import_react_aria_components18.TextArea,
37501
37693
  __spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), {
37502
37694
  className: TEXTAREA_CLASS_NAME,
37503
37695
  ref
@@ -37507,7 +37699,7 @@ var TextArea = (0, import_react226.forwardRef)(
37507
37699
  );
37508
37700
 
37509
37701
  // src/features/forms/components/FormTextAreaField.tsx
37510
- var import_jsx_runtime336 = require("react/jsx-runtime");
37702
+ var import_jsx_runtime337 = require("react/jsx-runtime");
37511
37703
  function FormTextAreaField(props) {
37512
37704
  const field = useFieldContext();
37513
37705
  const { name, state, handleChange, handleBlur } = field;
@@ -37515,12 +37707,22 @@ function FormTextAreaField(props) {
37515
37707
  const onChange = (0, import_react227.useCallback)((e) => {
37516
37708
  handleChange(e.target.value);
37517
37709
  }, [handleChange]);
37518
- return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, props), { isTextArea: true, children: /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(TextArea, { id: name, name, value, onChange, onBlur: handleBlur }) }));
37710
+ return /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, props), { isTextArea: true, children: /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
37711
+ TextArea,
37712
+ {
37713
+ slot: "input",
37714
+ id: name,
37715
+ name,
37716
+ value,
37717
+ onChange,
37718
+ onBlur: handleBlur
37719
+ }
37720
+ ) }));
37519
37721
  }
37520
37722
 
37521
37723
  // src/features/forms/components/FormTextField.tsx
37522
37724
  var import_react228 = require("react");
37523
- var import_jsx_runtime337 = require("react/jsx-runtime");
37725
+ var import_jsx_runtime338 = require("react/jsx-runtime");
37524
37726
  function FormTextField(props) {
37525
37727
  const field = useFieldContext();
37526
37728
  const { name, state, handleChange, handleBlur } = field;
@@ -37528,17 +37730,27 @@ function FormTextField(props) {
37528
37730
  const onChange = (0, import_react228.useCallback)((e) => {
37529
37731
  handleChange(e.target.value);
37530
37732
  }, [handleChange]);
37531
- return /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(InputGroup2, { children: /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(Input2, { inset: true, id: name, name, value, onChange, onBlur: handleBlur }) }) }));
37733
+ return /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(InputGroup2, { slot: "input", children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
37734
+ Input2,
37735
+ {
37736
+ id: name,
37737
+ name,
37738
+ value,
37739
+ onChange,
37740
+ onBlur: handleBlur,
37741
+ inset: true
37742
+ }
37743
+ ) }) }));
37532
37744
  }
37533
37745
 
37534
37746
  // src/features/forms/hooks/useForm.tsx
37535
37747
  var { fieldContext, useFieldContext, formContext, useFormContext } = (0, import_react_form6.createFormHookContexts)();
37536
- var { useAppForm, withForm } = (0, import_react_form6.createFormHook)({
37748
+ var { useAppForm: useInternalAppForm } = (0, import_react_form6.createFormHook)({
37537
37749
  fieldComponents: {
37538
37750
  BaseFormTextField,
37539
37751
  FormBigDecimalField,
37540
37752
  FormCheckboxField,
37541
- FormCurrencyField,
37753
+ FormDateField,
37542
37754
  FormTextAreaField,
37543
37755
  FormTextField
37544
37756
  },
@@ -37548,9 +37760,104 @@ var { useAppForm, withForm } = (0, import_react_form6.createFormHook)({
37548
37760
  fieldContext,
37549
37761
  formContext
37550
37762
  });
37763
+ function useAppForm(props) {
37764
+ return useInternalAppForm(props);
37765
+ }
37551
37766
 
37552
37767
  // src/features/invoices/invoiceSchemas.ts
37553
37768
  var import_effect12 = require("effect");
37769
+
37770
+ // src/components/Invoices/InvoiceTermsComboBox/InvoiceTermsComboBox.tsx
37771
+ var import_react229 = require("react");
37772
+ var import_date_fns51 = require("date-fns");
37773
+ var import_jsx_runtime339 = require("react/jsx-runtime");
37774
+ var InvoiceTermsValues = /* @__PURE__ */ ((InvoiceTermsValues2) => {
37775
+ InvoiceTermsValues2["Net10"] = "Net10";
37776
+ InvoiceTermsValues2["Net15"] = "Net15";
37777
+ InvoiceTermsValues2["Net30"] = "Net30";
37778
+ InvoiceTermsValues2["Net60"] = "Net60";
37779
+ InvoiceTermsValues2["Net90"] = "Net90";
37780
+ InvoiceTermsValues2["Custom"] = "Custom";
37781
+ return InvoiceTermsValues2;
37782
+ })(InvoiceTermsValues || {});
37783
+ var InvoiceTermsOptionConfig = {
37784
+ ["Net10" /* Net10 */]: { label: "Net 10", value: "Net10" /* Net10 */ },
37785
+ ["Net15" /* Net15 */]: { label: "Net 15", value: "Net15" /* Net15 */ },
37786
+ ["Net30" /* Net30 */]: { label: "Net 30", value: "Net30" /* Net30 */ },
37787
+ ["Net60" /* Net60 */]: { label: "Net 60", value: "Net60" /* Net60 */ },
37788
+ ["Net90" /* Net90 */]: { label: "Net 90", value: "Net90" /* Net90 */ },
37789
+ ["Custom" /* Custom */]: { label: "Custom", value: "Custom" /* Custom */ }
37790
+ };
37791
+ var options = Object.values(InvoiceTermsOptionConfig);
37792
+ var getDurationInDaysFromTerms = (terms) => {
37793
+ switch (terms) {
37794
+ case "Net10" /* Net10 */:
37795
+ return 10;
37796
+ case "Net15" /* Net15 */:
37797
+ return 15;
37798
+ case "Net30" /* Net30 */:
37799
+ return 30;
37800
+ case "Net60" /* Net60 */:
37801
+ return 60;
37802
+ case "Net90" /* Net90 */:
37803
+ return 90;
37804
+ case "Custom" /* Custom */:
37805
+ default:
37806
+ return void 0;
37807
+ }
37808
+ };
37809
+ var getInvoiceTermsFromDates = (sentAt, dueAt) => {
37810
+ if (!sentAt || !dueAt) return "Custom" /* Custom */;
37811
+ const days = (0, import_date_fns51.differenceInDays)(
37812
+ (0, import_date_fns51.startOfDay)(dueAt.toDate()),
37813
+ (0, import_date_fns51.startOfDay)(sentAt.toDate())
37814
+ );
37815
+ switch (days) {
37816
+ case 10:
37817
+ return "Net10" /* Net10 */;
37818
+ case 15:
37819
+ return "Net15" /* Net15 */;
37820
+ case 30:
37821
+ return "Net30" /* Net30 */;
37822
+ case 60:
37823
+ return "Net60" /* Net60 */;
37824
+ case 90:
37825
+ return "Net90" /* Net90 */;
37826
+ default:
37827
+ return "Custom" /* Custom */;
37828
+ }
37829
+ };
37830
+ var InvoiceTermsComboBox = ({ value, onValueChange, isReadOnly }) => {
37831
+ const selectedOption = InvoiceTermsOptionConfig[value];
37832
+ const onSelectedValueChange = (0, import_react229.useCallback)((option) => {
37833
+ onValueChange((option == null ? void 0 : option.value) || null);
37834
+ }, [onValueChange]);
37835
+ const inputId = (0, import_react229.useId)();
37836
+ return /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(HStack, { className: "Layer__InvoiceForm__TermsComboBox Layer__InvoiceForm__Field__Terms", children: [
37837
+ /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(Label, { size: "sm", htmlFor: inputId, children: "Terms" }),
37838
+ /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
37839
+ ComboBox,
37840
+ {
37841
+ options,
37842
+ onSelectedValueChange,
37843
+ selectedValue: selectedOption,
37844
+ isSearchable: false,
37845
+ isClearable: false,
37846
+ inputId,
37847
+ isReadOnly
37848
+ }
37849
+ )
37850
+ ] });
37851
+ };
37852
+
37853
+ // src/utils/schema/utils.ts
37854
+ var import_effect11 = require("effect");
37855
+ var import_date3 = require("@internationalized/date");
37856
+ var ZonedDateTimeFromSelf = import_effect11.Schema.declare(
37857
+ (input) => input instanceof import_date3.ZonedDateTime
37858
+ );
37859
+
37860
+ // src/features/invoices/invoiceSchemas.ts
37554
37861
  var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus3) => {
37555
37862
  InvoiceStatus3["Voided"] = "VOIDED";
37556
37863
  InvoiceStatus3["Paid"] = "PAID";
@@ -37683,7 +37990,11 @@ var UpsertInvoiceLineItemSchema = import_effect12.Schema.Struct({
37683
37990
  import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
37684
37991
  import_effect12.Schema.fromKey("unit_price")
37685
37992
  ),
37686
- quantity: import_effect12.Schema.BigDecimal
37993
+ quantity: import_effect12.Schema.BigDecimal,
37994
+ salesTaxes: (0, import_effect12.pipe)(
37995
+ import_effect12.Schema.propertySignature(import_effect12.Schema.UndefinedOr(import_effect12.Schema.Array(UpsertInvoiceTaxLineItemSchema))),
37996
+ import_effect12.Schema.fromKey("sales_taxes")
37997
+ )
37687
37998
  });
37688
37999
  var UpsertInvoiceSchema = import_effect12.Schema.Struct({
37689
38000
  sentAt: (0, import_effect12.pipe)(
@@ -37710,15 +38021,33 @@ var UpsertInvoiceSchema = import_effect12.Schema.Struct({
37710
38021
  additionalDiscount: (0, import_effect12.pipe)(
37711
38022
  import_effect12.Schema.propertySignature(import_effect12.Schema.UndefinedOr(import_effect12.Schema.Number)),
37712
38023
  import_effect12.Schema.fromKey("additional_discount")
37713
- ),
37714
- additionalSalesTaxes: (0, import_effect12.pipe)(
37715
- import_effect12.Schema.propertySignature(import_effect12.Schema.UndefinedOr(import_effect12.Schema.Array(UpsertInvoiceTaxLineItemSchema))),
37716
- import_effect12.Schema.fromKey("additional_sales_taxes")
37717
38024
  )
37718
38025
  });
38026
+ var InvoiceFormLineItemSchema = import_effect12.Schema.Struct({
38027
+ description: import_effect12.Schema.String,
38028
+ product: import_effect12.Schema.String,
38029
+ unitPrice: import_effect12.Schema.BigDecimal,
38030
+ quantity: import_effect12.Schema.BigDecimal,
38031
+ amount: import_effect12.Schema.BigDecimal,
38032
+ isTaxable: import_effect12.Schema.Boolean
38033
+ });
38034
+ var InvoiceTermsValuesSchema = import_effect12.Schema.Enums(InvoiceTermsValues);
38035
+ var InvoiceFormSchema = import_effect12.Schema.Struct({
38036
+ terms: InvoiceTermsValuesSchema,
38037
+ sentAt: import_effect12.Schema.NullOr(ZonedDateTimeFromSelf),
38038
+ dueAt: import_effect12.Schema.NullOr(ZonedDateTimeFromSelf),
38039
+ invoiceNumber: import_effect12.Schema.String,
38040
+ customer: import_effect12.Schema.NullOr(CustomerSchema),
38041
+ email: import_effect12.Schema.String,
38042
+ address: import_effect12.Schema.String,
38043
+ lineItems: import_effect12.Schema.Array(InvoiceFormLineItemSchema),
38044
+ discountRate: import_effect12.Schema.BigDecimal,
38045
+ taxRate: import_effect12.Schema.BigDecimal,
38046
+ memo: import_effect12.Schema.String
38047
+ });
37719
38048
 
37720
38049
  // src/features/invoices/api/useUpsertInvoice.tsx
37721
- var import_react229 = require("react");
38050
+ var import_react230 = require("react");
37722
38051
  var import_mutation26 = __toESM(require("swr/mutation"));
37723
38052
  var import_effect13 = require("effect");
37724
38053
  var UPSERT_INVOICES_TAG_KEY = "#upsert-invoice";
@@ -37809,12 +38138,13 @@ var useUpsertInvoice = (props) => {
37809
38138
  }).then(import_effect13.Schema.decodeUnknownPromise(UpsertInvoiceReturnSchema));
37810
38139
  },
37811
38140
  {
37812
- revalidate: false
38141
+ revalidate: false,
38142
+ throwOnError: true
37813
38143
  }
37814
38144
  );
37815
38145
  const mutationResponse = new UpsertInvoiceSWRResponse(rawMutationResponse);
37816
38146
  const originalTrigger = mutationResponse.trigger;
37817
- const stableProxiedTrigger = (0, import_react229.useCallback)(
38147
+ const stableProxiedTrigger = (0, import_react230.useCallback)(
37818
38148
  (...triggerParameters) => __async(null, null, function* () {
37819
38149
  const triggerResult = yield originalTrigger(...triggerParameters);
37820
38150
  return triggerResult;
@@ -37832,77 +38162,293 @@ var useUpsertInvoice = (props) => {
37832
38162
  };
37833
38163
 
37834
38164
  // src/components/Invoices/InvoiceForm/useInvoiceForm.ts
38165
+ var import_effect16 = require("effect");
38166
+
38167
+ // src/components/Invoices/InvoiceForm/totalsUtils.ts
37835
38168
  var import_effect14 = require("effect");
37836
- var EMPTY_LINE_ITEM = {
38169
+ function computeSubtotal(lineItems) {
38170
+ return lineItems.reduce((sum, item) => import_effect14.BigDecimal.sum(sum, item.amount), BIG_DECIMAL_ZERO);
38171
+ }
38172
+ var computeRawTaxableSubtotal = (lineItems) => lineItems.filter((item) => item.isTaxable).reduce((sum, item) => import_effect14.BigDecimal.sum(sum, item.amount), BIG_DECIMAL_ZERO);
38173
+ function computeAdditionalDiscount({
38174
+ subtotal,
38175
+ discountRate
38176
+ }) {
38177
+ const rawDiscountAmount = import_effect14.BigDecimal.multiply(subtotal, discountRate);
38178
+ const additionalDiscount = roundDecimalToCents(rawDiscountAmount);
38179
+ return additionalDiscount;
38180
+ }
38181
+ function computeTaxableSubtotal({
38182
+ rawTaxableSubtotal,
38183
+ discountRate
38184
+ }) {
38185
+ const discountForTaxableSubtotal = import_effect14.BigDecimal.multiply(rawTaxableSubtotal, discountRate);
38186
+ const taxableSubtotal = import_effect14.BigDecimal.subtract(rawTaxableSubtotal, discountForTaxableSubtotal);
38187
+ return taxableSubtotal;
38188
+ }
38189
+ function computeTaxes({
38190
+ taxableSubtotal,
38191
+ taxRate
38192
+ }) {
38193
+ const rawTaxAmount = import_effect14.BigDecimal.multiply(taxableSubtotal, taxRate);
38194
+ const taxes = roundDecimalToCents(rawTaxAmount);
38195
+ return taxes;
38196
+ }
38197
+ function computeGrandTotal({
38198
+ subtotal,
38199
+ additionalDiscount,
38200
+ taxes
38201
+ }) {
38202
+ const subtotalLessDiscounts = import_effect14.BigDecimal.subtract(subtotal, additionalDiscount);
38203
+ const grandTotal = import_effect14.BigDecimal.sum(subtotalLessDiscounts, taxes);
38204
+ return grandTotal;
38205
+ }
38206
+ var getGrandTotalFromInvoice = (invoice) => {
38207
+ const { lineItems, discountRate, taxRate } = invoice;
38208
+ const subtotal = computeSubtotal(lineItems);
38209
+ const rawTaxableSubtotal = computeRawTaxableSubtotal(lineItems);
38210
+ const taxableSubtotal = computeTaxableSubtotal({ rawTaxableSubtotal, discountRate });
38211
+ const taxes = computeTaxes({ taxableSubtotal, taxRate });
38212
+ const additionalDiscount = computeAdditionalDiscount({ subtotal, discountRate });
38213
+ const grandTotal = computeGrandTotal({ subtotal, additionalDiscount, taxes });
38214
+ return grandTotal;
38215
+ };
38216
+
38217
+ // src/components/Invoices/InvoiceForm/formUtils.ts
38218
+ var import_effect15 = require("effect");
38219
+ var import_date_fns52 = require("date-fns");
38220
+ var import_date4 = require("@internationalized/date");
38221
+ var import_lodash6 = __toESM(require_lodash());
38222
+ var getEmptyLineItem = () => ({
37837
38223
  product: "",
37838
38224
  description: "",
37839
- unitPrice: 0,
38225
+ unitPrice: BIG_DECIMAL_ZERO,
37840
38226
  quantity: BIG_DECIMAL_ONE,
37841
- amount: 0,
38227
+ amount: BIG_DECIMAL_ZERO,
37842
38228
  isTaxable: false
37843
- };
37844
- var DEFAULT_FORM_VALUES = {
37845
- invoiceNumber: "",
37846
- customer: null,
37847
- email: "",
37848
- address: "",
37849
- lineItems: [EMPTY_LINE_ITEM]
38229
+ });
38230
+ var getInvoiceFormDefaultValues = () => {
38231
+ const sentAt = (0, import_date4.fromDate)((0, import_date_fns52.startOfToday)(), (0, import_date4.getLocalTimeZone)());
38232
+ const dueAt = sentAt.add({ days: 30 });
38233
+ return {
38234
+ invoiceNumber: "",
38235
+ terms: "Net30" /* Net30 */,
38236
+ sentAt,
38237
+ dueAt,
38238
+ customer: null,
38239
+ email: "",
38240
+ address: "",
38241
+ lineItems: [getEmptyLineItem()],
38242
+ memo: "",
38243
+ discountRate: BIG_DECIMAL_ZERO,
38244
+ taxRate: BIG_DECIMAL_ZERO
38245
+ };
37850
38246
  };
37851
38247
  var getInvoiceLineItemAmount = (lineItem) => {
37852
38248
  const { unitPrice, quantity } = lineItem;
37853
- return convertBigDecimalToCents(import_effect14.BigDecimal.multiply(quantity, convertCentsToBigDecimal(unitPrice)));
38249
+ return import_effect15.BigDecimal.multiply(quantity, convertCentsToBigDecimal(unitPrice));
37854
38250
  };
37855
- var getAugmentedInvoiceFormLineItem = (lineItem) => {
37856
- return __spreadProps(__spreadValues({}, lineItem), {
38251
+ var getInvoiceFormLineItem = (lineItem) => {
38252
+ const { product, description, unitPrice, quantity } = lineItem;
38253
+ return {
38254
+ product: product || "",
38255
+ description: description || "",
38256
+ quantity: import_effect15.BigDecimal.normalize(quantity),
38257
+ unitPrice: convertCentsToBigDecimal(unitPrice),
37857
38258
  amount: getInvoiceLineItemAmount(lineItem),
37858
38259
  isTaxable: lineItem.salesTaxTotal > 0
37859
- });
38260
+ };
37860
38261
  };
37861
- var getInvoiceFormDefaultValues = (invoice) => {
38262
+ var getInvoiceFormInitialValues = (invoice) => {
37862
38263
  var _a, _b;
38264
+ const invoiceFormLineItems = invoice.lineItems.map(getInvoiceFormLineItem);
38265
+ const subtotal = computeSubtotal(invoiceFormLineItems);
38266
+ const rawTaxableSubtotal = computeRawTaxableSubtotal(invoiceFormLineItems);
38267
+ const additionalDiscount = convertCentsToBigDecimal(invoice.additionalDiscount);
38268
+ const discountRate = safeDivide(additionalDiscount, subtotal);
38269
+ const taxableSubtotal = computeTaxableSubtotal({ rawTaxableSubtotal, discountRate });
38270
+ const taxes = invoice.lineItems.reduce(
38271
+ (sum, item) => import_effect15.BigDecimal.sum(sum, convertCentsToBigDecimal(item.salesTaxTotal)),
38272
+ BIG_DECIMAL_ZERO
38273
+ );
38274
+ const taxRate = safeDivide(taxes, taxableSubtotal);
38275
+ const sentAt = invoice.sentAt ? (0, import_date4.fromDate)(invoice.sentAt, "UTC") : null;
38276
+ const dueAt = invoice.dueAt ? (0, import_date4.fromDate)(invoice.dueAt, "UTC") : null;
37863
38277
  return {
37864
- invoiceNumber: invoice.invoiceNumber,
38278
+ terms: getInvoiceTermsFromDates(sentAt, dueAt),
38279
+ invoiceNumber: invoice.invoiceNumber || "",
38280
+ sentAt,
38281
+ dueAt,
37865
38282
  customer: invoice.customer,
37866
- email: (_a = invoice.customer) == null ? void 0 : _a.email,
37867
- address: (_b = invoice.customer) == null ? void 0 : _b.addressString,
37868
- lineItems: invoice.lineItems.map(getAugmentedInvoiceFormLineItem)
38283
+ email: ((_a = invoice.customer) == null ? void 0 : _a.email) || "",
38284
+ address: ((_b = invoice.customer) == null ? void 0 : _b.addressString) || "",
38285
+ lineItems: invoiceFormLineItems,
38286
+ discountRate,
38287
+ taxRate,
38288
+ memo: invoice.memo || ""
37869
38289
  };
37870
38290
  };
38291
+ var getIsEqualLineItems = (a, b) => {
38292
+ return (0, import_lodash6.isEqualWith)(a, b, (val1, val2, key) => {
38293
+ if (key === "unitPrice" || key === "quantity" || key === "amount") {
38294
+ return import_effect15.BigDecimal.isBigDecimal(val1) && import_effect15.BigDecimal.isBigDecimal(val2) && import_effect15.BigDecimal.equals(val1, val2);
38295
+ }
38296
+ return void 0;
38297
+ });
38298
+ };
38299
+ var validateOnSubmit = ({ value: invoice }) => {
38300
+ const errors = [];
38301
+ if (invoice.customer === null) {
38302
+ errors.push({ customer: "Customer is a required field." });
38303
+ }
38304
+ if (!invoice.invoiceNumber.trim()) {
38305
+ errors.push({ invoiceNumber: "Invoice number is a required field." });
38306
+ }
38307
+ if (invoice.sentAt === null) {
38308
+ errors.push({ sentAt: "Invoice date is a required field." });
38309
+ }
38310
+ if (invoice.dueAt === null) {
38311
+ errors.push({ dueAt: "Due date is a required field." });
38312
+ }
38313
+ if (invoice.lineItems.length === 0) {
38314
+ errors.push({ lineItems: "Invoice requires at least one line item." });
38315
+ }
38316
+ const emptyLineItem = getEmptyLineItem();
38317
+ invoice.lineItems.some((item) => {
38318
+ if (!getIsEqualLineItems(item, emptyLineItem) && item.product === "") {
38319
+ errors.push({ lineItems: "Invoice has incomplete line items. Please include required field Product/Service." });
38320
+ return true;
38321
+ }
38322
+ });
38323
+ const grandTotal = getGrandTotalFromInvoice(invoice);
38324
+ if (import_effect15.BigDecimal.isNegative(grandTotal)) {
38325
+ errors.push({ lineItems: "Invoice has a negative total." });
38326
+ }
38327
+ return errors.length > 0 ? errors : null;
38328
+ };
38329
+ function flattenValidationErrors(errors) {
38330
+ return Object.values(errors).filter(
38331
+ (value) => Array.isArray(value) && value.every((entry) => typeof entry === "object" && entry !== null)
38332
+ ).flatMap(
38333
+ (errorArray) => errorArray.flatMap(
38334
+ (entry) => Object.values(entry)
38335
+ )
38336
+ );
38337
+ }
38338
+ var convertInvoiceFormToParams = (form) => {
38339
+ var _a, _b, _c;
38340
+ return __spreadValues({
38341
+ customerId: (_a = form.customer) == null ? void 0 : _a.id,
38342
+ dueAt: (_b = form.dueAt) == null ? void 0 : _b.toDate(),
38343
+ sentAt: (_c = form.sentAt) == null ? void 0 : _c.toDate(),
38344
+ invoiceNumber: form.invoiceNumber || void 0,
38345
+ memo: form.memo,
38346
+ lineItems: form.lineItems.map((item) => {
38347
+ const baseLineItem = {
38348
+ description: item.description,
38349
+ product: item.product,
38350
+ unitPrice: convertBigDecimalToCents(item.unitPrice),
38351
+ quantity: item.quantity
38352
+ };
38353
+ return !import_effect15.BigDecimal.equals(form.taxRate, BIG_DECIMAL_ZERO) && item.isTaxable ? __spreadProps(__spreadValues({}, baseLineItem), {
38354
+ salesTaxes: [
38355
+ {
38356
+ amount: convertBigDecimalToCents(
38357
+ import_effect15.BigDecimal.multiply(item.amount, form.taxRate)
38358
+ )
38359
+ }
38360
+ ]
38361
+ }) : baseLineItem;
38362
+ })
38363
+ }, !import_effect15.BigDecimal.equals(form.discountRate, BIG_DECIMAL_ZERO) && {
38364
+ additionalDiscount: convertBigDecimalToCents(
38365
+ import_effect15.BigDecimal.multiply(computeSubtotal(form.lineItems), form.discountRate)
38366
+ )
38367
+ });
38368
+ };
38369
+
38370
+ // src/components/Invoices/InvoiceForm/useInvoiceForm.ts
38371
+ function isUpdateMode(props) {
38372
+ return props.mode === "Update" /* Update */;
38373
+ }
37871
38374
  var useInvoiceForm = (props) => {
37872
- const [submitError, setSubmitError] = (0, import_react230.useState)(void 0);
38375
+ const [submitError, setSubmitError] = (0, import_react231.useState)(void 0);
37873
38376
  const { onSuccess, mode } = props;
37874
38377
  const upsertInvoiceProps = mode === "Update" /* Update */ ? { mode, invoiceId: props.invoice.id } : { mode };
37875
38378
  const { trigger: upsertInvoice } = useUpsertInvoice(upsertInvoiceProps);
37876
- const defaultValues = mode === "Update" /* Update */ ? getInvoiceFormDefaultValues(props.invoice) : DEFAULT_FORM_VALUES;
37877
- const form = useAppForm({
37878
- defaultValues,
37879
- onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
37880
- var _a;
37881
- try {
37882
- const payload = __spreadProps(__spreadValues({}, value), {
37883
- customerId: (_a = value == null ? void 0 : value.customer) == null ? void 0 : _a.id
37884
- });
37885
- const invoiceParams = import_effect14.Schema.validateSync(UpsertInvoiceSchema)(payload);
37886
- const { data: invoice } = yield upsertInvoice(invoiceParams);
37887
- setSubmitError(void 0);
37888
- onSuccess == null ? void 0 : onSuccess(invoice);
37889
- } catch (e) {
37890
- setSubmitError("Something went wrong. Please try again.");
37891
- }
37892
- })
37893
- });
38379
+ const defaultValuesRef = (0, import_react231.useRef)(
38380
+ isUpdateMode(props) ? getInvoiceFormInitialValues(props.invoice) : getInvoiceFormDefaultValues()
38381
+ );
38382
+ const defaultValues = defaultValuesRef.current;
38383
+ const onSubmit = (0, import_react231.useCallback)((_0) => __async(null, [_0], function* ({ value }) {
38384
+ try {
38385
+ const upsertInvoiceParams = convertInvoiceFormToParams(value);
38386
+ const upsertInvoiceRequest = import_effect16.Schema.encodeUnknownSync(UpsertInvoiceSchema)(upsertInvoiceParams);
38387
+ const { data: invoice } = yield upsertInvoice(upsertInvoiceRequest);
38388
+ setSubmitError(void 0);
38389
+ onSuccess == null ? void 0 : onSuccess(invoice);
38390
+ } catch (e) {
38391
+ console.error(e);
38392
+ setSubmitError("Something went wrong. Please try again.");
38393
+ }
38394
+ }), [onSuccess, upsertInvoice]);
38395
+ const validators = (0, import_react231.useMemo)(() => ({
38396
+ onSubmit: validateOnSubmit
38397
+ }), []);
38398
+ const form = useAppForm({ defaultValues, onSubmit, validators });
37894
38399
  const isFormValid = (0, import_react_form7.useStore)(form.store, (state) => state.isValid);
37895
- return { form, submitError, isFormValid };
38400
+ const isSubmitting = (0, import_react_form7.useStore)(form.store, (state) => state.isSubmitting);
38401
+ const formState = (0, import_react231.useMemo)(() => ({
38402
+ isFormValid,
38403
+ isSubmitting,
38404
+ submitError
38405
+ }), [isFormValid, isSubmitting, submitError]);
38406
+ const discountRate = (0, import_react_form7.useStore)(form.store, (state) => state.values.discountRate);
38407
+ const taxRate = (0, import_react_form7.useStore)(form.store, (state) => state.values.taxRate);
38408
+ const { subtotal, rawTaxableSubtotal } = (0, import_react_form7.useStore)(form.store, (state) => {
38409
+ const lineItems = state.values.lineItems;
38410
+ return {
38411
+ subtotal: computeSubtotal(lineItems),
38412
+ rawTaxableSubtotal: computeRawTaxableSubtotal(lineItems)
38413
+ };
38414
+ });
38415
+ const additionalDiscount = (0, import_react231.useMemo)(
38416
+ () => computeAdditionalDiscount({ subtotal, discountRate }),
38417
+ [subtotal, discountRate]
38418
+ );
38419
+ const taxableSubtotal = (0, import_react231.useMemo)(
38420
+ () => computeTaxableSubtotal({ rawTaxableSubtotal, discountRate }),
38421
+ [rawTaxableSubtotal, discountRate]
38422
+ );
38423
+ const taxes = (0, import_react231.useMemo)(
38424
+ () => computeTaxes({ taxableSubtotal, taxRate }),
38425
+ [taxableSubtotal, taxRate]
38426
+ );
38427
+ const grandTotal = (0, import_react231.useMemo)(
38428
+ () => computeGrandTotal({ subtotal, additionalDiscount, taxes }),
38429
+ [subtotal, additionalDiscount, taxes]
38430
+ );
38431
+ const totals = (0, import_react231.useMemo)(() => ({
38432
+ subtotal,
38433
+ additionalDiscount,
38434
+ taxableSubtotal,
38435
+ taxes,
38436
+ grandTotal
38437
+ }), [additionalDiscount, grandTotal, subtotal, taxableSubtotal, taxes]);
38438
+ return (0, import_react231.useMemo)(
38439
+ () => ({ form, formState, totals }),
38440
+ [form, formState, totals]
38441
+ );
37896
38442
  };
37897
38443
 
37898
38444
  // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
37899
38445
  var import_lucide_react16 = require("lucide-react");
37900
- var import_effect15 = require("effect");
38446
+ var import_effect17 = require("effect");
37901
38447
 
37902
38448
  // src/features/customers/components/CustomerSelector.tsx
37903
- var import_react231 = require("react");
37904
- var import_classnames90 = __toESM(require("classnames"));
37905
- var import_jsx_runtime338 = require("react/jsx-runtime");
38449
+ var import_react232 = require("react");
38450
+ var import_classnames91 = __toESM(require("classnames"));
38451
+ var import_jsx_runtime340 = require("react/jsx-runtime");
37906
38452
  function getCustomerName(customer) {
37907
38453
  var _a, _b, _c;
37908
38454
  return (_c = (_b = (_a = customer.individualName) != null ? _a : customer.companyName) != null ? _b : customer.externalId) != null ? _c : "Unknown Customer";
@@ -37933,7 +38479,7 @@ function CustomerSelector({
37933
38479
  inline,
37934
38480
  className
37935
38481
  }) {
37936
- const combinedClassName = (0, import_classnames90.default)(
38482
+ const combinedClassName = (0, import_classnames91.default)(
37937
38483
  "Layer__CustomerSelector",
37938
38484
  inline && "Layer__CustomerSelector--inline",
37939
38485
  className
@@ -37943,12 +38489,12 @@ function CustomerSelector({
37943
38489
  });
37944
38490
  const effectiveSearchQuery = searchQuery === "" ? void 0 : searchQuery;
37945
38491
  const { data, isLoading, isError } = useListCustomers({ query: effectiveSearchQuery });
37946
- const options = (0, import_react231.useMemo)(
38492
+ const options2 = (0, import_react232.useMemo)(
37947
38493
  () => (data == null ? void 0 : data.flatMap(({ data: data2 }) => data2).map((customer) => new CustomerAsOption(customer))) || [],
37948
38494
  [data]
37949
38495
  );
37950
38496
  const selectedCustomerId = selectedCustomer == null ? void 0 : selectedCustomer.id;
37951
- const handleSelectionChange = (0, import_react231.useCallback)(
38497
+ const handleSelectionChange = (0, import_react232.useCallback)(
37952
38498
  (selectedOption) => {
37953
38499
  if (selectedOption === null) {
37954
38500
  handleInputChange("");
@@ -37957,7 +38503,7 @@ function CustomerSelector({
37957
38503
  }
37958
38504
  return;
37959
38505
  }
37960
- const selectedCustomer2 = options.find(({ id }) => id === selectedOption.value);
38506
+ const selectedCustomer2 = options2.find(({ id }) => id === selectedOption.value);
37961
38507
  if (selectedCustomer2) {
37962
38508
  const selectedCustomerWithType = selectedCustomer2.original;
37963
38509
  if (selectedCustomer2.id !== selectedCustomerId) {
@@ -37967,9 +38513,9 @@ function CustomerSelector({
37967
38513
  return;
37968
38514
  }
37969
38515
  },
37970
- [options, handleInputChange, selectedCustomerId, onSelectedCustomerChange]
38516
+ [options2, handleInputChange, selectedCustomerId, onSelectedCustomerChange]
37971
38517
  );
37972
- const selectedCustomerForComboBox = (0, import_react231.useMemo)(
38518
+ const selectedCustomerForComboBox = (0, import_react232.useMemo)(
37973
38519
  () => {
37974
38520
  if (selectedCustomer === null) {
37975
38521
  return null;
@@ -37981,12 +38527,12 @@ function CustomerSelector({
37981
38527
  },
37982
38528
  [selectedCustomer]
37983
38529
  );
37984
- const EmptyMessage = (0, import_react231.useMemo)(
37985
- () => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(P, { variant: "subtle", children: "No matching customer" }),
38530
+ const EmptyMessage = (0, import_react232.useMemo)(
38531
+ () => /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(P, { variant: "subtle", children: "No matching customer" }),
37986
38532
  []
37987
38533
  );
37988
- const ErrorMessage = (0, import_react231.useMemo)(
37989
- () => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
38534
+ const ErrorMessage = (0, import_react232.useMemo)(
38535
+ () => /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(
37990
38536
  P,
37991
38537
  {
37992
38538
  size: "xs",
@@ -37996,143 +38542,287 @@ function CustomerSelector({
37996
38542
  ),
37997
38543
  []
37998
38544
  );
37999
- const inputId = (0, import_react231.useId)();
38000
- const isFiltered = effectiveSearchQuery !== void 0;
38001
- const noCustomersExist = !isLoading && !isFiltered && data !== void 0 && data.every(({ data: data2 }) => data2.length === 0);
38002
- const shouldHideComponent = noCustomersExist || isReadOnly && selectedCustomer === null;
38003
- if (shouldHideComponent) {
38004
- return null;
38005
- }
38545
+ const inputId = (0, import_react232.useId)();
38006
38546
  const isLoadingWithoutFallback = isLoading && !data;
38007
38547
  const shouldDisableComboBox = isLoadingWithoutFallback || isError;
38008
- return /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(VStack, { className: combinedClassName, children: [
38009
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(Label, { htmlFor: inputId, size: "sm", children: "Customer" }),
38010
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
38548
+ return /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(VStack, { className: combinedClassName, children: [
38549
+ /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(Label, { htmlFor: inputId, size: "sm", children: "Customer" }),
38550
+ /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(
38011
38551
  ComboBox,
38012
38552
  {
38013
38553
  selectedValue: selectedCustomerForComboBox,
38014
38554
  onSelectedValueChange: handleSelectionChange,
38015
- options,
38555
+ options: options2,
38016
38556
  onInputValueChange: handleInputChange,
38017
38557
  inputId,
38018
38558
  placeholder,
38019
38559
  slots: { EmptyMessage, ErrorMessage },
38020
- isDisabled: isReadOnly || shouldDisableComboBox,
38560
+ isDisabled: shouldDisableComboBox,
38021
38561
  isError,
38022
- isLoading: isLoadingWithoutFallback
38562
+ isLoading: isLoadingWithoutFallback,
38563
+ isReadOnly
38023
38564
  }
38024
38565
  )
38025
38566
  ] });
38026
38567
  }
38027
38568
 
38028
38569
  // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
38029
- var import_jsx_runtime339 = require("react/jsx-runtime");
38570
+ var import_lucide_react17 = require("lucide-react");
38571
+ var import_jsx_runtime341 = require("react/jsx-runtime");
38030
38572
  var INVOICE_FORM_CSS_PREFIX = "Layer__InvoiceForm";
38031
38573
  var INVOICE_FORM_FIELD_CSS_PREFIX = `${INVOICE_FORM_CSS_PREFIX}__Field`;
38032
- var InvoiceForm = (props) => {
38033
- const { onSuccess, mode } = props;
38034
- const { form } = useInvoiceForm(
38574
+ var getDueAtChanged = (dueAt, previousDueAt) => dueAt === null && previousDueAt !== null || dueAt !== null && previousDueAt === null || dueAt !== null && previousDueAt !== null && dueAt.compare(previousDueAt) !== 0;
38575
+ var InvoiceFormTotalRow = ({ label, value, children }) => {
38576
+ const className = (0, import_classnames92.default)(
38577
+ `${INVOICE_FORM_CSS_PREFIX}__TotalRow`,
38578
+ children && `${INVOICE_FORM_CSS_PREFIX}__TotalRow--withField`
38579
+ );
38580
+ return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(HStack, { className, align: "center", gap: "md", children: [
38581
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Span, { children: label }),
38582
+ children,
38583
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Span, { align: "right", children: convertCentsToCurrency(convertBigDecimalToCents(value)) })
38584
+ ] });
38585
+ };
38586
+ var InvoiceForm = (0, import_react233.forwardRef)((props, ref) => {
38587
+ const { onSuccess, onChangeFormState, isReadOnly, mode } = props;
38588
+ const { form, formState, totals } = useInvoiceForm(
38035
38589
  __spreadValues({ onSuccess }, mode === "Update" /* Update */ ? { mode, invoice: props.invoice } : { mode })
38036
38590
  );
38037
- return /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(Form, { className: INVOICE_FORM_CSS_PREFIX, children: [
38038
- /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__Metadata`, gap: "xs", children: [
38039
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
38040
- form.Field,
38041
- {
38042
- name: "customer",
38043
- listeners: {
38044
- onChange: ({ value: customer }) => {
38045
- form.setFieldValue("email", customer == null ? void 0 : customer.email);
38046
- form.setFieldValue("address", customer == null ? void 0 : customer.addressString);
38047
- }
38048
- },
38049
- children: (field) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
38050
- CustomerSelector,
38051
- {
38052
- className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Customer`,
38053
- selectedCustomer: field.state.value,
38054
- onSelectedCustomerChange: field.handleChange,
38055
- inline: true
38056
- }
38057
- )
38058
- }
38059
- ),
38060
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(form.AppField, { name: "email", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(field.FormTextField, { label: "Email", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Email` }) }),
38061
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(form.AppField, { name: "address", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(field.FormTextAreaField, { label: "Billing address", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Address` }) })
38062
- ] }),
38063
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__LineItems`, gap: "xs", children: /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(form.AppField, { name: "lineItems", mode: "array", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(VStack, { gap: "xs", align: "baseline", children: [
38064
- field.state.value.map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(HStack, { gap: "xs", align: "end", className: `${INVOICE_FORM_CSS_PREFIX}__LineItem`, children: [
38065
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(form.AppField, { name: `lineItems[${index}].product`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(innerField.FormTextField, { label: "Product", showLabel: index === 0 }) }),
38066
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(form.AppField, { name: `lineItems[${index}].description`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(innerField.FormTextField, { label: "Description", showLabel: index === 0 }) }),
38067
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
38068
- form.AppField,
38591
+ const { subtotal, additionalDiscount, taxableSubtotal, taxes, grandTotal } = totals;
38592
+ const lastDueAtRef = (0, import_react233.useRef)(null);
38593
+ const updateDueAtFromTermsAndSentAt = (0, import_react233.useCallback)((terms, sentAt) => {
38594
+ if (sentAt == null) return;
38595
+ const duration = getDurationInDaysFromTerms(terms);
38596
+ if (!duration) return;
38597
+ const newDueAt = sentAt.add({ days: duration });
38598
+ const dueAtChanged = getDueAtChanged(lastDueAtRef.current, newDueAt);
38599
+ if (dueAtChanged) {
38600
+ form.setFieldValue("dueAt", newDueAt);
38601
+ lastDueAtRef.current = newDueAt;
38602
+ }
38603
+ }, [form]);
38604
+ const blockNativeOnSubmit = (0, import_react233.useCallback)((e) => {
38605
+ e.preventDefault();
38606
+ e.stopPropagation();
38607
+ }, []);
38608
+ (0, import_react233.useImperativeHandle)(ref, () => ({
38609
+ submit: () => form.handleSubmit()
38610
+ }));
38611
+ (0, import_react233.useEffect)(() => {
38612
+ onChangeFormState == null ? void 0 : onChangeFormState(formState);
38613
+ }, [formState, onChangeFormState]);
38614
+ return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(Form, { className: INVOICE_FORM_CSS_PREFIX, onSubmit: blockNativeOnSubmit, children: [
38615
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.Subscribe, { selector: (state) => state.errorMap, children: (errorMap) => {
38616
+ const validationErrors = flattenValidationErrors(errorMap);
38617
+ if (validationErrors.length > 0) {
38618
+ return /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(HStack, { className: "Layer__InvoiceForm__FormError", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38619
+ DataState,
38069
38620
  {
38070
- name: `lineItems[${index}].quantity`,
38621
+ className: "Layer__InvoiceForm__FormError__DataState",
38622
+ icon: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_lucide_react17.AlertTriangle, { size: 16 }),
38623
+ status: "failed" /* failed */,
38624
+ title: validationErrors[0],
38625
+ titleSize: "md" /* md */,
38626
+ inline: true
38627
+ }
38628
+ ) });
38629
+ }
38630
+ } }),
38631
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(HStack, { gap: "xl", className: `${INVOICE_FORM_CSS_PREFIX}__Terms`, children: [
38632
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(VStack, { gap: "xs", children: [
38633
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38634
+ form.Field,
38635
+ {
38636
+ name: "customer",
38071
38637
  listeners: {
38072
- onBlur: ({ value: quantity }) => {
38073
- const unitPrice = form.getFieldValue(`lineItems[${index}].unitPrice`);
38074
- const nextAmount = import_effect15.BigDecimal.multiply(convertCentsToBigDecimal(unitPrice), quantity);
38075
- form.setFieldValue(`lineItems[${index}].amount`, convertBigDecimalToCents(nextAmount));
38638
+ onChange: ({ value: customer }) => {
38639
+ form.setFieldValue("email", (customer == null ? void 0 : customer.email) || "");
38640
+ form.setFieldValue("address", (customer == null ? void 0 : customer.addressString) || "");
38076
38641
  }
38077
38642
  },
38078
- children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(innerField.FormBigDecimalField, { label: "Quantity", showLabel: index === 0 })
38643
+ children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38644
+ CustomerSelector,
38645
+ {
38646
+ className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Customer`,
38647
+ selectedCustomer: field.state.value,
38648
+ onSelectedCustomerChange: field.handleChange,
38649
+ isReadOnly,
38650
+ inline: true
38651
+ }
38652
+ )
38079
38653
  }
38080
38654
  ),
38081
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
38655
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.AppField, { name: "email", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(field.FormTextField, { label: "Email", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Email`, isReadOnly: true }) }),
38656
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.AppField, { name: "address", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(field.FormTextAreaField, { label: "Billing address", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Address`, isReadOnly: true }) })
38657
+ ] }),
38658
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(VStack, { gap: "xs", children: [
38659
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.AppField, { name: "invoiceNumber", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(field.FormTextField, { label: "Invoice number", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__InvoiceNo`, isReadOnly }) }),
38660
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38661
+ form.Field,
38662
+ {
38663
+ name: "terms",
38664
+ listeners: {
38665
+ onChange: ({ value: terms }) => {
38666
+ const sentAt = form.getFieldValue("sentAt");
38667
+ updateDueAtFromTermsAndSentAt(terms, sentAt);
38668
+ }
38669
+ },
38670
+ children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38671
+ InvoiceTermsComboBox,
38672
+ {
38673
+ value: field.state.value,
38674
+ onValueChange: (value) => {
38675
+ if (value !== null) {
38676
+ field.handleChange(value);
38677
+ }
38678
+ },
38679
+ isReadOnly
38680
+ }
38681
+ )
38682
+ }
38683
+ ),
38684
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38082
38685
  form.AppField,
38083
38686
  {
38084
- name: `lineItems[${index}].unitPrice`,
38687
+ name: "sentAt",
38085
38688
  listeners: {
38086
- onBlur: ({ value: unitPrice }) => {
38087
- const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38088
- const nextAmount = import_effect15.BigDecimal.multiply(convertCentsToBigDecimal(unitPrice), quantity);
38089
- form.setFieldValue(`lineItems[${index}].amount`, convertBigDecimalToCents(nextAmount));
38689
+ onBlur: ({ value: sentAt }) => {
38690
+ const terms = form.getFieldValue("terms");
38691
+ updateDueAtFromTermsAndSentAt(terms, sentAt);
38090
38692
  }
38091
38693
  },
38092
- children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(innerField.FormCurrencyField, { label: "Rate", showLabel: index === 0 })
38694
+ children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(field.FormDateField, { label: "Invoice date", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__SentAt`, isReadOnly })
38093
38695
  }
38094
38696
  ),
38095
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
38697
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38096
38698
  form.AppField,
38097
38699
  {
38098
- name: `lineItems[${index}].amount`,
38700
+ name: "dueAt",
38099
38701
  listeners: {
38100
- onBlur: ({ value: amount }) => {
38101
- const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38102
- let nextUnitPrice = BIG_DECIMAL_ZERO;
38103
- try {
38104
- nextUnitPrice = import_effect15.BigDecimal.unsafeDivide(convertCentsToBigDecimal(amount), quantity);
38105
- } catch (e) {
38702
+ onBlur: ({ value: dueAt }) => {
38703
+ const terms = form.getFieldValue("terms");
38704
+ const previousDueAt = lastDueAtRef.current;
38705
+ const dueAtChanged = getDueAtChanged(dueAt, previousDueAt);
38706
+ if (terms !== "Custom" /* Custom */ && dueAtChanged) {
38707
+ form.setFieldValue("terms", "Custom" /* Custom */);
38708
+ lastDueAtRef.current = dueAt;
38106
38709
  }
38107
- form.setFieldValue(`lineItems[${index}].unitPrice`, convertBigDecimalToCents(nextUnitPrice));
38108
38710
  }
38109
38711
  },
38110
- children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(innerField.FormCurrencyField, { label: "Amount", showLabel: index === 0 })
38712
+ children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(field.FormDateField, { label: "Due date", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__DueAt`, isReadOnly })
38111
38713
  }
38112
- ),
38113
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(form.AppField, { name: `lineItems[${index}].isTaxable`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(innerField.FormCheckboxField, { label: "Tax", showLabel: index === 0 }) }),
38114
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(Button2, { variant: "outlined", icon: true, "aria-label": "Delete line item", onClick: () => field.removeValue(index), children: /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(import_lucide_react16.Trash, { size: 16 }) })
38115
- ] }, `lineItems[${index}]`)),
38116
- /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(Button2, { variant: "outlined", onClick: () => field.pushValue(EMPTY_LINE_ITEM), children: [
38117
- "Add line item",
38118
- /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(import_lucide_react16.Plus, { size: 16 })
38714
+ )
38119
38715
  ] })
38120
- ] }) }) })
38716
+ ] }),
38717
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__LineItems`, gap: "md", children: [
38718
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.Field, { name: "lineItems", mode: "array", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(VStack, { gap: "xs", align: "baseline", children: [
38719
+ field.state.value.map((_value, index) => (
38720
+ /**
38721
+ * A more correct implementation would use a UUID as the key for this HStack. Specifically, it is an antipattern in
38722
+ * React to use array indices as keys. However, there are some ongoing issues with @tanstack/react-form related to
38723
+ * deleting an element from an array field. In particular, the form values for the remaining array items may become
38724
+ * momentarily undefined as they re-render due to re-indexing. Thus, we use indices here for now.
38725
+ * See here for more information: https://github.com/TanStack/form/issues/1518.
38726
+ */
38727
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(
38728
+ HStack,
38729
+ {
38730
+ gap: "xs",
38731
+ align: "end",
38732
+ className: (0, import_classnames92.default)(`${INVOICE_FORM_CSS_PREFIX}__LineItem`, isReadOnly && `${INVOICE_FORM_CSS_PREFIX}__LineItem--readonly`),
38733
+ children: [
38734
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.AppField, { name: `lineItems[${index}].product`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(innerField.FormTextField, { label: "Product/Service", showLabel: index === 0, isReadOnly }) }),
38735
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.AppField, { name: `lineItems[${index}].description`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(innerField.FormTextField, { label: "Description", showLabel: index === 0, isReadOnly }) }),
38736
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38737
+ form.AppField,
38738
+ {
38739
+ name: `lineItems[${index}].quantity`,
38740
+ listeners: {
38741
+ onBlur: ({ value: quantity }) => {
38742
+ const amount = form.getFieldValue(`lineItems[${index}].amount`);
38743
+ const unitPrice = form.getFieldValue(`lineItems[${index}].unitPrice`);
38744
+ const nextAmount = import_effect17.BigDecimal.multiply(unitPrice, quantity);
38745
+ if (!import_effect17.BigDecimal.equals(amount, nextAmount)) {
38746
+ form.setFieldValue(`lineItems[${index}].amount`, withForceUpdate(nextAmount));
38747
+ }
38748
+ }
38749
+ },
38750
+ children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(innerField.FormBigDecimalField, { label: "Quantity", showLabel: index === 0, isReadOnly })
38751
+ }
38752
+ ),
38753
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38754
+ form.AppField,
38755
+ {
38756
+ name: `lineItems[${index}].unitPrice`,
38757
+ listeners: {
38758
+ onBlur: ({ value: unitPrice }) => {
38759
+ const amount = form.getFieldValue(`lineItems[${index}].amount`);
38760
+ const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38761
+ const nextAmount = import_effect17.BigDecimal.multiply(unitPrice, quantity);
38762
+ if (!import_effect17.BigDecimal.equals(amount, nextAmount)) {
38763
+ form.setFieldValue(`lineItems[${index}].amount`, withForceUpdate(nextAmount));
38764
+ }
38765
+ }
38766
+ },
38767
+ children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(innerField.FormBigDecimalField, { label: "Rate", mode: "currency", showLabel: index === 0, allowNegative: true, isReadOnly })
38768
+ }
38769
+ ),
38770
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38771
+ form.AppField,
38772
+ {
38773
+ name: `lineItems[${index}].amount`,
38774
+ listeners: {
38775
+ onBlur: ({ value: amount }) => {
38776
+ const unitPrice = form.getFieldValue(`lineItems[${index}].unitPrice`);
38777
+ const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38778
+ const nextUnitPrice = safeDivide(amount, quantity);
38779
+ if (!import_effect17.BigDecimal.equals(unitPrice, nextUnitPrice)) {
38780
+ form.setFieldValue(`lineItems[${index}].unitPrice`, withForceUpdate(nextUnitPrice));
38781
+ }
38782
+ }
38783
+ },
38784
+ children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(innerField.FormBigDecimalField, { label: "Amount", mode: "currency", showLabel: index === 0, allowNegative: true, isReadOnly })
38785
+ }
38786
+ ),
38787
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.AppField, { name: `lineItems[${index}].isTaxable`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(innerField.FormCheckboxField, { label: "Tax", showLabel: index === 0, isReadOnly }) }),
38788
+ !isReadOnly && /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Button2, { variant: "outlined", icon: true, "aria-label": "Delete line item", onClick: () => field.removeValue(index), children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_lucide_react16.Trash, { size: 16 }) })
38789
+ ]
38790
+ },
38791
+ index
38792
+ )
38793
+ )),
38794
+ !isReadOnly && /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(Button2, { variant: "outlined", onClick: () => field.pushValue(getEmptyLineItem()), children: [
38795
+ "Add line item",
38796
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_lucide_react16.Plus, { size: 16 })
38797
+ ] })
38798
+ ] }) }),
38799
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__Metadata`, pbs: "md", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(HStack, { justify: "space-between", gap: "xl", children: [
38800
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__AdditionalTextFields`, children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.AppField, { name: "memo", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(field.FormTextAreaField, { label: "Memo", isReadOnly }) }) }),
38801
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__TotalFields`, fluid: true, children: [
38802
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceFormTotalRow, { label: "Subtotal", value: subtotal }),
38803
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceFormTotalRow, { label: "Discount", value: negate(additionalDiscount), children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.AppField, { name: "discountRate", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(field.FormBigDecimalField, { label: "Discount", showLabel: false, mode: "percent", isReadOnly }) }) }),
38804
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceFormTotalRow, { label: "Taxable subtotal", value: taxableSubtotal }),
38805
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceFormTotalRow, { label: "Tax rate", value: taxes, children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(form.AppField, { name: "taxRate", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(field.FormBigDecimalField, { label: "Tax Rate", showLabel: false, mode: "percent", isReadOnly }) }) }),
38806
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceFormTotalRow, { label: "Total", value: grandTotal })
38807
+ ] })
38808
+ ] }) })
38809
+ ] })
38121
38810
  ] });
38122
- };
38811
+ });
38812
+ InvoiceForm.displayName = "InvoiceForm";
38123
38813
 
38124
38814
  // src/components/DataPoint/DataPoint.tsx
38125
- var import_jsx_runtime340 = require("react/jsx-runtime");
38815
+ var import_jsx_runtime342 = require("react/jsx-runtime");
38126
38816
  var DataPoint = ({ label, children }) => {
38127
- return /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(VStack, { gap: "3xs", children: [
38128
- /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(Span, { variant: "subtle", size: "xs", children: label }),
38817
+ return /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)(VStack, { gap: "3xs", children: [
38818
+ /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(Span, { variant: "subtle", size: "xs", children: label }),
38129
38819
  children
38130
38820
  ] });
38131
38821
  };
38132
38822
 
38133
38823
  // src/components/Invoices/InvoiceStatusCell/InvoiceStatusCell.tsx
38134
38824
  var import_pluralize6 = __toESM(require("pluralize"));
38135
- var import_jsx_runtime341 = require("react/jsx-runtime");
38825
+ var import_jsx_runtime343 = require("react/jsx-runtime");
38136
38826
  var getDueStatusConfig = (invoice, { inline }) => {
38137
38827
  const badgeSize = inline ? "xs" /* EXTRA_SMALL */ : "small" /* SMALL */;
38138
38828
  const iconSize = inline ? 10 : 12;
@@ -38146,7 +38836,7 @@ var getDueStatusConfig = (invoice, { inline }) => {
38146
38836
  case "PAID" /* Paid */: {
38147
38837
  return {
38148
38838
  text: "Paid",
38149
- badge: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Badge, { variant: "success" /* SUCCESS */, size: badgeSize, icon: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(CheckCircle_default, { size: iconSize }), iconOnly: true })
38839
+ badge: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Badge, { variant: "success" /* SUCCESS */, size: badgeSize, icon: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(CheckCircle_default, { size: iconSize }), iconOnly: true })
38150
38840
  };
38151
38841
  }
38152
38842
  case "VOIDED" /* Voided */: {
@@ -38169,7 +38859,7 @@ var getDueStatusConfig = (invoice, { inline }) => {
38169
38859
  return {
38170
38860
  text: "Overdue",
38171
38861
  subText: `Due ${(0, import_pluralize6.default)("day", Math.abs(dueDifference), true)} ago`,
38172
- badge: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Badge, { variant: "warning" /* WARNING */, size: badgeSize, icon: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(AlertCircle_default, { size: iconSize }), iconOnly: true })
38862
+ badge: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Badge, { variant: "warning" /* WARNING */, size: badgeSize, icon: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(AlertCircle_default, { size: iconSize }), iconOnly: true })
38173
38863
  };
38174
38864
  }
38175
38865
  return {
@@ -38189,73 +38879,117 @@ var InvoiceStatusCell = ({ invoice, inline = false }) => {
38189
38879
  const dueStatus = getDueStatusConfig(invoice, { inline });
38190
38880
  const Stack3 = inline ? HStack : VStack;
38191
38881
  const subText = inline && dueStatus.subText ? `(${dueStatus.subText})` : dueStatus.subText;
38192
- return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(HStack, { gap: "xs", align: "center", children: [
38882
+ return /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(HStack, { gap: "xs", align: "center", children: [
38193
38883
  dueStatus.badge,
38194
- /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(Stack3, __spreadProps(__spreadValues({}, inline && { gap: "3xs", align: "center" }), { children: [
38195
- /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Span, { children: dueStatus.text }),
38196
- subText && /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Span, { variant: "subtle", size: "sm", children: subText })
38884
+ /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(Stack3, __spreadProps(__spreadValues({}, inline && { gap: "3xs", align: "center" }), { children: [
38885
+ /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Span, { children: dueStatus.text }),
38886
+ subText && /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Span, { variant: "subtle", size: "sm", children: subText })
38197
38887
  ] }))
38198
38888
  ] });
38199
38889
  };
38200
38890
 
38201
38891
  // src/components/Invoices/InvoiceDetail/InvoiceDetail.tsx
38202
- var import_jsx_runtime342 = require("react/jsx-runtime");
38892
+ var import_lucide_react18 = require("lucide-react");
38893
+ var import_jsx_runtime344 = require("react/jsx-runtime");
38203
38894
  var InvoiceDetail = (props) => {
38204
- const _a = props, { onSuccess: _onSuccess, onGoBack } = _a, restProps = __objRest(_a, ["onSuccess", "onGoBack"]);
38205
- const Header6 = (0, import_react232.useCallback)(() => {
38206
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(InvoiceDetailHeader, __spreadValues({}, restProps));
38207
- }, [restProps]);
38208
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)(BaseDetailView, { slots: { Header: Header6 }, name: "Invoice Detail View", onGoBack, children: [
38209
- restProps.mode === "Update" /* Update */ && /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(InvoiceDetailSubHeader, { invoice: restProps.invoice }),
38210
- /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(InvoiceForm, __spreadValues({}, props))
38895
+ const _a = props, { onSuccess, onGoBack } = _a, restProps = __objRest(_a, ["onSuccess", "onGoBack"]);
38896
+ const [isReadOnly, setIsReadOnly] = (0, import_react234.useState)(props.mode === "Update" /* Update */);
38897
+ const formRef = (0, import_react234.useRef)(null);
38898
+ const onSubmit = (0, import_react234.useCallback)(() => {
38899
+ var _a2;
38900
+ return (_a2 = formRef.current) == null ? void 0 : _a2.submit();
38901
+ }, []);
38902
+ const [formState, setFormState] = (0, import_react234.useState)({
38903
+ isFormValid: true,
38904
+ isSubmitting: false,
38905
+ submitError: void 0
38906
+ });
38907
+ const onChangeFormState = (0, import_react234.useCallback)((nextState) => {
38908
+ setFormState(nextState);
38909
+ }, []);
38910
+ const Header6 = (0, import_react234.useCallback)(() => {
38911
+ return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
38912
+ InvoiceDetailHeader,
38913
+ __spreadValues({
38914
+ onSubmit,
38915
+ isReadOnly,
38916
+ formState,
38917
+ setIsReadOnly
38918
+ }, restProps)
38919
+ );
38920
+ }, [onSubmit, isReadOnly, formState, restProps]);
38921
+ return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(BaseDetailView, { slots: { Header: Header6 }, name: "Invoice Detail View", onGoBack, children: [
38922
+ restProps.mode === "Update" /* Update */ && /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(InvoiceDetailSubHeader, { invoice: restProps.invoice }),
38923
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
38924
+ InvoiceForm,
38925
+ __spreadProps(__spreadValues({
38926
+ isReadOnly,
38927
+ onSuccess,
38928
+ onChangeFormState
38929
+ }, restProps), {
38930
+ ref: formRef
38931
+ })
38932
+ )
38211
38933
  ] });
38212
38934
  };
38213
38935
  var InvoiceDetailHeader = (props) => {
38214
- const { mode } = props;
38936
+ const { mode, onSubmit, formState, isReadOnly, setIsReadOnly } = props;
38937
+ const { isSubmitting } = formState;
38215
38938
  if (mode === "Create" /* Create */) {
38216
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(Heading2, { children: "Create Invoice" });
38939
+ return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", children: [
38940
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Heading2, { children: "Create Invoice" }),
38941
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Button2, { isPending: isSubmitting, onPress: onSubmit, children: "Review & Send" })
38942
+ ] });
38217
38943
  }
38218
38944
  const invoice = props.invoice;
38219
38945
  const { invoiceNumber } = invoice;
38220
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(Heading2, { children: invoiceNumber ? `Invoice ${invoiceNumber}` : "View Invoice" });
38946
+ return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", children: [
38947
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Heading2, { children: invoiceNumber ? `Invoice ${invoiceNumber}` : "View Invoice" }),
38948
+ isReadOnly ? /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(Button2, { onPress: () => {
38949
+ setIsReadOnly(false);
38950
+ }, children: [
38951
+ "Edit Invoice",
38952
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(import_lucide_react18.SquarePen, { size: 14 })
38953
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Button2, { isPending: isSubmitting, onPress: onSubmit, children: "Review & Resend" })
38954
+ ] });
38221
38955
  };
38222
38956
  var InvoiceDetailSubHeader = ({ invoice }) => {
38223
38957
  const { outstandingBalance, totalAmount } = invoice;
38224
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(HStack, { className: "Layer__InvoiceDetail__SubHeader", children: /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)(HStack, { gap: "5xl", children: [
38225
- /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(DataPoint, { label: "Balance due", children: /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(Span, { children: convertCentsToCurrency(outstandingBalance) }) }),
38226
- /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(DataPoint, { label: "Open balance", children: /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(Span, { children: convertCentsToCurrency(totalAmount) }) }),
38227
- /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(DataPoint, { label: "Status", children: /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(InvoiceStatusCell, { invoice, inline: true }) })
38958
+ return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(HStack, { className: "Layer__InvoiceDetail__SubHeader", children: /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(HStack, { gap: "5xl", children: [
38959
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(DataPoint, { label: "Balance due", children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Span, { children: convertCentsToCurrency(outstandingBalance) }) }),
38960
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(DataPoint, { label: "Open balance", children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Span, { children: convertCentsToCurrency(totalAmount) }) }),
38961
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(DataPoint, { label: "Status", children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(InvoiceStatusCell, { invoice, inline: true }) })
38228
38962
  ] }) });
38229
38963
  };
38230
38964
 
38231
38965
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38232
- var import_react237 = require("react");
38966
+ var import_react239 = require("react");
38233
38967
 
38234
38968
  // src/features/invoices/api/useListInvoices.tsx
38235
38969
  var import_infinite7 = __toESM(require("swr/infinite"));
38236
- var import_react233 = require("react");
38237
- var import_lodash6 = __toESM(require_lodash());
38238
- var import_effect17 = require("effect");
38970
+ var import_react235 = require("react");
38971
+ var import_lodash7 = __toESM(require_lodash());
38972
+ var import_effect19 = require("effect");
38239
38973
 
38240
38974
  // src/types/utility/pagination.ts
38241
- var import_effect16 = require("effect");
38242
- var PaginatedResponseMetaSchema = import_effect16.Schema.Struct({
38243
- cursor: import_effect16.Schema.NullOr(import_effect16.Schema.String),
38244
- hasMore: (0, import_effect16.pipe)(
38245
- import_effect16.Schema.propertySignature(import_effect16.Schema.Boolean),
38246
- import_effect16.Schema.fromKey("has_more")
38975
+ var import_effect18 = require("effect");
38976
+ var PaginatedResponseMetaSchema = import_effect18.Schema.Struct({
38977
+ cursor: import_effect18.Schema.NullOr(import_effect18.Schema.String),
38978
+ hasMore: (0, import_effect18.pipe)(
38979
+ import_effect18.Schema.propertySignature(import_effect18.Schema.Boolean),
38980
+ import_effect18.Schema.fromKey("has_more")
38247
38981
  ),
38248
- totalCount: (0, import_effect16.pipe)(
38249
- import_effect16.Schema.propertySignature(import_effect16.Schema.UndefinedOr(import_effect16.Schema.Number)),
38250
- import_effect16.Schema.fromKey("total_count")
38982
+ totalCount: (0, import_effect18.pipe)(
38983
+ import_effect18.Schema.propertySignature(import_effect18.Schema.UndefinedOr(import_effect18.Schema.Number)),
38984
+ import_effect18.Schema.fromKey("total_count")
38251
38985
  )
38252
38986
  });
38253
38987
 
38254
38988
  // src/features/invoices/api/useListInvoices.tsx
38255
38989
  var LIST_INVOICES_TAG_KEY = "#list-invoices";
38256
- var ListInvoicesReturnSchema = import_effect17.Schema.Struct({
38257
- data: import_effect17.Schema.Array(InvoiceSchema),
38258
- meta: import_effect17.Schema.Struct({
38990
+ var ListInvoicesReturnSchema = import_effect19.Schema.Struct({
38991
+ data: import_effect19.Schema.Array(InvoiceSchema),
38992
+ meta: import_effect19.Schema.Struct({
38259
38993
  pagination: PaginatedResponseMetaSchema
38260
38994
  })
38261
38995
  });
@@ -38383,7 +39117,7 @@ function useListInvoices({
38383
39117
  showTotalCount: showTotalCount2
38384
39118
  }
38385
39119
  }
38386
- )().then(import_effect17.Schema.decodeUnknownPromise(ListInvoicesReturnSchema)),
39120
+ )().then(import_effect19.Schema.decodeUnknownPromise(ListInvoicesReturnSchema)),
38387
39121
  {
38388
39122
  keepPreviousData: true,
38389
39123
  revalidateFirstPage: false,
@@ -38397,20 +39131,20 @@ function useListInvoices({
38397
39131
  var import_react_table2 = require("@tanstack/react-table");
38398
39132
 
38399
39133
  // src/components/DataTable/DataTable.tsx
38400
- var import_react235 = require("react");
39134
+ var import_react237 = require("react");
38401
39135
 
38402
39136
  // src/components/ui/Table/Table.tsx
38403
- var import_react234 = require("react");
38404
- var import_react_aria_components18 = require("react-aria-components");
38405
- var import_classnames91 = __toESM(require("classnames"));
38406
- var import_jsx_runtime343 = require("react/jsx-runtime");
39137
+ var import_react236 = require("react");
39138
+ var import_react_aria_components19 = require("react-aria-components");
39139
+ var import_classnames93 = __toESM(require("classnames"));
39140
+ var import_jsx_runtime345 = require("react/jsx-runtime");
38407
39141
  var CSS_PREFIX2 = "Layer__UI__Table";
38408
- var getClassName = (component, additionalClassNames) => (0, import_classnames91.default)(`${CSS_PREFIX2}-${component}`, additionalClassNames);
38409
- var Table2 = (0, import_react234.forwardRef)(
39142
+ var getClassName = (component, additionalClassNames) => (0, import_classnames93.default)(`${CSS_PREFIX2}-${component}`, additionalClassNames);
39143
+ var Table2 = (0, import_react236.forwardRef)(
38410
39144
  (_a, ref) => {
38411
39145
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38412
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(
38413
- import_react_aria_components18.Table,
39146
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39147
+ import_react_aria_components19.Table,
38414
39148
  __spreadProps(__spreadValues({
38415
39149
  className: getClassName("Table" /* Table */, className)
38416
39150
  }, restProps), {
@@ -38423,8 +39157,8 @@ var Table2 = (0, import_react234.forwardRef)(
38423
39157
  Table2.displayName = "Table" /* Table */;
38424
39158
  var TableHeaderInner = (_a, ref) => {
38425
39159
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38426
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(
38427
- import_react_aria_components18.TableHeader,
39160
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39161
+ import_react_aria_components19.TableHeader,
38428
39162
  __spreadProps(__spreadValues({
38429
39163
  className: getClassName("TableHeader" /* TableHeader */, className)
38430
39164
  }, restProps), {
@@ -38433,12 +39167,12 @@ var TableHeaderInner = (_a, ref) => {
38433
39167
  })
38434
39168
  );
38435
39169
  };
38436
- var TableHeader = (0, import_react234.forwardRef)(TableHeaderInner);
39170
+ var TableHeader = (0, import_react236.forwardRef)(TableHeaderInner);
38437
39171
  TableHeader.displayName = "TableHeader" /* TableHeader */;
38438
39172
  var TableBodyInner = (_a, ref) => {
38439
39173
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38440
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(
38441
- import_react_aria_components18.TableBody,
39174
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39175
+ import_react_aria_components19.TableBody,
38442
39176
  __spreadProps(__spreadValues({
38443
39177
  className: getClassName("TableBody" /* TableBody */, className)
38444
39178
  }, restProps), {
@@ -38447,12 +39181,12 @@ var TableBodyInner = (_a, ref) => {
38447
39181
  })
38448
39182
  );
38449
39183
  };
38450
- var TableBody2 = (0, import_react234.forwardRef)(TableBodyInner);
39184
+ var TableBody2 = (0, import_react236.forwardRef)(TableBodyInner);
38451
39185
  TableBody2.displayName = "TableBody" /* TableBody */;
38452
39186
  var RowInner = (_a, ref) => {
38453
39187
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38454
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(
38455
- import_react_aria_components18.Row,
39188
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39189
+ import_react_aria_components19.Row,
38456
39190
  __spreadProps(__spreadValues({
38457
39191
  className: getClassName("Row" /* Row */, className)
38458
39192
  }, restProps), {
@@ -38461,14 +39195,14 @@ var RowInner = (_a, ref) => {
38461
39195
  })
38462
39196
  );
38463
39197
  };
38464
- var Row2 = (0, import_react234.forwardRef)(RowInner);
39198
+ var Row2 = (0, import_react236.forwardRef)(RowInner);
38465
39199
  Row2.displayName = "Row" /* Row */;
38466
- var Column = (0, import_react234.forwardRef)(
39200
+ var Column = (0, import_react236.forwardRef)(
38467
39201
  (_a, ref) => {
38468
39202
  var _b = _a, { children, className, textAlign = "left" } = _b, restProps = __objRest(_b, ["children", "className", "textAlign"]);
38469
39203
  const dataProperties = toDataProperties({ "text-align": textAlign });
38470
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(
38471
- import_react_aria_components18.Column,
39204
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39205
+ import_react_aria_components19.Column,
38472
39206
  __spreadProps(__spreadValues(__spreadValues({
38473
39207
  className: getClassName("Column" /* Column */, className)
38474
39208
  }, restProps), dataProperties), {
@@ -38479,11 +39213,11 @@ var Column = (0, import_react234.forwardRef)(
38479
39213
  }
38480
39214
  );
38481
39215
  Column.displayName = "Column" /* Column */;
38482
- var Cell5 = (0, import_react234.forwardRef)(
39216
+ var Cell5 = (0, import_react236.forwardRef)(
38483
39217
  (_a, ref) => {
38484
39218
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38485
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(
38486
- import_react_aria_components18.Cell,
39219
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39220
+ import_react_aria_components19.Cell,
38487
39221
  __spreadProps(__spreadValues({
38488
39222
  className: getClassName("Cell" /* Cell */, className)
38489
39223
  }, restProps), {
@@ -38496,7 +39230,7 @@ var Cell5 = (0, import_react234.forwardRef)(
38496
39230
  Cell5.displayName = "Cell" /* Cell */;
38497
39231
 
38498
39232
  // src/components/DataTable/DataTable.tsx
38499
- var import_jsx_runtime344 = require("react/jsx-runtime");
39233
+ var import_jsx_runtime346 = require("react/jsx-runtime");
38500
39234
  var DataTable = ({
38501
39235
  columnConfig,
38502
39236
  data,
@@ -38509,17 +39243,17 @@ var DataTable = ({
38509
39243
  const columns = Object.values(columnConfig);
38510
39244
  const { EmptyState, ErrorState } = slots;
38511
39245
  const isEmptyTable = (data == null ? void 0 : data.length) === 0;
38512
- const renderTableBody = (0, import_react235.useMemo)(() => {
39246
+ const renderTableBody = (0, import_react237.useMemo)(() => {
38513
39247
  if (isError) {
38514
- return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(ErrorState, {}) }) });
39248
+ return /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(ErrorState, {}) }) });
38515
39249
  }
38516
39250
  if (isLoading) {
38517
- return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Loader2, {}) }) });
39251
+ return /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Loader2, {}) }) });
38518
39252
  }
38519
39253
  if (isEmptyTable) {
38520
- return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(EmptyState, {}) }) });
39254
+ return /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(EmptyState, {}) }) });
38521
39255
  }
38522
- const RowRenderer = (row) => /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Row2, { children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
39256
+ const RowRenderer = (row) => /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Row2, { children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(
38523
39257
  Cell5,
38524
39258
  {
38525
39259
  className: `Layer__UI__Table-Cell__${componentName}--${col.id}`,
@@ -38530,15 +39264,15 @@ var DataTable = ({
38530
39264
  RowRenderer.displayName = "Row";
38531
39265
  return RowRenderer;
38532
39266
  }, [isError, isLoading, isEmptyTable, columns, ErrorState, EmptyState, componentName]);
38533
- return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(Table2, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, children: [
38534
- /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(TableHeader, { columns, children: ({ id, header, isRowHeader }) => /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Column, { isRowHeader, className: `Layer__UI__Table-Column__${componentName}--${id}`, children: header }, id) }),
38535
- /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(TableBody2, { items: data, children: renderTableBody })
39267
+ return /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(Table2, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, children: [
39268
+ /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(TableHeader, { columns, children: ({ id, header, isRowHeader }) => /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Column, { isRowHeader, className: `Layer__UI__Table-Column__${componentName}--${id}`, children: header }, id) }),
39269
+ /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(TableBody2, { items: data, children: renderTableBody })
38536
39270
  ] });
38537
39271
  };
38538
39272
 
38539
39273
  // src/components/DataTable/PaginatedTable.tsx
38540
- var import_react236 = require("react");
38541
- var import_jsx_runtime345 = require("react/jsx-runtime");
39274
+ var import_react238 = require("react");
39275
+ var import_jsx_runtime347 = require("react/jsx-runtime");
38542
39276
  var EMPTY_ARRAY = [];
38543
39277
  function PaginatedTable({
38544
39278
  data,
@@ -38551,7 +39285,7 @@ function PaginatedTable({
38551
39285
  slots
38552
39286
  }) {
38553
39287
  const { pageSize = 20, hasMore, fetchMore } = paginationProps;
38554
- const [pagination, setPagination] = (0, import_react236.useState)({ pageIndex: 0, pageSize });
39288
+ const [pagination, setPagination] = (0, import_react238.useState)({ pageIndex: 0, pageSize });
38555
39289
  const columnHelper = (0, import_react_table2.createColumnHelper)();
38556
39290
  const columns = Object.values(columnConfig);
38557
39291
  const columnDefs = columns.map((col) => {
@@ -38571,12 +39305,12 @@ function PaginatedTable({
38571
39305
  autoResetPageIndex: false
38572
39306
  });
38573
39307
  const { rows } = table.getRowModel();
38574
- const rowData = (0, import_react236.useMemo)(() => rows.map((r) => r.original), [rows]);
38575
- const onPageChange = (0, import_react236.useCallback)((page) => {
39308
+ const rowData = (0, import_react238.useMemo)(() => rows.map((r) => r.original), [rows]);
39309
+ const onPageChange = (0, import_react238.useCallback)((page) => {
38576
39310
  table.setPageIndex(page - 1);
38577
39311
  }, [table]);
38578
- return /* @__PURE__ */ (0, import_jsx_runtime345.jsxs)(VStack, { children: [
38579
- /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39312
+ return /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(VStack, { children: [
39313
+ /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
38580
39314
  DataTable,
38581
39315
  {
38582
39316
  ariaLabel,
@@ -38588,7 +39322,7 @@ function PaginatedTable({
38588
39322
  slots
38589
39323
  }
38590
39324
  ),
38591
- !isError && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39325
+ !isError && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
38592
39326
  Pagination,
38593
39327
  {
38594
39328
  currentPage: table.getState().pagination.pageIndex + 1,
@@ -38603,10 +39337,10 @@ function PaginatedTable({
38603
39337
  }
38604
39338
 
38605
39339
  // src/icons/ChevronRightFill.tsx
38606
- var import_jsx_runtime346 = require("react/jsx-runtime");
39340
+ var import_jsx_runtime348 = require("react/jsx-runtime");
38607
39341
  var ChevronRightFill = (_a) => {
38608
39342
  var _b = _a, { size = 18 } = _b, props = __objRest(_b, ["size"]);
38609
- return /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(
39343
+ return /* @__PURE__ */ (0, import_jsx_runtime348.jsxs)(
38610
39344
  "svg",
38611
39345
  __spreadProps(__spreadValues({
38612
39346
  xmlns: "http://www.w3.org/2000/svg",
@@ -38616,8 +39350,8 @@ var ChevronRightFill = (_a) => {
38616
39350
  width: size,
38617
39351
  height: size,
38618
39352
  children: [
38619
- /* @__PURE__ */ (0, import_jsx_runtime346.jsx)("path", { d: "M6.75 4.5L11.25 9L6.75 13.5", fill: "currentColor" }),
38620
- /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(
39353
+ /* @__PURE__ */ (0, import_jsx_runtime348.jsx)("path", { d: "M6.75 4.5L11.25 9L6.75 13.5", fill: "currentColor" }),
39354
+ /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
38621
39355
  "path",
38622
39356
  {
38623
39357
  d: "M6.75 4.5L11.25 9L6.75 13.5Z",
@@ -38633,37 +39367,37 @@ var ChevronRightFill = (_a) => {
38633
39367
  var ChevronRightFill_default = ChevronRightFill;
38634
39368
 
38635
39369
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38636
- var import_lucide_react17 = require("lucide-react");
39370
+ var import_lucide_react19 = require("lucide-react");
38637
39371
 
38638
39372
  // src/components/DataTable/DataTableHeader.tsx
38639
- var import_jsx_runtime347 = require("react/jsx-runtime");
39373
+ var import_jsx_runtime349 = require("react/jsx-runtime");
38640
39374
  var DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
38641
39375
  const { showCount, totalCount } = count != null ? count : {};
38642
39376
  const { Filters: Filters2, HeaderActions, HeaderFilters } = slots;
38643
- return /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(VStack, { children: [
38644
- /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(HStack, { justify: "space-between", align: "center", className: "Layer__DataTableHeader__Header", children: [
38645
- /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(HStack, { pis: "md", align: "center", gap: "xl", children: [
38646
- /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(HStack, { align: "center", gap: "sm", children: [
38647
- /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Span, { weight: "bold", size: "lg", children: name }),
38648
- showCount && (totalCount ? /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Badge, { variant: "default" /* DEFAULT */, size: "medium" /* MEDIUM */, children: totalCount }) : /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(BadgeLoader, {}))
39377
+ return /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)(VStack, { children: [
39378
+ /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)(HStack, { justify: "space-between", align: "center", className: "Layer__DataTableHeader__Header", children: [
39379
+ /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)(HStack, { pis: "md", align: "center", gap: "xl", children: [
39380
+ /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)(HStack, { align: "center", gap: "sm", children: [
39381
+ /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(Span, { weight: "bold", size: "lg", children: name }),
39382
+ showCount && (totalCount ? /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(Badge, { variant: "default" /* DEFAULT */, size: "medium" /* MEDIUM */, children: totalCount }) : /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(BadgeLoader, {}))
38649
39383
  ] }),
38650
- HeaderFilters && /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(HeaderFilters, {})
39384
+ HeaderFilters && /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(HeaderFilters, {})
38651
39385
  ] }),
38652
- /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(HStack, { pie: "md", align: "center", gap: "3xs", children: [
38653
- slotProps.SearchField && /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(SearchField, __spreadValues({}, slotProps.SearchField)),
38654
- HeaderActions && /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(HeaderActions, {})
39386
+ /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)(HStack, { pie: "md", align: "center", gap: "3xs", children: [
39387
+ slotProps.SearchField && /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(SearchField, __spreadValues({}, slotProps.SearchField)),
39388
+ HeaderActions && /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(HeaderActions, {})
38655
39389
  ] })
38656
39390
  ] }),
38657
- Filters2 && /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
38658
- /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Filters2, {}),
38659
- slotProps.ClearFiltersButton && /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Button2, __spreadProps(__spreadValues({ variant: "outlined" }, slotProps.ClearFiltersButton), { children: "Clear All Filters" }))
39391
+ Filters2 && /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
39392
+ /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(Filters2, {}),
39393
+ slotProps.ClearFiltersButton && /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(Button2, __spreadProps(__spreadValues({ variant: "outlined" }, slotProps.ClearFiltersButton), { children: "Clear All Filters" }))
38660
39394
  ] })
38661
39395
  ] });
38662
39396
  };
38663
39397
 
38664
39398
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38665
- var import_date_fns51 = require("date-fns");
38666
- var import_jsx_runtime348 = require("react/jsx-runtime");
39399
+ var import_date_fns53 = require("date-fns");
39400
+ var import_jsx_runtime350 = require("react/jsx-runtime");
38667
39401
  var COMPONENT_NAME10 = "InvoicesTable";
38668
39402
  var InvoiceStatusOptionConfig = {
38669
39403
  ["All" /* All */]: { label: "All", value: "All" /* All */ },
@@ -38684,12 +39418,12 @@ var AmountCell = ({ invoice }) => {
38684
39418
  case "WRITTEN_OFF" /* WrittenOff */:
38685
39419
  case "VOIDED" /* Voided */:
38686
39420
  case "SENT" /* Sent */: {
38687
- return /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(VStack, { children: /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(Span, { align: "right", children: totalAmount }) });
39421
+ return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(VStack, { children: /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(Span, { align: "right", children: totalAmount }) });
38688
39422
  }
38689
39423
  case "PARTIALLY_PAID" /* PartiallyPaid */: {
38690
- return /* @__PURE__ */ (0, import_jsx_runtime348.jsxs)(VStack, { children: [
38691
- /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(Span, { align: "right", children: totalAmount }),
38692
- /* @__PURE__ */ (0, import_jsx_runtime348.jsxs)(Span, { align: "right", variant: "subtle", size: "sm", children: [
39424
+ return /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(VStack, { children: [
39425
+ /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(Span, { align: "right", children: totalAmount }),
39426
+ /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(Span, { align: "right", variant: "subtle", size: "sm", children: [
38693
39427
  outstandingBalance,
38694
39428
  " ",
38695
39429
  "outstanding"
@@ -38706,7 +39440,7 @@ var AmountCell = ({ invoice }) => {
38706
39440
  };
38707
39441
  var getCustomerName2 = (invoice) => {
38708
39442
  const { recipientName, customer } = invoice;
38709
- return recipientName || (customer == null ? void 0 : customer.individualName) || (customer == null ? void 0 : customer.companyName);
39443
+ return (customer == null ? void 0 : customer.individualName) || (customer == null ? void 0 : customer.companyName) || recipientName;
38710
39444
  };
38711
39445
  var getColumnConfig = (onSelectInvoice) => ({
38712
39446
  ["SentAt" /* SentAt */]: {
@@ -38728,16 +39462,16 @@ var getColumnConfig = (onSelectInvoice) => ({
38728
39462
  ["Total" /* Total */]: {
38729
39463
  id: "Total" /* Total */,
38730
39464
  header: "Amount",
38731
- cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(AmountCell, { invoice: row })
39465
+ cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(AmountCell, { invoice: row })
38732
39466
  },
38733
39467
  ["Status" /* Status */]: {
38734
39468
  id: "Status" /* Status */,
38735
39469
  header: "Status",
38736
- cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(InvoiceStatusCell, { invoice: row })
39470
+ cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(InvoiceStatusCell, { invoice: row })
38737
39471
  },
38738
39472
  ["Expand" /* Expand */]: {
38739
39473
  id: "Expand" /* Expand */,
38740
- cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(Button2, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(ChevronRightFill_default, {}) })
39474
+ cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(Button2, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(ChevronRightFill_default, {}) })
38741
39475
  }
38742
39476
  });
38743
39477
  var UNPAID_STATUSES2 = ["SENT" /* Sent */, "PARTIALLY_PAID" /* PartiallyPaid */];
@@ -38749,9 +39483,9 @@ var getListInvoiceParams = ({ statusFilter }) => {
38749
39483
  case "Unpaid" /* Unpaid */:
38750
39484
  return { status: UNPAID_STATUSES2 };
38751
39485
  case "Overdue" /* Overdue */:
38752
- return { status: UNPAID_STATUSES2, dueAtEnd: (0, import_date_fns51.endOfYesterday)() };
39486
+ return { status: UNPAID_STATUSES2, dueAtEnd: (0, import_date_fns53.endOfYesterday)() };
38753
39487
  case "Sent" /* Sent */:
38754
- return { status: UNPAID_STATUSES2, dueAtStart: (0, import_date_fns51.startOfToday)() };
39488
+ return { status: UNPAID_STATUSES2, dueAtStart: (0, import_date_fns53.startOfToday)() };
38755
39489
  case "Paid" /* Paid */:
38756
39490
  return { status: ["PAID" /* Paid */, "PARTIALLY_WRITTEN_OFF" /* PartiallyWrittenOff */] };
38757
39491
  case "Written Off" /* WrittenOff */:
@@ -38766,8 +39500,8 @@ var getListInvoiceParams = ({ statusFilter }) => {
38766
39500
  }
38767
39501
  };
38768
39502
  var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38769
- const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = (0, import_react237.useState)(ALL_OPTION);
38770
- const listInvoiceParams = (0, import_react237.useMemo)(
39503
+ const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = (0, import_react239.useState)(ALL_OPTION);
39504
+ const listInvoiceParams = (0, import_react239.useMemo)(
38771
39505
  () => getListInvoiceParams({ statusFilter: selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value }),
38772
39506
  [selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value]
38773
39507
  );
@@ -38775,29 +39509,29 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38775
39509
  const invoices = data == null ? void 0 : data.flatMap(({ data: data2 }) => data2);
38776
39510
  const paginationMeta = data == null ? void 0 : data[data.length - 1].meta.pagination;
38777
39511
  const hasMore = paginationMeta == null ? void 0 : paginationMeta.hasMore;
38778
- const fetchMore = (0, import_react237.useCallback)(() => {
39512
+ const fetchMore = (0, import_react239.useCallback)(() => {
38779
39513
  if (hasMore) {
38780
39514
  void setSize(size + 1);
38781
39515
  }
38782
39516
  }, [hasMore, setSize, size]);
38783
- const paginationProps = (0, import_react237.useMemo)(() => {
39517
+ const paginationProps = (0, import_react239.useMemo)(() => {
38784
39518
  return {
38785
39519
  pageSize: 10,
38786
39520
  hasMore,
38787
39521
  fetchMore
38788
39522
  };
38789
39523
  }, [fetchMore, hasMore]);
38790
- const options = (0, import_react237.useMemo)(() => Object.values(InvoiceStatusOptionConfig), []);
38791
- const SelectedValue = (0, import_react237.useMemo)(() => {
39524
+ const options2 = (0, import_react239.useMemo)(() => Object.values(InvoiceStatusOptionConfig), []);
39525
+ const SelectedValue = (0, import_react239.useMemo)(() => {
38792
39526
  const label = selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label;
38793
39527
  return label ? `Status: ${label}` : "Status";
38794
39528
  }, [selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label]);
38795
- const StatusFilter = (0, import_react237.useCallback)(
38796
- () => /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
39529
+ const StatusFilter = (0, import_react239.useCallback)(
39530
+ () => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
38797
39531
  ComboBox,
38798
39532
  {
38799
39533
  className: "Layer__InvoicesTable__StatusFilter",
38800
- options,
39534
+ options: options2,
38801
39535
  onSelectedValueChange: (option) => setSelectedInvoiceStatusOption(option),
38802
39536
  selectedValue: selectedInvoiceStatusOption,
38803
39537
  isSearchable: false,
@@ -38807,29 +39541,29 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38807
39541
  "aria-label": "Status Filter"
38808
39542
  }
38809
39543
  ),
38810
- [SelectedValue, options, selectedInvoiceStatusOption]
39544
+ [SelectedValue, options2, selectedInvoiceStatusOption]
38811
39545
  );
38812
- const CreateInvoiceButton = (0, import_react237.useCallback)(
38813
- () => /* @__PURE__ */ (0, import_jsx_runtime348.jsxs)(Button2, { onPress: onCreateInvoice, children: [
39546
+ const CreateInvoiceButton = (0, import_react239.useCallback)(
39547
+ () => /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(Button2, { onPress: onCreateInvoice, children: [
38814
39548
  "Create Invoice",
38815
- /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(import_lucide_react17.Plus, { size: 16 })
39549
+ /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(import_lucide_react19.Plus, { size: 16 })
38816
39550
  ] }),
38817
39551
  [onCreateInvoice]
38818
39552
  );
38819
- const InvoicesTableEmptyState = (0, import_react237.useCallback)(() => {
39553
+ const InvoicesTableEmptyState = (0, import_react239.useCallback)(() => {
38820
39554
  const isFiltered = selectedInvoiceStatusOption && selectedInvoiceStatusOption !== ALL_OPTION;
38821
- return /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
39555
+ return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
38822
39556
  DataState,
38823
39557
  {
38824
39558
  status: "allDone" /* allDone */,
38825
39559
  title: isFiltered ? "No results found" : "No invoices yet",
38826
39560
  description: isFiltered ? "We couldn\u2019t find any invoices with the current filters. Try changing or clearing them to see more results." : "Add your first invoice to start tracking what your customers owe you.",
38827
- icon: isFiltered ? /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(import_lucide_react17.Search, {}) : /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(import_lucide_react17.HandCoins, {}),
39561
+ icon: isFiltered ? /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(import_lucide_react19.Search, {}) : /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(import_lucide_react19.HandCoins, {}),
38828
39562
  spacing: true
38829
39563
  }
38830
39564
  );
38831
39565
  }, [selectedInvoiceStatusOption]);
38832
- const InvoicesTableErrorState = (0, import_react237.useCallback)(() => /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
39566
+ const InvoicesTableErrorState = (0, import_react239.useCallback)(() => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
38833
39567
  DataState,
38834
39568
  {
38835
39569
  status: "failed" /* failed */,
@@ -38841,9 +39575,9 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38841
39575
  spacing: true
38842
39576
  }
38843
39577
  ), [refetch]);
38844
- const columnConfig = (0, import_react237.useMemo)(() => getColumnConfig(onSelectInvoice), [onSelectInvoice]);
38845
- return /* @__PURE__ */ (0, import_jsx_runtime348.jsxs)(Container, { name: "InvoicesTable", children: [
38846
- /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
39578
+ const columnConfig = (0, import_react239.useMemo)(() => getColumnConfig(onSelectInvoice), [onSelectInvoice]);
39579
+ return /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(Container, { name: "InvoicesTable", children: [
39580
+ /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
38847
39581
  DataTableHeader,
38848
39582
  {
38849
39583
  name: "Invoices",
@@ -38853,7 +39587,7 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38853
39587
  }
38854
39588
  }
38855
39589
  ),
38856
- /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
39590
+ /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
38857
39591
  PaginatedTable,
38858
39592
  {
38859
39593
  ariaLabel: "Invoices",
@@ -38873,38 +39607,38 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38873
39607
  };
38874
39608
 
38875
39609
  // src/components/Invoices/Invoices.tsx
38876
- var import_jsx_runtime349 = require("react/jsx-runtime");
39610
+ var import_jsx_runtime351 = require("react/jsx-runtime");
38877
39611
  var unstable_Invoices = ({
38878
39612
  showTitle = true,
38879
39613
  stringOverrides
38880
39614
  }) => {
38881
- const [invoiceFormMode, setInvoiceFormMode] = (0, import_react238.useState)(null);
38882
- const goBackToInvoicesTable = (0, import_react238.useCallback)(() => {
39615
+ const [invoiceFormMode, setInvoiceFormMode] = (0, import_react240.useState)(null);
39616
+ const goBackToInvoicesTable = (0, import_react240.useCallback)(() => {
38883
39617
  setInvoiceFormMode(null);
38884
39618
  }, []);
38885
- const onCreateInvoice = (0, import_react238.useCallback)(() => {
39619
+ const onCreateInvoice = (0, import_react240.useCallback)(() => {
38886
39620
  setInvoiceFormMode({ mode: "Create" /* Create */ });
38887
39621
  }, []);
38888
- const onSelectInvoice = (0, import_react238.useCallback)((invoice) => {
39622
+ const onSelectInvoice = (0, import_react240.useCallback)((invoice) => {
38889
39623
  setInvoiceFormMode({ mode: "Update" /* Update */, invoice });
38890
39624
  }, []);
38891
- return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(
39625
+ return /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(
38892
39626
  View,
38893
39627
  {
38894
39628
  title: (stringOverrides == null ? void 0 : stringOverrides.title) || "Invoices",
38895
39629
  showHeader: showTitle,
38896
- children: invoiceFormMode !== null ? /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(InvoiceDetail, __spreadProps(__spreadValues({}, invoiceFormMode), { onGoBack: goBackToInvoicesTable })) : /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(InvoicesTable, { onCreateInvoice, onSelectInvoice })
39630
+ children: invoiceFormMode !== null ? /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(InvoiceDetail, __spreadProps(__spreadValues({}, invoiceFormMode), { onGoBack: goBackToInvoicesTable })) : /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(InvoicesTable, { onCreateInvoice, onSelectInvoice })
38897
39631
  }
38898
39632
  );
38899
39633
  };
38900
39634
 
38901
39635
  // src/providers/BankTransactionsProvider/BankTransactionsProvider.tsx
38902
- var import_jsx_runtime350 = require("react/jsx-runtime");
39636
+ var import_jsx_runtime352 = require("react/jsx-runtime");
38903
39637
  var BankTransactionsProvider = ({
38904
39638
  children
38905
39639
  }) => {
38906
39640
  const bankTransactionsContextData = useAugmentedBankTransactions();
38907
- return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(BankTransactionsContext.Provider, { value: bankTransactionsContextData, children });
39641
+ return /* @__PURE__ */ (0, import_jsx_runtime352.jsx)(BankTransactionsContext.Provider, { value: bankTransactionsContextData, children });
38908
39642
  };
38909
39643
  // Annotate the CommonJS export names for ESM import in node:
38910
39644
  0 && (module.exports = {