@redneckz/wildless-cms-uni-blocks 0.14.666 → 0.14.667

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 (205) hide show
  1. package/bundle/api/RetailAPI/regionOffices.d.ts +16 -0
  2. package/bundle/bundle.umd.js +1336 -1310
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/ApplicationForm/getInitialFormState.d.ts +1 -0
  5. package/bundle/components/ApplicationLeadForm/getInitialFormState.d.ts +2 -1
  6. package/bundle/components/CreditForm/getFifthStepData.d.ts +3 -0
  7. package/bundle/components/OfficesAtmsMap/renderWorkSchedule.d.ts +1 -1
  8. package/bundle/ui-kit/FormField/Fields/{RetailAddressField.d.ts → AddressRetailField.d.ts} +1 -1
  9. package/{lib/ui-kit/FormField/Fields/RetailRegionField.d.ts → bundle/ui-kit/FormField/Fields/RegionRetailField.d.ts} +1 -1
  10. package/bundle/ui-kit/FormField/SelectField.d.ts +2 -0
  11. package/bundle/ui-kit/YandexMap/YandexMap.d.ts +1 -0
  12. package/dist/api/RetailAPI/regionOffices.d.ts +16 -0
  13. package/dist/api/RetailAPI/regionOffices.js +19 -0
  14. package/dist/api/RetailAPI/regionOffices.js.map +1 -0
  15. package/dist/components/ApplicationForm/getInitialFormState.d.ts +1 -0
  16. package/dist/components/ApplicationForm/getInitialFormState.js +1 -0
  17. package/dist/components/ApplicationForm/getInitialFormState.js.map +1 -1
  18. package/dist/components/ApplicationLeadForm/getInitialFormState.d.ts +2 -1
  19. package/dist/components/ApplicationLeadForm/getInitialFormState.js +1 -0
  20. package/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  21. package/dist/components/CreditCardForm/formStateMap.js +2 -2
  22. package/dist/components/CreditCardForm/formStateMap.js.map +1 -1
  23. package/dist/components/CreditForm/getCreditFormTaskData.js +3 -1
  24. package/dist/components/CreditForm/getCreditFormTaskData.js.map +1 -1
  25. package/dist/components/CreditForm/getFifthStepData.d.ts +3 -0
  26. package/dist/components/CreditForm/getFifthStepData.js +10 -0
  27. package/dist/components/CreditForm/getFifthStepData.js.map +1 -0
  28. package/dist/components/OfficesAtmsMap/renderWorkSchedule.d.ts +1 -1
  29. package/dist/components/OfficesAtmsMap/renderWorkSchedule.js +1 -1
  30. package/dist/components/OfficesAtmsMap/renderWorkSchedule.js.map +1 -1
  31. package/{lib/ui-kit/FormField/Fields/RetailAddressField.d.ts → dist/ui-kit/FormField/Fields/AddressRetailField.d.ts} +1 -1
  32. package/{mobile/dist/ui-kit/FormField/Fields/RetailAddressField.js → dist/ui-kit/FormField/Fields/AddressRetailField.js} +20 -18
  33. package/dist/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -0
  34. package/{bundle/ui-kit/FormField/Fields/RetailRegionField.d.ts → dist/ui-kit/FormField/Fields/RegionRetailField.d.ts} +1 -1
  35. package/dist/ui-kit/FormField/Fields/RegionRetailField.js +14 -0
  36. package/dist/ui-kit/FormField/Fields/RegionRetailField.js.map +1 -0
  37. package/dist/ui-kit/FormField/SelectField.d.ts +2 -0
  38. package/dist/ui-kit/FormField/SelectField.js +2 -2
  39. package/dist/ui-kit/FormField/SelectField.js.map +1 -1
  40. package/dist/ui-kit/FormField/getField.js +4 -4
  41. package/dist/ui-kit/FormField/getField.js.map +1 -1
  42. package/dist/ui-kit/FormField/getObjectValidator.js +1 -1
  43. package/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
  44. package/dist/ui-kit/YandexMap/YandexMap.d.ts +1 -0
  45. package/dist/ui-kit/YandexMap/YandexMap.js +4 -4
  46. package/dist/ui-kit/YandexMap/YandexMap.js.map +1 -1
  47. package/lib/api/RetailAPI/regionOffices.d.ts +16 -0
  48. package/lib/api/RetailAPI/regionOffices.js +16 -0
  49. package/lib/api/RetailAPI/regionOffices.js.map +1 -0
  50. package/lib/components/ApplicationForm/getInitialFormState.d.ts +1 -0
  51. package/lib/components/ApplicationForm/getInitialFormState.js +1 -0
  52. package/lib/components/ApplicationForm/getInitialFormState.js.map +1 -1
  53. package/lib/components/ApplicationLeadForm/getInitialFormState.d.ts +2 -1
  54. package/lib/components/ApplicationLeadForm/getInitialFormState.js +1 -0
  55. package/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  56. package/lib/components/CreditCardForm/formStateMap.js +2 -2
  57. package/lib/components/CreditCardForm/formStateMap.js.map +1 -1
  58. package/lib/components/CreditForm/getCreditFormTaskData.js +3 -1
  59. package/lib/components/CreditForm/getCreditFormTaskData.js.map +1 -1
  60. package/lib/components/CreditForm/getFifthStepData.d.ts +3 -0
  61. package/lib/components/CreditForm/getFifthStepData.js +7 -0
  62. package/lib/components/CreditForm/getFifthStepData.js.map +1 -0
  63. package/lib/components/OfficesAtmsMap/renderWorkSchedule.d.ts +1 -1
  64. package/lib/components/OfficesAtmsMap/renderWorkSchedule.js +1 -1
  65. package/lib/components/OfficesAtmsMap/renderWorkSchedule.js.map +1 -1
  66. package/{dist/ui-kit/FormField/Fields/RetailAddressField.d.ts → lib/ui-kit/FormField/Fields/AddressRetailField.d.ts} +1 -1
  67. package/lib/ui-kit/FormField/Fields/{RetailAddressField.js → AddressRetailField.js} +20 -18
  68. package/lib/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -0
  69. package/{mobile/bundle/ui-kit/FormField/Fields/RetailRegionField.d.ts → lib/ui-kit/FormField/Fields/RegionRetailField.d.ts} +1 -1
  70. package/lib/ui-kit/FormField/Fields/RegionRetailField.js +12 -0
  71. package/lib/ui-kit/FormField/Fields/RegionRetailField.js.map +1 -0
  72. package/lib/ui-kit/FormField/SelectField.d.ts +2 -0
  73. package/lib/ui-kit/FormField/SelectField.js +2 -2
  74. package/lib/ui-kit/FormField/SelectField.js.map +1 -1
  75. package/lib/ui-kit/FormField/getField.js +4 -4
  76. package/lib/ui-kit/FormField/getField.js.map +1 -1
  77. package/lib/ui-kit/FormField/getObjectValidator.js +1 -1
  78. package/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
  79. package/lib/ui-kit/YandexMap/YandexMap.d.ts +1 -0
  80. package/lib/ui-kit/YandexMap/YandexMap.js +2 -2
  81. package/lib/ui-kit/YandexMap/YandexMap.js.map +1 -1
  82. package/mobile/bundle/api/RetailAPI/regionOffices.d.ts +16 -0
  83. package/mobile/bundle/bundle.umd.js +1336 -1310
  84. package/mobile/bundle/bundle.umd.min.js +1 -1
  85. package/mobile/bundle/components/ApplicationForm/getInitialFormState.d.ts +1 -0
  86. package/mobile/bundle/components/ApplicationLeadForm/getInitialFormState.d.ts +2 -1
  87. package/mobile/bundle/components/CreditForm/getFifthStepData.d.ts +3 -0
  88. package/mobile/bundle/components/OfficesAtmsMap/renderWorkSchedule.d.ts +1 -1
  89. package/mobile/bundle/ui-kit/FormField/Fields/{RetailAddressField.d.ts → AddressRetailField.d.ts} +1 -1
  90. package/{dist/ui-kit/FormField/Fields/RetailRegionField.d.ts → mobile/bundle/ui-kit/FormField/Fields/RegionRetailField.d.ts} +1 -1
  91. package/mobile/bundle/ui-kit/FormField/SelectField.d.ts +2 -0
  92. package/mobile/bundle/ui-kit/YandexMap/YandexMap.d.ts +1 -0
  93. package/mobile/dist/api/RetailAPI/regionOffices.d.ts +16 -0
  94. package/mobile/dist/api/RetailAPI/regionOffices.js +19 -0
  95. package/mobile/dist/api/RetailAPI/regionOffices.js.map +1 -0
  96. package/mobile/dist/components/ApplicationForm/getInitialFormState.d.ts +1 -0
  97. package/mobile/dist/components/ApplicationForm/getInitialFormState.js +1 -0
  98. package/mobile/dist/components/ApplicationForm/getInitialFormState.js.map +1 -1
  99. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.d.ts +2 -1
  100. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.js +1 -0
  101. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  102. package/mobile/dist/components/CreditCardForm/formStateMap.js +2 -2
  103. package/mobile/dist/components/CreditCardForm/formStateMap.js.map +1 -1
  104. package/mobile/dist/components/CreditForm/getCreditFormTaskData.js +3 -1
  105. package/mobile/dist/components/CreditForm/getCreditFormTaskData.js.map +1 -1
  106. package/mobile/dist/components/CreditForm/getFifthStepData.d.ts +3 -0
  107. package/mobile/dist/components/CreditForm/getFifthStepData.js +10 -0
  108. package/mobile/dist/components/CreditForm/getFifthStepData.js.map +1 -0
  109. package/mobile/dist/components/OfficesAtmsMap/renderWorkSchedule.d.ts +1 -1
  110. package/mobile/dist/components/OfficesAtmsMap/renderWorkSchedule.js +1 -1
  111. package/mobile/dist/components/OfficesAtmsMap/renderWorkSchedule.js.map +1 -1
  112. package/mobile/dist/ui-kit/FormField/Fields/AddressRetailField.d.ts +2 -0
  113. package/{dist/ui-kit/FormField/Fields/RetailAddressField.js → mobile/dist/ui-kit/FormField/Fields/AddressRetailField.js} +20 -18
  114. package/mobile/dist/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -0
  115. package/mobile/dist/ui-kit/FormField/Fields/RegionRetailField.d.ts +2 -0
  116. package/mobile/dist/ui-kit/FormField/Fields/RegionRetailField.js +14 -0
  117. package/mobile/dist/ui-kit/FormField/Fields/RegionRetailField.js.map +1 -0
  118. package/mobile/dist/ui-kit/FormField/SelectField.d.ts +2 -0
  119. package/mobile/dist/ui-kit/FormField/SelectField.js +2 -2
  120. package/mobile/dist/ui-kit/FormField/SelectField.js.map +1 -1
  121. package/mobile/dist/ui-kit/FormField/getField.js +4 -4
  122. package/mobile/dist/ui-kit/FormField/getField.js.map +1 -1
  123. package/mobile/dist/ui-kit/FormField/getObjectValidator.js +1 -1
  124. package/mobile/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
  125. package/mobile/dist/ui-kit/YandexMap/YandexMap.d.ts +1 -0
  126. package/mobile/dist/ui-kit/YandexMap/YandexMap.js +4 -4
  127. package/mobile/dist/ui-kit/YandexMap/YandexMap.js.map +1 -1
  128. package/mobile/lib/api/RetailAPI/regionOffices.d.ts +16 -0
  129. package/mobile/lib/api/RetailAPI/regionOffices.js +16 -0
  130. package/mobile/lib/api/RetailAPI/regionOffices.js.map +1 -0
  131. package/mobile/lib/components/ApplicationForm/getInitialFormState.d.ts +1 -0
  132. package/mobile/lib/components/ApplicationForm/getInitialFormState.js +1 -0
  133. package/mobile/lib/components/ApplicationForm/getInitialFormState.js.map +1 -1
  134. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.d.ts +2 -1
  135. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.js +1 -0
  136. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  137. package/mobile/lib/components/CreditCardForm/formStateMap.js +2 -2
  138. package/mobile/lib/components/CreditCardForm/formStateMap.js.map +1 -1
  139. package/mobile/lib/components/CreditForm/getCreditFormTaskData.js +3 -1
  140. package/mobile/lib/components/CreditForm/getCreditFormTaskData.js.map +1 -1
  141. package/mobile/lib/components/CreditForm/getFifthStepData.d.ts +3 -0
  142. package/mobile/lib/components/CreditForm/getFifthStepData.js +7 -0
  143. package/mobile/lib/components/CreditForm/getFifthStepData.js.map +1 -0
  144. package/mobile/lib/components/OfficesAtmsMap/renderWorkSchedule.d.ts +1 -1
  145. package/mobile/lib/components/OfficesAtmsMap/renderWorkSchedule.js +1 -1
  146. package/mobile/lib/components/OfficesAtmsMap/renderWorkSchedule.js.map +1 -1
  147. package/mobile/lib/ui-kit/FormField/Fields/AddressRetailField.d.ts +2 -0
  148. package/mobile/lib/ui-kit/FormField/Fields/{RetailAddressField.js → AddressRetailField.js} +20 -18
  149. package/mobile/lib/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -0
  150. package/mobile/lib/ui-kit/FormField/Fields/RegionRetailField.d.ts +2 -0
  151. package/mobile/lib/ui-kit/FormField/Fields/RegionRetailField.js +12 -0
  152. package/mobile/lib/ui-kit/FormField/Fields/RegionRetailField.js.map +1 -0
  153. package/mobile/lib/ui-kit/FormField/SelectField.d.ts +2 -0
  154. package/mobile/lib/ui-kit/FormField/SelectField.js +2 -2
  155. package/mobile/lib/ui-kit/FormField/SelectField.js.map +1 -1
  156. package/mobile/lib/ui-kit/FormField/getField.js +4 -4
  157. package/mobile/lib/ui-kit/FormField/getField.js.map +1 -1
  158. package/mobile/lib/ui-kit/FormField/getObjectValidator.js +1 -1
  159. package/mobile/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
  160. package/mobile/lib/ui-kit/YandexMap/YandexMap.d.ts +1 -0
  161. package/mobile/lib/ui-kit/YandexMap/YandexMap.js +2 -2
  162. package/mobile/lib/ui-kit/YandexMap/YandexMap.js.map +1 -1
  163. package/mobile/src/api/RetailAPI/regionOffices.ts +36 -0
  164. package/mobile/src/components/ApplicationForm/getInitialFormState.tsx +2 -0
  165. package/mobile/src/components/ApplicationLeadForm/getInitialFormState.tsx +3 -1
  166. package/mobile/src/components/CreditCardForm/formStateMap.tsx +2 -2
  167. package/mobile/src/components/CreditForm/getCreditFormTaskData.ts +3 -1
  168. package/mobile/src/components/CreditForm/getFifthStepData.ts +10 -0
  169. package/mobile/src/components/OfficesAtmsMap/renderWorkSchedule.tsx +1 -1
  170. package/mobile/src/ui-kit/FormField/Fields/{RetailAddressField.tsx → AddressRetailField.tsx} +20 -23
  171. package/mobile/src/ui-kit/FormField/Fields/{RetailRegionField.tsx → RegionRetailField.tsx} +6 -8
  172. package/mobile/src/ui-kit/FormField/SelectField.tsx +13 -2
  173. package/mobile/src/ui-kit/FormField/getField.tsx +4 -4
  174. package/mobile/src/ui-kit/FormField/getObjectValidator.tsx +1 -1
  175. package/mobile/src/ui-kit/YandexMap/YandexMap.tsx +2 -2
  176. package/package.json +1 -1
  177. package/src/api/RetailAPI/regionOffices.ts +36 -0
  178. package/src/components/ApplicationForm/getInitialFormState.tsx +2 -0
  179. package/src/components/ApplicationLeadForm/getInitialFormState.tsx +3 -1
  180. package/src/components/CreditCardForm/formStateMap.tsx +2 -2
  181. package/src/components/CreditForm/getCreditFormTaskData.ts +3 -1
  182. package/src/components/CreditForm/getFifthStepData.ts +10 -0
  183. package/src/components/OfficesAtmsMap/renderWorkSchedule.tsx +1 -1
  184. package/src/ui-kit/FormField/Fields/{RetailAddressField.tsx → AddressRetailField.tsx} +20 -23
  185. package/src/ui-kit/FormField/Fields/{RetailRegionField.tsx → RegionRetailField.tsx} +6 -8
  186. package/src/ui-kit/FormField/SelectField.tsx +13 -2
  187. package/src/ui-kit/FormField/getField.tsx +4 -4
  188. package/src/ui-kit/FormField/getObjectValidator.tsx +1 -1
  189. package/src/ui-kit/YandexMap/YandexMap.tsx +2 -2
  190. package/dist/ui-kit/FormField/Fields/RetailAddressField.js.map +0 -1
  191. package/dist/ui-kit/FormField/Fields/RetailRegionField.js +0 -14
  192. package/dist/ui-kit/FormField/Fields/RetailRegionField.js.map +0 -1
  193. package/lib/ui-kit/FormField/Fields/RetailAddressField.js.map +0 -1
  194. package/lib/ui-kit/FormField/Fields/RetailRegionField.js +0 -12
  195. package/lib/ui-kit/FormField/Fields/RetailRegionField.js.map +0 -1
  196. package/mobile/dist/ui-kit/FormField/Fields/RetailAddressField.d.ts +0 -2
  197. package/mobile/dist/ui-kit/FormField/Fields/RetailAddressField.js.map +0 -1
  198. package/mobile/dist/ui-kit/FormField/Fields/RetailRegionField.d.ts +0 -2
  199. package/mobile/dist/ui-kit/FormField/Fields/RetailRegionField.js +0 -14
  200. package/mobile/dist/ui-kit/FormField/Fields/RetailRegionField.js.map +0 -1
  201. package/mobile/lib/ui-kit/FormField/Fields/RetailAddressField.d.ts +0 -2
  202. package/mobile/lib/ui-kit/FormField/Fields/RetailAddressField.js.map +0 -1
  203. package/mobile/lib/ui-kit/FormField/Fields/RetailRegionField.d.ts +0 -2
  204. package/mobile/lib/ui-kit/FormField/Fields/RetailRegionField.js +0 -12
  205. package/mobile/lib/ui-kit/FormField/Fields/RetailRegionField.js.map +0 -1
@@ -1512,6 +1512,7 @@
1512
1512
  feedbackMethod: defaultSelectValidator(),
1513
1513
  serviceType: defaultSelectValidator(),
1514
1514
  serviceDirection: defaultSelectValidator(),
1515
+ regionRetail: defaultSelectValidator('Выберите регион'),
1515
1516
  meetingDay: defaultValidator(),
1516
1517
  product: defaultValidator(),
1517
1518
  localities: defaultValidator(),
@@ -1546,7 +1547,6 @@
1546
1547
  legalEntityName: defaultValidator(),
1547
1548
  bankEmployeeCode: defaultValidator(),
1548
1549
  partInBusiness: defaultValidator(),
1549
- regionRetail: defaultSelectValidator('Выберите филиал банка'),
1550
1550
  addressRetail: defaultSelectValidator('Выберите адрес банка'),
1551
1551
  addressMatch: defaultValidator(),
1552
1552
  codeWord: codeWordValidator('Необходимо ввести кодовое слово'),
@@ -1804,1458 +1804,1474 @@
1804
1804
  return (jsx(CheckboxWithError, { text: "\u0410\u0434\u0440\u0435\u0441 \u0444\u0430\u043A\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0433\u043E \u043C\u0435\u0441\u0442\u0430 \u0436\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u0430 \u0441\u043E\u0432\u043F\u0430\u0434\u0430\u0435\u0442 \u0441 \u0430\u0434\u0440\u0435\u0441\u043E\u043C \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438", ...getValidation(field('addressMatch'), validatorObj.addressMatch, input?.required) }));
1805
1805
  });
1806
1806
 
1807
- const useNormalizedInput = (props, { normalize, format }) => {
1808
- const { value, onFocus, onBlur, onChange } = props;
1809
- const [isFocused, setIsFocused] = useState(false);
1810
- const handleFocus = useCallback((ev) => {
1811
- setIsFocused(true);
1812
- onFocus && onFocus(ev);
1813
- }, []);
1814
- const handleBlur = useCallback(() => {
1815
- setIsFocused(false);
1816
- onChange && onChange(normalize(value));
1817
- onBlur && onBlur();
1818
- }, [onChange, value]);
1819
- return {
1820
- value: (isFocused || !format ? value : format(value)),
1821
- onFocus: handleFocus,
1822
- onBlur: handleBlur,
1823
- };
1824
- };
1825
-
1826
- const clamp = (value, min, max) => Math.max(min, Math.min(value, max));
1827
-
1828
- function parseDecimal(value) {
1829
- const rawValue = (value || '').replace(/\D/g, '');
1830
- const unsafeDecimal = parseInt(rawValue, 10);
1831
- return Number.isNaN(unsafeDecimal) ? 0 : unsafeDecimal;
1832
- }
1807
+ const Loader = JSX(({ color = 'text-primary-main', position = 'absolute', blur = true }) => (jsx("div", { className: style('flex justify-center items-center h-full w-full z-50', position, {
1808
+ 'backdrop-blur': blur,
1809
+ }), children: jsx("div", { className: style('inline-block h-28 w-28', 'animate-spin rounded-full', 'border-8 border-solid border-current', 'border-r-transparent', color), role: "status" }) })));
1833
1810
 
1834
- function renderRangeWithTicks({ list = [], min, max, step, value = list[0] || min, disabled, onChange, }) {
1835
- const rangeValue = list.length ? list.indexOf(value) : value;
1836
- const rangeValueShift = rangeValue > min ? rangeValue - min : 0;
1837
- const percentage = (rangeValueShift * 100) / (max - min);
1838
- const inputStyle = {
1839
- backgroundSize: `${percentage.toFixed(2)}% 100%`,
1840
- };
1841
- return (jsxs("div", { children: [list.length ? (jsx("div", { className: "absolute w-full flex justify-between -bottom-[3px] px-m", children: list.map((_, i) => (jsx("div", { className: style('w-2 h-2 rounded-full', rangeValue <= i || disabled ? 'bg-gray' : 'bg-primary-main') }, String(i)))) })) : null, jsx("div", { className: "absolute inset-x-0 -bottom-1 px-m leading-[18px]", children: jsx("input", { className: "box-border w-full m-0 cursor-pointer slider relative z-10", style: inputStyle, type: "range", min: min, max: max, step: step, value: rangeValue, disabled: disabled, onChange: ((ev) => {
1842
- const rawValue = parseDecimal(ev.target?.value);
1843
- const newValue = list.length ? list[rawValue] : rawValue;
1844
- onChange && onChange(newValue || 0);
1845
- }) }) })] }));
1811
+ const MapMarkerClusterIcon = '/icons/MapMarkerClusterIcon.svg';
1812
+ const MapMarkerClusterYellowIcon = '/icons/MapMarkerClusterYellowIcon.svg';
1813
+ function renderClusterer({ yandexMaps, map, points, isLoad, }) {
1814
+ if (isLoad || !points) {
1815
+ return;
1816
+ }
1817
+ map.geoObjects.removeAll();
1818
+ if (!points.length) {
1819
+ return;
1820
+ }
1821
+ const clusterIconContentLayout = yandexMaps.templateLayoutFactory.createClass('<div style="margin-top: -3px;">{{properties.geoObjects.length}}</div>');
1822
+ const officeClusterer = defineClusterer('offices', yandexMaps, clusterIconContentLayout);
1823
+ if (points.length && points.every((_) => 'type' in _)) {
1824
+ const remoteWorkplaceClusterer = defineClusterer('workplaces', yandexMaps, clusterIconContentLayout);
1825
+ const remoteWorkplaceGeoObjects = defineGeoObjects(points.filter((_) => _.type === 'workplaces'), 'workplaces', yandexMaps);
1826
+ const officesGeoObjects = defineGeoObjects(points.filter((_) => _.type === 'offices'), 'offices', yandexMaps);
1827
+ officeClusterer.add(officesGeoObjects);
1828
+ remoteWorkplaceClusterer.add(remoteWorkplaceGeoObjects);
1829
+ map.geoObjects.add(remoteWorkplaceClusterer);
1830
+ map.geoObjects.add(officeClusterer);
1831
+ }
1832
+ else {
1833
+ const geoObjects = defineGeoObjects(points, 'offices', yandexMaps);
1834
+ officeClusterer.add(geoObjects);
1835
+ map.geoObjects.add(officeClusterer);
1836
+ }
1837
+ map.setBounds(yandexMaps.util.bounds.fromPoints(points.map((_) => _.coords))).then(() => {
1838
+ if (map.getZoom() > 10) {
1839
+ map.setZoom(10);
1840
+ }
1841
+ });
1846
1842
  }
1847
-
1848
- const inputDisabledStyle = 'disabled:border-gray disabled:bg-main-divider';
1849
- const DEFAULT_MIN = 1;
1850
- const DEFAULT_MAX = 100;
1851
- const InputRange = JSX((props) => {
1852
- const { className, title, items = [], list = [], min = list.length ? 0 : DEFAULT_MIN, max = list.length ? list.length - 1 : DEFAULT_MAX, step = 1, value = list[0] || min, disabled = false, onChange, } = props;
1853
- const normalizedProps = useNormalizedInput(props, {
1854
- normalize: (_ = 0) => list.length ? closestValue(list)(_) : clamp(_, min, max),
1855
- format: toLocalNumberFormat(),
1843
+ const defineClusterer = (type, yandexMaps, clusterIconContentLayout) => {
1844
+ return new yandexMaps.Clusterer({
1845
+ clusterIcons: [
1846
+ {
1847
+ href: type === 'offices' ? MapMarkerClusterIcon : MapMarkerClusterYellowIcon,
1848
+ size: [78, 84],
1849
+ offset: [-35, -50],
1850
+ },
1851
+ ],
1852
+ clusterIconContentLayout,
1853
+ clusterHideIconOnBalloonOpen: false,
1854
+ geoObjectHideIconOnBalloonOpen: false,
1856
1855
  });
1857
- const handleChange = useCallback((ev) => {
1858
- onChange && onChange(parseDecimal(ev.target?.value));
1859
- }, [onChange]);
1860
- return (jsxs("div", { className: className, children: [jsxs("label", { className: "block relative", children: [title ? (jsx(Text, { size: "text-m", font: "font-light", color: "text-primary-text", children: title })) : null, jsx("input", { className: style('text-h3 w-full h-14', 'pl-m mt-xs box-border', 'text-primary-text', inputValidStyle, inputDisabledStyle), disabled: disabled, onChange: handleChange, ...normalizedProps }), renderRangeWithTicks({ list, min, max, step, disabled, value, onChange })] }), renderRangeCaption(items)] }));
1861
- });
1862
- const closestValue = (list) => (_) => list.reduce((prev, curr) => (Math.abs(curr - _) < Math.abs(prev - _) ? curr : prev));
1863
- const renderRangeCaption = (items) => (jsx("div", { className: "flex justify-between my-xs", children: items.map((item, i) => (jsx(Text, { size: "text-s", font: "font-light", color: "text-secondary-text", children: item }, String(i)))) }));
1864
-
1865
- const MIN_CREDIT_AMOUNT = 1000;
1866
- const MAX_CREDIT_AMOUNT = 1000000000;
1867
- const ITEMS_CREDIT_AMOUNT = ['От 1 000 ₽', 'До 1 000 000 000 ₽'];
1868
- const AmountField = JSX(({ field }) => (jsx(InputRange, { title: "\u0421\u0443\u043C\u043C\u0430, \u20BD", items: ITEMS_CREDIT_AMOUNT, min: MIN_CREDIT_AMOUNT, max: MAX_CREDIT_AMOUNT, ...field('amount') })));
1869
-
1870
- const useLeadFormData = (typeField) => {
1871
- const { data, error } = useAsyncData(`/api/v1/dictionary?dictionaryType=${encodeURIComponent(typeField)}`, fetchData);
1872
- if (data && 'errorMessage' in data) {
1873
- return { error };
1874
- }
1875
- return { data: data, error };
1876
1856
  };
1877
- const fetchData = async (url) => {
1878
- const result = await fetchJSON(url, { method: 'POST' });
1879
- return result || [];
1857
+ const defineGeoObjects = (pointArr, type, yandexMaps) => {
1858
+ return pointArr.map(({ coords, content }) => new yandexMaps.Placemark(coords, {
1859
+ balloonContentHeader: content?.header,
1860
+ balloonContentBody: content?.body,
1861
+ balloonContentFooter: content?.footer,
1862
+ hintContent: content?.hint,
1863
+ }, {
1864
+ iconLayout: 'default#image',
1865
+ iconImageHref: type === 'offices' ? MapMarkerClusterIcon : MapMarkerClusterYellowIcon,
1866
+ iconImageSize: [78, 84],
1867
+ iconImageOffset: [-35, -50],
1868
+ }));
1880
1869
  };
1881
1870
 
1882
- const SelectField = UniBlock(({ field, source, label, fieldName, input }) => {
1883
- const leadOptions = (source &&
1884
- source?.map((_) => ({
1885
- key: _.key || '',
1886
- text: _.value,
1887
- }))) ||
1888
- [];
1889
- return (jsx(SelectControl, { placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0441\u043F\u0438\u0441\u043A\u0430", label: label, options: leadOptions, ...getValidation(field(fieldName), validatorObj[fieldName], input?.required) }));
1890
- });
1891
-
1892
- const AmountWorkersField = JSX(({ field, input }) => {
1893
- const { data: amountWorkers } = useLeadFormData('EMPLOYEES_NUMBER');
1894
- return (jsx(SelectField, { field: field, source: amountWorkers, label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0440\u0430\u0431\u043E\u0442\u0430\u044E\u0449\u0438\u0445 \u0432 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438", fieldName: "amountWorkers", input: input }));
1895
- });
1896
-
1897
- const AnnualRevenueField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0413\u043E\u0434\u043E\u0432\u0430\u044F \u0432\u044B\u0440\u0443\u0447\u043A\u0430, \u20BD", ...getValidation(field('annualRevenue'), validatorObj.annualRevenue, input?.required) })));
1898
-
1899
- const ArmyIdFlgField = JSX(({ field, input }) => (jsx(CheckboxWithError, { text: "\u041D\u0430\u043B\u0438\u0447\u0438\u0435 \u0432\u043E\u0435\u043D\u043D\u043E\u0433\u043E \u0431\u0438\u043B\u0435\u0442\u0430", ...getValidation(field('armyIdFlg'), validatorObj.armyIdFlg, input?.required) })));
1900
-
1901
- const BankEmpoleeCodeField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u0434 \u043F\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043B\u044F \u0411\u0430\u043D\u043A\u0430", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043A\u043E\u0434", type: "number", ...getValidation(field('bankEmployeeCode'), validatorObj.bankEmployeeCode, input?.required), ...input })));
1902
-
1903
- const BankEmpoleeField = JSX(({ field }) => (jsx(InputControl, { label: "\u0424\u0418\u041E \u0438\u043B\u0438 \u0434\u043E\u043B\u0436\u043D\u043E\u0441\u0442\u044C \u043E\u0431\u0441\u043B\u0443\u0436\u0438\u0432\u0430\u0432\u0448\u0435\u0433\u043E \u0412\u0430\u0441 \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u0430 \u0411\u0430\u043D\u043A\u0430", ...field('bankEmpolee') })));
1871
+ const defaultStyle = {
1872
+ focus: 'focus:border-primary-text focus:border',
1873
+ hover: 'hover:bg-primary-hover',
1874
+ active: 'active:bg-primary-active',
1875
+ font: 'text-center font-sans',
1876
+ };
1904
1877
 
1905
- const BankruptcyFlgField = JSX(({ field, input }) => (jsx(CheckboxWithError, { text: "\u0412 \u043E\u0442\u043D\u043E\u0448\u0435\u043D\u0438\u0438 \u043C\u0435\u043D\u044F \u0432\u0435\u0434\u0451\u0442\u0441\u044F \u043F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0441\u0442\u0432\u043E \u043F\u043E \u0434\u0435\u043B\u0443 \u043E \u0431\u0430\u043D\u043A\u0440\u043E\u0442\u0441\u0442\u0432\u0435", ...getValidation(field('bankruptcyFlg'), validatorObj.bankruptcyFlg, input?.required) })));
1878
+ const styles$1 = {
1879
+ ...defaultStyle,
1880
+ border: 'border border-transparent rounded-md',
1881
+ position: 'absolute flex items-center justify-center',
1882
+ };
1883
+ const renderUserGeolocation = (map, yandexMaps, className) => {
1884
+ const setUserGeoLocation = () => {
1885
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1886
+ // @ts-ignore
1887
+ yandexMaps.geolocation
1888
+ .get({
1889
+ provider: 'yandex',
1890
+ autoReverseGeocode: true,
1891
+ mapStateAutoApply: true,
1892
+ })
1893
+ .then(function (result) {
1894
+ map.current.geoObjects.add(result.geoObjects);
1895
+ });
1896
+ };
1897
+ return (jsx("div", { className: `select-none cursor-pointer py-m w-12 bg-white ${Object.values(styles$1).join(' ')} ${className}`, onClick: setUserGeoLocation, children: jsx(Icon, { name: "UserGeoLocationIcon", width: "20", height: "16" }) }));
1898
+ };
1906
1899
 
1907
- const useElementSpace = (ref, heightEl) => {
1908
- const [spaceAbove, setSpaceAbove] = useState(false);
1900
+ const getNS = (_) => globalThis[_];
1901
+ const initializeExternalNS = (namespaceName, url) => {
1902
+ const script = document.getElementById(url);
1903
+ if (script) {
1904
+ const ns = getNS(namespaceName);
1905
+ if (ns) {
1906
+ return Promise.resolve(ns);
1907
+ }
1908
+ else {
1909
+ return new Promise((resolve) => {
1910
+ script.addEventListener('load', () => {
1911
+ resolve(getNS(namespaceName));
1912
+ });
1913
+ });
1914
+ }
1915
+ }
1916
+ else {
1917
+ return new Promise((resolve, reject) => {
1918
+ const newScript = document.createElement('script');
1919
+ newScript.src = url;
1920
+ newScript.async = true;
1921
+ newScript.id = url;
1922
+ newScript.addEventListener('load', () => {
1923
+ resolve(getNS(namespaceName));
1924
+ });
1925
+ newScript.addEventListener('error', (error) => {
1926
+ reject(error);
1927
+ });
1928
+ document.head.appendChild(newScript);
1929
+ });
1930
+ }
1931
+ };
1932
+ function useExternalNS(namespaceName, url, unmountNS = true) {
1933
+ const [externalNS, setExternalNS] = useState(undefined);
1909
1934
  useEffect(() => {
1910
- const handleResize = () => {
1911
- if (ref?.current) {
1912
- const { top } = ref.current.getBoundingClientRect();
1913
- const hasSpaceAbove = top > heightEl;
1914
- setSpaceAbove(hasSpaceAbove);
1935
+ let isMounted = true;
1936
+ initializeExternalNS(namespaceName, url)
1937
+ .then((ns) => {
1938
+ if (isMounted) {
1939
+ setExternalNS(ns);
1940
+ }
1941
+ })
1942
+ .catch((error) => {
1943
+ console.error(`Failed to initialize external namespace: ${error}`);
1944
+ });
1945
+ return () => {
1946
+ isMounted = false;
1947
+ if (unmountNS) {
1948
+ const script = document.getElementById(url);
1949
+ if (script) {
1950
+ document.head.removeChild(script);
1951
+ }
1952
+ setExternalNS(undefined);
1915
1953
  }
1916
1954
  };
1917
- handleResize();
1918
- window.addEventListener('resize', handleResize);
1919
- return () => window.removeEventListener('resize', handleResize);
1920
- }, [ref]);
1921
- return spaceAbove;
1955
+ }, [namespaceName, url, unmountNS]);
1956
+ return externalNS;
1957
+ }
1958
+
1959
+ const YMAPS_NAMESPACE = 'ymaps';
1960
+ const useYandexMaps = () => {
1961
+ const url = `https://api-maps.yandex.ru/2.1/?apikey=${projectSettings.YANDEX_MAP_API_KEY || ''}&lang=ru_RU`;
1962
+ return useExternalNS(YMAPS_NAMESPACE, url, false);
1922
1963
  };
1923
1964
 
1924
- const DAY_COUNT = 6;
1925
- const WEEK_COUNT = 7;
1926
- const renderCalendarCells = ({ today, firstDayOfWeek, totalDays, currentMonth, currentYear, min, max, onDateClick, }) => {
1927
- const calendarCells = [];
1928
- let dayCounter = 1;
1929
- for (let i = 0; i < DAY_COUNT; i++) {
1930
- const rowCells = [];
1931
- for (let j = 0; j < WEEK_COUNT; j++) {
1932
- if (i === 0 && j < firstDayOfWeek) {
1933
- rowCells.push(jsx("td", {}, `empty-${j}`));
1934
- }
1935
- else if (dayCounter > totalDays) {
1936
- rowCells.push(jsx("td", {}, `empty-${j}`));
1937
- }
1938
- else {
1939
- const currentDate = new Date(currentYear, currentMonth, dayCounter);
1940
- const isToday = checkIsToday(currentDate, today);
1941
- const isDisabled = checkIsDisabled(currentDate, min, max);
1942
- rowCells.push(jsx("td", { children: jsx("div", { className: getDayStyles(isToday, isDisabled), onClick: () => !isDisabled && onDateClick(currentDate), children: dayCounter }) }, `day-${dayCounter}`));
1943
- dayCounter++;
1944
- }
1945
- }
1946
- calendarCells.push(jsx("tr", { children: rowCells }, `row-${i}`));
1947
- }
1948
- return calendarCells;
1965
+ const styles = {
1966
+ ...defaultStyle,
1967
+ border: 'border-b border-b-2 border-gray last:border-0',
1968
+ position: 'relative flex items-center justify-center',
1949
1969
  };
1950
- const checkIsToday = (currentDate, today) => today && currentDate.toDateString() === today.toDateString();
1951
- const checkIsDisabled = (currentDate, min, max) => (min && currentDate.getTime() < min.getTime()) || (max && currentDate.getTime() > max.getTime());
1952
- const getDayStyles = (isToday = false, isDisabled = false) => style('p-s text-center rounded-md border', {
1953
- 'border-transparent hover:bg-gray': !isToday,
1954
- }, isDisabled ? 'text-gray hover:bg-transparent' : 'cursor-pointer');
1955
-
1956
- const WEEK_DAYS = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
1957
- const Calendar = JSX(({ today, currentMonth, currentYear, min, max, onDateSelect = noop, setValue = noop }) => {
1958
- const handleDateClick = useCallback((date) => {
1959
- onDateSelect(date);
1960
- setValue(false);
1961
- }, []);
1962
- const { firstDayOfWeek, totalDays } = useMemo(() => ({
1963
- firstDayOfWeek: new Date(currentYear, currentMonth, 1).getDay() - 1,
1964
- totalDays: new Date(currentYear, currentMonth + 1, 0).getDate(),
1965
- }), [currentYear, currentMonth]);
1966
- return (jsxs("table", { className: "mx-auto", children: [jsx("thead", { className: "text-gray font-light", children: jsx("tr", { children: WEEK_DAYS.map((day, index) => (jsx("th", { className: "p-s", children: day }, String(index)))) }) }), jsx("tbody", { children: renderCalendarCells({
1967
- firstDayOfWeek,
1968
- today,
1969
- totalDays,
1970
- currentYear,
1971
- currentMonth,
1972
- min,
1973
- max,
1974
- onDateClick: handleDateClick,
1975
- }) })] }));
1970
+ // TODO: Добавить метод определения центральной точки
1971
+ const ZoomButton = JSX(({ yandexMaps, direction = 'in' }) => {
1972
+ const iconName = direction === 'in' ? 'PlusIcon' : 'MinusIcon';
1973
+ const changeZoom = () => {
1974
+ const currentZoom = yandexMaps.current.getZoom();
1975
+ const newZoom = direction === 'in' ? currentZoom + 1 : currentZoom - 1;
1976
+ yandexMaps.current.setZoom(newZoom, { checkZoomRange: true });
1977
+ };
1978
+ return (jsx("div", { onClick: changeZoom, className: `${Object.values(styles).join(' ')} bg-white select-none cursor-pointer w-12 h-12`, children: jsx(Icon, { name: iconName, width: "20", height: "16" }) }));
1976
1979
  });
1977
1980
 
1978
- const months = [
1979
- 'Январь',
1980
- 'Февраль',
1981
- 'Март',
1982
- 'Апрель',
1983
- 'Май',
1984
- 'Июнь',
1985
- 'Июль',
1986
- 'Август',
1987
- 'Сентябрь',
1988
- 'Октябрь',
1989
- 'Ноябрь',
1990
- 'Декабрь',
1991
- ];
1992
-
1993
- function normalizeWithMask(value, pattern) {
1994
- const valueNumbers = value.replace(/\D/g, '');
1995
- if (valueNumbers === '' || value?.length === pattern.length) {
1996
- return value;
1997
- }
1998
- const patternInArr = [...pattern];
1999
- const firstPlaceholderIndex = patternInArr.findIndex(isPlaceholder$1);
2000
- const valueWildcardIndicies = patternInArr.map((_, i) => isWildcard$1(_) ? patternInArr.slice(0, i).filter(isWildcard$1).length : -1);
2001
- const applyPlaceholder = (_, i) => isDigit$1(_) ? _ : valueNumbers.charAt(valueWildcardIndicies[i]) || _;
2002
- const resultInArr = patternInArr.map(applyPlaceholder);
2003
- const resultLength = valueWildcardIndicies.indexOf(valueNumbers.length - 1) + 1;
2004
- return resultInArr.slice(0, Math.max(firstPlaceholderIndex, resultLength)).join('');
2005
- }
2006
- const isPlaceholder$1 = (_) => _ === '_';
2007
- const isDigit$1 = (_) => /\d/.test(_);
2008
- const isWildcard$1 = (_) => isPlaceholder$1(_) || isDigit$1(_);
2009
-
2010
- const START_YEAR = 1940;
2011
- const getYears = () => Array.from({ length: new Date().getFullYear() - START_YEAR + 1 }, (_, i) => START_YEAR + i);
2012
-
2013
- const ICON_PROPS$1 = {
2014
- name: 'CalendarIcon',
2015
- iconVersion: 'black',
2016
- width: '24',
2017
- height: '24',
2018
- };
2019
- const DatePickerInput = JSX(({ setSelectedMonth, setSelectedYear, className, value, disabled, onChange, onClick }) => {
2020
- const ref = useRef(null);
2021
- const [inputValue, setInputValue] = useState(value || '');
2022
- const handleChange = (ev) => {
2023
- const val = ev.target?.value;
2024
- if (typeof val === 'string' && val?.length < 11) {
2025
- setInputValue(normalizeWithMask(val, '__.__.____'));
2026
- }
2027
- };
2028
- const onBlur = () => {
2029
- if (checkIsValidDate(inputValue)) {
2030
- const [day, month, year] = inputValue.split('.');
2031
- onChange?.(new Date(Number(year), Number(month) - 1, Number(day)));
2032
- setSelectedMonth(Number(month) - 1);
2033
- setSelectedYear(Number(year));
1981
+ const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
1982
+ // TODO: Поле для поиска: невыяснено среди каких данных делать поиск (искать в имени офиса, в адресе, метро и т.д.).
1983
+ // Сейчас реализован поиск среди тестовых данных
1984
+ // TODO: Также выяснить что делать когда ничего не найдено
1985
+ // TODO: На макетах также когда есть поле поиска нет кнопки открыть на карте.
1986
+ const YandexMap = JSX(({ points, className = '', zoom = 5, isLoad, selectedAddress }) => {
1987
+ const map = useRef(null);
1988
+ const yandexMaps = useYandexMaps();
1989
+ useEffect(() => {
1990
+ if (map.current) {
1991
+ renderClusterer({ yandexMaps, map: map.current, points, isLoad, selectedAddress });
2034
1992
  }
2035
1993
  else {
2036
- setInputValue(value || '');
2037
- }
2038
- };
2039
- const onInputClick = () => {
2040
- if (ref.current !== null) {
2041
- ref.current.focus();
1994
+ yandexMaps?.ready(() => {
1995
+ // Ready function may be called few times, but must be called once
1996
+ if (map.current) {
1997
+ renderClusterer({ yandexMaps, map: map.current, points, isLoad });
1998
+ return;
1999
+ }
2000
+ map.current = new yandexMaps.Map('map', {
2001
+ center: getCenterPoint(points),
2002
+ zoom,
2003
+ controls: [],
2004
+ suppressMapOpenBlock: true,
2005
+ });
2006
+ renderClusterer({ yandexMaps, map: map.current, points, isLoad });
2007
+ });
2042
2008
  }
2043
- onClick?.();
2044
- };
2009
+ }, [yandexMaps, points, zoom, isLoad, selectedAddress]);
2045
2010
  useEffect(() => {
2046
- setInputValue(value || '');
2047
- }, [value]);
2048
- return (jsxs("div", { onClick: onInputClick, className: style('relative', className), children: [jsx("input", { ref: ref, className: "h-full w-full px-m text-l text-black focus-visible:outline-none", value: inputValue, type: "text", onChange: handleChange, onBlur: onBlur, disabled: disabled }), disabled ? null : jsx(Icon, { className: "mr-s", ...ICON_PROPS$1 })] }));
2049
- });
2050
- const isValidYear = (year) => Number(year) >= START_YEAR && Number(year) <= new Date().getFullYear();
2051
- const isValidMonth = (month) => Number(month) > 0 && Number(month) < 13;
2052
- const checkIsValidDate = (date) => {
2053
- const [day, month, year] = date.split('.');
2054
- if (isValidYear(year)) {
2055
- if (isValidMonth(month)) {
2056
- const currentDate = new Date(Number(year), Number(month) - 1, 1);
2057
- let maxDateOfMonth = 0;
2058
- while (currentDate.getMonth() === Number(month) - 1) {
2059
- currentDate.setDate(currentDate.getDate() + 1);
2060
- maxDateOfMonth++;
2061
- }
2062
- if (Number(day) > 0 && Number(day) <= maxDateOfMonth) {
2063
- return true;
2064
- }
2011
+ if (map.current && selectedAddress) {
2012
+ yandexMaps?.geocode(selectedAddress).then((res) => {
2013
+ const firstGeoObject = res.geoObjects.get(0);
2014
+ const coords = firstGeoObject.geometry.getCoordinates();
2015
+ map.current.setCenter(coords);
2016
+ map.current.setZoom(18);
2017
+ });
2065
2018
  }
2019
+ }, [selectedAddress]);
2020
+ if (!yandexMaps) {
2021
+ return null;
2066
2022
  }
2067
- return false;
2023
+ const zIndex = 'z-10';
2024
+ return (jsxs("div", { id: "map", className: style('relative', 'w-full', className), children: [isLoad ? jsx(Loader, {}) : null, jsxs("div", { className: style('absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md', zIndex), children: [jsx(ZoomButton, { yandexMaps: map }), jsx(ZoomButton, { yandexMaps: map, direction: "out" })] }), renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))] }));
2025
+ });
2026
+ const getCenterPoint = (points) => {
2027
+ const centerCoords = [
2028
+ getArraySumAndAverage(mapByIndex(points, 0)),
2029
+ getArraySumAndAverage(mapByIndex(points, 1)),
2030
+ ];
2031
+ return centerCoords.every((_) => _) ? centerCoords : DEFAULT_CENTER_COORDS;
2068
2032
  };
2033
+ const mapByIndex = (points, index) => points.map((_) => _.coords?.[index]);
2034
+ const getArraySumAndAverage = (arr) => arr.length && arr.reduce((a, b) => a + b) / arr.length;
2069
2035
 
2070
- const formStyle = 'flex justify-between items-center h-14 border rounded-md cursor-pointer ' +
2071
- 'hover:border-black active:border-black focus:border-black';
2072
- const renderDatePickerForm = ({ handleChangeVisibleCalendar, value, valid, onChange, setSelectedMonth, setSelectedYear, disabled = false, }) => (jsx(DatePickerInput, { onChange: onChange, disabled: disabled, onClick: handleChangeVisibleCalendar, value: value && formatDate(value), setSelectedMonth: setSelectedMonth, setSelectedYear: setSelectedYear, className: style(formStyle, valid ? 'border-gray' : 'border-error') }));
2036
+ async function doRequest(url, method, body) {
2037
+ const response = await fetch(`${API_BASE_URI}${url}`, {
2038
+ method,
2039
+ headers: {
2040
+ 'Content-Type': 'application/json',
2041
+ ...getAuthorizationHeaders(),
2042
+ },
2043
+ credentials: 'include',
2044
+ body: body ? JSON.stringify(body) : null,
2045
+ });
2046
+ // TODO: add error handling
2047
+ return isJSON(response) ? response.json() : response;
2048
+ }
2049
+ // TODO: Need delete isJSON
2050
+ const isJSON = (response) => response.headers.get('Content-Type') === 'application/json';
2051
+ const getAuthorizationHeaders = () => {
2052
+ const token = sessionStorage.getItem('accessToken');
2053
+ return token ? { Authorization: `Bearer ${token}` } : null;
2054
+ };
2073
2055
 
2074
- const MONTHS_COUNT = 11;
2075
- const MONTHS_OPTIONS = months.map((key) => ({ key }));
2076
- const YEARS_OPTIONS = getYears()
2077
- .reverse()
2078
- .map((key) => ({ key: String(key) }));
2079
- const useDatePickerManager = ({ onShowCalendar, showCalendar, selectedMonth, onMonthSelect, onYearSelect, selectedYear, onChange, value, }) => {
2080
- const close = useCallback(() => showCalendar && onShowCalendar(false), [showCalendar]);
2081
- const ref = useOutsideClick(close);
2082
- const handleChangeVisibleCalendar = useCallback(() => onShowCalendar(!showCalendar), [showCalendar]);
2083
- const handleNextMonth = useCallback(() => {
2084
- if (selectedMonth + 1 <= MONTHS_COUNT) {
2085
- onMonthSelect(selectedMonth + 1);
2086
- }
2087
- else {
2088
- onMonthSelect(0);
2089
- onYearSelect(selectedYear + 1);
2090
- }
2091
- }, [selectedMonth]);
2092
- const handlePrevMonth = useCallback(() => {
2093
- if (selectedMonth - 1 >= 0) {
2094
- onMonthSelect(selectedMonth - 1);
2095
- }
2096
- else {
2097
- onMonthSelect(11);
2098
- onYearSelect(selectedYear - 1);
2056
+ const regionOffices = async (regionKey) => {
2057
+ const response = await doRequest('/public-data/regionOffices', 'POST', {
2058
+ regionRfCd: {
2059
+ key: regionKey,
2060
+ },
2061
+ cashCardFlg: true,
2062
+ });
2063
+ return await response.json().then((_) => _?.offices?.map((office) => ({
2064
+ ...office,
2065
+ gpsLatitude: (office.latitude ?? DEFAULT_CENTER_COORDS[0]).toString().replace(',', '.'),
2066
+ gpsLongitude: (office.longitude ?? DEFAULT_CENTER_COORDS[1]).toString().replace(',', '.'),
2067
+ })));
2068
+ };
2069
+
2070
+ const Foldable = JSX(({ className = '', isFoldButtonOnTop = false, unfoldedByDefault = false, renderFoldableSection, renderFoldButton, }) => {
2071
+ const [isUnfolded, setIsUnfolded] = useState(unfoldedByDefault);
2072
+ const onToggle = useCallback(() => {
2073
+ setIsUnfolded((_) => !_);
2074
+ }, []);
2075
+ const sectionNode = renderFoldableSection({ isUnfolded, onToggle });
2076
+ const buttonNode = renderFoldButton ? renderFoldButton({ isUnfolded, onToggle }) : null;
2077
+ return isFoldButtonOnTop ? (jsxs("div", { className: className, role: "group", children: [buttonNode, sectionNode] })) : (jsxs("div", { className: className, role: "group", children: [sectionNode, buttonNode] }));
2078
+ });
2079
+
2080
+ function useResizeObserver(callback, deps) {
2081
+ const ref = useRef(null);
2082
+ useEffect(() => {
2083
+ const element = ref?.current;
2084
+ if (!element) {
2085
+ return undefined;
2099
2086
  }
2100
- }, [selectedMonth]);
2101
- const handleSelectMonth = useCallback(({ key }) => {
2102
- onMonthSelect(months.indexOf(key));
2103
- const maxDateOfMonth = calculateMaxDaysOfMonth(selectedYear, months.indexOf(key));
2104
- handleChangeMonth({
2105
- maxDateOfMonth,
2106
- selectedYear,
2107
- selectedMonth: months.indexOf(key),
2108
- value,
2109
- onChange,
2087
+ const observer = new ResizeObserver((entries) => {
2088
+ callback(element, entries[0]);
2110
2089
  });
2111
- }, [value]);
2112
- const handleSelectYear = useCallback(({ key }) => {
2113
- onYearSelect(Number(key));
2114
- value && onChange?.(new Date(Number(key), selectedMonth, value?.getDate()));
2115
- }, [value]);
2116
- return {
2117
- handleChangeVisibleCalendar,
2118
- handleNextMonth,
2119
- handlePrevMonth,
2120
- handleSelectMonth,
2121
- handleSelectYear,
2122
- monthsOptions: MONTHS_OPTIONS,
2123
- yearsOptions: YEARS_OPTIONS,
2124
- ref,
2125
- };
2090
+ observer.observe(element);
2091
+ return () => {
2092
+ observer.disconnect();
2093
+ };
2094
+ }, [callback, ...deps]);
2095
+ return ref;
2096
+ }
2097
+
2098
+ const FoldableSection = JSX(({ className = '', isUnfolded, children }) => {
2099
+ const containerRef = useRef(null);
2100
+ const childrenWrapperRef = useResizeObserver((childrenWrapperEl) => {
2101
+ if (containerRef.current) {
2102
+ containerRef.current.style.maxHeight = isUnfolded
2103
+ ? `${childrenWrapperEl.scrollHeight}px`
2104
+ : '';
2105
+ }
2106
+ }, [isUnfolded]);
2107
+ return (jsx("div", { ref: containerRef, className: `transition-max-h duration-300 overflow-hidden ${containerRef.current || !isUnfolded ? 'max-h-0' : ''} `, children: jsx("div", { className: className, ref: childrenWrapperRef, children: children }) }));
2108
+ });
2109
+
2110
+ const CardCell = JSX(({ value, subText, children, isPhone, ...props }) => {
2111
+ const textItems = (Array.isArray(value) ? value : value?.split(',') ?? []).filter(Boolean);
2112
+ if ([textItems.length, children, subText].every((_) => !_)) {
2113
+ return null;
2114
+ }
2115
+ return renderCardCell({ textItems, subText, children, isPhone, ...props });
2116
+ });
2117
+ const renderCardCell = ({ label, labelSize = 'text-m', textItems, subColor, subText, className, children, isPhone = false, }) => (jsxs("div", { className: style('flex gap-2xs flex-col h-full max-w-[300px]', className), children: [label ? (jsx(Text, { color: "text-secondary-text", font: "font-light", size: labelSize, children: label })) : null, children || renderTextItems(textItems, isPhone), subText ? (jsx(Text, { color: subColor, size: "text-m", children: subText })) : null] }));
2118
+ const renderTextItems = (textItems, isPhone) => textItems.filter(Boolean).map((text, i) => (jsx(Text, { size: "text-l", children: isPhone ? jsx("a", { href: `tel:${cleanPhoneNumber(text)}`, children: text.trim() }) : text.trim() }, String(i))));
2119
+ const cleanPhoneNumber = (phone) => phone.replace(/\D/g, '');
2120
+
2121
+ const CardRow = JSX(({ className, children }) => (jsx("div", { className: style('flex flex-col sm:flex-row sm:border-t sm:border-solid sm:border-main-divider py-xl gap-x-6xl gap-y-xl', className), children: children })));
2122
+
2123
+ const getScheduleDescription = (workScheduleWeek) => {
2124
+ const rows = getDateDescription(workScheduleWeek);
2125
+ return jsx(CardCell, { label: "\u0420\u0435\u0436\u0438\u043C \u0440\u0430\u0431\u043E\u0442\u044B", value: rows, className: "max-w-none" });
2126
2126
  };
2127
- const calculateMaxDaysOfMonth = (selectedYear, selectedMonth) => {
2128
- const date = new Date(selectedYear, selectedMonth, 1);
2129
- let maxDateOfMonth = 0;
2130
- while (date.getMonth() === selectedMonth) {
2131
- maxDateOfMonth++;
2132
- date.setDate(date.getDate() + 1);
2127
+ const buildScheduleText = ({ workTime = '', lunchHour = '', daysOff = '' }, isSaturday = false) => {
2128
+ if (!workTime) {
2129
+ return '';
2133
2130
  }
2134
- return maxDateOfMonth;
2131
+ return [
2132
+ `${isSaturday ? 'Суббота' : 'Будние дни'}: ${workTime}`,
2133
+ lunchHour ? `перерыв: ${lunchHour}` : '',
2134
+ daysOff ? `не работает: ${daysOff}` : '',
2135
+ ]
2136
+ .filter(Boolean)
2137
+ .join('; ');
2135
2138
  };
2136
- const handleChangeMonth = ({ maxDateOfMonth, selectedYear, selectedMonth, value, onChange, }) => {
2137
- value &&
2138
- onChange?.(new Date(selectedYear, selectedMonth, Math.min(maxDateOfMonth, value.getDate())));
2139
+ const getDateDescription = (workScheduleWeek) => {
2140
+ const workingWeekday = workScheduleWeek.find((_) => _.key !== 'workingSaturday' && Boolean(_.status) && Boolean(_.workTime));
2141
+ const workingSaturday = workScheduleWeek.find((_) => _.key === 'workingSaturday' && Boolean(_.status) && Boolean(_.workTime));
2142
+ const daysOff = workScheduleWeek
2143
+ .filter((_) => !_.status)
2144
+ .map((_) => _.short?.toLowerCase())
2145
+ .join(', ');
2146
+ const rows = [
2147
+ buildScheduleText({
2148
+ workTime: workingWeekday?.workTime,
2149
+ lunchHour: workingWeekday?.lunchHour,
2150
+ daysOff: workingSaturday ? '' : daysOff,
2151
+ }),
2152
+ buildScheduleText({ workTime: workingSaturday?.workTime, lunchHour: workingSaturday?.lunchHour, daysOff }, true),
2153
+ ].filter(Boolean);
2154
+ return rows;
2139
2155
  };
2140
2156
 
2141
- const ICON_PROPS = {
2142
- name: 'ArrowUpIcon',
2143
- iconVersion: 'black',
2144
- width: '24',
2145
- height: '24',
2157
+ const WEEKDAY_MAP = [
2158
+ ['workingMonday', 'Пн', 'Понедельник'],
2159
+ ['workingTuesday', 'Вт', 'Вторник'],
2160
+ ['workingWednesday', 'Ср', 'Среда'],
2161
+ ['workingThursday', 'Чт', 'Четверг'],
2162
+ ['workingFriday', 'Пт', 'Пятница'],
2163
+ ['workingSaturday', 'Сб', 'Суббота'],
2164
+ ['workingSunday', 'Вс', 'Воскресенье'],
2165
+ ];
2166
+ const getWorkScheduleWeek = (workSchedule) => WEEKDAY_MAP.map(([key, short, title]) => ({
2167
+ key,
2168
+ title,
2169
+ short,
2170
+ status: Boolean(workSchedule?.[key]),
2171
+ get workTime() {
2172
+ return key === 'workingSaturday' ? workSchedule?.workTimeSaturday : workSchedule?.workTime;
2173
+ },
2174
+ get lunchHour() {
2175
+ return key === 'workingSaturday' ? workSchedule?.lunchHourSaturday : workSchedule?.lunchHour;
2176
+ },
2177
+ get hasLunch() {
2178
+ return /\d+/.test(this.lunchHour ?? '');
2179
+ },
2180
+ }));
2181
+
2182
+ const renderBusinessSchedule = (scheduleDescription) => {
2183
+ if (!scheduleDescription) {
2184
+ return null;
2185
+ }
2186
+ const businessSchedule = getBusinessSchedule(scheduleDescription);
2187
+ return (jsxs(CardRow, { className: "border-none", children: [jsx(CardCell, { label: "\u0414\u043B\u044F \u044E\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446", labelSize: "text-l", children: jsx("div", { className: "flex gap-1", children: businessSchedule.map(renderAlternativeDay) }) }), jsx(CardCell, { label: "\u0420\u0435\u0436\u0438\u043C \u0440\u0430\u0431\u043E\u0442\u044B", className: "max-w-none", children: jsx(Text, { children: scheduleDescription }) })] }));
2146
2188
  };
2147
- const SELECT_PROPS = {
2148
- className: 'min-w-32',
2149
- iconVersion: 'black',
2150
- isBorder: false,
2189
+ const getBusinessSchedule = (scheduleDescription) => {
2190
+ const weekDayMap = WEEKDAY_MAP.map(([, short]) => ({ short, status: true }));
2191
+ const splittedScheduleDescription = scheduleDescription.split('/') ?? [];
2192
+ const lastPartScheduleDescription = splittedScheduleDescription[splittedScheduleDescription.length - 1]?.toLowerCase();
2193
+ if (!lastPartScheduleDescription?.includes('выходной')) {
2194
+ return weekDayMap;
2195
+ }
2196
+ return weekDayMap.map((_) => ({
2197
+ ..._,
2198
+ status: !lastPartScheduleDescription?.includes(_.short.toLowerCase()),
2199
+ }));
2151
2200
  };
2152
- const DatePicker = JSX(
2153
- // eslint-disable-next-line max-lines-per-function
2154
- ({ className = '', label = '', value, valid = true, minDate, maxDate, disabled, onChange }) => {
2155
- const [showCalendar, { setValue }] = useBool(false);
2156
- const [selectedMonth, setSelectedMonth] = useState(value?.getMonth() || new Date().getMonth());
2157
- const [selectedYear, setSelectedYear] = useState(value?.getFullYear() || new Date().getFullYear());
2158
- const { handlePrevMonth, handleNextMonth, handleSelectMonth, handleSelectYear, monthsOptions, yearsOptions, handleChangeVisibleCalendar, ref, } = useDatePickerManager({
2159
- onYearSelect: setSelectedYear,
2160
- onMonthSelect: setSelectedMonth,
2161
- onShowCalendar: setValue,
2162
- selectedYear,
2163
- selectedMonth,
2164
- showCalendar,
2165
- onChange,
2166
- value,
2167
- });
2168
- const spaceAbove = useElementSpace(ref, 370);
2169
- return (jsxs("div", { className: style('space-y-xs', className), ref: ref, children: [renderLabel(label), jsxs("div", { className: "relative", children: [renderDatePickerForm({
2170
- handleChangeVisibleCalendar,
2171
- value,
2172
- valid,
2173
- onChange,
2174
- disabled,
2175
- setSelectedMonth,
2176
- setSelectedYear,
2177
- }), showCalendar && !disabled ? (jsxs("div", { className: style('absolute bg-white z-20 select-none', {
2178
- 'bottom-full': spaceAbove,
2179
- }), children: [jsxs("div", { className: "flex gap-s", children: [jsx("div", { className: "my-auto", onClick: handlePrevMonth, children: jsx(Icon, { ...ICON_PROPS, className: "-rotate-90 cursor-pointer" }) }), jsx(Select, { onChange: handleSelectMonth, value: { key: months[selectedMonth] }, options: monthsOptions, ...SELECT_PROPS }), jsx(Select, { onChange: handleSelectYear, value: { key: String(selectedYear) }, options: yearsOptions, ...SELECT_PROPS }), jsx("div", { className: "my-auto", onClick: handleNextMonth, children: jsx(Icon, { ...ICON_PROPS, className: "rotate-90 cursor-pointer" }) })] }), jsx(Calendar, { today: value, currentMonth: selectedMonth, currentYear: selectedYear, onDateSelect: onChange, min: minDate, max: maxDate, setValue: setValue })] })) : null] })] }));
2180
- });
2201
+ const renderAlternativeDay = ({ short, status }, i) => (jsx("div", { className: style('w-9 h-9 rounded-md flex items-center justify-center', status ? 'bg-green-more-light text-green-dark' : 'bg-error/30 text-error'), children: jsx(Text, { size: "text-xs", children: short }) }, String(i)));
2181
2202
 
2182
- const DatePickerControl = JSX(({ className, label, error, errors, ...rest }) => (jsxs("div", { className: style('shrink-0 w-full', className), children: [jsx(DatePicker, { label: getRequiredLabel({ label, errors }), valid: Boolean(!error), ...rest }), renderErrorText(error)] })));
2203
+ const renderCurrency = ({ currency, buyExchangeRate, saleExchangeRate }, i) => (jsxs("div", { className: "flex gap-lg h-full", children: [currency?.currency ? jsx(CardCell, { label: "\u0412\u0430\u043B\u044E\u0442\u0430", value: currency.currency }) : null, buyExchangeRate ? jsx(CardCell, { label: "\u041A\u0443\u043F\u0438\u0442\u044C", value: String(buyExchangeRate) }) : null, saleExchangeRate ? jsx(CardCell, { label: "\u041F\u0440\u043E\u0434\u0430\u0442\u044C", value: String(saleExchangeRate) }) : null] }, String(i)));
2183
2204
 
2184
- const BeginDateField = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u043D\u0430\u0447\u0430\u043B\u0430 \u0440\u0430\u0431\u043E\u0442\u044B \u043D\u0430 \u0442\u0435\u043A\u0443\u0449\u0435\u043C \u043C\u0435\u0441\u0442\u0435", ...getValidation(field('beginDate'), validatorObj.beginDate, input?.required), ...input })));
2205
+ const colorStyle = {
2206
+ yellow: { border: 'border-yellow-light', text: 'text-yellow' },
2207
+ green: { border: 'border-green-more-light', text: 'text-green-dark' },
2208
+ gray: { border: 'border-gray', text: 'text-secondary-text' },
2209
+ red: { border: 'border-error/30', text: 'text-error' },
2210
+ };
2211
+ const Badge$1 = JSX(({ className, children, color = 'gray' }) => (jsxs("div", { className: style('sm:p-s sm:border sm:border-green rounded-md flex items-center h-fit', colorStyle[color].border, className), children: [jsx("div", { className: "block pr-m sm:pr-0 sm:hidden", children: jsx(Img, { image: { icon: 'SmallClockIcon' }, width: "24", height: "24" }) }), jsx(Text, { size: "text-m", color: colorStyle[color].text, children: children })] })));
2185
2212
 
2186
- const MIN_AGE = 23;
2187
- const MAX_AGE = 75;
2188
- const AGE_ERROR_MESSAGE = 'Допустимый возраст заёмщика - от 23 до 75 лет';
2189
- const FIELD_NAME$8 = 'birthday';
2190
- const BirthdayField = JSX(({ field, input, isRetailForm = false }) => {
2191
- const { value } = field(FIELD_NAME$8);
2192
- return (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u0440\u043E\u0436\u0434\u0435\u043D\u0438\u044F", ...getValidation(field(FIELD_NAME$8), validatorObj.birthday, input?.required), error: isRetailForm && value && !birthdayValidate(value) ? AGE_ERROR_MESSAGE : '', disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$8) }));
2193
- });
2194
- const birthdayValidate = (date) => {
2195
- const today = new Date();
2196
- const minDate = new Date(today.getFullYear() - MIN_AGE, today.getMonth(), today.getDate());
2197
- const maxDate = new Date(today.getFullYear() - MAX_AGE, today.getMonth(), today.getDate());
2198
- if (!date || date > minDate || date < maxDate) {
2199
- return false;
2213
+ const currentWeekDayIdx = new Date().getDay();
2214
+ //TODO: Add logic time https://github.com/redneckz/wildless-cms-uni-blocks/pull/1549
2215
+ const renderCurrentDaySchedule = (workScheduleWeek) => {
2216
+ const [currentWeekDay] = workScheduleWeek?.slice(currentWeekDayIdx - 1) ?? [];
2217
+ if (!currentWeekDay) {
2218
+ return null;
2200
2219
  }
2201
- return true;
2220
+ const { lunchHour, status, workTime, hasLunch } = currentWeekDay;
2221
+ return status ? (jsxs("div", { className: "flex gap-s items-start whitespace-nowrap", children: [workTime ? jsx(Badge$1, { color: "green", children: workTime }) : null, lunchHour && hasLunch ? jsx(Badge$1, { color: "yellow", children: `перерыв: ${lunchHour}` }) : null] })) : (jsx(Badge$1, { color: "red", children: "\u0412\u044B\u0445\u043E\u0434\u043D\u043E\u0439" }));
2202
2222
  };
2203
2223
 
2204
- const FIELD_NAME$7 = 'birthPlace';
2205
- const BirthPlaceField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041C\u0435\u0441\u0442\u043E \u0440\u043E\u0436\u0434\u0435\u043D\u0438\u044F", ...getValidation(field('birthPlace'), validatorObj.birthPlace, input?.required), ...input, disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$7) })));
2206
-
2207
- const CardCategoryField = JSX(({ field, input }) => {
2208
- const { data: cardCategory } = useLeadFormData('CARD_TYPE');
2209
- return (jsx(SelectField, { field: field, source: cardCategory, label: "\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F \u043A\u0430\u0440\u0442\u044B", fieldName: "cardCategory", input: input }));
2210
- });
2211
-
2212
- const ChildrenField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0434\u0435\u0442\u0435\u0439 \u0434\u043E 18 \u043B\u0435\u0442", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", ...getValidation(field('children'), validatorObj.children, input?.required), ...input })));
2213
-
2214
- const CodeWordField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u0434\u043E\u0432\u043E\u0435 \u0441\u043B\u043E\u0432\u043E", ...getValidation(field('codeWord'), validatorObj.codeWord, input?.required), ...input })));
2215
-
2216
- const CollectionCountField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432 \u0438\u043D\u043A\u0430\u0441\u0441\u0430\u0446\u0438\u0438", type: "number", ...getValidation(field('collectionCount'), validatorObj.collectionCount, input?.required) })));
2224
+ const getSubTextLunch = ({ lunchHour, hasLunch = false, status = false }) => {
2225
+ if (!status) {
2226
+ return 'Не работает';
2227
+ }
2228
+ return lunchHour && hasLunch ? `Перерыв ${lunchHour}` : lunchHour;
2229
+ };
2230
+ const renderDay = ({ title, status, workTime, lunchHour, hasLunch }, i) => (jsx(CardCell, { label: title, value: status && workTime ? workTime : '', subText: getSubTextLunch({ lunchHour, hasLunch, status }), subColor: !status || hasLunch ? 'text-error' : 'text-green-dark' }, String(i)));
2217
2231
 
2218
- const CommentField = JSX(({ field, input }) => (jsx(InputControl, { className: "col-span-2", ...getValidation(field('comment'), validatorObj.comment, input?.required), placeholder: "\u0412\u0430\u0448\u0435 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435", isTextarea: true })));
2232
+ const ICONS$1 = ['ArrowDownIcon', 'ArrowUpIcon'];
2233
+ const labels = ['Подробнее', 'Скрыть'];
2234
+ const renderFoldButton$3 = ({ isUnfolded, onToggle }) => (jsxs("button", { className: "w-full py-2xl cursor-pointer text-primary-main flex items-center border-b border-solid border-main-divider", onClick: onToggle, type: "button", children: [jsx("div", { className: "pr-m", children: labels[Number(isUnfolded)] }), jsx(Icon, { className: "text-primary-text", name: ICONS$1[Number(isUnfolded)], width: "16", height: "16" })] }));
2219
2235
 
2220
- const ConfirmationIncomeField = JSX(({ field, input }) => {
2221
- const { data: confirmationIncome } = useLeadFormData('INCOME_CERT_UNITED');
2222
- return (jsx(SelectField, { field: field, source: confirmationIncome, label: "\u0421\u043F\u043E\u0441\u043E\u0431 \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u044F \u0434\u043E\u0445\u043E\u0434\u0430", fieldName: "confirmationIncome", input: input }));
2223
- });
2236
+ const renderWorkSchedule = (workSchedule) => {
2237
+ const workScheduleWeek = getWorkScheduleWeek(workSchedule);
2238
+ const timeOfWork = workSchedule ? getDateDescription(workScheduleWeek) : '';
2239
+ const businessTimeOfWork = workSchedule ? workSchedule.businessScheduleDescription : '';
2240
+ if (!workSchedule) {
2241
+ return '';
2242
+ }
2243
+ if (!workSchedule.businessScheduleVisibleTag) {
2244
+ return renderMatchingTimeOfWork(timeOfWork);
2245
+ }
2246
+ if (workSchedule.businessScheduleVisibleTag &&
2247
+ workSchedule.businessScheduleDescription === null) {
2248
+ return renderIndividualTimeOfWork(timeOfWork);
2249
+ }
2250
+ return renderDefaultTimeOfWork(timeOfWork, businessTimeOfWork);
2251
+ };
2252
+ const renderIndividualTimeOfWork = (timeOfWork) => `<p><b>Режим обслуживания физ.лиц:<br/></b>${timeOfWork}</p>`;
2253
+ const renderMatchingTimeOfWork = (timeOfWork) => `<p><b>Режим обслуживания физ. и юр. лиц:<br/></b> ${timeOfWork}</p>`;
2254
+ const renderDefaultTimeOfWork = (timeOfWork, businessTimeOfWork) => `<p><b>Режим обслуживания физ.лиц:<br/></b>${timeOfWork}</p> <p><b>Режим обслуживания юр.лиц:<br/></b>${businessTimeOfWork}</p>`;
2224
2255
 
2225
- const ConscriptionField = JSX(({ field, input }) => {
2226
- const { data: conscription } = useLeadFormData('MILITARY_STATUS');
2227
- return (jsx(SelectField, { field: field, source: conscription, label: "\u0421\u0442\u0430\u0442\u0443\u0441 \u0432\u043E\u0435\u043D\u043D\u043E\u043E\u0431\u044F\u0437\u0430\u043D\u043D\u043E\u0433\u043E", fieldName: "conscription", input: input }));
2228
- });
2229
-
2230
- const CONSENTS = {
2231
- processPersonalDataFlg: {
2232
- text: 'Согласие на обработку персональных данных',
2233
- docId: 4,
2234
- },
2235
- consentInformFlg: {
2236
- text: 'Согласие на информирование о продуктах и услугах Банка',
2237
- docId: 14,
2238
- },
2239
- consentProviderFlg: {
2240
- text: 'Согласие об использовании простой электронной подписи',
2241
- docId: 5,
2242
- },
2243
- consentOthersFlg: {
2244
- text: 'Прочие согласия',
2245
- docId: 1,
2246
- },
2247
- consentPfrFlg: {
2248
- text: 'Согласие на запрос в ПФР',
2249
- docId: 3,
2250
- },
2251
- consentToReceiveMaterials: {
2252
- text: 'Согласен на получение информационных и аналитических материалов по электронной почте',
2253
- },
2254
- };
2255
-
2256
- async function doRequest(url, method, body) {
2257
- const response = await fetch(`${API_BASE_URI}${url}`, {
2258
- method,
2259
- headers: {
2260
- 'Content-Type': 'application/json',
2261
- ...getAuthorizationHeaders(),
2262
- },
2263
- credentials: 'include',
2264
- body: body ? JSON.stringify(body) : null,
2265
- });
2266
- // TODO: add error handling
2267
- return isJSON(response) ? response.json() : response;
2268
- }
2269
- // TODO: Need delete isJSON
2270
- const isJSON = (response) => response.headers.get('Content-Type') === 'application/json';
2271
- const getAuthorizationHeaders = () => {
2272
- const token = sessionStorage.getItem('accessToken');
2273
- return token ? { Authorization: `Bearer ${token}` } : null;
2256
+ const renderOfficeCard = ({ name, address, phone, fax, phoneBusiness, phoneNatural, phoneCallCentre, phoneCurrencyControl, workSchedule, exchangeRate, }, i) => {
2257
+ if (!workSchedule) {
2258
+ return null;
2259
+ }
2260
+ const workScheduleWeek = getWorkScheduleWeek(workSchedule);
2261
+ return (jsxs("div", { className: "bg-white col-span-12 p-3xl sm:border-green sm:border", children: [jsxs("div", { className: "sm:flex sm:justify-between", children: [jsxs("div", { children: [jsx(Text, { size: "text-h4", children: name }), address ? (jsxs("div", { className: "flex pb-xl pt-xs gap-2xs", children: [jsx(Icon, { name: "GeolocationIcon", width: "24", height: "24" }), jsx(Text, { size: "text-l", children: address })] })) : null] }), renderCurrentDaySchedule(workScheduleWeek)] }), jsx("div", { className: "hidden sm:block", children: renderCardContent$1({
2262
+ phone,
2263
+ fax,
2264
+ phoneBusiness,
2265
+ phoneNatural,
2266
+ phoneCallCentre,
2267
+ phoneCurrencyControl,
2268
+ workSchedule,
2269
+ exchangeRate,
2270
+ }) }), jsx(Foldable, { className: "block sm:hidden", renderFoldableSection: ({ isUnfolded }) => {
2271
+ return (jsx(FoldableSection, { isUnfolded: isUnfolded, children: renderCardContent$1({
2272
+ phone,
2273
+ fax,
2274
+ phoneBusiness,
2275
+ phoneNatural,
2276
+ phoneCallCentre,
2277
+ phoneCurrencyControl,
2278
+ workSchedule,
2279
+ exchangeRate,
2280
+ }) }));
2281
+ },
2282
+ //** TODO: remove styles with refactoring DefaultFoldButton*/
2283
+ renderFoldButton: ({ isUnfolded, onToggle }) => renderFoldButton$3({ isUnfolded, onToggle }) })] }, String(i)));
2274
2284
  };
2275
-
2276
- const feedbackById = async (id, convertToPng = false) => {
2277
- const response = await doRequest(`/feedback/file?id=${encodeURIComponent(id)}&convertToPngFlg=${convertToPng}`, 'GET');
2278
- return await response.blob();
2285
+ const renderCardContent$1 = ({ phone, fax, phoneBusiness, phoneNatural, phoneCallCentre, phoneCurrencyControl, workSchedule, exchangeRate, }) => {
2286
+ const workScheduleWeek = getWorkScheduleWeek(workSchedule);
2287
+ const labelSchedule = workSchedule?.businessScheduleVisibleTag
2288
+ ? 'Для физических лиц'
2289
+ : 'Для физических и юридических лиц';
2290
+ return (jsxs("div", { children: [jsxs(CardRow, { className: "flex-wrap border-b border-solid border-main-divider", children: [jsx(CardCell, { label: "\u0424\u0430\u043A\u0441", value: fax, isPhone: true }), jsx(CardCell, { label: "\u0422\u0435\u043B\u0435\u0444\u043E\u043D \u0444\u0438\u043B\u0438\u0430\u043B\u0430", value: phone, isPhone: true }), jsx(CardCell, { label: "\u0414\u043B\u044F \u043E\u0431\u0440\u0430\u0449\u0435\u043D\u0438\u0439 \u044E\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446", value: phoneBusiness, isPhone: true }), jsx(CardCell, { label: "\u041E\u0431\u0441\u043B\u0443\u0436\u0438\u0432\u0430\u043D\u0438\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446", value: phoneNatural, isPhone: true }), jsx(CardCell, { label: "\u0414\u043B\u044F \u043A\u043E\u043D\u0441\u0443\u043B\u044C\u0442\u0430\u0446\u0438\u0439 \u043F\u043E \u0432\u0430\u043B\u044E\u0442\u043D\u043E\u043C\u0443 \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044E", value: phoneCurrencyControl, isPhone: true }), jsx(CardCell, { label: "\u041A\u043E\u043D\u0442\u0430\u043A\u0442-\u0446\u0435\u043D\u0442\u0440", value: phoneCallCentre, isPhone: true })] }), workSchedule?.isMatchesPattern ? (jsx(CardRow, { children: jsx(CardCell, { label: labelSchedule, labelSize: "text-l", className: "w-full max-w-none", children: jsx("div", { className: "flex flex-wrap gap-xs sm:justify-between pt-xs", children: workScheduleWeek?.map(renderDay) }) }) })) : (jsxs(CardRow, { children: [jsx(CardCell, { label: labelSchedule, labelSize: "text-l", children: jsx("div", { className: "flex gap-1", children: workScheduleWeek?.map(renderAlternativeDay) }) }), getScheduleDescription(workScheduleWeek)] })), workSchedule?.businessScheduleVisibleTag
2291
+ ? renderBusinessSchedule(workSchedule?.businessScheduleDescription)
2292
+ : null, exchangeRate?.currencies?.length ? (jsx(CardRow, { className: "flex-wrap", children: exchangeRate?.currencies?.map(renderCurrency) })) : null] }));
2279
2293
  };
2280
-
2281
- const getDocument = async (id, convertToPng = false) => {
2282
- const response = await feedbackById(id, convertToPng);
2283
- return URL.createObjectURL(response);
2294
+ const capitalizedFirstLetter$1 = (text) => text ? `${text?.charAt(0)?.toUpperCase()}${text?.slice(1)}` : '';
2295
+ const getOfficePoint = ({ name = '', address = '', workSchedule }) => {
2296
+ const header = capitalizedFirstLetter$1(name);
2297
+ const body = `${address} ${renderWorkSchedule(workSchedule)}`;
2298
+ return { header, body };
2284
2299
  };
2285
2300
 
2286
- const CloseButton = JSX(({ className, onClose }) => (jsx("button", { className: style('flex justify-center items-center w-12 h-12 p-2xs bg-transparent border-none', className), onClick: onClose, title: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C", type: "button", children: jsx(Icon, { name: "CloseIcon", width: "20", height: "20", iconVersion: "gray" }) })));
2301
+ const isSSR = () => Boolean(typeof globalThis.process === 'object' && globalThis.process && globalThis.process.version);
2287
2302
 
2288
- const Dialog = JSX(({ className, head, children, onClose, onClick }) => {
2289
- const { close } = useDialogManager();
2290
- const handleClose = useCallback(() => {
2291
- close();
2292
- onClose && onClose();
2293
- }, [onClose]);
2294
- return (jsxs("div", { onClick: onClick, className: style('relative min-h-full bg-white pt-0 p-lg', className), role: "dialog", children: [jsxs("div", { className: "sticky py-xl top-0 bg-white z-10", children: [jsx(CloseButton, { className: "absolute top-0 right-0", onClose: handleClose }), jsx("div", { className: "container", children: head })] }), jsx("div", { className: "container pb-6xl", children: children })] }));
2295
- });
2303
+ const isClient = !isSSR();
2304
+ const ClientOnly = JSX(({ children }) => (isClient ? children : null));
2296
2305
 
2297
- const openDocument = async (open, id, convertToPng = false) => {
2298
- const document = await getDocument(id, convertToPng);
2299
- open(jsx(Dialog, { className: "my-6xl max-w-4xl mx-auto px-0 min-h-0 pb-0", children: convertToPng ? (jsx("img", { src: document })) : (jsx("iframe", { src: `${document}#toolbar=0`, className: "w-full h-[80vh]", id: "iframe-dialog" })) }));
2306
+ const INITIAL_FILTRATION_STATE$1 = {
2307
+ workingSaturday: false,
2308
+ premiumService: false,
2309
+ privateBanking: false,
2310
+ remoteWorkplace: false,
2311
+ serviceDisabledPeople: false,
2312
+ sellingCoins: false,
2313
+ buyingCoins: false,
2314
+ bullionOperations: false,
2315
+ preciousMetalsOperations: false,
2316
+ transferringDataToBiometricSystem: false,
2300
2317
  };
2301
-
2302
- const OPEN_DOC_BUTTON_TEXT = 'Ознакомиться';
2303
- const CheckboxWithDoc = JSX(({ className, error, docId, ...props }) => {
2304
- const { open } = useDialogManager();
2305
- const isMobile = useMobileMode();
2306
- return (jsxs("div", { className: className, children: [jsxs("div", { className: "flex flex-wrap gap-x-m", children: [jsx(Checkbox, { ...props }), docId ? (jsx(LinkButton, { className: "text-primary-main", onClick: () => openDocument(open, docId, isMobile), children: jsx(Text, { children: OPEN_DOC_BUTTON_TEXT }) })) : null] }), renderErrorText(error)] }));
2307
- });
2308
-
2309
- const ConsentField = JSX(({ field, input }) => input && input.name ? (jsx(CheckboxWithDoc, { text: CONSENTS[input.name]?.text, docId: CONSENTS[input.name]?.docId, ...getValidation(field(input.name), validatorObj[input.name], input?.required) })) : null);
2310
-
2311
- const LABEL_TEXT = `Имеет ли юридическое лицо, акционером / участником / членом / пайщиком /
2312
- вкладчиком с долей участия более 20% уставного капитала руководителем,
2313
- которого Вы являетесь, кредит в АО «Россельхозбанк»`;
2314
- const CreditInRshbCdField = JSX(({ field, input }) => {
2315
- const { data: creditInRshbCd } = useLeadFormData('CREDIT_IN_RSHB');
2316
- return (jsx(SelectField, { field: field, source: creditInRshbCd, label: LABEL_TEXT, fieldName: "creditInRshbCd", input: input }));
2317
- });
2318
-
2319
- const orientationStyleMap = {
2320
- horizontal: '@lg:flex-row',
2321
- vertical: '',
2318
+ const FILTRATION_LABELS = {
2319
+ safeBoxCaseVolumes: 'Аренда индивидуальных сейфовых ячеек',
2320
+ workingSaturday: 'Открыты по субботам',
2321
+ terminalTypeAtms: 'Банкоматы',
2322
+ terminalTypeTerm: 'Терминалы',
2323
+ workAllTime: 'Круглосуточно',
2324
+ billAcceptorEnable: 'Прием наличных',
2325
+ premiumService: 'Премиальное обслуживание',
2326
+ privateBanking: 'Услуга Private banking',
2327
+ sellingCoins: 'Продажа монет из драгоценных металлов',
2328
+ buyingCoins: 'Покупка монет из драгоценных металлов',
2329
+ bullionOperations: 'Операции со слитками',
2330
+ preciousMetalsOperations: 'Операции с драгоценными металлами',
2331
+ transferringDataToBiometricSystem: 'Передача фото и голоса в Единую биометрическую систему',
2332
+ locationDisabledPeople: 'Для маломобильных',
2333
+ designDisabledPeople: 'Для слабовидящих',
2334
+ remoteWorkplace: 'Удаленное рабочее место',
2335
+ serviceDisabledPeople: 'Для маломобильных граждан',
2336
+ };
2337
+ const FILTRATION_PREDICATES$1 = {
2338
+ workingSaturday: (item) => Boolean('workSchedule' in item && item.workSchedule?.workingSaturday),
2339
+ premiumService: (item) => Boolean('premiumService' in item && item.premiumService),
2340
+ privateBanking: (item) => Boolean('privateBanking' in item && item.privateBanking),
2341
+ remoteWorkplace: (item) => Boolean('workScheduleDescription' in item),
2342
+ serviceDisabledPeople: (item) => Boolean('serviceDisabledPeople' in item && item.serviceDisabledPeople),
2343
+ sellingCoins: (item) => Boolean('sellingCoins' in item && item.sellingCoins),
2344
+ buyingCoins: (item) => Boolean('buyingCoins' in item && item.buyingCoins),
2345
+ bullionOperations: (item) => Boolean('bullionOperations' in item && item.bullionOperations),
2346
+ preciousMetalsOperations: (item) => Boolean('preciousMetalsOperations' in item && item.preciousMetalsOperations),
2347
+ transferringDataToBiometricSystem: (item) => Boolean('transferringDataToBiometricSystem' in item && item.transferringDataToBiometricSystem),
2322
2348
  };
2323
- const RadioButtonGroup = JSX(({ label, items, value, className, onChange: onChangeCheckedItem, disabled = false, orientation = 'horizontal', }) => (jsxs("div", { className: "grid gap-xs whitespace-nowrap", children: [label ? (jsx("div", { role: "radiogroup", "aria-label": label, children: jsx(Text, { color: "text-secondary-text", font: "font-light", children: label }) })) : null, jsx("div", { className: style('flex flex-col gap-s', orientationStyleMap[orientation], className), role: "radiogroup", "aria-label": "\u0413\u0440\u0443\u043F\u043F\u0430 \u043A\u043D\u043E\u043F\u043E\u043A", children: items?.map(({ id, text }) => (jsx(Checkbox, { isRadio: true, text: text, value: value === id, onChange: () => onChangeCheckedItem && onChangeCheckedItem(id), disabled: disabled }, String(id)))) })] })));
2324
2349
 
2325
- const RadioButtonGroupControl = JSX(({ className, label, onChange, error, ...rest }) => (jsxs("div", { className: style('shrink-0 w-full', className), children: [jsx(RadioButtonGroup, { label: getRequiredLabel({ label, errors: rest?.errors }), onChange: (_) => onChange && onChange(_), ...rest }), renderErrorText(error)] })));
2350
+ function useButton() {
2351
+ return (props) => ({
2352
+ ...props,
2353
+ onClick: handlerDecorator(handleClick(props)),
2354
+ });
2355
+ }
2356
+ function handleClick({ disabled, onClick }) {
2357
+ return (ev) => {
2358
+ !disabled && onClick && onClick(ev);
2359
+ };
2360
+ }
2326
2361
 
2327
- const CURRENCY_TYPES = [{ id: 'rub', text: 'Рубль' }];
2328
- const CurrencyField = JSX(({ field, input }) => {
2329
- const { value, onChange } = field('currency');
2330
- return (jsx(RadioButtonGroupControl, { label: "\u0412\u0430\u043B\u044E\u0442\u0430", orientation: "horizontal", items: CURRENCY_TYPES, value: value, onChange: (_) => onChange?.(_), ...getValidation(field('currency'), validatorObj.currency, input?.required) }));
2362
+ const buttonStyleMap = {
2363
+ primary: 'text-white bg-primary-main hover:bg-primary-hover active:bg-primary-active',
2364
+ secondary: 'text-primary-main bg-main-divider hover:text-white hover:bg-primary-hover active:bg-primary-active',
2365
+ };
2366
+ const secondaryButtonStyleMap = {
2367
+ primary: style('group-data-secondary:text-primary-main group-data-secondary:bg-white', 'group-data-secondary:hover:text-white group-data-secondary:hover:bg-primary-hover', 'group-data-secondary:active:bg-primary-active'),
2368
+ secondary: style('group-data-secondary:text-white group-data-secondary:bg-white/20', 'group-data-secondary:hover:bg-primary-hover', 'group-data-secondary:active:bg-primary-active'),
2369
+ };
2370
+ const Button = JSX(({ children, ...props }) => {
2371
+ const button = useButton();
2372
+ const { className, version = 'primary', active, disabled, type = 'button', rounded = true, role, onClick, } = button(props);
2373
+ return (jsx("button", { className: style('font-sans px-9 py-4', 'flex justify-center items-center gap-xs', {
2374
+ 'text-white bg-primary-active': active,
2375
+ 'bg-main-gray text-main-disabled cursor-not-allowed': disabled,
2376
+ 'rounded-md': rounded,
2377
+ }, !active && !disabled
2378
+ ? style(buttonStyleMap[version], secondaryButtonStyleMap[version])
2379
+ : '', className), type: type, role: role, onClick: onClick, children: children }));
2331
2380
  });
2332
2381
 
2333
- const DeliveryDateFiels = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u0434\u043E\u0441\u0442\u0430\u0432\u043A\u0438", ...getValidation(field('deliveryDate'), validatorObj.deliveryDate, input?.required) })));
2334
-
2335
- const DependentsField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0438\u0436\u0434\u0438\u0432\u0435\u043D\u0446\u0435\u0432", placeholder: "\u0417\u0430 \u0438\u0441\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435 \u0434\u0435\u0442\u0435\u0439 \u0434\u043E 18 \u043B\u0435\u0442", type: "number", maxLength: 2, ...getValidation(field('dependents'), validatorObj.dependents, input?.required), ...input })));
2382
+ const getVersion = (isPrimary, type) => isPrimary && type !== 'underlined' ? 'primary' : 'secondary';
2336
2383
 
2337
- const DesiredMeetingDateField = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0416\u0435\u043B\u0430\u0435\u043C\u0430\u044F \u0434\u0430\u0442\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0438", ...getValidation(field('desiredMeetingDate'), validatorObj.meetingDay, input?.required) })));
2384
+ const renderButtonsGroup = (data, activeButton, onButtonClick) => {
2385
+ const allButtonVersion = getVersion(activeButton === 'all');
2386
+ const businessButtonVersion = getVersion(activeButton === 'business');
2387
+ const handleClick = (e, key, branches) => {
2388
+ const filteredBranches = e.currentTarget === e.target && key === 'business' ? filterBranches(branches) : branches;
2389
+ onButtonClick(key);
2390
+ return filteredBranches;
2391
+ };
2392
+ const filterBranches = (branches) => branches.filter((branch) => branch.workSchedule &&
2393
+ branch.workSchedule.businessScheduleVisibleTag &&
2394
+ !branch.workSchedule.businessScheduleDescription);
2395
+ return (jsxs("div", { className: "flex gap-lg flex-col sm:flex-row pb-lg", children: [jsx(Button, { "data-id": "all", onClick: (e) => handleClick(e, 'all', data), version: allButtonVersion, children: "\u0414\u043B\u044F \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446" }), jsx(Button, { "data-id": "business", onClick: (e) => handleClick(e, 'business', data), version: businessButtonVersion, children: "\u0414\u043B\u044F \u044E\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446" })] }));
2396
+ };
2338
2397
 
2339
- const DisablePeopleFlgField = JSX(({ field, input }) => (jsx(CheckboxWithError, { text: "\u042F\u0432\u043B\u044F\u044E\u0441\u044C \u0438\u043D\u0432\u0430\u043B\u0438\u0434\u043E\u043C", ...getValidation(field('disablePeopleFlg'), validatorObj.disablePeopleFlg, input?.required) })));
2398
+ const renderDescriptionBlock$1 = ({ __html, list, richVersion }) => __html || list?.length ? (jsxs("div", { className: "mb-2xl border-b sm:border border-main-divider sm:rounded-md", children: [__html ? (jsx("div", { className: "mb-2xl", children: jsx(RichText, { __html: __html, richVersion: richVersion }) })) : null, list?.length ? (jsx("div", { className: "flex flex-col sm:flex-row gap-2xl sm:flex-wrap pb-2xl sm:pb-xl", children: list.map((item, i) => (jsxs("div", { className: "flex gap-xs items-center", children: [item?.image ? jsx(Img, { image: item.image }) : null, item?.text ? (jsx(Text, { size: "text-m", font: "font-light", children: item.text })) : null] }, String(i)))) })) : null] })) : null;
2340
2399
 
2341
- const FIELD_NAME$6 = 'dulIssueDateField';
2342
- const DulIssueDateField = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u0432\u044B\u0434\u0430\u0447\u0438", ...getValidation(field(FIELD_NAME$6), validatorObj.dulIssueDateField, input?.required), disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$6) })));
2400
+ const COMMON_FILTERS_STYLES = 'flex flex-col sm:flex-row sm:flex-wrap gap-3xl pb-2xl';
2401
+ const renderFiltrationForm = ({ filters, field: { field, reset }, onlyOffice, labels, }) => {
2402
+ const visibleFiltersNum = onlyOffice ? 5 : 6;
2403
+ const filtersCheckbox = (filters || []).map((key) => (jsx(Checkbox, { text: labels[key], ...field(key) }, key)));
2404
+ const [visibleFilters, hiddenFilters] = visibleFiltersNum > 0
2405
+ ? [filtersCheckbox.slice(0, visibleFiltersNum), filtersCheckbox.slice(visibleFiltersNum)]
2406
+ : [filtersCheckbox, []];
2407
+ return (jsx("div", { children: filters?.length ? (jsx("div", { children: jsx(Foldable, { renderFoldableSection: ({ isUnfolded }) => (jsxs("div", { children: [jsx("div", { className: COMMON_FILTERS_STYLES, children: visibleFilters }), jsx(FoldableSection, { className: COMMON_FILTERS_STYLES, isUnfolded: isUnfolded, children: hiddenFilters })] })), renderFoldButton: renderFoldButton$2(reset, onlyOffice) }) })) : null }));
2408
+ };
2409
+ const renderFoldButton$2 = (reset, onlyOffice = false) => ({ isUnfolded, onToggle }) => {
2410
+ const labels = ['Больше фильтров', 'Меньше фильтров'];
2411
+ const icons = ['ArrowDownIcon', 'ArrowUpIcon'];
2412
+ return (jsxs("div", { className: "flex space-x-lg", children: [onlyOffice ? (jsx(LinkButton, { version: "transparent", className: "text-secondary-text [&>*]:p-0", appendRight: jsx(Icon, { name: icons[Number(isUnfolded)], width: "16", height: "16" }), text: labels[Number(isUnfolded)], onClick: onToggle })) : null, jsx(LinkButton, { version: "transparent", className: "text-secondary-text [&>*]:p-0", onClick: reset, children: renderBtnInner() })] }));
2413
+ };
2414
+ const renderBtnInner = () => (jsxs("div", { className: "flex items-center", children: ["\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0444\u0438\u043B\u044C\u0442\u0440", jsx(Icon, { name: "CloseIcon", width: "16", height: "16", className: "ml-2xs" })] }));
2343
2415
 
2344
- const FIELD_NAME$5 = 'dulIssuedBy';
2345
- const DulIssuedByField = JSX(({ field, input }) => {
2346
- const { value: dulSubdivisionCode, onChange: changeDulSubdivisionCode } = field('dulSubdivisionCode');
2347
- const onDaDataChange = useCallback((item) => {
2348
- changeDulSubdivisionCode?.(item?.data?.code?.replace('-', ''));
2349
- }, []);
2350
- return (jsx(InputControl, { disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$5), label: "\u041A\u0435\u043C \u0432\u044B\u0434\u0430\u043D", ...input, ...getValidation(field(FIELD_NAME$5), validatorObj.dulIssuedBy, input?.required), onDaDataChange: onDaDataChange, daDataQueryPrefix: dulSubdivisionCode }));
2351
- });
2416
+ const renderHeading = (title, lengthItems) => (jsx("div", { className: "flex flex-col sm:flex-row gap-xs mb-2xl", children: jsxs(Heading, { headingType: "h3", children: [jsx("span", { suppressHydrationWarning: true, children: title }), lengthItems ? (jsx(Text, { size: "text-h2", color: "text-secondary-text", children: jsx("span", { suppressHydrationWarning: true, children: ` (${lengthItems})` }) })) : null] }) }));
2352
2417
 
2353
- const FIELD_NAME$4 = 'dulNumber';
2354
- const DulNumberField = JSX(({ field, input }) => (jsx(InputControl, { disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$4), label: "\u041D\u043E\u043C\u0435\u0440 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430", type: "number", maxLength: 6, ...getValidation(field('dulNumber'), validatorObj.dulNumber, input?.required) })));
2355
-
2356
- const FIELD_NAME$3 = 'dulSerie';
2357
- const DulSerieField = JSX(({ field, input }) => (jsx(InputControl, { disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$3), label: "\u0421\u0435\u0440\u0438\u044F \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430", type: "number", maxLength: 4, ...getValidation(field('dulSerie'), validatorObj.dulSerie, input?.required) })));
2358
-
2359
- const FIELD_NAME$2 = 'dulSubdivisionCode';
2360
- const DulSubdivisionCodeField = JSX(({ field, input }) => {
2361
- const onDaDataChange = useCallback((item) => {
2362
- field?.('dulIssuedBy')?.onChange?.(item?.data?.name);
2363
- }, []);
2364
- return (jsx(InputControl, { disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$2), label: "\u041A\u043E\u0434 \u043F\u043E\u0434\u0440\u0430\u0437\u0434\u0435\u043B\u0435\u043D\u0438\u044F", type: "number", maxLength: 6, ...input, ...getValidation(field(FIELD_NAME$2), validatorObj.dulSubdivisionCode, input?.required), onDaDataChange: onDaDataChange }));
2365
- });
2366
-
2367
- const EducationField = JSX(({ field, input }) => {
2368
- const { data: education } = useLeadFormData('EDUCATION_LEVEL');
2369
- return (jsx(SelectField, { field: field, source: education, label: "\u041E\u0431\u0440\u0430\u0437\u043E\u0432\u0430\u043D\u0438\u0435", fieldName: "education", input: input }));
2418
+ const defaultEmptyFunction$1 = () => void 0;
2419
+ const filtersVisibleStyles = (activeButton) => activeButton === 'all' ? 'block' : 'hidden';
2420
+ const OfficesAtmsMapLayout = JSX(({ className, data = [], isLoad, remoteWorkplaces = [], renderCard = defaultEmptyFunction$1, renderRemoteWorkplaceCard = defaultEmptyFunction$1, getBalloon = defaultEmptyFunction$1, getBalloonRemoteWorkplaces = defaultEmptyFunction$1, descriptionData, title, }) => {
2421
+ const onlyOffice = title?.includes('Офис');
2422
+ const [filtrationState, { field, reset }] = useForm(INITIAL_FILTRATION_STATE$1);
2423
+ const { filteredItems, points, filteredRemoteWorkplaces, lengthItems } = useOfficesAtmsMapData({
2424
+ data,
2425
+ remoteWorkplaces,
2426
+ filtrationState,
2427
+ getBalloon,
2428
+ getBalloonRemoteWorkplaces,
2429
+ });
2430
+ const [activeButton, setActiveButton] = useState('all');
2431
+ const filterOptions = {
2432
+ filters: getFiltersWithNonEmptyData([...data, ...remoteWorkplaces]),
2433
+ field: { field, reset },
2434
+ onlyOffice,
2435
+ labels: FILTRATION_LABELS,
2436
+ };
2437
+ return (jsxs("div", { className: style('space-y-1', className), children: [jsxs("div", { className: "bg-white", children: [jsxs("div", { className: "p-3xl pb-0", children: [renderHeading(title, lengthItems), descriptionData ? renderDescriptionBlock$1(descriptionData) : null, onlyOffice && renderButtonsGroup(data, activeButton, setActiveButton), jsx("div", { className: style('pb-3xl', filtersVisibleStyles(activeButton)), children: renderFiltrationForm(filterOptions) })] }), jsx("div", { className: "h-[600px]", children: jsx(ClientOnly, { children: jsx(YandexMap, { points: points, isLoad: isLoad, className: "h-full" }) }) })] }), jsxs(ClientOnly, { children: [filteredItems.map(renderCard), filteredRemoteWorkplaces.map(renderRemoteWorkplaceCard)] })] }));
2370
2438
  });
2439
+ const filterItems$1 = (data, filtrationState) => {
2440
+ const truthyFilters = Object.keys(filtrationState).filter((key) => filtrationState[key]);
2441
+ return data.filter((item) => truthyFilters.every((_) => FILTRATION_PREDICATES$1[_](item)));
2442
+ };
2443
+ const getFiltersWithNonEmptyData = (data) => Object.keys(INITIAL_FILTRATION_STATE$1).filter((_) => data.filter((item) => FILTRATION_PREDICATES$1[_](item)).length);
2371
2444
 
2372
- const EmailField = JSX(({ field, input }) => {
2373
- const { required, ...rest } = input;
2374
- return (jsx(InputControl, { label: "\u042D\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u0430\u044F \u043F\u043E\u0447\u0442\u0430", ...getValidation(field('email'), validatorObj.email, required), ...rest }));
2375
- });
2445
+ const defaultEmptyFunction = () => void 0;
2446
+ const useOfficesAtmsMapData = ({ data, remoteWorkplaces = [], filtrationState = {}, getBalloon = defaultEmptyFunction, getBalloonRemoteWorkplaces = defaultEmptyFunction, }) => {
2447
+ const [filteredItems, points, filteredRemoteWorkplaces, lengthItems] = useMemo(() => {
2448
+ const _filteredItems = filterItems$1(data, filtrationState);
2449
+ const _filteredRemoteWorkplaces = filterItems$1(remoteWorkplaces, filtrationState);
2450
+ const _points = [
2451
+ ..._filteredItems.map((_) => ({
2452
+ type: 'offices',
2453
+ coords: [Number(_.gpsLatitude), Number(_.gpsLongitude)]?.filter(Boolean),
2454
+ content: getBalloon(_),
2455
+ })),
2456
+ ..._filteredRemoteWorkplaces.map((_) => ({
2457
+ type: 'workplaces',
2458
+ coords: [Number(_.gpsLatitude), Number(_.gpsLongitude)]?.filter(Boolean),
2459
+ content: getBalloonRemoteWorkplaces({
2460
+ address: _.address,
2461
+ workScheduleDescription: _.workScheduleDescription,
2462
+ }),
2463
+ })),
2464
+ ].filter((_) => _.coords && _.coords.length === 2);
2465
+ const itemsLength = _filteredItems.length + _filteredRemoteWorkplaces?.length;
2466
+ return [_filteredItems, _points, _filteredRemoteWorkplaces, itemsLength];
2467
+ }, [data, remoteWorkplaces, filtrationState, getBalloon, getBalloonRemoteWorkplaces]);
2468
+ return { filteredItems, points, filteredRemoteWorkplaces, lengthItems };
2469
+ };
2376
2470
 
2377
- const EmployerActivitiesField = JSX(({ field, input }) => {
2378
- const { data: employerActivities } = useLeadFormData('ORGANIZATION_ACTIVITY_TYPE');
2379
- return (jsx(SelectField, { field: field, source: employerActivities, label: "\u0412\u0438\u0434 \u0434\u0435\u044F\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u0438 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438-\u0440\u0430\u0431\u043E\u0442\u043E\u0434\u0430\u0442\u0435\u043B\u044F", fieldName: "employerActivities", input: input }));
2380
- });
2471
+ const useLeadFormData = (typeField) => {
2472
+ const { data, error } = useAsyncData(`/api/v1/dictionary?dictionaryType=${encodeURIComponent(typeField)}`, fetchData);
2473
+ if (data && 'errorMessage' in data) {
2474
+ return { error };
2475
+ }
2476
+ return { data: data, error };
2477
+ };
2478
+ const fetchData = async (url) => {
2479
+ const result = await fetchJSON(url, { method: 'POST' });
2480
+ return result || [];
2481
+ };
2381
2482
 
2382
- const EmployerOrganizationField = JSX(({ field, input }) => {
2383
- const { data: employerOrganization } = useLeadFormData('ORGANIZATION_KIND');
2384
- return (jsx(SelectField, { field: field, source: employerOrganization, label: "\u0412\u0438\u0434 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043E\u0442\u043E\u0434\u0430\u0442\u0435\u043B\u044F", fieldName: "employerOrganization", input: input }));
2483
+ const AddressRetailField = JSX(({ field, input }) => {
2484
+ const [offices, setOffices] = useState([]);
2485
+ const { data } = useLeadFormData('REGION_RF');
2486
+ const regionValue = field('regionRetail')?.value || {};
2487
+ const fieldBranch = field('addressRetail');
2488
+ useEffect(() => {
2489
+ (async () => {
2490
+ const officesList = await regionOffices(regionValue?.key ?? '');
2491
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
2492
+ setOffices(officesList || []);
2493
+ })();
2494
+ if (regionValue?.key) {
2495
+ field?.('addressRetail')?.onChange?.('');
2496
+ }
2497
+ }, [regionValue.key]);
2498
+ const { points } = useOfficesAtmsMapData({
2499
+ data: offices,
2500
+ filtrationState: {},
2501
+ getBalloon: getOfficePoint,
2502
+ });
2503
+ const isRegionSelected = Boolean(regionValue?.key);
2504
+ return (jsxs("div", { children: [jsx(SelectControl, { label: "\u0410\u0434\u0440\u0435\u0441 \u043E\u0442\u0434\u0435\u043B\u0435\u043D\u0438\u044F", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043E\u0442\u0434\u0435\u043B\u0435\u043D\u0438\u0435", options: offices.map(({ id, address = '' }) => ({
2505
+ key: id?.toString() || '',
2506
+ text: address,
2507
+ })), ...getValidation(field('addressRetail'), validatorObj.addressRetail, input?.required && isRegionSelected), isSearch: true }), jsx("div", { className: "h-[600px]", children: jsx(ClientOnly, { children: jsx(YandexMap, { points: points, isLoad: !data, className: "h-full", selectedAddress: fieldBranch?.value?.text }) }) })] }));
2385
2508
  });
2386
2509
 
2387
- const EmploymentField = JSX(({ field, input }) => {
2388
- const { data: employment } = useLeadFormData('EMPLOYMENT_INFO_UNITED');
2389
- return (jsx(SelectField, { field: field, source: employment, label: "\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u0442\u0440\u0443\u0434\u043E\u0443\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432\u0435", fieldName: "employment", input: input }));
2390
- });
2510
+ const useNormalizedInput = (props, { normalize, format }) => {
2511
+ const { value, onFocus, onBlur, onChange } = props;
2512
+ const [isFocused, setIsFocused] = useState(false);
2513
+ const handleFocus = useCallback((ev) => {
2514
+ setIsFocused(true);
2515
+ onFocus && onFocus(ev);
2516
+ }, []);
2517
+ const handleBlur = useCallback(() => {
2518
+ setIsFocused(false);
2519
+ onChange && onChange(normalize(value));
2520
+ onBlur && onBlur();
2521
+ }, [onChange, value]);
2522
+ return {
2523
+ value: (isFocused || !format ? value : format(value)),
2524
+ onFocus: handleFocus,
2525
+ onBlur: handleBlur,
2526
+ };
2527
+ };
2391
2528
 
2392
- const ExpensesField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0440\u0430\u0441\u0445\u043E\u0434\u044B \u0432 \u043C\u0435\u0441\u044F\u0446", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", ...getValidation(field('expenses'), validatorObj.expenses, input?.required), ...input })));
2529
+ const clamp = (value, min, max) => Math.max(min, Math.min(value, max));
2393
2530
 
2394
- const Experience5YearsField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0421\u0442\u0430\u0436", placeholder: "\u0417\u0430 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435 5 \u043B\u0435\u0442", type: "number", maxLength: 2, ...getValidation(field('experience5Years'), validatorObj.experience5Years, input?.required), ...input })));
2531
+ function parseDecimal(value) {
2532
+ const rawValue = (value || '').replace(/\D/g, '');
2533
+ const unsafeDecimal = parseInt(rawValue, 10);
2534
+ return Number.isNaN(unsafeDecimal) ? 0 : unsafeDecimal;
2535
+ }
2395
2536
 
2396
- const FamilyMembersField = JSX(({ field }) => {
2397
- const { value, onChange } = field('familyMembers');
2398
- const familyStatusKey = field('familyStatus')?.value?.key;
2399
- const adultsCount = familyStatusKey === 'MARRIED' ? 2 : 1;
2400
- const childrenCount = Number(field('children')?.value);
2401
- const dependentsCount = Number(field('dependents')?.value);
2402
- const totalCount = adultsCount + childrenCount + dependentsCount;
2403
- useEffect(() => {
2404
- field?.('familyMembers')?.onChange?.(totalCount);
2405
- }, [familyStatusKey, childrenCount, dependentsCount]);
2406
- return (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0447\u043B\u0435\u043D\u043E\u0432 \u0441\u0435\u043C\u044C\u0438", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", disabled: true, value: value, onChange: (_) => onChange?.(_) }));
2407
- });
2537
+ function renderRangeWithTicks({ list = [], min, max, step, value = list[0] || min, disabled, onChange, }) {
2538
+ const rangeValue = list.length ? list.indexOf(value) : value;
2539
+ const rangeValueShift = rangeValue > min ? rangeValue - min : 0;
2540
+ const percentage = (rangeValueShift * 100) / (max - min);
2541
+ const inputStyle = {
2542
+ backgroundSize: `${percentage.toFixed(2)}% 100%`,
2543
+ };
2544
+ return (jsxs("div", { children: [list.length ? (jsx("div", { className: "absolute w-full flex justify-between -bottom-[3px] px-m", children: list.map((_, i) => (jsx("div", { className: style('w-2 h-2 rounded-full', rangeValue <= i || disabled ? 'bg-gray' : 'bg-primary-main') }, String(i)))) })) : null, jsx("div", { className: "absolute inset-x-0 -bottom-1 px-m leading-[18px]", children: jsx("input", { className: "box-border w-full m-0 cursor-pointer slider relative z-10", style: inputStyle, type: "range", min: min, max: max, step: step, value: rangeValue, disabled: disabled, onChange: ((ev) => {
2545
+ const rawValue = parseDecimal(ev.target?.value);
2546
+ const newValue = list.length ? list[rawValue] : rawValue;
2547
+ onChange && onChange(newValue || 0);
2548
+ }) }) })] }));
2549
+ }
2408
2550
 
2409
- const FamilyStatusField = JSX(({ field, input }) => {
2410
- const { data: familyStatus } = useLeadFormData('MARITAL_STATUS');
2411
- return (jsx(SelectField, { field: field, source: familyStatus, label: "\u0421\u0435\u043C\u0435\u0439\u043D\u043E\u0435 \u043F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0435", fieldName: "familyStatus", input: input }));
2551
+ const inputDisabledStyle = 'disabled:border-gray disabled:bg-main-divider';
2552
+ const DEFAULT_MIN = 1;
2553
+ const DEFAULT_MAX = 100;
2554
+ const InputRange = JSX((props) => {
2555
+ const { className, title, items = [], list = [], min = list.length ? 0 : DEFAULT_MIN, max = list.length ? list.length - 1 : DEFAULT_MAX, step = 1, value = list[0] || min, disabled = false, onChange, } = props;
2556
+ const normalizedProps = useNormalizedInput(props, {
2557
+ normalize: (_ = 0) => list.length ? closestValue(list)(_) : clamp(_, min, max),
2558
+ format: toLocalNumberFormat(),
2559
+ });
2560
+ const handleChange = useCallback((ev) => {
2561
+ onChange && onChange(parseDecimal(ev.target?.value));
2562
+ }, [onChange]);
2563
+ return (jsxs("div", { className: className, children: [jsxs("label", { className: "block relative", children: [title ? (jsx(Text, { size: "text-m", font: "font-light", color: "text-primary-text", children: title })) : null, jsx("input", { className: style('text-h3 w-full h-14', 'pl-m mt-xs box-border', 'text-primary-text', inputValidStyle, inputDisabledStyle), disabled: disabled, onChange: handleChange, ...normalizedProps }), renderRangeWithTicks({ list, min, max, step, disabled, value, onChange })] }), renderRangeCaption(items)] }));
2412
2564
  });
2565
+ const closestValue = (list) => (_) => list.reduce((prev, curr) => (Math.abs(curr - _) < Math.abs(prev - _) ? curr : prev));
2566
+ const renderRangeCaption = (items) => (jsx("div", { className: "flex justify-between my-xs", children: items.map((item, i) => (jsx(Text, { size: "text-s", font: "font-light", color: "text-secondary-text", children: item }, String(i)))) }));
2413
2567
 
2414
- const SERVICE_TYPES = [
2415
- { key: 'ULTRASERVICE', text: 'Ультра' },
2416
- { key: 'PREMIUMSERVICE', text: 'Премиум' },
2417
- ];
2418
- const SERVICE_DIRECTIONS = [
2419
- { key: 'Физическое лицо' },
2420
- { key: 'Юридическое лицо / ИП' },
2421
- ];
2422
- const FEEDBACK_METHOD = [
2423
- { key: 'phone', text: 'Телефонный звонок' },
2424
- { key: 'email', text: 'Электронное сообщение' },
2425
- ];
2426
-
2427
- const FeedbackMethodField = JSX(({ field, input }) => (jsx(SelectControl, { label: "\u0421\u043F\u043E\u0441\u043E\u0431 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u044F \u043E\u0442\u0432\u0435\u0442\u0430", options: FEEDBACK_METHOD, ...getValidation(field('feedbackMethod'), validatorObj.feedbackMethod, input?.required) })));
2428
-
2429
- const FullNameField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0424\u0418\u041E", ...getValidation(field('fullName'), validatorObj.fullName, input?.required), ...input })));
2430
-
2431
- const GeneralSeniorityField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u0431\u0449\u0438\u0439 \u0441\u0442\u0430\u0436", type: "number", maxLength: 2, placeholder: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043B\u0435\u0442", ...getValidation(field('generalSeniority'), validatorObj.generalSeniority, input?.required), ...input })));
2568
+ const MIN_CREDIT_AMOUNT = 1000;
2569
+ const MAX_CREDIT_AMOUNT = 1000000000;
2570
+ const ITEMS_CREDIT_AMOUNT = ['От 1 000 ₽', 'До 1 000 000 000 ₽'];
2571
+ const AmountField = JSX(({ field }) => (jsx(InputRange, { title: "\u0421\u0443\u043C\u043C\u0430, \u20BD", items: ITEMS_CREDIT_AMOUNT, min: MIN_CREDIT_AMOUNT, max: MAX_CREDIT_AMOUNT, ...field('amount') })));
2432
2572
 
2433
- const HousingField = JSX(({ field, input }) => {
2434
- const { data: housing } = useLeadFormData('HOUSE_TYPE');
2435
- return (jsx(SelectField, { field: field, source: housing, label: "\u0422\u0438\u043F \u0436\u0438\u043B\u044C\u044F", fieldName: "housing", input: input }));
2573
+ const SelectField = UniBlock(({ field, source, label, fieldName, input, placeholder = 'Выберите из списка', isSearch = false, }) => {
2574
+ const leadOptions = (source &&
2575
+ source?.map((_) => ({
2576
+ key: _.key || '',
2577
+ text: _.value,
2578
+ }))) ||
2579
+ [];
2580
+ return (jsx(SelectControl, { placeholder: placeholder, label: label, options: leadOptions, isSearch: isSearch, ...getValidation(field(fieldName), validatorObj[fieldName], input?.required) }));
2436
2581
  });
2437
2582
 
2438
- const InnField = JSX(({ field, input }) => {
2439
- const onDaDataChange = useCallback((item) => {
2440
- field?.('organizationName')?.onChange?.(item.data?.name?.short_with_opf);
2441
- field?.('legalForm')?.onChange?.(item.data?.opf?.short);
2442
- }, []);
2443
- return (jsx(InputControl, { label: "\u0418\u041D\u041D", type: "number", maxLength: 12, ...input, ...getValidation(field('inn'), validatorObj.inn, input?.required), onDaDataChange: onDaDataChange }));
2583
+ const AmountWorkersField = JSX(({ field, input }) => {
2584
+ const { data: amountWorkers } = useLeadFormData('EMPLOYEES_NUMBER');
2585
+ return (jsx(SelectField, { field: field, source: amountWorkers, label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0440\u0430\u0431\u043E\u0442\u0430\u044E\u0449\u0438\u0445 \u0432 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438", fieldName: "amountWorkers", input: input }));
2444
2586
  });
2445
2587
 
2446
- const IsClientField = JSX(({ field }) => (jsx(CheckboxWithError, { ...field('isClient'), text: '\u042F\u0432\u043B\u044F\u044E\u0441\u044C \u043A\u043B\u0438\u0435\u043D\u0442\u043E\u043C \u0431\u0430\u043D\u043A\u0430 \u0410\u041E "\u0420\u043E\u0441\u0441\u0435\u043B\u044C\u0445\u043E\u0437\u0431\u0430\u043D\u043A"' })));
2447
-
2448
- const JobsNumberField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u0442 \u0440\u0430\u0431\u043E\u0442\u044B \u0437\u0430 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435 5 \u043B\u0435\u0442", placeholder: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u0442", type: "number", maxLength: 2, ...getValidation(field('jobsNumber'), validatorObj.jobsNumber, input?.required), ...input })));
2588
+ const AnnualRevenueField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0413\u043E\u0434\u043E\u0432\u0430\u044F \u0432\u044B\u0440\u0443\u0447\u043A\u0430, \u20BD", ...getValidation(field('annualRevenue'), validatorObj.annualRevenue, input?.required) })));
2449
2589
 
2450
- const LastJobExperienceField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0421\u0442\u0430\u0436 \u043D\u0430 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0435\u043C \u0440\u0430\u0431\u043E\u0447\u0435\u043C \u043C\u0435\u0441\u0442\u0435", placeholder: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043B\u0435\u0442", type: "number", maxLength: 2, ...getValidation(field('lastJobExperience'), validatorObj.lastJobExperience, input?.required), ...input })));
2590
+ const ArmyIdFlgField = JSX(({ field, input }) => (jsx(CheckboxWithError, { text: "\u041D\u0430\u043B\u0438\u0447\u0438\u0435 \u0432\u043E\u0435\u043D\u043D\u043E\u0433\u043E \u0431\u0438\u043B\u0435\u0442\u0430", ...getValidation(field('armyIdFlg'), validatorObj.armyIdFlg, input?.required) })));
2451
2591
 
2452
- const LegalEntityNameField = JSX(({ field, input }) => {
2453
- return (jsx(InputControl, { label: "\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435 \u044E\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043A\u043E\u0433\u043E \u043B\u0438\u0446\u0430", ...input, ...getValidation(field('legalEntityName'), validatorObj.legalEntityName, input?.required) }));
2454
- });
2592
+ const BankEmpoleeCodeField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u0434 \u043F\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043B\u044F \u0411\u0430\u043D\u043A\u0430", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043A\u043E\u0434", type: "number", ...getValidation(field('bankEmployeeCode'), validatorObj.bankEmployeeCode, input?.required), ...input })));
2455
2593
 
2456
- const LegalFormField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u041F\u0424", placeholder: "\u041E\u041E\u041E, \u041F\u0410\u041E \u0438 \u0434\u0440.", ...getValidation(field('legalForm'), validatorObj.legalForm, input?.required), ...input })));
2594
+ const BankEmpoleeField = JSX(({ field }) => (jsx(InputControl, { label: "\u0424\u0418\u041E \u0438\u043B\u0438 \u0434\u043E\u043B\u0436\u043D\u043E\u0441\u0442\u044C \u043E\u0431\u0441\u043B\u0443\u0436\u0438\u0432\u0430\u0432\u0448\u0435\u0433\u043E \u0412\u0430\u0441 \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u0430 \u0411\u0430\u043D\u043A\u0430", ...field('bankEmpolee') })));
2457
2595
 
2458
- const OUT_SERVICE_BASE_URL = `${API_BASE_URI}/outservice`;
2459
- const EMPTY_REGIONS = [];
2460
- async function getOutServiceRegions() {
2461
- const data = await fetchJSON(`${OUT_SERVICE_BASE_URL}/outserviceregions`);
2462
- return data && Array.isArray(data) ? data : EMPTY_REGIONS;
2463
- }
2596
+ const BankruptcyFlgField = JSX(({ field, input }) => (jsx(CheckboxWithError, { text: "\u0412 \u043E\u0442\u043D\u043E\u0448\u0435\u043D\u0438\u0438 \u043C\u0435\u043D\u044F \u0432\u0435\u0434\u0451\u0442\u0441\u044F \u043F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0441\u0442\u0432\u043E \u043F\u043E \u0434\u0435\u043B\u0443 \u043E \u0431\u0430\u043D\u043A\u0440\u043E\u0442\u0441\u0442\u0432\u0435", ...getValidation(field('bankruptcyFlg'), validatorObj.bankruptcyFlg, input?.required) })));
2464
2597
 
2465
- const LocalitiesField = JSX(({ field, input }) => {
2466
- const fieldRegion = field('region');
2467
- const regionKey = fieldRegion?.value?.key;
2468
- const { data: regions } = useAsyncData('outServiceRegions', getOutServiceRegions);
2469
- const localities = regions
2470
- ?.find((_) => _.code === regionKey)
2471
- ?.localities?.map((_) => ({ key: _, text: _ }));
2598
+ const useElementSpace = (ref, heightEl) => {
2599
+ const [spaceAbove, setSpaceAbove] = useState(false);
2472
2600
  useEffect(() => {
2473
- if (regionKey !== '') {
2474
- field?.('localities')?.onChange?.('');
2475
- }
2476
- }, [regionKey]);
2477
- return (jsx(SelectControl, { label: "\u041D\u0430\u0441\u0435\u043B\u0435\u043D\u043D\u044B\u0439 \u043F\u0443\u043D\u043A\u0442", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0433\u043E\u0440\u043E\u0434, \u0433\u0434\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0441\u0435\u0440\u0432\u0438\u0441", options: localities, ...getValidation(field('localities'), validatorObj.localities, input?.required), isSearch: true }));
2478
- });
2479
-
2480
- const MandatoryPaymentsField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0432\u044B\u043F\u043B\u0430\u0442\u044B", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", ...getValidation(field('mandatoryPayments'), validatorObj.mandatoryPayments, input?.required), ...input })));
2481
-
2482
- const METHODS_OF_OBTAIN = [
2483
- { id: 'office', text: 'В отделении Банка' },
2484
- { id: 'courier', text: 'Курьерская доставка' },
2485
- ];
2486
- const MethodObtainField = JSX(({ field, input }) => (jsx(RadioButtonGroupControl, { orientation: "horizontal", items: METHODS_OF_OBTAIN, ...getValidation(field('methodObtain'), validatorObj.methodObtain, input?.required) })));
2487
-
2488
- const FIELD_NAME$1 = 'middleName';
2489
- const MiddleNameField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u0442\u0447\u0435\u0441\u0442\u0432\u043E (\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E, \u043F\u0440\u0438 \u043D\u0430\u043B\u0438\u0447\u0438\u0438)", maxLength: 60, disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$1), ...getValidation(field(FIELD_NAME$1), validatorObj.middleName, input?.required), ...input })));
2490
-
2491
- const NameField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0418\u043C\u044F", maxLength: 60, disabled: input?.filledByEsia && isEsiaAuthorize(field, input.name ?? ''), ...getValidation(field('name'), validatorObj.name, input?.required), ...input })));
2492
-
2493
- const SlideCheckbox = JSX(({ value = false, text, type = 'checkbox', onChange }) => (jsxs("div", { role: type, "aria-checked": value, className: "flex justify-start items-center w-full cursor-pointer mb-s", onClick: () => onChange && onChange(!value), children: [jsx("div", { className: style('relative flex-shrink-0 duration-300 w-9 h-5 mr-s rounded-2xl', value ? 'bg-primary-main' : 'bg-main-divider'), children: jsx("div", { className: style('absolute opacity-80 duration-500 top-0.5 w-4 h-4 bg-white rounded-full', value ? 'left-1/2' : 'left-[5%]') }) }), text ? (jsx(Text, { size: "text-l", font: "font-light", color: "text-primary-text", children: text })) : null] })));
2494
-
2495
- const OnlineCheckoutField = JSX(({ field }) => isAcquiringTrade(field('acquiringType')?.value?.key) ? (jsx(SlideCheckbox, { type: "radio", text: "\u0425\u043E\u0447\u0443 \u043E\u043D\u043B\u0430\u0439\u043D-\u043A\u0430\u0441\u0441\u0443", ...field('onlineCheckout') })) : null);
2601
+ const handleResize = () => {
2602
+ if (ref?.current) {
2603
+ const { top } = ref.current.getBoundingClientRect();
2604
+ const hasSpaceAbove = top > heightEl;
2605
+ setSpaceAbove(hasSpaceAbove);
2606
+ }
2607
+ };
2608
+ handleResize();
2609
+ window.addEventListener('resize', handleResize);
2610
+ return () => window.removeEventListener('resize', handleResize);
2611
+ }, [ref]);
2612
+ return spaceAbove;
2613
+ };
2496
2614
 
2497
- const OrganizationField = JSX(({ field, input }) => {
2498
- const { data: organization } = useLeadFormData('ORGANIZATION_TYPE');
2499
- return (jsx(SelectField, { field: field, source: organization, label: "\u0422\u0438\u043F \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438", fieldName: "organization", input: input }));
2500
- });
2615
+ const DAY_COUNT = 6;
2616
+ const WEEK_COUNT = 7;
2617
+ const renderCalendarCells = ({ today, firstDayOfWeek, totalDays, currentMonth, currentYear, min, max, onDateClick, }) => {
2618
+ const calendarCells = [];
2619
+ let dayCounter = 1;
2620
+ for (let i = 0; i < DAY_COUNT; i++) {
2621
+ const rowCells = [];
2622
+ for (let j = 0; j < WEEK_COUNT; j++) {
2623
+ if (i === 0 && j < firstDayOfWeek) {
2624
+ rowCells.push(jsx("td", {}, `empty-${j}`));
2625
+ }
2626
+ else if (dayCounter > totalDays) {
2627
+ rowCells.push(jsx("td", {}, `empty-${j}`));
2628
+ }
2629
+ else {
2630
+ const currentDate = new Date(currentYear, currentMonth, dayCounter);
2631
+ const isToday = checkIsToday(currentDate, today);
2632
+ const isDisabled = checkIsDisabled(currentDate, min, max);
2633
+ rowCells.push(jsx("td", { children: jsx("div", { className: getDayStyles(isToday, isDisabled), onClick: () => !isDisabled && onDateClick(currentDate), children: dayCounter }) }, `day-${dayCounter}`));
2634
+ dayCounter++;
2635
+ }
2636
+ }
2637
+ calendarCells.push(jsx("tr", { children: rowCells }, `row-${i}`));
2638
+ }
2639
+ return calendarCells;
2640
+ };
2641
+ const checkIsToday = (currentDate, today) => today && currentDate.toDateString() === today.toDateString();
2642
+ const checkIsDisabled = (currentDate, min, max) => (min && currentDate.getTime() < min.getTime()) || (max && currentDate.getTime() > max.getTime());
2643
+ const getDayStyles = (isToday = false, isDisabled = false) => style('p-s text-center rounded-md border', {
2644
+ 'border-transparent hover:bg-gray': !isToday,
2645
+ }, isDisabled ? 'text-gray hover:bg-transparent' : 'cursor-pointer');
2501
2646
 
2502
- const OrganizationNameField = JSX(({ field, input }) => {
2503
- const onDaDataChange = useCallback((item) => {
2504
- field?.('inn')?.onChange?.(item.data?.inn);
2505
- field?.('legalForm')?.onChange?.(item.data?.opf?.short);
2647
+ const WEEK_DAYS = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
2648
+ const Calendar = JSX(({ today, currentMonth, currentYear, min, max, onDateSelect = noop, setValue = noop }) => {
2649
+ const handleDateClick = useCallback((date) => {
2650
+ onDateSelect(date);
2651
+ setValue(false);
2506
2652
  }, []);
2507
- return (jsx(InputControl, { label: "\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438", ...input, ...getValidation(field('organizationName'), validatorObj.organizationName, input?.required), onDaDataChange: onDaDataChange }));
2508
- });
2509
-
2510
- const OtherIncomeField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0418\u043D\u044B\u0435 \u0434\u043E\u0445\u043E\u0434\u044B", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", ...getValidation(field('otherIncome'), validatorObj.otherIncome, input?.required), ...input })));
2511
-
2512
- const ParticipantDateRegistrationField = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043F\u043E \u043C\u0435\u0441\u0442\u0443 \u0436\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u0430", ...getValidation(field('participantDateRegistration'), validatorObj.participantDateRegistration, input?.required) })));
2513
-
2514
- const MAX_PART = 100;
2515
- const PartInBusinessField = JSX(({ field, input }) => {
2516
- const isBusinessOwner = field('positionOrganization')?.value?.key === 'BUSINESS_OWNER';
2517
- const partInBusinessField = {
2518
- ...getValidation(field('partInBusiness'), validatorObj.partInBusiness, input?.required),
2519
- };
2520
- const handleChange = (value) => partInBusinessField?.onChange &&
2521
- partInBusinessField?.onChange(String(Number(value) > MAX_PART ? MAX_PART : Number(value) || ''));
2522
- return (jsx(InputControl, { label: "\u0414\u043E\u043B\u044F \u0443\u0447\u0430\u0441\u0442\u0438\u044F \u0432 \u0431\u0438\u0437\u043D\u0435\u0441\u0435", placeholder: "\u0432 %", type: "number", maxLength: 3, ...partInBusinessField, ...input, onChange: handleChange, value: isBusinessOwner ? partInBusinessField?.value : '', disabled: !isBusinessOwner }));
2523
- });
2524
-
2525
- const PartnerCommentsField = JSX(({ field, input }) => {
2526
- const { required, ...rest } = input;
2527
- return (jsx(InputControl, { ...getValidation(field('partnerComments'), validatorObj.partnerComments, required), placeholder: "\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u0438\u043D\u0442\u0435\u0440\u0435\u0441\u0443\u044E\u0449\u0438\u0439 \u0432\u0430\u0441 \u0432\u043E\u043F\u0440\u043E\u0441", isTextarea: true, ...rest }));
2653
+ const { firstDayOfWeek, totalDays } = useMemo(() => ({
2654
+ firstDayOfWeek: new Date(currentYear, currentMonth, 1).getDay() - 1,
2655
+ totalDays: new Date(currentYear, currentMonth + 1, 0).getDate(),
2656
+ }), [currentYear, currentMonth]);
2657
+ return (jsxs("table", { className: "mx-auto", children: [jsx("thead", { className: "text-gray font-light", children: jsx("tr", { children: WEEK_DAYS.map((day, index) => (jsx("th", { className: "p-s", children: day }, String(index)))) }) }), jsx("tbody", { children: renderCalendarCells({
2658
+ firstDayOfWeek,
2659
+ today,
2660
+ totalDays,
2661
+ currentYear,
2662
+ currentMonth,
2663
+ min,
2664
+ max,
2665
+ onDateClick: handleDateClick,
2666
+ }) })] }));
2528
2667
  });
2529
2668
 
2530
- const PAYMENT_SYSTEM_TYPES = [
2531
- { id: 'mir', text: 'Карта МИР' },
2532
- { id: 'union_pay', text: 'UnionPay' },
2669
+ const months = [
2670
+ 'Январь',
2671
+ 'Февраль',
2672
+ 'Март',
2673
+ 'Апрель',
2674
+ 'Май',
2675
+ 'Июнь',
2676
+ 'Июль',
2677
+ 'Август',
2678
+ 'Сентябрь',
2679
+ 'Октябрь',
2680
+ 'Ноябрь',
2681
+ 'Декабрь',
2533
2682
  ];
2534
- const PaymentSystemField = JSX(({ field, input }) => {
2535
- const { value, onChange } = field('paymentSystem');
2536
- return (jsx(RadioButtonGroupControl, { label: "\u041F\u043B\u0430\u0442\u0435\u0436\u043D\u0430\u044F \u0441\u0438\u0441\u0442\u0435\u043C\u0430", orientation: "horizontal", items: PAYMENT_SYSTEM_TYPES, value: value, onChange: (_) => onChange?.(_), ...getValidation(field('paymentSystem'), validatorObj.paymentSystem, input?.required) }));
2537
- });
2538
-
2539
- const isPlaceholder = (_) => _ === '_';
2540
- const isDigit = (_) => /\d/.test(_);
2541
- const isWildcard = (_) => isPlaceholder(_) || isDigit(_);
2542
- const phonePattern = [...'+7 (___) ___-__-__'];
2543
- const firstPlaceholderIndex = phonePattern.findIndex(isPlaceholder);
2544
- const phoneWildcardIndicies = phonePattern.map((_, i) => isWildcard(_) ? phonePattern.slice(0, i).filter(isWildcard).length : -1);
2545
- function normalizePhone(phone) {
2546
- const phoneNumbers = phone.replace(/\D/g, '');
2547
- const applyPlaceholder = (_, i) => isDigit(_) ? _ : phoneNumbers.charAt(phoneWildcardIndicies[i]) || _;
2548
- const result = phonePattern.map(applyPlaceholder);
2549
- const resultLength = phoneWildcardIndicies.indexOf(phoneNumbers.length - 1) + 1;
2550
- return (resultLength ? result.slice(0, Math.max(firstPlaceholderIndex, resultLength)) : result).join('');
2551
- }
2552
-
2553
- const PhoneInput = JSX(({ children, onChange, ...inputProps }) => {
2554
- const handleChange = useCallback((v) => onChange && onChange(normalizePhone(v)), [onChange]);
2555
- const handleBlur = useCallback((v) => {
2556
- if (v === '+7 (') {
2557
- onChange && onChange('');
2558
- }
2559
- }, []);
2560
- return (jsx(Input, { ...inputProps, onChange: handleChange, onFocus: (ev) => handleChange(ev?.target?.value || ''), onBlur: (ev) => handleBlur(ev?.target?.value || ''), children: children }));
2561
- });
2562
-
2563
- const InputPhoneControl = JSX(({ className, label, error, ...rest }) => (jsxs("div", { className: style('shrink-0 w-full', className), children: [jsx(PhoneInput, { "aria-label": label, label: getRequiredLabel({ label, errors: rest?.errors }), valid: Boolean(!error), placeholder: "+7 (___) ___-__-__", ...rest }), renderErrorText(error)] })));
2564
-
2565
- const PhoneField = JSX(({ field, input }) => {
2566
- const fieldName = input?.name || 'phone';
2567
- return (jsx(InputPhoneControl, { label: "\u0422\u0435\u043B\u0435\u0444\u043E\u043D", ...getValidation(field(fieldName), validatorObj.phone, input?.required), disabled: input?.filledByEsia && isEsiaAuthorize(field, fieldName), ...input }));
2568
- });
2569
-
2570
- const PositionOrganizationField = JSX(({ field, input }) => {
2571
- const { data: positionOrganization } = useLeadFormData('POSITION');
2572
- return (jsx(SelectField, { field: field, source: positionOrganization, label: "\u0414\u043E\u043B\u0436\u043D\u043E\u0441\u0442\u044C \u0432 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438", fieldName: "positionOrganization", input: input }));
2573
- });
2574
-
2575
- const PosTerminalField = JSX(({ field }) => isAcquiringTrade(field('acquiringType')?.value?.key) ? (jsx(SlideCheckbox, { type: "radio", text: "\u0425\u043E\u0447\u0443 POS-\u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B", ...field('posTerminal') })) : null);
2576
-
2577
- const ProductField = UniBlock(({ field, source }) => (jsx(SelectControl, { placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043F\u0440\u043E\u0434\u0443\u043A\u0442", label: "\u041F\u0440\u043E\u0434\u0443\u043A\u0442", options: arrayToOptions(source?.productList), ...withValidator(field('product'), validatorObj.product) })));
2578
- const arrayToOptions = (array) => (array ?? []).map((_) => ({ key: _, value: _ }));
2579
2683
 
2580
- const REGIONS_URL = `${API_BASE_URI}/regions`;
2581
- function useRegions(url = REGIONS_URL) {
2582
- const { data } = useAsyncData(url, fetchJSONUnsafe);
2583
- return Array.isArray(data) ? data : [];
2684
+ function normalizeWithMask(value, pattern) {
2685
+ const valueNumbers = value.replace(/\D/g, '');
2686
+ if (valueNumbers === '' || value?.length === pattern.length) {
2687
+ return value;
2688
+ }
2689
+ const patternInArr = [...pattern];
2690
+ const firstPlaceholderIndex = patternInArr.findIndex(isPlaceholder$1);
2691
+ const valueWildcardIndicies = patternInArr.map((_, i) => isWildcard$1(_) ? patternInArr.slice(0, i).filter(isWildcard$1).length : -1);
2692
+ const applyPlaceholder = (_, i) => isDigit$1(_) ? _ : valueNumbers.charAt(valueWildcardIndicies[i]) || _;
2693
+ const resultInArr = patternInArr.map(applyPlaceholder);
2694
+ const resultLength = valueWildcardIndicies.indexOf(valueNumbers.length - 1) + 1;
2695
+ return resultInArr.slice(0, Math.max(firstPlaceholderIndex, resultLength)).join('');
2584
2696
  }
2697
+ const isPlaceholder$1 = (_) => _ === '_';
2698
+ const isDigit$1 = (_) => /\d/.test(_);
2699
+ const isWildcard$1 = (_) => isPlaceholder$1(_) || isDigit$1(_);
2585
2700
 
2586
- const RegionField = JSX(({ field, input, url }) => {
2587
- const regions = useRegions(url);
2588
- return (jsx(SelectControl, { label: "\u0424\u0438\u043B\u0438\u0430\u043B", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0438\u043B\u0438\u0430\u043B", isSearch: true, options: useMemo(() => regions?.map(({ code = '', name = '' }) => ({ key: code, text: name })), [regions]), ...getValidation(field('region'), validatorObj.region, input?.required) }));
2589
- });
2590
-
2591
- const RegionPremiumField = JSX(({ field, input }) => {
2592
- const branchByRegions = useBranchesByRegions(true);
2593
- const regions = useMemo(() => branchByRegions?.map(({ region }) => ({
2594
- key: region,
2595
- text: region,
2596
- })), [branchByRegions]);
2597
- return (jsx(SelectControl, { label: "\u0420\u0435\u0433\u0438\u043E\u043D", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0435\u0433\u0438\u043E\u043D", options: regions, ...getValidation(field('region'), validatorObj.region, input?.required) }));
2598
- });
2599
-
2600
- const Foldable = JSX(({ className = '', isFoldButtonOnTop = false, unfoldedByDefault = false, renderFoldableSection, renderFoldButton, }) => {
2601
- const [isUnfolded, setIsUnfolded] = useState(unfoldedByDefault);
2602
- const onToggle = useCallback(() => {
2603
- setIsUnfolded((_) => !_);
2604
- }, []);
2605
- const sectionNode = renderFoldableSection({ isUnfolded, onToggle });
2606
- const buttonNode = renderFoldButton ? renderFoldButton({ isUnfolded, onToggle }) : null;
2607
- return isFoldButtonOnTop ? (jsxs("div", { className: className, role: "group", children: [buttonNode, sectionNode] })) : (jsxs("div", { className: className, role: "group", children: [sectionNode, buttonNode] }));
2608
- });
2701
+ const START_YEAR = 1940;
2702
+ const getYears = () => Array.from({ length: new Date().getFullYear() - START_YEAR + 1 }, (_, i) => START_YEAR + i);
2609
2703
 
2610
- function useResizeObserver(callback, deps) {
2704
+ const ICON_PROPS$1 = {
2705
+ name: 'CalendarIcon',
2706
+ iconVersion: 'black',
2707
+ width: '24',
2708
+ height: '24',
2709
+ };
2710
+ const DatePickerInput = JSX(({ setSelectedMonth, setSelectedYear, className, value, disabled, onChange, onClick }) => {
2611
2711
  const ref = useRef(null);
2612
- useEffect(() => {
2613
- const element = ref?.current;
2614
- if (!element) {
2615
- return undefined;
2712
+ const [inputValue, setInputValue] = useState(value || '');
2713
+ const handleChange = (ev) => {
2714
+ const val = ev.target?.value;
2715
+ if (typeof val === 'string' && val?.length < 11) {
2716
+ setInputValue(normalizeWithMask(val, '__.__.____'));
2616
2717
  }
2617
- const observer = new ResizeObserver((entries) => {
2618
- callback(element, entries[0]);
2619
- });
2620
- observer.observe(element);
2621
- return () => {
2622
- observer.disconnect();
2623
- };
2624
- }, [callback, ...deps]);
2625
- return ref;
2626
- }
2627
-
2628
- const FoldableSection = JSX(({ className = '', isUnfolded, children }) => {
2629
- const containerRef = useRef(null);
2630
- const childrenWrapperRef = useResizeObserver((childrenWrapperEl) => {
2631
- if (containerRef.current) {
2632
- containerRef.current.style.maxHeight = isUnfolded
2633
- ? `${childrenWrapperEl.scrollHeight}px`
2634
- : '';
2718
+ };
2719
+ const onBlur = () => {
2720
+ if (checkIsValidDate(inputValue)) {
2721
+ const [day, month, year] = inputValue.split('.');
2722
+ onChange?.(new Date(Number(year), Number(month) - 1, Number(day)));
2723
+ setSelectedMonth(Number(month) - 1);
2724
+ setSelectedYear(Number(year));
2635
2725
  }
2636
- }, [isUnfolded]);
2637
- return (jsx("div", { ref: containerRef, className: `transition-max-h duration-300 overflow-hidden ${containerRef.current || !isUnfolded ? 'max-h-0' : ''} `, children: jsx("div", { className: className, ref: childrenWrapperRef, children: children }) }));
2638
- });
2639
-
2640
- const CardCell = JSX(({ value, subText, children, isPhone, ...props }) => {
2641
- const textItems = (Array.isArray(value) ? value : value?.split(',') ?? []).filter(Boolean);
2642
- if ([textItems.length, children, subText].every((_) => !_)) {
2643
- return null;
2644
- }
2645
- return renderCardCell({ textItems, subText, children, isPhone, ...props });
2726
+ else {
2727
+ setInputValue(value || '');
2728
+ }
2729
+ };
2730
+ const onInputClick = () => {
2731
+ if (ref.current !== null) {
2732
+ ref.current.focus();
2733
+ }
2734
+ onClick?.();
2735
+ };
2736
+ useEffect(() => {
2737
+ setInputValue(value || '');
2738
+ }, [value]);
2739
+ return (jsxs("div", { onClick: onInputClick, className: style('relative', className), children: [jsx("input", { ref: ref, className: "h-full w-full px-m text-l text-black focus-visible:outline-none", value: inputValue, type: "text", onChange: handleChange, onBlur: onBlur, disabled: disabled }), disabled ? null : jsx(Icon, { className: "mr-s", ...ICON_PROPS$1 })] }));
2646
2740
  });
2647
- const renderCardCell = ({ label, labelSize = 'text-m', textItems, subColor, subText, className, children, isPhone = false, }) => (jsxs("div", { className: style('flex gap-2xs flex-col h-full max-w-[300px]', className), children: [label ? (jsx(Text, { color: "text-secondary-text", font: "font-light", size: labelSize, children: label })) : null, children || renderTextItems(textItems, isPhone), subText ? (jsx(Text, { color: subColor, size: "text-m", children: subText })) : null] }));
2648
- const renderTextItems = (textItems, isPhone) => textItems.filter(Boolean).map((text, i) => (jsx(Text, { size: "text-l", children: isPhone ? jsx("a", { href: `tel:${cleanPhoneNumber(text)}`, children: text.trim() }) : text.trim() }, String(i))));
2649
- const cleanPhoneNumber = (phone) => phone.replace(/\D/g, '');
2741
+ const isValidYear = (year) => Number(year) >= START_YEAR && Number(year) <= new Date().getFullYear();
2742
+ const isValidMonth = (month) => Number(month) > 0 && Number(month) < 13;
2743
+ const checkIsValidDate = (date) => {
2744
+ const [day, month, year] = date.split('.');
2745
+ if (isValidYear(year)) {
2746
+ if (isValidMonth(month)) {
2747
+ const currentDate = new Date(Number(year), Number(month) - 1, 1);
2748
+ let maxDateOfMonth = 0;
2749
+ while (currentDate.getMonth() === Number(month) - 1) {
2750
+ currentDate.setDate(currentDate.getDate() + 1);
2751
+ maxDateOfMonth++;
2752
+ }
2753
+ if (Number(day) > 0 && Number(day) <= maxDateOfMonth) {
2754
+ return true;
2755
+ }
2756
+ }
2757
+ }
2758
+ return false;
2759
+ };
2650
2760
 
2651
- const CardRow = JSX(({ className, children }) => (jsx("div", { className: style('flex flex-col sm:flex-row sm:border-t sm:border-solid sm:border-main-divider py-xl gap-x-6xl gap-y-xl', className), children: children })));
2761
+ const formStyle = 'flex justify-between items-center h-14 border rounded-md cursor-pointer ' +
2762
+ 'hover:border-black active:border-black focus:border-black';
2763
+ const renderDatePickerForm = ({ handleChangeVisibleCalendar, value, valid, onChange, setSelectedMonth, setSelectedYear, disabled = false, }) => (jsx(DatePickerInput, { onChange: onChange, disabled: disabled, onClick: handleChangeVisibleCalendar, value: value && formatDate(value), setSelectedMonth: setSelectedMonth, setSelectedYear: setSelectedYear, className: style(formStyle, valid ? 'border-gray' : 'border-error') }));
2652
2764
 
2653
- const getScheduleDescription = (workScheduleWeek) => {
2654
- const rows = getDateDescription(workScheduleWeek);
2655
- return jsx(CardCell, { label: "\u0420\u0435\u0436\u0438\u043C \u0440\u0430\u0431\u043E\u0442\u044B", value: rows, className: "max-w-none" });
2765
+ const MONTHS_COUNT = 11;
2766
+ const MONTHS_OPTIONS = months.map((key) => ({ key }));
2767
+ const YEARS_OPTIONS = getYears()
2768
+ .reverse()
2769
+ .map((key) => ({ key: String(key) }));
2770
+ const useDatePickerManager = ({ onShowCalendar, showCalendar, selectedMonth, onMonthSelect, onYearSelect, selectedYear, onChange, value, }) => {
2771
+ const close = useCallback(() => showCalendar && onShowCalendar(false), [showCalendar]);
2772
+ const ref = useOutsideClick(close);
2773
+ const handleChangeVisibleCalendar = useCallback(() => onShowCalendar(!showCalendar), [showCalendar]);
2774
+ const handleNextMonth = useCallback(() => {
2775
+ if (selectedMonth + 1 <= MONTHS_COUNT) {
2776
+ onMonthSelect(selectedMonth + 1);
2777
+ }
2778
+ else {
2779
+ onMonthSelect(0);
2780
+ onYearSelect(selectedYear + 1);
2781
+ }
2782
+ }, [selectedMonth]);
2783
+ const handlePrevMonth = useCallback(() => {
2784
+ if (selectedMonth - 1 >= 0) {
2785
+ onMonthSelect(selectedMonth - 1);
2786
+ }
2787
+ else {
2788
+ onMonthSelect(11);
2789
+ onYearSelect(selectedYear - 1);
2790
+ }
2791
+ }, [selectedMonth]);
2792
+ const handleSelectMonth = useCallback(({ key }) => {
2793
+ onMonthSelect(months.indexOf(key));
2794
+ const maxDateOfMonth = calculateMaxDaysOfMonth(selectedYear, months.indexOf(key));
2795
+ handleChangeMonth({
2796
+ maxDateOfMonth,
2797
+ selectedYear,
2798
+ selectedMonth: months.indexOf(key),
2799
+ value,
2800
+ onChange,
2801
+ });
2802
+ }, [value]);
2803
+ const handleSelectYear = useCallback(({ key }) => {
2804
+ onYearSelect(Number(key));
2805
+ value && onChange?.(new Date(Number(key), selectedMonth, value?.getDate()));
2806
+ }, [value]);
2807
+ return {
2808
+ handleChangeVisibleCalendar,
2809
+ handleNextMonth,
2810
+ handlePrevMonth,
2811
+ handleSelectMonth,
2812
+ handleSelectYear,
2813
+ monthsOptions: MONTHS_OPTIONS,
2814
+ yearsOptions: YEARS_OPTIONS,
2815
+ ref,
2816
+ };
2656
2817
  };
2657
- const buildScheduleText = ({ workTime = '', lunchHour = '', daysOff = '' }, isSaturday = false) => {
2658
- if (!workTime) {
2659
- return '';
2818
+ const calculateMaxDaysOfMonth = (selectedYear, selectedMonth) => {
2819
+ const date = new Date(selectedYear, selectedMonth, 1);
2820
+ let maxDateOfMonth = 0;
2821
+ while (date.getMonth() === selectedMonth) {
2822
+ maxDateOfMonth++;
2823
+ date.setDate(date.getDate() + 1);
2660
2824
  }
2661
- return [
2662
- `${isSaturday ? 'Суббота' : 'Будние дни'}: ${workTime}`,
2663
- lunchHour ? `перерыв: ${lunchHour}` : '',
2664
- daysOff ? `не работает: ${daysOff}` : '',
2665
- ]
2666
- .filter(Boolean)
2667
- .join('; ');
2825
+ return maxDateOfMonth;
2668
2826
  };
2669
- const getDateDescription = (workScheduleWeek) => {
2670
- const workingWeekday = workScheduleWeek.find((_) => _.key !== 'workingSaturday' && Boolean(_.status) && Boolean(_.workTime));
2671
- const workingSaturday = workScheduleWeek.find((_) => _.key === 'workingSaturday' && Boolean(_.status) && Boolean(_.workTime));
2672
- const daysOff = workScheduleWeek
2673
- .filter((_) => !_.status)
2674
- .map((_) => _.short?.toLowerCase())
2675
- .join(', ');
2676
- const rows = [
2677
- buildScheduleText({
2678
- workTime: workingWeekday?.workTime,
2679
- lunchHour: workingWeekday?.lunchHour,
2680
- daysOff: workingSaturday ? '' : daysOff,
2681
- }),
2682
- buildScheduleText({ workTime: workingSaturday?.workTime, lunchHour: workingSaturday?.lunchHour, daysOff }, true),
2683
- ].filter(Boolean);
2684
- return rows;
2827
+ const handleChangeMonth = ({ maxDateOfMonth, selectedYear, selectedMonth, value, onChange, }) => {
2828
+ value &&
2829
+ onChange?.(new Date(selectedYear, selectedMonth, Math.min(maxDateOfMonth, value.getDate())));
2685
2830
  };
2686
2831
 
2687
- const WEEKDAY_MAP = [
2688
- ['workingMonday', 'Пн', 'Понедельник'],
2689
- ['workingTuesday', 'Вт', 'Вторник'],
2690
- ['workingWednesday', 'Ср', 'Среда'],
2691
- ['workingThursday', 'Чт', 'Четверг'],
2692
- ['workingFriday', 'Пт', 'Пятница'],
2693
- ['workingSaturday', 'Сб', 'Суббота'],
2694
- ['workingSunday', 'Вс', 'Воскресенье'],
2695
- ];
2696
- const getWorkScheduleWeek = (workSchedule) => WEEKDAY_MAP.map(([key, short, title]) => ({
2697
- key,
2698
- title,
2699
- short,
2700
- status: Boolean(workSchedule?.[key]),
2701
- get workTime() {
2702
- return key === 'workingSaturday' ? workSchedule?.workTimeSaturday : workSchedule?.workTime;
2703
- },
2704
- get lunchHour() {
2705
- return key === 'workingSaturday' ? workSchedule?.lunchHourSaturday : workSchedule?.lunchHour;
2706
- },
2707
- get hasLunch() {
2708
- return /\d+/.test(this.lunchHour ?? '');
2709
- },
2710
- }));
2711
-
2712
- const renderBusinessSchedule = (scheduleDescription) => {
2713
- if (!scheduleDescription) {
2714
- return null;
2715
- }
2716
- const businessSchedule = getBusinessSchedule(scheduleDescription);
2717
- return (jsxs(CardRow, { className: "border-none", children: [jsx(CardCell, { label: "\u0414\u043B\u044F \u044E\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446", labelSize: "text-l", children: jsx("div", { className: "flex gap-1", children: businessSchedule.map(renderAlternativeDay) }) }), jsx(CardCell, { label: "\u0420\u0435\u0436\u0438\u043C \u0440\u0430\u0431\u043E\u0442\u044B", className: "max-w-none", children: jsx(Text, { children: scheduleDescription }) })] }));
2832
+ const ICON_PROPS = {
2833
+ name: 'ArrowUpIcon',
2834
+ iconVersion: 'black',
2835
+ width: '24',
2836
+ height: '24',
2718
2837
  };
2719
- const getBusinessSchedule = (scheduleDescription) => {
2720
- const weekDayMap = WEEKDAY_MAP.map(([, short]) => ({ short, status: true }));
2721
- const splittedScheduleDescription = scheduleDescription.split('/') ?? [];
2722
- const lastPartScheduleDescription = splittedScheduleDescription[splittedScheduleDescription.length - 1]?.toLowerCase();
2723
- if (!lastPartScheduleDescription?.includes('выходной')) {
2724
- return weekDayMap;
2725
- }
2726
- return weekDayMap.map((_) => ({
2727
- ..._,
2728
- status: !lastPartScheduleDescription?.includes(_.short.toLowerCase()),
2729
- }));
2838
+ const SELECT_PROPS = {
2839
+ className: 'min-w-32',
2840
+ iconVersion: 'black',
2841
+ isBorder: false,
2730
2842
  };
2731
- const renderAlternativeDay = ({ short, status }, i) => (jsx("div", { className: style('w-9 h-9 rounded-md flex items-center justify-center', status ? 'bg-green-more-light text-green-dark' : 'bg-error/30 text-error'), children: jsx(Text, { size: "text-xs", children: short }) }, String(i)));
2843
+ const DatePicker = JSX(
2844
+ // eslint-disable-next-line max-lines-per-function
2845
+ ({ className = '', label = '', value, valid = true, minDate, maxDate, disabled, onChange }) => {
2846
+ const [showCalendar, { setValue }] = useBool(false);
2847
+ const [selectedMonth, setSelectedMonth] = useState(value?.getMonth() || new Date().getMonth());
2848
+ const [selectedYear, setSelectedYear] = useState(value?.getFullYear() || new Date().getFullYear());
2849
+ const { handlePrevMonth, handleNextMonth, handleSelectMonth, handleSelectYear, monthsOptions, yearsOptions, handleChangeVisibleCalendar, ref, } = useDatePickerManager({
2850
+ onYearSelect: setSelectedYear,
2851
+ onMonthSelect: setSelectedMonth,
2852
+ onShowCalendar: setValue,
2853
+ selectedYear,
2854
+ selectedMonth,
2855
+ showCalendar,
2856
+ onChange,
2857
+ value,
2858
+ });
2859
+ const spaceAbove = useElementSpace(ref, 370);
2860
+ return (jsxs("div", { className: style('space-y-xs', className), ref: ref, children: [renderLabel(label), jsxs("div", { className: "relative", children: [renderDatePickerForm({
2861
+ handleChangeVisibleCalendar,
2862
+ value,
2863
+ valid,
2864
+ onChange,
2865
+ disabled,
2866
+ setSelectedMonth,
2867
+ setSelectedYear,
2868
+ }), showCalendar && !disabled ? (jsxs("div", { className: style('absolute bg-white z-20 select-none', {
2869
+ 'bottom-full': spaceAbove,
2870
+ }), children: [jsxs("div", { className: "flex gap-s", children: [jsx("div", { className: "my-auto", onClick: handlePrevMonth, children: jsx(Icon, { ...ICON_PROPS, className: "-rotate-90 cursor-pointer" }) }), jsx(Select, { onChange: handleSelectMonth, value: { key: months[selectedMonth] }, options: monthsOptions, ...SELECT_PROPS }), jsx(Select, { onChange: handleSelectYear, value: { key: String(selectedYear) }, options: yearsOptions, ...SELECT_PROPS }), jsx("div", { className: "my-auto", onClick: handleNextMonth, children: jsx(Icon, { ...ICON_PROPS, className: "rotate-90 cursor-pointer" }) })] }), jsx(Calendar, { today: value, currentMonth: selectedMonth, currentYear: selectedYear, onDateSelect: onChange, min: minDate, max: maxDate, setValue: setValue })] })) : null] })] }));
2871
+ });
2732
2872
 
2733
- const renderCurrency = ({ currency, buyExchangeRate, saleExchangeRate }, i) => (jsxs("div", { className: "flex gap-lg h-full", children: [currency?.currency ? jsx(CardCell, { label: "\u0412\u0430\u043B\u044E\u0442\u0430", value: currency.currency }) : null, buyExchangeRate ? jsx(CardCell, { label: "\u041A\u0443\u043F\u0438\u0442\u044C", value: String(buyExchangeRate) }) : null, saleExchangeRate ? jsx(CardCell, { label: "\u041F\u0440\u043E\u0434\u0430\u0442\u044C", value: String(saleExchangeRate) }) : null] }, String(i)));
2873
+ const DatePickerControl = JSX(({ className, label, error, errors, ...rest }) => (jsxs("div", { className: style('shrink-0 w-full', className), children: [jsx(DatePicker, { label: getRequiredLabel({ label, errors }), valid: Boolean(!error), ...rest }), renderErrorText(error)] })));
2734
2874
 
2735
- const colorStyle = {
2736
- yellow: { border: 'border-yellow-light', text: 'text-yellow' },
2737
- green: { border: 'border-green-more-light', text: 'text-green-dark' },
2738
- gray: { border: 'border-gray', text: 'text-secondary-text' },
2739
- red: { border: 'border-error/30', text: 'text-error' },
2740
- };
2741
- const Badge$1 = JSX(({ className, children, color = 'gray' }) => (jsxs("div", { className: style('sm:p-s sm:border sm:border-green rounded-md flex items-center h-fit', colorStyle[color].border, className), children: [jsx("div", { className: "block pr-m sm:pr-0 sm:hidden", children: jsx(Img, { image: { icon: 'SmallClockIcon' }, width: "24", height: "24" }) }), jsx(Text, { size: "text-m", color: colorStyle[color].text, children: children })] })));
2875
+ const BeginDateField = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u043D\u0430\u0447\u0430\u043B\u0430 \u0440\u0430\u0431\u043E\u0442\u044B \u043D\u0430 \u0442\u0435\u043A\u0443\u0449\u0435\u043C \u043C\u0435\u0441\u0442\u0435", ...getValidation(field('beginDate'), validatorObj.beginDate, input?.required), ...input })));
2742
2876
 
2743
- const currentWeekDayIdx = new Date().getDay();
2744
- //TODO: Add logic time https://github.com/redneckz/wildless-cms-uni-blocks/pull/1549
2745
- const renderCurrentDaySchedule = (workScheduleWeek) => {
2746
- const [currentWeekDay] = workScheduleWeek?.slice(currentWeekDayIdx - 1) ?? [];
2747
- if (!currentWeekDay) {
2748
- return null;
2877
+ const MIN_AGE = 23;
2878
+ const MAX_AGE = 75;
2879
+ const AGE_ERROR_MESSAGE = 'Допустимый возраст заёмщика - от 23 до 75 лет';
2880
+ const FIELD_NAME$8 = 'birthday';
2881
+ const BirthdayField = JSX(({ field, input, isRetailForm = false }) => {
2882
+ const { value } = field(FIELD_NAME$8);
2883
+ return (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u0440\u043E\u0436\u0434\u0435\u043D\u0438\u044F", ...getValidation(field(FIELD_NAME$8), validatorObj.birthday, input?.required), error: isRetailForm && value && !birthdayValidate(value) ? AGE_ERROR_MESSAGE : '', disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$8) }));
2884
+ });
2885
+ const birthdayValidate = (date) => {
2886
+ const today = new Date();
2887
+ const minDate = new Date(today.getFullYear() - MIN_AGE, today.getMonth(), today.getDate());
2888
+ const maxDate = new Date(today.getFullYear() - MAX_AGE, today.getMonth(), today.getDate());
2889
+ if (!date || date > minDate || date < maxDate) {
2890
+ return false;
2749
2891
  }
2750
- const { lunchHour, status, workTime, hasLunch } = currentWeekDay;
2751
- return status ? (jsxs("div", { className: "flex gap-s items-start whitespace-nowrap", children: [workTime ? jsx(Badge$1, { color: "green", children: workTime }) : null, lunchHour && hasLunch ? jsx(Badge$1, { color: "yellow", children: `перерыв: ${lunchHour}` }) : null] })) : (jsx(Badge$1, { color: "red", children: "\u0412\u044B\u0445\u043E\u0434\u043D\u043E\u0439" }));
2892
+ return true;
2752
2893
  };
2753
2894
 
2754
- const getSubTextLunch = ({ lunchHour, hasLunch = false, status = false }) => {
2755
- if (!status) {
2756
- return 'Не работает';
2757
- }
2758
- return lunchHour && hasLunch ? `Перерыв ${lunchHour}` : lunchHour;
2759
- };
2760
- const renderDay = ({ title, status, workTime, lunchHour, hasLunch }, i) => (jsx(CardCell, { label: title, value: status && workTime ? workTime : '', subText: getSubTextLunch({ lunchHour, hasLunch, status }), subColor: !status || hasLunch ? 'text-error' : 'text-green-dark' }, String(i)));
2895
+ const FIELD_NAME$7 = 'birthPlace';
2896
+ const BirthPlaceField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041C\u0435\u0441\u0442\u043E \u0440\u043E\u0436\u0434\u0435\u043D\u0438\u044F", ...getValidation(field('birthPlace'), validatorObj.birthPlace, input?.required), ...input, disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$7) })));
2761
2897
 
2762
- const ICONS$1 = ['ArrowDownIcon', 'ArrowUpIcon'];
2763
- const labels = ['Подробнее', 'Скрыть'];
2764
- const renderFoldButton$3 = ({ isUnfolded, onToggle }) => (jsxs("button", { className: "w-full py-2xl cursor-pointer text-primary-main flex items-center border-b border-solid border-main-divider", onClick: onToggle, type: "button", children: [jsx("div", { className: "pr-m", children: labels[Number(isUnfolded)] }), jsx(Icon, { className: "text-primary-text", name: ICONS$1[Number(isUnfolded)], width: "16", height: "16" })] }));
2898
+ const CardCategoryField = JSX(({ field, input }) => {
2899
+ const { data: cardCategory } = useLeadFormData('CARD_TYPE');
2900
+ return (jsx(SelectField, { field: field, source: cardCategory, label: "\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F \u043A\u0430\u0440\u0442\u044B", fieldName: "cardCategory", input: input }));
2901
+ });
2765
2902
 
2766
- const renderWorkSchedule = (workSchedule) => {
2767
- const workScheduleWeek = getWorkScheduleWeek(workSchedule);
2768
- const timeOfWork = workSchedule ? getDateDescription(workScheduleWeek) : '';
2769
- const businessTimeOfWork = workSchedule ? workSchedule.businessScheduleDescription : '';
2770
- if (!workSchedule) {
2771
- return null;
2772
- }
2773
- if (!workSchedule.businessScheduleVisibleTag) {
2774
- return renderMatchingTimeOfWork(timeOfWork);
2775
- }
2776
- if (workSchedule.businessScheduleVisibleTag &&
2777
- workSchedule.businessScheduleDescription === null) {
2778
- return renderIndividualTimeOfWork(timeOfWork);
2779
- }
2780
- return renderDefaultTimeOfWork(timeOfWork, businessTimeOfWork);
2781
- };
2782
- const renderIndividualTimeOfWork = (timeOfWork) => `<p><b>Режим обслуживания физ.лиц:<br/></b>${timeOfWork}</p>`;
2783
- const renderMatchingTimeOfWork = (timeOfWork) => `<p><b>Режим обслуживания физ. и юр. лиц:<br/></b> ${timeOfWork}</p>`;
2784
- const renderDefaultTimeOfWork = (timeOfWork, businessTimeOfWork) => `<p><b>Режим обслуживания физ.лиц:<br/></b>${timeOfWork}</p> <p><b>Режим обслуживания юр.лиц:<br/></b>${businessTimeOfWork}</p>`;
2903
+ const ChildrenField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0434\u0435\u0442\u0435\u0439 \u0434\u043E 18 \u043B\u0435\u0442", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", ...getValidation(field('children'), validatorObj.children, input?.required), ...input })));
2785
2904
 
2786
- const renderOfficeCard = ({ name, address, phone, fax, phoneBusiness, phoneNatural, phoneCallCentre, phoneCurrencyControl, workSchedule, exchangeRate, }, i) => {
2787
- if (!workSchedule) {
2788
- return null;
2789
- }
2790
- const workScheduleWeek = getWorkScheduleWeek(workSchedule);
2791
- return (jsxs("div", { className: "bg-white col-span-12 p-3xl sm:border-green sm:border", children: [jsxs("div", { className: "sm:flex sm:justify-between", children: [jsxs("div", { children: [jsx(Text, { size: "text-h4", children: name }), address ? (jsxs("div", { className: "flex pb-xl pt-xs gap-2xs", children: [jsx(Icon, { name: "GeolocationIcon", width: "24", height: "24" }), jsx(Text, { size: "text-l", children: address })] })) : null] }), renderCurrentDaySchedule(workScheduleWeek)] }), jsx("div", { className: "hidden sm:block", children: renderCardContent$1({
2792
- phone,
2793
- fax,
2794
- phoneBusiness,
2795
- phoneNatural,
2796
- phoneCallCentre,
2797
- phoneCurrencyControl,
2798
- workSchedule,
2799
- exchangeRate,
2800
- }) }), jsx(Foldable, { className: "block sm:hidden", renderFoldableSection: ({ isUnfolded }) => {
2801
- return (jsx(FoldableSection, { isUnfolded: isUnfolded, children: renderCardContent$1({
2802
- phone,
2803
- fax,
2804
- phoneBusiness,
2805
- phoneNatural,
2806
- phoneCallCentre,
2807
- phoneCurrencyControl,
2808
- workSchedule,
2809
- exchangeRate,
2810
- }) }));
2811
- },
2812
- //** TODO: remove styles with refactoring DefaultFoldButton*/
2813
- renderFoldButton: ({ isUnfolded, onToggle }) => renderFoldButton$3({ isUnfolded, onToggle }) })] }, String(i)));
2814
- };
2815
- const renderCardContent$1 = ({ phone, fax, phoneBusiness, phoneNatural, phoneCallCentre, phoneCurrencyControl, workSchedule, exchangeRate, }) => {
2816
- const workScheduleWeek = getWorkScheduleWeek(workSchedule);
2817
- const labelSchedule = workSchedule?.businessScheduleVisibleTag
2818
- ? 'Для физических лиц'
2819
- : 'Для физических и юридических лиц';
2820
- return (jsxs("div", { children: [jsxs(CardRow, { className: "flex-wrap border-b border-solid border-main-divider", children: [jsx(CardCell, { label: "\u0424\u0430\u043A\u0441", value: fax, isPhone: true }), jsx(CardCell, { label: "\u0422\u0435\u043B\u0435\u0444\u043E\u043D \u0444\u0438\u043B\u0438\u0430\u043B\u0430", value: phone, isPhone: true }), jsx(CardCell, { label: "\u0414\u043B\u044F \u043E\u0431\u0440\u0430\u0449\u0435\u043D\u0438\u0439 \u044E\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446", value: phoneBusiness, isPhone: true }), jsx(CardCell, { label: "\u041E\u0431\u0441\u043B\u0443\u0436\u0438\u0432\u0430\u043D\u0438\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446", value: phoneNatural, isPhone: true }), jsx(CardCell, { label: "\u0414\u043B\u044F \u043A\u043E\u043D\u0441\u0443\u043B\u044C\u0442\u0430\u0446\u0438\u0439 \u043F\u043E \u0432\u0430\u043B\u044E\u0442\u043D\u043E\u043C\u0443 \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044E", value: phoneCurrencyControl, isPhone: true }), jsx(CardCell, { label: "\u041A\u043E\u043D\u0442\u0430\u043A\u0442-\u0446\u0435\u043D\u0442\u0440", value: phoneCallCentre, isPhone: true })] }), workSchedule?.isMatchesPattern ? (jsx(CardRow, { children: jsx(CardCell, { label: labelSchedule, labelSize: "text-l", className: "w-full max-w-none", children: jsx("div", { className: "flex flex-wrap gap-xs sm:justify-between pt-xs", children: workScheduleWeek?.map(renderDay) }) }) })) : (jsxs(CardRow, { children: [jsx(CardCell, { label: labelSchedule, labelSize: "text-l", children: jsx("div", { className: "flex gap-1", children: workScheduleWeek?.map(renderAlternativeDay) }) }), getScheduleDescription(workScheduleWeek)] })), workSchedule?.businessScheduleVisibleTag
2821
- ? renderBusinessSchedule(workSchedule?.businessScheduleDescription)
2822
- : null, exchangeRate?.currencies?.length ? (jsx(CardRow, { className: "flex-wrap", children: exchangeRate?.currencies?.map(renderCurrency) })) : null] }));
2823
- };
2824
- const capitalizedFirstLetter$1 = (text) => text ? `${text?.charAt(0)?.toUpperCase()}${text?.slice(1)}` : '';
2825
- const getOfficePoint = ({ name = '', address = '', workSchedule }) => {
2826
- const header = capitalizedFirstLetter$1(name);
2827
- const body = `${address} ${renderWorkSchedule(workSchedule)}`;
2828
- return { header, body };
2829
- };
2905
+ const CodeWordField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u0434\u043E\u0432\u043E\u0435 \u0441\u043B\u043E\u0432\u043E", ...getValidation(field('codeWord'), validatorObj.codeWord, input?.required), ...input })));
2830
2906
 
2831
- const isSSR = () => Boolean(typeof globalThis.process === 'object' && globalThis.process && globalThis.process.version);
2907
+ const CollectionCountField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432 \u0438\u043D\u043A\u0430\u0441\u0441\u0430\u0446\u0438\u0438", type: "number", ...getValidation(field('collectionCount'), validatorObj.collectionCount, input?.required) })));
2832
2908
 
2833
- const isClient = !isSSR();
2834
- const ClientOnly = JSX(({ children }) => (isClient ? children : null));
2909
+ const CommentField = JSX(({ field, input }) => (jsx(InputControl, { className: "col-span-2", ...getValidation(field('comment'), validatorObj.comment, input?.required), placeholder: "\u0412\u0430\u0448\u0435 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435", isTextarea: true })));
2835
2910
 
2836
- const Loader = JSX(({ color = 'text-primary-main', position = 'absolute', blur = true }) => (jsx("div", { className: style('flex justify-center items-center h-full w-full z-50', position, {
2837
- 'backdrop-blur': blur,
2838
- }), children: jsx("div", { className: style('inline-block h-28 w-28', 'animate-spin rounded-full', 'border-8 border-solid border-current', 'border-r-transparent', color), role: "status" }) })));
2911
+ const ConfirmationIncomeField = JSX(({ field, input }) => {
2912
+ const { data: confirmationIncome } = useLeadFormData('INCOME_CERT_UNITED');
2913
+ return (jsx(SelectField, { field: field, source: confirmationIncome, label: "\u0421\u043F\u043E\u0441\u043E\u0431 \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u044F \u0434\u043E\u0445\u043E\u0434\u0430", fieldName: "confirmationIncome", input: input }));
2914
+ });
2839
2915
 
2840
- const MapMarkerClusterIcon = '/icons/MapMarkerClusterIcon.svg';
2841
- const MapMarkerClusterYellowIcon = '/icons/MapMarkerClusterYellowIcon.svg';
2842
- function renderClusterer({ yandexMaps, map, points, isLoad, }) {
2843
- if (isLoad || !points) {
2844
- return;
2845
- }
2846
- map.geoObjects.removeAll();
2847
- if (!points.length) {
2848
- return;
2849
- }
2850
- const clusterIconContentLayout = yandexMaps.templateLayoutFactory.createClass('<div style="margin-top: -3px;">{{properties.geoObjects.length}}</div>');
2851
- const officeClusterer = defineClusterer('offices', yandexMaps, clusterIconContentLayout);
2852
- if (points.length && points.every((_) => 'type' in _)) {
2853
- const remoteWorkplaceClusterer = defineClusterer('workplaces', yandexMaps, clusterIconContentLayout);
2854
- const remoteWorkplaceGeoObjects = defineGeoObjects(points.filter((_) => _.type === 'workplaces'), 'workplaces', yandexMaps);
2855
- const officesGeoObjects = defineGeoObjects(points.filter((_) => _.type === 'offices'), 'offices', yandexMaps);
2856
- officeClusterer.add(officesGeoObjects);
2857
- remoteWorkplaceClusterer.add(remoteWorkplaceGeoObjects);
2858
- map.geoObjects.add(remoteWorkplaceClusterer);
2859
- map.geoObjects.add(officeClusterer);
2860
- }
2861
- else {
2862
- const geoObjects = defineGeoObjects(points, 'offices', yandexMaps);
2863
- officeClusterer.add(geoObjects);
2864
- map.geoObjects.add(officeClusterer);
2865
- }
2866
- map.setBounds(yandexMaps.util.bounds.fromPoints(points.map((_) => _.coords))).then(() => {
2867
- if (map.getZoom() > 10) {
2868
- map.setZoom(10);
2869
- }
2870
- });
2871
- }
2872
- const defineClusterer = (type, yandexMaps, clusterIconContentLayout) => {
2873
- return new yandexMaps.Clusterer({
2874
- clusterIcons: [
2875
- {
2876
- href: type === 'offices' ? MapMarkerClusterIcon : MapMarkerClusterYellowIcon,
2877
- size: [78, 84],
2878
- offset: [-35, -50],
2879
- },
2880
- ],
2881
- clusterIconContentLayout,
2882
- clusterHideIconOnBalloonOpen: false,
2883
- geoObjectHideIconOnBalloonOpen: false,
2884
- });
2916
+ const ConscriptionField = JSX(({ field, input }) => {
2917
+ const { data: conscription } = useLeadFormData('MILITARY_STATUS');
2918
+ return (jsx(SelectField, { field: field, source: conscription, label: "\u0421\u0442\u0430\u0442\u0443\u0441 \u0432\u043E\u0435\u043D\u043D\u043E\u043E\u0431\u044F\u0437\u0430\u043D\u043D\u043E\u0433\u043E", fieldName: "conscription", input: input }));
2919
+ });
2920
+
2921
+ const CONSENTS = {
2922
+ processPersonalDataFlg: {
2923
+ text: 'Согласие на обработку персональных данных',
2924
+ docId: 4,
2925
+ },
2926
+ consentInformFlg: {
2927
+ text: 'Согласие на информирование о продуктах и услугах Банка',
2928
+ docId: 14,
2929
+ },
2930
+ consentProviderFlg: {
2931
+ text: 'Согласие об использовании простой электронной подписи',
2932
+ docId: 5,
2933
+ },
2934
+ consentOthersFlg: {
2935
+ text: 'Прочие согласия',
2936
+ docId: 1,
2937
+ },
2938
+ consentPfrFlg: {
2939
+ text: 'Согласие на запрос в ПФР',
2940
+ docId: 3,
2941
+ },
2942
+ consentToReceiveMaterials: {
2943
+ text: 'Согласен на получение информационных и аналитических материалов по электронной почте',
2944
+ },
2885
2945
  };
2886
- const defineGeoObjects = (pointArr, type, yandexMaps) => {
2887
- return pointArr.map(({ coords, content }) => new yandexMaps.Placemark(coords, {
2888
- balloonContentHeader: content?.header,
2889
- balloonContentBody: content?.body,
2890
- balloonContentFooter: content?.footer,
2891
- hintContent: content?.hint,
2892
- }, {
2893
- iconLayout: 'default#image',
2894
- iconImageHref: type === 'offices' ? MapMarkerClusterIcon : MapMarkerClusterYellowIcon,
2895
- iconImageSize: [78, 84],
2896
- iconImageOffset: [-35, -50],
2897
- }));
2946
+
2947
+ const feedbackById = async (id, convertToPng = false) => {
2948
+ const response = await doRequest(`/feedback/file?id=${encodeURIComponent(id)}&convertToPngFlg=${convertToPng}`, 'GET');
2949
+ return await response.blob();
2898
2950
  };
2899
2951
 
2900
- const defaultStyle = {
2901
- focus: 'focus:border-primary-text focus:border',
2902
- hover: 'hover:bg-primary-hover',
2903
- active: 'active:bg-primary-active',
2904
- font: 'text-center font-sans',
2952
+ const getDocument = async (id, convertToPng = false) => {
2953
+ const response = await feedbackById(id, convertToPng);
2954
+ return URL.createObjectURL(response);
2905
2955
  };
2906
2956
 
2907
- const styles$1 = {
2908
- ...defaultStyle,
2909
- border: 'border border-transparent rounded-md',
2910
- position: 'absolute flex items-center justify-center',
2957
+ const CloseButton = JSX(({ className, onClose }) => (jsx("button", { className: style('flex justify-center items-center w-12 h-12 p-2xs bg-transparent border-none', className), onClick: onClose, title: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C", type: "button", children: jsx(Icon, { name: "CloseIcon", width: "20", height: "20", iconVersion: "gray" }) })));
2958
+
2959
+ const Dialog = JSX(({ className, head, children, onClose, onClick }) => {
2960
+ const { close } = useDialogManager();
2961
+ const handleClose = useCallback(() => {
2962
+ close();
2963
+ onClose && onClose();
2964
+ }, [onClose]);
2965
+ return (jsxs("div", { onClick: onClick, className: style('relative min-h-full bg-white pt-0 p-lg', className), role: "dialog", children: [jsxs("div", { className: "sticky py-xl top-0 bg-white z-10", children: [jsx(CloseButton, { className: "absolute top-0 right-0", onClose: handleClose }), jsx("div", { className: "container", children: head })] }), jsx("div", { className: "container pb-6xl", children: children })] }));
2966
+ });
2967
+
2968
+ const openDocument = async (open, id, convertToPng = false) => {
2969
+ const document = await getDocument(id, convertToPng);
2970
+ open(jsx(Dialog, { className: "my-6xl max-w-4xl mx-auto px-0 min-h-0 pb-0", children: convertToPng ? (jsx("img", { src: document })) : (jsx("iframe", { src: `${document}#toolbar=0`, className: "w-full h-[80vh]", id: "iframe-dialog" })) }));
2911
2971
  };
2912
- const renderUserGeolocation = (map, yandexMaps, className) => {
2913
- const setUserGeoLocation = () => {
2914
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2915
- // @ts-ignore
2916
- yandexMaps.geolocation
2917
- .get({
2918
- provider: 'yandex',
2919
- autoReverseGeocode: true,
2920
- mapStateAutoApply: true,
2921
- })
2922
- .then(function (result) {
2923
- map.current.geoObjects.add(result.geoObjects);
2924
- });
2925
- };
2926
- return (jsx("div", { className: `select-none cursor-pointer py-m w-12 bg-white ${Object.values(styles$1).join(' ')} ${className}`, onClick: setUserGeoLocation, children: jsx(Icon, { name: "UserGeoLocationIcon", width: "20", height: "16" }) }));
2972
+
2973
+ const OPEN_DOC_BUTTON_TEXT = 'Ознакомиться';
2974
+ const CheckboxWithDoc = JSX(({ className, error, docId, ...props }) => {
2975
+ const { open } = useDialogManager();
2976
+ const isMobile = useMobileMode();
2977
+ return (jsxs("div", { className: className, children: [jsxs("div", { className: "flex flex-wrap gap-x-m", children: [jsx(Checkbox, { ...props }), docId ? (jsx(LinkButton, { className: "text-primary-main", onClick: () => openDocument(open, docId, isMobile), children: jsx(Text, { children: OPEN_DOC_BUTTON_TEXT }) })) : null] }), renderErrorText(error)] }));
2978
+ });
2979
+
2980
+ const ConsentField = JSX(({ field, input }) => input && input.name ? (jsx(CheckboxWithDoc, { text: CONSENTS[input.name]?.text, docId: CONSENTS[input.name]?.docId, ...getValidation(field(input.name), validatorObj[input.name], input?.required) })) : null);
2981
+
2982
+ const LABEL_TEXT = `Имеет ли юридическое лицо, акционером / участником / членом / пайщиком /
2983
+ вкладчиком с долей участия более 20% уставного капитала руководителем,
2984
+ которого Вы являетесь, кредит в АО «Россельхозбанк»`;
2985
+ const CreditInRshbCdField = JSX(({ field, input }) => {
2986
+ const { data: creditInRshbCd } = useLeadFormData('CREDIT_IN_RSHB');
2987
+ return (jsx(SelectField, { field: field, source: creditInRshbCd, label: LABEL_TEXT, fieldName: "creditInRshbCd", input: input }));
2988
+ });
2989
+
2990
+ const orientationStyleMap = {
2991
+ horizontal: '@lg:flex-row',
2992
+ vertical: '',
2927
2993
  };
2994
+ const RadioButtonGroup = JSX(({ label, items, value, className, onChange: onChangeCheckedItem, disabled = false, orientation = 'horizontal', }) => (jsxs("div", { className: "grid gap-xs whitespace-nowrap", children: [label ? (jsx("div", { role: "radiogroup", "aria-label": label, children: jsx(Text, { color: "text-secondary-text", font: "font-light", children: label }) })) : null, jsx("div", { className: style('flex flex-col gap-s', orientationStyleMap[orientation], className), role: "radiogroup", "aria-label": "\u0413\u0440\u0443\u043F\u043F\u0430 \u043A\u043D\u043E\u043F\u043E\u043A", children: items?.map(({ id, text }) => (jsx(Checkbox, { isRadio: true, text: text, value: value === id, onChange: () => onChangeCheckedItem && onChangeCheckedItem(id), disabled: disabled }, String(id)))) })] })));
2928
2995
 
2929
- const getNS = (_) => globalThis[_];
2930
- const initializeExternalNS = (namespaceName, url) => {
2931
- const script = document.getElementById(url);
2932
- if (script) {
2933
- const ns = getNS(namespaceName);
2934
- if (ns) {
2935
- return Promise.resolve(ns);
2936
- }
2937
- else {
2938
- return new Promise((resolve) => {
2939
- script.addEventListener('load', () => {
2940
- resolve(getNS(namespaceName));
2941
- });
2942
- });
2943
- }
2944
- }
2945
- else {
2946
- return new Promise((resolve, reject) => {
2947
- const newScript = document.createElement('script');
2948
- newScript.src = url;
2949
- newScript.async = true;
2950
- newScript.id = url;
2951
- newScript.addEventListener('load', () => {
2952
- resolve(getNS(namespaceName));
2953
- });
2954
- newScript.addEventListener('error', (error) => {
2955
- reject(error);
2956
- });
2957
- document.head.appendChild(newScript);
2958
- });
2959
- }
2960
- };
2961
- function useExternalNS(namespaceName, url, unmountNS = true) {
2962
- const [externalNS, setExternalNS] = useState(undefined);
2963
- useEffect(() => {
2964
- let isMounted = true;
2965
- initializeExternalNS(namespaceName, url)
2966
- .then((ns) => {
2967
- if (isMounted) {
2968
- setExternalNS(ns);
2969
- }
2970
- })
2971
- .catch((error) => {
2972
- console.error(`Failed to initialize external namespace: ${error}`);
2973
- });
2974
- return () => {
2975
- isMounted = false;
2976
- if (unmountNS) {
2977
- const script = document.getElementById(url);
2978
- if (script) {
2979
- document.head.removeChild(script);
2980
- }
2981
- setExternalNS(undefined);
2982
- }
2983
- };
2984
- }, [namespaceName, url, unmountNS]);
2985
- return externalNS;
2986
- }
2996
+ const RadioButtonGroupControl = JSX(({ className, label, onChange, error, ...rest }) => (jsxs("div", { className: style('shrink-0 w-full', className), children: [jsx(RadioButtonGroup, { label: getRequiredLabel({ label, errors: rest?.errors }), onChange: (_) => onChange && onChange(_), ...rest }), renderErrorText(error)] })));
2987
2997
 
2988
- const YMAPS_NAMESPACE = 'ymaps';
2989
- const useYandexMaps = () => {
2990
- const url = `https://api-maps.yandex.ru/2.1/?apikey=${projectSettings.YANDEX_MAP_API_KEY || ''}&lang=ru_RU`;
2991
- return useExternalNS(YMAPS_NAMESPACE, url, false);
2992
- };
2998
+ const CURRENCY_TYPES = [{ id: 'rub', text: 'Рубль' }];
2999
+ const CurrencyField = JSX(({ field, input }) => {
3000
+ const { value, onChange } = field('currency');
3001
+ return (jsx(RadioButtonGroupControl, { label: "\u0412\u0430\u043B\u044E\u0442\u0430", orientation: "horizontal", items: CURRENCY_TYPES, value: value, onChange: (_) => onChange?.(_), ...getValidation(field('currency'), validatorObj.currency, input?.required) }));
3002
+ });
2993
3003
 
2994
- const styles = {
2995
- ...defaultStyle,
2996
- border: 'border-b border-b-2 border-gray last:border-0',
2997
- position: 'relative flex items-center justify-center',
2998
- };
2999
- // TODO: Добавить метод определения центральной точки
3000
- const ZoomButton = JSX(({ yandexMaps, direction = 'in' }) => {
3001
- const iconName = direction === 'in' ? 'PlusIcon' : 'MinusIcon';
3002
- const changeZoom = () => {
3003
- const currentZoom = yandexMaps.current.getZoom();
3004
- const newZoom = direction === 'in' ? currentZoom + 1 : currentZoom - 1;
3005
- yandexMaps.current.setZoom(newZoom, { checkZoomRange: true });
3006
- };
3007
- return (jsx("div", { onClick: changeZoom, className: `${Object.values(styles).join(' ')} bg-white select-none cursor-pointer w-12 h-12`, children: jsx(Icon, { name: iconName, width: "20", height: "16" }) }));
3004
+ const DeliveryDateFiels = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u0434\u043E\u0441\u0442\u0430\u0432\u043A\u0438", ...getValidation(field('deliveryDate'), validatorObj.deliveryDate, input?.required) })));
3005
+
3006
+ const DependentsField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0438\u0436\u0434\u0438\u0432\u0435\u043D\u0446\u0435\u0432", placeholder: "\u0417\u0430 \u0438\u0441\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435 \u0434\u0435\u0442\u0435\u0439 \u0434\u043E 18 \u043B\u0435\u0442", type: "number", maxLength: 2, ...getValidation(field('dependents'), validatorObj.dependents, input?.required), ...input })));
3007
+
3008
+ const DesiredMeetingDateField = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0416\u0435\u043B\u0430\u0435\u043C\u0430\u044F \u0434\u0430\u0442\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0438", ...getValidation(field('desiredMeetingDate'), validatorObj.meetingDay, input?.required) })));
3009
+
3010
+ const DisablePeopleFlgField = JSX(({ field, input }) => (jsx(CheckboxWithError, { text: "\u042F\u0432\u043B\u044F\u044E\u0441\u044C \u0438\u043D\u0432\u0430\u043B\u0438\u0434\u043E\u043C", ...getValidation(field('disablePeopleFlg'), validatorObj.disablePeopleFlg, input?.required) })));
3011
+
3012
+ const FIELD_NAME$6 = 'dulIssueDateField';
3013
+ const DulIssueDateField = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u0432\u044B\u0434\u0430\u0447\u0438", ...getValidation(field(FIELD_NAME$6), validatorObj.dulIssueDateField, input?.required), disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$6) })));
3014
+
3015
+ const FIELD_NAME$5 = 'dulIssuedBy';
3016
+ const DulIssuedByField = JSX(({ field, input }) => {
3017
+ const { value: dulSubdivisionCode, onChange: changeDulSubdivisionCode } = field('dulSubdivisionCode');
3018
+ const onDaDataChange = useCallback((item) => {
3019
+ changeDulSubdivisionCode?.(item?.data?.code?.replace('-', ''));
3020
+ }, []);
3021
+ return (jsx(InputControl, { disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$5), label: "\u041A\u0435\u043C \u0432\u044B\u0434\u0430\u043D", ...input, ...getValidation(field(FIELD_NAME$5), validatorObj.dulIssuedBy, input?.required), onDaDataChange: onDaDataChange, daDataQueryPrefix: dulSubdivisionCode }));
3008
3022
  });
3009
3023
 
3010
- const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
3011
- // TODO: Поле для поиска: невыяснено среди каких данных делать поиск (искать в имени офиса, в адресе, метро и т.д.).
3012
- // Сейчас реализован поиск среди тестовых данных
3013
- // TODO: Также выяснить что делать когда ничего не найдено
3014
- // TODO: На макетах также когда есть поле поиска нет кнопки открыть на карте.
3015
- const YandexMap = JSX(({ points, className = '', zoom = 5, isLoad, selectedAddress }) => {
3016
- const map = useRef(null);
3017
- const yandexMaps = useYandexMaps();
3018
- useEffect(() => {
3019
- if (map.current) {
3020
- renderClusterer({ yandexMaps, map: map.current, points, isLoad });
3021
- }
3022
- else {
3023
- yandexMaps?.ready(() => {
3024
- // Ready function may be called few times, but must be called once
3025
- if (map.current) {
3026
- renderClusterer({ yandexMaps, map: map.current, points, isLoad });
3027
- return;
3028
- }
3029
- map.current = new yandexMaps.Map('map', {
3030
- center: getCenterPoint(points),
3031
- zoom,
3032
- controls: [],
3033
- suppressMapOpenBlock: true,
3034
- });
3035
- renderClusterer({ yandexMaps, map: map.current, points, isLoad });
3036
- });
3037
- }
3038
- }, [yandexMaps, points, zoom, isLoad, selectedAddress]);
3024
+ const FIELD_NAME$4 = 'dulNumber';
3025
+ const DulNumberField = JSX(({ field, input }) => (jsx(InputControl, { disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$4), label: "\u041D\u043E\u043C\u0435\u0440 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430", type: "number", maxLength: 6, ...getValidation(field('dulNumber'), validatorObj.dulNumber, input?.required) })));
3026
+
3027
+ const FIELD_NAME$3 = 'dulSerie';
3028
+ const DulSerieField = JSX(({ field, input }) => (jsx(InputControl, { disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$3), label: "\u0421\u0435\u0440\u0438\u044F \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430", type: "number", maxLength: 4, ...getValidation(field('dulSerie'), validatorObj.dulSerie, input?.required) })));
3029
+
3030
+ const FIELD_NAME$2 = 'dulSubdivisionCode';
3031
+ const DulSubdivisionCodeField = JSX(({ field, input }) => {
3032
+ const onDaDataChange = useCallback((item) => {
3033
+ field?.('dulIssuedBy')?.onChange?.(item?.data?.name);
3034
+ }, []);
3035
+ return (jsx(InputControl, { disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$2), label: "\u041A\u043E\u0434 \u043F\u043E\u0434\u0440\u0430\u0437\u0434\u0435\u043B\u0435\u043D\u0438\u044F", type: "number", maxLength: 6, ...input, ...getValidation(field(FIELD_NAME$2), validatorObj.dulSubdivisionCode, input?.required), onDaDataChange: onDaDataChange }));
3036
+ });
3037
+
3038
+ const EducationField = JSX(({ field, input }) => {
3039
+ const { data: education } = useLeadFormData('EDUCATION_LEVEL');
3040
+ return (jsx(SelectField, { field: field, source: education, label: "\u041E\u0431\u0440\u0430\u0437\u043E\u0432\u0430\u043D\u0438\u0435", fieldName: "education", input: input }));
3041
+ });
3042
+
3043
+ const EmailField = JSX(({ field, input }) => {
3044
+ const { required, ...rest } = input;
3045
+ return (jsx(InputControl, { label: "\u042D\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u0430\u044F \u043F\u043E\u0447\u0442\u0430", ...getValidation(field('email'), validatorObj.email, required), ...rest }));
3046
+ });
3047
+
3048
+ const EmployerActivitiesField = JSX(({ field, input }) => {
3049
+ const { data: employerActivities } = useLeadFormData('ORGANIZATION_ACTIVITY_TYPE');
3050
+ return (jsx(SelectField, { field: field, source: employerActivities, label: "\u0412\u0438\u0434 \u0434\u0435\u044F\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u0438 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438-\u0440\u0430\u0431\u043E\u0442\u043E\u0434\u0430\u0442\u0435\u043B\u044F", fieldName: "employerActivities", input: input }));
3051
+ });
3052
+
3053
+ const EmployerOrganizationField = JSX(({ field, input }) => {
3054
+ const { data: employerOrganization } = useLeadFormData('ORGANIZATION_KIND');
3055
+ return (jsx(SelectField, { field: field, source: employerOrganization, label: "\u0412\u0438\u0434 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043E\u0442\u043E\u0434\u0430\u0442\u0435\u043B\u044F", fieldName: "employerOrganization", input: input }));
3056
+ });
3057
+
3058
+ const EmploymentField = JSX(({ field, input }) => {
3059
+ const { data: employment } = useLeadFormData('EMPLOYMENT_INFO_UNITED');
3060
+ return (jsx(SelectField, { field: field, source: employment, label: "\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u0442\u0440\u0443\u0434\u043E\u0443\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432\u0435", fieldName: "employment", input: input }));
3061
+ });
3062
+
3063
+ const ExpensesField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0440\u0430\u0441\u0445\u043E\u0434\u044B \u0432 \u043C\u0435\u0441\u044F\u0446", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", ...getValidation(field('expenses'), validatorObj.expenses, input?.required), ...input })));
3064
+
3065
+ const Experience5YearsField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0421\u0442\u0430\u0436", placeholder: "\u0417\u0430 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435 5 \u043B\u0435\u0442", type: "number", maxLength: 2, ...getValidation(field('experience5Years'), validatorObj.experience5Years, input?.required), ...input })));
3066
+
3067
+ const FamilyMembersField = JSX(({ field }) => {
3068
+ const { value, onChange } = field('familyMembers');
3069
+ const familyStatusKey = field('familyStatus')?.value?.key;
3070
+ const adultsCount = familyStatusKey === 'MARRIED' ? 2 : 1;
3071
+ const childrenCount = Number(field('children')?.value);
3072
+ const dependentsCount = Number(field('dependents')?.value);
3073
+ const totalCount = adultsCount + childrenCount + dependentsCount;
3039
3074
  useEffect(() => {
3040
- if (map.current && selectedAddress) {
3041
- yandexMaps?.geocode(selectedAddress).then((res) => {
3042
- const firstGeoObject = res.geoObjects.get(0);
3043
- const coords = firstGeoObject.geometry.getCoordinates();
3044
- map.current.setCenter(coords);
3045
- map.current.setZoom(18);
3046
- });
3047
- }
3048
- }, [selectedAddress]);
3049
- if (!yandexMaps) {
3050
- return null;
3051
- }
3052
- const zIndex = 'z-10';
3053
- return (jsxs("div", { id: "map", className: style('relative', 'w-full', className), children: [isLoad ? jsx(Loader, {}) : null, jsxs("div", { className: style('absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md', zIndex), children: [jsx(ZoomButton, { yandexMaps: map }), jsx(ZoomButton, { yandexMaps: map, direction: "out" })] }), renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))] }));
3075
+ field?.('familyMembers')?.onChange?.(totalCount);
3076
+ }, [familyStatusKey, childrenCount, dependentsCount]);
3077
+ return (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0447\u043B\u0435\u043D\u043E\u0432 \u0441\u0435\u043C\u044C\u0438", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", disabled: true, value: value, onChange: (_) => onChange?.(_) }));
3054
3078
  });
3055
- const getCenterPoint = (points) => {
3056
- const centerCoords = [
3057
- getArraySumAndAverage(mapByIndex(points, 0)),
3058
- getArraySumAndAverage(mapByIndex(points, 1)),
3059
- ];
3060
- return centerCoords.every((_) => _) ? centerCoords : DEFAULT_CENTER_COORDS;
3061
- };
3062
- const mapByIndex = (points, index) => points.map((_) => _.coords?.[index]);
3063
- const getArraySumAndAverage = (arr) => arr.length && arr.reduce((a, b) => a + b) / arr.length;
3064
3079
 
3065
- const INITIAL_FILTRATION_STATE$1 = {
3066
- workingSaturday: false,
3067
- premiumService: false,
3068
- privateBanking: false,
3069
- remoteWorkplace: false,
3070
- serviceDisabledPeople: false,
3071
- sellingCoins: false,
3072
- buyingCoins: false,
3073
- bullionOperations: false,
3074
- preciousMetalsOperations: false,
3075
- transferringDataToBiometricSystem: false,
3076
- };
3077
- const FILTRATION_LABELS = {
3078
- safeBoxCaseVolumes: 'Аренда индивидуальных сейфовых ячеек',
3079
- workingSaturday: 'Открыты по субботам',
3080
- terminalTypeAtms: 'Банкоматы',
3081
- terminalTypeTerm: 'Терминалы',
3082
- workAllTime: 'Круглосуточно',
3083
- billAcceptorEnable: 'Прием наличных',
3084
- premiumService: 'Премиальное обслуживание',
3085
- privateBanking: 'Услуга Private banking',
3086
- sellingCoins: 'Продажа монет из драгоценных металлов',
3087
- buyingCoins: 'Покупка монет из драгоценных металлов',
3088
- bullionOperations: 'Операции со слитками',
3089
- preciousMetalsOperations: 'Операции с драгоценными металлами',
3090
- transferringDataToBiometricSystem: 'Передача фото и голоса в Единую биометрическую систему',
3091
- locationDisabledPeople: 'Для маломобильных',
3092
- designDisabledPeople: 'Для слабовидящих',
3093
- remoteWorkplace: 'Удаленное рабочее место',
3094
- serviceDisabledPeople: 'Для маломобильных граждан',
3095
- };
3096
- const FILTRATION_PREDICATES$1 = {
3097
- workingSaturday: (item) => Boolean('workSchedule' in item && item.workSchedule?.workingSaturday),
3098
- premiumService: (item) => Boolean('premiumService' in item && item.premiumService),
3099
- privateBanking: (item) => Boolean('privateBanking' in item && item.privateBanking),
3100
- remoteWorkplace: (item) => Boolean('workScheduleDescription' in item),
3101
- serviceDisabledPeople: (item) => Boolean('serviceDisabledPeople' in item && item.serviceDisabledPeople),
3102
- sellingCoins: (item) => Boolean('sellingCoins' in item && item.sellingCoins),
3103
- buyingCoins: (item) => Boolean('buyingCoins' in item && item.buyingCoins),
3104
- bullionOperations: (item) => Boolean('bullionOperations' in item && item.bullionOperations),
3105
- preciousMetalsOperations: (item) => Boolean('preciousMetalsOperations' in item && item.preciousMetalsOperations),
3106
- transferringDataToBiometricSystem: (item) => Boolean('transferringDataToBiometricSystem' in item && item.transferringDataToBiometricSystem),
3107
- };
3080
+ const FamilyStatusField = JSX(({ field, input }) => {
3081
+ const { data: familyStatus } = useLeadFormData('MARITAL_STATUS');
3082
+ return (jsx(SelectField, { field: field, source: familyStatus, label: "\u0421\u0435\u043C\u0435\u0439\u043D\u043E\u0435 \u043F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0435", fieldName: "familyStatus", input: input }));
3083
+ });
3084
+
3085
+ const SERVICE_TYPES = [
3086
+ { key: 'ULTRASERVICE', text: 'Ультра' },
3087
+ { key: 'PREMIUMSERVICE', text: 'Премиум' },
3088
+ ];
3089
+ const SERVICE_DIRECTIONS = [
3090
+ { key: 'Физическое лицо' },
3091
+ { key: 'Юридическое лицо / ИП' },
3092
+ ];
3093
+ const FEEDBACK_METHOD = [
3094
+ { key: 'phone', text: 'Телефонный звонок' },
3095
+ { key: 'email', text: 'Электронное сообщение' },
3096
+ ];
3097
+
3098
+ const FeedbackMethodField = JSX(({ field, input }) => (jsx(SelectControl, { label: "\u0421\u043F\u043E\u0441\u043E\u0431 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u044F \u043E\u0442\u0432\u0435\u0442\u0430", options: FEEDBACK_METHOD, ...getValidation(field('feedbackMethod'), validatorObj.feedbackMethod, input?.required) })));
3099
+
3100
+ const FullNameField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0424\u0418\u041E", ...getValidation(field('fullName'), validatorObj.fullName, input?.required), ...input })));
3101
+
3102
+ const GeneralSeniorityField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u0431\u0449\u0438\u0439 \u0441\u0442\u0430\u0436", type: "number", maxLength: 2, placeholder: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043B\u0435\u0442", ...getValidation(field('generalSeniority'), validatorObj.generalSeniority, input?.required), ...input })));
3103
+
3104
+ const HousingField = JSX(({ field, input }) => {
3105
+ const { data: housing } = useLeadFormData('HOUSE_TYPE');
3106
+ return (jsx(SelectField, { field: field, source: housing, label: "\u0422\u0438\u043F \u0436\u0438\u043B\u044C\u044F", fieldName: "housing", input: input }));
3107
+ });
3108
+
3109
+ const InnField = JSX(({ field, input }) => {
3110
+ const onDaDataChange = useCallback((item) => {
3111
+ field?.('organizationName')?.onChange?.(item.data?.name?.short_with_opf);
3112
+ field?.('legalForm')?.onChange?.(item.data?.opf?.short);
3113
+ }, []);
3114
+ return (jsx(InputControl, { label: "\u0418\u041D\u041D", type: "number", maxLength: 12, ...input, ...getValidation(field('inn'), validatorObj.inn, input?.required), onDaDataChange: onDaDataChange }));
3115
+ });
3116
+
3117
+ const IsClientField = JSX(({ field }) => (jsx(CheckboxWithError, { ...field('isClient'), text: '\u042F\u0432\u043B\u044F\u044E\u0441\u044C \u043A\u043B\u0438\u0435\u043D\u0442\u043E\u043C \u0431\u0430\u043D\u043A\u0430 \u0410\u041E "\u0420\u043E\u0441\u0441\u0435\u043B\u044C\u0445\u043E\u0437\u0431\u0430\u043D\u043A"' })));
3118
+
3119
+ const JobsNumberField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u0442 \u0440\u0430\u0431\u043E\u0442\u044B \u0437\u0430 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435 5 \u043B\u0435\u0442", placeholder: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u0442", type: "number", maxLength: 2, ...getValidation(field('jobsNumber'), validatorObj.jobsNumber, input?.required), ...input })));
3120
+
3121
+ const LastJobExperienceField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0421\u0442\u0430\u0436 \u043D\u0430 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0435\u043C \u0440\u0430\u0431\u043E\u0447\u0435\u043C \u043C\u0435\u0441\u0442\u0435", placeholder: "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043B\u0435\u0442", type: "number", maxLength: 2, ...getValidation(field('lastJobExperience'), validatorObj.lastJobExperience, input?.required), ...input })));
3122
+
3123
+ const LegalEntityNameField = JSX(({ field, input }) => {
3124
+ return (jsx(InputControl, { label: "\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435 \u044E\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043A\u043E\u0433\u043E \u043B\u0438\u0446\u0430", ...input, ...getValidation(field('legalEntityName'), validatorObj.legalEntityName, input?.required) }));
3125
+ });
3108
3126
 
3109
- function useButton() {
3110
- return (props) => ({
3111
- ...props,
3112
- onClick: handlerDecorator(handleClick(props)),
3113
- });
3114
- }
3115
- function handleClick({ disabled, onClick }) {
3116
- return (ev) => {
3117
- !disabled && onClick && onClick(ev);
3118
- };
3127
+ const LegalFormField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u041F\u0424", placeholder: "\u041E\u041E\u041E, \u041F\u0410\u041E \u0438 \u0434\u0440.", ...getValidation(field('legalForm'), validatorObj.legalForm, input?.required), ...input })));
3128
+
3129
+ const OUT_SERVICE_BASE_URL = `${API_BASE_URI}/outservice`;
3130
+ const EMPTY_REGIONS = [];
3131
+ async function getOutServiceRegions() {
3132
+ const data = await fetchJSON(`${OUT_SERVICE_BASE_URL}/outserviceregions`);
3133
+ return data && Array.isArray(data) ? data : EMPTY_REGIONS;
3119
3134
  }
3120
3135
 
3121
- const buttonStyleMap = {
3122
- primary: 'text-white bg-primary-main hover:bg-primary-hover active:bg-primary-active',
3123
- secondary: 'text-primary-main bg-main-divider hover:text-white hover:bg-primary-hover active:bg-primary-active',
3124
- };
3125
- const secondaryButtonStyleMap = {
3126
- primary: style('group-data-secondary:text-primary-main group-data-secondary:bg-white', 'group-data-secondary:hover:text-white group-data-secondary:hover:bg-primary-hover', 'group-data-secondary:active:bg-primary-active'),
3127
- secondary: style('group-data-secondary:text-white group-data-secondary:bg-white/20', 'group-data-secondary:hover:bg-primary-hover', 'group-data-secondary:active:bg-primary-active'),
3128
- };
3129
- const Button = JSX(({ children, ...props }) => {
3130
- const button = useButton();
3131
- const { className, version = 'primary', active, disabled, type = 'button', rounded = true, role, onClick, } = button(props);
3132
- return (jsx("button", { className: style('font-sans px-9 py-4', 'flex justify-center items-center gap-xs', {
3133
- 'text-white bg-primary-active': active,
3134
- 'bg-main-gray text-main-disabled cursor-not-allowed': disabled,
3135
- 'rounded-md': rounded,
3136
- }, !active && !disabled
3137
- ? style(buttonStyleMap[version], secondaryButtonStyleMap[version])
3138
- : '', className), type: type, role: role, onClick: onClick, children: children }));
3136
+ const LocalitiesField = JSX(({ field, input }) => {
3137
+ const fieldRegion = field('region');
3138
+ const regionKey = fieldRegion?.value?.key;
3139
+ const { data: regions } = useAsyncData('outServiceRegions', getOutServiceRegions);
3140
+ const localities = regions
3141
+ ?.find((_) => _.code === regionKey)
3142
+ ?.localities?.map((_) => ({ key: _, text: _ }));
3143
+ useEffect(() => {
3144
+ if (regionKey !== '') {
3145
+ field?.('localities')?.onChange?.('');
3146
+ }
3147
+ }, [regionKey]);
3148
+ return (jsx(SelectControl, { label: "\u041D\u0430\u0441\u0435\u043B\u0435\u043D\u043D\u044B\u0439 \u043F\u0443\u043D\u043A\u0442", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0433\u043E\u0440\u043E\u0434, \u0433\u0434\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0441\u0435\u0440\u0432\u0438\u0441", options: localities, ...getValidation(field('localities'), validatorObj.localities, input?.required), isSearch: true }));
3139
3149
  });
3140
3150
 
3141
- const getVersion = (isPrimary, type) => isPrimary && type !== 'underlined' ? 'primary' : 'secondary';
3151
+ const MandatoryPaymentsField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0432\u044B\u043F\u043B\u0430\u0442\u044B", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", ...getValidation(field('mandatoryPayments'), validatorObj.mandatoryPayments, input?.required), ...input })));
3142
3152
 
3143
- const renderButtonsGroup = (data, activeButton, onButtonClick) => {
3144
- const allButtonVersion = getVersion(activeButton === 'all');
3145
- const businessButtonVersion = getVersion(activeButton === 'business');
3146
- const handleClick = (e, key, branches) => {
3147
- const filteredBranches = e.currentTarget === e.target && key === 'business' ? filterBranches(branches) : branches;
3148
- onButtonClick(key);
3149
- return filteredBranches;
3150
- };
3151
- const filterBranches = (branches) => branches.filter((branch) => branch.workSchedule &&
3152
- branch.workSchedule.businessScheduleVisibleTag &&
3153
- !branch.workSchedule.businessScheduleDescription);
3154
- return (jsxs("div", { className: "flex gap-lg flex-col sm:flex-row pb-lg", children: [jsx(Button, { "data-id": "all", onClick: (e) => handleClick(e, 'all', data), version: allButtonVersion, children: "\u0414\u043B\u044F \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446" }), jsx(Button, { "data-id": "business", onClick: (e) => handleClick(e, 'business', data), version: businessButtonVersion, children: "\u0414\u043B\u044F \u044E\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043B\u0438\u0446" })] }));
3155
- };
3153
+ const METHODS_OF_OBTAIN = [
3154
+ { id: 'office', text: отделении Банка' },
3155
+ { id: 'courier', text: 'Курьерская доставка' },
3156
+ ];
3157
+ const MethodObtainField = JSX(({ field, input }) => (jsx(RadioButtonGroupControl, { orientation: "horizontal", items: METHODS_OF_OBTAIN, ...getValidation(field('methodObtain'), validatorObj.methodObtain, input?.required) })));
3156
3158
 
3157
- const renderDescriptionBlock$1 = ({ __html, list, richVersion }) => __html || list?.length ? (jsxs("div", { className: "mb-2xl border-b sm:border border-main-divider sm:rounded-md", children: [__html ? (jsx("div", { className: "mb-2xl", children: jsx(RichText, { __html: __html, richVersion: richVersion }) })) : null, list?.length ? (jsx("div", { className: "flex flex-col sm:flex-row gap-2xl sm:flex-wrap pb-2xl sm:pb-xl", children: list.map((item, i) => (jsxs("div", { className: "flex gap-xs items-center", children: [item?.image ? jsx(Img, { image: item.image }) : null, item?.text ? (jsx(Text, { size: "text-m", font: "font-light", children: item.text })) : null] }, String(i)))) })) : null] })) : null;
3159
+ const FIELD_NAME$1 = 'middleName';
3160
+ const MiddleNameField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u0442\u0447\u0435\u0441\u0442\u0432\u043E (\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E, \u043F\u0440\u0438 \u043D\u0430\u043B\u0438\u0447\u0438\u0438)", maxLength: 60, disabled: input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME$1), ...getValidation(field(FIELD_NAME$1), validatorObj.middleName, input?.required), ...input })));
3158
3161
 
3159
- const COMMON_FILTERS_STYLES = 'flex flex-col sm:flex-row sm:flex-wrap gap-3xl pb-2xl';
3160
- const renderFiltrationForm = ({ filters, field: { field, reset }, onlyOffice, labels, }) => {
3161
- const visibleFiltersNum = onlyOffice ? 5 : 6;
3162
- const filtersCheckbox = (filters || []).map((key) => (jsx(Checkbox, { text: labels[key], ...field(key) }, key)));
3163
- const [visibleFilters, hiddenFilters] = visibleFiltersNum > 0
3164
- ? [filtersCheckbox.slice(0, visibleFiltersNum), filtersCheckbox.slice(visibleFiltersNum)]
3165
- : [filtersCheckbox, []];
3166
- return (jsx("div", { children: filters?.length ? (jsx("div", { children: jsx(Foldable, { renderFoldableSection: ({ isUnfolded }) => (jsxs("div", { children: [jsx("div", { className: COMMON_FILTERS_STYLES, children: visibleFilters }), jsx(FoldableSection, { className: COMMON_FILTERS_STYLES, isUnfolded: isUnfolded, children: hiddenFilters })] })), renderFoldButton: renderFoldButton$2(reset, onlyOffice) }) })) : null }));
3167
- };
3168
- const renderFoldButton$2 = (reset, onlyOffice = false) => ({ isUnfolded, onToggle }) => {
3169
- const labels = ['Больше фильтров', 'Меньше фильтров'];
3170
- const icons = ['ArrowDownIcon', 'ArrowUpIcon'];
3171
- return (jsxs("div", { className: "flex space-x-lg", children: [onlyOffice ? (jsx(LinkButton, { version: "transparent", className: "text-secondary-text [&>*]:p-0", appendRight: jsx(Icon, { name: icons[Number(isUnfolded)], width: "16", height: "16" }), text: labels[Number(isUnfolded)], onClick: onToggle })) : null, jsx(LinkButton, { version: "transparent", className: "text-secondary-text [&>*]:p-0", onClick: reset, children: renderBtnInner() })] }));
3172
- };
3173
- const renderBtnInner = () => (jsxs("div", { className: "flex items-center", children: ["\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0444\u0438\u043B\u044C\u0442\u0440", jsx(Icon, { name: "CloseIcon", width: "16", height: "16", className: "ml-2xs" })] }));
3162
+ const NameField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0418\u043C\u044F", maxLength: 60, disabled: input?.filledByEsia && isEsiaAuthorize(field, input.name ?? ''), ...getValidation(field('name'), validatorObj.name, input?.required), ...input })));
3174
3163
 
3175
- const renderHeading = (title, lengthItems) => (jsx("div", { className: "flex flex-col sm:flex-row gap-xs mb-2xl", children: jsxs(Heading, { headingType: "h3", children: [jsx("span", { suppressHydrationWarning: true, children: title }), lengthItems ? (jsx(Text, { size: "text-h2", color: "text-secondary-text", children: jsx("span", { suppressHydrationWarning: true, children: ` (${lengthItems})` }) })) : null] }) }));
3164
+ const SlideCheckbox = JSX(({ value = false, text, type = 'checkbox', onChange }) => (jsxs("div", { role: type, "aria-checked": value, className: "flex justify-start items-center w-full cursor-pointer mb-s", onClick: () => onChange && onChange(!value), children: [jsx("div", { className: style('relative flex-shrink-0 duration-300 w-9 h-5 mr-s rounded-2xl', value ? 'bg-primary-main' : 'bg-main-divider'), children: jsx("div", { className: style('absolute opacity-80 duration-500 top-0.5 w-4 h-4 bg-white rounded-full', value ? 'left-1/2' : 'left-[5%]') }) }), text ? (jsx(Text, { size: "text-l", font: "font-light", color: "text-primary-text", children: text })) : null] })));
3176
3165
 
3177
- const defaultEmptyFunction$1 = () => void 0;
3178
- const filtersVisibleStyles = (activeButton) => activeButton === 'all' ? 'block' : 'hidden';
3179
- const OfficesAtmsMapLayout = JSX(({ className, data = [], isLoad, remoteWorkplaces = [], renderCard = defaultEmptyFunction$1, renderRemoteWorkplaceCard = defaultEmptyFunction$1, getBalloon = defaultEmptyFunction$1, getBalloonRemoteWorkplaces = defaultEmptyFunction$1, descriptionData, title, }) => {
3180
- const onlyOffice = title?.includes('Офис');
3181
- const [filtrationState, { field, reset }] = useForm(INITIAL_FILTRATION_STATE$1);
3182
- const { filteredItems, points, filteredRemoteWorkplaces, lengthItems } = useOfficesAtmsMapData({
3183
- data,
3184
- remoteWorkplaces,
3185
- filtrationState,
3186
- getBalloon,
3187
- getBalloonRemoteWorkplaces,
3188
- });
3189
- const [activeButton, setActiveButton] = useState('all');
3190
- const filterOptions = {
3191
- filters: getFiltersWithNonEmptyData([...data, ...remoteWorkplaces]),
3192
- field: { field, reset },
3193
- onlyOffice,
3194
- labels: FILTRATION_LABELS,
3166
+ const OnlineCheckoutField = JSX(({ field }) => isAcquiringTrade(field('acquiringType')?.value?.key) ? (jsx(SlideCheckbox, { type: "radio", text: "\u0425\u043E\u0447\u0443 \u043E\u043D\u043B\u0430\u0439\u043D-\u043A\u0430\u0441\u0441\u0443", ...field('onlineCheckout') })) : null);
3167
+
3168
+ const OrganizationField = JSX(({ field, input }) => {
3169
+ const { data: organization } = useLeadFormData('ORGANIZATION_TYPE');
3170
+ return (jsx(SelectField, { field: field, source: organization, label: "\u0422\u0438\u043F \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438", fieldName: "organization", input: input }));
3171
+ });
3172
+
3173
+ const OrganizationNameField = JSX(({ field, input }) => {
3174
+ const onDaDataChange = useCallback((item) => {
3175
+ field?.('inn')?.onChange?.(item.data?.inn);
3176
+ field?.('legalForm')?.onChange?.(item.data?.opf?.short);
3177
+ }, []);
3178
+ return (jsx(InputControl, { label: "\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438", ...input, ...getValidation(field('organizationName'), validatorObj.organizationName, input?.required), onDaDataChange: onDaDataChange }));
3179
+ });
3180
+
3181
+ const OtherIncomeField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0418\u043D\u044B\u0435 \u0434\u043E\u0445\u043E\u0434\u044B", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435", type: "number", ...getValidation(field('otherIncome'), validatorObj.otherIncome, input?.required), ...input })));
3182
+
3183
+ const ParticipantDateRegistrationField = JSX(({ field, input }) => (jsx(DatePickerControl, { label: "\u0414\u0430\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043F\u043E \u043C\u0435\u0441\u0442\u0443 \u0436\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u0430", ...getValidation(field('participantDateRegistration'), validatorObj.participantDateRegistration, input?.required) })));
3184
+
3185
+ const MAX_PART = 100;
3186
+ const PartInBusinessField = JSX(({ field, input }) => {
3187
+ const isBusinessOwner = field('positionOrganization')?.value?.key === 'BUSINESS_OWNER';
3188
+ const partInBusinessField = {
3189
+ ...getValidation(field('partInBusiness'), validatorObj.partInBusiness, input?.required),
3195
3190
  };
3196
- return (jsxs("div", { className: style('space-y-1', className), children: [jsxs("div", { className: "bg-white", children: [jsxs("div", { className: "p-3xl pb-0", children: [renderHeading(title, lengthItems), descriptionData ? renderDescriptionBlock$1(descriptionData) : null, onlyOffice && renderButtonsGroup(data, activeButton, setActiveButton), jsx("div", { className: style('pb-3xl', filtersVisibleStyles(activeButton)), children: renderFiltrationForm(filterOptions) })] }), jsx("div", { className: "h-[600px]", children: jsx(ClientOnly, { children: jsx(YandexMap, { points: points, isLoad: isLoad, className: "h-full" }) }) })] }), jsxs(ClientOnly, { children: [filteredItems.map(renderCard), filteredRemoteWorkplaces.map(renderRemoteWorkplaceCard)] })] }));
3191
+ const handleChange = (value) => partInBusinessField?.onChange &&
3192
+ partInBusinessField?.onChange(String(Number(value) > MAX_PART ? MAX_PART : Number(value) || ''));
3193
+ return (jsx(InputControl, { label: "\u0414\u043E\u043B\u044F \u0443\u0447\u0430\u0441\u0442\u0438\u044F \u0432 \u0431\u0438\u0437\u043D\u0435\u0441\u0435", placeholder: "\u0432 %", type: "number", maxLength: 3, ...partInBusinessField, ...input, onChange: handleChange, value: isBusinessOwner ? partInBusinessField?.value : '', disabled: !isBusinessOwner }));
3197
3194
  });
3198
- const filterItems$1 = (data, filtrationState) => {
3199
- const truthyFilters = Object.keys(filtrationState).filter((key) => filtrationState[key]);
3200
- return data.filter((item) => truthyFilters.every((_) => FILTRATION_PREDICATES$1[_](item)));
3201
- };
3202
- const getFiltersWithNonEmptyData = (data) => Object.keys(INITIAL_FILTRATION_STATE$1).filter((_) => data.filter((item) => FILTRATION_PREDICATES$1[_](item)).length);
3203
3195
 
3204
- const defaultEmptyFunction = () => void 0;
3205
- const useOfficesAtmsMapData = ({ data, remoteWorkplaces = [], filtrationState = {}, getBalloon = defaultEmptyFunction, getBalloonRemoteWorkplaces = defaultEmptyFunction, }) => {
3206
- const [filteredItems, points, filteredRemoteWorkplaces, lengthItems] = useMemo(() => {
3207
- const _filteredItems = filterItems$1(data, filtrationState);
3208
- const _filteredRemoteWorkplaces = filterItems$1(remoteWorkplaces, filtrationState);
3209
- const _points = [
3210
- ..._filteredItems.map((_) => ({
3211
- type: 'offices',
3212
- coords: [Number(_.gpsLatitude), Number(_.gpsLongitude)]?.filter(Boolean),
3213
- content: getBalloon(_),
3214
- })),
3215
- ..._filteredRemoteWorkplaces.map((_) => ({
3216
- type: 'workplaces',
3217
- coords: [Number(_.gpsLatitude), Number(_.gpsLongitude)]?.filter(Boolean),
3218
- content: getBalloonRemoteWorkplaces({
3219
- address: _.address,
3220
- workScheduleDescription: _.workScheduleDescription,
3221
- }),
3222
- })),
3223
- ].filter((_) => _.coords && _.coords.length === 2);
3224
- const itemsLength = _filteredItems.length + _filteredRemoteWorkplaces?.length;
3225
- return [_filteredItems, _points, _filteredRemoteWorkplaces, itemsLength];
3226
- }, [data, remoteWorkplaces, filtrationState, getBalloon, getBalloonRemoteWorkplaces]);
3227
- return { filteredItems, points, filteredRemoteWorkplaces, lengthItems };
3228
- };
3196
+ const PartnerCommentsField = JSX(({ field, input }) => {
3197
+ const { required, ...rest } = input;
3198
+ return (jsx(InputControl, { ...getValidation(field('partnerComments'), validatorObj.partnerComments, required), placeholder: "\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u0438\u043D\u0442\u0435\u0440\u0435\u0441\u0443\u044E\u0449\u0438\u0439 \u0432\u0430\u0441 \u0432\u043E\u043F\u0440\u043E\u0441", isTextarea: true, ...rest }));
3199
+ });
3229
3200
 
3230
- const RetailAddressField = JSX(({ field, input }) => {
3231
- const fieldRegion = field('regionRetail');
3232
- const fieldBranch = field('addressRetail');
3233
- const regions = useBranchesByRegions();
3234
- const regionKey = fieldRegion?.value?.key;
3235
- const selectedRegion = regions.find(({ region }) => region === regionKey);
3236
- const isLoad = !regions;
3237
- const regionText = fieldRegion?.value?.text;
3238
- const addressBranchRetail = useBranchesByRegions()?.find((_) => _?.region === regionText)?.branches;
3239
- useEffect(() => {
3240
- if (fieldRegion?.value?.key !== '') {
3241
- field?.('addressRetail')?.onChange?.('');
3201
+ const PAYMENT_SYSTEM_TYPES = [
3202
+ { id: 'mir', text: 'Карта МИР' },
3203
+ { id: 'union_pay', text: 'UnionPay' },
3204
+ ];
3205
+ const PaymentSystemField = JSX(({ field, input }) => {
3206
+ const { value, onChange } = field('paymentSystem');
3207
+ return (jsx(RadioButtonGroupControl, { label: "\u041F\u043B\u0430\u0442\u0435\u0436\u043D\u0430\u044F \u0441\u0438\u0441\u0442\u0435\u043C\u0430", orientation: "horizontal", items: PAYMENT_SYSTEM_TYPES, value: value, onChange: (_) => onChange?.(_), ...getValidation(field('paymentSystem'), validatorObj.paymentSystem, input?.required) }));
3208
+ });
3209
+
3210
+ const isPlaceholder = (_) => _ === '_';
3211
+ const isDigit = (_) => /\d/.test(_);
3212
+ const isWildcard = (_) => isPlaceholder(_) || isDigit(_);
3213
+ const phonePattern = [...'+7 (___) ___-__-__'];
3214
+ const firstPlaceholderIndex = phonePattern.findIndex(isPlaceholder);
3215
+ const phoneWildcardIndicies = phonePattern.map((_, i) => isWildcard(_) ? phonePattern.slice(0, i).filter(isWildcard).length : -1);
3216
+ function normalizePhone(phone) {
3217
+ const phoneNumbers = phone.replace(/\D/g, '');
3218
+ const applyPlaceholder = (_, i) => isDigit(_) ? _ : phoneNumbers.charAt(phoneWildcardIndicies[i]) || _;
3219
+ const result = phonePattern.map(applyPlaceholder);
3220
+ const resultLength = phoneWildcardIndicies.indexOf(phoneNumbers.length - 1) + 1;
3221
+ return (resultLength ? result.slice(0, Math.max(firstPlaceholderIndex, resultLength)) : result).join('');
3222
+ }
3223
+
3224
+ const PhoneInput = JSX(({ children, onChange, ...inputProps }) => {
3225
+ const handleChange = useCallback((v) => onChange && onChange(normalizePhone(v)), [onChange]);
3226
+ const handleBlur = useCallback((v) => {
3227
+ if (v === '+7 (') {
3228
+ onChange && onChange('');
3242
3229
  }
3243
- }, [fieldRegion?.value]);
3244
- const { points } = useOfficesAtmsMapData({
3245
- data: selectedRegion?.branches || [],
3246
- filtrationState: {},
3247
- getBalloon: getOfficePoint,
3248
- });
3249
- const isRegionSelected = Boolean(fieldRegion?.value?.key);
3250
- return (jsxs("div", { children: [jsx(SelectControl, { label: "\u0410\u0434\u0440\u0435\u0441 \u043E\u0442\u0434\u0435\u043B\u0435\u043D\u0438\u044F", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043E\u0442\u0434\u0435\u043B\u0435\u043D\u0438\u0435", options: (addressBranchRetail || []).map(({ address = '' }) => ({
3251
- key: address,
3252
- text: address,
3253
- })), ...getValidation(field('addressRetail'), validatorObj.addressRetail, input?.required && isRegionSelected), isSearch: true }), jsx("div", { className: "h-[600px]", children: jsx(ClientOnly, { children: jsx(YandexMap, { points: points, isLoad: isLoad, className: "h-full", selectedAddress: fieldBranch?.value?.text }) }) })] }));
3230
+ }, []);
3231
+ return (jsx(Input, { ...inputProps, onChange: handleChange, onFocus: (ev) => handleChange(ev?.target?.value || ''), onBlur: (ev) => handleBlur(ev?.target?.value || ''), children: children }));
3232
+ });
3233
+
3234
+ const InputPhoneControl = JSX(({ className, label, error, ...rest }) => (jsxs("div", { className: style('shrink-0 w-full', className), children: [jsx(PhoneInput, { "aria-label": label, label: getRequiredLabel({ label, errors: rest?.errors }), valid: Boolean(!error), placeholder: "+7 (___) ___-__-__", ...rest }), renderErrorText(error)] })));
3235
+
3236
+ const PhoneField = JSX(({ field, input }) => {
3237
+ const fieldName = input?.name || 'phone';
3238
+ return (jsx(InputPhoneControl, { label: "\u0422\u0435\u043B\u0435\u0444\u043E\u043D", ...getValidation(field(fieldName), validatorObj.phone, input?.required), disabled: input?.filledByEsia && isEsiaAuthorize(field, fieldName), ...input }));
3239
+ });
3240
+
3241
+ const PositionOrganizationField = JSX(({ field, input }) => {
3242
+ const { data: positionOrganization } = useLeadFormData('POSITION');
3243
+ return (jsx(SelectField, { field: field, source: positionOrganization, label: "\u0414\u043E\u043B\u0436\u043D\u043E\u0441\u0442\u044C \u0432 \u043E\u0440\u0433\u0430\u043D\u0438\u0437\u0430\u0446\u0438\u0438", fieldName: "positionOrganization", input: input }));
3244
+ });
3245
+
3246
+ const PosTerminalField = JSX(({ field }) => isAcquiringTrade(field('acquiringType')?.value?.key) ? (jsx(SlideCheckbox, { type: "radio", text: "\u0425\u043E\u0447\u0443 POS-\u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B", ...field('posTerminal') })) : null);
3247
+
3248
+ const ProductField = UniBlock(({ field, source }) => (jsx(SelectControl, { placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043F\u0440\u043E\u0434\u0443\u043A\u0442", label: "\u041F\u0440\u043E\u0434\u0443\u043A\u0442", options: arrayToOptions(source?.productList), ...withValidator(field('product'), validatorObj.product) })));
3249
+ const arrayToOptions = (array) => (array ?? []).map((_) => ({ key: _, value: _ }));
3250
+
3251
+ const REGIONS_URL = `${API_BASE_URI}/regions`;
3252
+ function useRegions(url = REGIONS_URL) {
3253
+ const { data } = useAsyncData(url, fetchJSONUnsafe);
3254
+ return Array.isArray(data) ? data : [];
3255
+ }
3256
+
3257
+ const RegionField = JSX(({ field, input, url }) => {
3258
+ const regions = useRegions(url);
3259
+ return (jsx(SelectControl, { label: "\u0424\u0438\u043B\u0438\u0430\u043B", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0438\u043B\u0438\u0430\u043B", isSearch: true, options: useMemo(() => regions?.map(({ code = '', name = '' }) => ({ key: code, text: name })), [regions]), ...getValidation(field('region'), validatorObj.region, input?.required) }));
3260
+ });
3261
+
3262
+ const RegionPremiumField = JSX(({ field, input }) => {
3263
+ const branchByRegions = useBranchesByRegions(true);
3264
+ const regions = useMemo(() => branchByRegions?.map(({ region }) => ({
3265
+ key: region,
3266
+ text: region,
3267
+ })), [branchByRegions]);
3268
+ return (jsx(SelectControl, { label: "\u0420\u0435\u0433\u0438\u043E\u043D", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0435\u0433\u0438\u043E\u043D", options: regions, ...getValidation(field('region'), validatorObj.region, input?.required) }));
3254
3269
  });
3255
3270
 
3256
- const RetailRegionField = JSX(({ field, input }) => {
3257
- const regions = useBranchesByRegions();
3258
- return (jsx(SelectControl, { label: "\u0420\u0435\u0433\u0438\u043E\u043D", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0435\u0433\u0438\u043E\u043D", isSearch: true, options: useMemo(() => regions?.map(({ region = '' }) => ({ key: region, text: region })), [regions]), ...getValidation(field('regionRetail'), validatorObj.regionRetail, input?.required) }));
3271
+ const RegionRetailField = JSX(({ field, input }) => {
3272
+ const { data: regions } = useLeadFormData('REGION_RF');
3273
+ const formatRegions = regions?.map(({ key, value }) => ({ key, text: value }));
3274
+ return (jsx(SelectControl, { label: "\u0420\u0435\u0433\u0438\u043E\u043D", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0435\u0433\u0438\u043E\u043D", isSearch: true, options: formatRegions, ...getValidation(field('regionRetail'), validatorObj.regionRetail, input?.required) }));
3259
3275
  });
3260
3276
 
3261
3277
  const RetirementIncomeField = JSX(({ field, input }) => {
@@ -3437,8 +3453,8 @@
3437
3453
  creditInRshbCd: jsx(CreditInRshbCdField, { field: field, input: input }),
3438
3454
  bankEmployeeCode: jsx(BankEmpoleeCodeField, { field: field, input: input }),
3439
3455
  partInBusiness: jsx(PartInBusinessField, { field: field, input: input }),
3440
- regionRetail: jsx(RetailRegionField, { field: field, input: input }),
3441
- addressRetail: jsx(RetailAddressField, { field: field, input: input }),
3456
+ regionRetail: jsx(RegionRetailField, { field: field, input: input }),
3457
+ addressRetail: jsx(AddressRetailField, { field: field, input: input }),
3442
3458
  addressMatch: jsx(AddressMatchField, { field: field, input: input }),
3443
3459
  paymentSystem: jsx(PaymentSystemField, { field: field, input: input }),
3444
3460
  currency: jsx(CurrencyField, { field: field, input: input }),
@@ -3539,6 +3555,7 @@
3539
3555
  posTerminal: false,
3540
3556
  consentToReceiveMaterials: false,
3541
3557
  consentDataProcessing: false,
3558
+ addressRetail: { key: '', text: '' },
3542
3559
  };
3543
3560
  const getInitialFormState$3 = (inputs, typeForm = '') => {
3544
3561
  const formState = Object.fromEntries(inputs.map((_) => [
@@ -3676,6 +3693,7 @@
3676
3693
  paymentSystem: '',
3677
3694
  cardCategory: { key: '', text: '' },
3678
3695
  codeWord: '',
3696
+ addressRetail: { key: '', text: '' },
3679
3697
  };
3680
3698
  const getInitialFormState$2 = (inputs, savedForm, typeForm = '') => {
3681
3699
  if (savedForm) {
@@ -6224,8 +6242,8 @@
6224
6242
  {
6225
6243
  regionRetail: '',
6226
6244
  addressRetail: {
6227
- fullAddress: '',
6228
- fiasCode: '',
6245
+ key: '',
6246
+ text: '',
6229
6247
  },
6230
6248
  bankEmployeeCode: undefined,
6231
6249
  addressCourier: {
@@ -6305,7 +6323,7 @@
6305
6323
  return (jsxs("div", { className: "flex justify-between gap-m", children: [jsx(Button, { onClick: onPrevStep, className: style('w-full @xl:w-auto'), type: "button", version: "secondary", disabled: isFirstStep, children: "\u041D\u0430\u0437\u0430\u0434" }), jsx(Button, { className: "w-full @xl:w-auto", type: "submit", children: "\u0414\u0430\u043B\u0435\u0435" })] }));
6306
6324
  });
6307
6325
 
6308
- const getFifthStepData = (formData) => {
6326
+ const getFifthStepData$1 = (formData) => {
6309
6327
  const { bankruptcyFlg, shareholderFlg, legalEntityName, creditInRshbCd } = formData;
6310
6328
  return {
6311
6329
  bankruptcyFlg,
@@ -6453,7 +6471,7 @@
6453
6471
  case 3:
6454
6472
  return getFourthStepData$1(formData);
6455
6473
  case 4:
6456
- return getFifthStepData(formData);
6474
+ return getFifthStepData$1(formData);
6457
6475
  case 5:
6458
6476
  return getSixthStepData(formData);
6459
6477
  default:
@@ -7162,6 +7180,13 @@
7162
7180
  return (jsxs("div", { className: 'flex justify-between', children: [jsx(Button, { onClick: onPrevStep, className: style('w-full @xl:w-auto'), type: "button", version: "secondary", disabled: isFirstStep, children: "\u041D\u0430\u0437\u0430\u0434" }), jsx(Button, { className: style('w-full @xl:w-auto'), type: "submit", children: "\u0414\u0430\u043B\u0435\u0435" })] }));
7163
7181
  });
7164
7182
 
7183
+ const getFifthStepData = (formData) => {
7184
+ const { addressRetail } = formData;
7185
+ return {
7186
+ office: addressRetail?.key ? { id: addressRetail.key } : undefined,
7187
+ };
7188
+ };
7189
+
7165
7190
  const getFirstStepData = (formData) => {
7166
7191
  const { name, surname, middleName, birthday = '', phone = '', email, sex, birthPlace, dulIssueDateField = '', dulIssuedBy, dulNumber, dulSerie, dulSubdivisionCode, education, participantDateRegistration = '', housing, addressRegistration, addressFact, } = formData;
7167
7192
  return {
@@ -7267,7 +7292,7 @@
7267
7292
  taskSource: globalThis.location.origin,
7268
7293
  id: taskId,
7269
7294
  office: {
7270
- id: '650', // TODO: Remove hardcode
7295
+ id: '',
7271
7296
  },
7272
7297
  authorizedAgentId: formData?.bankEmployeeCode,
7273
7298
  participants: [
@@ -7284,6 +7309,7 @@
7284
7309
  },
7285
7310
  ],
7286
7311
  ...getZeroStepData(formData),
7312
+ ...getFifthStepData(formData),
7287
7313
  esiaAccountTypeCd: {
7288
7314
  key: formData?.esiaAccountTypeCd?.key,
7289
7315
  },
@@ -9566,7 +9592,7 @@
9566
9592
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
9567
9593
  });
9568
9594
 
9569
- const packageVersion = "0.14.665";
9595
+ const packageVersion = "0.14.666";
9570
9596
 
9571
9597
  exports.Blocks = Blocks;
9572
9598
  exports.ContentPage = ContentPage;