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