@tellescope/react-components 1.234.1 → 1.235.1

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.
Files changed (46) hide show
  1. package/lib/cjs/CMS/ContentViewer.d.ts.map +1 -1
  2. package/lib/cjs/CMS/ContentViewer.js +26 -22
  3. package/lib/cjs/CMS/ContentViewer.js.map +1 -1
  4. package/lib/cjs/Forms/forms.d.ts.map +1 -1
  5. package/lib/cjs/Forms/forms.js +37 -35
  6. package/lib/cjs/Forms/forms.js.map +1 -1
  7. package/lib/cjs/Forms/forms.v2.d.ts.map +1 -1
  8. package/lib/cjs/Forms/forms.v2.js +37 -35
  9. package/lib/cjs/Forms/forms.v2.js.map +1 -1
  10. package/lib/cjs/Forms/inputs.d.ts +17 -2
  11. package/lib/cjs/Forms/inputs.d.ts.map +1 -1
  12. package/lib/cjs/Forms/inputs.js +429 -37
  13. package/lib/cjs/Forms/inputs.js.map +1 -1
  14. package/lib/cjs/Forms/inputs.v2.d.ts +3 -2
  15. package/lib/cjs/Forms/inputs.v2.d.ts.map +1 -1
  16. package/lib/cjs/Forms/inputs.v2.js +21 -294
  17. package/lib/cjs/Forms/inputs.v2.js.map +1 -1
  18. package/lib/cjs/Forms/types.d.ts +4 -0
  19. package/lib/cjs/Forms/types.d.ts.map +1 -1
  20. package/lib/esm/CMS/ContentViewer.d.ts.map +1 -1
  21. package/lib/esm/CMS/ContentViewer.js +27 -23
  22. package/lib/esm/CMS/ContentViewer.js.map +1 -1
  23. package/lib/esm/Forms/forms.d.ts.map +1 -1
  24. package/lib/esm/Forms/forms.js +38 -36
  25. package/lib/esm/Forms/forms.js.map +1 -1
  26. package/lib/esm/Forms/forms.v2.d.ts.map +1 -1
  27. package/lib/esm/Forms/forms.v2.js +38 -36
  28. package/lib/esm/Forms/forms.v2.js.map +1 -1
  29. package/lib/esm/Forms/inputs.d.ts +17 -2
  30. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  31. package/lib/esm/Forms/inputs.js +427 -38
  32. package/lib/esm/Forms/inputs.js.map +1 -1
  33. package/lib/esm/Forms/inputs.v2.d.ts +3 -2
  34. package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
  35. package/lib/esm/Forms/inputs.v2.js +16 -290
  36. package/lib/esm/Forms/inputs.v2.js.map +1 -1
  37. package/lib/esm/Forms/types.d.ts +4 -0
  38. package/lib/esm/Forms/types.d.ts.map +1 -1
  39. package/lib/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +44 -44
  41. package/src/CMS/ContentViewer.tsx +16 -2
  42. package/src/Forms/forms.tsx +13 -6
  43. package/src/Forms/forms.v2.tsx +9 -2
  44. package/src/Forms/inputs.tsx +563 -66
  45. package/src/Forms/inputs.v2.tsx +13 -594
  46. package/src/Forms/types.ts +4 -2
@@ -72,9 +72,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
72
72
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
73
73
  import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
74
74
  import axios from "axios";
75
- import { Autocomplete, Box, Button, Checkbox, Chip, CircularProgress, Collapse, Divider, FormControl, FormControlLabel, FormLabel, Grid, IconButton as MuiIconButton, InputLabel, MenuItem, Radio, RadioGroup, Select, TextField, Typography } from "@mui/material";
75
+ import { Autocomplete, Box, Button, Checkbox, Chip, CircularProgress, Collapse, Divider, FormControl, FormControlLabel, FormLabel, Grid, IconButton as MuiIconButton, InputLabel, MenuItem, Paper, Radio, RadioGroup, Select, TextField, Typography } from "@mui/material";
76
76
  import { useDropzone } from "react-dropzone";
77
- import { CANVAS_TITLE, EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants";
77
+ import { CANVAS_TITLE, BRIDGE_TITLE, EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants";
78
78
  import { MM_DD_YYYY_to_YYYY_MM_DD, capture_is_supported, downloadFile, emit_gtm_event, first_letter_capitalized, form_response_value_to_string, format_stripe_subscription_interval, getLocalTimezone, getPublicFileURL, mm_dd_yyyy, object_is_empty, replace_enduser_template_values, responses_satisfy_conditions, truncate_string, update_local_storage, user_display_name } from "@tellescope/utilities";
79
79
  import { TIMEZONES_USA } from "@tellescope/types-models";
80
80
  import { VALID_STATES, emailValidator, phoneValidator } from "@tellescope/validation";
@@ -93,6 +93,14 @@ import { Elements, PaymentElement, useStripe, useElements, EmbeddedCheckout, Emb
93
93
  import { loadStripe } from '@stripe/stripe-js';
94
94
  import { CheckCircleOutline, Delete, Edit, ExpandMore } from "@mui/icons-material";
95
95
  import { WYSIWYG } from "./wysiwyg";
96
+ // Bridge Eligibility - shared variable for storing most recent eligibility userIds
97
+ var bridgeEligibilityResult = {
98
+ userIds: [],
99
+ };
100
+ export var getBridgeEligibilityUserIds = function () { return bridgeEligibilityResult.userIds; };
101
+ export var setBridgeEligibilityUserIds = function (userIds) {
102
+ bridgeEligibilityResult.userIds = userIds;
103
+ };
96
104
  // Debounce hook for search functionality
97
105
  var useDebounce = function (value, delay) {
98
106
  var _a = useState(value), debouncedValue = _a[0], setDebouncedValue = _a[1];
@@ -245,8 +253,14 @@ export var TableInput = function (_a) {
245
253
  : null }), v.label));
246
254
  }), _jsx(Grid, __assign({ item: true, sx: { ml: 'auto', width: iconWidth } }, { children: _jsx(LabeledIconButton, { Icon: CancelIcon, label: "Remove", onClick: function () { return handleRemove(i); }, disabled: !field.isOptional && value.length === 1 }) }))] }), i), _jsx(Divider, { flexItem: true, sx: { my: 1 } })] })); }), _jsx(Button, __assign({ variant: "outlined", size: "small", onClick: handleNewRow, sx: { width: 200 } }, { children: "Add new entry" }))] })));
247
255
  };
248
- export var AutoFocusTextField = function (props) { return (_jsx(TextField, __assign({ InputProps: defaultInputProps }, props))); };
249
- var CustomDateStringInput = forwardRef(function (props, ref) { return (_jsx(TextField, __assign({ InputProps: defaultInputProps, fullWidth: true, inputRef: ref }, props))); });
256
+ export var AutoFocusTextField = function (props) {
257
+ var inputProps = props.inputProps, textFieldProps = __rest(props, ["inputProps"]);
258
+ return _jsx(TextField, __assign({ InputProps: inputProps || defaultInputProps }, textFieldProps));
259
+ };
260
+ var CustomDateStringInput = forwardRef(function (props, ref) {
261
+ var inputProps = props.inputProps, textFieldProps = __rest(props, ["inputProps"]);
262
+ return (_jsx(TextField, __assign({ InputProps: inputProps || defaultInputProps, fullWidth: true, inputRef: ref }, textFieldProps)));
263
+ });
250
264
  export var DateStringInput = function (_a) {
251
265
  var _b;
252
266
  var field = _a.field, value = _a.value, onChange = _a.onChange, props = __rest(_a, ["field", "value", "onChange"]);
@@ -328,7 +342,7 @@ export var NumberInput = function (_a) {
328
342
  };
329
343
  export var InsuranceInput = function (_a) {
330
344
  var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
331
- var field = _a.field, onDatabaseSelect = _a.onDatabaseSelect, value = _a.value, onChange = _a.onChange, form = _a.form, responses = _a.responses, enduser = _a.enduser, props = __rest(_a, ["field", "onDatabaseSelect", "value", "onChange", "form", "responses", "enduser"]);
345
+ var field = _a.field, onDatabaseSelect = _a.onDatabaseSelect, value = _a.value, onChange = _a.onChange, form = _a.form, responses = _a.responses, enduser = _a.enduser, inputProps = _a.inputProps, props = __rest(_a, ["field", "onDatabaseSelect", "value", "onChange", "form", "responses", "enduser", "inputProps"]);
332
346
  var session = useResolvedSession();
333
347
  var _t = useState([]), payers = _t[0], setPayers = _t[1];
334
348
  var _u = useState(''), query = _u[0], setQuery = _u[1];
@@ -347,11 +361,14 @@ export var InsuranceInput = function (_a) {
347
361
  var _a, _b, _d;
348
362
  return ((((_a = addressQuestion === null || addressQuestion === void 0 ? void 0 : addressQuestion.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Address' ? (_d = (_b = addressQuestion === null || addressQuestion === void 0 ? void 0 : addressQuestion.answer) === null || _b === void 0 ? void 0 : _b.value) === null || _d === void 0 ? void 0 : _d.state : undefined) || (enduser === null || enduser === void 0 ? void 0 : enduser.state));
349
363
  }, [enduser === null || enduser === void 0 ? void 0 : enduser.state, addressQuestion]);
364
+ // load from database
350
365
  var loadRef = useRef(false); // so session changes don't cause
351
366
  useEffect(function () {
352
- var _a;
367
+ var _a, _b;
353
368
  if (((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === CANVAS_TITLE)
354
369
  return; // instead, look-up while typing against Canvas Search API
370
+ if (((_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === BRIDGE_TITLE)
371
+ return; // instead, look-up while typing against Bridge Search API
355
372
  if (loadRef.current)
356
373
  return;
357
374
  loadRef.current = true;
@@ -374,10 +391,11 @@ export var InsuranceInput = function (_a) {
374
391
  })
375
392
  .catch(console.error);
376
393
  }, [session, state, (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource]);
394
+ // load from 3rd-party on search only
377
395
  var searchRef = useRef(query);
378
396
  useEffect(function () {
379
- var _a;
380
- if (((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) !== CANVAS_TITLE) {
397
+ var _a, _b, _d, _e;
398
+ if (((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) !== CANVAS_TITLE && ((_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource) !== BRIDGE_TITLE) {
381
399
  return;
382
400
  }
383
401
  if (!query)
@@ -385,24 +403,30 @@ export var InsuranceInput = function (_a) {
385
403
  if (searchRef.current === query)
386
404
  return;
387
405
  searchRef.current = query;
388
- session.api.integrations.proxy_read({
389
- integration: CANVAS_TITLE,
406
+ var integration = ((_d = field === null || field === void 0 ? void 0 : field.options) === null || _d === void 0 ? void 0 : _d.dataSource) === CANVAS_TITLE ? CANVAS_TITLE : BRIDGE_TITLE;
407
+ var type = ((_e = field === null || field === void 0 ? void 0 : field.options) === null || _e === void 0 ? void 0 : _e.dataSource) === CANVAS_TITLE ? 'organizations' : 'payers';
408
+ var t = setTimeout(function () { return (session.api.integrations.proxy_read({
409
+ integration: integration,
390
410
  query: query,
391
- type: 'organizations',
411
+ type: type,
392
412
  })
393
413
  .then(function (_a) {
394
414
  var data = _a.data;
395
415
  try {
396
- setPayers(data.map(function (d) { return ({
397
- id: d.resource.id,
398
- name: d.resource.name,
399
- }); }));
416
+ setPayers(data.map(function (d) {
417
+ var _a, _b;
418
+ return ({
419
+ id: ((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === CANVAS_TITLE ? d.resource.id : d.id,
420
+ name: ((_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === CANVAS_TITLE ? d.resource.name : d.name,
421
+ });
422
+ }));
400
423
  }
401
424
  catch (err) {
402
425
  console.error;
403
426
  }
404
427
  })
405
- .catch(console.error);
428
+ .catch(console.error)); }, 300);
429
+ return function () { clearTimeout(t); };
406
430
  }, [session, (_d = field === null || field === void 0 ? void 0 : field.options) === null || _d === void 0 ? void 0 : _d.dataSource, query]);
407
431
  return (_jsxs(Grid, __assign({ container: true, spacing: 2, sx: { mt: '0' } }, { children: [_jsx(Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: _jsx(Autocomplete, { freeSolo: !((_e = field.options) === null || _e === void 0 ? void 0 : _e.requirePredefinedInsurer), options: payers.map(function (p) { return p.name; }), value: (value === null || value === void 0 ? void 0 : value.payerName) || '', onChange: function (e, v) {
408
432
  var _a, _b;
@@ -420,36 +444,393 @@ export var InsuranceInput = function (_a) {
420
444
  if (databaseRecord) {
421
445
  onDatabaseSelect === null || onDatabaseSelect === void 0 ? void 0 : onDatabaseSelect([databaseRecord]);
422
446
  }
423
- onChange(__assign(__assign({}, value), { payerName: v || '', payerId: ((_b = payers.find(function (p) { return p.name === v; })) === null || _b === void 0 ? void 0 : _b.id) || '', payerType: ((_d = payers.find(function (p) { return p.name === v; })) === null || _d === void 0 ? void 0 : _d.type) || '' }), field.id);
447
+ // don't lose existing payerId on back-and-forth navigation
448
+ onChange(__assign(__assign({}, value), { payerName: v || '', payerId: ((value === null || value === void 0 ? void 0 : value.payerName) === v && (value === null || value === void 0 ? void 0 : value.payerId) ? value.payerId : '') || ((_b = payers.find(function (p) { return p.name === v; })) === null || _b === void 0 ? void 0 : _b.id) || '', payerType: ((_d = payers.find(function (p) { return p.name === v; })) === null || _d === void 0 ? void 0 : _d.type) || '' }), field.id);
424
449
  }, renderInput: function (params) {
425
- var _a;
426
- return (_jsx(TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: defaultInputProps.sx }), required: !field.isOptional, size: "small", label: "Insurer", placeholder: ((_a = field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === CANVAS_TITLE ? "Search insurer..." : "Insurer" })));
427
- } }) })), _jsx(Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: _jsx(TextField, { InputProps: defaultInputProps, required: !field.isOptional, fullWidth: true, value: (_g = value === null || value === void 0 ? void 0 : value.memberId) !== null && _g !== void 0 ? _g : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { memberId: e.target.value }), field.id); }, label: form_display_text_for_language(form, "Member ID", ''), size: "small" }) })), _jsx(Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: _jsx(TextField, { InputProps: defaultInputProps, required: false, fullWidth: true, value: (_h = value === null || value === void 0 ? void 0 : value.planName) !== null && _h !== void 0 ? _h : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { planName: e.target.value }), field.id); }, label: form_display_text_for_language(form, "Plan Name", ''), size: "small" }) })), _jsx(Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: _jsx(DateStringInput, { size: "small", label: "Plan Start Date", field: __assign(__assign({}, field), { isOptional: true }), value: (value === null || value === void 0 ? void 0 : value.startDate) || '', onChange: function (startDate) {
450
+ var _a, _b;
451
+ return (_jsx(TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: (inputProps || defaultInputProps).sx }), required: !field.isOptional, size: "small", label: "Insurer", placeholder: (((_a = field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === CANVAS_TITLE || ((_b = field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === BRIDGE_TITLE) ? "Search insurer..." : "Insurer" })));
452
+ } }) })), _jsx(Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: _jsx(TextField, { InputProps: inputProps || defaultInputProps, required: !field.isOptional, fullWidth: true, value: (_g = value === null || value === void 0 ? void 0 : value.memberId) !== null && _g !== void 0 ? _g : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { memberId: e.target.value }), field.id); }, label: form_display_text_for_language(form, "Member ID", ''), size: "small" }) })), _jsx(Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: _jsx(TextField, { InputProps: inputProps || defaultInputProps, required: false, fullWidth: true, value: (_h = value === null || value === void 0 ? void 0 : value.planName) !== null && _h !== void 0 ? _h : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { planName: e.target.value }), field.id); }, label: form_display_text_for_language(form, "Plan Name", ''), size: "small" }) })), _jsx(Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: _jsx(DateStringInput, { size: "small", label: "Plan Start Date", inputProps: inputProps, field: __assign(__assign({}, field), { isOptional: true }), value: (value === null || value === void 0 ? void 0 : value.startDate) || '', onChange: function (startDate) {
428
453
  return onChange(__assign(__assign({}, value), { startDate: startDate }), field.id);
429
454
  } }) })), ((_j = field.options) === null || _j === void 0 ? void 0 : _j.includeGroupNumber) &&
430
- _jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(TextField, { InputProps: defaultInputProps, fullWidth: true, value: (_k = value === null || value === void 0 ? void 0 : value.groupNumber) !== null && _k !== void 0 ? _k : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { groupNumber: e.target.value }), field.id); }, label: form_display_text_for_language(form, "Group Number", ''), size: "small" }) })), _jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(StringSelector, { size: "small", label: "Relationship to Policy Owner", options: ((((_l = field.options) === null || _l === void 0 ? void 0 : _l.billingProvider) === CANVAS_TITLE || ((_m = field.options) === null || _m === void 0 ? void 0 : _m.dataSource) === CANVAS_TITLE)
455
+ _jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(TextField, { InputProps: inputProps || defaultInputProps, fullWidth: true, value: (_k = value === null || value === void 0 ? void 0 : value.groupNumber) !== null && _k !== void 0 ? _k : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { groupNumber: e.target.value }), field.id); }, label: form_display_text_for_language(form, "Group Number", ''), size: "small" }) })), _jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(StringSelector, { size: "small", label: "Relationship to Policy Owner", inputProps: inputProps, options: ((((_l = field.options) === null || _l === void 0 ? void 0 : _l.billingProvider) === CANVAS_TITLE || ((_m = field.options) === null || _m === void 0 ? void 0 : _m.dataSource) === CANVAS_TITLE)
431
456
  ? INSURANCE_RELATIONSHIPS_CANVAS
432
457
  : INSURANCE_RELATIONSHIPS)
433
458
  .sort(function (x, y) { return x.localeCompare(y); }), value: (value === null || value === void 0 ? void 0 : value.relationship) || 'Self', onChange: function (relationship) {
434
459
  return onChange(__assign(__assign({}, value), { relationship: relationship || 'Self' }), field.id);
435
460
  } }) })), ((value === null || value === void 0 ? void 0 : value.relationship) || 'Self') !== 'Self' &&
436
- _jsxs(_Fragment, { children: [_jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(Typography, __assign({ sx: { fontWeight: 'bold' } }, { children: "Policy Owner Details" })) })), _jsx(Grid, __assign({ item: true, xs: 6 }, { children: _jsx(TextField, { label: "First Name", size: "small", InputProps: defaultInputProps, fullWidth: true, value: ((_o = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _o === void 0 ? void 0 : _o.fname) || '', required: !field.isOptional, onChange: function (e) {
461
+ _jsxs(_Fragment, { children: [_jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(Typography, __assign({ sx: { fontWeight: 'bold' } }, { children: "Policy Owner Details" })) })), _jsx(Grid, __assign({ item: true, xs: 6 }, { children: _jsx(TextField, { label: "First Name", size: "small", InputProps: inputProps || defaultInputProps, fullWidth: true, value: ((_o = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _o === void 0 ? void 0 : _o.fname) || '', required: !field.isOptional, onChange: function (e) {
437
462
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { fname: e.target.value }) }), field.id);
438
- } }) })), _jsx(Grid, __assign({ item: true, xs: 6 }, { children: _jsx(TextField, { label: "Last Name", size: "small", InputProps: defaultInputProps, fullWidth: true, value: ((_p = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _p === void 0 ? void 0 : _p.lname) || '', required: !field.isOptional, onChange: function (e) {
463
+ } }) })), _jsx(Grid, __assign({ item: true, xs: 6 }, { children: _jsx(TextField, { label: "Last Name", size: "small", InputProps: inputProps || defaultInputProps, fullWidth: true, value: ((_p = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _p === void 0 ? void 0 : _p.lname) || '', required: !field.isOptional, onChange: function (e) {
439
464
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { lname: e.target.value }) }), field.id);
440
- } }) })), _jsx(Grid, __assign({ item: true, xs: 6 }, { children: _jsx(StringSelector, { options: TELLESCOPE_GENDERS, size: "small", label: "Gender", value: ((_q = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _q === void 0 ? void 0 : _q.gender) || '', required: !field.isOptional, onChange: function (v) {
465
+ } }) })), _jsx(Grid, __assign({ item: true, xs: 6 }, { children: _jsx(StringSelector, { options: TELLESCOPE_GENDERS, size: "small", label: "Gender", inputProps: inputProps, value: ((_q = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _q === void 0 ? void 0 : _q.gender) || '', required: !field.isOptional, onChange: function (v) {
441
466
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { gender: v }) }), field.id);
442
- } }) })), _jsx(Grid, __assign({ item: true, xs: 6 }, { children: _jsx(DateStringInput, { size: "small", label: "Date of Birth", field: __assign(__assign({}, field), { isOptional: field.isOptional || ((_r = field.options) === null || _r === void 0 ? void 0 : _r.billingProvider) === 'Candid' }), value: ((_s = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _s === void 0 ? void 0 : _s.dateOfBirth) || '', onChange: function (dateOfBirth) {
467
+ } }) })), _jsx(Grid, __assign({ item: true, xs: 6 }, { children: _jsx(DateStringInput, { size: "small", label: "Date of Birth", inputProps: inputProps, field: __assign(__assign({}, field), { isOptional: field.isOptional || ((_r = field.options) === null || _r === void 0 ? void 0 : _r.billingProvider) === 'Candid' }), value: ((_s = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _s === void 0 ? void 0 : _s.dateOfBirth) || '', onChange: function (dateOfBirth) {
443
468
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { dateOfBirth: dateOfBirth }) }), field.id);
444
469
  } }) }))] })] })));
445
470
  };
446
471
  var StringSelector = function (_a) {
447
- var options = _a.options, value = _a.value, onChange = _a.onChange, required = _a.required, getDisplayValue = _a.getDisplayValue, props = __rest(_a, ["options", "value", "onChange", "required", "getDisplayValue"]);
448
- return (_jsxs(FormControl, __assign({ fullWidth: true, size: props.size, required: required }, { children: [_jsx(InputLabel, { children: props.label }), _jsx(Select, __assign({}, props, { value: value, onChange: function (e) { return onChange(e.target.value); }, fullWidth: true, sx: defaultInputProps.sx }, { children: options.map(function (o, i) {
472
+ var options = _a.options, value = _a.value, onChange = _a.onChange, required = _a.required, getDisplayValue = _a.getDisplayValue, inputProps = _a.inputProps, props = __rest(_a, ["options", "value", "onChange", "required", "getDisplayValue", "inputProps"]);
473
+ return (_jsxs(FormControl, __assign({ fullWidth: true, size: props.size, required: required }, { children: [_jsx(InputLabel, { children: props.label }), _jsx(Select, __assign({}, props, { value: value, onChange: function (e) { return onChange(e.target.value); }, fullWidth: true, sx: (inputProps || defaultInputProps).sx }, { children: options.map(function (o, i) {
449
474
  var _a;
450
475
  return (_jsx(MenuItem, __assign({ value: o }, { children: (_a = getDisplayValue === null || getDisplayValue === void 0 ? void 0 : getDisplayValue(o)) !== null && _a !== void 0 ? _a : o }), o || i));
451
476
  }) }))] })));
452
477
  };
478
+ export var BridgeEligibilityInput = function (_a) {
479
+ var _b, _d, _e, _f, _g, _h, _j;
480
+ var field = _a.field, value = _a.value, onChange = _a.onChange, responses = _a.responses, enduser = _a.enduser, inputProps = _a.inputProps, enduserId = _a.enduserId, props = __rest(_a, ["field", "value", "onChange", "responses", "enduser", "inputProps", "enduserId"]);
481
+ var session = useResolvedSession();
482
+ var _k = useState(false), loading = _k[0], setLoading = _k[1];
483
+ var _l = useState(false), polling = _l[0], setPolling = _l[1];
484
+ var _m = useState(), error = _m[0], setError = _m[1];
485
+ // single-page form must require button-click to check, but 1-page-at-a-time enduser sessions should auto-check
486
+ var isEnduserSession = session.type === 'enduser';
487
+ var eligibilityType = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.bridgeEligibilityType) || 'Soft';
488
+ // Extract payerId from Insurance question response
489
+ var _o = useMemo(function () {
490
+ var _a, _b, _d, _e;
491
+ var insuranceResponse = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { var _a, _b, _d; return ((_a = r.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance' && ((_d = (_b = r.answer) === null || _b === void 0 ? void 0 : _b.value) === null || _d === void 0 ? void 0 : _d.payerId); });
492
+ if (((_a = insuranceResponse === null || insuranceResponse === void 0 ? void 0 : insuranceResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance') {
493
+ return [
494
+ (_b = insuranceResponse.answer.value) === null || _b === void 0 ? void 0 : _b.payerId,
495
+ (_d = insuranceResponse.answer.value) === null || _d === void 0 ? void 0 : _d.memberId,
496
+ (_e = insuranceResponse.answer.value) === null || _e === void 0 ? void 0 : _e.payerName,
497
+ ];
498
+ }
499
+ // existing payer id is automatically resolved on the backend as default
500
+ return [];
501
+ }, [responses]), payerId = _o[0], memberId = _o[1], payerName = _o[2];
502
+ // Extract state from Address question or enduser
503
+ var state = useMemo(function () {
504
+ var _a, _b;
505
+ // Find Address field with state value
506
+ var addressResponse = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { var _a, _b, _d; return ((_a = r.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Address' && ((_d = (_b = r.answer) === null || _b === void 0 ? void 0 : _b.value) === null || _d === void 0 ? void 0 : _d.state); });
507
+ if (((_a = addressResponse === null || addressResponse === void 0 ? void 0 : addressResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Address') {
508
+ return (_b = addressResponse.answer.value) === null || _b === void 0 ? void 0 : _b.state;
509
+ }
510
+ // enduser state is automatically resolved on the backend as default
511
+ }, [responses]);
512
+ // Soft eligibility check function - supports multiple service type IDs
513
+ var checkProviderEligibility = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
514
+ var serviceTypeIds, results, allUserIds, uniqueUserIds, aggregatedStatus, err_1;
515
+ var _a, _b;
516
+ return __generator(this, function (_d) {
517
+ switch (_d.label) {
518
+ case 0:
519
+ serviceTypeIds = (_a = field.options) === null || _a === void 0 ? void 0 : _a.bridgeServiceTypeIds;
520
+ if (!serviceTypeIds || serviceTypeIds.length === 0) {
521
+ setError('Bridge Service Type IDs not configured');
522
+ return [2 /*return*/];
523
+ }
524
+ // payerId and state can be automatically resolved on the backend, if already saved on Enduser, so not required here
525
+ setLoading(true);
526
+ setError(undefined);
527
+ _d.label = 1;
528
+ case 1:
529
+ _d.trys.push([1, 3, 4, 5]);
530
+ return [4 /*yield*/, Promise.all(serviceTypeIds.map(function (serviceTypeId) { return __awaiter(void 0, void 0, void 0, function () {
531
+ var data, err_2;
532
+ return __generator(this, function (_a) {
533
+ switch (_a.label) {
534
+ case 0:
535
+ _a.trys.push([0, 2, , 3]);
536
+ return [4 /*yield*/, session.api.integrations.proxy_read({
537
+ id: enduserId,
538
+ integration: BRIDGE_TITLE,
539
+ type: 'provider-eligibility',
540
+ query: JSON.stringify({
541
+ serviceTypeId: serviceTypeId,
542
+ payerId: payerId,
543
+ state: state,
544
+ }),
545
+ })];
546
+ case 1:
547
+ data = (_a.sent()).data;
548
+ return [2 /*return*/, {
549
+ serviceTypeId: serviceTypeId,
550
+ status: (data === null || data === void 0 ? void 0 : data.status) || 'unknown',
551
+ userIds: (data === null || data === void 0 ? void 0 : data.userIds) || [],
552
+ }];
553
+ case 2:
554
+ err_2 = _a.sent();
555
+ console.error("Provider eligibility check failed for ".concat(serviceTypeId, ":"), err_2);
556
+ return [2 /*return*/, {
557
+ serviceTypeId: serviceTypeId,
558
+ status: 'error',
559
+ userIds: [],
560
+ error: err_2 === null || err_2 === void 0 ? void 0 : err_2.message,
561
+ }];
562
+ case 3: return [2 /*return*/];
563
+ }
564
+ });
565
+ }); }))
566
+ // Aggregate results - union of userIds across all service types
567
+ ];
568
+ case 2:
569
+ results = _d.sent();
570
+ allUserIds = results.flatMap(function (r) { return r.userIds; });
571
+ uniqueUserIds = Array.from(new Set(allUserIds));
572
+ aggregatedStatus = results.some(function (r) { return r.status === 'ELIGIBLE'; })
573
+ ? 'ELIGIBLE'
574
+ : ((_b = results.find(function (r) { return r.status !== 'error'; })) === null || _b === void 0 ? void 0 : _b.status) || 'unknown';
575
+ // Store aggregated userIds in shared variable for Appointment Booking to use
576
+ setBridgeEligibilityUserIds(uniqueUserIds);
577
+ // Update the answer with aggregated results
578
+ onChange({
579
+ payerId: payerId,
580
+ status: aggregatedStatus,
581
+ userIds: uniqueUserIds,
582
+ }, field.id);
583
+ return [3 /*break*/, 5];
584
+ case 3:
585
+ err_1 = _d.sent();
586
+ setError((err_1 === null || err_1 === void 0 ? void 0 : err_1.message) || 'Failed to check eligibility');
587
+ console.error('Provider eligibility check failed:', err_1);
588
+ return [3 /*break*/, 5];
589
+ case 4:
590
+ setLoading(false);
591
+ return [7 /*endfinally*/];
592
+ case 5: return [2 /*return*/];
593
+ }
594
+ });
595
+ }); }, [session, field, payerId, state, onChange, enduserId]);
596
+ // Hard eligibility check function with polling - supports multiple service type IDs
597
+ var checkServiceEligibility = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
598
+ var serviceTypeIds, initiatedChecks_1, pollForAllResults, err_3;
599
+ var _a;
600
+ return __generator(this, function (_b) {
601
+ switch (_b.label) {
602
+ case 0:
603
+ serviceTypeIds = (_a = field.options) === null || _a === void 0 ? void 0 : _a.bridgeServiceTypeIds;
604
+ if (!serviceTypeIds || serviceTypeIds.length === 0) {
605
+ setError('Bridge Service Type IDs not configured');
606
+ return [2 /*return*/];
607
+ }
608
+ setLoading(true);
609
+ setError(undefined);
610
+ _b.label = 1;
611
+ case 1:
612
+ _b.trys.push([1, 3, , 4]);
613
+ return [4 /*yield*/, Promise.all(serviceTypeIds.map(function (serviceTypeId) { return __awaiter(void 0, void 0, void 0, function () {
614
+ var data, serviceEligibilityId, err_4;
615
+ return __generator(this, function (_a) {
616
+ switch (_a.label) {
617
+ case 0:
618
+ _a.trys.push([0, 2, , 3]);
619
+ return [4 /*yield*/, session.api.integrations.proxy_read({
620
+ id: enduserId,
621
+ integration: BRIDGE_TITLE,
622
+ type: 'service-eligibility',
623
+ query: JSON.stringify({
624
+ serviceTypeId: serviceTypeId,
625
+ payerId: payerId,
626
+ memberId: memberId,
627
+ state: state,
628
+ }),
629
+ })];
630
+ case 1:
631
+ data = (_a.sent()).data;
632
+ serviceEligibilityId = data === null || data === void 0 ? void 0 : data.id;
633
+ if (!serviceEligibilityId) {
634
+ throw new Error('No service eligibility ID returned');
635
+ }
636
+ return [2 /*return*/, {
637
+ serviceTypeId: serviceTypeId,
638
+ serviceEligibilityId: serviceEligibilityId,
639
+ error: undefined,
640
+ }];
641
+ case 2:
642
+ err_4 = _a.sent();
643
+ console.error("Service eligibility check initiation failed for ".concat(serviceTypeId, ":"), err_4);
644
+ return [2 /*return*/, {
645
+ serviceTypeId: serviceTypeId,
646
+ serviceEligibilityId: null,
647
+ error: err_4 === null || err_4 === void 0 ? void 0 : err_4.message,
648
+ }];
649
+ case 3: return [2 /*return*/];
650
+ }
651
+ });
652
+ }); }))];
653
+ case 2:
654
+ initiatedChecks_1 = _b.sent();
655
+ setLoading(false);
656
+ setPolling(true);
657
+ pollForAllResults = function () { return __awaiter(void 0, void 0, void 0, function () {
658
+ var maxAttempts, checkStatuses, attempts, pollAll;
659
+ return __generator(this, function (_a) {
660
+ maxAttempts = 60 // Poll for up to 60 attempts (2 minutes at 2s intervals)
661
+ ;
662
+ checkStatuses = new Map(initiatedChecks_1.map(function (check) { return [
663
+ check.serviceTypeId,
664
+ {
665
+ completed: check.error !== undefined || check.serviceEligibilityId === null,
666
+ result: check.error ? { status: 'error', userIds: [], error: check.error } : null,
667
+ serviceEligibilityId: check.serviceEligibilityId,
668
+ }
669
+ ]; }));
670
+ attempts = 0;
671
+ pollAll = function () { return __awaiter(void 0, void 0, void 0, function () {
672
+ var pollPromises, allCompleted, results, allUserIds, uniqueUserIds, aggregatedStatus;
673
+ var _a;
674
+ return __generator(this, function (_b) {
675
+ switch (_b.label) {
676
+ case 0:
677
+ if (attempts >= maxAttempts) {
678
+ setError('Eligibility check timed out. Please try again.');
679
+ setPolling(false);
680
+ return [2 /*return*/];
681
+ }
682
+ attempts++;
683
+ pollPromises = initiatedChecks_1
684
+ .filter(function (check) {
685
+ var status = checkStatuses.get(check.serviceTypeId);
686
+ return check.serviceEligibilityId && status && !status.completed;
687
+ })
688
+ .map(function (check) { return __awaiter(void 0, void 0, void 0, function () {
689
+ var pollData, status_1, checkStatus, err_5, checkStatus;
690
+ return __generator(this, function (_a) {
691
+ switch (_a.label) {
692
+ case 0:
693
+ _a.trys.push([0, 2, , 3]);
694
+ return [4 /*yield*/, session.api.integrations.proxy_read({
695
+ id: check.serviceEligibilityId,
696
+ integration: BRIDGE_TITLE,
697
+ type: 'service-eligibility-poll',
698
+ })];
699
+ case 1:
700
+ pollData = (_a.sent()).data;
701
+ status_1 = pollData === null || pollData === void 0 ? void 0 : pollData.status;
702
+ // Check if we're in a terminal state
703
+ if (status_1 && status_1 !== 'PENDING') {
704
+ checkStatus = checkStatuses.get(check.serviceTypeId);
705
+ checkStatus.completed = true;
706
+ checkStatus.result = {
707
+ status: status_1 || 'unknown',
708
+ userIds: (pollData === null || pollData === void 0 ? void 0 : pollData.userIds) || [],
709
+ error: undefined,
710
+ };
711
+ }
712
+ return [3 /*break*/, 3];
713
+ case 2:
714
+ err_5 = _a.sent();
715
+ console.error("Service eligibility polling failed for ".concat(check.serviceTypeId, ":"), err_5);
716
+ checkStatus = checkStatuses.get(check.serviceTypeId);
717
+ checkStatus.completed = true;
718
+ checkStatus.result = {
719
+ status: 'error',
720
+ userIds: [],
721
+ error: err_5 === null || err_5 === void 0 ? void 0 : err_5.message,
722
+ };
723
+ return [3 /*break*/, 3];
724
+ case 3: return [2 /*return*/];
725
+ }
726
+ });
727
+ }); });
728
+ return [4 /*yield*/, Promise.all(pollPromises)
729
+ // Check if all checks are completed
730
+ ];
731
+ case 1:
732
+ _b.sent();
733
+ allCompleted = Array.from(checkStatuses.values()).every(function (s) { return s.completed; });
734
+ if (allCompleted) {
735
+ results = Array.from(checkStatuses.entries()).map(function (_a) {
736
+ var _b, _d;
737
+ var serviceTypeId = _a[0], status = _a[1];
738
+ return ({
739
+ serviceTypeId: serviceTypeId,
740
+ status: ((_b = status.result) === null || _b === void 0 ? void 0 : _b.status) || 'unknown',
741
+ userIds: ((_d = status.result) === null || _d === void 0 ? void 0 : _d.userIds) || [],
742
+ });
743
+ });
744
+ allUserIds = results.flatMap(function (r) { return r.userIds; });
745
+ uniqueUserIds = Array.from(new Set(allUserIds));
746
+ aggregatedStatus = results.some(function (r) { return r.status === 'ELIGIBLE'; })
747
+ ? 'ELIGIBLE'
748
+ : ((_a = results.find(function (r) { return r.status !== 'error'; })) === null || _a === void 0 ? void 0 : _a.status) || 'unknown';
749
+ // Store aggregated userIds in shared variable for Appointment Booking to use
750
+ setBridgeEligibilityUserIds(uniqueUserIds);
751
+ // Update the answer with aggregated results
752
+ onChange({
753
+ payerId: payerId,
754
+ status: aggregatedStatus,
755
+ userIds: uniqueUserIds,
756
+ }, field.id);
757
+ setPolling(false);
758
+ return [2 /*return*/];
759
+ }
760
+ // Still have pending checks, poll again after delay
761
+ setTimeout(pollAll, 2000); // Poll every 2 seconds
762
+ return [2 /*return*/];
763
+ }
764
+ });
765
+ }); };
766
+ pollAll();
767
+ return [2 /*return*/];
768
+ });
769
+ }); };
770
+ pollForAllResults();
771
+ return [3 /*break*/, 4];
772
+ case 3:
773
+ err_3 = _b.sent();
774
+ setError((err_3 === null || err_3 === void 0 ? void 0 : err_3.message) || 'Failed to check service eligibility');
775
+ console.error('Service eligibility check failed:', err_3);
776
+ setLoading(false);
777
+ setPolling(false);
778
+ return [3 /*break*/, 4];
779
+ case 4: return [2 /*return*/];
780
+ }
781
+ });
782
+ }); }, [session, field, payerId, memberId, state, onChange, enduserId]);
783
+ // Auto-check eligibility for enduser sessions
784
+ var autoCheckRef = useRef(false);
785
+ useEffect(function () {
786
+ if (!isEnduserSession)
787
+ return;
788
+ // If we already have a result and the payer hasn't changed, use the cached result
789
+ if ((value === null || value === void 0 ? void 0 : value.status) && (value === null || value === void 0 ? void 0 : value.payerId) === payerId) {
790
+ return;
791
+ }
792
+ if (autoCheckRef.current)
793
+ return;
794
+ autoCheckRef.current = true;
795
+ if (eligibilityType === 'Hard') {
796
+ checkServiceEligibility();
797
+ }
798
+ else {
799
+ checkProviderEligibility();
800
+ }
801
+ }, [isEnduserSession, eligibilityType, checkProviderEligibility, checkServiceEligibility, value, payerId]);
802
+ var errorComponent = useMemo(function () { return (_jsx(Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center", style: { padding: '20px 0' } }, { children: _jsx(Grid, __assign({ item: true }, { children: _jsx(Paper, __assign({ style: {
803
+ padding: 16,
804
+ backgroundColor: '#ffebee',
805
+ border: '2px solid #f44336'
806
+ } }, { children: _jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "h2", style: { color: '#f44336' } }, { children: "\u26A0\uFE0F" })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "h6", align: "center", color: "error" }, { children: "Unable to Check Eligibility" })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body2", align: "center", style: { color: '#d32f2f' } }, { children: error })) }))] })) })) })) }))); }, [error]);
807
+ var checkingEligibilityComponent = useMemo(function () { return (_jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center", style: { padding: '20px 0' } }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(CircularProgress, { size: 40 }) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body1" }, { children: polling ? 'Verifying eligibility with insurance...' : 'Checking eligibility...' })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: polling ? 'This usually takes 15-30 seconds' : 'This may take a few moments' })) }))] }))); }, [polling]);
808
+ var resultsComponent = useMemo(function () {
809
+ var isEligible = (value === null || value === void 0 ? void 0 : value.status) === 'ELIGIBLE';
810
+ return (_jsx(Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: _jsx(Grid, __assign({ item: true }, { children: _jsx(Paper, __assign({ style: {
811
+ padding: 16,
812
+ backgroundColor: isEligible ? '#e8f5e9' : '#fff3e0',
813
+ border: "2px solid ".concat(isEligible ? '#4caf50' : '#ff9800')
814
+ } }, { children: _jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true }, { children: isEligible ? (_jsx(CheckCircleOutline, { style: { fontSize: 48, color: '#4caf50' } })) : (_jsx(Typography, __assign({ variant: "h2", style: { color: '#ff9800' } }, { children: "\u26A0\uFE0F" }))) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "h6", align: "center" }, { children: isEligible
815
+ ? "".concat(payerName || 'Your insurance provider', " is accepted!")
816
+ : 'Eligibility Status: ' + first_letter_capitalized(((value === null || value === void 0 ? void 0 : value.status) || 'Unknown').toLowerCase()) })) }))] })) })) })) })));
817
+ }, [value, payerName]);
818
+ // Loading/polling state for enduser sessions
819
+ if (isEnduserSession) {
820
+ if (loading || polling) {
821
+ return checkingEligibilityComponent;
822
+ }
823
+ if (error) {
824
+ return errorComponent;
825
+ }
826
+ if (value === null || value === void 0 ? void 0 : value.status) {
827
+ return resultsComponent;
828
+ }
829
+ return errorComponent;
830
+ }
831
+ // User/admin interface (non-enduser sessions)
832
+ return (_jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: [_jsxs(Grid, __assign({ item: true }, { children: [_jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Eligibility Type: ", eligibilityType] })), _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Service Type IDs: ", ((_e = (_d = field.options) === null || _d === void 0 ? void 0 : _d.bridgeServiceTypeIds) === null || _e === void 0 ? void 0 : _e.join(', ')) || 'Not configured'] })), state && _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["State: ", state] })), payerId && _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Payer ID: ", payerId] })), memberId && _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Member ID: ", memberId] }))] })), error && (_jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body2", color: "error" }, { children: error })) }))), polling && (_jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body2", color: "primary" }, { children: "Polling for results... (this may take 15-30 seconds)" })) }))), _jsxs(Grid, __assign({ item: true, container: true, spacing: 2 }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(LoadingButton, { variant: "outlined", onClick: checkProviderEligibility, submitText: "Check Provider Eligibility (Free)", submittingText: "Checking...", submitting: loading && !polling, disabled: !((_g = (_f = field.options) === null || _f === void 0 ? void 0 : _f.bridgeServiceTypeIds) === null || _g === void 0 ? void 0 : _g.length) || loading || polling }) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(LoadingButton, { variant: "outlined", onClick: checkServiceEligibility, submitText: "Check Service Eligibility (Paid)", submittingText: polling ? "Polling..." : "Initiating...", submitting: loading || polling, disabled: !((_j = (_h = field.options) === null || _h === void 0 ? void 0 : _h.bridgeServiceTypeIds) === null || _j === void 0 ? void 0 : _j.length) || loading || polling }) }))] })), value && (_jsxs(Grid, __assign({ item: true }, { children: [_jsx(Typography, __assign({ variant: "caption", color: "textSecondary" }, { children: "Current Answer:" })), _jsx("pre", __assign({ style: { fontSize: 11, whiteSpace: 'pre-wrap', wordBreak: 'break-word' } }, { children: JSON.stringify(value, null, 2) }))] })))] })));
833
+ };
453
834
  var HourSelector = function (props) { return (_jsx(StringSelector, __assign({}, props, { options: Array(12).fill('').map(function (_, i) { return (i + 1) <= 9 ? "0".concat(i + 1) : (i + 1).toString(); }) }))); };
454
835
  var MinuteSelector = function (props) { return (_jsx(StringSelector, __assign({}, props, { options: Array(60).fill('').map(function (_, i) { return i <= 9 ? "0".concat(i) : i.toString(); }) }))); };
455
836
  var AmPmSelector = function (props) { return (_jsx(StringSelector, __assign({}, props, { options: ['AM', 'PM'] }))); };
@@ -1824,17 +2205,17 @@ export var RelatedContactsInput = function (_a) {
1824
2205
  return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 1 }, { children: [_jsx(Grid, __assign({ item: true }, { children: value.map(function (contact, i) { return (_jsx(Grid, __assign({ item: true }, { children: _jsxs(Grid, __assign({ container: true, alignItems: "center", justifyContent: "space-between", wrap: "nowrap", spacing: 1 }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsxs(Grid, __assign({ container: true, alignItems: "center" }, { children: [_jsx(IconButton, __assign({ onClick: function () { return setEditing(i); }, color: "primary", size: "small" }, { children: _jsx(Edit, {}) })), _jsx(Typography, __assign({ noWrap: true }, { children: user_display_name(contact) || "Unnamed Contact ".concat(i + 1) }))] })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(LabeledIconButton, { Icon: Delete, label: "Remove", onClick: function () { return onChange(value.filter(function (v, _i) { return i !== _i; }), field.id); } }) }))] })) }), i)); }) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Button, __assign({ variant: "contained", onClick: handleAddContact }, { children: "Add Contact" })) }))] })));
1825
2206
  };
1826
2207
  export var AppointmentBookingInput = function (_a) {
1827
- var _b, _d, _e, _f, _g, _h, _j, _k, _l;
2208
+ var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1828
2209
  var formResponseId = _a.formResponseId, field = _a.field, value = _a.value, onChange = _a.onChange, form = _a.form, responses = _a.responses, goToPreviousField = _a.goToPreviousField, isPreviousDisabled = _a.isPreviousDisabled, enduserId = _a.enduserId, props = __rest(_a, ["formResponseId", "field", "value", "onChange", "form", "responses", "goToPreviousField", "isPreviousDisabled", "enduserId"]);
1829
2210
  var session = useResolvedSession();
1830
- var _m = useState(), loaded = _m[0], setLoaded = _m[1];
1831
- var _o = useState(''), error = _o[0], setError = _o[1];
1832
- var _p = useState(false), acknowledgedWarning = _p[0], setAcknowledgedWarning = _p[1];
1833
- var _q = useState(450), height = _q[0], setHeight = _q[1];
1834
- var _r = useState(false), confirming = _r[0], setConfirming = _r[1];
2211
+ var _o = useState(), loaded = _o[0], setLoaded = _o[1];
2212
+ var _p = useState(''), error = _p[0], setError = _p[1];
2213
+ var _q = useState(false), acknowledgedWarning = _q[0], setAcknowledgedWarning = _q[1];
2214
+ var _r = useState(450), height = _r[0], setHeight = _r[1];
2215
+ var _s = useState(false), confirming = _s[0], setConfirming = _s[1];
1835
2216
  var bookingPageId = (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.bookingPageId;
1836
2217
  var downloadICS = useCallback(function (event) { return __awaiter(void 0, void 0, void 0, function () {
1837
- var _a, err_1;
2218
+ var _a, err_6;
1838
2219
  return __generator(this, function (_b) {
1839
2220
  switch (_b.label) {
1840
2221
  case 0:
@@ -1846,8 +2227,8 @@ export var AppointmentBookingInput = function (_a) {
1846
2227
  { name: "event.ics", dataIsURL: true, type: 'text/calendar' }]);
1847
2228
  return [3 /*break*/, 3];
1848
2229
  case 2:
1849
- err_1 = _b.sent();
1850
- console.error(err_1);
2230
+ err_6 = _b.sent();
2231
+ console.error(err_6);
1851
2232
  return [3 /*break*/, 3];
1852
2233
  case 3: return [2 /*return*/];
1853
2234
  }
@@ -1983,12 +2364,20 @@ export var AppointmentBookingInput = function (_a) {
1983
2364
  })
1984
2365
  .join(','));
1985
2366
  }
2367
+ // Filter to Bridge eligibility userIds if option is enabled
2368
+ if ((_h = field.options) === null || _h === void 0 ? void 0 : _h.useBridgeEligibilityResult) {
2369
+ var bridgeUserIds = getBridgeEligibilityUserIds();
2370
+ if (bridgeUserIds.length === 0) {
2371
+ return _jsx(Typography, { children: "No eligible users found for booking" });
2372
+ }
2373
+ bookingURL += "&userIds=".concat(bridgeUserIds.join(','));
2374
+ }
1986
2375
  // need to use form?.id for internally-submitted forms because formResponseId isn't generated until initial submission or saved draft
1987
- if (((_h = field.options) === null || _h === void 0 ? void 0 : _h.holdAppointmentMinutes) && (formResponseId || (field === null || field === void 0 ? void 0 : field.id))) {
2376
+ if (((_j = field.options) === null || _j === void 0 ? void 0 : _j.holdAppointmentMinutes) && (formResponseId || (field === null || field === void 0 ? void 0 : field.id))) {
1988
2377
  bookingURL += "&formResponseId=".concat(formResponseId || (field === null || field === void 0 ? void 0 : field.id));
1989
2378
  bookingURL += "&holdAppointmentMinutes=".concat(field.options.holdAppointmentMinutes);
1990
2379
  }
1991
- return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 1, sx: { mt: 1 } }, { children: [!!((_k = (_j = field.options) === null || _j === void 0 ? void 0 : _j.userFilterTags) === null || _k === void 0 ? void 0 : _k.length) && !((_l = field.options.userTags) === null || _l === void 0 ? void 0 : _l.length) && !(isPreviousDisabled === null || isPreviousDisabled === void 0 ? void 0 : isPreviousDisabled()) && !confirming &&
2380
+ return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 1, sx: { mt: 1 } }, { children: [!!((_l = (_k = field.options) === null || _k === void 0 ? void 0 : _k.userFilterTags) === null || _l === void 0 ? void 0 : _l.length) && !((_m = field.options.userTags) === null || _m === void 0 ? void 0 : _m.length) && !(isPreviousDisabled === null || isPreviousDisabled === void 0 ? void 0 : isPreviousDisabled()) && !confirming &&
1992
2381
  _jsx(Grid, __assign({ item: true, alignSelf: "flex-start" }, { children: _jsx(Button, __assign({ variant: "outlined", onClick: goToPreviousField, sx: { height: 25, p: 0.5, px: 1 } }, { children: "Back" })) })), loaded.warningMessage &&
1993
2382
  _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ color: "error", sx: { fontSize: 20, fontWeight: 'bold' } }, { children: loaded.warningMessage })) })), _jsx(Grid, __assign({ item: true }, { children: (!loaded.warningMessage || acknowledgedWarning)
1994
2383
  ? (_jsx("iframe", { title: "Appointment Booking Embed", src: bookingURL, style: { border: 'none', width: '100%', height: height } }))