@layerfi/components 0.1.106-alpha.1 → 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-alpha.1";
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) => {
@@ -7123,7 +7127,7 @@ function clampToPresentOrPast(date, cutoff = (0, import_date_fns3.endOfDay)(/* @
7123
7127
  }
7124
7128
  var RANGE_MODE_LOOKUP = {
7125
7129
  dayPicker: {
7126
- getStart: ({ start }) => start,
7130
+ getStart: ({ start }) => (0, import_date_fns3.startOfMonth)(start),
7127
7131
  getEnd: ({ end }) => clampToPresentOrPast((0, import_date_fns3.endOfDay)(end))
7128
7132
  },
7129
7133
  dayRangePicker: {
@@ -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_react237 = require("react");
37229
+ var import_react240 = require("react");
37175
37230
 
37176
37231
  // src/components/Invoices/InvoiceDetail/InvoiceDetail.tsx
37177
- var import_react231 = 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_react229 = 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,34 +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;
37331
- function FormBigDecimalField({
37332
- slotProps,
37333
- maxInputLength = DEFAULT_MAX_INPUT_LENGTH,
37334
- allowNegative = false
37335
- }) {
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
+ });
37452
+ function FormBigDecimalField(_a) {
37453
+ var _b = _a, {
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
37459
+ } = _b, restProps = __objRest(_b, [
37460
+ "mode",
37461
+ "allowNegative",
37462
+ "maxValue",
37463
+ "minDecimalPlaces",
37464
+ "maxDecimalPlaces"
37465
+ ]);
37336
37466
  const field = useFieldContext();
37337
37467
  const { name, state, handleChange, handleBlur } = field;
37338
37468
  const { value } = state;
37339
- 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));
37340
37476
  const onInputChange = (0, import_react223.useCallback)((e) => {
37341
37477
  setInputValue(e.target.value);
37342
37478
  }, []);
37343
37479
  const onInputBlur = (0, import_react223.useCallback)(() => {
37344
- const cleaned = inputValue.replace(/,/g, "");
37345
- const maybeDecimal = import_effect10.BigDecimal.fromString(cleaned);
37480
+ const sanitizedInput = inputValue.replace(DECORATOR_CHARS_REGEX, "");
37481
+ const maybeDecimal = import_effect10.BigDecimal.fromString(sanitizedInput);
37346
37482
  const decimal = import_effect10.Option.match(maybeDecimal, {
37347
37483
  onNone: () => BIG_DECIMAL_ZERO,
37348
- onSome: (amount) => amount
37484
+ onSome: (value2) => value2
37349
37485
  });
37350
- const normalizedDecimal = import_effect10.BigDecimal.normalize(decimal);
37351
- 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
+ }
37352
37492
  handleBlur();
37353
- setInputValue(formatBigDecimalToString(normalizedDecimal, maxInputLength));
37354
- }, [inputValue, handleBlur, handleChange, maxInputLength]);
37493
+ setInputValue(formatBigDecimalToString(clamped, formattingProps));
37494
+ }, [inputValue, mode, maxBigDecimalValue, value, handleBlur, formattingProps, handleChange]);
37355
37495
  const allowedChars = (0, import_react223.useMemo)(
37356
- () => allowNegative ? DECIMAL_CHARS_REGEX : NON_NEGATIVE_DECIMAL_CHARS_REGEX,
37357
- [allowNegative]
37496
+ () => buildDecimalCharRegex({ allowNegative, allowPercent: mode === "percent", allowDollar: mode === "currency" }),
37497
+ [allowNegative, mode]
37358
37498
  );
37359
37499
  const onBeforeInput = (0, import_react223.useCallback)((e) => {
37360
37500
  if (e.data && !allowedChars.test(e.data)) {
@@ -37368,9 +37508,9 @@ function FormBigDecimalField({
37368
37508
  }
37369
37509
  }, [allowedChars]);
37370
37510
  (0, import_react223.useEffect)(() => {
37371
- setInputValue(formatBigDecimalToString(value, maxInputLength));
37372
- }, [value, maxInputLength]);
37373
- return /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { 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)(
37374
37514
  Input2,
37375
37515
  {
37376
37516
  inset: true,
@@ -37379,78 +37519,177 @@ function FormBigDecimalField({
37379
37519
  value: inputValue,
37380
37520
  onChange: onInputChange,
37381
37521
  onBlur: onInputBlur,
37382
- maxLength: maxInputLength,
37383
37522
  onBeforeInput,
37384
37523
  onPaste
37385
37524
  }
37386
37525
  ) }) }));
37387
37526
  }
37388
37527
 
37389
- // src/features/forms/components/FormCurrencyField.tsx
37390
- var import_react224 = require("react");
37391
- var import_react_currency_input_field2 = __toESM(require("react-currency-input-field"));
37392
- var import_effect11 = require("effect");
37528
+ // src/features/forms/components/FormCheckboxField.tsx
37529
+ var import_classnames89 = __toESM(require("classnames"));
37393
37530
  var import_jsx_runtime333 = require("react/jsx-runtime");
37394
- var ZERO_CENTS_INPUT_VALUE = "0.00";
37395
- var getCurrencyInputValueFromCents = (cents) => !Number.isNaN(cents) ? centsToDollarsWithoutCommas(cents) : ZERO_CENTS_INPUT_VALUE;
37396
- function FormCurrencyField({ slotProps }) {
37531
+ var FORM_CHECKBOX_FIELD_CLASSNAME = "Layer__FormCheckboxField";
37532
+ function FormCheckboxField({
37533
+ label,
37534
+ className,
37535
+ inline = false,
37536
+ showLabel = true,
37537
+ showFieldError = true,
37538
+ isReadOnly = false
37539
+ }) {
37397
37540
  const field = useFieldContext();
37398
- const label = slotProps.BaseFormTextField.label;
37399
37541
  const { name, state, handleChange, handleBlur } = field;
37400
- const { value } = state;
37401
- const [inputValue, setInputValue] = (0, import_react224.useState)(getCurrencyInputValueFromCents(value));
37402
- const onInputChange = (0, import_react224.useCallback)((newValue) => {
37403
- setInputValue(newValue != null ? newValue : ZERO_CENTS_INPUT_VALUE);
37404
- }, []);
37405
- const onInputBlur = (0, import_react224.useCallback)(() => {
37406
- const maybeAmount = import_effect11.BigDecimal.fromString(inputValue);
37407
- const cents = import_effect11.Option.match(maybeAmount, {
37408
- onNone: () => 0,
37409
- onSome: (amount) => convertBigDecimalToCents(amount)
37410
- });
37411
- handleChange(cents);
37412
- handleBlur();
37413
- setInputValue(getCurrencyInputValueFromCents(cents));
37414
- }, [inputValue, handleChange, handleBlur]);
37415
- (0, import_react224.useEffect)(() => {
37416
- setInputValue(getCurrencyInputValueFromCents(value));
37542
+ const { meta, value } = state;
37543
+ const { errors, isValid: isValid2 } = meta;
37544
+ const errorMessage = errors.length !== 0 ? errors[0] : void 0;
37545
+ const tooltipProps = showFieldError ? { tooltip: errorMessage } : {};
37546
+ const additionalAriaProps = !showLabel && { "aria-label": label };
37547
+ const checkboxClassNames = (0, import_classnames89.default)(
37548
+ FORM_CHECKBOX_FIELD_CLASSNAME,
37549
+ inline && `${FORM_CHECKBOX_FIELD_CLASSNAME}--inline`,
37550
+ className
37551
+ );
37552
+ return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
37553
+ CheckboxWithTooltip,
37554
+ __spreadProps(__spreadValues(__spreadValues(__spreadValues({
37555
+ className: checkboxClassNames,
37556
+ isSelected: value,
37557
+ isInvalid: !isValid2,
37558
+ onChange: handleChange,
37559
+ onBlur: handleBlur,
37560
+ name,
37561
+ value: name,
37562
+ size: "lg",
37563
+ isReadOnly
37564
+ }, tooltipProps), additionalAriaProps), !isValid2 && { variant: "error" }), {
37565
+ children: showLabel && /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(Label, { slot: "label", size: "sm", htmlFor: name, children: label })
37566
+ })
37567
+ );
37568
+ }
37569
+
37570
+ // src/features/forms/components/FormDateField.tsx
37571
+ var import_react225 = require("react");
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");
37577
+ var import_jsx_runtime334 = require("react/jsx-runtime");
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
+ }) {
37632
+ const field = useFieldContext();
37633
+ const { name, state, handleChange, handleBlur } = field;
37634
+ const { meta, value } = state;
37635
+ const { errors, isValid: isValid2 } = meta;
37636
+ const [localDate, setLocalDate] = (0, import_react225.useState)(value);
37637
+ (0, import_react225.useEffect)(() => {
37638
+ setLocalDate(value);
37417
37639
  }, [value]);
37418
- return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(InputGroup2, { children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
37419
- import_react_currency_input_field2.default,
37420
- {
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({
37421
37651
  name,
37422
- intlConfig: {
37423
- locale: "en-US",
37424
- currency: "USD"
37425
- },
37426
- prefix: "$",
37427
- decimalScale: 2,
37428
- decimalsLimit: 2,
37429
- disableAbbreviations: true,
37430
- value: inputValue,
37431
- onValueChange: onInputChange,
37432
- onBlur: onInputBlur,
37433
- className: "Layer__UI__Input",
37434
- "data-inset": "true",
37435
- "aria-label": label
37436
- }
37437
- ) }) }));
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
+ );
37438
37677
  }
37439
37678
 
37440
37679
  // src/features/forms/components/FormTextAreaField.tsx
37441
- var import_react226 = require("react");
37680
+ var import_react227 = require("react");
37442
37681
 
37443
37682
  // src/components/ui/Input/TextArea.tsx
37444
- var import_react225 = require("react");
37445
- var import_react_aria_components17 = require("react-aria-components");
37446
- var import_jsx_runtime334 = require("react/jsx-runtime");
37683
+ var import_react226 = require("react");
37684
+ var import_react_aria_components18 = require("react-aria-components");
37685
+ var import_jsx_runtime336 = require("react/jsx-runtime");
37447
37686
  var TEXTAREA_CLASS_NAME = "Layer__UI__TextArea";
37448
- var TextArea = (0, import_react225.forwardRef)(
37687
+ var TextArea = (0, import_react226.forwardRef)(
37449
37688
  function TextArea2(_a, ref) {
37450
37689
  var _b = _a, { resize = "none" } = _b, restProps = __objRest(_b, ["resize"]);
37451
37690
  const dataProperties = toDataProperties({ resize });
37452
- return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
37453
- import_react_aria_components17.TextArea,
37691
+ return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(
37692
+ import_react_aria_components18.TextArea,
37454
37693
  __spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), {
37455
37694
  className: TEXTAREA_CLASS_NAME,
37456
37695
  ref
@@ -37460,37 +37699,58 @@ var TextArea = (0, import_react225.forwardRef)(
37460
37699
  );
37461
37700
 
37462
37701
  // src/features/forms/components/FormTextAreaField.tsx
37463
- var import_jsx_runtime335 = require("react/jsx-runtime");
37464
- function FormTextAreaField({ slotProps }) {
37702
+ var import_jsx_runtime337 = require("react/jsx-runtime");
37703
+ function FormTextAreaField(props) {
37465
37704
  const field = useFieldContext();
37466
37705
  const { name, state, handleChange, handleBlur } = field;
37467
37706
  const { value } = state;
37468
- const onChange = (0, import_react226.useCallback)((e) => {
37707
+ const onChange = (0, import_react227.useCallback)((e) => {
37469
37708
  handleChange(e.target.value);
37470
37709
  }, [handleChange]);
37471
- return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { children: /* @__PURE__ */ (0, import_jsx_runtime335.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
+ ) }));
37472
37721
  }
37473
37722
 
37474
37723
  // src/features/forms/components/FormTextField.tsx
37475
- var import_react227 = require("react");
37476
- var import_jsx_runtime336 = require("react/jsx-runtime");
37477
- function FormTextField({ slotProps }) {
37724
+ var import_react228 = require("react");
37725
+ var import_jsx_runtime338 = require("react/jsx-runtime");
37726
+ function FormTextField(props) {
37478
37727
  const field = useFieldContext();
37479
37728
  const { name, state, handleChange, handleBlur } = field;
37480
37729
  const { value } = state;
37481
- const onChange = (0, import_react227.useCallback)((e) => {
37730
+ const onChange = (0, import_react228.useCallback)((e) => {
37482
37731
  handleChange(e.target.value);
37483
37732
  }, [handleChange]);
37484
- return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { children: /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(InputGroup2, { children: /* @__PURE__ */ (0, import_jsx_runtime336.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
+ ) }) }));
37485
37744
  }
37486
37745
 
37487
37746
  // src/features/forms/hooks/useForm.tsx
37488
37747
  var { fieldContext, useFieldContext, formContext, useFormContext } = (0, import_react_form6.createFormHookContexts)();
37489
- var { useAppForm, withForm } = (0, import_react_form6.createFormHook)({
37748
+ var { useAppForm: useInternalAppForm } = (0, import_react_form6.createFormHook)({
37490
37749
  fieldComponents: {
37491
37750
  BaseFormTextField,
37492
37751
  FormBigDecimalField,
37493
- FormCurrencyField,
37752
+ FormCheckboxField,
37753
+ FormDateField,
37494
37754
  FormTextAreaField,
37495
37755
  FormTextField
37496
37756
  },
@@ -37500,9 +37760,104 @@ var { useAppForm, withForm } = (0, import_react_form6.createFormHook)({
37500
37760
  fieldContext,
37501
37761
  formContext
37502
37762
  });
37763
+ function useAppForm(props) {
37764
+ return useInternalAppForm(props);
37765
+ }
37503
37766
 
37504
37767
  // src/features/invoices/invoiceSchemas.ts
37505
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
37506
37861
  var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus3) => {
37507
37862
  InvoiceStatus3["Voided"] = "VOIDED";
37508
37863
  InvoiceStatus3["Paid"] = "PAID";
@@ -37635,7 +37990,11 @@ var UpsertInvoiceLineItemSchema = import_effect12.Schema.Struct({
37635
37990
  import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
37636
37991
  import_effect12.Schema.fromKey("unit_price")
37637
37992
  ),
37638
- 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
+ )
37639
37998
  });
37640
37999
  var UpsertInvoiceSchema = import_effect12.Schema.Struct({
37641
38000
  sentAt: (0, import_effect12.pipe)(
@@ -37662,15 +38021,33 @@ var UpsertInvoiceSchema = import_effect12.Schema.Struct({
37662
38021
  additionalDiscount: (0, import_effect12.pipe)(
37663
38022
  import_effect12.Schema.propertySignature(import_effect12.Schema.UndefinedOr(import_effect12.Schema.Number)),
37664
38023
  import_effect12.Schema.fromKey("additional_discount")
37665
- ),
37666
- additionalSalesTaxes: (0, import_effect12.pipe)(
37667
- import_effect12.Schema.propertySignature(import_effect12.Schema.UndefinedOr(import_effect12.Schema.Array(UpsertInvoiceTaxLineItemSchema))),
37668
- import_effect12.Schema.fromKey("additional_sales_taxes")
37669
38024
  )
37670
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
+ });
37671
38048
 
37672
38049
  // src/features/invoices/api/useUpsertInvoice.tsx
37673
- var import_react228 = require("react");
38050
+ var import_react230 = require("react");
37674
38051
  var import_mutation26 = __toESM(require("swr/mutation"));
37675
38052
  var import_effect13 = require("effect");
37676
38053
  var UPSERT_INVOICES_TAG_KEY = "#upsert-invoice";
@@ -37761,12 +38138,13 @@ var useUpsertInvoice = (props) => {
37761
38138
  }).then(import_effect13.Schema.decodeUnknownPromise(UpsertInvoiceReturnSchema));
37762
38139
  },
37763
38140
  {
37764
- revalidate: false
38141
+ revalidate: false,
38142
+ throwOnError: true
37765
38143
  }
37766
38144
  );
37767
38145
  const mutationResponse = new UpsertInvoiceSWRResponse(rawMutationResponse);
37768
38146
  const originalTrigger = mutationResponse.trigger;
37769
- const stableProxiedTrigger = (0, import_react228.useCallback)(
38147
+ const stableProxiedTrigger = (0, import_react230.useCallback)(
37770
38148
  (...triggerParameters) => __async(null, null, function* () {
37771
38149
  const triggerResult = yield originalTrigger(...triggerParameters);
37772
38150
  return triggerResult;
@@ -37784,75 +38162,293 @@ var useUpsertInvoice = (props) => {
37784
38162
  };
37785
38163
 
37786
38164
  // src/components/Invoices/InvoiceForm/useInvoiceForm.ts
38165
+ var import_effect16 = require("effect");
38166
+
38167
+ // src/components/Invoices/InvoiceForm/totalsUtils.ts
37787
38168
  var import_effect14 = require("effect");
37788
- 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 = () => ({
37789
38223
  product: "",
37790
38224
  description: "",
37791
- unitPrice: 0,
38225
+ unitPrice: BIG_DECIMAL_ZERO,
37792
38226
  quantity: BIG_DECIMAL_ONE,
37793
- amount: 0
37794
- };
37795
- var DEFAULT_FORM_VALUES = {
37796
- invoiceNumber: "",
37797
- customer: null,
37798
- email: "",
37799
- address: "",
37800
- lineItems: [EMPTY_LINE_ITEM]
38227
+ amount: BIG_DECIMAL_ZERO,
38228
+ isTaxable: false
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
+ };
37801
38246
  };
37802
38247
  var getInvoiceLineItemAmount = (lineItem) => {
37803
38248
  const { unitPrice, quantity } = lineItem;
37804
- return convertBigDecimalToCents(import_effect14.BigDecimal.multiply(quantity, convertCentsToBigDecimal(unitPrice)));
38249
+ return import_effect15.BigDecimal.multiply(quantity, convertCentsToBigDecimal(unitPrice));
37805
38250
  };
37806
- var getAugmentedInvoiceFormLineItem = (lineItem) => {
37807
- return __spreadProps(__spreadValues({}, lineItem), {
37808
- amount: getInvoiceLineItemAmount(lineItem)
37809
- });
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),
38258
+ amount: getInvoiceLineItemAmount(lineItem),
38259
+ isTaxable: lineItem.salesTaxTotal > 0
38260
+ };
37810
38261
  };
37811
- var getInvoiceFormDefaultValues = (invoice) => {
38262
+ var getInvoiceFormInitialValues = (invoice) => {
37812
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;
37813
38277
  return {
37814
- invoiceNumber: invoice.invoiceNumber,
38278
+ terms: getInvoiceTermsFromDates(sentAt, dueAt),
38279
+ invoiceNumber: invoice.invoiceNumber || "",
38280
+ sentAt,
38281
+ dueAt,
37815
38282
  customer: invoice.customer,
37816
- email: (_a = invoice.customer) == null ? void 0 : _a.email,
37817
- address: (_b = invoice.customer) == null ? void 0 : _b.addressString,
37818
- 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 || ""
37819
38289
  };
37820
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
+ }
37821
38374
  var useInvoiceForm = (props) => {
37822
- const [submitError, setSubmitError] = (0, import_react229.useState)(void 0);
38375
+ const [submitError, setSubmitError] = (0, import_react231.useState)(void 0);
37823
38376
  const { onSuccess, mode } = props;
37824
38377
  const upsertInvoiceProps = mode === "Update" /* Update */ ? { mode, invoiceId: props.invoice.id } : { mode };
37825
38378
  const { trigger: upsertInvoice } = useUpsertInvoice(upsertInvoiceProps);
37826
- const defaultValues = mode === "Update" /* Update */ ? getInvoiceFormDefaultValues(props.invoice) : DEFAULT_FORM_VALUES;
37827
- const form = useAppForm({
37828
- defaultValues,
37829
- onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
37830
- var _a;
37831
- try {
37832
- const payload = __spreadProps(__spreadValues({}, value), {
37833
- customerId: (_a = value == null ? void 0 : value.customer) == null ? void 0 : _a.id
37834
- });
37835
- const invoiceParams = import_effect14.Schema.validateSync(UpsertInvoiceSchema)(payload);
37836
- const { data: invoice } = yield upsertInvoice(invoiceParams);
37837
- setSubmitError(void 0);
37838
- onSuccess == null ? void 0 : onSuccess(invoice);
37839
- } catch (e) {
37840
- setSubmitError("Something went wrong. Please try again.");
37841
- }
37842
- })
37843
- });
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 });
37844
38399
  const isFormValid = (0, import_react_form7.useStore)(form.store, (state) => state.isValid);
37845
- 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
+ );
37846
38442
  };
37847
38443
 
37848
38444
  // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
37849
38445
  var import_lucide_react16 = require("lucide-react");
37850
- var import_effect15 = require("effect");
38446
+ var import_effect17 = require("effect");
37851
38447
 
37852
38448
  // src/features/customers/components/CustomerSelector.tsx
37853
- var import_react230 = require("react");
37854
- var import_classnames89 = __toESM(require("classnames"));
37855
- var import_jsx_runtime337 = 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");
37856
38452
  function getCustomerName(customer) {
37857
38453
  var _a, _b, _c;
37858
38454
  return (_c = (_b = (_a = customer.individualName) != null ? _a : customer.companyName) != null ? _b : customer.externalId) != null ? _c : "Unknown Customer";
@@ -37883,7 +38479,7 @@ function CustomerSelector({
37883
38479
  inline,
37884
38480
  className
37885
38481
  }) {
37886
- const combinedClassName = (0, import_classnames89.default)(
38482
+ const combinedClassName = (0, import_classnames91.default)(
37887
38483
  "Layer__CustomerSelector",
37888
38484
  inline && "Layer__CustomerSelector--inline",
37889
38485
  className
@@ -37893,12 +38489,12 @@ function CustomerSelector({
37893
38489
  });
37894
38490
  const effectiveSearchQuery = searchQuery === "" ? void 0 : searchQuery;
37895
38491
  const { data, isLoading, isError } = useListCustomers({ query: effectiveSearchQuery });
37896
- const options = (0, import_react230.useMemo)(
38492
+ const options2 = (0, import_react232.useMemo)(
37897
38493
  () => (data == null ? void 0 : data.flatMap(({ data: data2 }) => data2).map((customer) => new CustomerAsOption(customer))) || [],
37898
38494
  [data]
37899
38495
  );
37900
38496
  const selectedCustomerId = selectedCustomer == null ? void 0 : selectedCustomer.id;
37901
- const handleSelectionChange = (0, import_react230.useCallback)(
38497
+ const handleSelectionChange = (0, import_react232.useCallback)(
37902
38498
  (selectedOption) => {
37903
38499
  if (selectedOption === null) {
37904
38500
  handleInputChange("");
@@ -37907,7 +38503,7 @@ function CustomerSelector({
37907
38503
  }
37908
38504
  return;
37909
38505
  }
37910
- const selectedCustomer2 = options.find(({ id }) => id === selectedOption.value);
38506
+ const selectedCustomer2 = options2.find(({ id }) => id === selectedOption.value);
37911
38507
  if (selectedCustomer2) {
37912
38508
  const selectedCustomerWithType = selectedCustomer2.original;
37913
38509
  if (selectedCustomer2.id !== selectedCustomerId) {
@@ -37917,9 +38513,9 @@ function CustomerSelector({
37917
38513
  return;
37918
38514
  }
37919
38515
  },
37920
- [options, handleInputChange, selectedCustomerId, onSelectedCustomerChange]
38516
+ [options2, handleInputChange, selectedCustomerId, onSelectedCustomerChange]
37921
38517
  );
37922
- const selectedCustomerForComboBox = (0, import_react230.useMemo)(
38518
+ const selectedCustomerForComboBox = (0, import_react232.useMemo)(
37923
38519
  () => {
37924
38520
  if (selectedCustomer === null) {
37925
38521
  return null;
@@ -37931,12 +38527,12 @@ function CustomerSelector({
37931
38527
  },
37932
38528
  [selectedCustomer]
37933
38529
  );
37934
- const EmptyMessage = (0, import_react230.useMemo)(
37935
- () => /* @__PURE__ */ (0, import_jsx_runtime337.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" }),
37936
38532
  []
37937
38533
  );
37938
- const ErrorMessage = (0, import_react230.useMemo)(
37939
- () => /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
38534
+ const ErrorMessage = (0, import_react232.useMemo)(
38535
+ () => /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(
37940
38536
  P,
37941
38537
  {
37942
38538
  size: "xs",
@@ -37946,142 +38542,287 @@ function CustomerSelector({
37946
38542
  ),
37947
38543
  []
37948
38544
  );
37949
- const inputId = (0, import_react230.useId)();
37950
- const isFiltered = effectiveSearchQuery !== void 0;
37951
- const noCustomersExist = !isLoading && !isFiltered && data !== void 0 && data.every(({ data: data2 }) => data2.length === 0);
37952
- const shouldHideComponent = noCustomersExist || isReadOnly && selectedCustomer === null;
37953
- if (shouldHideComponent) {
37954
- return null;
37955
- }
38545
+ const inputId = (0, import_react232.useId)();
37956
38546
  const isLoadingWithoutFallback = isLoading && !data;
37957
38547
  const shouldDisableComboBox = isLoadingWithoutFallback || isError;
37958
- return /* @__PURE__ */ (0, import_jsx_runtime337.jsxs)(VStack, { className: combinedClassName, children: [
37959
- /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(Label, { htmlFor: inputId, size: "sm", children: "Customer" }),
37960
- /* @__PURE__ */ (0, import_jsx_runtime337.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)(
37961
38551
  ComboBox,
37962
38552
  {
37963
38553
  selectedValue: selectedCustomerForComboBox,
37964
38554
  onSelectedValueChange: handleSelectionChange,
37965
- options,
38555
+ options: options2,
37966
38556
  onInputValueChange: handleInputChange,
37967
38557
  inputId,
37968
38558
  placeholder,
37969
38559
  slots: { EmptyMessage, ErrorMessage },
37970
- isDisabled: isReadOnly || shouldDisableComboBox,
38560
+ isDisabled: shouldDisableComboBox,
37971
38561
  isError,
37972
- isLoading: isLoadingWithoutFallback
38562
+ isLoading: isLoadingWithoutFallback,
38563
+ isReadOnly
37973
38564
  }
37974
38565
  )
37975
38566
  ] });
37976
38567
  }
37977
38568
 
37978
38569
  // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
37979
- var import_jsx_runtime338 = require("react/jsx-runtime");
38570
+ var import_lucide_react17 = require("lucide-react");
38571
+ var import_jsx_runtime341 = require("react/jsx-runtime");
37980
38572
  var INVOICE_FORM_CSS_PREFIX = "Layer__InvoiceForm";
37981
38573
  var INVOICE_FORM_FIELD_CSS_PREFIX = `${INVOICE_FORM_CSS_PREFIX}__Field`;
37982
- var InvoiceForm = (props) => {
37983
- const { onSuccess, mode } = props;
37984
- 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(
37985
38589
  __spreadValues({ onSuccess }, mode === "Update" /* Update */ ? { mode, invoice: props.invoice } : { mode })
37986
38590
  );
37987
- return /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(Form, { className: INVOICE_FORM_CSS_PREFIX, children: [
37988
- /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__Metadata`, gap: "xs", children: [
37989
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
37990
- form.Field,
37991
- {
37992
- name: "customer",
37993
- listeners: {
37994
- onChange: ({ value: customer }) => {
37995
- form.setFieldValue("email", customer == null ? void 0 : customer.email);
37996
- form.setFieldValue("address", customer == null ? void 0 : customer.addressString);
37997
- }
37998
- },
37999
- children: (field) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
38000
- CustomerSelector,
38001
- {
38002
- className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Customer`,
38003
- selectedCustomer: field.state.value,
38004
- onSelectedCustomerChange: field.handleChange,
38005
- inline: true
38006
- }
38007
- )
38008
- }
38009
- ),
38010
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: "email", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(field.FormTextField, { slotProps: { BaseFormTextField: { label: "Email", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Email` } } }) }),
38011
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: "address", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(field.FormTextAreaField, { slotProps: { BaseFormTextField: { label: "Billing address", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Address` } } }) })
38012
- ] }),
38013
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__LineItems`, gap: "xs", children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: "lineItems", mode: "array", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(VStack, { gap: "xs", align: "baseline", children: [
38014
- field.state.value.map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(HStack, { gap: "xs", align: "end", className: `${INVOICE_FORM_CSS_PREFIX}__LineItem`, children: [
38015
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: `lineItems[${index}].product`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormTextField, { slotProps: { BaseFormTextField: { label: "Product", showLabel: index === 0 } } }) }),
38016
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: `lineItems[${index}].description`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormTextField, { slotProps: { BaseFormTextField: { label: "Description", showLabel: index === 0 } } }) }),
38017
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
38018
- 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,
38620
+ {
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,
38019
38635
  {
38020
- name: `lineItems[${index}].quantity`,
38636
+ name: "customer",
38021
38637
  listeners: {
38022
- onBlur: ({ value: quantity }) => {
38023
- const unitPrice = form.getFieldValue(`lineItems[${index}].unitPrice`);
38024
- const nextAmount = import_effect15.BigDecimal.multiply(convertCentsToBigDecimal(unitPrice), quantity);
38025
- 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) || "");
38026
38641
  }
38027
38642
  },
38028
- children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormBigDecimalField, { slotProps: { BaseFormTextField: { 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
+ )
38029
38653
  }
38030
38654
  ),
38031
- /* @__PURE__ */ (0, import_jsx_runtime338.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)(
38032
38685
  form.AppField,
38033
38686
  {
38034
- name: `lineItems[${index}].unitPrice`,
38687
+ name: "sentAt",
38035
38688
  listeners: {
38036
- onBlur: ({ value: unitPrice }) => {
38037
- const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38038
- const nextAmount = import_effect15.BigDecimal.multiply(convertCentsToBigDecimal(unitPrice), quantity);
38039
- form.setFieldValue(`lineItems[${index}].amount`, convertBigDecimalToCents(nextAmount));
38689
+ onBlur: ({ value: sentAt }) => {
38690
+ const terms = form.getFieldValue("terms");
38691
+ updateDueAtFromTermsAndSentAt(terms, sentAt);
38040
38692
  }
38041
38693
  },
38042
- children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormCurrencyField, { slotProps: { BaseFormTextField: { 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 })
38043
38695
  }
38044
38696
  ),
38045
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
38697
+ /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
38046
38698
  form.AppField,
38047
38699
  {
38048
- name: `lineItems[${index}].amount`,
38700
+ name: "dueAt",
38049
38701
  listeners: {
38050
- onBlur: ({ value: amount }) => {
38051
- const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38052
- let nextUnitPrice = BIG_DECIMAL_ZERO;
38053
- try {
38054
- nextUnitPrice = import_effect15.BigDecimal.unsafeDivide(convertCentsToBigDecimal(amount), quantity);
38055
- } 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;
38056
38709
  }
38057
- form.setFieldValue(`lineItems[${index}].unitPrice`, convertBigDecimalToCents(nextUnitPrice));
38058
38710
  }
38059
38711
  },
38060
- children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormCurrencyField, { slotProps: { BaseFormTextField: { 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 })
38061
38713
  }
38062
- ),
38063
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(Button2, { variant: "outlined", icon: true, "aria-label": "Delete line item", onClick: () => field.removeValue(index), children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(import_lucide_react16.Trash, { size: 16 }) })
38064
- ] }, `lineItems[${index}]`)),
38065
- /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(Button2, { variant: "outlined", onClick: () => field.pushValue(EMPTY_LINE_ITEM), children: [
38066
- "Add line item",
38067
- /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(import_lucide_react16.Plus, { size: 16 })
38714
+ )
38068
38715
  ] })
38069
- ] }) }) })
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
+ ] })
38070
38810
  ] });
38071
- };
38811
+ });
38812
+ InvoiceForm.displayName = "InvoiceForm";
38072
38813
 
38073
38814
  // src/components/DataPoint/DataPoint.tsx
38074
- var import_jsx_runtime339 = require("react/jsx-runtime");
38815
+ var import_jsx_runtime342 = require("react/jsx-runtime");
38075
38816
  var DataPoint = ({ label, children }) => {
38076
- return /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(VStack, { gap: "3xs", children: [
38077
- /* @__PURE__ */ (0, import_jsx_runtime339.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 }),
38078
38819
  children
38079
38820
  ] });
38080
38821
  };
38081
38822
 
38082
38823
  // src/components/Invoices/InvoiceStatusCell/InvoiceStatusCell.tsx
38083
38824
  var import_pluralize6 = __toESM(require("pluralize"));
38084
- var import_jsx_runtime340 = require("react/jsx-runtime");
38825
+ var import_jsx_runtime343 = require("react/jsx-runtime");
38085
38826
  var getDueStatusConfig = (invoice, { inline }) => {
38086
38827
  const badgeSize = inline ? "xs" /* EXTRA_SMALL */ : "small" /* SMALL */;
38087
38828
  const iconSize = inline ? 10 : 12;
@@ -38095,7 +38836,7 @@ var getDueStatusConfig = (invoice, { inline }) => {
38095
38836
  case "PAID" /* Paid */: {
38096
38837
  return {
38097
38838
  text: "Paid",
38098
- badge: /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(Badge, { variant: "success" /* SUCCESS */, size: badgeSize, icon: /* @__PURE__ */ (0, import_jsx_runtime340.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 })
38099
38840
  };
38100
38841
  }
38101
38842
  case "VOIDED" /* Voided */: {
@@ -38118,7 +38859,7 @@ var getDueStatusConfig = (invoice, { inline }) => {
38118
38859
  return {
38119
38860
  text: "Overdue",
38120
38861
  subText: `Due ${(0, import_pluralize6.default)("day", Math.abs(dueDifference), true)} ago`,
38121
- badge: /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(Badge, { variant: "warning" /* WARNING */, size: badgeSize, icon: /* @__PURE__ */ (0, import_jsx_runtime340.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 })
38122
38863
  };
38123
38864
  }
38124
38865
  return {
@@ -38138,73 +38879,117 @@ var InvoiceStatusCell = ({ invoice, inline = false }) => {
38138
38879
  const dueStatus = getDueStatusConfig(invoice, { inline });
38139
38880
  const Stack3 = inline ? HStack : VStack;
38140
38881
  const subText = inline && dueStatus.subText ? `(${dueStatus.subText})` : dueStatus.subText;
38141
- return /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(HStack, { gap: "xs", align: "center", children: [
38882
+ return /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(HStack, { gap: "xs", align: "center", children: [
38142
38883
  dueStatus.badge,
38143
- /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(Stack3, __spreadProps(__spreadValues({}, inline && { gap: "3xs", align: "center" }), { children: [
38144
- /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(Span, { children: dueStatus.text }),
38145
- subText && /* @__PURE__ */ (0, import_jsx_runtime340.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 })
38146
38887
  ] }))
38147
38888
  ] });
38148
38889
  };
38149
38890
 
38150
38891
  // src/components/Invoices/InvoiceDetail/InvoiceDetail.tsx
38151
- var import_jsx_runtime341 = require("react/jsx-runtime");
38892
+ var import_lucide_react18 = require("lucide-react");
38893
+ var import_jsx_runtime344 = require("react/jsx-runtime");
38152
38894
  var InvoiceDetail = (props) => {
38153
- const _a = props, { onSuccess: _onSuccess, onGoBack } = _a, restProps = __objRest(_a, ["onSuccess", "onGoBack"]);
38154
- const Header6 = (0, import_react231.useCallback)(() => {
38155
- return /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceDetailHeader, __spreadValues({}, restProps));
38156
- }, [restProps]);
38157
- return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(BaseDetailView, { slots: { Header: Header6 }, name: "Invoice Detail View", onGoBack, children: [
38158
- restProps.mode === "Update" /* Update */ && /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceDetailSubHeader, { invoice: restProps.invoice }),
38159
- /* @__PURE__ */ (0, import_jsx_runtime341.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
+ )
38160
38933
  ] });
38161
38934
  };
38162
38935
  var InvoiceDetailHeader = (props) => {
38163
- const { mode } = props;
38936
+ const { mode, onSubmit, formState, isReadOnly, setIsReadOnly } = props;
38937
+ const { isSubmitting } = formState;
38164
38938
  if (mode === "Create" /* Create */) {
38165
- return /* @__PURE__ */ (0, import_jsx_runtime341.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
+ ] });
38166
38943
  }
38167
38944
  const invoice = props.invoice;
38168
38945
  const { invoiceNumber } = invoice;
38169
- return /* @__PURE__ */ (0, import_jsx_runtime341.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
+ ] });
38170
38955
  };
38171
38956
  var InvoiceDetailSubHeader = ({ invoice }) => {
38172
38957
  const { outstandingBalance, totalAmount } = invoice;
38173
- return /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(HStack, { className: "Layer__InvoiceDetail__SubHeader", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(HStack, { gap: "5xl", children: [
38174
- /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(DataPoint, { label: "Balance due", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Span, { children: convertCentsToCurrency(outstandingBalance) }) }),
38175
- /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(DataPoint, { label: "Open balance", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Span, { children: convertCentsToCurrency(totalAmount) }) }),
38176
- /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(DataPoint, { label: "Status", children: /* @__PURE__ */ (0, import_jsx_runtime341.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 }) })
38177
38962
  ] }) });
38178
38963
  };
38179
38964
 
38180
38965
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38181
- var import_react236 = require("react");
38966
+ var import_react239 = require("react");
38182
38967
 
38183
38968
  // src/features/invoices/api/useListInvoices.tsx
38184
38969
  var import_infinite7 = __toESM(require("swr/infinite"));
38185
- var import_react232 = require("react");
38186
- var import_lodash6 = __toESM(require_lodash());
38187
- var import_effect17 = require("effect");
38970
+ var import_react235 = require("react");
38971
+ var import_lodash7 = __toESM(require_lodash());
38972
+ var import_effect19 = require("effect");
38188
38973
 
38189
38974
  // src/types/utility/pagination.ts
38190
- var import_effect16 = require("effect");
38191
- var PaginatedResponseMetaSchema = import_effect16.Schema.Struct({
38192
- cursor: import_effect16.Schema.NullOr(import_effect16.Schema.String),
38193
- hasMore: (0, import_effect16.pipe)(
38194
- import_effect16.Schema.propertySignature(import_effect16.Schema.Boolean),
38195
- 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")
38196
38981
  ),
38197
- totalCount: (0, import_effect16.pipe)(
38198
- import_effect16.Schema.propertySignature(import_effect16.Schema.UndefinedOr(import_effect16.Schema.Number)),
38199
- 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")
38200
38985
  )
38201
38986
  });
38202
38987
 
38203
38988
  // src/features/invoices/api/useListInvoices.tsx
38204
38989
  var LIST_INVOICES_TAG_KEY = "#list-invoices";
38205
- var ListInvoicesReturnSchema = import_effect17.Schema.Struct({
38206
- data: import_effect17.Schema.Array(InvoiceSchema),
38207
- 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({
38208
38993
  pagination: PaginatedResponseMetaSchema
38209
38994
  })
38210
38995
  });
@@ -38332,7 +39117,7 @@ function useListInvoices({
38332
39117
  showTotalCount: showTotalCount2
38333
39118
  }
38334
39119
  }
38335
- )().then(import_effect17.Schema.decodeUnknownPromise(ListInvoicesReturnSchema)),
39120
+ )().then(import_effect19.Schema.decodeUnknownPromise(ListInvoicesReturnSchema)),
38336
39121
  {
38337
39122
  keepPreviousData: true,
38338
39123
  revalidateFirstPage: false,
@@ -38346,20 +39131,20 @@ function useListInvoices({
38346
39131
  var import_react_table2 = require("@tanstack/react-table");
38347
39132
 
38348
39133
  // src/components/DataTable/DataTable.tsx
38349
- var import_react234 = require("react");
39134
+ var import_react237 = require("react");
38350
39135
 
38351
39136
  // src/components/ui/Table/Table.tsx
38352
- var import_react233 = require("react");
38353
- var import_react_aria_components18 = require("react-aria-components");
38354
- var import_classnames90 = __toESM(require("classnames"));
38355
- var import_jsx_runtime342 = 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");
38356
39141
  var CSS_PREFIX2 = "Layer__UI__Table";
38357
- var getClassName = (component, additionalClassNames) => (0, import_classnames90.default)(`${CSS_PREFIX2}-${component}`, additionalClassNames);
38358
- var Table2 = (0, import_react233.forwardRef)(
39142
+ var getClassName = (component, additionalClassNames) => (0, import_classnames93.default)(`${CSS_PREFIX2}-${component}`, additionalClassNames);
39143
+ var Table2 = (0, import_react236.forwardRef)(
38359
39144
  (_a, ref) => {
38360
39145
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38361
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
38362
- import_react_aria_components18.Table,
39146
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39147
+ import_react_aria_components19.Table,
38363
39148
  __spreadProps(__spreadValues({
38364
39149
  className: getClassName("Table" /* Table */, className)
38365
39150
  }, restProps), {
@@ -38372,8 +39157,8 @@ var Table2 = (0, import_react233.forwardRef)(
38372
39157
  Table2.displayName = "Table" /* Table */;
38373
39158
  var TableHeaderInner = (_a, ref) => {
38374
39159
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38375
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
38376
- import_react_aria_components18.TableHeader,
39160
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39161
+ import_react_aria_components19.TableHeader,
38377
39162
  __spreadProps(__spreadValues({
38378
39163
  className: getClassName("TableHeader" /* TableHeader */, className)
38379
39164
  }, restProps), {
@@ -38382,12 +39167,12 @@ var TableHeaderInner = (_a, ref) => {
38382
39167
  })
38383
39168
  );
38384
39169
  };
38385
- var TableHeader = (0, import_react233.forwardRef)(TableHeaderInner);
39170
+ var TableHeader = (0, import_react236.forwardRef)(TableHeaderInner);
38386
39171
  TableHeader.displayName = "TableHeader" /* TableHeader */;
38387
39172
  var TableBodyInner = (_a, ref) => {
38388
39173
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38389
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
38390
- import_react_aria_components18.TableBody,
39174
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39175
+ import_react_aria_components19.TableBody,
38391
39176
  __spreadProps(__spreadValues({
38392
39177
  className: getClassName("TableBody" /* TableBody */, className)
38393
39178
  }, restProps), {
@@ -38396,12 +39181,12 @@ var TableBodyInner = (_a, ref) => {
38396
39181
  })
38397
39182
  );
38398
39183
  };
38399
- var TableBody2 = (0, import_react233.forwardRef)(TableBodyInner);
39184
+ var TableBody2 = (0, import_react236.forwardRef)(TableBodyInner);
38400
39185
  TableBody2.displayName = "TableBody" /* TableBody */;
38401
39186
  var RowInner = (_a, ref) => {
38402
39187
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38403
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
38404
- import_react_aria_components18.Row,
39188
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39189
+ import_react_aria_components19.Row,
38405
39190
  __spreadProps(__spreadValues({
38406
39191
  className: getClassName("Row" /* Row */, className)
38407
39192
  }, restProps), {
@@ -38410,14 +39195,14 @@ var RowInner = (_a, ref) => {
38410
39195
  })
38411
39196
  );
38412
39197
  };
38413
- var Row2 = (0, import_react233.forwardRef)(RowInner);
39198
+ var Row2 = (0, import_react236.forwardRef)(RowInner);
38414
39199
  Row2.displayName = "Row" /* Row */;
38415
- var Column = (0, import_react233.forwardRef)(
39200
+ var Column = (0, import_react236.forwardRef)(
38416
39201
  (_a, ref) => {
38417
39202
  var _b = _a, { children, className, textAlign = "left" } = _b, restProps = __objRest(_b, ["children", "className", "textAlign"]);
38418
39203
  const dataProperties = toDataProperties({ "text-align": textAlign });
38419
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
38420
- import_react_aria_components18.Column,
39204
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39205
+ import_react_aria_components19.Column,
38421
39206
  __spreadProps(__spreadValues(__spreadValues({
38422
39207
  className: getClassName("Column" /* Column */, className)
38423
39208
  }, restProps), dataProperties), {
@@ -38428,11 +39213,11 @@ var Column = (0, import_react233.forwardRef)(
38428
39213
  }
38429
39214
  );
38430
39215
  Column.displayName = "Column" /* Column */;
38431
- var Cell5 = (0, import_react233.forwardRef)(
39216
+ var Cell5 = (0, import_react236.forwardRef)(
38432
39217
  (_a, ref) => {
38433
39218
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38434
- return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
38435
- import_react_aria_components18.Cell,
39219
+ return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
39220
+ import_react_aria_components19.Cell,
38436
39221
  __spreadProps(__spreadValues({
38437
39222
  className: getClassName("Cell" /* Cell */, className)
38438
39223
  }, restProps), {
@@ -38445,7 +39230,7 @@ var Cell5 = (0, import_react233.forwardRef)(
38445
39230
  Cell5.displayName = "Cell" /* Cell */;
38446
39231
 
38447
39232
  // src/components/DataTable/DataTable.tsx
38448
- var import_jsx_runtime343 = require("react/jsx-runtime");
39233
+ var import_jsx_runtime346 = require("react/jsx-runtime");
38449
39234
  var DataTable = ({
38450
39235
  columnConfig,
38451
39236
  data,
@@ -38458,17 +39243,17 @@ var DataTable = ({
38458
39243
  const columns = Object.values(columnConfig);
38459
39244
  const { EmptyState, ErrorState } = slots;
38460
39245
  const isEmptyTable = (data == null ? void 0 : data.length) === 0;
38461
- const renderTableBody = (0, import_react234.useMemo)(() => {
39246
+ const renderTableBody = (0, import_react237.useMemo)(() => {
38462
39247
  if (isError) {
38463
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime343.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, {}) }) });
38464
39249
  }
38465
39250
  if (isLoading) {
38466
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime343.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, {}) }) });
38467
39252
  }
38468
39253
  if (isEmptyTable) {
38469
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime343.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, {}) }) });
38470
39255
  }
38471
- const RowRenderer = (row) => /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Row2, { children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(
39256
+ const RowRenderer = (row) => /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Row2, { children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(
38472
39257
  Cell5,
38473
39258
  {
38474
39259
  className: `Layer__UI__Table-Cell__${componentName}--${col.id}`,
@@ -38479,15 +39264,15 @@ var DataTable = ({
38479
39264
  RowRenderer.displayName = "Row";
38480
39265
  return RowRenderer;
38481
39266
  }, [isError, isLoading, isEmptyTable, columns, ErrorState, EmptyState, componentName]);
38482
- return /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(Table2, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, children: [
38483
- /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(TableHeader, { columns, children: ({ id, header, isRowHeader }) => /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Column, { isRowHeader, className: `Layer__UI__Table-Column__${componentName}--${id}`, children: header }, id) }),
38484
- /* @__PURE__ */ (0, import_jsx_runtime343.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 })
38485
39270
  ] });
38486
39271
  };
38487
39272
 
38488
39273
  // src/components/DataTable/PaginatedTable.tsx
38489
- var import_react235 = require("react");
38490
- var import_jsx_runtime344 = require("react/jsx-runtime");
39274
+ var import_react238 = require("react");
39275
+ var import_jsx_runtime347 = require("react/jsx-runtime");
38491
39276
  var EMPTY_ARRAY = [];
38492
39277
  function PaginatedTable({
38493
39278
  data,
@@ -38500,7 +39285,7 @@ function PaginatedTable({
38500
39285
  slots
38501
39286
  }) {
38502
39287
  const { pageSize = 20, hasMore, fetchMore } = paginationProps;
38503
- const [pagination, setPagination] = (0, import_react235.useState)({ pageIndex: 0, pageSize });
39288
+ const [pagination, setPagination] = (0, import_react238.useState)({ pageIndex: 0, pageSize });
38504
39289
  const columnHelper = (0, import_react_table2.createColumnHelper)();
38505
39290
  const columns = Object.values(columnConfig);
38506
39291
  const columnDefs = columns.map((col) => {
@@ -38520,12 +39305,12 @@ function PaginatedTable({
38520
39305
  autoResetPageIndex: false
38521
39306
  });
38522
39307
  const { rows } = table.getRowModel();
38523
- const rowData = (0, import_react235.useMemo)(() => rows.map((r) => r.original), [rows]);
38524
- const onPageChange = (0, import_react235.useCallback)((page) => {
39308
+ const rowData = (0, import_react238.useMemo)(() => rows.map((r) => r.original), [rows]);
39309
+ const onPageChange = (0, import_react238.useCallback)((page) => {
38525
39310
  table.setPageIndex(page - 1);
38526
39311
  }, [table]);
38527
- return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(VStack, { children: [
38528
- /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
39312
+ return /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(VStack, { children: [
39313
+ /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
38529
39314
  DataTable,
38530
39315
  {
38531
39316
  ariaLabel,
@@ -38537,7 +39322,7 @@ function PaginatedTable({
38537
39322
  slots
38538
39323
  }
38539
39324
  ),
38540
- !isError && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
39325
+ !isError && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
38541
39326
  Pagination,
38542
39327
  {
38543
39328
  currentPage: table.getState().pagination.pageIndex + 1,
@@ -38552,10 +39337,10 @@ function PaginatedTable({
38552
39337
  }
38553
39338
 
38554
39339
  // src/icons/ChevronRightFill.tsx
38555
- var import_jsx_runtime345 = require("react/jsx-runtime");
39340
+ var import_jsx_runtime348 = require("react/jsx-runtime");
38556
39341
  var ChevronRightFill = (_a) => {
38557
39342
  var _b = _a, { size = 18 } = _b, props = __objRest(_b, ["size"]);
38558
- return /* @__PURE__ */ (0, import_jsx_runtime345.jsxs)(
39343
+ return /* @__PURE__ */ (0, import_jsx_runtime348.jsxs)(
38559
39344
  "svg",
38560
39345
  __spreadProps(__spreadValues({
38561
39346
  xmlns: "http://www.w3.org/2000/svg",
@@ -38565,8 +39350,8 @@ var ChevronRightFill = (_a) => {
38565
39350
  width: size,
38566
39351
  height: size,
38567
39352
  children: [
38568
- /* @__PURE__ */ (0, import_jsx_runtime345.jsx)("path", { d: "M6.75 4.5L11.25 9L6.75 13.5", fill: "currentColor" }),
38569
- /* @__PURE__ */ (0, import_jsx_runtime345.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)(
38570
39355
  "path",
38571
39356
  {
38572
39357
  d: "M6.75 4.5L11.25 9L6.75 13.5Z",
@@ -38582,37 +39367,37 @@ var ChevronRightFill = (_a) => {
38582
39367
  var ChevronRightFill_default = ChevronRightFill;
38583
39368
 
38584
39369
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38585
- var import_lucide_react17 = require("lucide-react");
39370
+ var import_lucide_react19 = require("lucide-react");
38586
39371
 
38587
39372
  // src/components/DataTable/DataTableHeader.tsx
38588
- var import_jsx_runtime346 = require("react/jsx-runtime");
39373
+ var import_jsx_runtime349 = require("react/jsx-runtime");
38589
39374
  var DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
38590
39375
  const { showCount, totalCount } = count != null ? count : {};
38591
39376
  const { Filters: Filters2, HeaderActions, HeaderFilters } = slots;
38592
- return /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(VStack, { children: [
38593
- /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { justify: "space-between", align: "center", className: "Layer__DataTableHeader__Header", children: [
38594
- /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { pis: "md", align: "center", gap: "xl", children: [
38595
- /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { align: "center", gap: "sm", children: [
38596
- /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Span, { weight: "bold", size: "lg", children: name }),
38597
- showCount && (totalCount ? /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Badge, { variant: "default" /* DEFAULT */, size: "medium" /* MEDIUM */, children: totalCount }) : /* @__PURE__ */ (0, import_jsx_runtime346.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, {}))
38598
39383
  ] }),
38599
- HeaderFilters && /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(HeaderFilters, {})
39384
+ HeaderFilters && /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(HeaderFilters, {})
38600
39385
  ] }),
38601
- /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { pie: "md", align: "center", gap: "3xs", children: [
38602
- slotProps.SearchField && /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(SearchField, __spreadValues({}, slotProps.SearchField)),
38603
- HeaderActions && /* @__PURE__ */ (0, import_jsx_runtime346.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, {})
38604
39389
  ] })
38605
39390
  ] }),
38606
- Filters2 && /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
38607
- /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Filters2, {}),
38608
- slotProps.ClearFiltersButton && /* @__PURE__ */ (0, import_jsx_runtime346.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" }))
38609
39394
  ] })
38610
39395
  ] });
38611
39396
  };
38612
39397
 
38613
39398
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38614
- var import_date_fns51 = require("date-fns");
38615
- var import_jsx_runtime347 = require("react/jsx-runtime");
39399
+ var import_date_fns53 = require("date-fns");
39400
+ var import_jsx_runtime350 = require("react/jsx-runtime");
38616
39401
  var COMPONENT_NAME10 = "InvoicesTable";
38617
39402
  var InvoiceStatusOptionConfig = {
38618
39403
  ["All" /* All */]: { label: "All", value: "All" /* All */ },
@@ -38633,12 +39418,12 @@ var AmountCell = ({ invoice }) => {
38633
39418
  case "WRITTEN_OFF" /* WrittenOff */:
38634
39419
  case "VOIDED" /* Voided */:
38635
39420
  case "SENT" /* Sent */: {
38636
- return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(VStack, { children: /* @__PURE__ */ (0, import_jsx_runtime347.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 }) });
38637
39422
  }
38638
39423
  case "PARTIALLY_PAID" /* PartiallyPaid */: {
38639
- return /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(VStack, { children: [
38640
- /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Span, { align: "right", children: totalAmount }),
38641
- /* @__PURE__ */ (0, import_jsx_runtime347.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: [
38642
39427
  outstandingBalance,
38643
39428
  " ",
38644
39429
  "outstanding"
@@ -38655,7 +39440,7 @@ var AmountCell = ({ invoice }) => {
38655
39440
  };
38656
39441
  var getCustomerName2 = (invoice) => {
38657
39442
  const { recipientName, customer } = invoice;
38658
- 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;
38659
39444
  };
38660
39445
  var getColumnConfig = (onSelectInvoice) => ({
38661
39446
  ["SentAt" /* SentAt */]: {
@@ -38677,16 +39462,16 @@ var getColumnConfig = (onSelectInvoice) => ({
38677
39462
  ["Total" /* Total */]: {
38678
39463
  id: "Total" /* Total */,
38679
39464
  header: "Amount",
38680
- cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(AmountCell, { invoice: row })
39465
+ cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(AmountCell, { invoice: row })
38681
39466
  },
38682
39467
  ["Status" /* Status */]: {
38683
39468
  id: "Status" /* Status */,
38684
39469
  header: "Status",
38685
- cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(InvoiceStatusCell, { invoice: row })
39470
+ cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(InvoiceStatusCell, { invoice: row })
38686
39471
  },
38687
39472
  ["Expand" /* Expand */]: {
38688
39473
  id: "Expand" /* Expand */,
38689
- cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Button2, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ (0, import_jsx_runtime347.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, {}) })
38690
39475
  }
38691
39476
  });
38692
39477
  var UNPAID_STATUSES2 = ["SENT" /* Sent */, "PARTIALLY_PAID" /* PartiallyPaid */];
@@ -38698,9 +39483,9 @@ var getListInvoiceParams = ({ statusFilter }) => {
38698
39483
  case "Unpaid" /* Unpaid */:
38699
39484
  return { status: UNPAID_STATUSES2 };
38700
39485
  case "Overdue" /* Overdue */:
38701
- return { status: UNPAID_STATUSES2, dueAtEnd: (0, import_date_fns51.endOfYesterday)() };
39486
+ return { status: UNPAID_STATUSES2, dueAtEnd: (0, import_date_fns53.endOfYesterday)() };
38702
39487
  case "Sent" /* Sent */:
38703
- return { status: UNPAID_STATUSES2, dueAtStart: (0, import_date_fns51.startOfToday)() };
39488
+ return { status: UNPAID_STATUSES2, dueAtStart: (0, import_date_fns53.startOfToday)() };
38704
39489
  case "Paid" /* Paid */:
38705
39490
  return { status: ["PAID" /* Paid */, "PARTIALLY_WRITTEN_OFF" /* PartiallyWrittenOff */] };
38706
39491
  case "Written Off" /* WrittenOff */:
@@ -38715,8 +39500,8 @@ var getListInvoiceParams = ({ statusFilter }) => {
38715
39500
  }
38716
39501
  };
38717
39502
  var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38718
- const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = (0, import_react236.useState)(ALL_OPTION);
38719
- const listInvoiceParams = (0, import_react236.useMemo)(
39503
+ const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = (0, import_react239.useState)(ALL_OPTION);
39504
+ const listInvoiceParams = (0, import_react239.useMemo)(
38720
39505
  () => getListInvoiceParams({ statusFilter: selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value }),
38721
39506
  [selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value]
38722
39507
  );
@@ -38724,29 +39509,29 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38724
39509
  const invoices = data == null ? void 0 : data.flatMap(({ data: data2 }) => data2);
38725
39510
  const paginationMeta = data == null ? void 0 : data[data.length - 1].meta.pagination;
38726
39511
  const hasMore = paginationMeta == null ? void 0 : paginationMeta.hasMore;
38727
- const fetchMore = (0, import_react236.useCallback)(() => {
39512
+ const fetchMore = (0, import_react239.useCallback)(() => {
38728
39513
  if (hasMore) {
38729
39514
  void setSize(size + 1);
38730
39515
  }
38731
39516
  }, [hasMore, setSize, size]);
38732
- const paginationProps = (0, import_react236.useMemo)(() => {
39517
+ const paginationProps = (0, import_react239.useMemo)(() => {
38733
39518
  return {
38734
39519
  pageSize: 10,
38735
39520
  hasMore,
38736
39521
  fetchMore
38737
39522
  };
38738
39523
  }, [fetchMore, hasMore]);
38739
- const options = (0, import_react236.useMemo)(() => Object.values(InvoiceStatusOptionConfig), []);
38740
- const SelectedValue = (0, import_react236.useMemo)(() => {
39524
+ const options2 = (0, import_react239.useMemo)(() => Object.values(InvoiceStatusOptionConfig), []);
39525
+ const SelectedValue = (0, import_react239.useMemo)(() => {
38741
39526
  const label = selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label;
38742
39527
  return label ? `Status: ${label}` : "Status";
38743
39528
  }, [selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label]);
38744
- const StatusFilter = (0, import_react236.useCallback)(
38745
- () => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
39529
+ const StatusFilter = (0, import_react239.useCallback)(
39530
+ () => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
38746
39531
  ComboBox,
38747
39532
  {
38748
39533
  className: "Layer__InvoicesTable__StatusFilter",
38749
- options,
39534
+ options: options2,
38750
39535
  onSelectedValueChange: (option) => setSelectedInvoiceStatusOption(option),
38751
39536
  selectedValue: selectedInvoiceStatusOption,
38752
39537
  isSearchable: false,
@@ -38756,29 +39541,29 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38756
39541
  "aria-label": "Status Filter"
38757
39542
  }
38758
39543
  ),
38759
- [SelectedValue, options, selectedInvoiceStatusOption]
39544
+ [SelectedValue, options2, selectedInvoiceStatusOption]
38760
39545
  );
38761
- const CreateInvoiceButton = (0, import_react236.useCallback)(
38762
- () => /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(Button2, { onPress: onCreateInvoice, children: [
39546
+ const CreateInvoiceButton = (0, import_react239.useCallback)(
39547
+ () => /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(Button2, { onPress: onCreateInvoice, children: [
38763
39548
  "Create Invoice",
38764
- /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(import_lucide_react17.Plus, { size: 16 })
39549
+ /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(import_lucide_react19.Plus, { size: 16 })
38765
39550
  ] }),
38766
39551
  [onCreateInvoice]
38767
39552
  );
38768
- const InvoicesTableEmptyState = (0, import_react236.useCallback)(() => {
39553
+ const InvoicesTableEmptyState = (0, import_react239.useCallback)(() => {
38769
39554
  const isFiltered = selectedInvoiceStatusOption && selectedInvoiceStatusOption !== ALL_OPTION;
38770
- return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
39555
+ return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
38771
39556
  DataState,
38772
39557
  {
38773
39558
  status: "allDone" /* allDone */,
38774
39559
  title: isFiltered ? "No results found" : "No invoices yet",
38775
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.",
38776
- icon: isFiltered ? /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(import_lucide_react17.Search, {}) : /* @__PURE__ */ (0, import_jsx_runtime347.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, {}),
38777
39562
  spacing: true
38778
39563
  }
38779
39564
  );
38780
39565
  }, [selectedInvoiceStatusOption]);
38781
- const InvoicesTableErrorState = (0, import_react236.useCallback)(() => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
39566
+ const InvoicesTableErrorState = (0, import_react239.useCallback)(() => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
38782
39567
  DataState,
38783
39568
  {
38784
39569
  status: "failed" /* failed */,
@@ -38790,9 +39575,9 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38790
39575
  spacing: true
38791
39576
  }
38792
39577
  ), [refetch]);
38793
- const columnConfig = (0, import_react236.useMemo)(() => getColumnConfig(onSelectInvoice), [onSelectInvoice]);
38794
- return /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(Container, { name: "InvoicesTable", children: [
38795
- /* @__PURE__ */ (0, import_jsx_runtime347.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)(
38796
39581
  DataTableHeader,
38797
39582
  {
38798
39583
  name: "Invoices",
@@ -38802,7 +39587,7 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38802
39587
  }
38803
39588
  }
38804
39589
  ),
38805
- /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
39590
+ /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
38806
39591
  PaginatedTable,
38807
39592
  {
38808
39593
  ariaLabel: "Invoices",
@@ -38822,38 +39607,38 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38822
39607
  };
38823
39608
 
38824
39609
  // src/components/Invoices/Invoices.tsx
38825
- var import_jsx_runtime348 = require("react/jsx-runtime");
39610
+ var import_jsx_runtime351 = require("react/jsx-runtime");
38826
39611
  var unstable_Invoices = ({
38827
39612
  showTitle = true,
38828
39613
  stringOverrides
38829
39614
  }) => {
38830
- const [invoiceFormMode, setInvoiceFormMode] = (0, import_react237.useState)(null);
38831
- const goBackToInvoicesTable = (0, import_react237.useCallback)(() => {
39615
+ const [invoiceFormMode, setInvoiceFormMode] = (0, import_react240.useState)(null);
39616
+ const goBackToInvoicesTable = (0, import_react240.useCallback)(() => {
38832
39617
  setInvoiceFormMode(null);
38833
39618
  }, []);
38834
- const onCreateInvoice = (0, import_react237.useCallback)(() => {
39619
+ const onCreateInvoice = (0, import_react240.useCallback)(() => {
38835
39620
  setInvoiceFormMode({ mode: "Create" /* Create */ });
38836
39621
  }, []);
38837
- const onSelectInvoice = (0, import_react237.useCallback)((invoice) => {
39622
+ const onSelectInvoice = (0, import_react240.useCallback)((invoice) => {
38838
39623
  setInvoiceFormMode({ mode: "Update" /* Update */, invoice });
38839
39624
  }, []);
38840
- return /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
39625
+ return /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(
38841
39626
  View,
38842
39627
  {
38843
39628
  title: (stringOverrides == null ? void 0 : stringOverrides.title) || "Invoices",
38844
39629
  showHeader: showTitle,
38845
- children: invoiceFormMode !== null ? /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(InvoiceDetail, __spreadProps(__spreadValues({}, invoiceFormMode), { onGoBack: goBackToInvoicesTable })) : /* @__PURE__ */ (0, import_jsx_runtime348.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 })
38846
39631
  }
38847
39632
  );
38848
39633
  };
38849
39634
 
38850
39635
  // src/providers/BankTransactionsProvider/BankTransactionsProvider.tsx
38851
- var import_jsx_runtime349 = require("react/jsx-runtime");
39636
+ var import_jsx_runtime352 = require("react/jsx-runtime");
38852
39637
  var BankTransactionsProvider = ({
38853
39638
  children
38854
39639
  }) => {
38855
39640
  const bankTransactionsContextData = useAugmentedBankTransactions();
38856
- return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(BankTransactionsContext.Provider, { value: bankTransactionsContextData, children });
39641
+ return /* @__PURE__ */ (0, import_jsx_runtime352.jsx)(BankTransactionsContext.Provider, { value: bankTransactionsContextData, children });
38857
39642
  };
38858
39643
  // Annotate the CommonJS export names for ESM import in node:
38859
39644
  0 && (module.exports = {