@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
@@ -414,32 +414,53 @@
414
414
  className,
415
415
  ].join(' ');
416
416
 
417
- class EventBus {
418
- subscribers = {};
419
- subjectsStateMap = {};
420
- subscribe(type, listener) {
421
- this.subscribers[type] = (this.subscribers[type] || []).concat(listener);
422
- const latestEvent = this.subjectsStateMap[type];
423
- if (latestEvent) {
424
- listener(latestEvent);
425
- }
426
- return () => {
427
- this.unsubscribe(type, listener);
428
- };
429
- }
430
- unsubscribe(type, listener) {
431
- this.subscribers[type] = this.subscribers[type]?.filter((s) => s !== listener);
432
- }
433
- fire(type, event) {
434
- const isSubjectDeclared = type in this.subjectsStateMap;
435
- if (isSubjectDeclared) {
436
- this.subjectsStateMap[type] = event;
437
- }
438
- this.subscribers[type]?.forEach((s) => s(event));
439
- }
440
- subject(type, event) {
441
- this.subjectsStateMap[type] = event;
442
- }
417
+ class EventBus {
418
+ watchers = new Set();
419
+ subscribersMap = {};
420
+ subjectsStateMap = {};
421
+ emitter = this;
422
+ observable = this;
423
+ watch(watcher) {
424
+ this.watchers.add(watcher);
425
+ return () => {
426
+ this.watchers.delete(watcher);
427
+ };
428
+ }
429
+ subscribe(type, listener) {
430
+ this.subscribersMap[type] ||= new Set();
431
+ this.subscribersMap[type]?.add(listener);
432
+ const initialEvent = this.subjectsStateMap[type];
433
+ initialEvent && listener(initialEvent);
434
+ return () => {
435
+ this.subscribersMap[type]?.delete(listener);
436
+ };
437
+ }
438
+ fire(type, event) {
439
+ const isSubjectDeclared = type in this.subjectsStateMap;
440
+ if (isSubjectDeclared) {
441
+ this.subject(type, event);
442
+ }
443
+ else {
444
+ this.fireSubscribers(type, event);
445
+ }
446
+ }
447
+ subject(type, event) {
448
+ if (this.subjectsStateMap[type] !== event) {
449
+ this.subjectsStateMap[type] = event ?? undefined;
450
+ this.fireSubscribers(type, event);
451
+ }
452
+ return () => {
453
+ delete this.subjectsStateMap[type];
454
+ };
455
+ }
456
+ fireSubscribers(type, event) {
457
+ for (const _ of this.subscribersMap[type] ?? []) {
458
+ _(event ?? null);
459
+ }
460
+ for (const _ of this.watchers) {
461
+ _({ type, event: event ?? null });
462
+ }
463
+ }
443
464
  }
444
465
 
445
466
  const defaultEventBus = new EventBus();
@@ -725,26 +746,166 @@
725
746
  const leftOrRightImage = (img, directionRight) => directionRight ? { rightImage: img } : { leftImage: img };
726
747
  const renderTags = (tags) => (tags?.length ? jsx(Tags, { tags: tags }) : null);
727
748
 
749
+ class JSONBox {
750
+ _;
751
+ constructor(_) {
752
+ this._ = _;
753
+ }
754
+ of(_) {
755
+ return new this.constructor(_ instanceof JSONBox ? _._ : _);
756
+ }
757
+ filter(predicate) {
758
+ return this.from(this.entries().filter(predicate));
759
+ }
760
+ map(mapper) {
761
+ return this.from(this.entries().map(mapper));
762
+ }
763
+ flatMap(mapper) {
764
+ return this.from(this.entries().flatMap(mapper));
765
+ }
766
+ reduce(reducer, initial) {
767
+ return this.entries().reduce(reducer.bind(this), initial);
768
+ }
769
+ }
770
+
771
+ const trueF = () => true;
772
+ const and = (a, b) => (...args) => a(...args) && b(...args);
773
+
774
+ const table = (...table) => (...input) => {
775
+ const [, unit] = assertNonEmpty$1(table.find(([predicate]) => predicate(...input)));
776
+ return unit(...input);
777
+ };
778
+ function assertNonEmpty$1(value) {
779
+ if (!value) {
780
+ throw new Error('Value should be fulfilled');
781
+ }
782
+ return value;
783
+ }
784
+
728
785
  const isJSONArray = (_) => Boolean(_ && Array.isArray(_));
729
- const isJSONRecord = (_) => Boolean(_ && !Array.isArray(_) && typeof _ === 'object');
730
- const isJSONRef = (_) => Boolean(isJSONRecord(_) && typeof _.$ref === 'string');
786
+ const isJSONRecord = (_) => Boolean(_ && typeof _ === 'object' && !isJSONArray(_));
787
+
788
+ const identity$1 = (x) => x;
789
+
790
+ const t0 = (fn = identity$1) => ([_]) => fn(_);
791
+ const t1 = (fn = identity$1) => ([, _]) => fn(_);
731
792
 
732
- const mapJSONNode = (json, handlers) => {
733
- if (isJSONRef(json)) {
734
- return handlers.ref(json);
793
+ function unbox(box) {
794
+ return box instanceof JSONBox ? box._ : box;
795
+ }
796
+
797
+ class JSONArrayBox extends JSONBox {
798
+ from(entries) {
799
+ return this.of(entries.map(t1(unbox)));
735
800
  }
736
- else if (isJSONRecord(json)) {
737
- return handlers.record(json);
801
+ entries() {
802
+ return (this._ ?? []).map((node, p) => [p, this.of(node)]);
738
803
  }
739
- else if (isJSONArray(json)) {
740
- return handlers.array(json);
804
+ size() {
805
+ return this._?.length ?? 0;
741
806
  }
742
- else {
743
- return handlers.scalar ? handlers.scalar(json) : json;
807
+ get(p) {
808
+ return this.of(typeof p === 'number' ? this._?.[p] : undefined);
809
+ }
810
+ set(p, child) {
811
+ return this.of(isJSONArray(this._)
812
+ ? Array.from({ length: Math.max(this._.length, Number(p) + 1) }, (x, i) => (i === p ? child : this._[i]))
813
+ : Array.from({ length: Number(p) + 1 }, (x, i) => (i === p ? child : undefined)));
814
+ }
815
+ }
816
+
817
+ class JSONLeafBox extends JSONBox {
818
+ from() {
819
+ return this;
820
+ }
821
+ entries() {
822
+ return [];
823
+ }
824
+ size() {
825
+ return 0;
826
+ }
827
+ get(p) {
828
+ return this.of(p !== undefined ? undefined /* no childs */ : this._ /* self */);
829
+ }
830
+ set(p, child) {
831
+ return this.of(child);
832
+ }
833
+ }
834
+
835
+ class JSONRecordBox extends JSONBox {
836
+ from(entries) {
837
+ return this.of(Object.fromEntries(entries.map(([p, box]) => [p, unbox(box)])));
838
+ }
839
+ entries() {
840
+ return Object.entries(this._ ?? {}).map(([p, node]) => [p, this.of(node)]);
841
+ }
842
+ size() {
843
+ return Object.keys(this._ ?? {}).length;
844
+ }
845
+ get(p) {
846
+ return this.of(typeof p === 'string' ? this._?.[p] : undefined);
847
+ }
848
+ set(p, child) {
849
+ return this.of({ ...this._, [p]: child });
850
+ }
851
+ }
852
+
853
+ class JSONBoxDefault extends JSONBox {
854
+ proto = table([p => isJSONArray(this._) || typeof p === 'number', () => JSONArrayBox.prototype], [p => isJSONRecord(this._) || typeof p === 'string', () => JSONRecordBox.prototype], [trueF, () => JSONLeafBox.prototype]);
855
+ from(entries) {
856
+ return this.proto(undefined).from.call(this, entries);
857
+ }
858
+ entries() {
859
+ return this.proto(undefined).entries.call(this);
860
+ }
861
+ size() {
862
+ return this.proto(undefined).size.call(this);
744
863
  }
864
+ get(p) {
865
+ return this.proto(p).get.call(this, p);
866
+ }
867
+ set(p, child) {
868
+ return this.proto(p).set.call(this, p, child);
869
+ }
870
+ }
871
+
872
+ const box = (_) => (_ instanceof JSONBox ? _ : new JSONBoxDefault(_));
873
+
874
+ const boxed = (fn) => {
875
+ const boxedFn = (node, ...args) => unbox(fn(box(node), ...args));
876
+ boxedFn.fn = fn;
877
+ return boxedFn;
745
878
  };
746
879
 
747
- const mergeRecords = (entries) => entries.reduce((acc, _) => Object.assign(acc, _), {});
880
+ const ROOT = [];
881
+ const endsWith = (suffix) => suffix
882
+ .map((predicate, i) => (path) => cmp(predicate)(path[i + path.length - suffix.length]))
883
+ .reduceRight(and, trueF);
884
+ const cmp = (a) => a instanceof Function ? a : (b) => a === b;
885
+
886
+ const reduce = (reducer) => (node, initial, path = ROOT) => box(node)
887
+ .entries()
888
+ .reduce((acc, [p, _]) => reduce(reducer)(_, acc, path.concat(p)), reducer(initial, [path, box(node)]));
889
+
890
+ const set = boxed((target, [path, node]) => {
891
+ const [p, ...tail] = path;
892
+ return target.set(p, tail.length ? set(target.get(p), [tail, node]) : node);
893
+ });
894
+
895
+ const fromEntries = boxed((initial, tree) => tree.reduce(set.fn, initial));
896
+
897
+ const leafs = (node) => reduce((acc, [path, _]) => (isLeaf(_) ? [...acc, [path, unbox(_)]] : acc))(node, []);
898
+ const isLeaf = (_) => _.size() === 0;
899
+
900
+ const map = (mapper, initial = {}) => (node) => fromEntries(initial, leafs(node).map(_ => mapper(_)));
901
+
902
+ const init = (list) => list.slice(0, -1);
903
+
904
+ boxed((target, path = ROOT) => path.reduce((_, p) => _.get(p), target));
905
+
906
+ const remove = boxed((target, [p, ...tail]) => tail.length ? target.set(p, remove(target.get(p), tail)) : target.filter(([i]) => i !== p));
907
+
908
+ const isJSONRefPath = endsWith(['$ref']);
748
909
 
749
910
  const parseJPointer = (uri) => uri.includes('#')
750
911
  ? uri
@@ -754,46 +915,17 @@
754
915
  : [];
755
916
 
756
917
  const resolveJPointer = (json, uri) => parseJPointer(uri).reduce(selectNodeByKey, json);
757
- const selectNodeByKey = (json, key) => {
758
- if (!json || !key) {
759
- return json;
760
- }
761
- if (isJSONRecord(json)) {
762
- return json[key];
763
- }
764
- else if (isJSONArray(json)) {
765
- return json[parseInt(key, 10)];
766
- }
767
- else {
768
- return json;
769
- }
770
- };
918
+ const selectNodeByKey = table([isJSONArray, (json, key) => json[parseInt(key, 10)]], [isJSONRecord, (json, key) => json[key]], [trueF, identity$1]);
771
919
 
772
- const resolveRef = (json, resolver) => mapJSONNode(json, {
773
- ref: ({ $ref, ...rest }) => resolveRef($ref ? resolveJPointer(resolver($ref), $ref) : rest, resolver),
774
- record: record => mergeRecords(Object.entries(record).map(([key, value]) => ({ [key]: resolveRef(value, resolver) }))),
775
- array: list => list.map(_ => resolveRef(_, resolver))
776
- });
920
+ const resolveRef = (json, resolver) => map(([path, node]) => isJSONRefPath(path)
921
+ ? [init(path), resolveJPointer(resolver(node), node)]
922
+ : [path, node])(json);
777
923
 
778
- const visitRef = (json, visitor, path = []) => {
779
- mapJSONNode(json, {
780
- ref: json => visitor(json.$ref, path),
781
- record: record => {
782
- for (const key in record)
783
- visitRef(record[key], visitor, [...path, key]);
784
- },
785
- array: list => {
786
- for (let i = 0; i < list.length; i++)
787
- visitRef(list[i], visitor, [...path, i]);
788
- }
789
- });
790
- };
924
+ const refEntries = (json) => leafs(json).filter(t0(isJSONRefPath));
791
925
 
792
- const collectRef = (json) => {
793
- const refs = [];
794
- visitRef(json, _ => refs.push(_));
795
- return refs;
796
- };
926
+ const unique$1 = (list) => [...new Set(list)];
927
+
928
+ const collectRef = (json) => unique$1(refEntries(json).map(([, _]) => _));
797
929
 
798
930
  async function fetchJSON(url, options) {
799
931
  try {
@@ -3156,10 +3288,10 @@
3156
3288
  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 })));
3157
3289
 
3158
3290
  const OUT_SERVICE_BASE_URL = `${API_BASE_URI}/outservice`;
3159
- const EMPTY_REGIONS = [];
3291
+ const EMPTY_REGIONS$1 = [];
3160
3292
  async function getOutServiceRegions() {
3161
3293
  const data = await fetchJSON(`${OUT_SERVICE_BASE_URL}/outserviceregions`);
3162
- return data && Array.isArray(data) ? data : EMPTY_REGIONS;
3294
+ return data && Array.isArray(data) ? data : EMPTY_REGIONS$1;
3163
3295
  }
3164
3296
 
3165
3297
  const LocalitiesField = JSX(({ field, input }) => {
@@ -3292,9 +3424,11 @@
3292
3424
  const arrayToOptions = (array) => (array ?? []).map((_) => ({ key: _, value: _ }));
3293
3425
 
3294
3426
  const REGIONS_URL = `${API_BASE_URI}/regions`;
3427
+ const EMPTY_REGIONS = [];
3428
+ // TODO Почему url можно менять? Разве смысл не в инкапсуляции api url. Тоже под рефакторинг попадает
3295
3429
  function useRegions(url = REGIONS_URL) {
3296
3430
  const { data } = useAsyncData(url, fetchJSONUnsafe);
3297
- return Array.isArray(data) ? data : [];
3431
+ return Array.isArray(data) ? data : EMPTY_REGIONS;
3298
3432
  }
3299
3433
 
3300
3434
  const RegionField = JSX(({ field, input, url }) => {
@@ -6010,7 +6144,7 @@
6010
6144
  : [cellsNode, []];
6011
6145
  const [isVisible, setIsVisible] = useState(false);
6012
6146
  useEffect(() => defaultEventBus.subscribe('fold', (event) => {
6013
- if (options?.parent !== undefined && event.parent === options?.parent) {
6147
+ if (event && options?.parent !== undefined && event.parent === options?.parent) {
6014
6148
  setIsVisible(event.isUnfolded);
6015
6149
  }
6016
6150
  }), [options?.parent]);
@@ -6024,14 +6158,13 @@
6024
6158
  }
6025
6159
  }, type: "button", ...(isUnfolded ? getAspectsAttributes(data) : {}), children: [jsx("div", { children: isUnfolded ? 'Скрыть' : 'Подробнее о тарифе' }), jsx(Icon, { className: "text-primary-text", name: isUnfolded ? 'ArrowUpIcon' : 'ArrowDownIcon', width: "16", height: "16" })] }));
6026
6160
 
6027
- const PORTAL_NATURAL_URL = '/';
6028
6161
  const UPDATING_INTERVAL = 60000 * 4;
6029
- const updateRefreshToken = () => {
6162
+ const updateRefreshToken = (failCallback) => {
6030
6163
  const refreshToken = globalThis.sessionStorage?.getItem('refreshToken');
6031
6164
  const accessToken = globalThis.sessionStorage?.getItem('accessToken');
6032
6165
  const taskId = globalThis.localStorage.getItem('taskId');
6033
6166
  if (!accessToken || !refreshToken || !taskId) {
6034
- globalThis.location.href = PORTAL_NATURAL_URL;
6167
+ failCallback();
6035
6168
  return () => null;
6036
6169
  }
6037
6170
  const updateTokenRequest = async () => {
@@ -6041,8 +6174,10 @@
6041
6174
  // eslint-disable-next-line camelcase
6042
6175
  access_token: accessToken,
6043
6176
  });
6044
- if (res) {
6045
- handleStatus(res.status);
6177
+ if (res?.status == 401) {
6178
+ failCallback();
6179
+ }
6180
+ if (res?.ok) {
6046
6181
  const data = await res.json();
6047
6182
  globalThis.sessionStorage.setItem('refreshToken', data.refresh_token);
6048
6183
  globalThis.sessionStorage.setItem('accessToken', data.access_token);
@@ -6052,10 +6187,15 @@
6052
6187
  const timer = setInterval(updateTokenRequest, UPDATING_INTERVAL);
6053
6188
  return () => clearInterval(timer);
6054
6189
  };
6055
- const handleStatus = (status) => {
6056
- if (status == 401) {
6057
- globalThis.location.href = PORTAL_NATURAL_URL;
6058
- }
6190
+
6191
+ function useNavigator() {
6192
+ return useNavigator._impl();
6193
+ }
6194
+ useNavigator._impl = () => ({
6195
+ assign: (url) => globalThis.location.assign(url),
6196
+ });
6197
+ useNavigator.setup = (impl) => {
6198
+ useNavigator._impl = impl;
6059
6199
  };
6060
6200
 
6061
6201
  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] })] })));
@@ -6921,6 +7061,7 @@
6921
7061
  ],
6922
7062
  ];
6923
7063
 
7064
+ const PORTAL_NATURAL_URL$1 = '/';
6924
7065
  const WIZARD_STEPS$1 = 6;
6925
7066
  const WIZARD_TITLES$1 = [
6926
7067
  'Параметры карты',
@@ -6934,7 +7075,8 @@
6934
7075
  const [step, setStep] = useState(0);
6935
7076
  const formContainerRef = useRef(null);
6936
7077
  const scrollToTop = useCallback(() => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }), [formContainerRef]);
6937
- useEffect(updateRefreshToken, []);
7078
+ const navigator = useNavigator();
7079
+ useEffect(() => updateRefreshToken(() => navigator.assign(PORTAL_NATURAL_URL$1)), []);
6938
7080
  const handleNextStep = useCallback(() => {
6939
7081
  setStep((_) => Math.min(_ + 1, WIZARD_STEPS$1));
6940
7082
  scrollToTop();
@@ -7707,6 +7849,7 @@
7707
7849
  ],
7708
7850
  ];
7709
7851
 
7852
+ const PORTAL_NATURAL_URL = '/';
7710
7853
  const WIZARD_STEPS = 5;
7711
7854
  const WIZARD_TITLES = [
7712
7855
  '',
@@ -7720,7 +7863,8 @@
7720
7863
  const [step, setStep] = useState(0);
7721
7864
  const formContainerRef = useRef(null);
7722
7865
  const scrollToTop = useCallback(() => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }), [formContainerRef]);
7723
- useEffect(updateRefreshToken, []);
7866
+ const navigator = useNavigator();
7867
+ useEffect(() => updateRefreshToken(() => navigator.assign(PORTAL_NATURAL_URL)), []);
7724
7868
  const handleNextStep = useCallback(() => {
7725
7869
  setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
7726
7870
  scrollToTop();
@@ -7914,47 +8058,166 @@
7914
8058
  };
7915
8059
  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] })));
7916
8060
 
7917
- const useLatestEvent = (eventBus, type, initialEvent) => {
7918
- const [latestEvent, setLatestEvent] = useState(initialEvent || null);
7919
- useEffect(() => eventBus.subscribe(type, (_) => setLatestEvent(_)), [eventBus, type]);
7920
- const fireEvent = useCallback((_) => eventBus.fire(type, _), [eventBus, type]);
7921
- return [latestEvent, fireEvent];
7922
- };
8061
+ function copy(source, target) {
8062
+ for (const [k, v] of source.entries()) {
8063
+ if (v !== null && v !== undefined) {
8064
+ target.setItem(k, v);
8065
+ }
8066
+ else {
8067
+ target.removeItem(k);
8068
+ }
8069
+ }
8070
+ }
8071
+
8072
+ function replicate(primary, secondary) {
8073
+ copy(primary, secondary);
8074
+ copy(secondary, primary);
8075
+ return primary.bus.watch(({ type, event }) => {
8076
+ if (event !== null && event !== undefined) {
8077
+ secondary.setItem(type, event);
8078
+ }
8079
+ else {
8080
+ secondary.removeItem(type);
8081
+ }
8082
+ });
8083
+ }
8084
+
8085
+ class StorageAdapter {
8086
+ storage;
8087
+ bus;
8088
+ get size() {
8089
+ return this.storage?.length ?? 0;
8090
+ }
8091
+ constructor(storage, bus = new EventBus()) {
8092
+ this.storage = storage;
8093
+ this.bus = bus;
8094
+ }
8095
+ hasItem(key) {
8096
+ return Boolean(this.storage?.getItem(String(key)));
8097
+ }
8098
+ getItem(key) {
8099
+ const _ = this.storage?.getItem(String(key)) ?? null;
8100
+ try {
8101
+ return JSON.parse(String(_));
8102
+ }
8103
+ catch (ex) {
8104
+ return null;
8105
+ }
8106
+ }
8107
+ entries() {
8108
+ return Array.from({ length: this.size }, (_, i) => {
8109
+ const k = String(this.storage?.key(i));
8110
+ return [k, this.getItem(k)];
8111
+ });
8112
+ }
8113
+ setItem(key, value) {
8114
+ if (value !== null) {
8115
+ this.storage?.setItem(String(key), JSON.stringify(value));
8116
+ }
8117
+ else {
8118
+ this.storage?.removeItem(String(key));
8119
+ }
8120
+ this.bus?.subject(key, value);
8121
+ }
8122
+ removeItem(key) {
8123
+ this.storage?.removeItem(String(key));
8124
+ this.bus?.subject(key, null);
8125
+ }
8126
+ }
8127
+
8128
+ class Store {
8129
+ bus;
8130
+ store = new Map();
8131
+ get size() {
8132
+ return this.store.size;
8133
+ }
8134
+ constructor(bus = new EventBus()) {
8135
+ this.bus = bus;
8136
+ }
8137
+ hasItem(key) {
8138
+ return this.store.has(key);
8139
+ }
8140
+ getItem(key) {
8141
+ return this.store.get(key);
8142
+ }
8143
+ entries() {
8144
+ return this.store.entries();
8145
+ }
8146
+ setItem(key, value) {
8147
+ this.store.set(key, value);
8148
+ this.bus.subject(key, value);
8149
+ }
8150
+ removeItem(key) {
8151
+ this.store.delete(key);
8152
+ this.bus.subject(key, null);
8153
+ }
8154
+ }
8155
+
8156
+ function useRerender() {
8157
+ const [, setCount] = useState(0);
8158
+ return useCallback(() => setCount(_ => (_ + 1) % (1 << 16)), []);
8159
+ }
8160
+
8161
+ const DEFAULT_METHODS = {};
8162
+ /**
8163
+ * MobX like reactivity (simplified).
8164
+ * Can be used to migrate from Redux/MobX or something else
8165
+ *
8166
+ * @param store
8167
+ * @returns reactive proxy backed by store
8168
+ */
8169
+ function useStore(store, methods = DEFAULT_METHODS) {
8170
+ const deps = useRef(null);
8171
+ const render = useRerender();
8172
+ useEffect(() => store.bus.watch(ev => {
8173
+ if (deps.current?.has(String(ev.type))) {
8174
+ render();
8175
+ }
8176
+ }), [store, render]);
8177
+ return useMemo(() => new Proxy(methods, {
8178
+ get(_, key) {
8179
+ deps.current ||= new Set();
8180
+ deps.current.add(key);
8181
+ return store.getItem(key);
8182
+ },
8183
+ has(_, key) {
8184
+ deps.current ||= new Set();
8185
+ deps.current.add(key);
8186
+ return store.hasItem(key);
8187
+ },
8188
+ set(_, key, value) {
8189
+ store.setItem(key, value);
8190
+ return true;
8191
+ },
8192
+ deleteProperty(_, key) {
8193
+ store.removeItem(key);
8194
+ return true;
8195
+ }
8196
+ }), [store]);
8197
+ }
8198
+
8199
+ const localStore = new Store(); // localStorage cache
8200
+ replicate(localStore, new StorageAdapter(globalThis?.localStorage));
8201
+ function useLocalStore(methods) {
8202
+ return useStore(localStore, methods);
8203
+ }
7923
8204
 
7924
8205
  const REGION_URL = `${API_BASE_URI}/region`;
7925
- const LOCATION_STORAGE_KEY = 'location';
7926
8206
  function useLocation(defaultLocation = 'Москва') {
7927
- const [currentLocation, fireCurrentLocation] = useLatestEvent(defaultEventBus, 'location', restoreLocation() ?? { name: defaultLocation });
7928
- const selectCurrentLocation = useCallback((_) => {
7929
- storeLocation(_);
7930
- fireCurrentLocation(_);
7931
- }, []);
7932
- const { data } = useAsyncData(hasStoredLocation() ? null : REGION_URL, fetchJSONUnsafe);
7933
- useEffect(() => {
7934
- if (data && !hasStoredLocation()) {
7935
- fireCurrentLocation(data);
7936
- }
7937
- }, [data]);
7938
- return [currentLocation ?? { name: defaultLocation }, selectCurrentLocation];
8207
+ const locationStore = useLocalStore();
8208
+ return locationStore.location ?? { name: defaultLocation };
8209
+ }
8210
+ function useDefaultLocation(defaultLocation = 'Москва') {
8211
+ const locationStore = useLocalStore();
8212
+ const preselectLocation = useCallback(async () => {
8213
+ if (!locationStore.location) {
8214
+ const region = await fetchJSON(REGION_URL);
8215
+ locationStore.location = region ?? { name: defaultLocation };
8216
+ }
8217
+ }, [locationStore, defaultLocation]);
8218
+ useAsyncData(REGION_URL, preselectLocation);
8219
+ return locationStore;
7939
8220
  }
7940
- const hasStoredLocation = () => Boolean(globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY));
7941
- const restoreLocation = () => {
7942
- try {
7943
- const data = globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY);
7944
- return data && JSON.parse(data);
7945
- }
7946
- catch (ex) {
7947
- return null;
7948
- }
7949
- };
7950
- const storeLocation = (_) => {
7951
- try {
7952
- globalThis.localStorage?.setItem(LOCATION_STORAGE_KEY, JSON.stringify(_));
7953
- }
7954
- catch (ex) {
7955
- // Do nothing
7956
- }
7957
- };
7958
8221
 
7959
8222
  var Currency;
7960
8223
  (function (Currency) {
@@ -8096,7 +8359,7 @@
8096
8359
  }
8097
8360
 
8098
8361
  const ExchangeRateTile = JSX(({ className = '', title = 'Курсы обмена валют', button, ...rest }) => {
8099
- const [currentLocation] = useLocation();
8362
+ const currentLocation = useLocation();
8100
8363
  const exchangeRates = useFetchExchangeRateData(currentLocation);
8101
8364
  const currencyRates = getCurrencyRates(exchangeRates?.exchangeRate?.currencies);
8102
8365
  const currencyRatesBuy = currencyRates.filter((_) => _.buyExchangeRate);
@@ -8583,7 +8846,7 @@
8583
8846
  designDisabledPeople: (item) => Boolean(item.designDisabledPeople),
8584
8847
  };
8585
8848
  const AtmsMap = JSX(({ descriptionData, className }) => {
8586
- const [currentLocation] = useLocation();
8849
+ const currentLocation = useLocation();
8587
8850
  const regionCode = currentLocation?.code ?? '000';
8588
8851
  const { data: officesData, isLoad } = useAtms(regionCode);
8589
8852
  return (jsx(OfficesAtmsMapLayout, { className: className, filterItems: filterItems, data: officesData, isLoad: isLoad, initFilterState: INITIAL_FILTRATION_STATE, renderCard: renderAtmCard, getBalloon: getAtmPoint, title: `Банкоматы филиала ${currentLocation?.name}`, descriptionData: descriptionData }));
@@ -8636,7 +8899,7 @@
8636
8899
  };
8637
8900
 
8638
8901
  const OfficesMap = JSX(({ className }) => {
8639
- const [currentLocation] = useLocation();
8902
+ const currentLocation = useLocation();
8640
8903
  const regionCode = currentLocation?.code ?? '000';
8641
8904
  const { data, isLoad } = useOffices(regionCode);
8642
8905
  return (jsx(OfficesAtmsMapLayout, { className: className, data: data?.branches, isLoad: isLoad, remoteWorkplaces: data?.remoteWorkplaces, renderCard: renderOfficeCard, renderRemoteWorkplaceCard: renderRemoteWorkplaceCard, getBalloon: getOfficePoint, getBalloonRemoteWorkplaces: getRemoteWorkplacePoint, title: `Офисы филиала ${currentLocation?.name}` }));
@@ -8885,6 +9148,9 @@
8885
9148
  pop();
8886
9149
  }, [dialogs, onClose]);
8887
9150
  useEffect(() => defaultEventBus.subscribe('dialog', (action) => {
9151
+ if (!action) {
9152
+ return;
9153
+ }
8888
9154
  switch (action.type) {
8889
9155
  case 'open':
8890
9156
  push(action);
@@ -8993,27 +9259,33 @@
8993
9259
  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" })] }));
8994
9260
  });
8995
9261
 
8996
- const SEARCH_TERM_MIN_LENGTH = 3;
8997
- const LocationDialog = JSX(({ foreignOffices, branches }) => {
8998
- const [currentLocation, selectCurrentLocation] = useLocation(branches?.default);
9262
+ const SelectedLocation = JSX(({ defaultLocation }) => {
9263
+ const currentLocation = useLocation(defaultLocation);
8999
9264
  const link = useLink();
9000
9265
  const { href } = link({ href: `/branches/${currentLocation.slug}` });
9266
+ 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;
9267
+ });
9268
+
9269
+ const SEARCH_TERM_MIN_LENGTH = 3;
9270
+ const LocationDialog = JSX(({ foreignOffices, branches }) => {
9271
+ const locationStore = useDefaultLocation(branches?.default);
9001
9272
  const [query, setQuery] = useState('');
9002
- const regions = cleanUpRegions(useRegions()).sort((a, b) => a.name.localeCompare(b.name));
9003
- const regionsGroupByLetter = groupBy(regions, regionFirstLetter);
9273
+ const rawRegions = useRegions();
9274
+ const regions = useMemo(() => cleanUpRegions(rawRegions).sort((a, b) => a.name.localeCompare(b.name)), [rawRegions]);
9275
+ const regionsGroupByLetter = useMemo(() => groupBy(regions, regionFirstLetter), [regions]);
9004
9276
  const { close } = useDialogManager();
9005
- const handleChangeLocation = useCallback((region) => {
9006
- selectCurrentLocation(region);
9277
+ const handleChangeLocation = useCallback((_) => {
9278
+ locationStore.location = _;
9007
9279
  close();
9008
- }, []);
9009
- 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
9280
+ }, [locationStore]);
9281
+ 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
9010
9282
  .filter(({ name }) => name && jaroWinklerDistance(name.toLowerCase())(query.toLowerCase()) >= 0.8)
9011
9283
  .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)] }));
9012
9284
  });
9013
- const regionFirstLetter = (region) => region.name?.charAt(0) || '';
9285
+ const regionFirstLetter = (region) => region.name?.charAt(0) ?? '';
9014
9286
  const cleanUpRegions = (regions) => regions.map((region) => ({
9015
9287
  ...region,
9016
- name: region.name?.replace(/республика|область|край'/gi, '').trim() || '',
9288
+ name: region.name?.replace(/республика|область|край'/gi, '').trim() ?? '',
9017
9289
  }));
9018
9290
 
9019
9291
  const useLocationDialog = (props) => {
@@ -9026,7 +9298,7 @@
9026
9298
 
9027
9299
  const BurgerMenuDialog = JSX(({ menuRef, menuItem, locationDialogProps, closeAll }) => {
9028
9300
  const locationDialog = useLocationDialog(locationDialogProps || {});
9029
- const [{ name: location }] = useLocation();
9301
+ const { name: location } = useLocation();
9030
9302
  const menuDimensions = menuRef?.current?.getBoundingClientRect();
9031
9303
  const basePath = getBasePath(env.SITE_URL);
9032
9304
  const handleIframeLoad = () => {
@@ -9589,6 +9861,9 @@
9589
9861
  setPopup(null);
9590
9862
  }, []);
9591
9863
  useEffect(() => defaultEventBus.subscribe('popup', (action) => {
9864
+ if (!action) {
9865
+ return;
9866
+ }
9592
9867
  switch (action.type) {
9593
9868
  case 'open':
9594
9869
  case 'update':
@@ -9622,6 +9897,7 @@
9622
9897
  const { slots, blocks, fallback, ...pageContent } = data;
9623
9898
  const resolvedPageContent = useJSONRef(pageContent, fallback);
9624
9899
  useClickHandler();
9900
+ useDefaultLocation();
9625
9901
  const options = {
9626
9902
  key: '',
9627
9903
  page: { slots, blocks, fallback, ...resolvedPageContent },
@@ -9643,7 +9919,7 @@
9643
9919
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
9644
9920
  });
9645
9921
 
9646
- const packageVersion = "0.14.674";
9922
+ const packageVersion = "0.14.676";
9647
9923
 
9648
9924
  exports.Blocks = Blocks;
9649
9925
  exports.ContentPage = ContentPage;
@@ -9654,6 +9930,7 @@
9654
9930
  exports.setup = setup;
9655
9931
  exports.setupHooks = setupHooks;
9656
9932
  exports.url = url;
9933
+ exports.useNavigator = useNavigator;
9657
9934
  exports.useRouter = useRouter;
9658
9935
 
9659
9936
  Object.defineProperty(exports, '__esModule', { value: true });