formanitor 0.0.37 → 0.0.38

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.cjs CHANGED
@@ -129,6 +129,13 @@ function validateForm(values, fields) {
129
129
  }
130
130
 
131
131
  // src/core/rules.ts
132
+ function tokenListContainsString(text, needle) {
133
+ if (typeof text !== "string") return false;
134
+ const want = String(needle).trim();
135
+ if (!want) return false;
136
+ const parts = text.split(",").map((p) => p.trim()).filter(Boolean);
137
+ return parts.includes(want);
138
+ }
132
139
  function evaluateCondition(value, condition) {
133
140
  switch (condition.op) {
134
141
  case "==":
@@ -147,7 +154,13 @@ function evaluateCondition(value, condition) {
147
154
  case "in":
148
155
  return Array.isArray(condition.value) && condition.value.includes(value);
149
156
  case "contains":
150
- return Array.isArray(value) && value.includes(condition.value);
157
+ if (Array.isArray(value)) {
158
+ return value.includes(condition.value);
159
+ }
160
+ if (typeof value === "string") {
161
+ return tokenListContainsString(value, condition.value);
162
+ }
163
+ return false;
151
164
  default:
152
165
  return false;
153
166
  }
@@ -267,8 +280,47 @@ var FormStore = class {
267
280
  values[field.id] = field.defaultValue;
268
281
  } else {
269
282
  if (field.type === "repeatable") values[field.id] = [];
270
- else if (field.type === "checkbox") values[field.id] = [];
283
+ else if (field.type === "checkbox" || field.type === "multiselect") values[field.id] = [];
271
284
  else if (field.type === "smart_textarea") values[field.id] = { text: "", extractedKeywords: [] };
285
+ else if (field.type === "suggestion_textarea" || field.type === "complaint_chips") values[field.id] = "";
286
+ else if (field.type === "lens_assessment")
287
+ values[field.id] = {
288
+ notes: "",
289
+ assessmentKey: void 0,
290
+ locs: {
291
+ OD: { NO: 0, NC: 0, C: 0, PSC: 0 },
292
+ OS: { NO: 0, NC: 0, C: 0, PSC: 0 }
293
+ }
294
+ };
295
+ else if (field.type === "functional_impairment_score")
296
+ values[field.id] = {
297
+ reading: 0,
298
+ nightDriving: 0,
299
+ glare: 0,
300
+ occupation: 0,
301
+ adl: 0
302
+ };
303
+ else if (field.type === "biometry_iol_workup")
304
+ values[field.id] = {
305
+ axialLengthOD: "",
306
+ axialLengthOS: "",
307
+ k1k2AxisOD: "",
308
+ k1k2AxisOS: "",
309
+ anteriorChamberDepthOD: "",
310
+ anteriorChamberDepthOS: "",
311
+ iolPowerOD: "",
312
+ iolPowerOS: "",
313
+ targetRefractionOD: "",
314
+ targetRefractionOS: "",
315
+ formula: "SRK/T",
316
+ method: "optical_biometry",
317
+ cornealTopoUploaded: false,
318
+ specularMicroscopyDone: false,
319
+ endothelialCount: ""
320
+ };
321
+ else if (field.type === "surgical_risk_flags")
322
+ values[field.id] = { OD: [], OS: [] };
323
+ else if (field.type === "toggle") values[field.id] = false;
272
324
  else values[field.id] = null;
273
325
  }
274
326
  });
@@ -6100,6 +6152,12 @@ var tableCellClass = "border border-[#E0E0E0] px-1.5 py-1 text-center align-midd
6100
6152
  var selectClass = "w-full border border-[#D0D0D0] rounded-md bg-white px-2 py-1 text-xs focus-visible:outline-none focus-visible:ring-0";
6101
6153
  var numberInputClass = "w-full border border-[#D0D0D0] rounded-md bg-white px-2 py-1 text-xs text-right focus-visible:outline-none focus-visible:ring-0";
6102
6154
  var textInputClass = "w-full border border-[#D0D0D0] rounded-md bg-white px-2 py-1 text-xs focus-visible:outline-none focus-visible:ring-0";
6155
+ var refractionTableClass = "w-full table-fixed border-collapse text-xs";
6156
+ var refractionHeaderCellClass = "border border-[#E0E0E0] bg-[#F7F7F7] px-1 py-1 text-center font-semibold text-[11px]";
6157
+ var refractionDataCellClass = "border border-[#E0E0E0] p-0 text-center align-middle min-w-0";
6158
+ var refractionLabelCellClass = "border border-[#E0E0E0] px-2 py-1 text-left align-middle font-semibold whitespace-nowrap";
6159
+ var refractionInputClass = "h-7 w-full min-w-0 border-0 rounded-none bg-transparent px-1 py-0.5 text-xs text-right shadow-none ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 disabled:opacity-50";
6160
+ var refractionSelectClass = "box-border h-7 w-full min-w-0 max-w-full cursor-pointer border-0 rounded-none bg-transparent px-1 py-0.5 pr-6 text-xs shadow-none focus-visible:outline-none focus-visible:ring-0 disabled:opacity-50";
6103
6161
  var OphthalmologyWidget = ({ fieldId }) => {
6104
6162
  const { fieldDef, value, setValue, disabled } = useField(fieldId);
6105
6163
  const safe = React15.useMemo(() => ensureValue(value), [value]);
@@ -6331,34 +6389,45 @@ var OphthalmologyWidget = ({ fieldId }) => {
6331
6389
  ] }),
6332
6390
  /* @__PURE__ */ jsxRuntime.jsxs("section", { className: sectionWrapperClass, children: [
6333
6391
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Current Glass Prescription" }) }),
6334
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: tableBaseClass, children: [
6392
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: refractionTableClass, children: [
6393
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
6394
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[10%]" }),
6395
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6396
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6397
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6398
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[25%]" }),
6399
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6400
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6401
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6402
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[25%]" })
6403
+ ] }),
6335
6404
  /* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
6336
6405
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6337
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6338
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 4, children: "Right Eye" }),
6339
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 4, children: "Left Eye" })
6406
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6407
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 4, children: "Right Eye" }),
6408
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 4, children: "Left Eye" })
6340
6409
  ] }),
6341
6410
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6342
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6343
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6344
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6345
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6346
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6347
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6348
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6349
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6350
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" })
6411
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6412
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6413
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6414
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6415
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6416
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6417
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6418
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6419
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" })
6351
6420
  ] })
6352
6421
  ] }),
6353
6422
  /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6354
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Current Glass" }),
6355
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6423
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Current Glass" }),
6424
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6356
6425
  Input,
6357
6426
  {
6358
6427
  disabled,
6359
6428
  type: "number",
6360
6429
  step: "0.25",
6361
- className: numberInputClass,
6430
+ className: refractionInputClass,
6362
6431
  value: safe.current_glass_prescription.right_eye.sph ?? "",
6363
6432
  onChange: (e) => setRefractionField(
6364
6433
  "current_glass_prescription",
@@ -6369,13 +6438,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6369
6438
  )
6370
6439
  }
6371
6440
  ) }),
6372
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6441
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6373
6442
  Input,
6374
6443
  {
6375
6444
  disabled,
6376
6445
  type: "number",
6377
6446
  step: "0.25",
6378
- className: numberInputClass,
6447
+ className: refractionInputClass,
6379
6448
  value: safe.current_glass_prescription.right_eye.cyl ?? "",
6380
6449
  onChange: (e) => setRefractionField(
6381
6450
  "current_glass_prescription",
@@ -6386,12 +6455,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6386
6455
  )
6387
6456
  }
6388
6457
  ) }),
6389
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6458
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6390
6459
  Input,
6391
6460
  {
6392
6461
  disabled,
6393
6462
  type: "number",
6394
- className: numberInputClass,
6463
+ className: refractionInputClass,
6395
6464
  value: safe.current_glass_prescription.right_eye.axis ?? "",
6396
6465
  onChange: (e) => setRefractionField(
6397
6466
  "current_glass_prescription",
@@ -6402,11 +6471,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6402
6471
  )
6403
6472
  }
6404
6473
  ) }),
6405
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6474
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6406
6475
  "select",
6407
6476
  {
6408
6477
  disabled,
6409
- className: selectClass,
6478
+ className: refractionSelectClass,
6410
6479
  value: safe.current_glass_prescription.right_eye.va,
6411
6480
  onChange: (e) => setRefractionField(
6412
6481
  "current_glass_prescription",
@@ -6418,13 +6487,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6418
6487
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
6419
6488
  }
6420
6489
  ) }),
6421
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6490
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6422
6491
  Input,
6423
6492
  {
6424
6493
  disabled,
6425
6494
  type: "number",
6426
6495
  step: "0.25",
6427
- className: numberInputClass,
6496
+ className: refractionInputClass,
6428
6497
  value: safe.current_glass_prescription.left_eye.sph ?? "",
6429
6498
  onChange: (e) => setRefractionField(
6430
6499
  "current_glass_prescription",
@@ -6435,13 +6504,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6435
6504
  )
6436
6505
  }
6437
6506
  ) }),
6438
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6507
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6439
6508
  Input,
6440
6509
  {
6441
6510
  disabled,
6442
6511
  type: "number",
6443
6512
  step: "0.25",
6444
- className: numberInputClass,
6513
+ className: refractionInputClass,
6445
6514
  value: safe.current_glass_prescription.left_eye.cyl ?? "",
6446
6515
  onChange: (e) => setRefractionField(
6447
6516
  "current_glass_prescription",
@@ -6452,12 +6521,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6452
6521
  )
6453
6522
  }
6454
6523
  ) }),
6455
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6524
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6456
6525
  Input,
6457
6526
  {
6458
6527
  disabled,
6459
6528
  type: "number",
6460
- className: numberInputClass,
6529
+ className: refractionInputClass,
6461
6530
  value: safe.current_glass_prescription.left_eye.axis ?? "",
6462
6531
  onChange: (e) => setRefractionField(
6463
6532
  "current_glass_prescription",
@@ -6468,11 +6537,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6468
6537
  )
6469
6538
  }
6470
6539
  ) }),
6471
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6540
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6472
6541
  "select",
6473
6542
  {
6474
6543
  disabled,
6475
- className: selectClass,
6544
+ className: refractionSelectClass,
6476
6545
  value: safe.current_glass_prescription.left_eye.va,
6477
6546
  onChange: (e) => setRefractionField(
6478
6547
  "current_glass_prescription",
@@ -6581,37 +6650,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6581
6650
  ] }),
6582
6651
  /* @__PURE__ */ jsxRuntime.jsxs("section", { className: sectionWrapperClass, children: [
6583
6652
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Refraction (Distance)" }) }),
6584
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: tableBaseClass, children: [
6653
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: refractionTableClass, children: [
6654
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
6655
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[10%]" }),
6656
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6657
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6658
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6659
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[13%]" }),
6660
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[12%]" }),
6661
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6662
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6663
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6664
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[13%]" }),
6665
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[12%]" })
6666
+ ] }),
6585
6667
  /* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
6586
6668
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6587
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6588
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6589
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Left Eye" })
6669
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6670
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6671
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Left Eye" })
6590
6672
  ] }),
6591
6673
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6592
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6593
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6594
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6595
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6596
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6597
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "P/D" }),
6598
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6599
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6600
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6601
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6602
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "P/D" })
6674
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6675
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6676
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6677
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6678
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6679
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "P/D" }),
6680
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6681
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6682
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6683
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6684
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "P/D" })
6603
6685
  ] })
6604
6686
  ] }),
6605
6687
  /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
6606
6688
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6607
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Distance" }),
6608
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6689
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Distance" }),
6690
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6609
6691
  Input,
6610
6692
  {
6611
6693
  disabled,
6612
6694
  type: "number",
6613
6695
  step: "0.25",
6614
- className: numberInputClass,
6696
+ className: refractionInputClass,
6615
6697
  value: safe.refraction.right_eye.sph ?? "",
6616
6698
  onChange: (e) => setRefractionField(
6617
6699
  "refraction",
@@ -6622,13 +6704,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6622
6704
  )
6623
6705
  }
6624
6706
  ) }),
6625
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6707
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6626
6708
  Input,
6627
6709
  {
6628
6710
  disabled,
6629
6711
  type: "number",
6630
6712
  step: "0.25",
6631
- className: numberInputClass,
6713
+ className: refractionInputClass,
6632
6714
  value: safe.refraction.right_eye.cyl ?? "",
6633
6715
  onChange: (e) => setRefractionField(
6634
6716
  "refraction",
@@ -6639,12 +6721,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6639
6721
  )
6640
6722
  }
6641
6723
  ) }),
6642
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6724
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6643
6725
  Input,
6644
6726
  {
6645
6727
  disabled,
6646
6728
  type: "number",
6647
- className: numberInputClass,
6729
+ className: refractionInputClass,
6648
6730
  value: safe.refraction.right_eye.axis ?? "",
6649
6731
  onChange: (e) => setRefractionField(
6650
6732
  "refraction",
@@ -6655,11 +6737,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6655
6737
  )
6656
6738
  }
6657
6739
  ) }),
6658
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6740
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6659
6741
  "select",
6660
6742
  {
6661
6743
  disabled,
6662
- className: selectClass,
6744
+ className: refractionSelectClass,
6663
6745
  value: safe.refraction.right_eye.va,
6664
6746
  onChange: (e) => setRefractionField(
6665
6747
  "refraction",
@@ -6671,7 +6753,7 @@ var OphthalmologyWidget = ({ fieldId }) => {
6671
6753
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
6672
6754
  }
6673
6755
  ) }),
6674
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6756
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6675
6757
  Input,
6676
6758
  {
6677
6759
  disabled,
@@ -6679,18 +6761,18 @@ var OphthalmologyWidget = ({ fieldId }) => {
6679
6761
  min: 10,
6680
6762
  max: 45,
6681
6763
  step: "1",
6682
- className: numberInputClass,
6764
+ className: refractionInputClass,
6683
6765
  value: safe.refraction.right_eye.pd ?? "",
6684
6766
  onChange: (e) => setRefractionField("refraction", "right_eye", "pd", e.target.value, "int")
6685
6767
  }
6686
6768
  ) }),
6687
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6769
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6688
6770
  Input,
6689
6771
  {
6690
6772
  disabled,
6691
6773
  type: "number",
6692
6774
  step: "0.25",
6693
- className: numberInputClass,
6775
+ className: refractionInputClass,
6694
6776
  value: safe.refraction.left_eye.sph ?? "",
6695
6777
  onChange: (e) => setRefractionField(
6696
6778
  "refraction",
@@ -6701,13 +6783,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6701
6783
  )
6702
6784
  }
6703
6785
  ) }),
6704
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6786
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6705
6787
  Input,
6706
6788
  {
6707
6789
  disabled,
6708
6790
  type: "number",
6709
6791
  step: "0.25",
6710
- className: numberInputClass,
6792
+ className: refractionInputClass,
6711
6793
  value: safe.refraction.left_eye.cyl ?? "",
6712
6794
  onChange: (e) => setRefractionField(
6713
6795
  "refraction",
@@ -6718,12 +6800,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6718
6800
  )
6719
6801
  }
6720
6802
  ) }),
6721
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6803
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6722
6804
  Input,
6723
6805
  {
6724
6806
  disabled,
6725
6807
  type: "number",
6726
- className: numberInputClass,
6808
+ className: refractionInputClass,
6727
6809
  value: safe.refraction.left_eye.axis ?? "",
6728
6810
  onChange: (e) => setRefractionField(
6729
6811
  "refraction",
@@ -6734,11 +6816,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6734
6816
  )
6735
6817
  }
6736
6818
  ) }),
6737
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6819
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6738
6820
  "select",
6739
6821
  {
6740
6822
  disabled,
6741
- className: selectClass,
6823
+ className: refractionSelectClass,
6742
6824
  value: safe.refraction.left_eye.va,
6743
6825
  onChange: (e) => setRefractionField(
6744
6826
  "refraction",
@@ -6750,7 +6832,7 @@ var OphthalmologyWidget = ({ fieldId }) => {
6750
6832
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
6751
6833
  }
6752
6834
  ) }),
6753
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6835
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6754
6836
  Input,
6755
6837
  {
6756
6838
  disabled,
@@ -6758,32 +6840,32 @@ var OphthalmologyWidget = ({ fieldId }) => {
6758
6840
  min: 10,
6759
6841
  max: 45,
6760
6842
  step: "1",
6761
- className: numberInputClass,
6843
+ className: refractionInputClass,
6762
6844
  value: safe.refraction.left_eye.pd ?? "",
6763
6845
  onChange: (e) => setRefractionField("refraction", "left_eye", "pd", e.target.value, "int")
6764
6846
  }
6765
6847
  ) })
6766
6848
  ] }),
6767
6849
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6768
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
6769
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
6850
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Add" }),
6851
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
6770
6852
  Input,
6771
6853
  {
6772
6854
  disabled,
6773
6855
  type: "number",
6774
6856
  step: "0.25",
6775
- className: numberInputClass,
6857
+ className: refractionInputClass,
6776
6858
  value: safe.refraction.add.right ?? "",
6777
6859
  onChange: (e) => setRefractionAdd("refraction", "right", e.target.value)
6778
6860
  }
6779
6861
  ) }),
6780
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
6862
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
6781
6863
  Input,
6782
6864
  {
6783
6865
  disabled,
6784
6866
  type: "number",
6785
6867
  step: "0.25",
6786
- className: numberInputClass,
6868
+ className: refractionInputClass,
6787
6869
  value: safe.refraction.add.left ?? "",
6788
6870
  onChange: (e) => setRefractionAdd("refraction", "left", e.target.value)
6789
6871
  }
@@ -6794,37 +6876,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6794
6876
  ] }),
6795
6877
  /* @__PURE__ */ jsxRuntime.jsxs("section", { className: sectionWrapperClass, children: [
6796
6878
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Dilated Refraction" }) }),
6797
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: tableBaseClass, children: [
6879
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: refractionTableClass, children: [
6880
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
6881
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[10%]" }),
6882
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6883
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6884
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6885
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[8%]" }),
6886
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[17%]" }),
6887
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6888
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6889
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6890
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[8%]" }),
6891
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[17%]" })
6892
+ ] }),
6798
6893
  /* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
6799
6894
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6800
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6801
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6802
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Left Eye" })
6895
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6896
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6897
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Left Eye" })
6803
6898
  ] }),
6804
6899
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6805
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6806
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6807
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6808
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6809
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6810
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6811
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6812
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6813
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6814
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6815
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" })
6900
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6901
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6902
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6903
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6904
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
6905
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6906
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6907
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6908
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6909
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
6910
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" })
6816
6911
  ] })
6817
6912
  ] }),
6818
6913
  /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
6819
6914
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6820
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Dilated" }),
6821
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6915
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Dilated" }),
6916
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6822
6917
  Input,
6823
6918
  {
6824
6919
  disabled,
6825
6920
  type: "number",
6826
6921
  step: "0.25",
6827
- className: numberInputClass,
6922
+ className: refractionInputClass,
6828
6923
  value: safe.dilated_refraction.right_eye.sph ?? "",
6829
6924
  onChange: (e) => setRefractionField(
6830
6925
  "dilated_refraction",
@@ -6835,13 +6930,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6835
6930
  )
6836
6931
  }
6837
6932
  ) }),
6838
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6933
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6839
6934
  Input,
6840
6935
  {
6841
6936
  disabled,
6842
6937
  type: "number",
6843
6938
  step: "0.25",
6844
- className: numberInputClass,
6939
+ className: refractionInputClass,
6845
6940
  value: safe.dilated_refraction.right_eye.cyl ?? "",
6846
6941
  onChange: (e) => setRefractionField(
6847
6942
  "dilated_refraction",
@@ -6852,12 +6947,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6852
6947
  )
6853
6948
  }
6854
6949
  ) }),
6855
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6950
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6856
6951
  Input,
6857
6952
  {
6858
6953
  disabled,
6859
6954
  type: "number",
6860
- className: numberInputClass,
6955
+ className: refractionInputClass,
6861
6956
  value: safe.dilated_refraction.right_eye.axis ?? "",
6862
6957
  onChange: (e) => setRefractionField(
6863
6958
  "dilated_refraction",
@@ -6868,13 +6963,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6868
6963
  )
6869
6964
  }
6870
6965
  ) }),
6871
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6966
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6872
6967
  Input,
6873
6968
  {
6874
6969
  disabled,
6875
6970
  type: "number",
6876
6971
  step: "0.25",
6877
- className: numberInputClass,
6972
+ className: refractionInputClass,
6878
6973
  value: safe.dilated_refraction.right_eye.prism ?? "",
6879
6974
  onChange: (e) => setRefractionField(
6880
6975
  "dilated_refraction",
@@ -6885,11 +6980,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6885
6980
  )
6886
6981
  }
6887
6982
  ) }),
6888
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6983
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6889
6984
  "select",
6890
6985
  {
6891
6986
  disabled,
6892
- className: selectClass,
6987
+ className: refractionSelectClass,
6893
6988
  value: safe.dilated_refraction.right_eye.va,
6894
6989
  onChange: (e) => setRefractionField(
6895
6990
  "dilated_refraction",
@@ -6901,13 +6996,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6901
6996
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
6902
6997
  }
6903
6998
  ) }),
6904
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6999
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6905
7000
  Input,
6906
7001
  {
6907
7002
  disabled,
6908
7003
  type: "number",
6909
7004
  step: "0.25",
6910
- className: numberInputClass,
7005
+ className: refractionInputClass,
6911
7006
  value: safe.dilated_refraction.left_eye.sph ?? "",
6912
7007
  onChange: (e) => setRefractionField(
6913
7008
  "dilated_refraction",
@@ -6918,13 +7013,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6918
7013
  )
6919
7014
  }
6920
7015
  ) }),
6921
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7016
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6922
7017
  Input,
6923
7018
  {
6924
7019
  disabled,
6925
7020
  type: "number",
6926
7021
  step: "0.25",
6927
- className: numberInputClass,
7022
+ className: refractionInputClass,
6928
7023
  value: safe.dilated_refraction.left_eye.cyl ?? "",
6929
7024
  onChange: (e) => setRefractionField(
6930
7025
  "dilated_refraction",
@@ -6935,12 +7030,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6935
7030
  )
6936
7031
  }
6937
7032
  ) }),
6938
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7033
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6939
7034
  Input,
6940
7035
  {
6941
7036
  disabled,
6942
7037
  type: "number",
6943
- className: numberInputClass,
7038
+ className: refractionInputClass,
6944
7039
  value: safe.dilated_refraction.left_eye.axis ?? "",
6945
7040
  onChange: (e) => setRefractionField(
6946
7041
  "dilated_refraction",
@@ -6951,13 +7046,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6951
7046
  )
6952
7047
  }
6953
7048
  ) }),
6954
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7049
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6955
7050
  Input,
6956
7051
  {
6957
7052
  disabled,
6958
7053
  type: "number",
6959
7054
  step: "0.25",
6960
- className: numberInputClass,
7055
+ className: refractionInputClass,
6961
7056
  value: safe.dilated_refraction.left_eye.prism ?? "",
6962
7057
  onChange: (e) => setRefractionField(
6963
7058
  "dilated_refraction",
@@ -6968,11 +7063,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6968
7063
  )
6969
7064
  }
6970
7065
  ) }),
6971
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7066
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6972
7067
  "select",
6973
7068
  {
6974
7069
  disabled,
6975
- className: selectClass,
7070
+ className: refractionSelectClass,
6976
7071
  value: safe.dilated_refraction.left_eye.va,
6977
7072
  onChange: (e) => setRefractionField(
6978
7073
  "dilated_refraction",
@@ -6986,25 +7081,25 @@ var OphthalmologyWidget = ({ fieldId }) => {
6986
7081
  ) })
6987
7082
  ] }),
6988
7083
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6989
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
6990
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7084
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Add" }),
7085
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
6991
7086
  Input,
6992
7087
  {
6993
7088
  disabled,
6994
7089
  type: "number",
6995
7090
  step: "0.25",
6996
- className: numberInputClass,
7091
+ className: refractionInputClass,
6997
7092
  value: safe.dilated_refraction.add.right ?? "",
6998
7093
  onChange: (e) => setRefractionAdd("dilated_refraction", "right", e.target.value)
6999
7094
  }
7000
7095
  ) }),
7001
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7096
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7002
7097
  Input,
7003
7098
  {
7004
7099
  disabled,
7005
7100
  type: "number",
7006
7101
  step: "0.25",
7007
- className: numberInputClass,
7102
+ className: refractionInputClass,
7008
7103
  value: safe.dilated_refraction.add.left ?? "",
7009
7104
  onChange: (e) => setRefractionAdd("dilated_refraction", "left", e.target.value)
7010
7105
  }
@@ -7015,37 +7110,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
7015
7110
  ] }),
7016
7111
  /* @__PURE__ */ jsxRuntime.jsxs("section", { className: sectionWrapperClass, children: [
7017
7112
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Glass Power Prescription" }) }),
7018
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: tableBaseClass, children: [
7113
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: refractionTableClass, children: [
7114
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
7115
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[10%]" }),
7116
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7117
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7118
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
7119
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[8%]" }),
7120
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[17%]" }),
7121
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7122
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7123
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
7124
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[8%]" }),
7125
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[17%]" })
7126
+ ] }),
7019
7127
  /* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
7020
7128
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
7021
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
7022
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
7023
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Left Eye" })
7129
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
7130
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Right Eye" }),
7131
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Left Eye" })
7024
7132
  ] }),
7025
7133
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
7026
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
7027
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
7028
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
7029
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
7030
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
7031
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
7032
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
7033
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
7034
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
7035
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
7036
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" })
7134
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
7135
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
7136
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
7137
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
7138
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
7139
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
7140
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
7141
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
7142
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
7143
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
7144
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" })
7037
7145
  ] })
7038
7146
  ] }),
7039
7147
  /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
7040
7148
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
7041
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Glass Power" }),
7042
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7149
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Glass Power" }),
7150
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7043
7151
  Input,
7044
7152
  {
7045
7153
  disabled,
7046
7154
  type: "number",
7047
7155
  step: "0.25",
7048
- className: numberInputClass,
7156
+ className: refractionInputClass,
7049
7157
  value: safe.glass_power_prescription.right_eye.sph ?? "",
7050
7158
  onChange: (e) => setRefractionField(
7051
7159
  "glass_power_prescription",
@@ -7056,13 +7164,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7056
7164
  )
7057
7165
  }
7058
7166
  ) }),
7059
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7167
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7060
7168
  Input,
7061
7169
  {
7062
7170
  disabled,
7063
7171
  type: "number",
7064
7172
  step: "0.25",
7065
- className: numberInputClass,
7173
+ className: refractionInputClass,
7066
7174
  value: safe.glass_power_prescription.right_eye.cyl ?? "",
7067
7175
  onChange: (e) => setRefractionField(
7068
7176
  "glass_power_prescription",
@@ -7073,12 +7181,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
7073
7181
  )
7074
7182
  }
7075
7183
  ) }),
7076
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7184
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7077
7185
  Input,
7078
7186
  {
7079
7187
  disabled,
7080
7188
  type: "number",
7081
- className: numberInputClass,
7189
+ className: refractionInputClass,
7082
7190
  value: safe.glass_power_prescription.right_eye.axis ?? "",
7083
7191
  onChange: (e) => setRefractionField(
7084
7192
  "glass_power_prescription",
@@ -7089,13 +7197,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7089
7197
  )
7090
7198
  }
7091
7199
  ) }),
7092
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7200
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7093
7201
  Input,
7094
7202
  {
7095
7203
  disabled,
7096
7204
  type: "number",
7097
7205
  step: "0.25",
7098
- className: numberInputClass,
7206
+ className: refractionInputClass,
7099
7207
  value: safe.glass_power_prescription.right_eye.prism ?? "",
7100
7208
  onChange: (e) => setRefractionField(
7101
7209
  "glass_power_prescription",
@@ -7106,11 +7214,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
7106
7214
  )
7107
7215
  }
7108
7216
  ) }),
7109
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7217
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7110
7218
  "select",
7111
7219
  {
7112
7220
  disabled,
7113
- className: selectClass,
7221
+ className: refractionSelectClass,
7114
7222
  value: safe.glass_power_prescription.right_eye.va,
7115
7223
  onChange: (e) => setRefractionField(
7116
7224
  "glass_power_prescription",
@@ -7122,13 +7230,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7122
7230
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
7123
7231
  }
7124
7232
  ) }),
7125
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7233
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7126
7234
  Input,
7127
7235
  {
7128
7236
  disabled,
7129
7237
  type: "number",
7130
7238
  step: "0.25",
7131
- className: numberInputClass,
7239
+ className: refractionInputClass,
7132
7240
  value: safe.glass_power_prescription.left_eye.sph ?? "",
7133
7241
  onChange: (e) => setRefractionField(
7134
7242
  "glass_power_prescription",
@@ -7139,13 +7247,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7139
7247
  )
7140
7248
  }
7141
7249
  ) }),
7142
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7250
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7143
7251
  Input,
7144
7252
  {
7145
7253
  disabled,
7146
7254
  type: "number",
7147
7255
  step: "0.25",
7148
- className: numberInputClass,
7256
+ className: refractionInputClass,
7149
7257
  value: safe.glass_power_prescription.left_eye.cyl ?? "",
7150
7258
  onChange: (e) => setRefractionField(
7151
7259
  "glass_power_prescription",
@@ -7156,12 +7264,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
7156
7264
  )
7157
7265
  }
7158
7266
  ) }),
7159
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7267
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7160
7268
  Input,
7161
7269
  {
7162
7270
  disabled,
7163
7271
  type: "number",
7164
- className: numberInputClass,
7272
+ className: refractionInputClass,
7165
7273
  value: safe.glass_power_prescription.left_eye.axis ?? "",
7166
7274
  onChange: (e) => setRefractionField(
7167
7275
  "glass_power_prescription",
@@ -7172,13 +7280,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7172
7280
  )
7173
7281
  }
7174
7282
  ) }),
7175
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7283
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7176
7284
  Input,
7177
7285
  {
7178
7286
  disabled,
7179
7287
  type: "number",
7180
7288
  step: "0.25",
7181
- className: numberInputClass,
7289
+ className: refractionInputClass,
7182
7290
  value: safe.glass_power_prescription.left_eye.prism ?? "",
7183
7291
  onChange: (e) => setRefractionField(
7184
7292
  "glass_power_prescription",
@@ -7189,11 +7297,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
7189
7297
  )
7190
7298
  }
7191
7299
  ) }),
7192
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7300
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7193
7301
  "select",
7194
7302
  {
7195
7303
  disabled,
7196
- className: selectClass,
7304
+ className: refractionSelectClass,
7197
7305
  value: safe.glass_power_prescription.left_eye.va,
7198
7306
  onChange: (e) => setRefractionField(
7199
7307
  "glass_power_prescription",
@@ -7207,25 +7315,25 @@ var OphthalmologyWidget = ({ fieldId }) => {
7207
7315
  ) })
7208
7316
  ] }),
7209
7317
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
7210
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
7211
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7318
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Add" }),
7319
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7212
7320
  Input,
7213
7321
  {
7214
7322
  disabled,
7215
7323
  type: "number",
7216
7324
  step: "0.25",
7217
- className: numberInputClass,
7325
+ className: refractionInputClass,
7218
7326
  value: safe.glass_power_prescription.add.right ?? "",
7219
7327
  onChange: (e) => setRefractionAdd("glass_power_prescription", "right", e.target.value)
7220
7328
  }
7221
7329
  ) }),
7222
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7330
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7223
7331
  Input,
7224
7332
  {
7225
7333
  disabled,
7226
7334
  type: "number",
7227
7335
  step: "0.25",
7228
- className: numberInputClass,
7336
+ className: refractionInputClass,
7229
7337
  value: safe.glass_power_prescription.add.left ?? "",
7230
7338
  onChange: (e) => setRefractionAdd("glass_power_prescription", "left", e.target.value)
7231
7339
  }
@@ -7912,6 +8020,930 @@ var DischargeMedicationOrdersWidget = ({ fieldId }) => {
7912
8020
  showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
7913
8021
  ] });
7914
8022
  };
8023
+ var DEFAULT_TOKEN_SEPARATOR = ", ";
8024
+ function getAppendSeparator(def) {
8025
+ const raw = def.meta && typeof def.meta.appendSeparator === "string" ? def.meta.appendSeparator : DEFAULT_TOKEN_SEPARATOR;
8026
+ return raw;
8027
+ }
8028
+ function getSuggestionTokensFromText(text) {
8029
+ return text.split(",").map((p) => p.trim()).filter(Boolean);
8030
+ }
8031
+ function toggleSuggestionTokenInText(current, token, separator = DEFAULT_TOKEN_SEPARATOR) {
8032
+ const t = String(token).trim();
8033
+ if (!t) return current;
8034
+ const parts = getSuggestionTokensFromText(current);
8035
+ const i = parts.findIndex((p) => p === t);
8036
+ if (i >= 0) {
8037
+ parts.splice(i, 1);
8038
+ } else {
8039
+ parts.push(t);
8040
+ }
8041
+ return parts.join(separator);
8042
+ }
8043
+ function isTokenSelected(text, optionValue) {
8044
+ const t = String(optionValue).trim();
8045
+ if (!t) return false;
8046
+ return getSuggestionTokensFromText(text).some((p) => p === t);
8047
+ }
8048
+ function deriveKnownSuggestionChipValues(text, options) {
8049
+ if (!options.length) return [];
8050
+ const allowed = new Map(options.map((o) => [String(o.value), o.value]));
8051
+ const tokens = getSuggestionTokensFromText(text);
8052
+ const out = [];
8053
+ const seen = /* @__PURE__ */ new Set();
8054
+ for (const t of tokens) {
8055
+ if (!allowed.has(t) || seen.has(t)) continue;
8056
+ seen.add(t);
8057
+ out.push(allowed.get(t));
8058
+ }
8059
+ return out;
8060
+ }
8061
+ function parallelChipArraysEqual(a, b) {
8062
+ if (!Array.isArray(a) || !Array.isArray(b)) return false;
8063
+ if (a.length !== b.length) return false;
8064
+ for (let i = 0; i < a.length; i++) {
8065
+ if (a[i] !== b[i]) return false;
8066
+ }
8067
+ return true;
8068
+ }
8069
+ function isSuggestionField(type) {
8070
+ return type === "suggestion_textarea" || type === "complaint_chips";
8071
+ }
8072
+ var SuggestionTextareaWidget = ({ fieldId }) => {
8073
+ const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
8074
+ const { state } = useForm();
8075
+ const store = useFormStore();
8076
+ const hasVoice = !!(fieldDef?.voice && store.getVoice());
8077
+ const [options, setOptions] = React15.useState([]);
8078
+ const [loading, setLoading] = React15.useState(false);
8079
+ const showError = !!error && (touched || state.submitAttempted);
8080
+ const def = fieldDef && isSuggestionField(fieldDef.type) ? fieldDef : void 0;
8081
+ const textValue = value == null || typeof value === "string" ? value || "" : String(value);
8082
+ const parallelChipFieldId = def?.meta && typeof def.meta.parallelChipFieldId === "string" ? def.meta.parallelChipFieldId.trim() : void 0;
8083
+ React15.useEffect(() => {
8084
+ if (!def) {
8085
+ setOptions([]);
8086
+ return;
8087
+ }
8088
+ if (def.options?.length) {
8089
+ setOptions(def.options);
8090
+ } else if (def.dataSource) {
8091
+ setLoading(true);
8092
+ fetchOptions(def.dataSource.source, def.dataSource.params).then((opts) => setOptions(opts)).finally(() => setLoading(false));
8093
+ } else {
8094
+ setOptions([]);
8095
+ }
8096
+ }, [def]);
8097
+ React15.useEffect(() => {
8098
+ if (!parallelChipFieldId || !def) return;
8099
+ const parallelDef = store.getFieldDef(parallelChipFieldId);
8100
+ if (!parallelDef || parallelDef.type !== "multiselect") return;
8101
+ const next = deriveKnownSuggestionChipValues(textValue, options);
8102
+ const prev = store.getFieldState(parallelChipFieldId).value;
8103
+ if (parallelChipArraysEqual(prev, next)) return;
8104
+ store.setValues({ [parallelChipFieldId]: next }, { touch: false });
8105
+ }, [def, parallelChipFieldId, textValue, options, store]);
8106
+ if (!def) {
8107
+ return null;
8108
+ }
8109
+ const appendSeparator = getAppendSeparator(def);
8110
+ const suggestionsAria = def.meta && typeof def.meta.suggestionsAriaLabel === "string" ? def.meta.suggestionsAriaLabel : "Quick suggestions";
8111
+ const theme = getThemeConfig("textarea", def.theme);
8112
+ const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
8113
+ const labelClass = theme?.labelClassName;
8114
+ const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
8115
+ const height = def.height != null ? typeof def.height === "string" ? Number(def.height) || void 0 : def.height : void 0;
8116
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8117
+ def.label,
8118
+ " ",
8119
+ def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
8120
+ ] });
8121
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { children: labelContent });
8122
+ const onChipClick = (optValue) => {
8123
+ if (disabled) return;
8124
+ setValue(toggleSuggestionTokenInText(textValue, String(optValue), appendSeparator));
8125
+ };
8126
+ const hasSuggestions = options.length > 0;
8127
+ const isHighlightLabel = def.theme === "highlight-label";
8128
+ const suggestionShellClass = cn(
8129
+ "flex min-w-0 flex-col overflow-hidden",
8130
+ hasSuggestions && (isHighlightLabel ? "-mt-1 rounded-b-md border-[#D0D0D0] bg-white" : "rounded-md border border-input bg-background")
8131
+ );
8132
+ const chipsRowClass = cn(
8133
+ "flex flex-wrap gap-2 px-3 pb-2 pt-3",
8134
+ hasSuggestions && (isHighlightLabel ? "" : "border-b border-input/70"),
8135
+ disabled && "pointer-events-none opacity-50"
8136
+ );
8137
+ const textareaShellClass = cn(
8138
+ inputClass,
8139
+ hasSuggestions && cn(
8140
+ "mt-0 rounded-t-none rounded-b-md border-0 shadow-none focus-visible:ring-offset-0",
8141
+ isHighlightLabel ? "border-t-0" : "min-h-[80px]"
8142
+ )
8143
+ );
8144
+ const suggestionButtons = loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Loading suggestions\u2026" }) : options.map((opt) => {
8145
+ const on = isTokenSelected(textValue, opt.value);
8146
+ return /* @__PURE__ */ jsxRuntime.jsx(
8147
+ "button",
8148
+ {
8149
+ type: "button",
8150
+ onClick: () => onChipClick(opt.value),
8151
+ className: cn(
8152
+ "inline-flex min-h-8 items-center rounded-full border px-3 py-1 text-xs font-medium leading-none transition-colors",
8153
+ on ? "border-primary bg-primary/10 text-primary" : "border-muted-foreground/30 bg-background hover:bg-muted/60"
8154
+ ),
8155
+ children: opt.label
8156
+ },
8157
+ String(opt.value)
8158
+ );
8159
+ });
8160
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
8161
+ hasVoice ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
8162
+ labelEl,
8163
+ /* @__PURE__ */ jsxRuntime.jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
8164
+ ] }) : labelEl,
8165
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: def.description }),
8166
+ hasSuggestions ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: suggestionShellClass, children: [
8167
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: chipsRowClass, role: "group", "aria-label": suggestionsAria, children: suggestionButtons }),
8168
+ /* @__PURE__ */ jsxRuntime.jsx(
8169
+ Textarea,
8170
+ {
8171
+ id: fieldId,
8172
+ value: textValue,
8173
+ onChange: (e) => setValue(e.target.value),
8174
+ onBlur: setTouched,
8175
+ disabled,
8176
+ className: textareaShellClass,
8177
+ placeholder: def.placeholder,
8178
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
8179
+ }
8180
+ )
8181
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
8182
+ Textarea,
8183
+ {
8184
+ id: fieldId,
8185
+ value: textValue,
8186
+ onChange: (e) => setValue(e.target.value),
8187
+ onBlur: setTouched,
8188
+ disabled,
8189
+ className: inputClass,
8190
+ placeholder: def.placeholder,
8191
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
8192
+ }
8193
+ ),
8194
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
8195
+ ] });
8196
+ };
8197
+ var EMPTY_GRADES = { NO: 0, NC: 0, C: 0, PSC: 0 };
8198
+ var LOCS_FIELDS = [
8199
+ { key: "NO", label: "Nuclear Opalescence", max: 4, hint: "0\u20134" },
8200
+ { key: "NC", label: "Nuclear Colour", max: 4, hint: "0\u20134" },
8201
+ { key: "C", label: "Cortical", max: 4, hint: "0\u20134" },
8202
+ { key: "PSC", label: "Posterior Subcapsular", max: 4, hint: "0\u20134" }
8203
+ ];
8204
+ var LOCS_GRID_STYLE = {
8205
+ display: "grid",
8206
+ gridTemplateColumns: "minmax(0, 1fr) minmax(5.5rem, auto) minmax(5.5rem, auto)",
8207
+ columnGap: "1rem",
8208
+ rowGap: "0.5rem",
8209
+ alignItems: "center",
8210
+ width: "100%",
8211
+ minWidth: 0
8212
+ };
8213
+ function parseGrades(raw) {
8214
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
8215
+ const r = raw;
8216
+ const n = (k) => {
8217
+ const v = Number(r[k]);
8218
+ return Number.isFinite(v) ? Math.trunc(v) : 0;
8219
+ };
8220
+ return { NO: n("NO"), NC: n("NC"), C: n("C"), PSC: n("PSC") };
8221
+ }
8222
+ function clampGrade(v) {
8223
+ return Math.max(0, Math.min(4, Math.trunc(v)));
8224
+ }
8225
+ function parseValue(raw) {
8226
+ const locs = {
8227
+ OD: { ...EMPTY_GRADES },
8228
+ OS: { ...EMPTY_GRADES }
8229
+ };
8230
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
8231
+ const o = raw;
8232
+ const locsRaw = o.locs;
8233
+ if (locsRaw && typeof locsRaw === "object" && !Array.isArray(locsRaw)) {
8234
+ const L = locsRaw;
8235
+ const od = parseGrades(L.OD);
8236
+ const os = parseGrades(L.OS);
8237
+ if (od)
8238
+ locs.OD = {
8239
+ NO: clampGrade(od.NO),
8240
+ NC: clampGrade(od.NC),
8241
+ C: clampGrade(od.C),
8242
+ PSC: clampGrade(od.PSC)
8243
+ };
8244
+ if (os)
8245
+ locs.OS = {
8246
+ NO: clampGrade(os.NO),
8247
+ NC: clampGrade(os.NC),
8248
+ C: clampGrade(os.C),
8249
+ PSC: clampGrade(os.PSC)
8250
+ };
8251
+ }
8252
+ return {
8253
+ notes: typeof o.notes === "string" ? o.notes : "",
8254
+ assessmentKey: typeof o.assessmentKey === "string" ? o.assessmentKey : void 0,
8255
+ locs
8256
+ };
8257
+ }
8258
+ return { notes: "", assessmentKey: void 0, locs };
8259
+ }
8260
+ function cataractStage(eye, locs) {
8261
+ const g = locs[eye];
8262
+ const total = g.NO + g.NC + g.C + g.PSC;
8263
+ if (total === 0) return "\u2014";
8264
+ if (total <= 4) return "Early";
8265
+ if (total <= 8) return "Moderate";
8266
+ if (total <= 12) return "Advanced";
8267
+ return "Hypermature";
8268
+ }
8269
+ function Stepper({
8270
+ value,
8271
+ max,
8272
+ disabled,
8273
+ ariaLabel,
8274
+ onChange
8275
+ }) {
8276
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8277
+ "div",
8278
+ {
8279
+ className: "flex items-center gap-1 justify-self-center",
8280
+ role: "group",
8281
+ "aria-label": ariaLabel,
8282
+ children: [
8283
+ /* @__PURE__ */ jsxRuntime.jsx(
8284
+ "button",
8285
+ {
8286
+ type: "button",
8287
+ disabled,
8288
+ onClick: () => onChange(Math.max(0, value - 1)),
8289
+ className: "h-6 w-6 shrink-0 rounded border border-input text-xs hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
8290
+ children: "-"
8291
+ }
8292
+ ),
8293
+ /* @__PURE__ */ jsxRuntime.jsx(
8294
+ "input",
8295
+ {
8296
+ type: "number",
8297
+ min: 0,
8298
+ max,
8299
+ disabled,
8300
+ value,
8301
+ "aria-label": ariaLabel,
8302
+ onChange: (e) => onChange(Math.max(0, Math.min(max, Number(e.target.value) || 0))),
8303
+ className: "h-6 w-10 shrink-0 rounded border border-input bg-background px-1 py-0 text-center text-xs disabled:opacity-50"
8304
+ }
8305
+ ),
8306
+ /* @__PURE__ */ jsxRuntime.jsx(
8307
+ "button",
8308
+ {
8309
+ type: "button",
8310
+ disabled,
8311
+ onClick: () => onChange(Math.min(max, value + 1)),
8312
+ className: "h-6 w-6 shrink-0 rounded border border-input text-xs hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
8313
+ children: "+"
8314
+ }
8315
+ )
8316
+ ]
8317
+ }
8318
+ );
8319
+ }
8320
+ function StageBadge({ stage }) {
8321
+ const cls = {
8322
+ Early: "border border-emerald-200 text-foreground",
8323
+ Moderate: "border border-amber-200 text-foreground",
8324
+ Advanced: "border border-orange-300 text-foreground",
8325
+ Hypermature: "border border-destructive text-foreground",
8326
+ "\u2014": "border border-border text-muted-foreground"
8327
+ };
8328
+ return /* @__PURE__ */ jsxRuntime.jsx(
8329
+ "span",
8330
+ {
8331
+ className: cn(
8332
+ "rounded-full bg-background px-2 py-0.5 text-[11px] font-medium",
8333
+ cls[stage] ?? "border border-border text-muted-foreground"
8334
+ ),
8335
+ children: stage
8336
+ }
8337
+ );
8338
+ }
8339
+ var DEFAULT_TITLE = "Lens Assessment \u2014 LOCS III";
8340
+ var LensAssessmentWidget = ({ fieldId }) => {
8341
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8342
+ const { state } = useForm();
8343
+ const showError = !!error && (touched || state.submitAttempted);
8344
+ if (!fieldDef || fieldDef.type !== "lens_assessment") {
8345
+ return null;
8346
+ }
8347
+ const def = fieldDef;
8348
+ const v = parseValue(value);
8349
+ const locs = v.locs ?? { OD: { ...EMPTY_GRADES }, OS: { ...EMPTY_GRADES } };
8350
+ const title = def.meta?.cardTitle || (def.label?.trim() ? def.label : DEFAULT_TITLE);
8351
+ const setPartial = (patch) => {
8352
+ setValue({ ...v, ...patch, locs: patch.locs ?? v.locs ?? locs });
8353
+ };
8354
+ const setLocs = (eye, key, n) => {
8355
+ const next = clampGrade(n);
8356
+ setPartial({
8357
+ locs: {
8358
+ ...locs,
8359
+ [eye]: { ...locs[eye], [key]: next }
8360
+ }
8361
+ });
8362
+ };
8363
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8364
+ "div",
8365
+ {
8366
+ id: `lens-assessment-${fieldId}`,
8367
+ className: "w-full min-w-0 max-w-full rounded-lg border border-border bg-card p-4 text-card-foreground shadow-sm",
8368
+ children: [
8369
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mb-3 text-sm font-semibold text-foreground", children: title }),
8370
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: LOCS_GRID_STYLE, children: [
8371
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0", "aria-hidden": true }),
8372
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-24 justify-self-center text-center text-xs font-semibold", children: "Right Eye" }),
8373
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-24 justify-self-center text-center text-xs font-semibold", children: "Left Eye" }),
8374
+ LOCS_FIELDS.map((f) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "contents" }, children: [
8375
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 text-xs", children: [
8376
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium", children: f.label }),
8377
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground", children: f.hint })
8378
+ ] }),
8379
+ /* @__PURE__ */ jsxRuntime.jsx(
8380
+ Stepper,
8381
+ {
8382
+ value: locs.OD[f.key],
8383
+ max: f.max,
8384
+ disabled,
8385
+ ariaLabel: `${f.label} right eye`,
8386
+ onChange: (n) => setLocs("OD", f.key, n)
8387
+ }
8388
+ ),
8389
+ /* @__PURE__ */ jsxRuntime.jsx(
8390
+ Stepper,
8391
+ {
8392
+ value: locs.OS[f.key],
8393
+ max: f.max,
8394
+ disabled,
8395
+ ariaLabel: `${f.label} left eye`,
8396
+ onChange: (n) => setLocs("OS", f.key, n)
8397
+ }
8398
+ )
8399
+ ] }, f.key))
8400
+ ] }),
8401
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 border-t border-border pt-3 text-xs", children: [
8402
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Cataract Stage" }),
8403
+ " ",
8404
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 inline-flex items-center gap-1", children: [
8405
+ "OD ",
8406
+ /* @__PURE__ */ jsxRuntime.jsx(StageBadge, { stage: cataractStage("OD", locs) })
8407
+ ] }),
8408
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-2 inline-flex items-center gap-1", children: [
8409
+ "OS ",
8410
+ /* @__PURE__ */ jsxRuntime.jsx(StageBadge, { stage: cataractStage("OS", locs) })
8411
+ ] })
8412
+ ] }),
8413
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8414
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8415
+ ]
8416
+ }
8417
+ );
8418
+ };
8419
+
8420
+ // src/core/functionalImpairmentScore.ts
8421
+ function clampFunctionalScore03(n) {
8422
+ const v = typeof n === "number" ? n : Number(n);
8423
+ if (!Number.isFinite(v)) return 0;
8424
+ return Math.max(0, Math.min(3, Math.trunc(v)));
8425
+ }
8426
+ function parseFunctionalImpairmentScore(raw) {
8427
+ const base = {
8428
+ reading: 0,
8429
+ nightDriving: 0,
8430
+ glare: 0,
8431
+ occupation: 0,
8432
+ adl: 0
8433
+ };
8434
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return base;
8435
+ const o = raw;
8436
+ for (const k of Object.keys(base)) {
8437
+ base[k] = clampFunctionalScore03(o[k]);
8438
+ }
8439
+ return base;
8440
+ }
8441
+ function functionalImpairmentTotal(v) {
8442
+ return v.reading + v.nightDriving + v.glare + v.occupation + v.adl;
8443
+ }
8444
+ var ITEMS = [
8445
+ { key: "reading", label: "Difficulty reading" },
8446
+ { key: "nightDriving", label: "Night driving difficulty" },
8447
+ { key: "glare", label: "Glare sensitivity" },
8448
+ { key: "occupation", label: "Occupational impact" },
8449
+ { key: "adl", label: "ADL limitation" }
8450
+ ];
8451
+ var SCALE_LABELS = ["None", "Mild", "Moderate", "Severe"];
8452
+ var DEFAULT_TITLE2 = "Functional Impairment Score (Stage 5)";
8453
+ var ITEMS_GRID_STYLE = {
8454
+ display: "grid",
8455
+ gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 8rem), 1fr))",
8456
+ columnGap: "0.5rem",
8457
+ rowGap: "0.5rem",
8458
+ width: "100%",
8459
+ minWidth: 0
8460
+ };
8461
+ function clamp03(n) {
8462
+ const v = typeof n === "number" ? n : Number(n);
8463
+ if (!Number.isFinite(v)) return 0;
8464
+ return Math.max(0, Math.min(3, Math.trunc(v)));
8465
+ }
8466
+ var FunctionalImpairmentScoreWidget = ({
8467
+ fieldId
8468
+ }) => {
8469
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8470
+ const { state } = useForm();
8471
+ const showError = !!error && (touched || state.submitAttempted);
8472
+ if (!fieldDef || fieldDef.type !== "functional_impairment_score") {
8473
+ return null;
8474
+ }
8475
+ const def = fieldDef;
8476
+ const v = parseFunctionalImpairmentScore(value);
8477
+ const total = functionalImpairmentTotal(v);
8478
+ const title = def.meta?.cardTitle?.trim() || (def.label?.trim() ? def.label : DEFAULT_TITLE2);
8479
+ const setDim = (key, n) => {
8480
+ setValue({ ...v, [key]: clamp03(n) });
8481
+ };
8482
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8483
+ "div",
8484
+ {
8485
+ id: `functional-impairment-${fieldId}`,
8486
+ className: "w-full min-w-0 max-w-full rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm",
8487
+ children: [
8488
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mb-2 text-xs font-semibold leading-tight text-foreground sm:text-[13px]", children: title }),
8489
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: ITEMS_GRID_STYLE, children: ITEMS.map((it) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
8490
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[10px] font-medium leading-snug text-foreground sm:text-[11px]", children: it.label }),
8491
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-fit max-w-full shrink-0 gap-0.5", children: [0, 1, 2, 3].map((score) => /* @__PURE__ */ jsxRuntime.jsx(
8492
+ "button",
8493
+ {
8494
+ type: "button",
8495
+ title: SCALE_LABELS[score],
8496
+ disabled,
8497
+ onClick: () => setDim(it.key, score),
8498
+ className: cn(
8499
+ "h-6 w-7 shrink-0 rounded border text-[10px] transition-colors sm:text-[11px]",
8500
+ v[it.key] === score ? "border-primary bg-primary text-primary-foreground" : "border-input hover:bg-muted",
8501
+ disabled && "pointer-events-none opacity-50"
8502
+ ),
8503
+ children: score
8504
+ },
8505
+ score
8506
+ )) })
8507
+ ] }, it.key)) }),
8508
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex flex-col gap-1.5 border-t border-border pt-2 sm:flex-row sm:items-center sm:justify-between sm:gap-2", children: [
8509
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[10px] leading-snug text-muted-foreground sm:text-[11px]", children: "Score scale: 0 = none, 3 = severe (each item)" }),
8510
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-1.5 sm:justify-end", children: [
8511
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground sm:text-[11px]", children: "Total" }),
8512
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm font-bold tabular-nums sm:text-[15px]", children: [
8513
+ total,
8514
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-normal text-muted-foreground", children: "/15" })
8515
+ ] })
8516
+ ] })
8517
+ ] }),
8518
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8519
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8520
+ ]
8521
+ }
8522
+ );
8523
+ };
8524
+ var FORMULA_OPTIONS = [
8525
+ "SRK/T",
8526
+ "Barrett Universal II",
8527
+ "Hoffer Q",
8528
+ "Haigis",
8529
+ "Holladay 1",
8530
+ "Holladay 2",
8531
+ "Kane"
8532
+ ];
8533
+ var METHODS = [
8534
+ { value: "optical_biometry", label: "Optical biometry (IOL Master)" },
8535
+ { value: "ascan_immersion", label: "A-scan (immersion)" },
8536
+ { value: "ascan_contact", label: "A-scan (contact)" }
8537
+ ];
8538
+ var EMPTY = {
8539
+ axialLengthOD: "",
8540
+ axialLengthOS: "",
8541
+ k1k2AxisOD: "",
8542
+ k1k2AxisOS: "",
8543
+ anteriorChamberDepthOD: "",
8544
+ anteriorChamberDepthOS: "",
8545
+ iolPowerOD: "",
8546
+ iolPowerOS: "",
8547
+ targetRefractionOD: "",
8548
+ targetRefractionOS: "",
8549
+ formula: "SRK/T",
8550
+ method: "optical_biometry",
8551
+ cornealTopoUploaded: false,
8552
+ specularMicroscopyDone: false,
8553
+ endothelialCount: ""
8554
+ };
8555
+ function str(x) {
8556
+ return typeof x === "string" ? x : "";
8557
+ }
8558
+ function parseValue2(raw) {
8559
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { ...EMPTY };
8560
+ const o = raw;
8561
+ const m = o.method;
8562
+ const method = m === "ascan_immersion" || m === "ascan_contact" || m === "optical_biometry" ? m : "optical_biometry";
8563
+ const formula = str(o.formula);
8564
+ return {
8565
+ ...EMPTY,
8566
+ axialLengthOD: str(o.axialLengthOD),
8567
+ axialLengthOS: str(o.axialLengthOS),
8568
+ k1k2AxisOD: str(o.k1k2AxisOD),
8569
+ k1k2AxisOS: str(o.k1k2AxisOS),
8570
+ anteriorChamberDepthOD: str(o.anteriorChamberDepthOD),
8571
+ anteriorChamberDepthOS: str(o.anteriorChamberDepthOS),
8572
+ iolPowerOD: str(o.iolPowerOD),
8573
+ iolPowerOS: str(o.iolPowerOS),
8574
+ targetRefractionOD: str(o.targetRefractionOD),
8575
+ targetRefractionOS: str(o.targetRefractionOS),
8576
+ formula: formula || "SRK/T",
8577
+ method,
8578
+ cornealTopoUploaded: o.cornealTopoUploaded === true,
8579
+ specularMicroscopyDone: o.specularMicroscopyDone === true,
8580
+ endothelialCount: str(o.endothelialCount)
8581
+ };
8582
+ }
8583
+ var paramCell = "emr-biometry-param text-[11px] font-semibold leading-snug text-foreground sm:text-xs py-2";
8584
+ var eyeTh = "emr-biometry-eye text-center text-[11px] font-semibold sm:text-xs py-2";
8585
+ function Inp({
8586
+ value,
8587
+ onChange,
8588
+ disabled,
8589
+ placeholder
8590
+ }) {
8591
+ return /* @__PURE__ */ jsxRuntime.jsx(
8592
+ "input",
8593
+ {
8594
+ value,
8595
+ disabled,
8596
+ placeholder,
8597
+ onChange: (e) => onChange(e.target.value),
8598
+ className: "box-border w-full min-w-0 rounded border border-input bg-background px-2 py-1 text-[11px] sm:text-xs"
8599
+ }
8600
+ );
8601
+ }
8602
+ var DEFAULT_TITLE3 = "Biometry & IOL Workup (Stage 7)";
8603
+ var BiometryIolWorkupWidget = ({ fieldId }) => {
8604
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8605
+ const { state } = useForm();
8606
+ const showError = !!error && (touched || state.submitAttempted);
8607
+ if (!fieldDef || fieldDef.type !== "biometry_iol_workup") {
8608
+ return null;
8609
+ }
8610
+ const def = fieldDef;
8611
+ const v = parseValue2(value);
8612
+ const title = def.meta?.cardTitle?.trim() || (def.label?.trim() ? def.label : DEFAULT_TITLE3);
8613
+ const patch = (p) => setValue({ ...v, ...p });
8614
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8615
+ "div",
8616
+ {
8617
+ id: `biometry-iol-${fieldId}`,
8618
+ className: "w-full min-w-0 max-w-full self-stretch rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm",
8619
+ children: [
8620
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mb-2.5 text-sm font-semibold leading-tight text-foreground", children: title }),
8621
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full min-w-0 overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "emr-table emr-table--biometry min-w-full", children: [
8622
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
8623
+ /* @__PURE__ */ jsxRuntime.jsx("col", { style: { width: "32%" } }),
8624
+ /* @__PURE__ */ jsxRuntime.jsx("col", { style: { width: "34%" } }),
8625
+ /* @__PURE__ */ jsxRuntime.jsx("col", { style: { width: "34%" } })
8626
+ ] }),
8627
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8628
+ /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: paramCell, children: "Parameter" }),
8629
+ /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: eyeTh, children: "Right Eye" }),
8630
+ /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: eyeTh, children: "Left Eye" })
8631
+ ] }) }),
8632
+ /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
8633
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8634
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "Axial Length (mm)" }),
8635
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8636
+ Inp,
8637
+ {
8638
+ value: v.axialLengthOD,
8639
+ disabled,
8640
+ placeholder: "e.g. 23.45",
8641
+ onChange: (s) => patch({ axialLengthOD: s })
8642
+ }
8643
+ ) }),
8644
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8645
+ Inp,
8646
+ {
8647
+ value: v.axialLengthOS,
8648
+ disabled,
8649
+ placeholder: "e.g. 23.45",
8650
+ onChange: (s) => patch({ axialLengthOS: s })
8651
+ }
8652
+ ) })
8653
+ ] }),
8654
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8655
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "K1 / K2 / Axis" }),
8656
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8657
+ Inp,
8658
+ {
8659
+ value: v.k1k2AxisOD,
8660
+ disabled,
8661
+ placeholder: "44.0 / 44.5 / 90",
8662
+ onChange: (s) => patch({ k1k2AxisOD: s })
8663
+ }
8664
+ ) }),
8665
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8666
+ Inp,
8667
+ {
8668
+ value: v.k1k2AxisOS,
8669
+ disabled,
8670
+ placeholder: "44.0 / 44.5 / 90",
8671
+ onChange: (s) => patch({ k1k2AxisOS: s })
8672
+ }
8673
+ ) })
8674
+ ] }),
8675
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8676
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: `${paramCell} whitespace-nowrap`, children: "Anterior Chamber Depth (mm)" }),
8677
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8678
+ Inp,
8679
+ {
8680
+ value: v.anteriorChamberDepthOD,
8681
+ disabled,
8682
+ onChange: (s) => patch({ anteriorChamberDepthOD: s })
8683
+ }
8684
+ ) }),
8685
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8686
+ Inp,
8687
+ {
8688
+ value: v.anteriorChamberDepthOS,
8689
+ disabled,
8690
+ onChange: (s) => patch({ anteriorChamberDepthOS: s })
8691
+ }
8692
+ ) })
8693
+ ] }),
8694
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8695
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "IOL Power (D)" }),
8696
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(Inp, { value: v.iolPowerOD, disabled, onChange: (s) => patch({ iolPowerOD: s }) }) }),
8697
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(Inp, { value: v.iolPowerOS, disabled, onChange: (s) => patch({ iolPowerOS: s }) }) })
8698
+ ] }),
8699
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8700
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "Target Refraction (D)" }),
8701
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8702
+ Inp,
8703
+ {
8704
+ value: v.targetRefractionOD,
8705
+ disabled,
8706
+ placeholder: "e.g. -0.25",
8707
+ onChange: (s) => patch({ targetRefractionOD: s })
8708
+ }
8709
+ ) }),
8710
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8711
+ Inp,
8712
+ {
8713
+ value: v.targetRefractionOS,
8714
+ disabled,
8715
+ placeholder: "e.g. -0.25",
8716
+ onChange: (s) => patch({ targetRefractionOS: s })
8717
+ }
8718
+ ) })
8719
+ ] }),
8720
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8721
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "Formula" }),
8722
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-2 py-2 align-middle", colSpan: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
8723
+ "select",
8724
+ {
8725
+ value: v.formula,
8726
+ disabled,
8727
+ onChange: (e) => patch({ formula: e.target.value }),
8728
+ className: "box-border w-full min-w-0 rounded border border-input bg-background px-2 py-1 text-[11px] sm:text-xs",
8729
+ children: FORMULA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt))
8730
+ }
8731
+ ) })
8732
+ ] }),
8733
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8734
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: `${paramCell} align-top`, children: "Method" }),
8735
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-2 py-2 align-middle", colSpan: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
8736
+ "div",
8737
+ {
8738
+ role: "radiogroup",
8739
+ "aria-label": "Biometry method",
8740
+ className: "flex w-full flex-wrap items-center justify-center gap-x-3 gap-y-2 text-[11px] sm:gap-x-4 sm:text-xs",
8741
+ children: METHODS.map(({ value: mv, label }) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex min-w-0 shrink-0 cursor-pointer items-center gap-1.5", children: [
8742
+ /* @__PURE__ */ jsxRuntime.jsx(
8743
+ "input",
8744
+ {
8745
+ type: "radio",
8746
+ name: `${fieldId}-biom-method`,
8747
+ value: mv,
8748
+ checked: v.method === mv,
8749
+ disabled,
8750
+ onChange: () => patch({ method: mv }),
8751
+ className: "shrink-0"
8752
+ }
8753
+ ),
8754
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 whitespace-nowrap leading-tight", children: label })
8755
+ ] }, mv))
8756
+ }
8757
+ ) })
8758
+ ] }),
8759
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8760
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: `${paramCell} align-top text-muted-foreground`, children: "Optional workup" }),
8761
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-2 py-2 align-middle", colSpan: 2, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
8762
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-2 sm:justify-between", children: [
8763
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex min-w-0 cursor-pointer items-center gap-1.5 text-[11px] leading-snug sm:text-xs", children: [
8764
+ /* @__PURE__ */ jsxRuntime.jsx(
8765
+ "input",
8766
+ {
8767
+ type: "checkbox",
8768
+ className: "shrink-0",
8769
+ checked: v.cornealTopoUploaded,
8770
+ disabled,
8771
+ onChange: (e) => patch({ cornealTopoUploaded: e.target.checked })
8772
+ }
8773
+ ),
8774
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Corneal topography uploaded" })
8775
+ ] }),
8776
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex min-w-0 cursor-pointer items-center gap-1.5 text-[11px] leading-snug sm:text-xs", children: [
8777
+ /* @__PURE__ */ jsxRuntime.jsx(
8778
+ "input",
8779
+ {
8780
+ type: "checkbox",
8781
+ className: "shrink-0",
8782
+ checked: v.specularMicroscopyDone,
8783
+ disabled,
8784
+ onChange: (e) => patch({ specularMicroscopyDone: e.target.checked })
8785
+ }
8786
+ ),
8787
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Specular microscopy done" })
8788
+ ] })
8789
+ ] }),
8790
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2 text-[11px] sm:text-xs", children: [
8791
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-muted-foreground", children: "Endothelial count:" }),
8792
+ /* @__PURE__ */ jsxRuntime.jsx(
8793
+ "input",
8794
+ {
8795
+ value: v.endothelialCount,
8796
+ disabled,
8797
+ placeholder: "cells/mm\xB2",
8798
+ onChange: (e) => patch({ endothelialCount: e.target.value }),
8799
+ className: "box-border w-[5.5rem] min-w-0 shrink-0 rounded border border-input bg-background px-2 py-1 text-[11px] sm:text-xs"
8800
+ }
8801
+ )
8802
+ ] })
8803
+ ] }) })
8804
+ ] })
8805
+ ] })
8806
+ ] }) }),
8807
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8808
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8809
+ ]
8810
+ }
8811
+ );
8812
+ };
8813
+ var RISKS = [
8814
+ "Small pupil",
8815
+ "Pseudoexfoliation",
8816
+ "Diabetes",
8817
+ "Shallow AC",
8818
+ "Previous ocular surgery",
8819
+ "Zonular weakness",
8820
+ "Mature/white cataract"
8821
+ ];
8822
+ var DIABETES = "Diabetes";
8823
+ function parseValue3(raw) {
8824
+ const empty = { OD: [], OS: [] };
8825
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return empty;
8826
+ const o = raw;
8827
+ const arr = (x) => Array.isArray(x) ? x.filter((i) => typeof i === "string") : [];
8828
+ let OD = arr(o.OD);
8829
+ let OS = arr(o.OS);
8830
+ const odD = OD.includes(DIABETES);
8831
+ const osD = OS.includes(DIABETES);
8832
+ if (odD !== osD) {
8833
+ if (odD && !osD) OS = [...OS, DIABETES];
8834
+ else if (osD && !odD) OD = [...OD, DIABETES];
8835
+ }
8836
+ return { OD, OS };
8837
+ }
8838
+ function riskTierForCount(n) {
8839
+ if (n === 0) return "Low";
8840
+ if (n <= 2) return "Moderate";
8841
+ return "High";
8842
+ }
8843
+ function tierBadgeClass(tier) {
8844
+ if (tier === "High") return "bg-red-600 text-white";
8845
+ if (tier === "Moderate") return "bg-amber-500 text-white";
8846
+ return "bg-emerald-600 text-white";
8847
+ }
8848
+ var DEFAULT_TITLE4 = "Surgical Risk Flags (Stage 11)";
8849
+ function RiskCol({
8850
+ eye,
8851
+ value,
8852
+ disabled,
8853
+ onToggle
8854
+ }) {
8855
+ const selected = new Set(value[eye]);
8856
+ const tier = riskTierForCount(selected.size);
8857
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
8858
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [
8859
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-semibold text-foreground", children: eye === "OD" ? "Right Eye (OD)" : "Left Eye (OS)" }),
8860
+ /* @__PURE__ */ jsxRuntime.jsxs(
8861
+ "span",
8862
+ {
8863
+ className: cn(
8864
+ "whitespace-nowrap rounded-full px-2 py-0.5 text-[11px] font-medium",
8865
+ tierBadgeClass(tier)
8866
+ ),
8867
+ children: [
8868
+ tier,
8869
+ " risk"
8870
+ ]
8871
+ }
8872
+ )
8873
+ ] }),
8874
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1.5", children: RISKS.map((r) => /* @__PURE__ */ jsxRuntime.jsxs(
8875
+ "label",
8876
+ {
8877
+ className: "flex cursor-pointer items-center gap-2 rounded px-2 py-1 text-xs hover:bg-muted/50",
8878
+ children: [
8879
+ /* @__PURE__ */ jsxRuntime.jsx(
8880
+ "input",
8881
+ {
8882
+ type: "checkbox",
8883
+ className: "shrink-0",
8884
+ checked: selected.has(r),
8885
+ disabled,
8886
+ onChange: () => onToggle(eye, r)
8887
+ }
8888
+ ),
8889
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: r })
8890
+ ]
8891
+ },
8892
+ r
8893
+ )) })
8894
+ ] });
8895
+ }
8896
+ var SurgicalRiskFlagsWidget = ({ fieldId }) => {
8897
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8898
+ const { state } = useForm();
8899
+ const showError = !!error && (touched || state.submitAttempted);
8900
+ if (!fieldDef || fieldDef.type !== "surgical_risk_flags") {
8901
+ return null;
8902
+ }
8903
+ const def = fieldDef;
8904
+ const v = parseValue3(value);
8905
+ const title = def.meta?.cardTitle?.trim() || (def.label?.trim() ? def.label : DEFAULT_TITLE4);
8906
+ const toggleRisk = (eye, risk) => {
8907
+ const next = {
8908
+ OD: [...v.OD],
8909
+ OS: [...v.OS]
8910
+ };
8911
+ if (risk === DIABETES) {
8912
+ const had = next.OD.includes(DIABETES) || next.OS.includes(DIABETES);
8913
+ if (had) {
8914
+ next.OD = next.OD.filter((x) => x !== DIABETES);
8915
+ next.OS = next.OS.filter((x) => x !== DIABETES);
8916
+ } else {
8917
+ if (!next.OD.includes(DIABETES)) next.OD.push(DIABETES);
8918
+ if (!next.OS.includes(DIABETES)) next.OS.push(DIABETES);
8919
+ }
8920
+ setValue(next);
8921
+ return;
8922
+ }
8923
+ const list = next[eye];
8924
+ const i = list.indexOf(risk);
8925
+ if (i === -1) list.push(risk);
8926
+ else list.splice(i, 1);
8927
+ setValue(next);
8928
+ };
8929
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8930
+ "div",
8931
+ {
8932
+ id: `surgical-risk-flags-${fieldId}`,
8933
+ className: "w-full min-w-0 max-w-full rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm",
8934
+ children: [
8935
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mb-3 text-sm font-semibold leading-tight text-foreground", children: title }),
8936
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-6", children: [
8937
+ /* @__PURE__ */ jsxRuntime.jsx(RiskCol, { eye: "OD", value: v, disabled, onToggle: toggleRisk }),
8938
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-px shrink-0 bg-border", "aria-hidden": true }),
8939
+ /* @__PURE__ */ jsxRuntime.jsx(RiskCol, { eye: "OS", value: v, disabled, onToggle: toggleRisk })
8940
+ ] }),
8941
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8942
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8943
+ ]
8944
+ }
8945
+ );
8946
+ };
7915
8947
  var FieldRenderer = ({ fieldId }) => {
7916
8948
  const { fieldDef, visible } = useField(fieldId);
7917
8949
  if (!visible || !fieldDef) {
@@ -8003,6 +9035,17 @@ function renderWidget(fieldId, fieldDef) {
8003
9035
  /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
8004
9036
  ] });
8005
9037
  }
9038
+ case "suggestion_textarea":
9039
+ case "complaint_chips":
9040
+ return /* @__PURE__ */ jsxRuntime.jsx(SuggestionTextareaWidget, { fieldId });
9041
+ case "lens_assessment":
9042
+ return /* @__PURE__ */ jsxRuntime.jsx(LensAssessmentWidget, { fieldId });
9043
+ case "functional_impairment_score":
9044
+ return /* @__PURE__ */ jsxRuntime.jsx(FunctionalImpairmentScoreWidget, { fieldId });
9045
+ case "biometry_iol_workup":
9046
+ return /* @__PURE__ */ jsxRuntime.jsx(BiometryIolWorkupWidget, { fieldId });
9047
+ case "surgical_risk_flags":
9048
+ return /* @__PURE__ */ jsxRuntime.jsx(SurgicalRiskFlagsWidget, { fieldId });
8006
9049
  case "static_text": {
8007
9050
  const def = fieldDef;
8008
9051
  const size = def.size ?? "regular";
@@ -8703,6 +9746,84 @@ var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
8703
9746
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: `inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${isOn ? "bg-green-100 text-green-800" : "bg-gray-100 text-gray-600"}`, children: isOn ? "Yes" : "No" })
8704
9747
  ] });
8705
9748
  }
9749
+ case "suggestion_textarea":
9750
+ case "complaint_chips":
9751
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value });
9752
+ case "lens_assessment": {
9753
+ const v = value && typeof value === "object" && !Array.isArray(value) ? value : null;
9754
+ const notes = typeof v?.notes === "string" ? v.notes : "";
9755
+ const key = typeof v?.assessmentKey === "string" ? v.assessmentKey : null;
9756
+ const locs = v?.locs;
9757
+ const locsRecord = locs != null && typeof locs === "object" && !Array.isArray(locs) ? locs : null;
9758
+ const eyeLine = (label, g) => {
9759
+ if (!g || typeof g !== "object") return null;
9760
+ const num = (k) => typeof g[k] === "number" ? g[k] : "\u2014";
9761
+ return /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-foreground", children: [
9762
+ label,
9763
+ ": NO ",
9764
+ String(num("NO")),
9765
+ ", NC ",
9766
+ String(num("NC")),
9767
+ ", C ",
9768
+ String(num("C")),
9769
+ ", PSC",
9770
+ " ",
9771
+ String(num("PSC"))
9772
+ ] });
9773
+ };
9774
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-md border p-3 text-sm", children: [
9775
+ fieldDef.label && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-foreground", children: fieldDef.label }),
9776
+ locsRecord ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 border-l-2 border-muted pl-2", children: [
9777
+ eyeLine("Right (OD)", locsRecord.OD),
9778
+ eyeLine("Left (OS)", locsRecord.OS)
9779
+ ] }) : null,
9780
+ key && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
9781
+ "Assessment (legacy): ",
9782
+ key
9783
+ ] }),
9784
+ notes && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap text-foreground", children: notes })
9785
+ ] });
9786
+ }
9787
+ case "functional_impairment_score": {
9788
+ const v = parseFunctionalImpairmentScore(value);
9789
+ const total = functionalImpairmentTotal(v);
9790
+ const lines = [
9791
+ `Reading: ${v.reading}`,
9792
+ `Night driving: ${v.nightDriving}`,
9793
+ `Glare: ${v.glare}`,
9794
+ `Occupation: ${v.occupation}`,
9795
+ `ADL: ${v.adl}`,
9796
+ `Total: ${total}/15`
9797
+ ].join("\n");
9798
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: lines });
9799
+ }
9800
+ case "biometry_iol_workup": {
9801
+ const v = value && typeof value === "object" && !Array.isArray(value) ? value : {};
9802
+ const s = (k) => typeof v[k] === "string" ? v[k] : "";
9803
+ const b = (k) => v[k] === true;
9804
+ const method = v.method === "ascan_immersion" ? "A-scan (immersion)" : v.method === "ascan_contact" ? "A-scan (contact)" : "Optical biometry (IOL Master)";
9805
+ const lines = [
9806
+ `Axial length OD/OS (mm): ${s("axialLengthOD")} / ${s("axialLengthOS")}`,
9807
+ `K1/K2/Axis OD/OS: ${s("k1k2AxisOD")} / ${s("k1k2AxisOS")}`,
9808
+ `AC depth OD/OS (mm): ${s("anteriorChamberDepthOD")} / ${s("anteriorChamberDepthOS")}`,
9809
+ `IOL power (D) OD/OS: ${s("iolPowerOD")} / ${s("iolPowerOS")}`,
9810
+ `Target refraction (D) OD/OS: ${s("targetRefractionOD")} / ${s("targetRefractionOS")}`,
9811
+ `Formula: ${s("formula") || "\u2014"}`,
9812
+ `Method: ${method}`,
9813
+ `Corneal topography uploaded: ${b("cornealTopoUploaded") ? "Yes" : "No"}`,
9814
+ `Specular microscopy: ${b("specularMicroscopyDone") ? "Yes" : "No"}`,
9815
+ `Endothelial count: ${s("endothelialCount") || "\u2014"}`
9816
+ ].join("\n");
9817
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: lines });
9818
+ }
9819
+ case "surgical_risk_flags": {
9820
+ const v = value && typeof value === "object" && !Array.isArray(value) ? value : null;
9821
+ const list = (x) => Array.isArray(x) ? x.filter((i) => typeof i === "string").join(", ") : "\u2014";
9822
+ const od = list(v?.OD);
9823
+ const os = list(v?.OS);
9824
+ const lines = [`Right eye (OD): ${od}`, `Left eye (OS): ${os}`].join("\n");
9825
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: lines });
9826
+ }
8706
9827
  case "static_text": {
8707
9828
  const def = fieldDef;
8708
9829
  const size = def.size ?? "regular";