hplx-feature-library 1.0.158 → 1.0.160

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.
@@ -1,4 +1,4 @@
1
- import { j as Q, P as Bt, Y as Tl, M as s2, c as o2, g as Yy, R as r6, d as a6 } from "../index-C5JVupKG.js";
1
+ import { j as Q, b as Bt, K as Tl, O as s2, c as o2, g as Yy, P as r6, E as a6 } from "../index-4whwJbrk.js";
2
2
  import * as ca from "react";
3
3
  import dn, { createContext as d1, useContext as h1, memo as Zs, useMemo as fa, useCallback as Jt, useState as at, useRef as Gt, useEffect as rn, useLayoutEffect as i6, useDebugValue as l6 } from "react";
4
4
  import { E_DOCUMENT_VIEW_TYPE as Qs, E_DOCUMENT_FORMAT as yr, E_ATTACHMENT_QUERY_TYPE as Js, E_CANVAS_TOOLS as gr, E_DOCUMENT_TYPE as If } from "../types/AttachmentTypes/index.js";
@@ -1,35 +1,35 @@
1
- import { j as l, P as ye, a as Ce, M as $e } from "../index-C5JVupKG.js";
2
- import { useState as I, useRef as v, useMemo as je, useCallback as O, useEffect as J } from "react";
1
+ import { j as l, b as ye, N as Ce, O as $e } from "../index-4whwJbrk.js";
2
+ import { useState as S, useRef as v, useMemo as je, useCallback as I, useEffect as J } from "react";
3
3
  import { u as Ne } from "../useClickOutside-BjJyGTec.js";
4
4
  import { u as ke } from "../useOutsideClick-C4Q0aGuf.js";
5
5
  import Le from "../ToggleButtons/index.js";
6
- const Se = "data:image/svg+xml,%3csvg%20width='10'%20height='6'%20viewBox='0%200%2010%206'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M0.480062%200.819173C0.650418%200.648817%200.92662%200.648817%201.09698%200.819173L4.71454%204.43674L8.3321%200.819173C8.50246%200.648817%208.77866%200.648817%208.94902%200.819173C9.11937%200.98953%209.11937%201.26573%208.94902%201.43609L5.023%205.36211C4.85264%205.53246%204.57644%205.53246%204.40608%205.36211L0.480062%201.43609C0.309706%201.26573%200.309706%200.98953%200.480062%200.819173Z'%20fill='%23667085'/%3e%3c/svg%3e";
7
- function Pe(D) {
6
+ const Oe = "data:image/svg+xml,%3csvg%20width='10'%20height='6'%20viewBox='0%200%2010%206'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M0.480062%200.819173C0.650418%200.648817%200.92662%200.648817%201.09698%200.819173L4.71454%204.43674L8.3321%200.819173C8.50246%200.648817%208.77866%200.648817%208.94902%200.819173C9.11937%200.98953%209.11937%201.26573%208.94902%201.43609L5.023%205.36211C4.85264%205.53246%204.57644%205.53246%204.40608%205.36211L0.480062%201.43609C0.309706%201.26573%200.309706%200.98953%200.480062%200.819173Z'%20fill='%23667085'/%3e%3c/svg%3e";
7
+ function Fe(D) {
8
8
  const {
9
9
  label: E,
10
10
  labelClassName: B,
11
11
  hideDropdownIcon: Q,
12
- showClearOption: P,
12
+ showClearOption: F,
13
13
  isRequiredField: U,
14
14
  btnClassName: X,
15
- placeholder: F,
15
+ placeholder: H,
16
16
  options: i,
17
17
  selectedOption: p,
18
- onChangeHandler: H,
18
+ onChangeHandler: P,
19
19
  inputValue: n,
20
20
  inputChangeHandler: a,
21
- onInputFocusOutEvent: M,
21
+ onInputFocusOutEvent: T,
22
22
  inputClassName: ee,
23
23
  isSearchable: le,
24
24
  inputType: te,
25
25
  showInput: y,
26
- inputSuffix: T,
27
- selectedLabel: _,
28
- suffixPadding: oe,
29
- disableInputAutoSize: se,
26
+ inputSuffix: _,
27
+ selectedLabel: G,
28
+ suffixPadding: se,
29
+ disableInputAutoSize: oe,
30
30
  selectedOptions: C,
31
31
  isMulti: h,
32
- dropDownItemClickHandler: G,
32
+ dropDownItemClickHandler: M,
33
33
  showToggle: ne,
34
34
  toggleChangeHandler: re,
35
35
  selectedToggleOption: ie,
@@ -40,10 +40,10 @@ function Pe(D) {
40
40
  fieldColor: g,
41
41
  errorMsg: $,
42
42
  showErrorMsg: he,
43
- placeholderStyle: o,
43
+ placeholderStyle: s,
44
44
  onInputKeyDown: R,
45
45
  showEmptyDropdownPopup: fe = !0,
46
- isDropdownFixed: w = !1,
46
+ isDropdownFixed: b = !1,
47
47
  dropdownClassName: ce = "",
48
48
  wrapperClass: z = "",
49
49
  maxInputLength: W,
@@ -52,40 +52,40 @@ function Pe(D) {
52
52
  labelToolTipContent: pe = "",
53
53
  inputContainerClasses: V = "",
54
54
  onInputFocus: j
55
- } = D, [r, c] = I(!1), [d, me] = I(null), b = v(null), N = v(null), K = v(null), k = v([]), xe = je(() => i?.filter((e) => e ? e.label.toLowerCase().includes((n ?? "").toLowerCase()) : void 0), [n, i]), [ge, L] = I(!1), we = () => {
55
+ } = D, [r, c] = S(!1), [d, me] = S(null), w = v(null), N = v(null), K = v(null), k = v([]), xe = je(() => i?.filter((e) => e ? e.label.toLowerCase().includes((n ?? "").toLowerCase()) : void 0), [n, i]), [ge, L] = S(!1), be = () => {
56
56
  c(!1), h && a && a(""), me(null);
57
- }, Y = O(
57
+ }, Y = I(
58
58
  (e) => {
59
59
  e.stopPropagation(), f || c((t) => !t);
60
60
  },
61
61
  [f]
62
- ), q = (n?.length || 0) + 2 + Number(oe || 0);
63
- ke(b, we), J(() => {
62
+ ), q = (n?.length || 0) + 2 + Number(se || 0);
63
+ ke(w, be), J(() => {
64
64
  d !== null && k.current[d] && k.current[d].scrollIntoView({ block: "nearest" });
65
65
  }, [d]);
66
- const u = O(() => {
67
- if (w && r) {
68
- const e = y ? N.current : K.current, t = b.current;
66
+ const u = I(() => {
67
+ if (b && r) {
68
+ const e = y ? N.current : K.current, t = w.current;
69
69
  if (e && t) {
70
- const s = e.getBoundingClientRect();
71
- t.style.position = "fixed", t.style.top = `${window.scrollY ? s.bottom + window.scrollY : s.bottom}px`, t.style.left = `${s.left}px`, t.style.width = `${s.width}px`;
70
+ const o = e.getBoundingClientRect();
71
+ t.style.position = "fixed", t.style.top = `${window.scrollY ? o.bottom + window.scrollY : o.bottom}px`, t.style.left = `${o.left}px`, t.style.width = `${o.width}px`;
72
72
  }
73
73
  }
74
- }, [w, r, y]);
74
+ }, [b, r, y]);
75
75
  J(() => {
76
- if (w)
76
+ if (b)
77
77
  return r ? (u(), window.addEventListener("scroll", u, !0)) : window.removeEventListener("scroll", u, !0), () => {
78
78
  window.removeEventListener("scroll", u, !0);
79
79
  };
80
- }, [w, u, r]), Ne(b, () => {
81
- ge && M && M();
80
+ }, [b, u, r]), Ne(w, () => {
81
+ ge && T && T();
82
82
  });
83
83
  const A = (e) => {
84
- if (h && G) {
85
- const t = C?.some((s) => s.value === e.value);
86
- G(!!t, e);
84
+ if (h && M) {
85
+ const t = C?.some((o) => o.value === e.value);
86
+ M(!!t, e);
87
87
  }
88
- }, be = O(
88
+ }, we = I(
89
89
  async (e) => {
90
90
  e.stopPropagation(), r || c(!0), j && await j();
91
91
  },
@@ -114,8 +114,8 @@ function Pe(D) {
114
114
  /* @__PURE__ */ l.jsx(
115
115
  "span",
116
116
  {
117
- onClick: (s) => {
118
- s.stopPropagation(), A(e);
117
+ onClick: (o) => {
118
+ o.stopPropagation(), A(e);
119
119
  },
120
120
  className: "hx_close hfl-text-Gray-500 hfl-my-0 hfl-text-[14px] hfl-ml-[1px] hfl-cursor-pointer"
121
121
  }
@@ -124,35 +124,35 @@ function Pe(D) {
124
124
  },
125
125
  `${e.label}-${t}`
126
126
  )),
127
- Object.keys(o || {}).length > 0 && /* @__PURE__ */ l.jsx("style", { children: `
127
+ Object.keys(s || {}).length > 0 && /* @__PURE__ */ l.jsx("style", { children: `
128
128
  input.input-placeholder::placeholder {
129
- font-family: ${o?.fontFamily};
130
- font-weight: ${o?.fontWeight};
131
- line-height: ${o?.lineHeight};
132
- font-size: ${o?.fontSize};
133
- color: ${o?.color};
129
+ font-family: ${s?.fontFamily};
130
+ font-weight: ${s?.fontWeight};
131
+ line-height: ${s?.lineHeight};
132
+ font-size: ${s?.fontSize};
133
+ color: ${s?.color};
134
134
  }
135
135
  ` }),
136
136
  /* @__PURE__ */ l.jsx(
137
137
  "input",
138
138
  {
139
139
  ref: N,
140
- style: se ? {} : { width: `${Number(n?.length) > 4 ? (n?.length || 0) + 5 : 12}ch` },
140
+ style: oe ? {} : { width: `${Number(n?.length) > 4 ? (n?.length || 0) + 5 : 12}ch` },
141
141
  type: te,
142
- placeholder: F,
142
+ placeholder: H,
143
143
  value: n,
144
144
  className: `input-placeholder hfl-flex-1 hfl-pl-2 hfl-placeholder hfl-py-1 focus-visible:hfl-outline-0 focus-visible:hfl-outline-none hfl-border-0 focus:hfl-border-0 ${f ? "!hfl-bg-Gray-50 !hfl-cursor-not-allowed" : g || "hfl-bg-White"} ${ee || ""}`,
145
145
  onChange: (e) => {
146
146
  a && a(e.target.value), L(!0);
147
147
  },
148
- onClick: be,
148
+ onClick: we,
149
149
  onKeyDown: (e) => R && R(e, c, N),
150
150
  maxLength: W ?? W,
151
151
  ...D.inputProps || {}
152
152
  }
153
153
  ),
154
- !Q && !P && /* @__PURE__ */ l.jsx("i", { className: "hx_down hfl-mx-2" }),
155
- P && /* @__PURE__ */ l.jsx(
154
+ !Q && !F && /* @__PURE__ */ l.jsx("i", { className: "hx_down hfl-mx-2" }),
155
+ F && /* @__PURE__ */ l.jsx(
156
156
  "i",
157
157
  {
158
158
  className: `${n ? "hx_close hfl-cursor-pointer" : "hx_down"} hfl-mx-2`,
@@ -161,12 +161,12 @@ function Pe(D) {
161
161
  }
162
162
  }
163
163
  ),
164
- T ? /* @__PURE__ */ l.jsx(
164
+ _ ? /* @__PURE__ */ l.jsx(
165
165
  "span",
166
166
  {
167
167
  style: { left: `${q < 2 ? "3" : q}ch` },
168
168
  className: "hfl-absolute hfl-top-1/2 hfl--translate-y-1/2 hfl-pointer-events-none",
169
- children: T
169
+ children: _
170
170
  }
171
171
  ) : null
172
172
  ]
@@ -179,23 +179,23 @@ function Pe(D) {
179
179
  ref: K,
180
180
  onClick: Y,
181
181
  className: `hfl-w-full hfl-bg-White hfl-py-[6px] hfl-px-4 hfl-rounded-lg hfl-inline-flex hfl-justify-between hfl-items-center ${X || ""} ${m || "hfl-border-1"} ${$ ? "hfl-border-Error-300" : "hfl-border-Gray-300"} ${x || "hfl-h-[40px]"} ${f ? "!hfl-bg-Gray-50 !hfl-cursor-not-allowed" : ""}`,
182
- style: _ || p?.label ? {} : o ? {
183
- fontFamily: o?.fontFamily,
184
- fontSize: o?.fontSize,
185
- fontWeight: o?.fontWeight,
186
- lineHeight: o?.lineHeight,
187
- color: o?.color
182
+ style: G || p?.label ? {} : s ? {
183
+ fontFamily: s?.fontFamily,
184
+ fontSize: s?.fontSize,
185
+ fontWeight: s?.fontWeight,
186
+ lineHeight: s?.lineHeight,
187
+ color: s?.color
188
188
  } : {},
189
189
  children: [
190
- /* @__PURE__ */ l.jsx("span", { className: "hfl-pr-4", children: _ || p?.label || F || "Select an option" }),
191
- /* @__PURE__ */ l.jsx("img", { src: Se, alt: "down arrow" })
190
+ /* @__PURE__ */ l.jsx("span", { className: "hfl-pr-4", children: G || p?.label || H || "Select an option" }),
191
+ /* @__PURE__ */ l.jsx("img", { src: Oe, alt: "down arrow" })
192
192
  ]
193
193
  }
194
194
  ),
195
195
  i && i?.length >= 0 && /* @__PURE__ */ l.jsxs(
196
196
  "ul",
197
197
  {
198
- ref: b,
198
+ ref: w,
199
199
  className: `custom-dropdown-menu ${r ? "hfl-visible" : "hfl-invisible"} hfl-absolute hfl-z-50 hfl-grid hfl-gap-1 hfl-mt-3 hfl-w-full hfl-rounded-lg hfl-shadow-lg hfl-bg-White hfl-font-inter-0 hfl-p-1 hfl-px-2 ${h ? "hfl-min-w-[20em]" : "hfl-min-w-[16em]"} hfl-max-h-[330px] hfl-overflow-y-scroll ${ce}`,
200
200
  role: "menu",
201
201
  "aria-orientation": "vertical",
@@ -210,19 +210,19 @@ function Pe(D) {
210
210
  }
211
211
  ) : !1,
212
212
  (le ? xe : i)?.map((e, t) => {
213
- const s = h ? !!C?.some((S) => S.value === e?.value) : !1, Z = p?.value === e?.value, ve = d === t;
213
+ const o = h ? !!C?.some((O) => O.value === e?.value) : !1, Z = p?.value === e?.value, ve = d === t;
214
214
  return e ? /* @__PURE__ */ l.jsx(
215
215
  "li",
216
216
  {
217
217
  onClick: () => {
218
- h ? A(e) : (H && H(e), c(!1), L(!1));
218
+ h ? A(e) : (P && P(e), c(!1), L(!1));
219
219
  },
220
220
  className: `hfl-text-1 hfl-block hfl-px-4 hfl-py-2 hfl-rounded-md hover:hfl-bg-Blue-50 hfl-cursor-pointer custom_dropdown_item ${de ? "odd:hfl-bg-Gray-100" : ""} ${Z ? "hfl-bg-Blue-50 hfl-text-Blue-500" : ""}`,
221
221
  role: "menuitem",
222
222
  "aria-selected": Z,
223
223
  tabIndex: ve ? 0 : -1,
224
- ref: (S) => {
225
- k.current[t] = S;
224
+ ref: (O) => {
225
+ k.current[t] = O;
226
226
  },
227
227
  children: h ? /* @__PURE__ */ l.jsx(
228
228
  $e,
@@ -232,7 +232,7 @@ function Pe(D) {
232
232
  text: /* @__PURE__ */ l.jsx("span", { children: e.label }),
233
233
  secondaryText: "",
234
234
  id: `${e.label}-${t}`,
235
- isMarked: s
235
+ isMarked: o
236
236
  }
237
237
  ) : e.label
238
238
  },
@@ -252,5 +252,5 @@ function Pe(D) {
252
252
  ] });
253
253
  }
254
254
  export {
255
- Pe as default
255
+ Fe as default
256
256
  };
@@ -1,7 +1,7 @@
1
- import { j as ee, Y as Ft } from "../../index-C5JVupKG.js";
1
+ import { j as ee, K as Ft } from "../../index-4whwJbrk.js";
2
2
  import * as O from "react";
3
3
  import v, { useLayoutEffect as zr, cloneElement as Gr, createRef as Oe, Component as Z, useRef as Ze, useCallback as Xr, useEffect as Zr, createElement as Ln, useState as hr, useMemo as An } from "react";
4
- import { c as X, d as Fn } from "../../dayjs.min-qi3CdtFF.js";
4
+ import { c as X, d as Fn } from "../../dayjs.min-DQn5T5hy.js";
5
5
  import * as Hn from "react-dom";
6
6
  import Wn from "react-dom";
7
7
  import { t as S, c as z, m as Jr, a as en, n as We, d as Je, g as er, b as Bn, e as Qn, s as wt, f as tn, h as Kn, i as rn, j as nn, k as Vn, l as mr, o as Se, p as jn, q as qt, r as tr, u as rr, v as Un, w as vr } from "../../parseISO-Cso9HWPX.js";
@@ -1,4 +1,4 @@
1
- import { P as f } from "../PediatricsCalculatorTable-DEwcZURh.js";
1
+ import { P as f } from "../PediatricsCalculatorTable-DGWlajqt.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,8 +1,8 @@
1
- import { j as e, P as k, M as ge, c as Q, g as xe, Y as oe } from "./index-C5JVupKG.js";
1
+ import { j as e, b as k, O as ge, c as Y, g as xe, K as oe } from "./index-4whwJbrk.js";
2
2
  import le, { createContext as ye, useContext as _e, useState as W, useEffect as J, useMemo as Z, useCallback as G, forwardRef as be, useImperativeHandle as we } from "react";
3
3
  import { C_MedicineCalculatorList as ae, C_FrequencyDosageMap as ce, C_MedicineTypeList as te, C_MedicineFrequencyList as de, C_DefaultMgKgFields as je, C_DefaultMlKgFields as ve, C_Table_Column_Name as Ce } from "./constants/PediatricsCalculatorConstants/index.js";
4
4
  import g from "./CustomDropdown/index.js";
5
- import { M as Ie, A as Ne } from "./AlertPopup-CrMI2BnN.js";
5
+ import { M as Ie, A as Ne } from "./AlertPopup-CSD_rZzv.js";
6
6
  const fe = ye(null), he = () => {
7
7
  const i = _e(fe);
8
8
  if (!i) throw new Error("usePediatricsCalculatorTableContext must be used inside a MedicineTableProvider");
@@ -63,7 +63,7 @@ var ne, ue;
63
63
  function Te() {
64
64
  if (ue) return ne;
65
65
  ue = 1;
66
- var i = "Expected a function", a = NaN, x = "[object Symbol]", _ = /^\s+|\s+$/g, b = /^[-+]0x[0-9a-f]+$/i, w = /^0b[01]+$/i, o = /^0o[0-7]+$/i, j = parseInt, L = typeof Q == "object" && Q && Q.Object === Object && Q, v = typeof self == "object" && self && self.Object === Object && self, E = L || v || Function("return this")(), F = Object.prototype, $ = F.toString, O = Math.max, n = Math.min, d = function() {
66
+ var i = "Expected a function", a = NaN, x = "[object Symbol]", _ = /^\s+|\s+$/g, b = /^[-+]0x[0-9a-f]+$/i, w = /^0b[01]+$/i, o = /^0o[0-7]+$/i, j = parseInt, L = typeof Y == "object" && Y && Y.Object === Object && Y, v = typeof self == "object" && self && self.Object === Object && self, E = L || v || Function("return this")(), F = Object.prototype, $ = F.toString, O = Math.max, n = Math.min, d = function() {
67
67
  return E.Date.now();
68
68
  };
69
69
  function M(s, p, f) {
@@ -72,25 +72,25 @@ function Te() {
72
72
  throw new TypeError(i);
73
73
  p = z(p) || 0, T(f) && (q = !!f.leading, R = "maxWait" in f, I = R ? O(z(f.maxWait) || 0, p) : I, l = "trailing" in f ? !!f.trailing : l);
74
74
  function c(m) {
75
- var P = u, U = D;
76
- return u = D = void 0, y = m, r = s.apply(U, P), r;
75
+ var K = u, X = D;
76
+ return u = D = void 0, y = m, r = s.apply(X, K), r;
77
77
  }
78
78
  function h(m) {
79
- return y = m, t = setTimeout(K, p), q ? c(m) : r;
79
+ return y = m, t = setTimeout(P, p), q ? c(m) : r;
80
80
  }
81
81
  function S(m) {
82
- var P = m - N, U = m - y, re = p - P;
83
- return R ? n(re, I - U) : re;
82
+ var K = m - N, X = m - y, re = p - K;
83
+ return R ? n(re, I - X) : re;
84
84
  }
85
85
  function A(m) {
86
- var P = m - N, U = m - y;
87
- return N === void 0 || P >= p || P < 0 || R && U >= I;
86
+ var K = m - N, X = m - y;
87
+ return N === void 0 || K >= p || K < 0 || R && X >= I;
88
88
  }
89
- function K() {
89
+ function P() {
90
90
  var m = d();
91
91
  if (A(m))
92
92
  return se(m);
93
- t = setTimeout(K, S(m));
93
+ t = setTimeout(P, S(m));
94
94
  }
95
95
  function se(m) {
96
96
  return t = void 0, l && u ? c(m) : (u = D = void 0, r);
@@ -102,14 +102,14 @@ function Te() {
102
102
  return t === void 0 ? r : se(d());
103
103
  }
104
104
  function ee() {
105
- var m = d(), P = A(m);
106
- if (u = arguments, D = this, N = m, P) {
105
+ var m = d(), K = A(m);
106
+ if (u = arguments, D = this, N = m, K) {
107
107
  if (t === void 0)
108
108
  return h(N);
109
109
  if (R)
110
- return t = setTimeout(K, p), c(N);
110
+ return t = setTimeout(P, p), c(N);
111
111
  }
112
- return t === void 0 && (t = setTimeout(K, p)), r;
112
+ return t === void 0 && (t = setTimeout(P, p)), r;
113
113
  }
114
114
  return ee.cancel = pe, ee.flush = me, ee;
115
115
  }
@@ -120,13 +120,13 @@ function Te() {
120
120
  function C(s) {
121
121
  return !!s && typeof s == "object";
122
122
  }
123
- function Y(s) {
123
+ function U(s) {
124
124
  return typeof s == "symbol" || C(s) && $.call(s) == x;
125
125
  }
126
126
  function z(s) {
127
127
  if (typeof s == "number")
128
128
  return s;
129
- if (Y(s))
129
+ if (U(s))
130
130
  return a;
131
131
  if (T(s)) {
132
132
  var p = typeof s.valueOf == "function" ? s.valueOf() : s;
@@ -167,7 +167,7 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
167
167
  ":"
168
168
  ] }),
169
169
  /* @__PURE__ */ e.jsx(k, { variant: "Bold", type: "Text sm", className: "hfl-text-Blue_gray-800 hfl-break-words hfl-min-w-0", children: a || "--" })
170
- ] }), X = ({ children: i, className: a = "" }) => /* @__PURE__ */ e.jsx(
170
+ ] }), Q = ({ children: i, className: a = "" }) => /* @__PURE__ */ e.jsx(
171
171
  k,
172
172
  {
173
173
  variant: "Regular",
@@ -228,10 +228,10 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
228
228
  d((h) => {
229
229
  let S = { ...h.calculation_fields, [l]: c };
230
230
  if (l === "frequency" && o === "standard") {
231
- const K = ce[c] || [];
232
- K.length > 0 && (S = {
231
+ const P = ce[c] || [];
232
+ P.length > 0 && (S = {
233
233
  ...S,
234
- pedia_dosage: K[0]
234
+ pedia_dosage: P[0]
235
235
  });
236
236
  }
237
237
  const A = {
@@ -307,7 +307,7 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
307
307
  }
308
308
  }
309
309
  }
310
- ) : /* @__PURE__ */ e.jsx(X, { children: a.medicine_name }) }),
310
+ ) : /* @__PURE__ */ e.jsx(Q, { children: a.medicine_name }) }),
311
311
  /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: q("generic_name") ? /* @__PURE__ */ e.jsx(
312
312
  g,
313
313
  {
@@ -320,7 +320,7 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
320
320
  inputChangeHandler: (l) => D("generic_name", l),
321
321
  hideDropdownIcon: !0
322
322
  }
323
- ) : /* @__PURE__ */ e.jsx(X, { children: a.generic_name }) }),
323
+ ) : /* @__PURE__ */ e.jsx(Q, { children: a.generic_name }) }),
324
324
  /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: q("type") ? /* @__PURE__ */ e.jsx(
325
325
  g,
326
326
  {
@@ -339,7 +339,7 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
339
339
  })),
340
340
  onChangeHandler: (l) => D("type", l.value)
341
341
  }
342
- ) : /* @__PURE__ */ e.jsx(X, { children: a.type || "" }) }),
342
+ ) : /* @__PURE__ */ e.jsx(Q, { children: a.type || "" }) }),
343
343
  /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: q("calculation_type") ? /* @__PURE__ */ e.jsx(
344
344
  g,
345
345
  {
@@ -352,7 +352,7 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
352
352
  options: ae.map((l) => ({ label: l, value: l })),
353
353
  onChangeHandler: (l) => D("calculation_type", l.value)
354
354
  }
355
- ) : /* @__PURE__ */ e.jsx(X, { children: a.calculation_type }) }),
355
+ ) : /* @__PURE__ */ e.jsx(Q, { children: a.calculation_type }) }),
356
356
  /* @__PURE__ */ e.jsx("div", { className: "hfl-flex hfl-w-full hfl-flex-col hfl-gap-2 hfl-py-2.5 hfl-px-2", children: q("calculation_fields") ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
357
357
  f && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
358
358
  /* @__PURE__ */ e.jsx(B, { label: "Drug Strength", children: /* @__PURE__ */ e.jsx(
@@ -569,7 +569,7 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
569
569
  }
570
570
  ) });
571
571
  })() : /* @__PURE__ */ e.jsxs("div", { className: "hfl-flex hfl-flex-col hfl-h-full hfl-justify-between hfl-min-w-0", children: [
572
- /* @__PURE__ */ e.jsx(X, { children: o === "prescription" ? a.pedia_dosage : a.calculation_fields.pedia_dosage }),
572
+ /* @__PURE__ */ e.jsx(Q, { children: o === "prescription" ? a.pedia_dosage : a.calculation_fields.pedia_dosage }),
573
573
  s && r
574
574
  ] }) }),
575
575
  /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: /* @__PURE__ */ e.jsx(
@@ -709,7 +709,7 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
709
709
  externalSaveTrigger: E,
710
710
  setSearchDisabled: F
711
711
  }, $) => {
712
- const [O, n] = W(null), [d, M] = W(!1), [T, C] = W(), Y = G(
712
+ const [O, n] = W(null), [d, M] = W(!1), [T, C] = W(), U = G(
713
713
  (r, t, N) => {
714
714
  const y = i.find((R) => R.rowId === r);
715
715
  if (!y) return;
@@ -777,7 +777,7 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
777
777
  externallyTriggeredEditRowIds: x,
778
778
  getMedicineOptions: w,
779
779
  onRowChange: (r, t) => {
780
- Y(r.rowId, r, t), o?.(r, t);
780
+ U(r.rowId, r, t), o?.(r, t);
781
781
  },
782
782
  onRowDelete: j,
783
783
  onRowCopy: L,
@@ -792,7 +792,7 @@ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
792
792
  {
793
793
  rowData: r,
794
794
  isEditing: r.isEditing || !1,
795
- setIsEditing: (t) => Y(r.rowId, { isEditing: t }),
795
+ setIsEditing: (t) => U(r.rowId, { isEditing: t }),
796
796
  onSaveRow: u,
797
797
  allowCustomMedicineInput: b
798
798
  },
@@ -1 +1 @@
1
- "use strict";const e=require("./index-C3v1d6Xc.cjs"),c=require("react"),k=require("./constants/PediatricsCalculatorConstants/index.js"),g=require("./CustomDropdown/index.js"),se=require("./AlertPopup-CPKIp-41.cjs"),le=c.createContext(null),ne=()=>{const i=c.useContext(le);if(!i)throw new Error("usePediatricsCalculatorTableContext must be used inside a MedicineTableProvider");return i},re=({effectiveEditMode:i,rowData:s,isSavedToLibrary:j,onSave:_,onCancel:b,onEdit:E,onCheckboxToggle:o})=>{const{variant:w,externallyTriggeredEditMode:L,setRowToDelete:R,openPopupForRow:D}=ne();return w==="standard"?i?e.jsxRuntimeExports.jsxs("div",{className:"hfl-grid hfl-grid-cols-[1fr_1fr] hfl-border-1 hfl-border-Gray-200 hfl-rounded-lg ",children:[e.jsxRuntimeExports.jsx("button",{className:"hfl-px-3 hfl-py-1 hfl-text-Blue_gray-800 hfl-border-r-1 hover:hfl-bg-Primary-50",onClick:_,children:e.jsxRuntimeExports.jsx(e.Pc,{variant:"Medium",type:"Text xs",className:"hfl-text-Blue_gray-800",children:"Save"})}),e.jsxRuntimeExports.jsx("button",{className:"hfl-px-3 hfl-py-2 hfl-text-Error-600 hover:hfl-bg-Error-50",onClick:b,children:e.jsxRuntimeExports.jsx(e.Pc,{variant:"Medium",type:"Text xs",className:"",children:"Cancel"})})]}):e.jsxRuntimeExports.jsxs("div",{className:"hfl-grid hfl-grid-cols-[1fr_1fr_1fr] hfl-border-1 hfl-border-Gray-200 hfl-rounded-lg",children:[e.jsxRuntimeExports.jsx("button",{className:"hfl-px-3 hfl-py-1 hfl-text-Blue_gray-800 hover:hfl-bg-Primary-50",onClick:E,children:e.jsxRuntimeExports.jsx(e.Pc,{variant:"Medium",type:"Text xs",className:"",children:"Edit"})}),e.jsxRuntimeExports.jsx("button",{className:"hfl-px-3 hfl-py-2 hfl-text-Blue_gray-800 hfl-border-x-1 hover:hfl-bg-Primary-50",onClick:()=>D?.(s),children:e.jsxRuntimeExports.jsx(e.Pc,{variant:"Medium",type:"Text xs",className:"",children:"Copy"})}),e.jsxRuntimeExports.jsx("button",{className:"hx_delete hfl-px-3 hfl-py-2 hfl-text-Error-500 hover:hfl-bg-Error-50",onClick:()=>R?.(s.rowId)})]}):e.jsxRuntimeExports.jsx(e.Mc,{disabled:!L,text:"Save this to Pediatric Calculator Library ",id:s.rowId,size:"md",onClick:o,isMarked:j??!1,checkboxClasses:"hfl-mt-2",checkBoxInnerDivClasses:"hfl-text-Blue-600 hfl-bg-Blue-50"},s.rowId)};var X,te;function oe(){if(te)return X;te=1;var i="Expected a function",s=NaN,j="[object Symbol]",_=/^\s+|\s+$/g,b=/^[-+]0x[0-9a-f]+$/i,E=/^0b[01]+$/i,o=/^0o[0-7]+$/i,w=parseInt,L=typeof e.commonjsGlobal=="object"&&e.commonjsGlobal&&e.commonjsGlobal.Object===Object&&e.commonjsGlobal,R=typeof self=="object"&&self&&self.Object===Object&&self,D=L||R||Function("return this")(),F=Object.prototype,G=F.toString,O=Math.max,n=Math.min,d=function(){return D.Date.now()};function N(a,m,x){var f,T,v,r,l,I,y=0,A=!1,P=!1,t=!0;if(typeof a!="function")throw new TypeError(i);m=z(m)||0,M(x)&&(A=!!x.leading,P="maxWait"in x,v=P?O(z(x.maxWait)||0,m):v,t="trailing"in x?!!x.trailing:t);function u(h){var W=f,J=T;return f=T=void 0,y=h,r=a.apply(J,W),r}function p(h){return y=h,l=setTimeout($,m),A?u(h):r}function S(h){var W=h-I,J=h-y,ee=m-W;return P?n(ee,v-J):ee}function q(h){var W=h-I,J=h-y;return I===void 0||W>=m||W<0||P&&J>=v}function $(){var h=d();if(q(h))return Z(h);l=setTimeout($,S(h))}function Z(h){return l=void 0,t&&f?u(h):(f=T=void 0,r)}function ie(){l!==void 0&&clearTimeout(l),y=0,f=I=T=l=void 0}function ae(){return l===void 0?r:Z(d())}function U(){var h=d(),W=q(h);if(f=arguments,T=this,I=h,W){if(l===void 0)return p(I);if(P)return l=setTimeout($,m),u(I)}return l===void 0&&(l=setTimeout($,m)),r}return U.cancel=ie,U.flush=ae,U}function M(a){var m=typeof a;return!!a&&(m=="object"||m=="function")}function C(a){return!!a&&typeof a=="object"}function K(a){return typeof a=="symbol"||C(a)&&G.call(a)==j}function z(a){if(typeof a=="number")return a;if(K(a))return s;if(M(a)){var m=typeof a.valueOf=="function"?a.valueOf():a;a=M(m)?m+"":m}if(typeof a!="string")return a===0?a:+a;a=a.replace(_,"");var x=E.test(a);return x||o.test(a)?w(a.slice(2),x?2:8):b.test(a)?s:+a}return X=N,X}var ce=oe();const ue=e.getDefaultExportFromCjs(ce),Q=(i,s)=>{const j=parseFloat(i),_=parseFloat(s);if(!i||!s||isNaN(j)||isNaN(_)||_===0)return"";const b=j/_;return Number.isInteger(b)?b.toString(10):b.toFixed(3).replace(/\.?0+$/,"")},V=i=>/^(\d+)?(\.)?(\d*)?$/.test(i),B=({label:i,children:s})=>e.jsxRuntimeExports.jsxs(e.Pc,{variant:"Regular",type:"Text sm",className:"hfl-grid hfl-grid-cols-2 hfl-items-center hfl-text-Blue_gray-800 hfl-justify-between hfl-gap-8",children:[e.jsxRuntimeExports.jsxs("span",{className:"hfl-flex-shrink-0",children:[i,":"]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex-1 hfl-min-w-0",children:s})]}),H=({label:i,value:s})=>e.jsxRuntimeExports.jsxs(e.Pc,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-text-Blue_gray-800 hfl-gap-1",children:[e.jsxRuntimeExports.jsxs("span",{className:"hfl-flex-shrink-0",children:[i,":"]}),e.jsxRuntimeExports.jsx(e.Pc,{variant:"Bold",type:"Text sm",className:"hfl-text-Blue_gray-800 hfl-break-words hfl-min-w-0",children:s||"--"})]}),Y=({children:i,className:s=""})=>e.jsxRuntimeExports.jsx(e.Pc,{variant:"Regular",type:"Text sm",className:`hfl-text-Blue_gray-800 hfl-px-2 hfl-break-words hfl-overflow-wrap-anywhere hfl-min-w-0 ${s}`,children:i}),de=c.memo(function({rowData:s,isEditing:j,setIsEditing:_,onSaveRow:b,allowCustomMedicineInput:E}){const{variant:o,externallyTriggeredEditMode:w,externallyTriggeredEditRowIds:L,getMedicineOptions:R,onRowChange:D,onRowDelete:F}=ne(),[G,O]=c.useState([]),[n,d]=c.useState(s),[N,M]=c.useState(s.medicine_name);c.useEffect(()=>{j||M(s.medicine_name)},[s.medicine_name,j]),c.useEffect(()=>{j||d(s)},[s,j]);const C=async t=>(await R?.(t))?.map(p=>({label:p.doctorMedicineName,value:p}))||[],z=w||L?.includes(s.rowId)||j,a=c.useMemo(()=>n.out_of_range||s.out_of_range,[n.out_of_range,s.out_of_range]),m=c.useMemo(()=>n?.isDosageMismatch||s?.isDosageMismatch,[n?.isDosageMismatch,s?.isDosageMismatch]),x=c.useMemo(()=>n.calculation_type===k.C_MedicineCalculatorList[0]?n.calculation_fields:null,[n.calculation_fields,n.calculation_type]),f=c.useMemo(()=>n.calculation_type===k.C_MedicineCalculatorList[1]?n.calculation_fields:null,[n.calculation_fields,n.calculation_type]),T=(t,u)=>{let p;if(t==="calculation_type"){const S=u,q={frequency:n.calculation_fields.frequency,pedia_dosage:o==="standard"?n.calculation_fields.pedia_dosage:n.pedia_dosage};p={...n,calculation_type:S,calculation_fields:S==="mg/kg/dose"?{...k.C_DefaultMgKgFields,...q}:{...k.C_DefaultMlKgFields,...q}}}else p={...n,[t]:u};d(p),o==="prescription"&&v(p,t)},v=c.useMemo(()=>ue((t,u)=>{D?.(t,u||void 0)},500),[D]),r=c.useMemo(()=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-mb-1 hfl-flex hfl-w-max hfl-items-center hfl-rounded hfl-border-1 hfl-border-Warning-400 hfl-bg-Warning-50 hfl-p-1 hfl-px-2",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_warning hfl-text-Error-400"}),e.jsxRuntimeExports.jsx(e.Pc,{variant:"Regular",type:"Text sm",className:"hfl-px-2 hfl-text-1 hfl-text-Error-500",children:"Dosage exceed safety limits"})]}),[]);c.useEffect(()=>()=>{v.cancel()},[v]);const l=c.useCallback((t,u)=>{d(p=>{let S={...p.calculation_fields,[t]:u};if(t==="frequency"&&o==="standard"){const $=k.C_FrequencyDosageMap[u]||[];$.length>0&&(S={...S,pedia_dosage:$[0]})}const q={...p,calculation_fields:S};return o==="prescription"&&v(q,t),q})},[v,o]),I=async()=>{const t={...n,calculation_fields:{...n.calculation_fields}};await b?.(t)&&v({...t,isNewlyAdded:!1,isEditing:!1})},y=async()=>{if(!s.medicine_name||s.medicine_name.trim()===""){F?.(s.rowId);return}d(s),o==="standard"&&_(!1)},A=t=>o==="prescription"&&(t==="medicine_name"||t==="generic_name"||t==="type"||t==="calculation_type")?!1:z,P=()=>{const t=!(n?.isSavedToLibrary??!1),u={...n,isSavedToLibrary:t};d(u),v(u,"isSavedToLibrary")};return e.jsxRuntimeExports.jsxs("div",{className:`medicine-row hfl-grid hfl-grid-cols-[1.36fr_1.36fr_1.02fr_1.25fr_2.27fr_1.36fr_1.36fr] hfl-gap-2 hfl-px-2 hfl-py-1 hfl-border-b-1 hfl-border-Gray-200 ${z?"hfl-bg-gradient-to-b hfl-from-White_20 hfl-to-Primary-50":""} ${o==="prescription"&&!n.pedia_data_available?"hfl-hidden":""}`,children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("medicine_name")?e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",btnClassName:"hfl-w-full",inputClassName:"hfl-w-full",inputValue:n.medicine_name,showInput:!0,disableInputAutoSize:!0,inputChangeHandler:async t=>{if(T("medicine_name",t),t.trim()){const u=await C(t);O(u)}else O([])},onInputFocus:async()=>{const t=await C(n.medicine_name);O(t)},onChangeHandler:t=>{const u=t.value,p=k.C_MedicineTypeList.find(S=>S.val===u.medicineType);d(S=>({...S,medicine_name:u.doctorMedicineName,medicine_id:u.medicineId,generic_name:u.doctorGenericName,type:p?.type??""})),M(u.doctorMedicineName)},options:G,isSearchable:!0,placeholder:"Search medicine",disabled:!n?.isNewlyAdded,inputProps:{onBlur:t=>{const u=t.relatedTarget;if(!(u&&u.closest(".custom-dropdown-menu"))&&!E){const p=n.medicine_name?.trim()||"";G.some(q=>q.label===p)||d(q=>({...q,medicine_name:N}))}}}}):e.jsxRuntimeExports.jsx(Y,{children:s.medicine_name})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("generic_name")?e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",inputClassName:"hfl-w-full",btnClassName:"hfl-w-full",inputValue:n.generic_name,showInput:!0,disableInputAutoSize:!0,inputChangeHandler:t=>T("generic_name",t),hideDropdownIcon:!0}):e.jsxRuntimeExports.jsx(Y,{children:s.generic_name})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("type")?e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",btnClassName:"hfl-w-full",placeholder:"Select",showInput:!1,disableInputAutoSize:!0,selectedOption:(()=>{const t=k.C_MedicineTypeList.find(u=>u.type===n.type);return t?{label:t.type,value:t.type}:void 0})(),options:k.C_MedicineTypeList.map(t=>({label:t.type,value:t.type})),onChangeHandler:t=>T("type",t.value)}):e.jsxRuntimeExports.jsx(Y,{children:s.type||""})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("calculation_type")?e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",btnClassName:"hfl-w-full",placeholder:"Select",showInput:!1,disableInputAutoSize:!0,selectedOption:{label:n.calculation_type,value:n.calculation_type},options:k.C_MedicineCalculatorList.map(t=>({label:t,value:t})),onChangeHandler:t=>T("calculation_type",t.value)}):e.jsxRuntimeExports.jsx(Y,{children:s.calculation_type})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-w-full hfl-flex-col hfl-gap-2 hfl-py-2.5 hfl-px-2",children:A("calculation_fields")?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(B,{label:"Drug Strength",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"e.g., 250",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:x.drug_strength||"",inputChangeHandler:t=>{V(t)&&l("drug_strength",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Dose/mg/kg",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"e.g., 15",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:x.dose_mg_kg||"",inputChangeHandler:t=>{V(t)&&l("dose_mg_kg",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Frequency",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Frequency",showInput:!1,selectedOption:n.calculation_fields.frequency?{label:n.calculation_fields.frequency,value:n.calculation_fields.frequency}:void 0,options:k.C_MedicineFrequencyList.map(t=>({label:t,value:t})),onChangeHandler:t=>{l("frequency",t.value)}})}),e.jsxRuntimeExports.jsx(B,{label:"Max Dose (mg)",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Max mg/dose",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:x.max_mg_dose||"",inputChangeHandler:t=>{V(t)&&l("max_mg_dose",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Max Day (mg)",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Max mg/day",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:x.max_mg_day||"",inputChangeHandler:t=>{V(t)&&l("max_mg_day",t)}})})]}),f&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(B,{label:"Drug Strength/mL",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"e.g., 250",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:f.drug_strength||"",inputChangeHandler:t=>{V(t)&&(l("drug_strength",t),l("dose_ml_kg",Q(f.dose_mg_kg,t)))}})}),e.jsxRuntimeExports.jsx(B,{label:"Dose/mg/kg",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"e.g., 15",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:f.dose_mg_kg||"",inputChangeHandler:t=>{V(t)&&(l("dose_mg_kg",t),l("dose_ml_kg",Q(t,f.drug_strength)))}})}),e.jsxRuntimeExports.jsx(B,{label:"Dose/mL/kg",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",disabled:!0,placeholder:"e.g., 5",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:Q(f.dose_mg_kg,f.drug_strength)||"",inputChangeHandler:t=>{V(t)&&l("dose_ml_kg",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Frequency",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Frequency",showInput:!1,selectedOption:n.calculation_fields.frequency?{label:n.calculation_fields.frequency,value:n.calculation_fields.frequency}:void 0,options:k.C_MedicineFrequencyList.map(t=>({label:t,value:t})),onChangeHandler:t=>{l("frequency",t.value)}})}),e.jsxRuntimeExports.jsx(B,{label:"Max Dose (mL)",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Max mL/dose",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:f.max_ml_dose||"",inputChangeHandler:t=>{V(t)&&l("max_ml_dose",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Max Day (mL)",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Max mL/day",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:f.max_ml_day||"",inputChangeHandler:t=>{V(t)&&l("max_ml_day",t)}})})]})]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(H,{label:"Drug Strength",value:x.drug_strength}),e.jsxRuntimeExports.jsx(H,{label:"Dose/mg/kg",value:x.dose_mg_kg}),e.jsxRuntimeExports.jsx(H,{label:"Frequency",value:x.frequency}),e.jsxRuntimeExports.jsx(H,{label:"Max Dose (mg)",value:x.max_mg_dose}),e.jsxRuntimeExports.jsx(H,{label:"Max Day (mg)",value:x.max_mg_day})]}),f&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(H,{label:"Drug Strength/mL",value:f.drug_strength}),e.jsxRuntimeExports.jsx(H,{label:"Dose/mg/kg",value:f.dose_mg_kg}),e.jsxRuntimeExports.jsx(H,{label:"Dose/mL/kg",value:f.dose_ml_kg}),e.jsxRuntimeExports.jsx(H,{label:"Frequency",value:f.frequency}),e.jsxRuntimeExports.jsx(H,{label:"Max Dose (mL)",value:f.max_ml_dose}),e.jsxRuntimeExports.jsx(H,{label:"Max Day (mL)",value:f.max_ml_day})]})]})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("pedia_dosage")?(()=>{const t=n.calculation_fields.frequency,u=k.C_FrequencyDosageMap[t]||[];return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",btnClassName:"hfl-w-full",inputClassName:"hfl-w-full",placeholder:"Select",showInput:o!=="standard",disableInputAutoSize:!0,inputValue:o==="standard"?n.calculation_fields.pedia_dosage:n.pedia_dosage,inputChangeHandler:p=>o==="prescription"?T("pedia_dosage",p):l("pedia_dosage",p),selectedOption:o==="standard"?{label:n.calculation_fields.pedia_dosage,value:n.calculation_fields.pedia_dosage}:void 0,options:o!=="prescription"?u.map(p=>({label:p,value:p})):void 0,onChangeHandler:o!=="prescription"?p=>l("pedia_dosage",p.value):void 0,hideDropdownIcon:o==="prescription",showEmptyDropdownPopup:o!=="prescription",showErrorMsg:o==="prescription"?a||m:!1,errorMsg:o==="prescription"&&a?"Dosage Exceeds Safety Limits":o==="prescription"&&m?"Dosage is in mismatch with selected type of Frequency":""})})})():e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-h-full hfl-justify-between hfl-min-w-0",children:[e.jsxRuntimeExports.jsx(Y,{children:o==="prescription"?s.pedia_dosage:s.calculation_fields.pedia_dosage}),a&&r]})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:e.jsxRuntimeExports.jsx(re,{effectiveEditMode:z,rowData:s,isSavedToLibrary:n.isSavedToLibrary??!1,onSave:I,onCancel:y,onEdit:()=>_(!0),onCheckboxToggle:P})})]})},(i,s)=>i.isEditing===s.isEditing&&i.rowData.rowId===s.rowData.rowId&&i.rowData.isEditing===s.rowData.isEditing&&i.rowData.medicine_name===s.rowData.medicine_name&&i.rowData.generic_name===s.rowData.generic_name&&i.rowData.type===s.rowData.type&&i.rowData.pedia_dosage===s.rowData.pedia_dosage&&i.rowData.calculation_type===s.rowData.calculation_type&&JSON.stringify(i.rowData.calculation_fields)===JSON.stringify(s.rowData.calculation_fields)&&i.rowData.out_of_range===s.rowData.out_of_range&&i.rowData.isDosageMismatch===s.rowData.isDosageMismatch&&i.rowData.calculation_fields.pedia_dosage===s.rowData.calculation_fields.pedia_dosage&&i.rowData?.isNewlyAdded===s.rowData?.isNewlyAdded&&i.rowData?.pedia_data_available===s.rowData?.pedia_data_available),fe=({open:i,onCancel:s,onCopySave:j,rowMedicineData:_,getMedicineOptions:b})=>{const[E,o]=c.useState([]),[w,L]=c.useState(""),[R,D]=c.useState([]),F=c.useCallback(async d=>{const M=(await b?.(d))?.map(C=>({label:C.doctorMedicineName,value:C}));D(M||[])},[b]);c.useEffect(()=>{i&&F(w)},[w,F,i]);const G=d=>{const N=d.value;E.some(C=>C.medicineId===N.medicineId&&C.doctorMedicineName.trim().toLowerCase()===N.doctorMedicineName.trim().toLowerCase())||o(C=>[...C,N]),L(""),D([])},O=d=>{o(N=>N.filter(M=>M.medicineId!==d))},n=async()=>{w.trim()||await F("")};return e.jsxRuntimeExports.jsxs(se.Modal,{isOpen:i,onRequestClose:s,shouldCloseOnOverlayClick:!1,style:{overlay:{backgroundColor:"rgba(52, 64, 84, 0.5)",zIndex:1030},content:{zIndex:1031,maxWidth:"600px",maxHeight:"50vh",height:"auto",margin:"auto",borderRadius:"12px",padding:"0px",display:"flex",flexDirection:"column"}},children:[e.jsxRuntimeExports.jsx(e.Pc,{variant:"Bold",type:"Text lg",className:"hfl-text-White hfl-bg-gradient_primary_600_500_90 hfl-px-6 hfl-py-2",children:"Please select medicine to copy"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-px-6 hfl-py-5 hfl-flex hfl-flex-col hfl-gap-6 hfl-overflow-y-auto hfl-flex-1",children:[e.jsxRuntimeExports.jsx(g,{inputValue:w,showInput:!0,isSearchable:!0,disableInputAutoSize:!0,inputChangeHandler:L,onChangeHandler:G,onInputFocus:n,options:R,placeholder:"Search for medicines"}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-wrap hfl-gap-2",children:E.map(d=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-bg-Gray-100 hfl-px-2 hfl-py-0.5 hfl-rounded-md hfl-gap-1",children:[e.jsxRuntimeExports.jsx(e.Pc,{variant:"Regular",type:"Text sm",className:"hfl-text-nowrap",children:d.doctorMedicineName}),e.jsxRuntimeExports.jsx("button",{className:"hfl-text-Blue_gray-800",onClick:()=>O(d.medicineId),children:e.jsxRuntimeExports.jsx("i",{className:"hx_close"})})]},d.doctorMedicineName+d.medicineId))})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-justify-end hfl-gap-2.5 hfl-bg-Gray-50 hfl-px-7 hfl-py-3 hfl-border-t hfl-border-Gray-200",children:[e.jsxRuntimeExports.jsx(e.Yu,{size:"md",textField:"Cancel",onClick:s,hierarchy:"Secondary-Grey"}),e.jsxRuntimeExports.jsx(e.Yu,{size:"md",textField:"Save",disabled:!E||E.length==0,onClick:async()=>{await j(_,E)&&s()},className:"hfl-bg-Primary-600 hfl-text-White disabled:hfl-opacity-50 disabled:hfl-cursor-not-allowed",hierarchy:"Primary"})]})]})},xe=c.forwardRef(({data:i=[],variant:s,externallyTriggeredEditRowIds:j=[],externallyTriggeredEditMode:_=!1,allowCustomMedicineInput:b=!0,getMedicineOptions:E,onRowChange:o,onRowDelete:w,onRowCopy:L,onSaveRow:R,externalSaveTrigger:D,setSearchDisabled:F},G)=>{const[O,n]=c.useState(null),[d,N]=c.useState(!1),[M,C]=c.useState(),K=c.useCallback((r,l,I)=>{const y=i.find(P=>P.rowId===r);if(!y)return;const A={...y,...l};o?.(A,I||void 0)},[i,o]),z=c.useCallback(async()=>{const r=i.filter(l=>l.isEditing&&l.medicine_name);if(r.length!==0)try{await R?.(r)&&r.forEach(I=>{o?.({...I,isEditing:!1})})}catch(l){console.error("Bulk save failed",l)}finally{F?.(!1)}},[i,R,o,F]);c.useEffect(()=>{D&&z()},[D,z]),c.useEffect(()=>{const r=i.some(l=>l.isEditing);F?.(r)},[i,F]);const a=c.useCallback(r=>{C(r),N(!0)},[]),m=c.useCallback(async()=>{if(O)try{await w?.(O)}catch(r){console.error("Delete failed",r)}finally{n(null)}},[O,w]),x=c.useCallback(()=>{n(null)},[]),f=c.useCallback(async r=>{try{return await R?.([r])?(o?.({...r,isEditing:!1}),!0):!1}catch(l){return console.error("Save row failed",l),!1}},[R,o]),T=c.useCallback(async()=>{const r=i.filter(l=>l.isEditing&&l.medicine_name);if(r.length===0)return!0;try{const l=await R?.(r);return l&&i.map(y=>y.isEditing?{...y,isEditing:!1}:y).forEach(y=>o?.(y)),!!l}catch(l){return console.error("External bulk save failed",l),!1}},[i,R,o]);c.useImperativeHandle(G,()=>({triggerExternalSave:T}));const v={variant:s,externallyTriggeredEditMode:_,externallyTriggeredEditRowIds:j,getMedicineOptions:E,onRowChange:(r,l)=>{K(r.rowId,r,l),o?.(r,l)},onRowDelete:w,onRowCopy:L,setRowToDelete:n,openPopupForRow:a};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-border-1 hfl-border-Gray-200",children:[e.jsxRuntimeExports.jsx("div",{className:"table-header hfl-grid hfl-grid-cols-[1.36fr_1.36fr_1.02fr_1.25fr_2.27fr_1.36fr_1.36fr] hfl-gap-2 hfl-py-2 hfl-px-2 hfl-font-bold hfl-border-b-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50",children:k.C_Table_Column_Name.map(r=>e.jsxRuntimeExports.jsx(e.Pc,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600",children:r},r))}),e.jsxRuntimeExports.jsxs(le.Provider,{value:v,children:[e.jsxRuntimeExports.jsx("div",{className:"table-body",children:i.length===0?e.jsxRuntimeExports.jsx(e.Pc,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600 hfl-px-2 hfl-py-3",children:"No medicines added"}):i.map(r=>e.jsxRuntimeExports.jsx(de,{rowData:r,isEditing:r.isEditing||!1,setIsEditing:l=>K(r.rowId,{isEditing:l}),onSaveRow:f,allowCustomMedicineInput:b},r.rowId))}),e.jsxRuntimeExports.jsx(se.AlertPopup,{headingText:"Delete Medicine",subHeadingText:"Are you sure you want to delete this medicine?",openState:!!O,positiveButtonText:"Delete",negativeButtonText:"Cancel",positiveActionCallback:m,negativeActionCallback:x,classNameNegativeBtn:"hfl-bg-Blue-600",classNamePositiveBtn:"hfl-bg-Error-500 hover:hfl-bg-Error-700 hfl-text-White",closePopupCallback:x}),e.jsxRuntimeExports.jsx(fe,{open:d,onCancel:()=>N(!1),onCopySave:L,rowMedicineData:M,getMedicineOptions:E})]})]})});exports.PediatricsCalculatorTable=xe;
1
+ "use strict";const e=require("./index-C6KQLMQs.cjs"),c=require("react"),k=require("./constants/PediatricsCalculatorConstants/index.js"),g=require("./CustomDropdown/index.js"),se=require("./AlertPopup-DdrHGPKR.cjs"),le=c.createContext(null),ne=()=>{const i=c.useContext(le);if(!i)throw new Error("usePediatricsCalculatorTableContext must be used inside a MedicineTableProvider");return i},re=({effectiveEditMode:i,rowData:s,isSavedToLibrary:j,onSave:_,onCancel:b,onEdit:E,onCheckboxToggle:o})=>{const{variant:w,externallyTriggeredEditMode:L,setRowToDelete:R,openPopupForRow:D}=ne();return w==="standard"?i?e.jsxRuntimeExports.jsxs("div",{className:"hfl-grid hfl-grid-cols-[1fr_1fr] hfl-border-1 hfl-border-Gray-200 hfl-rounded-lg ",children:[e.jsxRuntimeExports.jsx("button",{className:"hfl-px-3 hfl-py-1 hfl-text-Blue_gray-800 hfl-border-r-1 hover:hfl-bg-Primary-50",onClick:_,children:e.jsxRuntimeExports.jsx(e.bs,{variant:"Medium",type:"Text xs",className:"hfl-text-Blue_gray-800",children:"Save"})}),e.jsxRuntimeExports.jsx("button",{className:"hfl-px-3 hfl-py-2 hfl-text-Error-600 hover:hfl-bg-Error-50",onClick:b,children:e.jsxRuntimeExports.jsx(e.bs,{variant:"Medium",type:"Text xs",className:"",children:"Cancel"})})]}):e.jsxRuntimeExports.jsxs("div",{className:"hfl-grid hfl-grid-cols-[1fr_1fr_1fr] hfl-border-1 hfl-border-Gray-200 hfl-rounded-lg",children:[e.jsxRuntimeExports.jsx("button",{className:"hfl-px-3 hfl-py-1 hfl-text-Blue_gray-800 hover:hfl-bg-Primary-50",onClick:E,children:e.jsxRuntimeExports.jsx(e.bs,{variant:"Medium",type:"Text xs",className:"",children:"Edit"})}),e.jsxRuntimeExports.jsx("button",{className:"hfl-px-3 hfl-py-2 hfl-text-Blue_gray-800 hfl-border-x-1 hover:hfl-bg-Primary-50",onClick:()=>D?.(s),children:e.jsxRuntimeExports.jsx(e.bs,{variant:"Medium",type:"Text xs",className:"",children:"Copy"})}),e.jsxRuntimeExports.jsx("button",{className:"hx_delete hfl-px-3 hfl-py-2 hfl-text-Error-500 hover:hfl-bg-Error-50",onClick:()=>R?.(s.rowId)})]}):e.jsxRuntimeExports.jsx(e.Os,{disabled:!L,text:"Save this to Pediatric Calculator Library ",id:s.rowId,size:"md",onClick:o,isMarked:j??!1,checkboxClasses:"hfl-mt-2",checkBoxInnerDivClasses:"hfl-text-Blue-600 hfl-bg-Blue-50"},s.rowId)};var Q,te;function oe(){if(te)return Q;te=1;var i="Expected a function",s=NaN,j="[object Symbol]",_=/^\s+|\s+$/g,b=/^[-+]0x[0-9a-f]+$/i,E=/^0b[01]+$/i,o=/^0o[0-7]+$/i,w=parseInt,L=typeof e.commonjsGlobal=="object"&&e.commonjsGlobal&&e.commonjsGlobal.Object===Object&&e.commonjsGlobal,R=typeof self=="object"&&self&&self.Object===Object&&self,D=L||R||Function("return this")(),F=Object.prototype,W=F.toString,O=Math.max,n=Math.min,d=function(){return D.Date.now()};function N(a,m,x){var f,T,v,r,l,I,y=0,A=!1,V=!1,t=!0;if(typeof a!="function")throw new TypeError(i);m=z(m)||0,M(x)&&(A=!!x.leading,V="maxWait"in x,v=V?O(z(x.maxWait)||0,m):v,t="trailing"in x?!!x.trailing:t);function u(h){var $=f,J=T;return f=T=void 0,y=h,r=a.apply(J,$),r}function p(h){return y=h,l=setTimeout(P,m),A?u(h):r}function S(h){var $=h-I,J=h-y,ee=m-$;return V?n(ee,v-J):ee}function q(h){var $=h-I,J=h-y;return I===void 0||$>=m||$<0||V&&J>=v}function P(){var h=d();if(q(h))return Z(h);l=setTimeout(P,S(h))}function Z(h){return l=void 0,t&&f?u(h):(f=T=void 0,r)}function ie(){l!==void 0&&clearTimeout(l),y=0,f=I=T=l=void 0}function ae(){return l===void 0?r:Z(d())}function X(){var h=d(),$=q(h);if(f=arguments,T=this,I=h,$){if(l===void 0)return p(I);if(V)return l=setTimeout(P,m),u(I)}return l===void 0&&(l=setTimeout(P,m)),r}return X.cancel=ie,X.flush=ae,X}function M(a){var m=typeof a;return!!a&&(m=="object"||m=="function")}function C(a){return!!a&&typeof a=="object"}function K(a){return typeof a=="symbol"||C(a)&&W.call(a)==j}function z(a){if(typeof a=="number")return a;if(K(a))return s;if(M(a)){var m=typeof a.valueOf=="function"?a.valueOf():a;a=M(m)?m+"":m}if(typeof a!="string")return a===0?a:+a;a=a.replace(_,"");var x=E.test(a);return x||o.test(a)?w(a.slice(2),x?2:8):b.test(a)?s:+a}return Q=N,Q}var ce=oe();const ue=e.getDefaultExportFromCjs(ce),Y=(i,s)=>{const j=parseFloat(i),_=parseFloat(s);if(!i||!s||isNaN(j)||isNaN(_)||_===0)return"";const b=j/_;return Number.isInteger(b)?b.toString(10):b.toFixed(3).replace(/\.?0+$/,"")},G=i=>/^(\d+)?(\.)?(\d*)?$/.test(i),B=({label:i,children:s})=>e.jsxRuntimeExports.jsxs(e.bs,{variant:"Regular",type:"Text sm",className:"hfl-grid hfl-grid-cols-2 hfl-items-center hfl-text-Blue_gray-800 hfl-justify-between hfl-gap-8",children:[e.jsxRuntimeExports.jsxs("span",{className:"hfl-flex-shrink-0",children:[i,":"]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex-1 hfl-min-w-0",children:s})]}),H=({label:i,value:s})=>e.jsxRuntimeExports.jsxs(e.bs,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-text-Blue_gray-800 hfl-gap-1",children:[e.jsxRuntimeExports.jsxs("span",{className:"hfl-flex-shrink-0",children:[i,":"]}),e.jsxRuntimeExports.jsx(e.bs,{variant:"Bold",type:"Text sm",className:"hfl-text-Blue_gray-800 hfl-break-words hfl-min-w-0",children:s||"--"})]}),U=({children:i,className:s=""})=>e.jsxRuntimeExports.jsx(e.bs,{variant:"Regular",type:"Text sm",className:`hfl-text-Blue_gray-800 hfl-px-2 hfl-break-words hfl-overflow-wrap-anywhere hfl-min-w-0 ${s}`,children:i}),de=c.memo(function({rowData:s,isEditing:j,setIsEditing:_,onSaveRow:b,allowCustomMedicineInput:E}){const{variant:o,externallyTriggeredEditMode:w,externallyTriggeredEditRowIds:L,getMedicineOptions:R,onRowChange:D,onRowDelete:F}=ne(),[W,O]=c.useState([]),[n,d]=c.useState(s),[N,M]=c.useState(s.medicine_name);c.useEffect(()=>{j||M(s.medicine_name)},[s.medicine_name,j]),c.useEffect(()=>{j||d(s)},[s,j]);const C=async t=>(await R?.(t))?.map(p=>({label:p.doctorMedicineName,value:p}))||[],z=w||L?.includes(s.rowId)||j,a=c.useMemo(()=>n.out_of_range||s.out_of_range,[n.out_of_range,s.out_of_range]),m=c.useMemo(()=>n?.isDosageMismatch||s?.isDosageMismatch,[n?.isDosageMismatch,s?.isDosageMismatch]),x=c.useMemo(()=>n.calculation_type===k.C_MedicineCalculatorList[0]?n.calculation_fields:null,[n.calculation_fields,n.calculation_type]),f=c.useMemo(()=>n.calculation_type===k.C_MedicineCalculatorList[1]?n.calculation_fields:null,[n.calculation_fields,n.calculation_type]),T=(t,u)=>{let p;if(t==="calculation_type"){const S=u,q={frequency:n.calculation_fields.frequency,pedia_dosage:o==="standard"?n.calculation_fields.pedia_dosage:n.pedia_dosage};p={...n,calculation_type:S,calculation_fields:S==="mg/kg/dose"?{...k.C_DefaultMgKgFields,...q}:{...k.C_DefaultMlKgFields,...q}}}else p={...n,[t]:u};d(p),o==="prescription"&&v(p,t)},v=c.useMemo(()=>ue((t,u)=>{D?.(t,u||void 0)},500),[D]),r=c.useMemo(()=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-mb-1 hfl-flex hfl-w-max hfl-items-center hfl-rounded hfl-border-1 hfl-border-Warning-400 hfl-bg-Warning-50 hfl-p-1 hfl-px-2",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_warning hfl-text-Error-400"}),e.jsxRuntimeExports.jsx(e.bs,{variant:"Regular",type:"Text sm",className:"hfl-px-2 hfl-text-1 hfl-text-Error-500",children:"Dosage exceed safety limits"})]}),[]);c.useEffect(()=>()=>{v.cancel()},[v]);const l=c.useCallback((t,u)=>{d(p=>{let S={...p.calculation_fields,[t]:u};if(t==="frequency"&&o==="standard"){const P=k.C_FrequencyDosageMap[u]||[];P.length>0&&(S={...S,pedia_dosage:P[0]})}const q={...p,calculation_fields:S};return o==="prescription"&&v(q,t),q})},[v,o]),I=async()=>{const t={...n,calculation_fields:{...n.calculation_fields}};await b?.(t)&&v({...t,isNewlyAdded:!1,isEditing:!1})},y=async()=>{if(!s.medicine_name||s.medicine_name.trim()===""){F?.(s.rowId);return}d(s),o==="standard"&&_(!1)},A=t=>o==="prescription"&&(t==="medicine_name"||t==="generic_name"||t==="type"||t==="calculation_type")?!1:z,V=()=>{const t=!(n?.isSavedToLibrary??!1),u={...n,isSavedToLibrary:t};d(u),v(u,"isSavedToLibrary")};return e.jsxRuntimeExports.jsxs("div",{className:`medicine-row hfl-grid hfl-grid-cols-[1.36fr_1.36fr_1.02fr_1.25fr_2.27fr_1.36fr_1.36fr] hfl-gap-2 hfl-px-2 hfl-py-1 hfl-border-b-1 hfl-border-Gray-200 ${z?"hfl-bg-gradient-to-b hfl-from-White_20 hfl-to-Primary-50":""} ${o==="prescription"&&!n.pedia_data_available?"hfl-hidden":""}`,children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("medicine_name")?e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",btnClassName:"hfl-w-full",inputClassName:"hfl-w-full",inputValue:n.medicine_name,showInput:!0,disableInputAutoSize:!0,inputChangeHandler:async t=>{if(T("medicine_name",t),t.trim()){const u=await C(t);O(u)}else O([])},onInputFocus:async()=>{const t=await C(n.medicine_name);O(t)},onChangeHandler:t=>{const u=t.value,p=k.C_MedicineTypeList.find(S=>S.val===u.medicineType);d(S=>({...S,medicine_name:u.doctorMedicineName,medicine_id:u.medicineId,generic_name:u.doctorGenericName,type:p?.type??""})),M(u.doctorMedicineName)},options:W,isSearchable:!0,placeholder:"Search medicine",disabled:!n?.isNewlyAdded,inputProps:{onBlur:t=>{const u=t.relatedTarget;if(!(u&&u.closest(".custom-dropdown-menu"))&&!E){const p=n.medicine_name?.trim()||"";W.some(q=>q.label===p)||d(q=>({...q,medicine_name:N}))}}}}):e.jsxRuntimeExports.jsx(U,{children:s.medicine_name})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("generic_name")?e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",inputClassName:"hfl-w-full",btnClassName:"hfl-w-full",inputValue:n.generic_name,showInput:!0,disableInputAutoSize:!0,inputChangeHandler:t=>T("generic_name",t),hideDropdownIcon:!0}):e.jsxRuntimeExports.jsx(U,{children:s.generic_name})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("type")?e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",btnClassName:"hfl-w-full",placeholder:"Select",showInput:!1,disableInputAutoSize:!0,selectedOption:(()=>{const t=k.C_MedicineTypeList.find(u=>u.type===n.type);return t?{label:t.type,value:t.type}:void 0})(),options:k.C_MedicineTypeList.map(t=>({label:t.type,value:t.type})),onChangeHandler:t=>T("type",t.value)}):e.jsxRuntimeExports.jsx(U,{children:s.type||""})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("calculation_type")?e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",btnClassName:"hfl-w-full",placeholder:"Select",showInput:!1,disableInputAutoSize:!0,selectedOption:{label:n.calculation_type,value:n.calculation_type},options:k.C_MedicineCalculatorList.map(t=>({label:t,value:t})),onChangeHandler:t=>T("calculation_type",t.value)}):e.jsxRuntimeExports.jsx(U,{children:s.calculation_type})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-w-full hfl-flex-col hfl-gap-2 hfl-py-2.5 hfl-px-2",children:A("calculation_fields")?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(B,{label:"Drug Strength",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"e.g., 250",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:x.drug_strength||"",inputChangeHandler:t=>{G(t)&&l("drug_strength",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Dose/mg/kg",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"e.g., 15",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:x.dose_mg_kg||"",inputChangeHandler:t=>{G(t)&&l("dose_mg_kg",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Frequency",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Frequency",showInput:!1,selectedOption:n.calculation_fields.frequency?{label:n.calculation_fields.frequency,value:n.calculation_fields.frequency}:void 0,options:k.C_MedicineFrequencyList.map(t=>({label:t,value:t})),onChangeHandler:t=>{l("frequency",t.value)}})}),e.jsxRuntimeExports.jsx(B,{label:"Max Dose (mg)",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Max mg/dose",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:x.max_mg_dose||"",inputChangeHandler:t=>{G(t)&&l("max_mg_dose",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Max Day (mg)",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Max mg/day",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:x.max_mg_day||"",inputChangeHandler:t=>{G(t)&&l("max_mg_day",t)}})})]}),f&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(B,{label:"Drug Strength/mL",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"e.g., 250",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:f.drug_strength||"",inputChangeHandler:t=>{G(t)&&(l("drug_strength",t),l("dose_ml_kg",Y(f.dose_mg_kg,t)))}})}),e.jsxRuntimeExports.jsx(B,{label:"Dose/mg/kg",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"e.g., 15",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:f.dose_mg_kg||"",inputChangeHandler:t=>{G(t)&&(l("dose_mg_kg",t),l("dose_ml_kg",Y(t,f.drug_strength)))}})}),e.jsxRuntimeExports.jsx(B,{label:"Dose/mL/kg",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",disabled:!0,placeholder:"e.g., 5",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:Y(f.dose_mg_kg,f.drug_strength)||"",inputChangeHandler:t=>{G(t)&&l("dose_ml_kg",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Frequency",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Frequency",showInput:!1,selectedOption:n.calculation_fields.frequency?{label:n.calculation_fields.frequency,value:n.calculation_fields.frequency}:void 0,options:k.C_MedicineFrequencyList.map(t=>({label:t,value:t})),onChangeHandler:t=>{l("frequency",t.value)}})}),e.jsxRuntimeExports.jsx(B,{label:"Max Dose (mL)",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Max mL/dose",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:f.max_ml_dose||"",inputChangeHandler:t=>{G(t)&&l("max_ml_dose",t)}})}),e.jsxRuntimeExports.jsx(B,{label:"Max Day (mL)",children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",placeholder:"Max mL/day",showInput:!0,hideDropdownIcon:!0,disableInputAutoSize:!0,inputType:"text",inputValue:f.max_ml_day||"",inputChangeHandler:t=>{G(t)&&l("max_ml_day",t)}})})]})]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(H,{label:"Drug Strength",value:x.drug_strength}),e.jsxRuntimeExports.jsx(H,{label:"Dose/mg/kg",value:x.dose_mg_kg}),e.jsxRuntimeExports.jsx(H,{label:"Frequency",value:x.frequency}),e.jsxRuntimeExports.jsx(H,{label:"Max Dose (mg)",value:x.max_mg_dose}),e.jsxRuntimeExports.jsx(H,{label:"Max Day (mg)",value:x.max_mg_day})]}),f&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(H,{label:"Drug Strength/mL",value:f.drug_strength}),e.jsxRuntimeExports.jsx(H,{label:"Dose/mg/kg",value:f.dose_mg_kg}),e.jsxRuntimeExports.jsx(H,{label:"Dose/mL/kg",value:f.dose_ml_kg}),e.jsxRuntimeExports.jsx(H,{label:"Frequency",value:f.frequency}),e.jsxRuntimeExports.jsx(H,{label:"Max Dose (mL)",value:f.max_ml_dose}),e.jsxRuntimeExports.jsx(H,{label:"Max Day (mL)",value:f.max_ml_day})]})]})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:A("pedia_dosage")?(()=>{const t=n.calculation_fields.frequency,u=k.C_FrequencyDosageMap[t]||[];return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(g,{wrapperClass:"hfl-w-full",btnClassName:"hfl-w-full",inputClassName:"hfl-w-full",placeholder:"Select",showInput:o!=="standard",disableInputAutoSize:!0,inputValue:o==="standard"?n.calculation_fields.pedia_dosage:n.pedia_dosage,inputChangeHandler:p=>o==="prescription"?T("pedia_dosage",p):l("pedia_dosage",p),selectedOption:o==="standard"?{label:n.calculation_fields.pedia_dosage,value:n.calculation_fields.pedia_dosage}:void 0,options:o!=="prescription"?u.map(p=>({label:p,value:p})):void 0,onChangeHandler:o!=="prescription"?p=>l("pedia_dosage",p.value):void 0,hideDropdownIcon:o==="prescription",showEmptyDropdownPopup:o!=="prescription",showErrorMsg:o==="prescription"?a||m:!1,errorMsg:o==="prescription"&&a?"Dosage Exceeds Safety Limits":o==="prescription"&&m?"Dosage is in mismatch with selected type of Frequency":""})})})():e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-h-full hfl-justify-between hfl-min-w-0",children:[e.jsxRuntimeExports.jsx(U,{children:o==="prescription"?s.pedia_dosage:s.calculation_fields.pedia_dosage}),a&&r]})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-py-2.5 hfl-min-w-0",children:e.jsxRuntimeExports.jsx(re,{effectiveEditMode:z,rowData:s,isSavedToLibrary:n.isSavedToLibrary??!1,onSave:I,onCancel:y,onEdit:()=>_(!0),onCheckboxToggle:V})})]})},(i,s)=>i.isEditing===s.isEditing&&i.rowData.rowId===s.rowData.rowId&&i.rowData.isEditing===s.rowData.isEditing&&i.rowData.medicine_name===s.rowData.medicine_name&&i.rowData.generic_name===s.rowData.generic_name&&i.rowData.type===s.rowData.type&&i.rowData.pedia_dosage===s.rowData.pedia_dosage&&i.rowData.calculation_type===s.rowData.calculation_type&&JSON.stringify(i.rowData.calculation_fields)===JSON.stringify(s.rowData.calculation_fields)&&i.rowData.out_of_range===s.rowData.out_of_range&&i.rowData.isDosageMismatch===s.rowData.isDosageMismatch&&i.rowData.calculation_fields.pedia_dosage===s.rowData.calculation_fields.pedia_dosage&&i.rowData?.isNewlyAdded===s.rowData?.isNewlyAdded&&i.rowData?.pedia_data_available===s.rowData?.pedia_data_available),fe=({open:i,onCancel:s,onCopySave:j,rowMedicineData:_,getMedicineOptions:b})=>{const[E,o]=c.useState([]),[w,L]=c.useState(""),[R,D]=c.useState([]),F=c.useCallback(async d=>{const M=(await b?.(d))?.map(C=>({label:C.doctorMedicineName,value:C}));D(M||[])},[b]);c.useEffect(()=>{i&&F(w)},[w,F,i]);const W=d=>{const N=d.value;E.some(C=>C.medicineId===N.medicineId&&C.doctorMedicineName.trim().toLowerCase()===N.doctorMedicineName.trim().toLowerCase())||o(C=>[...C,N]),L(""),D([])},O=d=>{o(N=>N.filter(M=>M.medicineId!==d))},n=async()=>{w.trim()||await F("")};return e.jsxRuntimeExports.jsxs(se.Modal,{isOpen:i,onRequestClose:s,shouldCloseOnOverlayClick:!1,style:{overlay:{backgroundColor:"rgba(52, 64, 84, 0.5)",zIndex:1030},content:{zIndex:1031,maxWidth:"600px",maxHeight:"50vh",height:"auto",margin:"auto",borderRadius:"12px",padding:"0px",display:"flex",flexDirection:"column"}},children:[e.jsxRuntimeExports.jsx(e.bs,{variant:"Bold",type:"Text lg",className:"hfl-text-White hfl-bg-gradient_primary_600_500_90 hfl-px-6 hfl-py-2",children:"Please select medicine to copy"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-px-6 hfl-py-5 hfl-flex hfl-flex-col hfl-gap-6 hfl-overflow-y-auto hfl-flex-1",children:[e.jsxRuntimeExports.jsx(g,{inputValue:w,showInput:!0,isSearchable:!0,disableInputAutoSize:!0,inputChangeHandler:L,onChangeHandler:W,onInputFocus:n,options:R,placeholder:"Search for medicines"}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-wrap hfl-gap-2",children:E.map(d=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-bg-Gray-100 hfl-px-2 hfl-py-0.5 hfl-rounded-md hfl-gap-1",children:[e.jsxRuntimeExports.jsx(e.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-nowrap",children:d.doctorMedicineName}),e.jsxRuntimeExports.jsx("button",{className:"hfl-text-Blue_gray-800",onClick:()=>O(d.medicineId),children:e.jsxRuntimeExports.jsx("i",{className:"hx_close"})})]},d.doctorMedicineName+d.medicineId))})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-justify-end hfl-gap-2.5 hfl-bg-Gray-50 hfl-px-7 hfl-py-3 hfl-border-t hfl-border-Gray-200",children:[e.jsxRuntimeExports.jsx(e.Ku,{size:"md",textField:"Cancel",onClick:s,hierarchy:"Secondary-Grey"}),e.jsxRuntimeExports.jsx(e.Ku,{size:"md",textField:"Save",disabled:!E||E.length==0,onClick:async()=>{await j(_,E)&&s()},className:"hfl-bg-Primary-600 hfl-text-White disabled:hfl-opacity-50 disabled:hfl-cursor-not-allowed",hierarchy:"Primary"})]})]})},xe=c.forwardRef(({data:i=[],variant:s,externallyTriggeredEditRowIds:j=[],externallyTriggeredEditMode:_=!1,allowCustomMedicineInput:b=!0,getMedicineOptions:E,onRowChange:o,onRowDelete:w,onRowCopy:L,onSaveRow:R,externalSaveTrigger:D,setSearchDisabled:F},W)=>{const[O,n]=c.useState(null),[d,N]=c.useState(!1),[M,C]=c.useState(),K=c.useCallback((r,l,I)=>{const y=i.find(V=>V.rowId===r);if(!y)return;const A={...y,...l};o?.(A,I||void 0)},[i,o]),z=c.useCallback(async()=>{const r=i.filter(l=>l.isEditing&&l.medicine_name);if(r.length!==0)try{await R?.(r)&&r.forEach(I=>{o?.({...I,isEditing:!1})})}catch(l){console.error("Bulk save failed",l)}finally{F?.(!1)}},[i,R,o,F]);c.useEffect(()=>{D&&z()},[D,z]),c.useEffect(()=>{const r=i.some(l=>l.isEditing);F?.(r)},[i,F]);const a=c.useCallback(r=>{C(r),N(!0)},[]),m=c.useCallback(async()=>{if(O)try{await w?.(O)}catch(r){console.error("Delete failed",r)}finally{n(null)}},[O,w]),x=c.useCallback(()=>{n(null)},[]),f=c.useCallback(async r=>{try{return await R?.([r])?(o?.({...r,isEditing:!1}),!0):!1}catch(l){return console.error("Save row failed",l),!1}},[R,o]),T=c.useCallback(async()=>{const r=i.filter(l=>l.isEditing&&l.medicine_name);if(r.length===0)return!0;try{const l=await R?.(r);return l&&i.map(y=>y.isEditing?{...y,isEditing:!1}:y).forEach(y=>o?.(y)),!!l}catch(l){return console.error("External bulk save failed",l),!1}},[i,R,o]);c.useImperativeHandle(W,()=>({triggerExternalSave:T}));const v={variant:s,externallyTriggeredEditMode:_,externallyTriggeredEditRowIds:j,getMedicineOptions:E,onRowChange:(r,l)=>{K(r.rowId,r,l),o?.(r,l)},onRowDelete:w,onRowCopy:L,setRowToDelete:n,openPopupForRow:a};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-border-1 hfl-border-Gray-200",children:[e.jsxRuntimeExports.jsx("div",{className:"table-header hfl-grid hfl-grid-cols-[1.36fr_1.36fr_1.02fr_1.25fr_2.27fr_1.36fr_1.36fr] hfl-gap-2 hfl-py-2 hfl-px-2 hfl-font-bold hfl-border-b-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50",children:k.C_Table_Column_Name.map(r=>e.jsxRuntimeExports.jsx(e.bs,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600",children:r},r))}),e.jsxRuntimeExports.jsxs(le.Provider,{value:v,children:[e.jsxRuntimeExports.jsx("div",{className:"table-body",children:i.length===0?e.jsxRuntimeExports.jsx(e.bs,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600 hfl-px-2 hfl-py-3",children:"No medicines added"}):i.map(r=>e.jsxRuntimeExports.jsx(de,{rowData:r,isEditing:r.isEditing||!1,setIsEditing:l=>K(r.rowId,{isEditing:l}),onSaveRow:f,allowCustomMedicineInput:b},r.rowId))}),e.jsxRuntimeExports.jsx(se.AlertPopup,{headingText:"Delete Medicine",subHeadingText:"Are you sure you want to delete this medicine?",openState:!!O,positiveButtonText:"Delete",negativeButtonText:"Cancel",positiveActionCallback:m,negativeActionCallback:x,classNameNegativeBtn:"hfl-bg-Blue-600",classNamePositiveBtn:"hfl-bg-Error-500 hover:hfl-bg-Error-700 hfl-text-White",closePopupCallback:x}),e.jsxRuntimeExports.jsx(fe,{open:d,onCancel:()=>N(!1),onCopySave:L,rowMedicineData:M,getMedicineOptions:E})]})]})});exports.PediatricsCalculatorTable=xe;
@@ -1,4 +1,4 @@
1
- import { j as e, Y as f } from "../index-C5JVupKG.js";
1
+ import { j as e, K as f } from "../index-4whwJbrk.js";
2
2
  function n(r) {
3
3
  const { options: h, selectedOption: a, onChangeHandler: s } = r;
4
4
  return /* @__PURE__ */ e.jsx("div", { className: "hfl-flex hfl-gap-2 hfl-h-full hfl-items-center hfl-px-4 hfl-justify-center hfl-py-1", children: h?.map((l) => /* @__PURE__ */ e.jsx("div", { className: "hfl-bg-White hfl-rounded-lg", children: /* @__PURE__ */ e.jsx(
@@ -1,4 +1,4 @@
1
- import { g as X } from "./index-C5JVupKG.js";
1
+ import { g as X } from "./index-4whwJbrk.js";
2
2
  function P(l) {
3
3
  var g, y, f = "";
4
4
  if (typeof l == "string" || typeof l == "number") f += l;