@claritylabs/cl-sdk 3.0.31 → 3.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2957,6 +2957,15 @@ function moneyValue(value) {
2957
2957
  if (/^\d{1,3}(?:,\d{3})*(?:\.\d{2})?$/.test(clean)) return `$${clean}`;
2958
2958
  return clean;
2959
2959
  }
2960
+ function premiumValue(value) {
2961
+ const clean = cleanValue(value);
2962
+ if (!clean) return void 0;
2963
+ if (/\$[A-Z0-9]/i.test(clean)) return clean;
2964
+ if (/\b(?:CAD|USD)\b/i.test(clean) && /(?:\d|X{2,})/i.test(clean)) return clean;
2965
+ if (/^\d{1,3}(?:,\d{3})+\.\d{2}$/.test(clean) || /^\d+\.\d{2}$/.test(clean)) return `$${clean}`;
2966
+ if (/^X{2,}(?:,X{3})*(?:\.X{2})$/i.test(clean)) return clean;
2967
+ return void 0;
2968
+ }
2960
2969
  function nodeText(node) {
2961
2970
  return normalizeWhitespace3([
2962
2971
  node.title,
@@ -3038,7 +3047,11 @@ function firstCleanMatch(nodes, patterns, clean) {
3038
3047
  function cleanNamedInsured(value) {
3039
3048
  const clean = cleanValue(value.replace(/\bborn\s+on\b.*$/i, "").replace(/\bage\s+nearest\b.*$/i, "").replace(/\bbeneficiary\b.*$/i, ""));
3040
3049
  if (!clean || clean.length > 160) return void 0;
3050
+ if (!/[A-Za-z0-9]/.test(clean)) return void 0;
3041
3051
  if (/^(person|persons)\b/i.test(clean)) return void 0;
3052
+ if (/^(insurance amount|benefit amount|policy number|policy date|owner|beneficiary|premium|coverage|risk classification)\b/i.test(clean)) {
3053
+ return void 0;
3054
+ }
3042
3055
  if (/\b(table of contents|policy wording|provided solely|convenience|not to be construed|actual policy issued)\b/i.test(clean)) {
3043
3056
  return void 0;
3044
3057
  }
@@ -3046,7 +3059,8 @@ function cleanNamedInsured(value) {
3046
3059
  }
3047
3060
  function namedInsuredFromNodes(nodes) {
3048
3061
  return firstCleanMatch(nodes, [
3049
- /\b(?:named insured|insured name|insured persons?|insured person)\s*:?\s*(.+?)(?=\s+(?:insurance amount|benefit amount|policy number|policy date|owner|beneficiary|premium|coverage|risk classification|date this)\b|[|;\n]|$)/i,
3062
+ /\b(?:named insured|insured name)\s*:?\s*(.+?)(?=\s+(?:insurance amount|benefit amount|policy number|policy date|owner|beneficiary|premium|coverage|risk classification|date this)\b|[|;\n]|$)/i,
3063
+ /\b(?:insured persons?|insured person)\s*:\s*(.+?)(?=\s+(?:insurance amount|benefit amount|policy number|policy date|owner|beneficiary|premium|coverage|risk classification|date this)\b|[|;\n]|$)/i,
3050
3064
  /\b(?:applicant|policyholder)\s*:?\s*(.+?)(?=\s+(?:coverage|policy number|insurer|carrier|premium|effective|expiration)\b|[|;\n]|$)/i
3051
3065
  ], cleanNamedInsured);
3052
3066
  }
@@ -3113,7 +3127,14 @@ function deductibleFromText(text) {
3113
3127
  return moneyValue(text.match(/\b(?:deductible|retention|sir)\s*:?\s*(\$?\d[\d,]*(?:\.\d{2})?)/i)?.[1]);
3114
3128
  }
3115
3129
  function premiumFromText(text) {
3116
- return moneyValue(text.match(/\b(?:premium|total premium|total cost|amount due)\s*:?\s*(\$?\d[\d,]*(?:\.\d{2})?)/i)?.[1]);
3130
+ return premiumValue(text.match(/\b(?:premium|total premium|total cost|amount due)\b(?:\s*(?:is|:|-))?\s*(\$?(?:\d[\d,]*(?:\.\d{2})?|X{2,}(?:,X{3})*(?:\.X{2})?))/i)?.[1]);
3131
+ }
3132
+ function premiumFromNodes(nodes) {
3133
+ for (const node of compactFactNodes(nodes)) {
3134
+ const value = premiumFromText(nodeText(node));
3135
+ if (value) return valueFromNode(node, value, "high");
3136
+ }
3137
+ return void 0;
3117
3138
  }
3118
3139
  function moneyAmount(value) {
3119
3140
  const match = value?.match(/\$?\s*([0-9][0-9,]*(?:\.\d+)?)/);
@@ -3535,9 +3556,7 @@ function buildDeterministicOperationalProfile(params) {
3535
3556
  retroactiveDate: firstMatch(nodes, [
3536
3557
  /\bretroactive date\s*:?\s*([0-9]{1,2}[/-][0-9]{1,2}[/-][0-9]{2,4}|full prior acts|none)/i
3537
3558
  ]),
3538
- premium: firstMatch(nodes, [
3539
- /\b(?:total premium|premium|total cost|amount due)\s*:?\s*(\$?\d[\d,]*(?:\.\d{2})?)/i
3540
- ])
3559
+ premium: premiumFromNodes(nodes)
3541
3560
  };
3542
3561
  const coverages = buildCoverages(nodes);
3543
3562
  const coverageTypes = [...new Set(coverages.map((coverage) => coverage.name))];