@redneckz/wildless-cms-uni-blocks 0.14.675 → 0.14.677

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 (243) hide show
  1. package/bundle/EventBus/EventBus.d.ts +1 -8
  2. package/bundle/EventBus/defaultEventBus.d.ts +0 -9
  3. package/bundle/api/RetailAPI/updateRefreshToken.d.ts +1 -1
  4. package/bundle/bundle.umd.js +420 -143
  5. package/bundle/bundle.umd.min.js +1 -1
  6. package/bundle/hooks/useLocation.d.ts +4 -1
  7. package/bundle/hooks/useNavigator.d.ts +8 -0
  8. package/bundle/index.d.ts +1 -0
  9. package/bundle/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  10. package/dist/EventBus/EventBus.d.ts +1 -8
  11. package/dist/EventBus/EventBus.js +2 -28
  12. package/dist/EventBus/EventBus.js.map +1 -1
  13. package/dist/EventBus/defaultEventBus.d.ts +0 -9
  14. package/dist/EventBus/defaultEventBus.js.map +1 -1
  15. package/dist/api/RetailAPI/updateRefreshToken.d.ts +1 -1
  16. package/dist/api/RetailAPI/updateRefreshToken.js +6 -10
  17. package/dist/api/RetailAPI/updateRefreshToken.js.map +1 -1
  18. package/dist/components/CarouselTariffsCard/CarouselTariffsCard.js +1 -1
  19. package/dist/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
  20. package/dist/components/ContentPage/ContentPage.js +2 -0
  21. package/dist/components/ContentPage/ContentPage.js.map +1 -1
  22. package/dist/components/CreditCardForm/CreditCardForm.js +4 -1
  23. package/dist/components/CreditCardForm/CreditCardForm.js.map +1 -1
  24. package/dist/components/CreditForm/CreditForm.js +4 -1
  25. package/dist/components/CreditForm/CreditForm.js.map +1 -1
  26. package/dist/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
  27. package/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
  28. package/dist/components/Header/HeaderSecondaryMenu.js +1 -1
  29. package/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  30. package/dist/components/OfficesAtmsMap/AtmsMap.js +1 -1
  31. package/dist/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
  32. package/dist/components/OfficesAtmsMap/OfficesMap.js +1 -1
  33. package/dist/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
  34. package/dist/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
  35. package/dist/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
  36. package/dist/hooks/useLocation.d.ts +4 -1
  37. package/dist/hooks/useLocation.js +16 -34
  38. package/dist/hooks/useLocation.js.map +1 -1
  39. package/dist/hooks/useNavigator.d.ts +8 -0
  40. package/dist/hooks/useNavigator.js +13 -0
  41. package/dist/hooks/useNavigator.js.map +1 -0
  42. package/dist/hooks/useRegions.js +3 -1
  43. package/dist/hooks/useRegions.js.map +1 -1
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +3 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/ui-kit/DialogManager/useDialogsList.js +3 -0
  48. package/dist/ui-kit/DialogManager/useDialogsList.js.map +1 -1
  49. package/dist/ui-kit/LocationDialog/LocationDialog.js +11 -14
  50. package/dist/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  51. package/dist/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  52. package/dist/ui-kit/LocationDialog/SelectedLocation.js +15 -0
  53. package/dist/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
  54. package/dist/ui-kit/PopupManager/PopupManager.js +3 -0
  55. package/dist/ui-kit/PopupManager/PopupManager.js.map +1 -1
  56. package/lib/EventBus/EventBus.d.ts +1 -8
  57. package/lib/EventBus/EventBus.js +1 -27
  58. package/lib/EventBus/EventBus.js.map +1 -1
  59. package/lib/EventBus/defaultEventBus.d.ts +0 -9
  60. package/lib/EventBus/defaultEventBus.js.map +1 -1
  61. package/lib/api/RetailAPI/updateRefreshToken.d.ts +1 -1
  62. package/lib/api/RetailAPI/updateRefreshToken.js +6 -10
  63. package/lib/api/RetailAPI/updateRefreshToken.js.map +1 -1
  64. package/lib/components/CarouselTariffsCard/CarouselTariffsCard.js +1 -1
  65. package/lib/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
  66. package/lib/components/ContentPage/ContentPage.js +2 -0
  67. package/lib/components/ContentPage/ContentPage.js.map +1 -1
  68. package/lib/components/CreditCardForm/CreditCardForm.js +4 -1
  69. package/lib/components/CreditCardForm/CreditCardForm.js.map +1 -1
  70. package/lib/components/CreditForm/CreditForm.js +4 -1
  71. package/lib/components/CreditForm/CreditForm.js.map +1 -1
  72. package/lib/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
  73. package/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
  74. package/lib/components/Header/HeaderSecondaryMenu.js +1 -1
  75. package/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  76. package/lib/components/OfficesAtmsMap/AtmsMap.js +1 -1
  77. package/lib/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
  78. package/lib/components/OfficesAtmsMap/OfficesMap.js +1 -1
  79. package/lib/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
  80. package/lib/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
  81. package/lib/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
  82. package/lib/hooks/useLocation.d.ts +4 -1
  83. package/lib/hooks/useLocation.js +15 -34
  84. package/lib/hooks/useLocation.js.map +1 -1
  85. package/lib/hooks/useNavigator.d.ts +8 -0
  86. package/lib/hooks/useNavigator.js +10 -0
  87. package/lib/hooks/useNavigator.js.map +1 -0
  88. package/lib/hooks/useRegions.js +3 -1
  89. package/lib/hooks/useRegions.js.map +1 -1
  90. package/lib/index.d.ts +1 -0
  91. package/lib/index.js +1 -0
  92. package/lib/index.js.map +1 -1
  93. package/lib/ui-kit/DialogManager/useDialogsList.js +3 -0
  94. package/lib/ui-kit/DialogManager/useDialogsList.js.map +1 -1
  95. package/lib/ui-kit/LocationDialog/LocationDialog.js +13 -16
  96. package/lib/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  97. package/lib/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  98. package/lib/ui-kit/LocationDialog/SelectedLocation.js +13 -0
  99. package/lib/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
  100. package/lib/ui-kit/PopupManager/PopupManager.js +3 -0
  101. package/lib/ui-kit/PopupManager/PopupManager.js.map +1 -1
  102. package/mobile/bundle/EventBus/EventBus.d.ts +1 -8
  103. package/mobile/bundle/EventBus/defaultEventBus.d.ts +0 -9
  104. package/mobile/bundle/api/RetailAPI/updateRefreshToken.d.ts +1 -1
  105. package/mobile/bundle/bundle.umd.js +420 -143
  106. package/mobile/bundle/bundle.umd.min.js +1 -1
  107. package/mobile/bundle/hooks/useLocation.d.ts +4 -1
  108. package/mobile/bundle/hooks/useNavigator.d.ts +8 -0
  109. package/mobile/bundle/index.d.ts +1 -0
  110. package/mobile/bundle/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  111. package/mobile/dist/EventBus/EventBus.d.ts +1 -8
  112. package/mobile/dist/EventBus/EventBus.js +2 -28
  113. package/mobile/dist/EventBus/EventBus.js.map +1 -1
  114. package/mobile/dist/EventBus/defaultEventBus.d.ts +0 -9
  115. package/mobile/dist/EventBus/defaultEventBus.js.map +1 -1
  116. package/mobile/dist/api/RetailAPI/updateRefreshToken.d.ts +1 -1
  117. package/mobile/dist/api/RetailAPI/updateRefreshToken.js +6 -10
  118. package/mobile/dist/api/RetailAPI/updateRefreshToken.js.map +1 -1
  119. package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCard.js +1 -1
  120. package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
  121. package/mobile/dist/components/ContentPage/ContentPage.js +2 -0
  122. package/mobile/dist/components/ContentPage/ContentPage.js.map +1 -1
  123. package/mobile/dist/components/CreditCardForm/CreditCardForm.js +4 -1
  124. package/mobile/dist/components/CreditCardForm/CreditCardForm.js.map +1 -1
  125. package/mobile/dist/components/CreditForm/CreditForm.js +4 -1
  126. package/mobile/dist/components/CreditForm/CreditForm.js.map +1 -1
  127. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
  128. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
  129. package/mobile/dist/components/Header/HeaderSecondaryMenu.js +1 -1
  130. package/mobile/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  131. package/mobile/dist/components/OfficesAtmsMap/AtmsMap.js +1 -1
  132. package/mobile/dist/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
  133. package/mobile/dist/components/OfficesAtmsMap/OfficesMap.js +1 -1
  134. package/mobile/dist/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
  135. package/mobile/dist/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
  136. package/mobile/dist/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
  137. package/mobile/dist/hooks/useLocation.d.ts +4 -1
  138. package/mobile/dist/hooks/useLocation.js +16 -34
  139. package/mobile/dist/hooks/useLocation.js.map +1 -1
  140. package/mobile/dist/hooks/useNavigator.d.ts +8 -0
  141. package/mobile/dist/hooks/useNavigator.js +13 -0
  142. package/mobile/dist/hooks/useNavigator.js.map +1 -0
  143. package/mobile/dist/hooks/useRegions.js +3 -1
  144. package/mobile/dist/hooks/useRegions.js.map +1 -1
  145. package/mobile/dist/index.d.ts +1 -0
  146. package/mobile/dist/index.js +3 -1
  147. package/mobile/dist/index.js.map +1 -1
  148. package/mobile/dist/ui-kit/DialogManager/useDialogsList.js +3 -0
  149. package/mobile/dist/ui-kit/DialogManager/useDialogsList.js.map +1 -1
  150. package/mobile/dist/ui-kit/LocationDialog/LocationDialog.js +11 -14
  151. package/mobile/dist/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  152. package/mobile/dist/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  153. package/mobile/dist/ui-kit/LocationDialog/SelectedLocation.js +15 -0
  154. package/mobile/dist/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
  155. package/mobile/dist/ui-kit/PopupManager/PopupManager.js +3 -0
  156. package/mobile/dist/ui-kit/PopupManager/PopupManager.js.map +1 -1
  157. package/mobile/lib/EventBus/EventBus.d.ts +1 -8
  158. package/mobile/lib/EventBus/EventBus.js +1 -27
  159. package/mobile/lib/EventBus/EventBus.js.map +1 -1
  160. package/mobile/lib/EventBus/defaultEventBus.d.ts +0 -9
  161. package/mobile/lib/EventBus/defaultEventBus.js.map +1 -1
  162. package/mobile/lib/api/RetailAPI/updateRefreshToken.d.ts +1 -1
  163. package/mobile/lib/api/RetailAPI/updateRefreshToken.js +6 -10
  164. package/mobile/lib/api/RetailAPI/updateRefreshToken.js.map +1 -1
  165. package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCard.js +1 -1
  166. package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
  167. package/mobile/lib/components/ContentPage/ContentPage.js +2 -0
  168. package/mobile/lib/components/ContentPage/ContentPage.js.map +1 -1
  169. package/mobile/lib/components/CreditCardForm/CreditCardForm.js +4 -1
  170. package/mobile/lib/components/CreditCardForm/CreditCardForm.js.map +1 -1
  171. package/mobile/lib/components/CreditForm/CreditForm.js +4 -1
  172. package/mobile/lib/components/CreditForm/CreditForm.js.map +1 -1
  173. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
  174. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
  175. package/mobile/lib/components/Header/HeaderSecondaryMenu.js +1 -1
  176. package/mobile/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  177. package/mobile/lib/components/OfficesAtmsMap/AtmsMap.js +1 -1
  178. package/mobile/lib/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
  179. package/mobile/lib/components/OfficesAtmsMap/OfficesMap.js +1 -1
  180. package/mobile/lib/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
  181. package/mobile/lib/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
  182. package/mobile/lib/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
  183. package/mobile/lib/hooks/useLocation.d.ts +4 -1
  184. package/mobile/lib/hooks/useLocation.js +15 -34
  185. package/mobile/lib/hooks/useLocation.js.map +1 -1
  186. package/mobile/lib/hooks/useNavigator.d.ts +8 -0
  187. package/mobile/lib/hooks/useNavigator.js +10 -0
  188. package/mobile/lib/hooks/useNavigator.js.map +1 -0
  189. package/mobile/lib/hooks/useRegions.js +3 -1
  190. package/mobile/lib/hooks/useRegions.js.map +1 -1
  191. package/mobile/lib/index.d.ts +1 -0
  192. package/mobile/lib/index.js +1 -0
  193. package/mobile/lib/index.js.map +1 -1
  194. package/mobile/lib/ui-kit/DialogManager/useDialogsList.js +3 -0
  195. package/mobile/lib/ui-kit/DialogManager/useDialogsList.js.map +1 -1
  196. package/mobile/lib/ui-kit/LocationDialog/LocationDialog.js +13 -16
  197. package/mobile/lib/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  198. package/mobile/lib/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  199. package/mobile/lib/ui-kit/LocationDialog/SelectedLocation.js +13 -0
  200. package/mobile/lib/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
  201. package/mobile/lib/ui-kit/PopupManager/PopupManager.js +3 -0
  202. package/mobile/lib/ui-kit/PopupManager/PopupManager.js.map +1 -1
  203. package/mobile/src/EventBus/EventBus.ts +1 -36
  204. package/mobile/src/EventBus/defaultEventBus.ts +0 -10
  205. package/mobile/src/api/RetailAPI/updateRefreshToken.ts +6 -12
  206. package/mobile/src/components/CarouselTariffsCard/CarouselTariffsCard.tsx +1 -1
  207. package/mobile/src/components/ContentPage/ContentPage.tsx +2 -0
  208. package/mobile/src/components/CreditCardForm/CreditCardForm.tsx +6 -1
  209. package/mobile/src/components/CreditForm/CreditForm.tsx +6 -1
  210. package/mobile/src/components/ExchangeRateTile/ExchangeRateTile.tsx +1 -1
  211. package/mobile/src/components/Header/HeaderSecondaryMenu.tsx +1 -1
  212. package/mobile/src/components/OfficesAtmsMap/AtmsMap.tsx +1 -1
  213. package/mobile/src/components/OfficesAtmsMap/OfficesMap.tsx +1 -1
  214. package/mobile/src/components/StickyBottomMenu/BurgerMenuDialog.tsx +1 -1
  215. package/mobile/src/hooks/useLocation.ts +25 -47
  216. package/mobile/src/hooks/useNavigator.ts +15 -0
  217. package/mobile/src/hooks/useRegions.ts +4 -1
  218. package/mobile/src/index.ts +1 -0
  219. package/mobile/src/ui-kit/DialogManager/useDialogsList.ts +3 -0
  220. package/mobile/src/ui-kit/LocationDialog/LocationDialog.tsx +22 -28
  221. package/mobile/src/ui-kit/LocationDialog/SelectedLocation.tsx +27 -0
  222. package/mobile/src/ui-kit/PopupManager/PopupManager.tsx +3 -0
  223. package/package.json +5 -5
  224. package/src/EventBus/EventBus.ts +1 -36
  225. package/src/EventBus/defaultEventBus.ts +0 -10
  226. package/src/api/RetailAPI/updateRefreshToken.ts +6 -12
  227. package/src/components/CarouselTariffsCard/CarouselTariffsCard.tsx +1 -1
  228. package/src/components/ContentPage/ContentPage.tsx +2 -0
  229. package/src/components/CreditCardForm/CreditCardForm.tsx +6 -1
  230. package/src/components/CreditForm/CreditForm.tsx +6 -1
  231. package/src/components/ExchangeRateTile/ExchangeRateTile.tsx +1 -1
  232. package/src/components/Header/HeaderSecondaryMenu.tsx +1 -1
  233. package/src/components/OfficesAtmsMap/AtmsMap.tsx +1 -1
  234. package/src/components/OfficesAtmsMap/OfficesMap.tsx +1 -1
  235. package/src/components/StickyBottomMenu/BurgerMenuDialog.tsx +1 -1
  236. package/src/hooks/useLocation.ts +25 -47
  237. package/src/hooks/useNavigator.ts +15 -0
  238. package/src/hooks/useRegions.ts +4 -1
  239. package/src/index.ts +1 -0
  240. package/src/ui-kit/DialogManager/useDialogsList.ts +3 -0
  241. package/src/ui-kit/LocationDialog/LocationDialog.tsx +22 -28
  242. package/src/ui-kit/LocationDialog/SelectedLocation.tsx +27 -0
  243. package/src/ui-kit/PopupManager/PopupManager.tsx +3 -0
@@ -406,32 +406,53 @@
406
406
  className,
407
407
  ].join(' ');
408
408
 
409
- class EventBus {
410
- subscribers = {};
411
- subjectsStateMap = {};
412
- subscribe(type, listener) {
413
- this.subscribers[type] = (this.subscribers[type] || []).concat(listener);
414
- const latestEvent = this.subjectsStateMap[type];
415
- if (latestEvent) {
416
- listener(latestEvent);
417
- }
418
- return () => {
419
- this.unsubscribe(type, listener);
420
- };
421
- }
422
- unsubscribe(type, listener) {
423
- this.subscribers[type] = this.subscribers[type]?.filter((s) => s !== listener);
424
- }
425
- fire(type, event) {
426
- const isSubjectDeclared = type in this.subjectsStateMap;
427
- if (isSubjectDeclared) {
428
- this.subjectsStateMap[type] = event;
429
- }
430
- this.subscribers[type]?.forEach((s) => s(event));
431
- }
432
- subject(type, event) {
433
- this.subjectsStateMap[type] = event;
434
- }
409
+ class EventBus {
410
+ watchers = new Set();
411
+ subscribersMap = {};
412
+ subjectsStateMap = {};
413
+ emitter = this;
414
+ observable = this;
415
+ watch(watcher) {
416
+ this.watchers.add(watcher);
417
+ return () => {
418
+ this.watchers.delete(watcher);
419
+ };
420
+ }
421
+ subscribe(type, listener) {
422
+ this.subscribersMap[type] ||= new Set();
423
+ this.subscribersMap[type]?.add(listener);
424
+ const initialEvent = this.subjectsStateMap[type];
425
+ initialEvent && listener(initialEvent);
426
+ return () => {
427
+ this.subscribersMap[type]?.delete(listener);
428
+ };
429
+ }
430
+ fire(type, event) {
431
+ const isSubjectDeclared = type in this.subjectsStateMap;
432
+ if (isSubjectDeclared) {
433
+ this.subject(type, event);
434
+ }
435
+ else {
436
+ this.fireSubscribers(type, event);
437
+ }
438
+ }
439
+ subject(type, event) {
440
+ if (this.subjectsStateMap[type] !== event) {
441
+ this.subjectsStateMap[type] = event ?? undefined;
442
+ this.fireSubscribers(type, event);
443
+ }
444
+ return () => {
445
+ delete this.subjectsStateMap[type];
446
+ };
447
+ }
448
+ fireSubscribers(type, event) {
449
+ for (const _ of this.subscribersMap[type] ?? []) {
450
+ _(event ?? null);
451
+ }
452
+ for (const _ of this.watchers) {
453
+ _({ type, event: event ?? null });
454
+ }
455
+ }
435
456
  }
436
457
 
437
458
  const defaultEventBus = new EventBus();
@@ -717,26 +738,166 @@
717
738
  const leftOrRightImage = (img, directionRight) => directionRight ? { rightImage: img } : { leftImage: img };
718
739
  const renderTags = (tags) => (tags?.length ? jsx(Tags, { tags: tags }) : null);
719
740
 
741
+ class JSONBox {
742
+ _;
743
+ constructor(_) {
744
+ this._ = _;
745
+ }
746
+ of(_) {
747
+ return new this.constructor(_ instanceof JSONBox ? _._ : _);
748
+ }
749
+ filter(predicate) {
750
+ return this.from(this.entries().filter(predicate));
751
+ }
752
+ map(mapper) {
753
+ return this.from(this.entries().map(mapper));
754
+ }
755
+ flatMap(mapper) {
756
+ return this.from(this.entries().flatMap(mapper));
757
+ }
758
+ reduce(reducer, initial) {
759
+ return this.entries().reduce(reducer.bind(this), initial);
760
+ }
761
+ }
762
+
763
+ const trueF = () => true;
764
+ const and = (a, b) => (...args) => a(...args) && b(...args);
765
+
766
+ const table = (...table) => (...input) => {
767
+ const [, unit] = assertNonEmpty$1(table.find(([predicate]) => predicate(...input)));
768
+ return unit(...input);
769
+ };
770
+ function assertNonEmpty$1(value) {
771
+ if (!value) {
772
+ throw new Error('Value should be fulfilled');
773
+ }
774
+ return value;
775
+ }
776
+
720
777
  const isJSONArray = (_) => Boolean(_ && Array.isArray(_));
721
- const isJSONRecord = (_) => Boolean(_ && !Array.isArray(_) && typeof _ === 'object');
722
- const isJSONRef = (_) => Boolean(isJSONRecord(_) && typeof _.$ref === 'string');
778
+ const isJSONRecord = (_) => Boolean(_ && typeof _ === 'object' && !isJSONArray(_));
779
+
780
+ const identity$1 = (x) => x;
781
+
782
+ const t0 = (fn = identity$1) => ([_]) => fn(_);
783
+ const t1 = (fn = identity$1) => ([, _]) => fn(_);
723
784
 
724
- const mapJSONNode = (json, handlers) => {
725
- if (isJSONRef(json)) {
726
- return handlers.ref(json);
785
+ function unbox(box) {
786
+ return box instanceof JSONBox ? box._ : box;
787
+ }
788
+
789
+ class JSONArrayBox extends JSONBox {
790
+ from(entries) {
791
+ return this.of(entries.map(t1(unbox)));
727
792
  }
728
- else if (isJSONRecord(json)) {
729
- return handlers.record(json);
793
+ entries() {
794
+ return (this._ ?? []).map((node, p) => [p, this.of(node)]);
730
795
  }
731
- else if (isJSONArray(json)) {
732
- return handlers.array(json);
796
+ size() {
797
+ return this._?.length ?? 0;
733
798
  }
734
- else {
735
- return handlers.scalar ? handlers.scalar(json) : json;
799
+ get(p) {
800
+ return this.of(typeof p === 'number' ? this._?.[p] : undefined);
801
+ }
802
+ set(p, child) {
803
+ return this.of(isJSONArray(this._)
804
+ ? Array.from({ length: Math.max(this._.length, Number(p) + 1) }, (x, i) => (i === p ? child : this._[i]))
805
+ : Array.from({ length: Number(p) + 1 }, (x, i) => (i === p ? child : undefined)));
806
+ }
807
+ }
808
+
809
+ class JSONLeafBox extends JSONBox {
810
+ from() {
811
+ return this;
812
+ }
813
+ entries() {
814
+ return [];
815
+ }
816
+ size() {
817
+ return 0;
818
+ }
819
+ get(p) {
820
+ return this.of(p !== undefined ? undefined /* no childs */ : this._ /* self */);
821
+ }
822
+ set(p, child) {
823
+ return this.of(child);
824
+ }
825
+ }
826
+
827
+ class JSONRecordBox extends JSONBox {
828
+ from(entries) {
829
+ return this.of(Object.fromEntries(entries.map(([p, box]) => [p, unbox(box)])));
830
+ }
831
+ entries() {
832
+ return Object.entries(this._ ?? {}).map(([p, node]) => [p, this.of(node)]);
833
+ }
834
+ size() {
835
+ return Object.keys(this._ ?? {}).length;
836
+ }
837
+ get(p) {
838
+ return this.of(typeof p === 'string' ? this._?.[p] : undefined);
839
+ }
840
+ set(p, child) {
841
+ return this.of({ ...this._, [p]: child });
842
+ }
843
+ }
844
+
845
+ class JSONBoxDefault extends JSONBox {
846
+ proto = table([p => isJSONArray(this._) || typeof p === 'number', () => JSONArrayBox.prototype], [p => isJSONRecord(this._) || typeof p === 'string', () => JSONRecordBox.prototype], [trueF, () => JSONLeafBox.prototype]);
847
+ from(entries) {
848
+ return this.proto(undefined).from.call(this, entries);
849
+ }
850
+ entries() {
851
+ return this.proto(undefined).entries.call(this);
852
+ }
853
+ size() {
854
+ return this.proto(undefined).size.call(this);
855
+ }
856
+ get(p) {
857
+ return this.proto(p).get.call(this, p);
858
+ }
859
+ set(p, child) {
860
+ return this.proto(p).set.call(this, p, child);
736
861
  }
862
+ }
863
+
864
+ const box = (_) => (_ instanceof JSONBox ? _ : new JSONBoxDefault(_));
865
+
866
+ const boxed = (fn) => {
867
+ const boxedFn = (node, ...args) => unbox(fn(box(node), ...args));
868
+ boxedFn.fn = fn;
869
+ return boxedFn;
737
870
  };
738
871
 
739
- const mergeRecords = (entries) => entries.reduce((acc, _) => Object.assign(acc, _), {});
872
+ const ROOT = [];
873
+ const endsWith = (suffix) => suffix
874
+ .map((predicate, i) => (path) => cmp(predicate)(path[i + path.length - suffix.length]))
875
+ .reduceRight(and, trueF);
876
+ const cmp = (a) => a instanceof Function ? a : (b) => a === b;
877
+
878
+ const reduce = (reducer) => (node, initial, path = ROOT) => box(node)
879
+ .entries()
880
+ .reduce((acc, [p, _]) => reduce(reducer)(_, acc, path.concat(p)), reducer(initial, [path, box(node)]));
881
+
882
+ const set = boxed((target, [path, node]) => {
883
+ const [p, ...tail] = path;
884
+ return target.set(p, tail.length ? set(target.get(p), [tail, node]) : node);
885
+ });
886
+
887
+ const fromEntries = boxed((initial, tree) => tree.reduce(set.fn, initial));
888
+
889
+ const leafs = (node) => reduce((acc, [path, _]) => (isLeaf(_) ? [...acc, [path, unbox(_)]] : acc))(node, []);
890
+ const isLeaf = (_) => _.size() === 0;
891
+
892
+ const map = (mapper, initial = {}) => (node) => fromEntries(initial, leafs(node).map(_ => mapper(_)));
893
+
894
+ const init = (list) => list.slice(0, -1);
895
+
896
+ boxed((target, path = ROOT) => path.reduce((_, p) => _.get(p), target));
897
+
898
+ const remove = boxed((target, [p, ...tail]) => tail.length ? target.set(p, remove(target.get(p), tail)) : target.filter(([i]) => i !== p));
899
+
900
+ const isJSONRefPath = endsWith(['$ref']);
740
901
 
741
902
  const parseJPointer = (uri) => uri.includes('#')
742
903
  ? uri
@@ -746,46 +907,17 @@
746
907
  : [];
747
908
 
748
909
  const resolveJPointer = (json, uri) => parseJPointer(uri).reduce(selectNodeByKey, json);
749
- const selectNodeByKey = (json, key) => {
750
- if (!json || !key) {
751
- return json;
752
- }
753
- if (isJSONRecord(json)) {
754
- return json[key];
755
- }
756
- else if (isJSONArray(json)) {
757
- return json[parseInt(key, 10)];
758
- }
759
- else {
760
- return json;
761
- }
762
- };
910
+ const selectNodeByKey = table([isJSONArray, (json, key) => json[parseInt(key, 10)]], [isJSONRecord, (json, key) => json[key]], [trueF, identity$1]);
763
911
 
764
- const resolveRef = (json, resolver) => mapJSONNode(json, {
765
- ref: ({ $ref, ...rest }) => resolveRef($ref ? resolveJPointer(resolver($ref), $ref) : rest, resolver),
766
- record: record => mergeRecords(Object.entries(record).map(([key, value]) => ({ [key]: resolveRef(value, resolver) }))),
767
- array: list => list.map(_ => resolveRef(_, resolver))
768
- });
912
+ const resolveRef = (json, resolver) => map(([path, node]) => isJSONRefPath(path)
913
+ ? [init(path), resolveJPointer(resolver(node), node)]
914
+ : [path, node])(json);
769
915
 
770
- const visitRef = (json, visitor, path = []) => {
771
- mapJSONNode(json, {
772
- ref: json => visitor(json.$ref, path),
773
- record: record => {
774
- for (const key in record)
775
- visitRef(record[key], visitor, [...path, key]);
776
- },
777
- array: list => {
778
- for (let i = 0; i < list.length; i++)
779
- visitRef(list[i], visitor, [...path, i]);
780
- }
781
- });
782
- };
916
+ const refEntries = (json) => leafs(json).filter(t0(isJSONRefPath));
783
917
 
784
- const collectRef = (json) => {
785
- const refs = [];
786
- visitRef(json, _ => refs.push(_));
787
- return refs;
788
- };
918
+ const unique$1 = (list) => [...new Set(list)];
919
+
920
+ const collectRef = (json) => unique$1(refEntries(json).map(([, _]) => _));
789
921
 
790
922
  async function fetchJSON(url, options) {
791
923
  try {
@@ -3148,10 +3280,10 @@
3148
3280
  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 })));
3149
3281
 
3150
3282
  const OUT_SERVICE_BASE_URL = `${API_BASE_URI}/outservice`;
3151
- const EMPTY_REGIONS = [];
3283
+ const EMPTY_REGIONS$1 = [];
3152
3284
  async function getOutServiceRegions() {
3153
3285
  const data = await fetchJSON(`${OUT_SERVICE_BASE_URL}/outserviceregions`);
3154
- return data && Array.isArray(data) ? data : EMPTY_REGIONS;
3286
+ return data && Array.isArray(data) ? data : EMPTY_REGIONS$1;
3155
3287
  }
3156
3288
 
3157
3289
  const LocalitiesField = JSX(({ field, input }) => {
@@ -3284,9 +3416,11 @@
3284
3416
  const arrayToOptions = (array) => (array ?? []).map((_) => ({ key: _, value: _ }));
3285
3417
 
3286
3418
  const REGIONS_URL = `${API_BASE_URI}/regions`;
3419
+ const EMPTY_REGIONS = [];
3420
+ // TODO Почему url можно менять? Разве смысл не в инкапсуляции api url. Тоже под рефакторинг попадает
3287
3421
  function useRegions(url = REGIONS_URL) {
3288
3422
  const { data } = useAsyncData(url, fetchJSONUnsafe);
3289
- return Array.isArray(data) ? data : [];
3423
+ return Array.isArray(data) ? data : EMPTY_REGIONS;
3290
3424
  }
3291
3425
 
3292
3426
  const RegionField = JSX(({ field, input, url }) => {
@@ -6042,7 +6176,7 @@
6042
6176
  : [cellsNode, []];
6043
6177
  const [isVisible, setIsVisible] = useState(false);
6044
6178
  useEffect(() => defaultEventBus.subscribe('fold', (event) => {
6045
- if (options?.parent !== undefined && event.parent === options?.parent) {
6179
+ if (event && options?.parent !== undefined && event.parent === options?.parent) {
6046
6180
  setIsVisible(event.isUnfolded);
6047
6181
  }
6048
6182
  }), [options?.parent]);
@@ -6060,14 +6194,13 @@
6060
6194
  const renderBlocks = (info) => (jsx("div", { className: "flex gap-5xl grow basis-0", children: info.map((column, i) => renderBlocksColumn({ column, i })) }));
6061
6195
  const renderBlocksColumn = ({ column, i }) => column ? (jsx("div", { className: "flex flex-col gap-xl grow basis-0", children: column.map(({ title = '', description, additionalDescription, button }, key) => (jsxs("div", { children: [jsx(Headline, { title: title, description: description, headlineVersion: "XS", align: "text-left", isEmbedded: true }), additionalDescription ? (jsx("div", { className: "mt-xs opacity-80", children: jsx(Paragraph, { size: "text-m", font: "font-light", children: additionalDescription }) })) : null, jsx("div", { className: style({ 'mt-xl': Boolean(button?.text) }), children: renderButtonsSection([button]) })] }, String(key)))) }, `col-${String(i)}`)) : null;
6062
6196
 
6063
- const PORTAL_NATURAL_URL = '/';
6064
6197
  const UPDATING_INTERVAL = 60000 * 4;
6065
- const updateRefreshToken = () => {
6198
+ const updateRefreshToken = (failCallback) => {
6066
6199
  const refreshToken = globalThis.sessionStorage?.getItem('refreshToken');
6067
6200
  const accessToken = globalThis.sessionStorage?.getItem('accessToken');
6068
6201
  const taskId = globalThis.localStorage.getItem('taskId');
6069
6202
  if (!accessToken || !refreshToken || !taskId) {
6070
- globalThis.location.href = PORTAL_NATURAL_URL;
6203
+ failCallback();
6071
6204
  return () => null;
6072
6205
  }
6073
6206
  const updateTokenRequest = async () => {
@@ -6077,8 +6210,10 @@
6077
6210
  // eslint-disable-next-line camelcase
6078
6211
  access_token: accessToken,
6079
6212
  });
6080
- if (res) {
6081
- handleStatus(res.status);
6213
+ if (res?.status == 401) {
6214
+ failCallback();
6215
+ }
6216
+ if (res?.ok) {
6082
6217
  const data = await res.json();
6083
6218
  globalThis.sessionStorage.setItem('refreshToken', data.refresh_token);
6084
6219
  globalThis.sessionStorage.setItem('accessToken', data.access_token);
@@ -6088,10 +6223,15 @@
6088
6223
  const timer = setInterval(updateTokenRequest, UPDATING_INTERVAL);
6089
6224
  return () => clearInterval(timer);
6090
6225
  };
6091
- const handleStatus = (status) => {
6092
- if (status == 401) {
6093
- globalThis.location.href = PORTAL_NATURAL_URL;
6094
- }
6226
+
6227
+ function useNavigator() {
6228
+ return useNavigator._impl();
6229
+ }
6230
+ useNavigator._impl = () => ({
6231
+ assign: (url) => globalThis.location.assign(url),
6232
+ });
6233
+ useNavigator.setup = (impl) => {
6234
+ useNavigator._impl = impl;
6095
6235
  };
6096
6236
 
6097
6237
  const ProgressBar = JSX(({ step = 10, description, showPercentage = true }) => (jsxs("div", { children: [jsx("div", { className: "h-4 w-full bg-gray relative", children: jsx("div", { className: "h-4 bg-green", style: { width: `${step}%` } }) }), jsxs("div", { className: "relative", children: [showPercentage ? jsxs("div", { className: "absolute left-2/4 text-green", children: [step, "%"] }) : null, description ? jsx("div", { className: "text-right mr-4 text-gray", children: description }) : null] })] })));
@@ -6941,6 +7081,7 @@
6941
7081
  ],
6942
7082
  ];
6943
7083
 
7084
+ const PORTAL_NATURAL_URL$1 = '/';
6944
7085
  const WIZARD_STEPS$1 = 6;
6945
7086
  const WIZARD_TITLES$1 = [
6946
7087
  'Параметры карты',
@@ -6954,7 +7095,8 @@
6954
7095
  const [step, setStep] = useState(0);
6955
7096
  const formContainerRef = useRef(null);
6956
7097
  const scrollToTop = useCallback(() => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }), [formContainerRef]);
6957
- useEffect(updateRefreshToken, []);
7098
+ const navigator = useNavigator();
7099
+ useEffect(() => updateRefreshToken(() => navigator.assign(PORTAL_NATURAL_URL$1)), []);
6958
7100
  const handleNextStep = useCallback(() => {
6959
7101
  setStep((_) => Math.min(_ + 1, WIZARD_STEPS$1));
6960
7102
  scrollToTop();
@@ -7727,6 +7869,7 @@
7727
7869
  ],
7728
7870
  ];
7729
7871
 
7872
+ const PORTAL_NATURAL_URL = '/';
7730
7873
  const WIZARD_STEPS = 5;
7731
7874
  const WIZARD_TITLES = [
7732
7875
  '',
@@ -7740,7 +7883,8 @@
7740
7883
  const [step, setStep] = useState(0);
7741
7884
  const formContainerRef = useRef(null);
7742
7885
  const scrollToTop = useCallback(() => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }), [formContainerRef]);
7743
- useEffect(updateRefreshToken, []);
7886
+ const navigator = useNavigator();
7887
+ useEffect(() => updateRefreshToken(() => navigator.assign(PORTAL_NATURAL_URL)), []);
7744
7888
  const handleNextStep = useCallback(() => {
7745
7889
  setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
7746
7890
  scrollToTop();
@@ -7935,47 +8079,166 @@
7935
8079
  };
7936
8080
  const ErrorBlock = JSX(({ className = '', title, description, error, button, ...rest }) => (jsxs(BlockWrapper, { className: style('flex flex-col justify-center items-center', className), defaultPadding: style('p-6xl'), version: "transparent", ...rest, children: [jsx("div", { className: "flex justify-center", children: renderErrorContent(error) }), jsx(Headline, { title: title, description: description, headlineVersion: "XL", isEmbedded: true, className: "mb-2xl last:mb-0" }), button?.text ? (jsx(LinkButton, { version: button?.version, text: button?.text, ...button })) : null] })));
7937
8081
 
7938
- const useLatestEvent = (eventBus, type, initialEvent) => {
7939
- const [latestEvent, setLatestEvent] = useState(initialEvent || null);
7940
- useEffect(() => eventBus.subscribe(type, (_) => setLatestEvent(_)), [eventBus, type]);
7941
- const fireEvent = useCallback((_) => eventBus.fire(type, _), [eventBus, type]);
7942
- return [latestEvent, fireEvent];
7943
- };
8082
+ function copy(source, target) {
8083
+ for (const [k, v] of source.entries()) {
8084
+ if (v !== null && v !== undefined) {
8085
+ target.setItem(k, v);
8086
+ }
8087
+ else {
8088
+ target.removeItem(k);
8089
+ }
8090
+ }
8091
+ }
8092
+
8093
+ function replicate(primary, secondary) {
8094
+ copy(primary, secondary);
8095
+ copy(secondary, primary);
8096
+ return primary.bus.watch(({ type, event }) => {
8097
+ if (event !== null && event !== undefined) {
8098
+ secondary.setItem(type, event);
8099
+ }
8100
+ else {
8101
+ secondary.removeItem(type);
8102
+ }
8103
+ });
8104
+ }
8105
+
8106
+ class StorageAdapter {
8107
+ storage;
8108
+ bus;
8109
+ get size() {
8110
+ return this.storage?.length ?? 0;
8111
+ }
8112
+ constructor(storage, bus = new EventBus()) {
8113
+ this.storage = storage;
8114
+ this.bus = bus;
8115
+ }
8116
+ hasItem(key) {
8117
+ return Boolean(this.storage?.getItem(String(key)));
8118
+ }
8119
+ getItem(key) {
8120
+ const _ = this.storage?.getItem(String(key)) ?? null;
8121
+ try {
8122
+ return JSON.parse(String(_));
8123
+ }
8124
+ catch (ex) {
8125
+ return null;
8126
+ }
8127
+ }
8128
+ entries() {
8129
+ return Array.from({ length: this.size }, (_, i) => {
8130
+ const k = String(this.storage?.key(i));
8131
+ return [k, this.getItem(k)];
8132
+ });
8133
+ }
8134
+ setItem(key, value) {
8135
+ if (value !== null) {
8136
+ this.storage?.setItem(String(key), JSON.stringify(value));
8137
+ }
8138
+ else {
8139
+ this.storage?.removeItem(String(key));
8140
+ }
8141
+ this.bus?.subject(key, value);
8142
+ }
8143
+ removeItem(key) {
8144
+ this.storage?.removeItem(String(key));
8145
+ this.bus?.subject(key, null);
8146
+ }
8147
+ }
8148
+
8149
+ class Store {
8150
+ bus;
8151
+ store = new Map();
8152
+ get size() {
8153
+ return this.store.size;
8154
+ }
8155
+ constructor(bus = new EventBus()) {
8156
+ this.bus = bus;
8157
+ }
8158
+ hasItem(key) {
8159
+ return this.store.has(key);
8160
+ }
8161
+ getItem(key) {
8162
+ return this.store.get(key);
8163
+ }
8164
+ entries() {
8165
+ return this.store.entries();
8166
+ }
8167
+ setItem(key, value) {
8168
+ this.store.set(key, value);
8169
+ this.bus.subject(key, value);
8170
+ }
8171
+ removeItem(key) {
8172
+ this.store.delete(key);
8173
+ this.bus.subject(key, null);
8174
+ }
8175
+ }
8176
+
8177
+ function useRerender() {
8178
+ const [, setCount] = useState(0);
8179
+ return useCallback(() => setCount(_ => (_ + 1) % (1 << 16)), []);
8180
+ }
8181
+
8182
+ const DEFAULT_METHODS = {};
8183
+ /**
8184
+ * MobX like reactivity (simplified).
8185
+ * Can be used to migrate from Redux/MobX or something else
8186
+ *
8187
+ * @param store
8188
+ * @returns reactive proxy backed by store
8189
+ */
8190
+ function useStore(store, methods = DEFAULT_METHODS) {
8191
+ const deps = useRef(null);
8192
+ const render = useRerender();
8193
+ useEffect(() => store.bus.watch(ev => {
8194
+ if (deps.current?.has(String(ev.type))) {
8195
+ render();
8196
+ }
8197
+ }), [store, render]);
8198
+ return useMemo(() => new Proxy(methods, {
8199
+ get(_, key) {
8200
+ deps.current ||= new Set();
8201
+ deps.current.add(key);
8202
+ return store.getItem(key);
8203
+ },
8204
+ has(_, key) {
8205
+ deps.current ||= new Set();
8206
+ deps.current.add(key);
8207
+ return store.hasItem(key);
8208
+ },
8209
+ set(_, key, value) {
8210
+ store.setItem(key, value);
8211
+ return true;
8212
+ },
8213
+ deleteProperty(_, key) {
8214
+ store.removeItem(key);
8215
+ return true;
8216
+ }
8217
+ }), [store]);
8218
+ }
8219
+
8220
+ const localStore = new Store(); // localStorage cache
8221
+ replicate(localStore, new StorageAdapter(globalThis?.localStorage));
8222
+ function useLocalStore(methods) {
8223
+ return useStore(localStore, methods);
8224
+ }
7944
8225
 
7945
8226
  const REGION_URL = `${API_BASE_URI}/region`;
7946
- const LOCATION_STORAGE_KEY = 'location';
7947
8227
  function useLocation(defaultLocation = 'Москва') {
7948
- const [currentLocation, fireCurrentLocation] = useLatestEvent(defaultEventBus, 'location', restoreLocation() ?? { name: defaultLocation });
7949
- const selectCurrentLocation = useCallback((_) => {
7950
- storeLocation(_);
7951
- fireCurrentLocation(_);
7952
- }, []);
7953
- const { data } = useAsyncData(hasStoredLocation() ? null : REGION_URL, fetchJSONUnsafe);
7954
- useEffect(() => {
7955
- if (data && !hasStoredLocation()) {
7956
- fireCurrentLocation(data);
7957
- }
7958
- }, [data]);
7959
- return [currentLocation ?? { name: defaultLocation }, selectCurrentLocation];
8228
+ const locationStore = useLocalStore();
8229
+ return locationStore.location ?? { name: defaultLocation };
8230
+ }
8231
+ function useDefaultLocation(defaultLocation = 'Москва') {
8232
+ const locationStore = useLocalStore();
8233
+ const preselectLocation = useCallback(async () => {
8234
+ if (!locationStore.location) {
8235
+ const region = await fetchJSON(REGION_URL);
8236
+ locationStore.location = region ?? { name: defaultLocation };
8237
+ }
8238
+ }, [locationStore, defaultLocation]);
8239
+ useAsyncData(REGION_URL, preselectLocation);
8240
+ return locationStore;
7960
8241
  }
7961
- const hasStoredLocation = () => Boolean(globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY));
7962
- const restoreLocation = () => {
7963
- try {
7964
- const data = globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY);
7965
- return data && JSON.parse(data);
7966
- }
7967
- catch (ex) {
7968
- return null;
7969
- }
7970
- };
7971
- const storeLocation = (_) => {
7972
- try {
7973
- globalThis.localStorage?.setItem(LOCATION_STORAGE_KEY, JSON.stringify(_));
7974
- }
7975
- catch (ex) {
7976
- // Do nothing
7977
- }
7978
- };
7979
8242
 
7980
8243
  var Currency;
7981
8244
  (function (Currency) {
@@ -8117,7 +8380,7 @@
8117
8380
  }
8118
8381
 
8119
8382
  const ExchangeRateTile = JSX(({ className = '', title = 'Курсы обмена валют', button, ...rest }) => {
8120
- const [currentLocation] = useLocation();
8383
+ const currentLocation = useLocation();
8121
8384
  const exchangeRates = useFetchExchangeRateData(currentLocation);
8122
8385
  const currencyRates = getCurrencyRates(exchangeRates?.exchangeRate?.currencies);
8123
8386
  const currencyRatesBuy = currencyRates.filter((_) => _.buyExchangeRate);
@@ -8597,27 +8860,33 @@
8597
8860
  return (jsxs("form", { className: `font-sans relative ${className}`, children: [jsx("div", { className: "absolute rounded h-full flex items-center justify-center pl-m max-w-44 gap-s pointer-events-none", children: searchTerm ? null : (jsx("label", { htmlFor: "search-bar-input", className: `text-secondary-text `, children: "\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0444\u0438\u043B\u0438\u0430\u043B\u0430\u043C" })) }), jsx("input", { id: "search-bar-input", className: style(inputValidStyle, `h-12 pl-m w-full peer text-l text-black rounded-md box-border`), value: searchTerm, onChange: (e) => onSearch(e.target.value.toLowerCase()), type: "text", name: "location-search-bar-input" })] }));
8598
8861
  });
8599
8862
 
8600
- const SEARCH_TERM_MIN_LENGTH = 3;
8601
- const LocationDialog = JSX(({ foreignOffices, branches }) => {
8602
- const [currentLocation, selectCurrentLocation] = useLocation(branches?.default);
8863
+ const SelectedLocation = JSX(({ defaultLocation }) => {
8864
+ const currentLocation = useLocation(defaultLocation);
8603
8865
  const link = useLink();
8604
8866
  const { href } = link({ href: `/branches/${currentLocation.slug}` });
8867
+ return currentLocation ? (jsx("div", { className: "mb-s", children: jsxs(Paragraph, { size: "text-l", color: "text-primary-text", children: ["\u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u044B\u0431\u0440\u0430\u043D:", jsx(LinkWrapper, { href: href, className: "inline mx-2xs text-primary-main", children: currentLocation.name })] }) })) : null;
8868
+ });
8869
+
8870
+ const SEARCH_TERM_MIN_LENGTH = 3;
8871
+ const LocationDialog = JSX(({ foreignOffices, branches }) => {
8872
+ const locationStore = useDefaultLocation(branches?.default);
8605
8873
  const [query, setQuery] = useState('');
8606
- const regions = cleanUpRegions(useRegions()).sort((a, b) => a.name.localeCompare(b.name));
8607
- const regionsGroupByLetter = groupBy(regions, regionFirstLetter);
8874
+ const rawRegions = useRegions();
8875
+ const regions = useMemo(() => cleanUpRegions(rawRegions).sort((a, b) => a.name.localeCompare(b.name)), [rawRegions]);
8876
+ const regionsGroupByLetter = useMemo(() => groupBy(regions, regionFirstLetter), [regions]);
8608
8877
  const { close } = useDialogManager();
8609
- const handleChangeLocation = useCallback((region) => {
8610
- selectCurrentLocation(region);
8878
+ const handleChangeLocation = useCallback((_) => {
8879
+ locationStore.location = _;
8611
8880
  close();
8612
- }, []);
8613
- return (jsxs(Dialog, { className: "pb-20", head: jsxs("div", { children: [jsx(Text, { size: "text-h4", color: "text-primary-text", children: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0438\u043B\u0438\u0430\u043B" }), currentLocation ? (jsx("div", { className: "mb-s", children: jsxs(Paragraph, { size: "text-l", color: "text-primary-text", children: ["\u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u044B\u0431\u0440\u0430\u043D:", jsx(LinkWrapper, { href: href, className: "inline mx-2xs text-primary-main", children: currentLocation.name })] }) })) : null, jsx(SearchBar, { onSearch: setQuery, searchTerm: query })] }), children: [query && query.length >= SEARCH_TERM_MIN_LENGTH ? (jsx("div", { children: regions
8881
+ }, [locationStore]);
8882
+ return (jsxs(Dialog, { className: "pb-20", head: jsxs("div", { children: [jsx(Text, { size: "text-h4", color: "text-primary-text", children: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0438\u043B\u0438\u0430\u043B" }), jsx(SelectedLocation, { defaultLocation: branches?.default }), jsx(SearchBar, { onSearch: setQuery, searchTerm: query })] }), children: [query && query.length >= SEARCH_TERM_MIN_LENGTH ? (jsx("div", { children: regions
8614
8883
  .filter(({ name }) => name && jaroWinklerDistance(name.toLowerCase())(query.toLowerCase()) >= 0.8)
8615
8884
  .map(renderRegion(branches?.dataSelect, handleChangeLocation)) })) : (jsx("div", { className: "columns-1 sm:columns-3 md:columns-4 lg:columns-5", children: Array.from(regionsGroupByLetter.entries()).map(renderRegionGroup(handleChangeLocation, branches?.dataSelect)) })), renderForeignOffices(foreignOffices)] }));
8616
8885
  });
8617
- const regionFirstLetter = (region) => region.name?.charAt(0) || '';
8886
+ const regionFirstLetter = (region) => region.name?.charAt(0) ?? '';
8618
8887
  const cleanUpRegions = (regions) => regions.map((region) => ({
8619
8888
  ...region,
8620
- name: region.name?.replace(/республика|область|край'/gi, '').trim() || '',
8889
+ name: region.name?.replace(/республика|область|край'/gi, '').trim() ?? '',
8621
8890
  }));
8622
8891
 
8623
8892
  const useLocationDialog = (props) => {
@@ -8645,7 +8914,7 @@
8645
8914
 
8646
8915
  const HeaderSecondaryMenu = JSX(({ className, version, ...rest }) => {
8647
8916
  const iconVersion = version === 'transparent' ? 'white' : 'black';
8648
- const [currentLocation] = useLocation(rest?.branches?.default);
8917
+ const currentLocation = useLocation(rest?.branches?.default);
8649
8918
  const searchDialog = useSearchDialog(rest);
8650
8919
  const locationDialog = useLocationDialog(rest);
8651
8920
  const openSearchDialog = useCallback(() => searchDialog.open(), [searchDialog]);
@@ -9177,7 +9446,7 @@
9177
9446
  designDisabledPeople: (item) => Boolean(item.designDisabledPeople),
9178
9447
  };
9179
9448
  const AtmsMap = JSX(({ descriptionData, className }) => {
9180
- const [currentLocation] = useLocation();
9449
+ const currentLocation = useLocation();
9181
9450
  const regionCode = currentLocation?.code ?? '000';
9182
9451
  const { data: officesData, isLoad } = useAtms(regionCode);
9183
9452
  return (jsx(OfficesAtmsMapLayout, { className: className, filterItems: filterItems, data: officesData, isLoad: isLoad, initFilterState: INITIAL_FILTRATION_STATE, renderCard: renderAtmCard, getBalloon: getAtmPoint, title: `Банкоматы филиала ${currentLocation?.name}`, descriptionData: descriptionData }));
@@ -9230,7 +9499,7 @@
9230
9499
  };
9231
9500
 
9232
9501
  const OfficesMap = JSX(({ className }) => {
9233
- const [currentLocation] = useLocation();
9502
+ const currentLocation = useLocation();
9234
9503
  const regionCode = currentLocation?.code ?? '000';
9235
9504
  const { data, isLoad } = useOffices(regionCode);
9236
9505
  return (jsx(OfficesAtmsMapLayout, { className: className, data: data?.branches, isLoad: isLoad, remoteWorkplaces: data?.remoteWorkplaces, renderCard: renderOfficeCard, renderRemoteWorkplaceCard: renderRemoteWorkplaceCard, getBalloon: getOfficePoint, getBalloonRemoteWorkplaces: getRemoteWorkplacePoint, title: `Офисы филиала ${currentLocation?.name}` }));
@@ -9918,6 +10187,9 @@
9918
10187
  pop();
9919
10188
  }, [dialogs, onClose]);
9920
10189
  useEffect(() => defaultEventBus.subscribe('dialog', (action) => {
10190
+ if (!action) {
10191
+ return;
10192
+ }
9921
10193
  switch (action.type) {
9922
10194
  case 'open':
9923
10195
  push(action);
@@ -9975,6 +10247,9 @@
9975
10247
  setPopup(null);
9976
10248
  }, []);
9977
10249
  useEffect(() => defaultEventBus.subscribe('popup', (action) => {
10250
+ if (!action) {
10251
+ return;
10252
+ }
9978
10253
  switch (action.type) {
9979
10254
  case 'open':
9980
10255
  case 'update':
@@ -10008,6 +10283,7 @@
10008
10283
  const { slots, blocks, fallback, ...pageContent } = data;
10009
10284
  const resolvedPageContent = useJSONRef(pageContent, fallback);
10010
10285
  useClickHandler();
10286
+ useDefaultLocation();
10011
10287
  const options = {
10012
10288
  key: '',
10013
10289
  page: { slots, blocks, fallback, ...resolvedPageContent },
@@ -10029,7 +10305,7 @@
10029
10305
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
10030
10306
  });
10031
10307
 
10032
- const packageVersion = "0.14.674";
10308
+ const packageVersion = "0.14.676";
10033
10309
 
10034
10310
  exports.Blocks = Blocks;
10035
10311
  exports.ContentPage = ContentPage;
@@ -10040,6 +10316,7 @@
10040
10316
  exports.setup = setup;
10041
10317
  exports.setupHooks = setupHooks;
10042
10318
  exports.url = url;
10319
+ exports.useNavigator = useNavigator;
10043
10320
  exports.useRouter = useRouter;
10044
10321
 
10045
10322
  Object.defineProperty(exports, '__esModule', { value: true });