@inploi/plugin-chatbot 3.25.0 → 3.26.0

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 { g as get$1, i as isString$1, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, N, c as getFlowSubmissionsPayload, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as k, m as k$1, n as getFormSubmitter, q as parse, r as picklist, t as isSubmissionOfType, C as Cn, u as parseAsync, V as ValiError, v as object, w as transform, x as cva, z as maxLength, B as minLength, D as record, E as boolean, G as number, H as minValue, I as maxValue, J as custom, K as string, L as email, M as url, O as regex, P as LoadingIndicator, Q as ERROR_MESSAGES } from "./index-91ddb671.js";
1
+ import { g as get$1, i as isString$1, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, N, c as getFlowSubmissionsPayload, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as k, m as k$1, n as getFormSubmitter, q as parse, r as picklist, t as isSubmissionOfType, C as Cn, u as parseAsync, V as ValiError, v as object, w as transform, x as cva, z as maxLength, B as minLength, D as record, E as boolean, G as number, H as minValue, I as maxValue, J as custom, K as string, L as regex, M as email, O as url, P as LoadingIndicator, Q as ERROR_MESSAGES } from "./index-0a6167b8.js";
2
2
  import "@inploi/sdk";
3
3
  const isIfBlockConditionMet = (ifBlock, {
4
4
  context,
@@ -478,17 +478,25 @@ async function interpretSubmitNode({
478
478
  });
479
479
  }).otherwise(() => {
480
480
  });
481
- await N(response).with({
482
- ats_data: {
481
+ await N(response).with(_.union({
482
+ ats_data: _.select("redirect", {
483
483
  redirect_url: _.string
484
+ })
485
+ }, {
486
+ integration_response: {
487
+ data: _.select("redirect", {
488
+ redirect_url: _.string
489
+ })
484
490
  }
485
- }, async (response2) => {
491
+ }), async (response2) => {
492
+ if (response2.redirect === void 0)
493
+ return;
486
494
  await chat.sendMessage({
487
495
  type: "text",
488
496
  author: "bot",
489
497
  text: "Almost there! Please complete your submission here:"
490
498
  });
491
- const href = new URL(response2.ats_data.redirect_url);
499
+ const href = new URL(response2.redirect.redirect_url);
492
500
  if (anonymous_id && !href.searchParams.has("anonymous_id")) {
493
501
  href.searchParams.set("anonymous_id", anonymous_id);
494
502
  }
@@ -497,8 +505,10 @@ async function interpretSubmitNode({
497
505
  href: href.toString(),
498
506
  text: "Complete submission",
499
507
  onClick: () => {
500
- if (!session_id)
501
- return logger.error("session_id not set, cannot log FLOW_REDIRECT event");
508
+ if (!session_id) {
509
+ logger.error("session_id not set, cannot log FLOW_REDIRECT event");
510
+ return;
511
+ }
502
512
  analytics.log({
503
513
  event: "FLOW_REDIRECT",
504
514
  properties: {
@@ -522,17 +532,24 @@ async function interpretSubmitNode({
522
532
  text: "Submission completed!"
523
533
  });
524
534
  next(node.nextId);
525
- }).with({
526
- sucess: false,
527
- ats_data: {
535
+ }).with(_.union({
536
+ success: false,
537
+ ats_data: _.select("error", {
528
538
  message: _.string
539
+ })
540
+ }, {
541
+ integration_response: {
542
+ error: _.select("error", {
543
+ message: _.string
544
+ })
529
545
  }
530
- }, async (response2) => {
531
- logger.error(response2.ats_data);
546
+ }), async (response2) => {
547
+ var _a;
548
+ logger.error(response2.error);
532
549
  await chat.sendMessage({
533
550
  type: "system",
534
551
  variant: "error",
535
- text: response2.ats_data.message
552
+ text: ((_a = response2.error) == null ? void 0 : _a.message) || "Failed to submit"
536
553
  });
537
554
  await submit(false);
538
555
  }).otherwise(async (response2) => {
@@ -624,7 +641,16 @@ async function interpretQuestionTextNode({
624
641
  context
625
642
  })
626
643
  });
627
- const reply = await chat.userInput({
644
+ const reply = node.data.format === "phone" ? await chat.userInput({
645
+ key: node.data.key,
646
+ type: "phone",
647
+ config: {
648
+ optional: node.data.optional,
649
+ placeholder: node.data.placeholder,
650
+ maxChars: node.data.maxChars,
651
+ minChars: node.data.minChars
652
+ }
653
+ }) : await chat.userInput({
628
654
  key: node.data.key,
629
655
  type: "text",
630
656
  config: {
@@ -1229,7 +1255,256 @@ const SkipButton = ({
1229
1255
  })]
1230
1256
  }), "Skip"]
1231
1257
  });
1232
- const countryNames = ["Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Caribbean Netherlands", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Curaçao", "Cyprus", "Czechia", "Côte d'Ivoire", "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Eswatini", "Ethiopia", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern and Antarctic Lands", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar (Burma)", "Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "North Macedonia", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestine", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Réunion", "Saint Barthélemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Sweden", "Switzerland", "Syria", "São Tomé and Príncipe", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas", "The Gambia", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Türkiye", "U.S. Virgin Islands", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe", "Åland Islands"];
1258
+ const countries = {
1259
+ Afghanistan: "93",
1260
+ Albania: "355",
1261
+ Algeria: "213",
1262
+ "American Samoa": "1",
1263
+ Andorra: "376",
1264
+ Angola: "244",
1265
+ Anguilla: "1",
1266
+ Antarctica: "672",
1267
+ "Antigua and Barbuda": "1",
1268
+ Argentina: "54",
1269
+ Armenia: "374",
1270
+ Aruba: "297",
1271
+ Australia: "61",
1272
+ Austria: "43",
1273
+ Azerbaijan: "994",
1274
+ Bahrain: "973",
1275
+ Bangladesh: "880",
1276
+ Barbados: "1",
1277
+ Belarus: "375",
1278
+ Belgium: "32",
1279
+ Belize: "501",
1280
+ Benin: "229",
1281
+ Bermuda: "1",
1282
+ Bhutan: "975",
1283
+ Bolivia: "591",
1284
+ "Bosnia and Herzegovina": "387",
1285
+ Botswana: "267",
1286
+ "Bouvet Island": "47",
1287
+ Brazil: "55",
1288
+ "British Indian Ocean Territory": "246",
1289
+ "British Virgin Islands": "1",
1290
+ Brunei: "673",
1291
+ Bulgaria: "359",
1292
+ "Burkina Faso": "226",
1293
+ Burundi: "257",
1294
+ "Cabo Verde": "238",
1295
+ Cambodia: "855",
1296
+ Cameroon: "237",
1297
+ Canada: "1",
1298
+ "Caribbean Netherlands": "599",
1299
+ "Cayman Islands": "1",
1300
+ "Central African Republic": "236",
1301
+ Chad: "235",
1302
+ Chile: "56",
1303
+ China: "86",
1304
+ "Christmas Island": "61",
1305
+ "Cocos (Keeling) Islands": "61",
1306
+ Colombia: "57",
1307
+ Comoros: "269",
1308
+ "Cook Islands": "682",
1309
+ "Costa Rica": "506",
1310
+ Croatia: "385",
1311
+ Cuba: "53",
1312
+ Curaçao: "599",
1313
+ Cyprus: "357",
1314
+ Czechia: "420",
1315
+ "Côte d'Ivoire": "225",
1316
+ "Democratic Republic of the Congo": "243",
1317
+ Denmark: "45",
1318
+ Djibouti: "253",
1319
+ "Dominican Republic": "1",
1320
+ Ecuador: "593",
1321
+ Egypt: "20",
1322
+ "El Salvador": "503",
1323
+ "Equatorial Guinea": "240",
1324
+ Eritrea: "291",
1325
+ Estonia: "372",
1326
+ Eswatini: "268",
1327
+ Ethiopia: "251",
1328
+ "Falkland Islands (Islas Malvinas)": "500",
1329
+ "Faroe Islands": "298",
1330
+ Fiji: "679",
1331
+ Finland: "358",
1332
+ France: "33",
1333
+ "French Guiana": "594",
1334
+ "French Polynesia": "689",
1335
+ "French Southern and Antarctic Lands": "260",
1336
+ Gabon: "241",
1337
+ Georgia: "995",
1338
+ Germany: "49",
1339
+ Ghana: "233",
1340
+ Gibraltar: "350",
1341
+ Greece: "30",
1342
+ Greenland: "299",
1343
+ Grenada: "1",
1344
+ Guadeloupe: "590",
1345
+ Guam: "1",
1346
+ Guatemala: "502",
1347
+ Guernsey: "44",
1348
+ Guinea: "224",
1349
+ "Guinea-Bissau": "245",
1350
+ Guyana: "592",
1351
+ Haiti: "509",
1352
+ "Heard Island and McDonald Islands": "334",
1353
+ Honduras: "504",
1354
+ "Hong Kong": "852",
1355
+ Hungary: "36",
1356
+ Iceland: "354",
1357
+ India: "91",
1358
+ Indonesia: "62",
1359
+ Iran: "98",
1360
+ Iraq: "964",
1361
+ Ireland: "352",
1362
+ "Isle of Man": "44",
1363
+ Israel: "972",
1364
+ Italy: "39",
1365
+ Jamaica: "1",
1366
+ Japan: "81",
1367
+ Jersey: "44",
1368
+ Jordan: "962",
1369
+ Kazakhstan: "7",
1370
+ Kenya: "254",
1371
+ Kiribati: "686",
1372
+ Kosovo: "383",
1373
+ Kuwait: "965",
1374
+ Kyrgyzstan: "996",
1375
+ Laos: "856",
1376
+ Latvia: "371",
1377
+ Lebanon: "961",
1378
+ Lesotho: "266",
1379
+ Liberia: "231",
1380
+ Libya: "218",
1381
+ Liechtenstein: "423",
1382
+ Lithuania: "370",
1383
+ Luxembourg: "352",
1384
+ Macao: "853",
1385
+ Madagascar: "261",
1386
+ Malawi: "265",
1387
+ Malaysia: "60",
1388
+ Maldives: "960",
1389
+ Mali: "223",
1390
+ Malta: "356",
1391
+ "Marshall Islands": "692",
1392
+ Martinique: "596",
1393
+ Mauritania: "222",
1394
+ Mauritius: "230",
1395
+ Mayotte: "262",
1396
+ Mexico: "52",
1397
+ Micronesia: "691",
1398
+ Moldova: "373",
1399
+ Monaco: "377",
1400
+ Mongolia: "976",
1401
+ Montenegro: "382",
1402
+ Montserrat: "1",
1403
+ Morocco: "212",
1404
+ Mozambique: "258",
1405
+ "Myanmar (Burma)": "95",
1406
+ Namibia: "264",
1407
+ Nauru: "674",
1408
+ Nepal: "977",
1409
+ Netherlands: "31",
1410
+ "New Caledonia": "687",
1411
+ "New Zealand": "64",
1412
+ Nicaragua: "505",
1413
+ Niger: "227",
1414
+ Nigeria: "234",
1415
+ Niue: "683",
1416
+ "Norfolk Island": "672",
1417
+ "North Korea": "852",
1418
+ "North Macedonia": "389",
1419
+ "Northern Mariana Islands": "1",
1420
+ Norway: "47",
1421
+ Oman: "968",
1422
+ Pakistan: "92",
1423
+ Palau: "680",
1424
+ Palestine: "970",
1425
+ Panama: "507",
1426
+ "Papua New Guinea": "675",
1427
+ Paraguay: "595",
1428
+ Peru: "51",
1429
+ Philippines: "63",
1430
+ "Pitcairn Islands": "64",
1431
+ Poland: "48",
1432
+ Portugal: "351",
1433
+ "Puerto Rico": "1",
1434
+ Qatar: "974",
1435
+ Romania: "40",
1436
+ Russia: "7",
1437
+ Rwanda: "250",
1438
+ Réunion: "262",
1439
+ "Saint Barthélemy": "590",
1440
+ "Saint Helena, Ascension and Tristan da Cunha": "290",
1441
+ "Saint Kitts and Nevis": "1",
1442
+ "Saint Lucia": "1",
1443
+ "Saint Martin": "590",
1444
+ "Saint Pierre and Miquelon": "508",
1445
+ "Saint Vincent and the Grenadines": "1",
1446
+ Samoa: "685",
1447
+ "San Marino": "378",
1448
+ "Saudi Arabia": "966",
1449
+ Senegal: "221",
1450
+ Serbia: "381",
1451
+ Seychelles: "248",
1452
+ "Sierra Leone": "232",
1453
+ Singapore: "65",
1454
+ "Sint Maarten": "1",
1455
+ Slovakia: "421",
1456
+ Slovenia: "386",
1457
+ "Solomon Islands": "677",
1458
+ Somalia: "252",
1459
+ "South Africa": "27",
1460
+ "South Georgia and the South Sandwich Islands": "500",
1461
+ "South Korea": "82",
1462
+ "South Sudan": "211",
1463
+ Spain: "34",
1464
+ "Sri Lanka": "94",
1465
+ Sudan: "249",
1466
+ Suriname: "597",
1467
+ "Svalbard and Jan Mayen": "47",
1468
+ Sweden: "46",
1469
+ Switzerland: "41",
1470
+ Syria: "963",
1471
+ "São Tomé and Príncipe": "293",
1472
+ Taiwan: "886",
1473
+ Tajikistan: "992",
1474
+ Tanzania: "255",
1475
+ Thailand: "66",
1476
+ "The Bahamas": "1",
1477
+ "The Gambia": "220",
1478
+ "Timor-Leste": "670",
1479
+ Togo: "228",
1480
+ Tokelau: "690",
1481
+ Tonga: "676",
1482
+ "Trinidad and Tobago": "1",
1483
+ Tunisia: "216",
1484
+ Turkmenistan: "993",
1485
+ "Turks and Caicos Islands": "1",
1486
+ Tuvalu: "688",
1487
+ Türkiye: "90",
1488
+ "U.S. Virgin Islands": "1",
1489
+ Uganda: "256",
1490
+ Ukraine: "380",
1491
+ "United Arab Emirates": "971",
1492
+ "United Kingdom": "44",
1493
+ "United States": "1",
1494
+ "United States Minor Outlying Islands": "1",
1495
+ Uruguay: "598",
1496
+ Uzbekistan: "998",
1497
+ Vanuatu: "678",
1498
+ "Vatican City": "379",
1499
+ Venezuela: "58",
1500
+ Vietnam: "84",
1501
+ "Wallis and Futuna": "681",
1502
+ "Western Sahara": "212",
1503
+ Yemen: "967",
1504
+ Zambia: "260",
1505
+ Zimbabwe: "263",
1506
+ "Åland Islands": "358"
1507
+ };
1233
1508
  const keyToAddressComponents = {
1234
1509
  line1: ["street_number", "floor", "room", "premise"],
1235
1510
  line2: ["subpremise", "street_address", "route"],
@@ -1558,6 +1833,7 @@ const ChatInputAddressDetails = ({
1558
1833
  }
1559
1834
  }
1560
1835
  }, []);
1836
+ const countryNames = Object.keys(countries);
1561
1837
  return o$1("form", {
1562
1838
  class: "bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",
1563
1839
  onSubmit: (e) => {
@@ -1586,7 +1862,7 @@ const ChatInputAddressDetails = ({
1586
1862
  children: [key === "country" ? o$1("div", {
1587
1863
  class: "relative",
1588
1864
  children: [o$1("select", {
1589
- class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",
1865
+ class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",
1590
1866
  name,
1591
1867
  id: labelId,
1592
1868
  defaultValue: addressFields[key],
@@ -1597,10 +1873,10 @@ const ChatInputAddressDetails = ({
1597
1873
  }) : o$1("option", {
1598
1874
  value: "",
1599
1875
  children: "Select a country"
1600
- }), countryNames.map((country) => o$1("option", {
1601
- value: country,
1602
- children: country
1603
- }, country))]
1876
+ }), countryNames.map((countryName) => o$1("option", {
1877
+ value: countryName,
1878
+ children: countryName
1879
+ }, countryName))]
1604
1880
  }), o$1("svg", {
1605
1881
  class: "text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",
1606
1882
  width: "16",
@@ -3431,7 +3707,7 @@ const LABEL_HEIGHT = 27;
3431
3707
  const GAP = 12;
3432
3708
  const PADDING = 10;
3433
3709
  const isMultipleChoiceSubmission = isSubmissionOfType("enum");
3434
- const getResolver$2 = (config) => {
3710
+ const getResolver$3 = (config) => {
3435
3711
  const length = {
3436
3712
  min: config.minSelected ?? 0,
3437
3713
  max: config.maxSelected ?? config.options.length
@@ -3485,7 +3761,7 @@ const ChatInputMultipleChoice = ({
3485
3761
  defaultValues: {
3486
3762
  checked: isSingleChoice ? {} : isMultipleChoiceSubmission(submission) ? Object.fromEntries(submission.value.map((key) => [key, true])) : {}
3487
3763
  },
3488
- resolver: getResolver$2(input.config)
3764
+ resolver: getResolver$3(input.config)
3489
3765
  });
3490
3766
  const focusRef = useFocusOnMount();
3491
3767
  if (isBooleanLike) {
@@ -3586,7 +3862,7 @@ const errors$1 = {
3586
3862
  max: (max) => `Please enter a number less than or equal to ${max}`,
3587
3863
  decimalCases: (decimalCases) => `Please enter a number with at most ${decimalCases} decimal cases`
3588
3864
  };
3589
- const getResolver$1 = (config) => {
3865
+ const getResolver$2 = (config) => {
3590
3866
  const min = config.min ?? Number.MIN_SAFE_INTEGER;
3591
3867
  const max = config.max ?? Number.MAX_SAFE_INTEGER;
3592
3868
  const decimalCases = config.decimalCases ?? 0;
@@ -3613,7 +3889,7 @@ const ChatInputNumber = ({
3613
3889
  defaultValues: {
3614
3890
  number: defaultValue ? Number(defaultValue) : isNumberSubmission(submission) ? submission.value : void 0
3615
3891
  },
3616
- resolver: getResolver$1(input.config)
3892
+ resolver: getResolver$2(input.config)
3617
3893
  });
3618
3894
  const {
3619
3895
  ref: setRef,
@@ -3671,6 +3947,115 @@ const ChatInputNumber = ({
3671
3947
  })]
3672
3948
  });
3673
3949
  };
3950
+ const invalidPhoneErrorMessage = "That doesn’t look like a valid phone number";
3951
+ const UK_CODE = "44";
3952
+ const PhoneSchema = string(invalidPhoneErrorMessage, [regex(/^\+?[0-9 -]+$/, invalidPhoneErrorMessage)]);
3953
+ const getResolver$1 = (config) => {
3954
+ const configErrors = {
3955
+ maxLength: `Please enter no more than ${config.maxChars ?? 999} characters`,
3956
+ minLength: `Please enter ${config.minChars ?? 1} or more characters`
3957
+ };
3958
+ return i(object({
3959
+ text: transform(PhoneSchema, (value) => value.replace(/[^0-9]/g, ""), [minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)])
3960
+ }));
3961
+ };
3962
+ const isTextSubmission$1 = isSubmissionOfType("string");
3963
+ const ChatInputPhoneNumber = ({
3964
+ input,
3965
+ onSubmitSuccess
3966
+ }) => {
3967
+ var _a;
3968
+ const submission = input.key ? (_a = store.current$.value.flow) == null ? void 0 : _a.data.submissions[input.key] : void 0;
3969
+ const defaultValue = input.config.defaultValue;
3970
+ const {
3971
+ register,
3972
+ handleSubmit,
3973
+ formState: {
3974
+ errors: errors2
3975
+ }
3976
+ } = useForm({
3977
+ defaultValues: {
3978
+ text: defaultValue ? defaultValue : isTextSubmission$1(submission) ? submission.value : ""
3979
+ },
3980
+ resolver: getResolver$1(input.config)
3981
+ });
3982
+ const {
3983
+ ref: setRef,
3984
+ ...props
3985
+ } = register("text", {
3986
+ required: !input.config.optional
3987
+ });
3988
+ const defaultCode = UK_CODE;
3989
+ const [countryCode, setCountryCode] = h(defaultCode);
3990
+ const inputRef = _$1();
3991
+ const selectRef = _$1(null);
3992
+ y(() => {
3993
+ if (inputRef.current) {
3994
+ inputRef.current.focus();
3995
+ inputRef.current.select();
3996
+ }
3997
+ }, []);
3998
+ return o$1("form", {
3999
+ noValidate: true,
4000
+ class: "flex flex-col gap-1 p-2.5",
4001
+ onSubmit: handleSubmit((submission2) => {
4002
+ onSubmitSuccess({
4003
+ type: "string",
4004
+ value: countryCode + submission2.text
4005
+ });
4006
+ }),
4007
+ children: [o$1("div", {
4008
+ class: "flex items-center gap-2",
4009
+ children: [o$1("div", {
4010
+ class: "relative flex min-w-0 flex-1 flex-grow gap-2",
4011
+ children: [o$1("label", {
4012
+ class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus-within:bg-neutral-5 focus-within:outline-accent-7 relative flex h-full w-12 appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-lg border-solid bg-transparent bg-none py-1.5 text-center text-base transition-colors focus-within:outline-none",
4013
+ htmlFor: `isdk_phone_${input.key}`,
4014
+ children: [o$1("span", {
4015
+ children: ["+", countryCode]
4016
+ }), o$1("select", {
4017
+ ref: selectRef,
4018
+ onChange: (e) => {
4019
+ var _a2;
4020
+ const selectedCode = (_a2 = e.currentTarget.selectedOptions[0]) == null ? void 0 : _a2.value;
4021
+ setCountryCode(selectedCode);
4022
+ },
4023
+ required: true,
4024
+ defaultValue: defaultCode,
4025
+ id: `isdk_phone_${input.key}`,
4026
+ class: "absolute inset-0 opacity-0",
4027
+ children: Object.entries(countries).map(([countryName, countryCode2]) => o$1("option", {
4028
+ value: countryCode2,
4029
+ children: [countryName, " (+", countryCode2, ")"]
4030
+ }, countryName))
4031
+ })]
4032
+ }), o$1("input", {
4033
+ ...props,
4034
+ id: "chat-input",
4035
+ type: "tel",
4036
+ inputMode: "tel",
4037
+ autocomplete: "off",
4038
+ autoCapitalize: "off",
4039
+ autoCorrect: "off",
4040
+ autoFocus: true,
4041
+ ref: (element) => {
4042
+ if (element) {
4043
+ inputRef.current = element;
4044
+ }
4045
+ setRef(element);
4046
+ },
4047
+ class: "outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest flex-1 rounded-full px-3 py-1 text-base outline outline-2 transition-all",
4048
+ placeholder: input.config.placeholder
4049
+ }), input.config.optional && o$1(SkipButton, {
4050
+ class: "absolute right-0 top-0",
4051
+ onClick: () => onSubmitSuccess(null)
4052
+ })]
4053
+ }), o$1(SendButton, {})]
4054
+ }), o$1(InputError, {
4055
+ error: errors2.text
4056
+ })]
4057
+ });
4058
+ };
3674
4059
  const ChatInputSubmit = ({
3675
4060
  input,
3676
4061
  onSubmitSuccess
@@ -3712,17 +4097,12 @@ const errors = {
3712
4097
  phone: "That doesn’t look like a valid phone number",
3713
4098
  url: "That doesn’t look like a valid URL"
3714
4099
  };
3715
- const PhoneSchema = string(errors.phone, [regex(/^\+?[0-9 -]+$/, errors.phone)]);
3716
4100
  const inputFormatToProps = {
3717
4101
  email: {
3718
4102
  type: "email",
3719
4103
  inputMode: "email",
3720
4104
  formNoValidate: true
3721
4105
  },
3722
- phone: {
3723
- type: "tel",
3724
- inputMode: "tel"
3725
- },
3726
4106
  text: {
3727
4107
  type: "text",
3728
4108
  inputMode: "text"
@@ -3742,7 +4122,6 @@ const getResolver = (config) => {
3742
4122
  return i(object({
3743
4123
  text: {
3744
4124
  email: string(errors.email, [email(errors.email), minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)]),
3745
- phone: transform(PhoneSchema, (value) => value.replace(/[^0-9]/g, ""), [minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)]),
3746
4125
  text: string([minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)]),
3747
4126
  url: string([url(errors.url), minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)])
3748
4127
  }[config.format]
@@ -3773,11 +4152,11 @@ const ChatInputText = ({
3773
4152
  } = register("text", {
3774
4153
  required: !input.config.optional
3775
4154
  });
3776
- const ref = _$1();
4155
+ const inputRef = _$1();
3777
4156
  y(() => {
3778
- if (ref.current) {
3779
- ref.current.focus();
3780
- ref.current.select();
4157
+ if (inputRef.current) {
4158
+ inputRef.current.focus();
4159
+ inputRef.current.select();
3781
4160
  }
3782
4161
  }, []);
3783
4162
  return o$1("form", {
@@ -3792,7 +4171,7 @@ const ChatInputText = ({
3792
4171
  children: [o$1("div", {
3793
4172
  class: "flex items-center gap-2",
3794
4173
  children: [o$1("div", {
3795
- class: "relative min-w-0 flex-grow",
4174
+ class: "relative min-w-0 flex-1",
3796
4175
  children: [o$1("input", {
3797
4176
  id: "chat-input",
3798
4177
  ...props,
@@ -3803,7 +4182,7 @@ const ChatInputText = ({
3803
4182
  autoFocus: true,
3804
4183
  ref: (element) => {
3805
4184
  if (element) {
3806
- ref.current = element;
4185
+ inputRef.current = element;
3807
4186
  }
3808
4187
  setRef(element);
3809
4188
  },
@@ -3870,6 +4249,13 @@ const ChatInput = () => {
3870
4249
  }, (props) => o$1(ChatInputText, {
3871
4250
  onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
3872
4251
  ...props
4252
+ })).with({
4253
+ input: {
4254
+ type: "phone"
4255
+ }
4256
+ }, (props) => o$1(ChatInputPhoneNumber, {
4257
+ onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
4258
+ ...props
3873
4259
  })).with({
3874
4260
  input: {
3875
4261
  type: "multiple-choice"