@ionic/angular 7.4.4 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/README.md +20 -0
  2. package/app-initialize.d.ts +1 -1
  3. package/common/directives/control-value-accessors/index.d.ts +1 -0
  4. package/{directives → common/directives}/control-value-accessors/value-accessor.d.ts +2 -2
  5. package/common/directives/navigation/back-button.d.ts +26 -0
  6. package/common/directives/navigation/nav.d.ts +13 -0
  7. package/common/directives/navigation/router-link-delegate.d.ts +50 -0
  8. package/common/directives/navigation/router-outlet.d.ts +103 -0
  9. package/{directives → common/directives}/navigation/stack-utils.d.ts +1 -1
  10. package/common/directives/navigation/tabs.d.ts +74 -0
  11. package/common/index.d.ts +28 -0
  12. package/common/overlays/modal.d.ts +50 -0
  13. package/common/overlays/popover.d.ts +46 -0
  14. package/{providers → common/providers}/action-sheet-controller.d.ts +2 -2
  15. package/{providers → common/providers}/alert-controller.d.ts +2 -2
  16. package/{providers → common/providers}/angular-delegate.d.ts +1 -1
  17. package/{providers → common/providers}/animation-controller.d.ts +1 -1
  18. package/{providers → common/providers}/config.d.ts +1 -1
  19. package/{providers → common/providers}/gesture-controller.d.ts +1 -1
  20. package/{providers → common/providers}/loading-controller.d.ts +2 -2
  21. package/{providers → common/providers}/modal-controller.d.ts +2 -2
  22. package/{providers → common/providers}/nav-controller.d.ts +2 -2
  23. package/{providers → common/providers}/picker-controller.d.ts +2 -2
  24. package/{providers → common/providers}/platform.d.ts +2 -2
  25. package/{providers → common/providers}/popover-controller.d.ts +2 -2
  26. package/{providers → common/providers}/toast-controller.d.ts +2 -2
  27. package/{types → common/types}/interfaces.d.ts +0 -4
  28. package/common/utils/proxy.d.ts +8 -0
  29. package/css/core.css +100 -0
  30. package/css/core.css.map +1 -1
  31. package/css/display.css +33 -0
  32. package/css/display.css.map +1 -1
  33. package/css/float-elements.css +33 -0
  34. package/css/float-elements.css.map +1 -1
  35. package/css/global.bundle.css +84 -6
  36. package/css/global.bundle.css.map +1 -1
  37. package/css/ionic-swiper.css +33 -0
  38. package/css/ionic-swiper.css.map +1 -1
  39. package/css/ionic.bundle.css +1 -1
  40. package/css/ionic.bundle.css.map +1 -1
  41. package/css/padding.css +33 -0
  42. package/css/padding.css.map +1 -1
  43. package/css/structure.css +33 -0
  44. package/css/structure.css.map +1 -1
  45. package/css/text-alignment.css +33 -0
  46. package/css/text-alignment.css.map +1 -1
  47. package/css/text-transformation.css +33 -0
  48. package/css/text-transformation.css.map +1 -1
  49. package/css/typography.css +51 -6
  50. package/css/typography.css.map +1 -1
  51. package/css/utils.bundle.css +165 -0
  52. package/css/utils.bundle.css.map +1 -1
  53. package/directives/control-value-accessors/boolean-value-accessor.d.ts +1 -1
  54. package/directives/control-value-accessors/numeric-value-accessor.d.ts +1 -1
  55. package/directives/control-value-accessors/radio-value-accessor.d.ts +1 -1
  56. package/directives/control-value-accessors/select-value-accessor.d.ts +1 -1
  57. package/directives/control-value-accessors/text-value-accessor.d.ts +1 -1
  58. package/directives/navigation/ion-back-button.d.ts +6 -16
  59. package/directives/navigation/ion-nav.d.ts +8 -0
  60. package/directives/navigation/ion-router-outlet.d.ts +4 -122
  61. package/directives/navigation/ion-tabs.d.ts +4 -64
  62. package/directives/navigation/router-link-delegate.d.ts +7 -41
  63. package/directives/overlays/modal.d.ts +3 -47
  64. package/directives/overlays/popover.d.ts +3 -43
  65. package/directives/proxies-list.d.ts +1 -1
  66. package/directives/proxies.d.ts +1 -27
  67. package/esm2020/app-initialize.mjs +2 -2
  68. package/esm2020/common/directives/control-value-accessors/index.mjs +2 -0
  69. package/esm2020/common/directives/control-value-accessors/value-accessor.mjs +141 -0
  70. package/esm2020/common/directives/navigation/back-button.mjs +59 -0
  71. package/esm2020/common/directives/navigation/nav-params.mjs +45 -0
  72. package/esm2020/common/directives/navigation/nav.mjs +47 -0
  73. package/esm2020/common/directives/navigation/router-link-delegate.mjs +111 -0
  74. package/esm2020/common/directives/navigation/router-outlet.mjs +461 -0
  75. package/esm2020/common/directives/navigation/stack-controller.mjs +275 -0
  76. package/esm2020/common/directives/navigation/stack-utils.mjs +73 -0
  77. package/esm2020/common/directives/navigation/tabs.mjs +172 -0
  78. package/esm2020/common/index.mjs +28 -0
  79. package/esm2020/common/ionic-angular-common.mjs +5 -0
  80. package/esm2020/common/overlays/modal.mjs +87 -0
  81. package/esm2020/common/overlays/popover.mjs +79 -0
  82. package/esm2020/common/providers/action-sheet-controller.mjs +18 -0
  83. package/esm2020/common/providers/alert-controller.mjs +18 -0
  84. package/esm2020/common/providers/angular-delegate.mjs +152 -0
  85. package/esm2020/common/providers/animation-controller.mjs +37 -0
  86. package/esm2020/common/providers/config.mjs +44 -0
  87. package/esm2020/common/providers/dom-controller.mjs +44 -0
  88. package/esm2020/common/providers/gesture-controller.mjs +31 -0
  89. package/esm2020/common/providers/loading-controller.mjs +18 -0
  90. package/esm2020/common/providers/menu-controller.mjs +100 -0
  91. package/esm2020/common/providers/modal-controller.mjs +25 -0
  92. package/esm2020/common/providers/nav-controller.mjs +221 -0
  93. package/esm2020/common/providers/picker-controller.mjs +18 -0
  94. package/esm2020/common/providers/platform.mjs +246 -0
  95. package/esm2020/common/providers/popover-controller.mjs +25 -0
  96. package/esm2020/common/providers/toast-controller.mjs +18 -0
  97. package/esm2020/common/types/interfaces.mjs +2 -0
  98. package/esm2020/common/utils/overlay.mjs +25 -0
  99. package/esm2020/common/utils/proxy.mjs +47 -0
  100. package/esm2020/common/utils/routing.mjs +55 -0
  101. package/esm2020/common/utils/util.mjs +10 -0
  102. package/esm2020/directives/control-value-accessors/boolean-value-accessor.mjs +4 -4
  103. package/esm2020/directives/control-value-accessors/numeric-value-accessor.mjs +2 -2
  104. package/esm2020/directives/control-value-accessors/radio-value-accessor.mjs +6 -3
  105. package/esm2020/directives/control-value-accessors/select-value-accessor.mjs +2 -2
  106. package/esm2020/directives/control-value-accessors/text-value-accessor.mjs +2 -2
  107. package/esm2020/directives/navigation/ion-back-button.mjs +15 -36
  108. package/esm2020/directives/navigation/ion-nav.mjs +21 -0
  109. package/esm2020/directives/navigation/ion-router-outlet.mjs +6 -435
  110. package/esm2020/directives/navigation/ion-tabs.mjs +9 -166
  111. package/esm2020/directives/navigation/router-link-delegate.mjs +11 -92
  112. package/esm2020/directives/overlays/modal.mjs +8 -88
  113. package/esm2020/directives/overlays/popover.mjs +8 -87
  114. package/esm2020/directives/proxies-list.mjs +1 -3
  115. package/esm2020/directives/proxies.mjs +4 -56
  116. package/esm2020/index.mjs +5 -22
  117. package/esm2020/ionic-module.mjs +14 -32
  118. package/esm2020/standalone/directives/angular-component-lib/utils.mjs +51 -0
  119. package/esm2020/standalone/directives/checkbox.mjs +73 -0
  120. package/esm2020/standalone/directives/datetime.mjs +90 -0
  121. package/esm2020/standalone/directives/icon.mjs +33 -0
  122. package/esm2020/standalone/directives/index.mjs +13 -0
  123. package/esm2020/standalone/directives/input.mjs +112 -0
  124. package/esm2020/standalone/directives/proxies.mjs +2268 -0
  125. package/esm2020/standalone/directives/radio-group.mjs +58 -0
  126. package/esm2020/standalone/directives/radio.mjs +62 -0
  127. package/esm2020/standalone/directives/range.mjs +77 -0
  128. package/esm2020/standalone/directives/searchbar.mjs +80 -0
  129. package/esm2020/standalone/directives/segment.mjs +58 -0
  130. package/esm2020/standalone/directives/select.mjs +81 -0
  131. package/esm2020/standalone/directives/textarea.mjs +90 -0
  132. package/esm2020/standalone/directives/toggle.mjs +73 -0
  133. package/esm2020/standalone/index.mjs +15 -0
  134. package/esm2020/standalone/ionic-angular-standalone.mjs +5 -0
  135. package/esm2020/standalone/navigation/back-button.mjs +32 -0
  136. package/esm2020/standalone/navigation/nav.mjs +28 -0
  137. package/esm2020/standalone/navigation/router-link-delegate.mjs +28 -0
  138. package/esm2020/standalone/navigation/router-outlet.mjs +23 -0
  139. package/esm2020/standalone/navigation/tabs.mjs +46 -0
  140. package/esm2020/standalone/overlays/modal.mjs +32 -0
  141. package/esm2020/standalone/overlays/popover.mjs +28 -0
  142. package/esm2020/standalone/providers/ionic-angular.mjs +41 -0
  143. package/fesm2015/ionic-angular-common.mjs +2620 -0
  144. package/fesm2015/ionic-angular-common.mjs.map +1 -0
  145. package/fesm2015/ionic-angular-standalone.mjs +3286 -0
  146. package/fesm2015/ionic-angular-standalone.mjs.map +1 -0
  147. package/fesm2015/ionic-angular.mjs +143 -2637
  148. package/fesm2015/ionic-angular.mjs.map +1 -1
  149. package/fesm2020/ionic-angular-common.mjs +2609 -0
  150. package/fesm2020/ionic-angular-common.mjs.map +1 -0
  151. package/fesm2020/ionic-angular-standalone.mjs +3284 -0
  152. package/fesm2020/ionic-angular-standalone.mjs.map +1 -0
  153. package/fesm2020/ionic-angular.mjs +142 -2627
  154. package/fesm2020/ionic-angular.mjs.map +1 -1
  155. package/index.d.ts +4 -20
  156. package/ionic-module.d.ts +2 -2
  157. package/package.json +18 -2
  158. package/standalone/directives/angular-component-lib/utils.d.ts +9 -0
  159. package/standalone/directives/checkbox.d.ts +30 -0
  160. package/standalone/directives/datetime.d.ts +30 -0
  161. package/standalone/directives/icon.d.ts +9 -0
  162. package/standalone/directives/index.d.ts +12 -0
  163. package/standalone/directives/input.d.ts +47 -0
  164. package/standalone/directives/proxies.d.ts +903 -0
  165. package/standalone/directives/radio-group.d.ts +18 -0
  166. package/standalone/directives/radio.d.ts +22 -0
  167. package/standalone/directives/range.d.ts +47 -0
  168. package/standalone/directives/searchbar.d.ts +45 -0
  169. package/standalone/directives/segment.d.ts +19 -0
  170. package/standalone/directives/select.d.ts +34 -0
  171. package/standalone/directives/textarea.d.ts +37 -0
  172. package/standalone/directives/toggle.d.ts +28 -0
  173. package/standalone/index.d.ts +12 -0
  174. package/standalone/navigation/back-button.d.ts +9 -0
  175. package/standalone/navigation/nav.d.ts +8 -0
  176. package/standalone/navigation/router-link-delegate.d.ts +10 -0
  177. package/standalone/navigation/router-outlet.d.ts +6 -0
  178. package/standalone/navigation/tabs.d.ts +12 -0
  179. package/standalone/overlays/modal.d.ts +6 -0
  180. package/standalone/overlays/popover.d.ts +6 -0
  181. package/standalone/providers/ionic-angular.d.ts +3 -0
  182. package/test/README.md +8 -0
  183. package/directives/navigation/nav-delegate.d.ts +0 -9
  184. package/esm2020/directives/control-value-accessors/value-accessor.mjs +0 -141
  185. package/esm2020/directives/navigation/nav-delegate.mjs +0 -42
  186. package/esm2020/directives/navigation/nav-params.mjs +0 -45
  187. package/esm2020/directives/navigation/stack-controller.mjs +0 -275
  188. package/esm2020/directives/navigation/stack-utils.mjs +0 -73
  189. package/esm2020/ionic-core.mjs +0 -6
  190. package/esm2020/providers/action-sheet-controller.mjs +0 -18
  191. package/esm2020/providers/alert-controller.mjs +0 -18
  192. package/esm2020/providers/angular-delegate.mjs +0 -152
  193. package/esm2020/providers/animation-controller.mjs +0 -37
  194. package/esm2020/providers/config.mjs +0 -44
  195. package/esm2020/providers/dom-controller.mjs +0 -44
  196. package/esm2020/providers/gesture-controller.mjs +0 -31
  197. package/esm2020/providers/loading-controller.mjs +0 -18
  198. package/esm2020/providers/menu-controller.mjs +0 -100
  199. package/esm2020/providers/modal-controller.mjs +0 -25
  200. package/esm2020/providers/nav-controller.mjs +0 -221
  201. package/esm2020/providers/picker-controller.mjs +0 -18
  202. package/esm2020/providers/platform.mjs +0 -246
  203. package/esm2020/providers/popover-controller.mjs +0 -25
  204. package/esm2020/providers/toast-controller.mjs +0 -18
  205. package/esm2020/types/interfaces.mjs +0 -2
  206. package/esm2020/util/ionic-router-reuse-strategy.mjs +0 -55
  207. package/esm2020/util/overlay.mjs +0 -25
  208. package/esm2020/util/util.mjs +0 -10
  209. package/ionic-core.d.ts +0 -2
  210. /package/{directives → common/directives}/navigation/nav-params.d.ts +0 -0
  211. /package/{directives → common/directives}/navigation/stack-controller.d.ts +0 -0
  212. /package/{providers → common/providers}/dom-controller.d.ts +0 -0
  213. /package/{providers → common/providers}/menu-controller.d.ts +0 -0
  214. /package/{util → common/utils}/overlay.d.ts +0 -0
  215. /package/{util/ionic-router-reuse-strategy.d.ts → common/utils/routing.d.ts} +0 -0
  216. /package/{util → common/utils}/util.d.ts +0 -0
@@ -0,0 +1,2609 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, inject, NgZone, ApplicationRef, Injector, createComponent, InjectionToken, EnvironmentInjector, Inject, Optional, TemplateRef, Directive, ContentChild, EventEmitter, ViewContainerRef, Attribute, SkipSelf, Input, Output, reflectComponentType, HostListener, ElementRef, ViewChild } from '@angular/core';
3
+ import { actionSheetController, alertController, loadingController, menuController, LIFECYCLE_WILL_ENTER, LIFECYCLE_DID_ENTER, LIFECYCLE_WILL_LEAVE, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_UNLOAD, modalController, pickerController, popoverController, toastController, createAnimation, getTimeGivenProgression, createGesture, isPlatform, getPlatforms, componentOnReady } from '@ionic/core/components';
4
+ import * as i3 from '@angular/router';
5
+ import { NavigationStart, PRIMARY_OUTLET, ChildrenOutletContexts, ActivatedRoute, Router } from '@angular/router';
6
+ import * as i1 from '@angular/common';
7
+ import { DOCUMENT } from '@angular/common';
8
+ import { Subject, fromEvent, BehaviorSubject, combineLatest, of } from 'rxjs';
9
+ import { __decorate } from 'tslib';
10
+ import { filter, switchMap, distinctUntilChanged } from 'rxjs/operators';
11
+ import { NgControl } from '@angular/forms';
12
+
13
+ // TODO(FW-2827): types
14
+ class OverlayBaseController {
15
+ constructor(ctrl) {
16
+ this.ctrl = ctrl;
17
+ }
18
+ /**
19
+ * Creates a new overlay
20
+ */
21
+ create(opts) {
22
+ return this.ctrl.create((opts || {}));
23
+ }
24
+ /**
25
+ * When `id` is not provided, it dismisses the top overlay.
26
+ */
27
+ dismiss(data, role, id) {
28
+ return this.ctrl.dismiss(data, role, id);
29
+ }
30
+ /**
31
+ * Returns the top overlay.
32
+ */
33
+ getTop() {
34
+ return this.ctrl.getTop();
35
+ }
36
+ }
37
+
38
+ class ActionSheetController extends OverlayBaseController {
39
+ constructor() {
40
+ super(actionSheetController);
41
+ }
42
+ }
43
+ /** @nocollapse */ ActionSheetController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ActionSheetController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
44
+ /** @nocollapse */ ActionSheetController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ActionSheetController, providedIn: 'root' });
45
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ActionSheetController, decorators: [{
46
+ type: Injectable,
47
+ args: [{
48
+ providedIn: 'root',
49
+ }]
50
+ }], ctorParameters: function () { return []; } });
51
+
52
+ class AlertController extends OverlayBaseController {
53
+ constructor() {
54
+ super(alertController);
55
+ }
56
+ }
57
+ /** @nocollapse */ AlertController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AlertController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
58
+ /** @nocollapse */ AlertController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AlertController, providedIn: 'root' });
59
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AlertController, decorators: [{
60
+ type: Injectable,
61
+ args: [{
62
+ providedIn: 'root',
63
+ }]
64
+ }], ctorParameters: function () { return []; } });
65
+
66
+ class LoadingController extends OverlayBaseController {
67
+ constructor() {
68
+ super(loadingController);
69
+ }
70
+ }
71
+ /** @nocollapse */ LoadingController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: LoadingController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
72
+ /** @nocollapse */ LoadingController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: LoadingController, providedIn: 'root' });
73
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: LoadingController, decorators: [{
74
+ type: Injectable,
75
+ args: [{
76
+ providedIn: 'root',
77
+ }]
78
+ }], ctorParameters: function () { return []; } });
79
+
80
+ class MenuController {
81
+ /**
82
+ * Programmatically open the Menu.
83
+ * @param [menuId] Optionally get the menu by its id, or side.
84
+ * @return returns a promise when the menu is fully opened
85
+ */
86
+ open(menuId) {
87
+ return menuController.open(menuId);
88
+ }
89
+ /**
90
+ * Programmatically close the Menu. If no `menuId` is given as the first
91
+ * argument then it'll close any menu which is open. If a `menuId`
92
+ * is given then it'll close that exact menu.
93
+ * @param [menuId] Optionally get the menu by its id, or side.
94
+ * @return returns a promise when the menu is fully closed
95
+ */
96
+ close(menuId) {
97
+ return menuController.close(menuId);
98
+ }
99
+ /**
100
+ * Toggle the menu. If it's closed, it will open, and if opened, it
101
+ * will close.
102
+ * @param [menuId] Optionally get the menu by its id, or side.
103
+ * @return returns a promise when the menu has been toggled
104
+ */
105
+ toggle(menuId) {
106
+ return menuController.toggle(menuId);
107
+ }
108
+ /**
109
+ * Used to enable or disable a menu. For example, there could be multiple
110
+ * left menus, but only one of them should be able to be opened at the same
111
+ * time. If there are multiple menus on the same side, then enabling one menu
112
+ * will also automatically disable all the others that are on the same side.
113
+ * @param [menuId] Optionally get the menu by its id, or side.
114
+ * @return Returns the instance of the menu, which is useful for chaining.
115
+ */
116
+ enable(shouldEnable, menuId) {
117
+ return menuController.enable(shouldEnable, menuId);
118
+ }
119
+ /**
120
+ * Used to enable or disable the ability to swipe open the menu.
121
+ * @param shouldEnable True if it should be swipe-able, false if not.
122
+ * @param [menuId] Optionally get the menu by its id, or side.
123
+ * @return Returns the instance of the menu, which is useful for chaining.
124
+ */
125
+ swipeGesture(shouldEnable, menuId) {
126
+ return menuController.swipeGesture(shouldEnable, menuId);
127
+ }
128
+ /**
129
+ * @param [menuId] Optionally get the menu by its id, or side.
130
+ * @return Returns true if the specified menu is currently open, otherwise false.
131
+ * If the menuId is not specified, it returns true if ANY menu is currenly open.
132
+ */
133
+ isOpen(menuId) {
134
+ return menuController.isOpen(menuId);
135
+ }
136
+ /**
137
+ * @param [menuId] Optionally get the menu by its id, or side.
138
+ * @return Returns true if the menu is currently enabled, otherwise false.
139
+ */
140
+ isEnabled(menuId) {
141
+ return menuController.isEnabled(menuId);
142
+ }
143
+ /**
144
+ * Used to get a menu instance. If a `menuId` is not provided then it'll
145
+ * return the first menu found. If a `menuId` is `left` or `right`, then
146
+ * it'll return the enabled menu on that side. Otherwise, if a `menuId` is
147
+ * provided, then it'll try to find the menu using the menu's `id`
148
+ * property. If a menu is not found then it'll return `null`.
149
+ * @param [menuId] Optionally get the menu by its id, or side.
150
+ * @return Returns the instance of the menu if found, otherwise `null`.
151
+ */
152
+ get(menuId) {
153
+ return menuController.get(menuId);
154
+ }
155
+ /**
156
+ * @return Returns the instance of the menu already opened, otherwise `null`.
157
+ */
158
+ getOpen() {
159
+ return menuController.getOpen();
160
+ }
161
+ /**
162
+ * @return Returns an array of all menu instances.
163
+ */
164
+ getMenus() {
165
+ return menuController.getMenus();
166
+ }
167
+ }
168
+ /** @nocollapse */ MenuController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MenuController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
169
+ /** @nocollapse */ MenuController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MenuController, providedIn: 'root' });
170
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MenuController, decorators: [{
171
+ type: Injectable,
172
+ args: [{
173
+ providedIn: 'root',
174
+ }]
175
+ }] });
176
+
177
+ /**
178
+ * @description
179
+ * NavParams are an object that exists on a page and can contain data for that particular view.
180
+ * Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible
181
+ * option with a simple `get` method.
182
+ *
183
+ * @usage
184
+ * ```ts
185
+ * import { NavParams } from '@ionic/angular';
186
+ *
187
+ * export class MyClass{
188
+ *
189
+ * constructor(navParams: NavParams){
190
+ * // userParams is an object we have in our nav-parameters
191
+ * navParams.get('userParams');
192
+ * }
193
+ *
194
+ * }
195
+ * ```
196
+ */
197
+ class NavParams {
198
+ constructor(data = {}) {
199
+ this.data = data;
200
+ }
201
+ /**
202
+ * Get the value of a nav-parameter for the current view
203
+ *
204
+ * ```ts
205
+ * import { NavParams } from 'ionic-angular';
206
+ *
207
+ * export class MyClass{
208
+ * constructor(public navParams: NavParams){
209
+ * // userParams is an object we have in our nav-parameters
210
+ * this.navParams.get('userParams');
211
+ * }
212
+ * }
213
+ * ```
214
+ *
215
+ * @param param Which param you want to look up
216
+ */
217
+ get(param) {
218
+ return this.data[param];
219
+ }
220
+ }
221
+
222
+ // TODO(FW-2827): types
223
+ class AngularDelegate {
224
+ constructor() {
225
+ this.zone = inject(NgZone);
226
+ this.applicationRef = inject(ApplicationRef);
227
+ }
228
+ create(environmentInjector, injector, elementReferenceKey) {
229
+ return new AngularFrameworkDelegate(environmentInjector, injector, this.applicationRef, this.zone, elementReferenceKey);
230
+ }
231
+ }
232
+ /** @nocollapse */ AngularDelegate.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
233
+ /** @nocollapse */ AngularDelegate.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate });
234
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, decorators: [{
235
+ type: Injectable
236
+ }] });
237
+ class AngularFrameworkDelegate {
238
+ constructor(environmentInjector, injector, applicationRef, zone, elementReferenceKey) {
239
+ this.environmentInjector = environmentInjector;
240
+ this.injector = injector;
241
+ this.applicationRef = applicationRef;
242
+ this.zone = zone;
243
+ this.elementReferenceKey = elementReferenceKey;
244
+ this.elRefMap = new WeakMap();
245
+ this.elEventsMap = new WeakMap();
246
+ }
247
+ attachViewToDom(container, component, params, cssClasses) {
248
+ return this.zone.run(() => {
249
+ return new Promise((resolve) => {
250
+ const componentProps = {
251
+ ...params,
252
+ };
253
+ /**
254
+ * Ionic Angular passes a reference to a modal
255
+ * or popover that can be accessed using a
256
+ * variable in the overlay component. If
257
+ * elementReferenceKey is defined, then we should
258
+ * pass a reference to the component using
259
+ * elementReferenceKey as the key.
260
+ */
261
+ if (this.elementReferenceKey !== undefined) {
262
+ componentProps[this.elementReferenceKey] = container;
263
+ }
264
+ const el = attachView(this.zone, this.environmentInjector, this.injector, this.applicationRef, this.elRefMap, this.elEventsMap, container, component, componentProps, cssClasses, this.elementReferenceKey);
265
+ resolve(el);
266
+ });
267
+ });
268
+ }
269
+ removeViewFromDom(_container, component) {
270
+ return this.zone.run(() => {
271
+ return new Promise((resolve) => {
272
+ const componentRef = this.elRefMap.get(component);
273
+ if (componentRef) {
274
+ componentRef.destroy();
275
+ this.elRefMap.delete(component);
276
+ const unbindEvents = this.elEventsMap.get(component);
277
+ if (unbindEvents) {
278
+ unbindEvents();
279
+ this.elEventsMap.delete(component);
280
+ }
281
+ }
282
+ resolve();
283
+ });
284
+ });
285
+ }
286
+ }
287
+ const attachView = (zone, environmentInjector, injector, applicationRef, elRefMap, elEventsMap, container, component, params, cssClasses, elementReferenceKey) => {
288
+ /**
289
+ * Wraps the injector with a custom injector that
290
+ * provides NavParams to the component.
291
+ *
292
+ * NavParams is a legacy feature from Ionic v3 that allows
293
+ * Angular developers to provide data to a component
294
+ * and access it by providing NavParams as a dependency
295
+ * in the constructor.
296
+ *
297
+ * The modern approach is to access the data directly
298
+ * from the component's class instance.
299
+ */
300
+ const childInjector = Injector.create({
301
+ providers: getProviders(params),
302
+ parent: injector,
303
+ });
304
+ const componentRef = createComponent(component, {
305
+ environmentInjector,
306
+ elementInjector: childInjector,
307
+ });
308
+ const instance = componentRef.instance;
309
+ const hostElement = componentRef.location.nativeElement;
310
+ if (params) {
311
+ /**
312
+ * For modals and popovers, a reference to the component is
313
+ * added to `params` during the call to attachViewToDom. If
314
+ * a reference using this name is already set, this means
315
+ * the app is trying to use the name as a component prop,
316
+ * which will cause collisions.
317
+ */
318
+ if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
319
+ console.error(`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${component.name}.`);
320
+ }
321
+ Object.assign(instance, params);
322
+ }
323
+ if (cssClasses) {
324
+ for (const cssClass of cssClasses) {
325
+ hostElement.classList.add(cssClass);
326
+ }
327
+ }
328
+ const unbindEvents = bindLifecycleEvents(zone, instance, hostElement);
329
+ container.appendChild(hostElement);
330
+ applicationRef.attachView(componentRef.hostView);
331
+ elRefMap.set(hostElement, componentRef);
332
+ elEventsMap.set(hostElement, unbindEvents);
333
+ return hostElement;
334
+ };
335
+ const LIFECYCLES = [
336
+ LIFECYCLE_WILL_ENTER,
337
+ LIFECYCLE_DID_ENTER,
338
+ LIFECYCLE_WILL_LEAVE,
339
+ LIFECYCLE_DID_LEAVE,
340
+ LIFECYCLE_WILL_UNLOAD,
341
+ ];
342
+ const bindLifecycleEvents = (zone, instance, element) => {
343
+ return zone.run(() => {
344
+ const unregisters = LIFECYCLES.filter((eventName) => typeof instance[eventName] === 'function').map((eventName) => {
345
+ const handler = (ev) => instance[eventName](ev.detail);
346
+ element.addEventListener(eventName, handler);
347
+ return () => element.removeEventListener(eventName, handler);
348
+ });
349
+ return () => unregisters.forEach((fn) => fn());
350
+ });
351
+ };
352
+ const NavParamsToken = new InjectionToken('NavParamsToken');
353
+ const getProviders = (params) => {
354
+ return [
355
+ {
356
+ provide: NavParamsToken,
357
+ useValue: params,
358
+ },
359
+ {
360
+ provide: NavParams,
361
+ useFactory: provideNavParamsInjectable,
362
+ deps: [NavParamsToken],
363
+ },
364
+ ];
365
+ };
366
+ const provideNavParamsInjectable = (params) => {
367
+ return new NavParams(params);
368
+ };
369
+
370
+ class ModalController extends OverlayBaseController {
371
+ constructor() {
372
+ super(modalController);
373
+ this.angularDelegate = inject(AngularDelegate);
374
+ this.injector = inject(Injector);
375
+ this.environmentInjector = inject(EnvironmentInjector);
376
+ }
377
+ create(opts) {
378
+ return super.create({
379
+ ...opts,
380
+ delegate: this.angularDelegate.create(this.environmentInjector, this.injector, 'modal'),
381
+ });
382
+ }
383
+ }
384
+ /** @nocollapse */ ModalController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
385
+ /** @nocollapse */ ModalController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController });
386
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, decorators: [{
387
+ type: Injectable
388
+ }], ctorParameters: function () { return []; } });
389
+
390
+ class PickerController extends OverlayBaseController {
391
+ constructor() {
392
+ super(pickerController);
393
+ }
394
+ }
395
+ /** @nocollapse */ PickerController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PickerController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
396
+ /** @nocollapse */ PickerController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PickerController, providedIn: 'root' });
397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PickerController, decorators: [{
398
+ type: Injectable,
399
+ args: [{
400
+ providedIn: 'root',
401
+ }]
402
+ }], ctorParameters: function () { return []; } });
403
+
404
+ class PopoverController extends OverlayBaseController {
405
+ constructor() {
406
+ super(popoverController);
407
+ this.angularDelegate = inject(AngularDelegate);
408
+ this.injector = inject(Injector);
409
+ this.environmentInjector = inject(EnvironmentInjector);
410
+ }
411
+ create(opts) {
412
+ return super.create({
413
+ ...opts,
414
+ delegate: this.angularDelegate.create(this.environmentInjector, this.injector, 'popover'),
415
+ });
416
+ }
417
+ }
418
+ /** @nocollapse */ PopoverController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PopoverController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
419
+ /** @nocollapse */ PopoverController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PopoverController });
420
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PopoverController, decorators: [{
421
+ type: Injectable
422
+ }], ctorParameters: function () { return []; } });
423
+
424
+ class ToastController extends OverlayBaseController {
425
+ constructor() {
426
+ super(toastController);
427
+ }
428
+ }
429
+ /** @nocollapse */ ToastController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ToastController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
430
+ /** @nocollapse */ ToastController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ToastController, providedIn: 'root' });
431
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ToastController, decorators: [{
432
+ type: Injectable,
433
+ args: [{
434
+ providedIn: 'root',
435
+ }]
436
+ }], ctorParameters: function () { return []; } });
437
+
438
+ class AnimationController {
439
+ /**
440
+ * Create a new animation
441
+ */
442
+ create(animationId) {
443
+ return createAnimation(animationId);
444
+ }
445
+ /**
446
+ * EXPERIMENTAL
447
+ *
448
+ * Given a progression and a cubic bezier function,
449
+ * this utility returns the time value(s) at which the
450
+ * cubic bezier reaches the given time progression.
451
+ *
452
+ * If the cubic bezier never reaches the progression
453
+ * the result will be an empty array.
454
+ *
455
+ * This is most useful for switching between easing curves
456
+ * when doing a gesture animation (i.e. going from linear easing
457
+ * during a drag, to another easing when `progressEnd` is called)
458
+ */
459
+ easingTime(p0, p1, p2, p3, progression) {
460
+ return getTimeGivenProgression(p0, p1, p2, p3, progression);
461
+ }
462
+ }
463
+ /** @nocollapse */ AnimationController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AnimationController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
464
+ /** @nocollapse */ AnimationController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AnimationController, providedIn: 'root' });
465
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AnimationController, decorators: [{
466
+ type: Injectable,
467
+ args: [{
468
+ providedIn: 'root',
469
+ }]
470
+ }] });
471
+
472
+ class GestureController {
473
+ constructor(zone) {
474
+ this.zone = zone;
475
+ }
476
+ /**
477
+ * Create a new gesture
478
+ */
479
+ create(opts, runInsideAngularZone = false) {
480
+ if (runInsideAngularZone) {
481
+ Object.getOwnPropertyNames(opts).forEach((key) => {
482
+ if (typeof opts[key] === 'function') {
483
+ const fn = opts[key];
484
+ opts[key] = (...props) => this.zone.run(() => fn(...props));
485
+ }
486
+ });
487
+ }
488
+ return createGesture(opts);
489
+ }
490
+ }
491
+ /** @nocollapse */ GestureController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GestureController, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
492
+ /** @nocollapse */ GestureController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GestureController, providedIn: 'root' });
493
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GestureController, decorators: [{
494
+ type: Injectable,
495
+ args: [{
496
+ providedIn: 'root',
497
+ }]
498
+ }], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
499
+
500
+ class DomController {
501
+ /**
502
+ * Schedules a task to run during the READ phase of the next frame.
503
+ * This task should only read the DOM, but never modify it.
504
+ */
505
+ read(cb) {
506
+ getQueue().read(cb);
507
+ }
508
+ /**
509
+ * Schedules a task to run during the WRITE phase of the next frame.
510
+ * This task should write the DOM, but never READ it.
511
+ */
512
+ write(cb) {
513
+ getQueue().write(cb);
514
+ }
515
+ }
516
+ /** @nocollapse */ DomController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DomController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
517
+ /** @nocollapse */ DomController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DomController, providedIn: 'root' });
518
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DomController, decorators: [{
519
+ type: Injectable,
520
+ args: [{
521
+ providedIn: 'root',
522
+ }]
523
+ }] });
524
+ const getQueue = () => {
525
+ const win = typeof window !== 'undefined' ? window : null;
526
+ if (win != null) {
527
+ const Ionic = win.Ionic;
528
+ if (Ionic?.queue) {
529
+ return Ionic.queue;
530
+ }
531
+ return {
532
+ read: (cb) => win.requestAnimationFrame(cb),
533
+ write: (cb) => win.requestAnimationFrame(cb),
534
+ };
535
+ }
536
+ return {
537
+ read: (cb) => cb(),
538
+ write: (cb) => cb(),
539
+ };
540
+ };
541
+
542
+ class Platform {
543
+ constructor(doc, zone) {
544
+ this.doc = doc;
545
+ /**
546
+ * @hidden
547
+ */
548
+ this.backButton = new Subject();
549
+ /**
550
+ * The keyboardDidShow event emits when the
551
+ * on-screen keyboard is presented.
552
+ */
553
+ this.keyboardDidShow = new Subject();
554
+ /**
555
+ * The keyboardDidHide event emits when the
556
+ * on-screen keyboard is hidden.
557
+ */
558
+ this.keyboardDidHide = new Subject();
559
+ /**
560
+ * The pause event emits when the native platform puts the application
561
+ * into the background, typically when the user switches to a different
562
+ * application. This event would emit when a Cordova app is put into
563
+ * the background, however, it would not fire on a standard web browser.
564
+ */
565
+ this.pause = new Subject();
566
+ /**
567
+ * The resume event emits when the native platform pulls the application
568
+ * out from the background. This event would emit when a Cordova app comes
569
+ * out from the background, however, it would not fire on a standard web browser.
570
+ */
571
+ this.resume = new Subject();
572
+ /**
573
+ * The resize event emits when the browser window has changed dimensions. This
574
+ * could be from a browser window being physically resized, or from a device
575
+ * changing orientation.
576
+ */
577
+ this.resize = new Subject();
578
+ zone.run(() => {
579
+ this.win = doc.defaultView;
580
+ this.backButton.subscribeWithPriority = function (priority, callback) {
581
+ return this.subscribe((ev) => {
582
+ return ev.register(priority, (processNextHandler) => zone.run(() => callback(processNextHandler)));
583
+ });
584
+ };
585
+ proxyEvent(this.pause, doc, 'pause');
586
+ proxyEvent(this.resume, doc, 'resume');
587
+ proxyEvent(this.backButton, doc, 'ionBackButton');
588
+ proxyEvent(this.resize, this.win, 'resize');
589
+ proxyEvent(this.keyboardDidShow, this.win, 'ionKeyboardDidShow');
590
+ proxyEvent(this.keyboardDidHide, this.win, 'ionKeyboardDidHide');
591
+ let readyResolve;
592
+ this._readyPromise = new Promise((res) => {
593
+ readyResolve = res;
594
+ });
595
+ if (this.win?.['cordova']) {
596
+ doc.addEventListener('deviceready', () => {
597
+ readyResolve('cordova');
598
+ }, { once: true });
599
+ }
600
+ else {
601
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
602
+ readyResolve('dom');
603
+ }
604
+ });
605
+ }
606
+ /**
607
+ * @returns returns true/false based on platform.
608
+ * @description
609
+ * Depending on the platform the user is on, `is(platformName)` will
610
+ * return `true` or `false`. Note that the same app can return `true`
611
+ * for more than one platform name. For example, an app running from
612
+ * an iPad would return `true` for the platform names: `mobile`,
613
+ * `ios`, `ipad`, and `tablet`. Additionally, if the app was running
614
+ * from Cordova then `cordova` would be true, and if it was running
615
+ * from a web browser on the iPad then `mobileweb` would be `true`.
616
+ *
617
+ * ```
618
+ * import { Platform } from 'ionic-angular';
619
+ *
620
+ * @Component({...})
621
+ * export MyPage {
622
+ * constructor(public platform: Platform) {
623
+ * if (this.platform.is('ios')) {
624
+ * // This will only print when on iOS
625
+ * console.log('I am an iOS device!');
626
+ * }
627
+ * }
628
+ * }
629
+ * ```
630
+ *
631
+ * | Platform Name | Description |
632
+ * |-----------------|------------------------------------|
633
+ * | android | on a device running Android. |
634
+ * | capacitor | on a device running Capacitor. |
635
+ * | cordova | on a device running Cordova. |
636
+ * | ios | on a device running iOS. |
637
+ * | ipad | on an iPad device. |
638
+ * | iphone | on an iPhone device. |
639
+ * | phablet | on a phablet device. |
640
+ * | tablet | on a tablet device. |
641
+ * | electron | in Electron on a desktop device. |
642
+ * | pwa | as a PWA app. |
643
+ * | mobile | on a mobile device. |
644
+ * | mobileweb | on a mobile device in a browser. |
645
+ * | desktop | on a desktop device. |
646
+ * | hybrid | is a cordova or capacitor app. |
647
+ *
648
+ */
649
+ is(platformName) {
650
+ return isPlatform(this.win, platformName);
651
+ }
652
+ /**
653
+ * @returns the array of platforms
654
+ * @description
655
+ * Depending on what device you are on, `platforms` can return multiple values.
656
+ * Each possible value is a hierarchy of platforms. For example, on an iPhone,
657
+ * it would return `mobile`, `ios`, and `iphone`.
658
+ *
659
+ * ```
660
+ * import { Platform } from 'ionic-angular';
661
+ *
662
+ * @Component({...})
663
+ * export MyPage {
664
+ * constructor(public platform: Platform) {
665
+ * // This will print an array of the current platforms
666
+ * console.log(this.platform.platforms());
667
+ * }
668
+ * }
669
+ * ```
670
+ */
671
+ platforms() {
672
+ return getPlatforms(this.win);
673
+ }
674
+ /**
675
+ * Returns a promise when the platform is ready and native functionality
676
+ * can be called. If the app is running from within a web browser, then
677
+ * the promise will resolve when the DOM is ready. When the app is running
678
+ * from an application engine such as Cordova, then the promise will
679
+ * resolve when Cordova triggers the `deviceready` event.
680
+ *
681
+ * The resolved value is the `readySource`, which states which platform
682
+ * ready was used. For example, when Cordova is ready, the resolved ready
683
+ * source is `cordova`. The default ready source value will be `dom`. The
684
+ * `readySource` is useful if different logic should run depending on the
685
+ * platform the app is running from. For example, only Cordova can execute
686
+ * the status bar plugin, so the web should not run status bar plugin logic.
687
+ *
688
+ * ```
689
+ * import { Component } from '@angular/core';
690
+ * import { Platform } from 'ionic-angular';
691
+ *
692
+ * @Component({...})
693
+ * export MyApp {
694
+ * constructor(public platform: Platform) {
695
+ * this.platform.ready().then((readySource) => {
696
+ * console.log('Platform ready from', readySource);
697
+ * // Platform now ready, execute any required native code
698
+ * });
699
+ * }
700
+ * }
701
+ * ```
702
+ */
703
+ ready() {
704
+ return this._readyPromise;
705
+ }
706
+ /**
707
+ * Returns if this app is using right-to-left language direction or not.
708
+ * We recommend the app's `index.html` file already has the correct `dir`
709
+ * attribute value set, such as `<html dir="ltr">` or `<html dir="rtl">`.
710
+ * [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
711
+ */
712
+ get isRTL() {
713
+ return this.doc.dir === 'rtl';
714
+ }
715
+ /**
716
+ * Get the query string parameter
717
+ */
718
+ getQueryParam(key) {
719
+ return readQueryParam(this.win.location.href, key);
720
+ }
721
+ /**
722
+ * Returns `true` if the app is in landscape mode.
723
+ */
724
+ isLandscape() {
725
+ return !this.isPortrait();
726
+ }
727
+ /**
728
+ * Returns `true` if the app is in portrait mode.
729
+ */
730
+ isPortrait() {
731
+ return this.win.matchMedia?.('(orientation: portrait)').matches;
732
+ }
733
+ testUserAgent(expression) {
734
+ const nav = this.win.navigator;
735
+ return !!(nav?.userAgent && nav.userAgent.indexOf(expression) >= 0);
736
+ }
737
+ /**
738
+ * Get the current url.
739
+ */
740
+ url() {
741
+ return this.win.location.href;
742
+ }
743
+ /**
744
+ * Gets the width of the platform's viewport using `window.innerWidth`.
745
+ */
746
+ width() {
747
+ return this.win.innerWidth;
748
+ }
749
+ /**
750
+ * Gets the height of the platform's viewport using `window.innerHeight`.
751
+ */
752
+ height() {
753
+ return this.win.innerHeight;
754
+ }
755
+ }
756
+ /** @nocollapse */ Platform.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Platform, deps: [{ token: DOCUMENT }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
757
+ /** @nocollapse */ Platform.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Platform, providedIn: 'root' });
758
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Platform, decorators: [{
759
+ type: Injectable,
760
+ args: [{
761
+ providedIn: 'root',
762
+ }]
763
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
764
+ type: Inject,
765
+ args: [DOCUMENT]
766
+ }] }, { type: i0.NgZone }]; } });
767
+ const readQueryParam = (url, key) => {
768
+ key = key.replace(/[[\]\\]/g, '\\$&');
769
+ const regex = new RegExp('[\\?&]' + key + '=([^&#]*)');
770
+ const results = regex.exec(url);
771
+ return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null;
772
+ };
773
+ const proxyEvent = (emitter, el, eventName) => {
774
+ if (el) {
775
+ el.addEventListener(eventName, (ev) => {
776
+ // ?? cordova might emit "null" events
777
+ const value = ev != null ? ev.detail : undefined;
778
+ emitter.next(value);
779
+ });
780
+ }
781
+ };
782
+
783
+ class NavController {
784
+ constructor(platform, location, serializer, router) {
785
+ this.location = location;
786
+ this.serializer = serializer;
787
+ this.router = router;
788
+ this.direction = DEFAULT_DIRECTION;
789
+ this.animated = DEFAULT_ANIMATED;
790
+ this.guessDirection = 'forward';
791
+ this.lastNavId = -1;
792
+ // Subscribe to router events to detect direction
793
+ if (router) {
794
+ router.events.subscribe((ev) => {
795
+ if (ev instanceof NavigationStart) {
796
+ const id = ev.restoredState ? ev.restoredState.navigationId : ev.id;
797
+ this.guessDirection = id < this.lastNavId ? 'back' : 'forward';
798
+ this.guessAnimation = !ev.restoredState ? this.guessDirection : undefined;
799
+ this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;
800
+ }
801
+ });
802
+ }
803
+ // Subscribe to backButton events
804
+ platform.backButton.subscribeWithPriority(0, (processNextHandler) => {
805
+ this.pop();
806
+ processNextHandler();
807
+ });
808
+ }
809
+ /**
810
+ * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,
811
+ * it's equivalent to calling `this.router.navigateByUrl()`, but it's explicit about the **direction** of the transition.
812
+ *
813
+ * Going **forward** means that a new page is going to be pushed to the stack of the outlet (ion-router-outlet),
814
+ * and that it will show a "forward" animation by default.
815
+ *
816
+ * Navigating forward can also be triggered in a declarative manner by using the `[routerDirection]` directive:
817
+ *
818
+ * ```html
819
+ * <a routerLink="/path/to/page" routerDirection="forward">Link</a>
820
+ * ```
821
+ */
822
+ navigateForward(url, options = {}) {
823
+ this.setDirection('forward', options.animated, options.animationDirection, options.animation);
824
+ return this.navigate(url, options);
825
+ }
826
+ /**
827
+ * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,
828
+ * it's equivalent to calling:
829
+ *
830
+ * ```ts
831
+ * this.navController.setDirection('back');
832
+ * this.router.navigateByUrl(path);
833
+ * ```
834
+ *
835
+ * Going **back** means that all the pages in the stack until the navigated page is found will be popped,
836
+ * and that it will show a "back" animation by default.
837
+ *
838
+ * Navigating back can also be triggered in a declarative manner by using the `[routerDirection]` directive:
839
+ *
840
+ * ```html
841
+ * <a routerLink="/path/to/page" routerDirection="back">Link</a>
842
+ * ```
843
+ */
844
+ navigateBack(url, options = {}) {
845
+ this.setDirection('back', options.animated, options.animationDirection, options.animation);
846
+ return this.navigate(url, options);
847
+ }
848
+ /**
849
+ * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,
850
+ * it's equivalent to calling:
851
+ *
852
+ * ```ts
853
+ * this.navController.setDirection('root');
854
+ * this.router.navigateByUrl(path);
855
+ * ```
856
+ *
857
+ * Going **root** means that all existing pages in the stack will be removed,
858
+ * and the navigated page will become the single page in the stack.
859
+ *
860
+ * Navigating root can also be triggered in a declarative manner by using the `[routerDirection]` directive:
861
+ *
862
+ * ```html
863
+ * <a routerLink="/path/to/page" routerDirection="root">Link</a>
864
+ * ```
865
+ */
866
+ navigateRoot(url, options = {}) {
867
+ this.setDirection('root', options.animated, options.animationDirection, options.animation);
868
+ return this.navigate(url, options);
869
+ }
870
+ /**
871
+ * Same as [Location](https://angular.io/api/common/Location)'s back() method.
872
+ * It will use the standard `window.history.back()` under the hood, but featuring a `back` animation
873
+ * by default.
874
+ */
875
+ back(options = { animated: true, animationDirection: 'back' }) {
876
+ this.setDirection('back', options.animated, options.animationDirection, options.animation);
877
+ return this.location.back();
878
+ }
879
+ /**
880
+ * This methods goes back in the context of Ionic's stack navigation.
881
+ *
882
+ * It recursively finds the top active `ion-router-outlet` and calls `pop()`.
883
+ * This is the recommended way to go back when you are using `ion-router-outlet`.
884
+ *
885
+ * Resolves to `true` if it was able to pop.
886
+ */
887
+ async pop() {
888
+ let outlet = this.topOutlet;
889
+ while (outlet) {
890
+ if (await outlet.pop()) {
891
+ return true;
892
+ }
893
+ else {
894
+ outlet = outlet.parentOutlet;
895
+ }
896
+ }
897
+ return false;
898
+ }
899
+ /**
900
+ * This methods specifies the direction of the next navigation performed by the Angular router.
901
+ *
902
+ * `setDirection()` does not trigger any transition, it just sets some flags to be consumed by `ion-router-outlet`.
903
+ *
904
+ * It's recommended to use `navigateForward()`, `navigateBack()` and `navigateRoot()` instead of `setDirection()`.
905
+ */
906
+ setDirection(direction, animated, animationDirection, animationBuilder) {
907
+ this.direction = direction;
908
+ this.animated = getAnimation(direction, animated, animationDirection);
909
+ this.animationBuilder = animationBuilder;
910
+ }
911
+ /**
912
+ * @internal
913
+ */
914
+ setTopOutlet(outlet) {
915
+ this.topOutlet = outlet;
916
+ }
917
+ /**
918
+ * @internal
919
+ */
920
+ consumeTransition() {
921
+ let direction = 'root';
922
+ let animation;
923
+ const animationBuilder = this.animationBuilder;
924
+ if (this.direction === 'auto') {
925
+ direction = this.guessDirection;
926
+ animation = this.guessAnimation;
927
+ }
928
+ else {
929
+ animation = this.animated;
930
+ direction = this.direction;
931
+ }
932
+ this.direction = DEFAULT_DIRECTION;
933
+ this.animated = DEFAULT_ANIMATED;
934
+ this.animationBuilder = undefined;
935
+ return {
936
+ direction,
937
+ animation,
938
+ animationBuilder,
939
+ };
940
+ }
941
+ navigate(url, options) {
942
+ if (Array.isArray(url)) {
943
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
944
+ return this.router.navigate(url, options);
945
+ }
946
+ else {
947
+ /**
948
+ * navigateByUrl ignores any properties that
949
+ * would change the url, so things like queryParams
950
+ * would be ignored unless we create a url tree
951
+ * More Info: https://github.com/angular/angular/issues/18798
952
+ */
953
+ const urlTree = this.serializer.parse(url.toString());
954
+ if (options.queryParams !== undefined) {
955
+ urlTree.queryParams = { ...options.queryParams };
956
+ }
957
+ if (options.fragment !== undefined) {
958
+ urlTree.fragment = options.fragment;
959
+ }
960
+ /**
961
+ * `navigateByUrl` will still apply `NavigationExtras` properties
962
+ * that do not modify the url, such as `replaceUrl` which is why
963
+ * `options` is passed in here.
964
+ */
965
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
966
+ return this.router.navigateByUrl(urlTree, options);
967
+ }
968
+ }
969
+ }
970
+ /** @nocollapse */ NavController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NavController, deps: [{ token: Platform }, { token: i1.Location }, { token: i3.UrlSerializer }, { token: i3.Router, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
971
+ /** @nocollapse */ NavController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NavController, providedIn: 'root' });
972
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NavController, decorators: [{
973
+ type: Injectable,
974
+ args: [{
975
+ providedIn: 'root',
976
+ }]
977
+ }], ctorParameters: function () { return [{ type: Platform }, { type: i1.Location }, { type: i3.UrlSerializer }, { type: i3.Router, decorators: [{
978
+ type: Optional
979
+ }] }]; } });
980
+ const getAnimation = (direction, animated, animationDirection) => {
981
+ if (animated === false) {
982
+ return undefined;
983
+ }
984
+ if (animationDirection !== undefined) {
985
+ return animationDirection;
986
+ }
987
+ if (direction === 'forward' || direction === 'back') {
988
+ return direction;
989
+ }
990
+ else if (direction === 'root' && animated === true) {
991
+ return 'forward';
992
+ }
993
+ return undefined;
994
+ };
995
+ const DEFAULT_DIRECTION = 'auto';
996
+ const DEFAULT_ANIMATED = undefined;
997
+
998
+ class Config {
999
+ get(key, fallback) {
1000
+ const c = getConfig();
1001
+ if (c) {
1002
+ return c.get(key, fallback);
1003
+ }
1004
+ return null;
1005
+ }
1006
+ getBoolean(key, fallback) {
1007
+ const c = getConfig();
1008
+ if (c) {
1009
+ return c.getBoolean(key, fallback);
1010
+ }
1011
+ return false;
1012
+ }
1013
+ getNumber(key, fallback) {
1014
+ const c = getConfig();
1015
+ if (c) {
1016
+ return c.getNumber(key, fallback);
1017
+ }
1018
+ return 0;
1019
+ }
1020
+ }
1021
+ /** @nocollapse */ Config.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Config, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1022
+ /** @nocollapse */ Config.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Config, providedIn: 'root' });
1023
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Config, decorators: [{
1024
+ type: Injectable,
1025
+ args: [{
1026
+ providedIn: 'root',
1027
+ }]
1028
+ }] });
1029
+ const ConfigToken = new InjectionToken('USERCONFIG');
1030
+ const getConfig = () => {
1031
+ if (typeof window !== 'undefined') {
1032
+ const Ionic = window.Ionic;
1033
+ if (Ionic?.config) {
1034
+ return Ionic.config;
1035
+ }
1036
+ }
1037
+ return null;
1038
+ };
1039
+
1040
+ // TODO: Is there a way we can grab this from angular-component-lib instead?
1041
+ const proxyInputs = (Cmp, inputs) => {
1042
+ const Prototype = Cmp.prototype;
1043
+ inputs.forEach((item) => {
1044
+ Object.defineProperty(Prototype, item, {
1045
+ get() {
1046
+ return this.el[item];
1047
+ },
1048
+ set(val) {
1049
+ this.z.runOutsideAngular(() => (this.el[item] = val));
1050
+ },
1051
+ });
1052
+ });
1053
+ };
1054
+ const proxyMethods = (Cmp, methods) => {
1055
+ const Prototype = Cmp.prototype;
1056
+ methods.forEach((methodName) => {
1057
+ Prototype[methodName] = function () {
1058
+ const args = arguments;
1059
+ return this.z.runOutsideAngular(() => this.el[methodName].apply(this.el, args));
1060
+ };
1061
+ });
1062
+ };
1063
+ const proxyOutputs = (instance, el, events) => {
1064
+ events.forEach((eventName) => (instance[eventName] = fromEvent(el, eventName)));
1065
+ };
1066
+ // tslint:disable-next-line: only-arrow-functions
1067
+ function ProxyCmp(opts) {
1068
+ const decorator = function (cls) {
1069
+ const { defineCustomElementFn, inputs, methods } = opts;
1070
+ if (defineCustomElementFn !== undefined) {
1071
+ defineCustomElementFn();
1072
+ }
1073
+ if (inputs) {
1074
+ proxyInputs(cls, inputs);
1075
+ }
1076
+ if (methods) {
1077
+ proxyMethods(cls, methods);
1078
+ }
1079
+ return cls;
1080
+ };
1081
+ return decorator;
1082
+ }
1083
+
1084
+ const POPOVER_INPUTS = [
1085
+ 'alignment',
1086
+ 'animated',
1087
+ 'arrow',
1088
+ 'keepContentsMounted',
1089
+ 'backdropDismiss',
1090
+ 'cssClass',
1091
+ 'dismissOnSelect',
1092
+ 'enterAnimation',
1093
+ 'event',
1094
+ 'isOpen',
1095
+ 'keyboardClose',
1096
+ 'leaveAnimation',
1097
+ 'mode',
1098
+ 'showBackdrop',
1099
+ 'translucent',
1100
+ 'trigger',
1101
+ 'triggerAction',
1102
+ 'reference',
1103
+ 'size',
1104
+ 'side',
1105
+ ];
1106
+ const POPOVER_METHODS = ['present', 'dismiss', 'onDidDismiss', 'onWillDismiss'];
1107
+ let IonPopover = class IonPopover {
1108
+ constructor(c, r, z) {
1109
+ this.z = z;
1110
+ this.isCmpOpen = false;
1111
+ this.el = r.nativeElement;
1112
+ this.el.addEventListener('ionMount', () => {
1113
+ this.isCmpOpen = true;
1114
+ c.detectChanges();
1115
+ });
1116
+ this.el.addEventListener('didDismiss', () => {
1117
+ this.isCmpOpen = false;
1118
+ c.detectChanges();
1119
+ });
1120
+ proxyOutputs(this, this.el, [
1121
+ 'ionPopoverDidPresent',
1122
+ 'ionPopoverWillPresent',
1123
+ 'ionPopoverWillDismiss',
1124
+ 'ionPopoverDidDismiss',
1125
+ 'didPresent',
1126
+ 'willPresent',
1127
+ 'willDismiss',
1128
+ 'didDismiss',
1129
+ ]);
1130
+ }
1131
+ };
1132
+ /** @nocollapse */ IonPopover.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonPopover, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1133
+ /** @nocollapse */ IonPopover.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonPopover, selector: "ion-popover", inputs: { alignment: "alignment", animated: "animated", arrow: "arrow", keepContentsMounted: "keepContentsMounted", backdropDismiss: "backdropDismiss", cssClass: "cssClass", dismissOnSelect: "dismissOnSelect", enterAnimation: "enterAnimation", event: "event", isOpen: "isOpen", keyboardClose: "keyboardClose", leaveAnimation: "leaveAnimation", mode: "mode", showBackdrop: "showBackdrop", translucent: "translucent", trigger: "trigger", triggerAction: "triggerAction", reference: "reference", size: "size", side: "side" }, queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 });
1134
+ IonPopover = __decorate([
1135
+ ProxyCmp({
1136
+ inputs: POPOVER_INPUTS,
1137
+ methods: POPOVER_METHODS,
1138
+ })
1139
+ /**
1140
+ * @Component extends from @Directive
1141
+ * so by defining the inputs here we
1142
+ * do not need to re-define them for the
1143
+ * lazy loaded popover.
1144
+ */
1145
+ ], IonPopover);
1146
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonPopover, decorators: [{
1147
+ type: Directive,
1148
+ args: [{
1149
+ selector: 'ion-popover',
1150
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1151
+ inputs: POPOVER_INPUTS,
1152
+ }]
1153
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { template: [{
1154
+ type: ContentChild,
1155
+ args: [TemplateRef, { static: false }]
1156
+ }] } });
1157
+
1158
+ const MODAL_INPUTS = [
1159
+ 'animated',
1160
+ 'keepContentsMounted',
1161
+ 'backdropBreakpoint',
1162
+ 'backdropDismiss',
1163
+ 'breakpoints',
1164
+ 'canDismiss',
1165
+ 'cssClass',
1166
+ 'enterAnimation',
1167
+ 'event',
1168
+ 'handle',
1169
+ 'handleBehavior',
1170
+ 'initialBreakpoint',
1171
+ 'isOpen',
1172
+ 'keyboardClose',
1173
+ 'leaveAnimation',
1174
+ 'mode',
1175
+ 'presentingElement',
1176
+ 'showBackdrop',
1177
+ 'translucent',
1178
+ 'trigger',
1179
+ ];
1180
+ const MODAL_METHODS = [
1181
+ 'present',
1182
+ 'dismiss',
1183
+ 'onDidDismiss',
1184
+ 'onWillDismiss',
1185
+ 'setCurrentBreakpoint',
1186
+ 'getCurrentBreakpoint',
1187
+ ];
1188
+ let IonModal = class IonModal {
1189
+ constructor(c, r, z) {
1190
+ this.z = z;
1191
+ this.isCmpOpen = false;
1192
+ this.el = r.nativeElement;
1193
+ this.el.addEventListener('ionMount', () => {
1194
+ this.isCmpOpen = true;
1195
+ c.detectChanges();
1196
+ });
1197
+ this.el.addEventListener('didDismiss', () => {
1198
+ this.isCmpOpen = false;
1199
+ c.detectChanges();
1200
+ });
1201
+ proxyOutputs(this, this.el, [
1202
+ 'ionModalDidPresent',
1203
+ 'ionModalWillPresent',
1204
+ 'ionModalWillDismiss',
1205
+ 'ionModalDidDismiss',
1206
+ 'ionBreakpointDidChange',
1207
+ 'didPresent',
1208
+ 'willPresent',
1209
+ 'willDismiss',
1210
+ 'didDismiss',
1211
+ ]);
1212
+ }
1213
+ };
1214
+ /** @nocollapse */ IonModal.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonModal, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1215
+ /** @nocollapse */ IonModal.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonModal, selector: "ion-modal", inputs: { animated: "animated", keepContentsMounted: "keepContentsMounted", backdropBreakpoint: "backdropBreakpoint", backdropDismiss: "backdropDismiss", breakpoints: "breakpoints", canDismiss: "canDismiss", cssClass: "cssClass", enterAnimation: "enterAnimation", event: "event", handle: "handle", handleBehavior: "handleBehavior", initialBreakpoint: "initialBreakpoint", isOpen: "isOpen", keyboardClose: "keyboardClose", leaveAnimation: "leaveAnimation", mode: "mode", presentingElement: "presentingElement", showBackdrop: "showBackdrop", translucent: "translucent", trigger: "trigger" }, queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 });
1216
+ IonModal = __decorate([
1217
+ ProxyCmp({
1218
+ inputs: MODAL_INPUTS,
1219
+ methods: MODAL_METHODS,
1220
+ })
1221
+ /**
1222
+ * @Component extends from @Directive
1223
+ * so by defining the inputs here we
1224
+ * do not need to re-define them for the
1225
+ * lazy loaded popover.
1226
+ */
1227
+ ], IonModal);
1228
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonModal, decorators: [{
1229
+ type: Directive,
1230
+ args: [{
1231
+ selector: 'ion-modal',
1232
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1233
+ inputs: MODAL_INPUTS,
1234
+ }]
1235
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { template: [{
1236
+ type: ContentChild,
1237
+ args: [TemplateRef, { static: false }]
1238
+ }] } });
1239
+
1240
+ const insertView = (views, view, direction) => {
1241
+ if (direction === 'root') {
1242
+ return setRoot(views, view);
1243
+ }
1244
+ else if (direction === 'forward') {
1245
+ return setForward(views, view);
1246
+ }
1247
+ else {
1248
+ return setBack(views, view);
1249
+ }
1250
+ };
1251
+ const setRoot = (views, view) => {
1252
+ views = views.filter((v) => v.stackId !== view.stackId);
1253
+ views.push(view);
1254
+ return views;
1255
+ };
1256
+ const setForward = (views, view) => {
1257
+ const index = views.indexOf(view);
1258
+ if (index >= 0) {
1259
+ views = views.filter((v) => v.stackId !== view.stackId || v.id <= view.id);
1260
+ }
1261
+ else {
1262
+ views.push(view);
1263
+ }
1264
+ return views;
1265
+ };
1266
+ const setBack = (views, view) => {
1267
+ const index = views.indexOf(view);
1268
+ if (index >= 0) {
1269
+ return views.filter((v) => v.stackId !== view.stackId || v.id <= view.id);
1270
+ }
1271
+ else {
1272
+ return setRoot(views, view);
1273
+ }
1274
+ };
1275
+ const getUrl = (router, activatedRoute) => {
1276
+ const urlTree = router.createUrlTree(['.'], { relativeTo: activatedRoute });
1277
+ return router.serializeUrl(urlTree);
1278
+ };
1279
+ const isTabSwitch = (enteringView, leavingView) => {
1280
+ if (!leavingView) {
1281
+ return true;
1282
+ }
1283
+ return enteringView.stackId !== leavingView.stackId;
1284
+ };
1285
+ const computeStackId = (prefixUrl, url) => {
1286
+ if (!prefixUrl) {
1287
+ return undefined;
1288
+ }
1289
+ const segments = toSegments(url);
1290
+ for (let i = 0; i < segments.length; i++) {
1291
+ if (i >= prefixUrl.length) {
1292
+ return segments[i];
1293
+ }
1294
+ if (segments[i] !== prefixUrl[i]) {
1295
+ return undefined;
1296
+ }
1297
+ }
1298
+ return undefined;
1299
+ };
1300
+ const toSegments = (path) => {
1301
+ return path
1302
+ .split('/')
1303
+ .map((s) => s.trim())
1304
+ .filter((s) => s !== '');
1305
+ };
1306
+ const destroyView = (view) => {
1307
+ if (view) {
1308
+ view.ref.destroy();
1309
+ view.unlistenEvents();
1310
+ }
1311
+ };
1312
+
1313
+ // TODO(FW-2827): types
1314
+ class StackController {
1315
+ constructor(tabsPrefix, containerEl, router, navCtrl, zone, location) {
1316
+ this.containerEl = containerEl;
1317
+ this.router = router;
1318
+ this.navCtrl = navCtrl;
1319
+ this.zone = zone;
1320
+ this.location = location;
1321
+ this.views = [];
1322
+ this.skipTransition = false;
1323
+ this.nextId = 0;
1324
+ this.tabsPrefix = tabsPrefix !== undefined ? toSegments(tabsPrefix) : undefined;
1325
+ }
1326
+ createView(ref, activatedRoute) {
1327
+ const url = getUrl(this.router, activatedRoute);
1328
+ const element = ref?.location?.nativeElement;
1329
+ const unlistenEvents = bindLifecycleEvents(this.zone, ref.instance, element);
1330
+ return {
1331
+ id: this.nextId++,
1332
+ stackId: computeStackId(this.tabsPrefix, url),
1333
+ unlistenEvents,
1334
+ element,
1335
+ ref,
1336
+ url,
1337
+ };
1338
+ }
1339
+ getExistingView(activatedRoute) {
1340
+ const activatedUrlKey = getUrl(this.router, activatedRoute);
1341
+ const view = this.views.find((vw) => vw.url === activatedUrlKey);
1342
+ if (view) {
1343
+ view.ref.changeDetectorRef.reattach();
1344
+ }
1345
+ return view;
1346
+ }
1347
+ setActive(enteringView) {
1348
+ const consumeResult = this.navCtrl.consumeTransition();
1349
+ let { direction, animation, animationBuilder } = consumeResult;
1350
+ const leavingView = this.activeView;
1351
+ const tabSwitch = isTabSwitch(enteringView, leavingView);
1352
+ if (tabSwitch) {
1353
+ direction = 'back';
1354
+ animation = undefined;
1355
+ }
1356
+ const viewsSnapshot = this.views.slice();
1357
+ let currentNavigation;
1358
+ const router = this.router;
1359
+ // Angular >= 7.2.0
1360
+ if (router.getCurrentNavigation) {
1361
+ currentNavigation = router.getCurrentNavigation();
1362
+ // Angular < 7.2.0
1363
+ }
1364
+ else if (router.navigations?.value) {
1365
+ currentNavigation = router.navigations.value;
1366
+ }
1367
+ /**
1368
+ * If the navigation action
1369
+ * sets `replaceUrl: true`
1370
+ * then we need to make sure
1371
+ * we remove the last item
1372
+ * from our views stack
1373
+ */
1374
+ if (currentNavigation?.extras?.replaceUrl) {
1375
+ if (this.views.length > 0) {
1376
+ this.views.splice(-1, 1);
1377
+ }
1378
+ }
1379
+ const reused = this.views.includes(enteringView);
1380
+ const views = this.insertView(enteringView, direction);
1381
+ // Trigger change detection before transition starts
1382
+ // This will call ngOnInit() the first time too, just after the view
1383
+ // was attached to the dom, but BEFORE the transition starts
1384
+ if (!reused) {
1385
+ enteringView.ref.changeDetectorRef.detectChanges();
1386
+ }
1387
+ /**
1388
+ * If we are going back from a page that
1389
+ * was presented using a custom animation
1390
+ * we should default to using that
1391
+ * unless the developer explicitly
1392
+ * provided another animation.
1393
+ */
1394
+ const customAnimation = enteringView.animationBuilder;
1395
+ if (animationBuilder === undefined && direction === 'back' && !tabSwitch && customAnimation !== undefined) {
1396
+ animationBuilder = customAnimation;
1397
+ }
1398
+ /**
1399
+ * Save any custom animation so that navigating
1400
+ * back will use this custom animation by default.
1401
+ */
1402
+ if (leavingView) {
1403
+ leavingView.animationBuilder = animationBuilder;
1404
+ }
1405
+ // Wait until previous transitions finish
1406
+ return this.zone.runOutsideAngular(() => {
1407
+ return this.wait(() => {
1408
+ // disconnect leaving page from change detection to
1409
+ // reduce jank during the page transition
1410
+ if (leavingView) {
1411
+ leavingView.ref.changeDetectorRef.detach();
1412
+ }
1413
+ // In case the enteringView is the same as the leavingPage we need to reattach()
1414
+ enteringView.ref.changeDetectorRef.reattach();
1415
+ return this.transition(enteringView, leavingView, animation, this.canGoBack(1), false, animationBuilder)
1416
+ .then(() => cleanupAsync(enteringView, views, viewsSnapshot, this.location, this.zone))
1417
+ .then(() => ({
1418
+ enteringView,
1419
+ direction,
1420
+ animation,
1421
+ tabSwitch,
1422
+ }));
1423
+ });
1424
+ });
1425
+ }
1426
+ canGoBack(deep, stackId = this.getActiveStackId()) {
1427
+ return this.getStack(stackId).length > deep;
1428
+ }
1429
+ pop(deep, stackId = this.getActiveStackId()) {
1430
+ return this.zone.run(() => {
1431
+ const views = this.getStack(stackId);
1432
+ if (views.length <= deep) {
1433
+ return Promise.resolve(false);
1434
+ }
1435
+ const view = views[views.length - deep - 1];
1436
+ let url = view.url;
1437
+ const viewSavedData = view.savedData;
1438
+ if (viewSavedData) {
1439
+ const primaryOutlet = viewSavedData.get('primary');
1440
+ if (primaryOutlet?.route?._routerState?.snapshot.url) {
1441
+ url = primaryOutlet.route._routerState.snapshot.url;
1442
+ }
1443
+ }
1444
+ const { animationBuilder } = this.navCtrl.consumeTransition();
1445
+ return this.navCtrl.navigateBack(url, { ...view.savedExtras, animation: animationBuilder }).then(() => true);
1446
+ });
1447
+ }
1448
+ startBackTransition() {
1449
+ const leavingView = this.activeView;
1450
+ if (leavingView) {
1451
+ const views = this.getStack(leavingView.stackId);
1452
+ const enteringView = views[views.length - 2];
1453
+ const customAnimation = enteringView.animationBuilder;
1454
+ return this.wait(() => {
1455
+ return this.transition(enteringView, // entering view
1456
+ leavingView, // leaving view
1457
+ 'back', this.canGoBack(2), true, customAnimation);
1458
+ });
1459
+ }
1460
+ return Promise.resolve();
1461
+ }
1462
+ endBackTransition(shouldComplete) {
1463
+ if (shouldComplete) {
1464
+ this.skipTransition = true;
1465
+ this.pop(1);
1466
+ }
1467
+ else if (this.activeView) {
1468
+ cleanup(this.activeView, this.views, this.views, this.location, this.zone);
1469
+ }
1470
+ }
1471
+ getLastUrl(stackId) {
1472
+ const views = this.getStack(stackId);
1473
+ return views.length > 0 ? views[views.length - 1] : undefined;
1474
+ }
1475
+ /**
1476
+ * @internal
1477
+ */
1478
+ getRootUrl(stackId) {
1479
+ const views = this.getStack(stackId);
1480
+ return views.length > 0 ? views[0] : undefined;
1481
+ }
1482
+ getActiveStackId() {
1483
+ return this.activeView ? this.activeView.stackId : undefined;
1484
+ }
1485
+ /**
1486
+ * @internal
1487
+ */
1488
+ getActiveView() {
1489
+ return this.activeView;
1490
+ }
1491
+ hasRunningTask() {
1492
+ return this.runningTask !== undefined;
1493
+ }
1494
+ destroy() {
1495
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1496
+ this.containerEl = undefined;
1497
+ this.views.forEach(destroyView);
1498
+ this.activeView = undefined;
1499
+ this.views = [];
1500
+ }
1501
+ getStack(stackId) {
1502
+ return this.views.filter((v) => v.stackId === stackId);
1503
+ }
1504
+ insertView(enteringView, direction) {
1505
+ this.activeView = enteringView;
1506
+ this.views = insertView(this.views, enteringView, direction);
1507
+ return this.views.slice();
1508
+ }
1509
+ transition(enteringView, leavingView, direction, showGoBack, progressAnimation, animationBuilder) {
1510
+ if (this.skipTransition) {
1511
+ this.skipTransition = false;
1512
+ return Promise.resolve(false);
1513
+ }
1514
+ if (leavingView === enteringView) {
1515
+ return Promise.resolve(false);
1516
+ }
1517
+ const enteringEl = enteringView ? enteringView.element : undefined;
1518
+ const leavingEl = leavingView ? leavingView.element : undefined;
1519
+ const containerEl = this.containerEl;
1520
+ if (enteringEl && enteringEl !== leavingEl) {
1521
+ enteringEl.classList.add('ion-page');
1522
+ enteringEl.classList.add('ion-page-invisible');
1523
+ if (enteringEl.parentElement !== containerEl) {
1524
+ containerEl.appendChild(enteringEl);
1525
+ }
1526
+ if (containerEl.commit) {
1527
+ return containerEl.commit(enteringEl, leavingEl, {
1528
+ duration: direction === undefined ? 0 : undefined,
1529
+ direction,
1530
+ showGoBack,
1531
+ progressAnimation,
1532
+ animationBuilder,
1533
+ });
1534
+ }
1535
+ }
1536
+ return Promise.resolve(false);
1537
+ }
1538
+ async wait(task) {
1539
+ if (this.runningTask !== undefined) {
1540
+ await this.runningTask;
1541
+ this.runningTask = undefined;
1542
+ }
1543
+ const promise = (this.runningTask = task());
1544
+ promise.finally(() => (this.runningTask = undefined));
1545
+ return promise;
1546
+ }
1547
+ }
1548
+ const cleanupAsync = (activeRoute, views, viewsSnapshot, location, zone) => {
1549
+ if (typeof requestAnimationFrame === 'function') {
1550
+ return new Promise((resolve) => {
1551
+ requestAnimationFrame(() => {
1552
+ cleanup(activeRoute, views, viewsSnapshot, location, zone);
1553
+ resolve();
1554
+ });
1555
+ });
1556
+ }
1557
+ return Promise.resolve();
1558
+ };
1559
+ const cleanup = (activeRoute, views, viewsSnapshot, location, zone) => {
1560
+ /**
1561
+ * Re-enter the Angular zone when destroying page components. This will allow
1562
+ * lifecycle events (`ngOnDestroy`) to be run inside the Angular zone.
1563
+ */
1564
+ zone.run(() => viewsSnapshot.filter((view) => !views.includes(view)).forEach(destroyView));
1565
+ views.forEach((view) => {
1566
+ /**
1567
+ * In the event that a user navigated multiple
1568
+ * times in rapid succession, we want to make sure
1569
+ * we don't pre-emptively detach a view while
1570
+ * it is in mid-transition.
1571
+ *
1572
+ * In this instance we also do not care about query
1573
+ * params or fragments as it will be the same view regardless
1574
+ */
1575
+ const locationWithoutParams = location.path().split('?')[0];
1576
+ const locationWithoutFragment = locationWithoutParams.split('#')[0];
1577
+ if (view !== activeRoute && view.url !== locationWithoutFragment) {
1578
+ const element = view.element;
1579
+ element.setAttribute('aria-hidden', 'true');
1580
+ element.classList.add('ion-page-hidden');
1581
+ view.ref.changeDetectorRef.detach();
1582
+ }
1583
+ });
1584
+ };
1585
+
1586
+ // TODO(FW-2827): types
1587
+ // eslint-disable-next-line @angular-eslint/directive-class-suffix
1588
+ class IonRouterOutlet {
1589
+ constructor(name, tabs, commonLocation, elementRef, router, zone, activatedRoute, parentOutlet) {
1590
+ this.parentOutlet = parentOutlet;
1591
+ this.activatedView = null;
1592
+ // Maintain map of activated route proxies for each component instance
1593
+ this.proxyMap = new WeakMap();
1594
+ // Keep the latest activated route in a subject for the proxy routes to switch map to
1595
+ this.currentActivatedRoute$ = new BehaviorSubject(null);
1596
+ this.activated = null;
1597
+ this._activatedRoute = null;
1598
+ /**
1599
+ * The name of the outlet
1600
+ */
1601
+ this.name = PRIMARY_OUTLET;
1602
+ /** @internal */
1603
+ this.stackWillChange = new EventEmitter();
1604
+ /** @internal */
1605
+ this.stackDidChange = new EventEmitter();
1606
+ // eslint-disable-next-line @angular-eslint/no-output-rename
1607
+ this.activateEvents = new EventEmitter();
1608
+ // eslint-disable-next-line @angular-eslint/no-output-rename
1609
+ this.deactivateEvents = new EventEmitter();
1610
+ this.parentContexts = inject(ChildrenOutletContexts);
1611
+ this.location = inject(ViewContainerRef);
1612
+ this.environmentInjector = inject(EnvironmentInjector);
1613
+ this.inputBinder = inject(INPUT_BINDER, { optional: true });
1614
+ /** @nodoc */
1615
+ this.supportsBindingToComponentInputs = true;
1616
+ // Ionic providers
1617
+ this.config = inject(Config);
1618
+ this.navCtrl = inject(NavController);
1619
+ this.nativeEl = elementRef.nativeElement;
1620
+ this.name = name || PRIMARY_OUTLET;
1621
+ this.tabsPrefix = tabs === 'true' ? getUrl(router, activatedRoute) : undefined;
1622
+ this.stackCtrl = new StackController(this.tabsPrefix, this.nativeEl, router, this.navCtrl, zone, commonLocation);
1623
+ this.parentContexts.onChildOutletCreated(this.name, this);
1624
+ }
1625
+ /** @internal */
1626
+ get activatedComponentRef() {
1627
+ return this.activated;
1628
+ }
1629
+ set animation(animation) {
1630
+ this.nativeEl.animation = animation;
1631
+ }
1632
+ set animated(animated) {
1633
+ this.nativeEl.animated = animated;
1634
+ }
1635
+ set swipeGesture(swipe) {
1636
+ this._swipeGesture = swipe;
1637
+ this.nativeEl.swipeHandler = swipe
1638
+ ? {
1639
+ canStart: () => this.stackCtrl.canGoBack(1) && !this.stackCtrl.hasRunningTask(),
1640
+ onStart: () => this.stackCtrl.startBackTransition(),
1641
+ onEnd: (shouldContinue) => this.stackCtrl.endBackTransition(shouldContinue),
1642
+ }
1643
+ : undefined;
1644
+ }
1645
+ ngOnDestroy() {
1646
+ this.stackCtrl.destroy();
1647
+ this.inputBinder?.unsubscribeFromRouteData(this);
1648
+ }
1649
+ getContext() {
1650
+ return this.parentContexts.getContext(this.name);
1651
+ }
1652
+ ngOnInit() {
1653
+ this.initializeOutletWithName();
1654
+ }
1655
+ // Note: Ionic deviates from the Angular Router implementation here
1656
+ initializeOutletWithName() {
1657
+ if (!this.activated) {
1658
+ // If the outlet was not instantiated at the time the route got activated we need to populate
1659
+ // the outlet when it is initialized (ie inside a NgIf)
1660
+ const context = this.getContext();
1661
+ if (context?.route) {
1662
+ this.activateWith(context.route, context.injector);
1663
+ }
1664
+ }
1665
+ new Promise((resolve) => componentOnReady(this.nativeEl, resolve)).then(() => {
1666
+ if (this._swipeGesture === undefined) {
1667
+ this.swipeGesture = this.config.getBoolean('swipeBackEnabled', this.nativeEl.mode === 'ios');
1668
+ }
1669
+ });
1670
+ }
1671
+ get isActivated() {
1672
+ return !!this.activated;
1673
+ }
1674
+ get component() {
1675
+ if (!this.activated) {
1676
+ throw new Error('Outlet is not activated');
1677
+ }
1678
+ return this.activated.instance;
1679
+ }
1680
+ get activatedRoute() {
1681
+ if (!this.activated) {
1682
+ throw new Error('Outlet is not activated');
1683
+ }
1684
+ return this._activatedRoute;
1685
+ }
1686
+ get activatedRouteData() {
1687
+ if (this._activatedRoute) {
1688
+ return this._activatedRoute.snapshot.data;
1689
+ }
1690
+ return {};
1691
+ }
1692
+ /**
1693
+ * Called when the `RouteReuseStrategy` instructs to detach the subtree
1694
+ */
1695
+ detach() {
1696
+ throw new Error('incompatible reuse strategy');
1697
+ }
1698
+ /**
1699
+ * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree
1700
+ */
1701
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1702
+ attach(_ref, _activatedRoute) {
1703
+ throw new Error('incompatible reuse strategy');
1704
+ }
1705
+ deactivate() {
1706
+ if (this.activated) {
1707
+ if (this.activatedView) {
1708
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1709
+ const context = this.getContext();
1710
+ this.activatedView.savedData = new Map(context.children['contexts']);
1711
+ /**
1712
+ * Angular v11.2.10 introduced a change
1713
+ * where this route context is cleared out when
1714
+ * a router-outlet is deactivated, However,
1715
+ * we need this route information in order to
1716
+ * return a user back to the correct tab when
1717
+ * leaving and then going back to the tab context.
1718
+ */
1719
+ const primaryOutlet = this.activatedView.savedData.get('primary');
1720
+ if (primaryOutlet && context.route) {
1721
+ primaryOutlet.route = { ...context.route };
1722
+ }
1723
+ /**
1724
+ * Ensure we are saving the NavigationExtras
1725
+ * data otherwise it will be lost
1726
+ */
1727
+ this.activatedView.savedExtras = {};
1728
+ if (context.route) {
1729
+ const contextSnapshot = context.route.snapshot;
1730
+ this.activatedView.savedExtras.queryParams = contextSnapshot.queryParams;
1731
+ this.activatedView.savedExtras.fragment = contextSnapshot.fragment;
1732
+ }
1733
+ }
1734
+ const c = this.component;
1735
+ this.activatedView = null;
1736
+ this.activated = null;
1737
+ this._activatedRoute = null;
1738
+ this.deactivateEvents.emit(c);
1739
+ }
1740
+ }
1741
+ activateWith(activatedRoute, environmentInjector) {
1742
+ if (this.isActivated) {
1743
+ throw new Error('Cannot activate an already activated outlet');
1744
+ }
1745
+ this._activatedRoute = activatedRoute;
1746
+ let cmpRef;
1747
+ let enteringView = this.stackCtrl.getExistingView(activatedRoute);
1748
+ if (enteringView) {
1749
+ cmpRef = this.activated = enteringView.ref;
1750
+ const saved = enteringView.savedData;
1751
+ if (saved) {
1752
+ // self-restore
1753
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1754
+ const context = this.getContext();
1755
+ context.children['contexts'] = saved;
1756
+ }
1757
+ // Updated activated route proxy for this component
1758
+ this.updateActivatedRouteProxy(cmpRef.instance, activatedRoute);
1759
+ }
1760
+ else {
1761
+ const snapshot = activatedRoute._futureSnapshot;
1762
+ /**
1763
+ * Angular 14 introduces a new `loadComponent` property to the route config.
1764
+ * This function will assign a `component` property to the route snapshot.
1765
+ * We check for the presence of this property to determine if the route is
1766
+ * using standalone components.
1767
+ */
1768
+ const childContexts = this.parentContexts.getOrCreateContext(this.name).children;
1769
+ // We create an activated route proxy object that will maintain future updates for this component
1770
+ // over its lifecycle in the stack.
1771
+ const component$ = new BehaviorSubject(null);
1772
+ const activatedRouteProxy = this.createActivatedRouteProxy(component$, activatedRoute);
1773
+ const injector = new OutletInjector(activatedRouteProxy, childContexts, this.location.injector);
1774
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1775
+ const component = snapshot.routeConfig.component ?? snapshot.component;
1776
+ cmpRef = this.activated = this.location.createComponent(component, {
1777
+ index: this.location.length,
1778
+ injector,
1779
+ environmentInjector: environmentInjector ?? this.environmentInjector,
1780
+ });
1781
+ // Once the component is created we can push it to our local subject supplied to the proxy
1782
+ component$.next(cmpRef.instance);
1783
+ // Calling `markForCheck` to make sure we will run the change detection when the
1784
+ // `RouterOutlet` is inside a `ChangeDetectionStrategy.OnPush` component.
1785
+ enteringView = this.stackCtrl.createView(this.activated, activatedRoute);
1786
+ // Store references to the proxy by component
1787
+ this.proxyMap.set(cmpRef.instance, activatedRouteProxy);
1788
+ this.currentActivatedRoute$.next({ component: cmpRef.instance, activatedRoute });
1789
+ }
1790
+ this.inputBinder?.bindActivatedRouteToOutletComponent(this);
1791
+ this.activatedView = enteringView;
1792
+ /**
1793
+ * The top outlet is set prior to the entering view's transition completing,
1794
+ * so that when we have nested outlets (e.g. ion-tabs inside an ion-router-outlet),
1795
+ * the tabs outlet will be assigned as the top outlet when a view inside tabs is
1796
+ * activated.
1797
+ *
1798
+ * In this scenario, activeWith is called for both the tabs and the root router outlet.
1799
+ * To avoid a race condition, we assign the top outlet synchronously.
1800
+ */
1801
+ this.navCtrl.setTopOutlet(this);
1802
+ const leavingView = this.stackCtrl.getActiveView();
1803
+ this.stackWillChange.emit({
1804
+ enteringView,
1805
+ tabSwitch: isTabSwitch(enteringView, leavingView),
1806
+ });
1807
+ this.stackCtrl.setActive(enteringView).then((data) => {
1808
+ this.activateEvents.emit(cmpRef.instance);
1809
+ this.stackDidChange.emit(data);
1810
+ });
1811
+ }
1812
+ /**
1813
+ * Returns `true` if there are pages in the stack to go back.
1814
+ */
1815
+ canGoBack(deep = 1, stackId) {
1816
+ return this.stackCtrl.canGoBack(deep, stackId);
1817
+ }
1818
+ /**
1819
+ * Resolves to `true` if it the outlet was able to sucessfully pop the last N pages.
1820
+ */
1821
+ pop(deep = 1, stackId) {
1822
+ return this.stackCtrl.pop(deep, stackId);
1823
+ }
1824
+ /**
1825
+ * Returns the URL of the active page of each stack.
1826
+ */
1827
+ getLastUrl(stackId) {
1828
+ const active = this.stackCtrl.getLastUrl(stackId);
1829
+ return active ? active.url : undefined;
1830
+ }
1831
+ /**
1832
+ * Returns the RouteView of the active page of each stack.
1833
+ * @internal
1834
+ */
1835
+ getLastRouteView(stackId) {
1836
+ return this.stackCtrl.getLastUrl(stackId);
1837
+ }
1838
+ /**
1839
+ * Returns the root view in the tab stack.
1840
+ * @internal
1841
+ */
1842
+ getRootView(stackId) {
1843
+ return this.stackCtrl.getRootUrl(stackId);
1844
+ }
1845
+ /**
1846
+ * Returns the active stack ID. In the context of ion-tabs, it means the active tab.
1847
+ */
1848
+ getActiveStackId() {
1849
+ return this.stackCtrl.getActiveStackId();
1850
+ }
1851
+ /**
1852
+ * Since the activated route can change over the life time of a component in an ion router outlet, we create
1853
+ * a proxy so that we can update the values over time as a user navigates back to components already in the stack.
1854
+ */
1855
+ createActivatedRouteProxy(component$, activatedRoute) {
1856
+ const proxy = new ActivatedRoute();
1857
+ proxy._futureSnapshot = activatedRoute._futureSnapshot;
1858
+ proxy._routerState = activatedRoute._routerState;
1859
+ proxy.snapshot = activatedRoute.snapshot;
1860
+ proxy.outlet = activatedRoute.outlet;
1861
+ proxy.component = activatedRoute.component;
1862
+ // Setup wrappers for the observables so consumers don't have to worry about switching to new observables as the state updates
1863
+ proxy._paramMap = this.proxyObservable(component$, 'paramMap');
1864
+ proxy._queryParamMap = this.proxyObservable(component$, 'queryParamMap');
1865
+ proxy.url = this.proxyObservable(component$, 'url');
1866
+ proxy.params = this.proxyObservable(component$, 'params');
1867
+ proxy.queryParams = this.proxyObservable(component$, 'queryParams');
1868
+ proxy.fragment = this.proxyObservable(component$, 'fragment');
1869
+ proxy.data = this.proxyObservable(component$, 'data');
1870
+ return proxy;
1871
+ }
1872
+ /**
1873
+ * Create a wrapped observable that will switch to the latest activated route matched by the given component
1874
+ */
1875
+ proxyObservable(component$, path) {
1876
+ return component$.pipe(
1877
+ // First wait until the component instance is pushed
1878
+ filter((component) => !!component), switchMap((component) => this.currentActivatedRoute$.pipe(filter((current) => current !== null && current.component === component), switchMap((current) => current && current.activatedRoute[path]), distinctUntilChanged())));
1879
+ }
1880
+ /**
1881
+ * Updates the activated route proxy for the given component to the new incoming router state
1882
+ */
1883
+ updateActivatedRouteProxy(component, activatedRoute) {
1884
+ const proxy = this.proxyMap.get(component);
1885
+ if (!proxy) {
1886
+ throw new Error(`Could not find activated route proxy for view`);
1887
+ }
1888
+ proxy._futureSnapshot = activatedRoute._futureSnapshot;
1889
+ proxy._routerState = activatedRoute._routerState;
1890
+ proxy.snapshot = activatedRoute.snapshot;
1891
+ proxy.outlet = activatedRoute.outlet;
1892
+ proxy.component = activatedRoute.component;
1893
+ this.currentActivatedRoute$.next({ component, activatedRoute });
1894
+ }
1895
+ }
1896
+ /** @nocollapse */ IonRouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonRouterOutlet, deps: [{ token: 'name', attribute: true }, { token: 'tabs', attribute: true, optional: true }, { token: i1.Location }, { token: i0.ElementRef }, { token: i3.Router }, { token: i0.NgZone }, { token: i3.ActivatedRoute }, { token: IonRouterOutlet, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
1897
+ /** @nocollapse */ IonRouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonRouterOutlet, selector: "ion-router-outlet", inputs: { animated: "animated", animation: "animation", mode: "mode", swipeGesture: "swipeGesture", name: "name" }, outputs: { stackWillChange: "stackWillChange", stackDidChange: "stackDidChange", activateEvents: "activate", deactivateEvents: "deactivate" }, exportAs: ["outlet"], ngImport: i0 });
1898
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonRouterOutlet, decorators: [{
1899
+ type: Directive,
1900
+ args: [{
1901
+ selector: 'ion-router-outlet',
1902
+ exportAs: 'outlet',
1903
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1904
+ inputs: ['animated', 'animation', 'mode', 'swipeGesture'],
1905
+ }]
1906
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1907
+ type: Attribute,
1908
+ args: ['name']
1909
+ }] }, { type: undefined, decorators: [{
1910
+ type: Optional
1911
+ }, {
1912
+ type: Attribute,
1913
+ args: ['tabs']
1914
+ }] }, { type: i1.Location }, { type: i0.ElementRef }, { type: i3.Router }, { type: i0.NgZone }, { type: i3.ActivatedRoute }, { type: IonRouterOutlet, decorators: [{
1915
+ type: SkipSelf
1916
+ }, {
1917
+ type: Optional
1918
+ }] }]; }, propDecorators: { name: [{
1919
+ type: Input
1920
+ }], stackWillChange: [{
1921
+ type: Output
1922
+ }], stackDidChange: [{
1923
+ type: Output
1924
+ }], activateEvents: [{
1925
+ type: Output,
1926
+ args: ['activate']
1927
+ }], deactivateEvents: [{
1928
+ type: Output,
1929
+ args: ['deactivate']
1930
+ }] } });
1931
+ class OutletInjector {
1932
+ constructor(route, childContexts, parent) {
1933
+ this.route = route;
1934
+ this.childContexts = childContexts;
1935
+ this.parent = parent;
1936
+ }
1937
+ get(token, notFoundValue) {
1938
+ if (token === ActivatedRoute) {
1939
+ return this.route;
1940
+ }
1941
+ if (token === ChildrenOutletContexts) {
1942
+ return this.childContexts;
1943
+ }
1944
+ return this.parent.get(token, notFoundValue);
1945
+ }
1946
+ }
1947
+ // TODO: FW-4785 - Remove this once Angular 15 support is dropped
1948
+ const INPUT_BINDER = new InjectionToken('');
1949
+ /**
1950
+ * Injectable used as a tree-shakable provider for opting in to binding router data to component
1951
+ * inputs.
1952
+ *
1953
+ * The RouterOutlet registers itself with this service when an `ActivatedRoute` is attached or
1954
+ * activated. When this happens, the service subscribes to the `ActivatedRoute` observables (params,
1955
+ * queryParams, data) and sets the inputs of the component using `ComponentRef.setInput`.
1956
+ * Importantly, when an input does not have an item in the route data with a matching key, this
1957
+ * input is set to `undefined`. If it were not done this way, the previous information would be
1958
+ * retained if the data got removed from the route (i.e. if a query parameter is removed).
1959
+ *
1960
+ * The `RouterOutlet` should unregister itself when destroyed via `unsubscribeFromRouteData` so that
1961
+ * the subscriptions are cleaned up.
1962
+ */
1963
+ class RoutedComponentInputBinder {
1964
+ constructor() {
1965
+ this.outletDataSubscriptions = new Map();
1966
+ }
1967
+ bindActivatedRouteToOutletComponent(outlet) {
1968
+ this.unsubscribeFromRouteData(outlet);
1969
+ this.subscribeToRouteData(outlet);
1970
+ }
1971
+ unsubscribeFromRouteData(outlet) {
1972
+ this.outletDataSubscriptions.get(outlet)?.unsubscribe();
1973
+ this.outletDataSubscriptions.delete(outlet);
1974
+ }
1975
+ subscribeToRouteData(outlet) {
1976
+ const { activatedRoute } = outlet;
1977
+ const dataSubscription = combineLatest([activatedRoute.queryParams, activatedRoute.params, activatedRoute.data])
1978
+ .pipe(switchMap(([queryParams, params, data], index) => {
1979
+ data = { ...queryParams, ...params, ...data };
1980
+ // Get the first result from the data subscription synchronously so it's available to
1981
+ // the component as soon as possible (and doesn't require a second change detection).
1982
+ if (index === 0) {
1983
+ return of(data);
1984
+ }
1985
+ // Promise.resolve is used to avoid synchronously writing the wrong data when
1986
+ // two of the Observables in the `combineLatest` stream emit one after
1987
+ // another.
1988
+ return Promise.resolve(data);
1989
+ }))
1990
+ .subscribe((data) => {
1991
+ // Outlet may have been deactivated or changed names to be associated with a different
1992
+ // route
1993
+ if (!outlet.isActivated ||
1994
+ !outlet.activatedComponentRef ||
1995
+ outlet.activatedRoute !== activatedRoute ||
1996
+ activatedRoute.component === null) {
1997
+ this.unsubscribeFromRouteData(outlet);
1998
+ return;
1999
+ }
2000
+ const mirror = reflectComponentType(activatedRoute.component);
2001
+ if (!mirror) {
2002
+ this.unsubscribeFromRouteData(outlet);
2003
+ return;
2004
+ }
2005
+ for (const { templateName } of mirror.inputs) {
2006
+ outlet.activatedComponentRef.setInput(templateName, data[templateName]);
2007
+ }
2008
+ });
2009
+ this.outletDataSubscriptions.set(outlet, dataSubscription);
2010
+ }
2011
+ }
2012
+ /** @nocollapse */ RoutedComponentInputBinder.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RoutedComponentInputBinder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2013
+ /** @nocollapse */ RoutedComponentInputBinder.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RoutedComponentInputBinder });
2014
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RoutedComponentInputBinder, decorators: [{
2015
+ type: Injectable
2016
+ }] });
2017
+ const provideComponentInputBinding = () => {
2018
+ return {
2019
+ provide: INPUT_BINDER,
2020
+ useFactory: componentInputBindingFactory,
2021
+ deps: [Router],
2022
+ };
2023
+ };
2024
+ function componentInputBindingFactory(router) {
2025
+ /**
2026
+ * We cast the router to any here, since the componentInputBindingEnabled
2027
+ * property is not available until Angular v16.
2028
+ */
2029
+ if (router?.componentInputBindingEnabled) {
2030
+ return new RoutedComponentInputBinder();
2031
+ }
2032
+ return null;
2033
+ }
2034
+
2035
+ const BACK_BUTTON_INPUTS = ['color', 'defaultHref', 'disabled', 'icon', 'mode', 'routerAnimation', 'text', 'type'];
2036
+ let IonBackButton = class IonBackButton {
2037
+ constructor(routerOutlet, navCtrl, config, r, z, c) {
2038
+ this.routerOutlet = routerOutlet;
2039
+ this.navCtrl = navCtrl;
2040
+ this.config = config;
2041
+ this.r = r;
2042
+ this.z = z;
2043
+ c.detach();
2044
+ this.el = this.r.nativeElement;
2045
+ }
2046
+ /**
2047
+ * @internal
2048
+ */
2049
+ onClick(ev) {
2050
+ const defaultHref = this.defaultHref || this.config.get('backButtonDefaultHref');
2051
+ if (this.routerOutlet?.canGoBack()) {
2052
+ this.navCtrl.setDirection('back', undefined, undefined, this.routerAnimation);
2053
+ this.routerOutlet.pop();
2054
+ ev.preventDefault();
2055
+ }
2056
+ else if (defaultHref != null) {
2057
+ this.navCtrl.navigateBack(defaultHref, { animation: this.routerAnimation });
2058
+ ev.preventDefault();
2059
+ }
2060
+ }
2061
+ };
2062
+ /** @nocollapse */ IonBackButton.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonBackButton, deps: [{ token: IonRouterOutlet, optional: true }, { token: NavController }, { token: Config }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2063
+ /** @nocollapse */ IonBackButton.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonBackButton, inputs: { color: "color", defaultHref: "defaultHref", disabled: "disabled", icon: "icon", mode: "mode", routerAnimation: "routerAnimation", text: "text", type: "type" }, host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 });
2064
+ IonBackButton = __decorate([
2065
+ ProxyCmp({
2066
+ inputs: BACK_BUTTON_INPUTS,
2067
+ })
2068
+ ], IonBackButton);
2069
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonBackButton, decorators: [{
2070
+ type: Directive,
2071
+ args: [{
2072
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
2073
+ inputs: BACK_BUTTON_INPUTS,
2074
+ }]
2075
+ }], ctorParameters: function () { return [{ type: IonRouterOutlet, decorators: [{
2076
+ type: Optional
2077
+ }] }, { type: NavController }, { type: Config }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { defaultHref: [{
2078
+ type: Input
2079
+ }], routerAnimation: [{
2080
+ type: Input
2081
+ }], onClick: [{
2082
+ type: HostListener,
2083
+ args: ['click', ['$event']]
2084
+ }] } });
2085
+
2086
+ /**
2087
+ * Adds support for Ionic routing directions and animations to the base Angular router link directive.
2088
+ *
2089
+ * When the router link is clicked, the directive will assign the direction and
2090
+ * animation so that the routing integration will transition correctly.
2091
+ */
2092
+ class RouterLinkDelegateDirective {
2093
+ constructor(locationStrategy, navCtrl, elementRef, router, routerLink) {
2094
+ this.locationStrategy = locationStrategy;
2095
+ this.navCtrl = navCtrl;
2096
+ this.elementRef = elementRef;
2097
+ this.router = router;
2098
+ this.routerLink = routerLink;
2099
+ this.routerDirection = 'forward';
2100
+ }
2101
+ ngOnInit() {
2102
+ this.updateTargetUrlAndHref();
2103
+ }
2104
+ ngOnChanges() {
2105
+ this.updateTargetUrlAndHref();
2106
+ }
2107
+ updateTargetUrlAndHref() {
2108
+ if (this.routerLink?.urlTree) {
2109
+ const href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.routerLink.urlTree));
2110
+ this.elementRef.nativeElement.href = href;
2111
+ }
2112
+ }
2113
+ /**
2114
+ * @internal
2115
+ */
2116
+ onClick(ev) {
2117
+ this.navCtrl.setDirection(this.routerDirection, undefined, undefined, this.routerAnimation);
2118
+ /**
2119
+ * This prevents the browser from
2120
+ * performing a page reload when pressing
2121
+ * an Ionic component with routerLink.
2122
+ * The page reload interferes with routing
2123
+ * and causes ion-back-button to disappear
2124
+ * since the local history is wiped on reload.
2125
+ */
2126
+ ev.preventDefault();
2127
+ }
2128
+ }
2129
+ /** @nocollapse */ RouterLinkDelegateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkDelegateDirective, deps: [{ token: i1.LocationStrategy }, { token: NavController }, { token: i0.ElementRef }, { token: i3.Router }, { token: i3.RouterLink, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
2130
+ /** @nocollapse */ RouterLinkDelegateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RouterLinkDelegateDirective, selector: ":not(a):not(area)[routerLink]", inputs: { routerDirection: "routerDirection", routerAnimation: "routerAnimation" }, host: { listeners: { "click": "onClick($event)" } }, usesOnChanges: true, ngImport: i0 });
2131
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkDelegateDirective, decorators: [{
2132
+ type: Directive,
2133
+ args: [{
2134
+ selector: ':not(a):not(area)[routerLink]',
2135
+ }]
2136
+ }], ctorParameters: function () { return [{ type: i1.LocationStrategy }, { type: NavController }, { type: i0.ElementRef }, { type: i3.Router }, { type: i3.RouterLink, decorators: [{
2137
+ type: Optional
2138
+ }] }]; }, propDecorators: { routerDirection: [{
2139
+ type: Input
2140
+ }], routerAnimation: [{
2141
+ type: Input
2142
+ }], onClick: [{
2143
+ type: HostListener,
2144
+ args: ['click', ['$event']]
2145
+ }] } });
2146
+ class RouterLinkWithHrefDelegateDirective {
2147
+ constructor(locationStrategy, navCtrl, elementRef, router, routerLink) {
2148
+ this.locationStrategy = locationStrategy;
2149
+ this.navCtrl = navCtrl;
2150
+ this.elementRef = elementRef;
2151
+ this.router = router;
2152
+ this.routerLink = routerLink;
2153
+ this.routerDirection = 'forward';
2154
+ }
2155
+ ngOnInit() {
2156
+ this.updateTargetUrlAndHref();
2157
+ }
2158
+ ngOnChanges() {
2159
+ this.updateTargetUrlAndHref();
2160
+ }
2161
+ updateTargetUrlAndHref() {
2162
+ if (this.routerLink?.urlTree) {
2163
+ const href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.routerLink.urlTree));
2164
+ this.elementRef.nativeElement.href = href;
2165
+ }
2166
+ }
2167
+ /**
2168
+ * @internal
2169
+ */
2170
+ onClick() {
2171
+ this.navCtrl.setDirection(this.routerDirection, undefined, undefined, this.routerAnimation);
2172
+ }
2173
+ }
2174
+ /** @nocollapse */ RouterLinkWithHrefDelegateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkWithHrefDelegateDirective, deps: [{ token: i1.LocationStrategy }, { token: NavController }, { token: i0.ElementRef }, { token: i3.Router }, { token: i3.RouterLink, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
2175
+ /** @nocollapse */ RouterLinkWithHrefDelegateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RouterLinkWithHrefDelegateDirective, selector: "a[routerLink],area[routerLink]", inputs: { routerDirection: "routerDirection", routerAnimation: "routerAnimation" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
2176
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkWithHrefDelegateDirective, decorators: [{
2177
+ type: Directive,
2178
+ args: [{
2179
+ selector: 'a[routerLink],area[routerLink]',
2180
+ }]
2181
+ }], ctorParameters: function () { return [{ type: i1.LocationStrategy }, { type: NavController }, { type: i0.ElementRef }, { type: i3.Router }, { type: i3.RouterLink, decorators: [{
2182
+ type: Optional
2183
+ }] }]; }, propDecorators: { routerDirection: [{
2184
+ type: Input
2185
+ }], routerAnimation: [{
2186
+ type: Input
2187
+ }], onClick: [{
2188
+ type: HostListener,
2189
+ args: ['click']
2190
+ }] } });
2191
+
2192
+ const NAV_INPUTS = ['animated', 'animation', 'root', 'rootParams', 'swipeGesture'];
2193
+ const NAV_METHODS = [
2194
+ 'push',
2195
+ 'insert',
2196
+ 'insertPages',
2197
+ 'pop',
2198
+ 'popTo',
2199
+ 'popToRoot',
2200
+ 'removeIndex',
2201
+ 'setRoot',
2202
+ 'setPages',
2203
+ 'getActive',
2204
+ 'getByIndex',
2205
+ 'canGoBack',
2206
+ 'getPrevious',
2207
+ ];
2208
+ let IonNav = class IonNav {
2209
+ constructor(ref, environmentInjector, injector, angularDelegate, z, c) {
2210
+ this.z = z;
2211
+ c.detach();
2212
+ this.el = ref.nativeElement;
2213
+ ref.nativeElement.delegate = angularDelegate.create(environmentInjector, injector);
2214
+ proxyOutputs(this, this.el, ['ionNavDidChange', 'ionNavWillChange']);
2215
+ }
2216
+ };
2217
+ /** @nocollapse */ IonNav.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonNav, deps: [{ token: i0.ElementRef }, { token: i0.EnvironmentInjector }, { token: i0.Injector }, { token: AngularDelegate }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2218
+ /** @nocollapse */ IonNav.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonNav, inputs: { animated: "animated", animation: "animation", root: "root", rootParams: "rootParams", swipeGesture: "swipeGesture" }, ngImport: i0 });
2219
+ IonNav = __decorate([
2220
+ ProxyCmp({
2221
+ inputs: NAV_INPUTS,
2222
+ methods: NAV_METHODS,
2223
+ })
2224
+ ], IonNav);
2225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonNav, decorators: [{
2226
+ type: Directive,
2227
+ args: [{
2228
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
2229
+ inputs: NAV_INPUTS,
2230
+ }]
2231
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.EnvironmentInjector }, { type: i0.Injector }, { type: AngularDelegate }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; } });
2232
+
2233
+ // eslint-disable-next-line @angular-eslint/directive-class-suffix
2234
+ class IonTabs {
2235
+ constructor(navCtrl) {
2236
+ this.navCtrl = navCtrl;
2237
+ /**
2238
+ * Emitted before the tab view is changed.
2239
+ */
2240
+ this.ionTabsWillChange = new EventEmitter();
2241
+ /**
2242
+ * Emitted after the tab view is changed.
2243
+ */
2244
+ this.ionTabsDidChange = new EventEmitter();
2245
+ this.tabBarSlot = 'bottom';
2246
+ }
2247
+ ngAfterContentInit() {
2248
+ this.detectSlotChanges();
2249
+ }
2250
+ ngAfterContentChecked() {
2251
+ this.detectSlotChanges();
2252
+ }
2253
+ /**
2254
+ * @internal
2255
+ */
2256
+ onStackWillChange({ enteringView, tabSwitch }) {
2257
+ const stackId = enteringView.stackId;
2258
+ if (tabSwitch && stackId !== undefined) {
2259
+ this.ionTabsWillChange.emit({ tab: stackId });
2260
+ }
2261
+ }
2262
+ /**
2263
+ * @internal
2264
+ */
2265
+ onStackDidChange({ enteringView, tabSwitch }) {
2266
+ const stackId = enteringView.stackId;
2267
+ if (tabSwitch && stackId !== undefined) {
2268
+ if (this.tabBar) {
2269
+ this.tabBar.selectedTab = stackId;
2270
+ }
2271
+ this.ionTabsDidChange.emit({ tab: stackId });
2272
+ }
2273
+ }
2274
+ /**
2275
+ * When a tab button is clicked, there are several scenarios:
2276
+ * 1. If the selected tab is currently active (the tab button has been clicked
2277
+ * again), then it should go to the root view for that tab.
2278
+ *
2279
+ * a. Get the saved root view from the router outlet. If the saved root view
2280
+ * matches the tabRootUrl, set the route view to this view including the
2281
+ * navigation extras.
2282
+ * b. If the saved root view from the router outlet does
2283
+ * not match, navigate to the tabRootUrl. No navigation extras are
2284
+ * included.
2285
+ *
2286
+ * 2. If the current tab tab is not currently selected, get the last route
2287
+ * view from the router outlet.
2288
+ *
2289
+ * a. If the last route view exists, navigate to that view including any
2290
+ * navigation extras
2291
+ * b. If the last route view doesn't exist, then navigate
2292
+ * to the default tabRootUrl
2293
+ */
2294
+ select(tabOrEvent) {
2295
+ const isTabString = typeof tabOrEvent === 'string';
2296
+ const tab = isTabString ? tabOrEvent : tabOrEvent.detail.tab;
2297
+ const alreadySelected = this.outlet.getActiveStackId() === tab;
2298
+ const tabRootUrl = `${this.outlet.tabsPrefix}/${tab}`;
2299
+ /**
2300
+ * If this is a nested tab, prevent the event
2301
+ * from bubbling otherwise the outer tabs
2302
+ * will respond to this event too, causing
2303
+ * the app to get directed to the wrong place.
2304
+ */
2305
+ if (!isTabString) {
2306
+ tabOrEvent.stopPropagation();
2307
+ }
2308
+ if (alreadySelected) {
2309
+ const activeStackId = this.outlet.getActiveStackId();
2310
+ const activeView = this.outlet.getLastRouteView(activeStackId);
2311
+ // If on root tab, do not navigate to root tab again
2312
+ if (activeView?.url === tabRootUrl) {
2313
+ return;
2314
+ }
2315
+ const rootView = this.outlet.getRootView(tab);
2316
+ const navigationExtras = rootView && tabRootUrl === rootView.url && rootView.savedExtras;
2317
+ return this.navCtrl.navigateRoot(tabRootUrl, {
2318
+ ...navigationExtras,
2319
+ animated: true,
2320
+ animationDirection: 'back',
2321
+ });
2322
+ }
2323
+ else {
2324
+ const lastRoute = this.outlet.getLastRouteView(tab);
2325
+ /**
2326
+ * If there is a lastRoute, goto that, otherwise goto the fallback url of the
2327
+ * selected tab
2328
+ */
2329
+ const url = lastRoute?.url || tabRootUrl;
2330
+ const navigationExtras = lastRoute?.savedExtras;
2331
+ return this.navCtrl.navigateRoot(url, {
2332
+ ...navigationExtras,
2333
+ animated: true,
2334
+ animationDirection: 'back',
2335
+ });
2336
+ }
2337
+ }
2338
+ getSelected() {
2339
+ return this.outlet.getActiveStackId();
2340
+ }
2341
+ /**
2342
+ * Detects changes to the slot attribute of the tab bar.
2343
+ *
2344
+ * If the slot attribute has changed, then the tab bar
2345
+ * should be relocated to the new slot position.
2346
+ */
2347
+ detectSlotChanges() {
2348
+ this.tabBars.forEach((tabBar) => {
2349
+ // el is a protected attribute from the generated component wrapper
2350
+ const currentSlot = tabBar.el.getAttribute('slot');
2351
+ if (currentSlot !== this.tabBarSlot) {
2352
+ this.tabBarSlot = currentSlot;
2353
+ this.relocateTabBar();
2354
+ }
2355
+ });
2356
+ }
2357
+ /**
2358
+ * Relocates the tab bar to the new slot position.
2359
+ */
2360
+ relocateTabBar() {
2361
+ /**
2362
+ * `el` is a protected attribute from the generated component wrapper.
2363
+ * To avoid having to manually create the wrapper for tab bar, we
2364
+ * cast the tab bar to any and access the protected attribute.
2365
+ */
2366
+ const tabBar = this.tabBar.el;
2367
+ if (this.tabBarSlot === 'top') {
2368
+ /**
2369
+ * A tab bar with a slot of "top" should be inserted
2370
+ * at the top of the container.
2371
+ */
2372
+ this.tabsInner.nativeElement.before(tabBar);
2373
+ }
2374
+ else {
2375
+ /**
2376
+ * A tab bar with a slot of "bottom" or without a slot
2377
+ * should be inserted at the end of the container.
2378
+ */
2379
+ this.tabsInner.nativeElement.after(tabBar);
2380
+ }
2381
+ }
2382
+ }
2383
+ /** @nocollapse */ IonTabs.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonTabs, deps: [{ token: NavController }], target: i0.ɵɵFactoryTarget.Directive });
2384
+ /** @nocollapse */ IonTabs.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonTabs, selector: "ion-tabs", outputs: { ionTabsWillChange: "ionTabsWillChange", ionTabsDidChange: "ionTabsDidChange" }, host: { listeners: { "ionTabButtonClick": "select($event)" } }, viewQueries: [{ propertyName: "tabsInner", first: true, predicate: ["tabsInner"], descendants: true, read: ElementRef, static: true }], ngImport: i0 });
2385
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonTabs, decorators: [{
2386
+ type: Directive,
2387
+ args: [{
2388
+ selector: 'ion-tabs',
2389
+ }]
2390
+ }], ctorParameters: function () { return [{ type: NavController }]; }, propDecorators: { tabsInner: [{
2391
+ type: ViewChild,
2392
+ args: ['tabsInner', { read: ElementRef, static: true }]
2393
+ }], ionTabsWillChange: [{
2394
+ type: Output
2395
+ }], ionTabsDidChange: [{
2396
+ type: Output
2397
+ }], select: [{
2398
+ type: HostListener,
2399
+ args: ['ionTabButtonClick', ['$event']]
2400
+ }] } });
2401
+
2402
+ const raf = (h) => {
2403
+ if (typeof __zone_symbol__requestAnimationFrame === 'function') {
2404
+ return __zone_symbol__requestAnimationFrame(h);
2405
+ }
2406
+ if (typeof requestAnimationFrame === 'function') {
2407
+ return requestAnimationFrame(h);
2408
+ }
2409
+ return setTimeout(h);
2410
+ };
2411
+
2412
+ // TODO(FW-2827): types
2413
+ class ValueAccessor {
2414
+ constructor(injector, elementRef) {
2415
+ this.injector = injector;
2416
+ this.elementRef = elementRef;
2417
+ this.onChange = () => {
2418
+ /**/
2419
+ };
2420
+ this.onTouched = () => {
2421
+ /**/
2422
+ };
2423
+ }
2424
+ writeValue(value) {
2425
+ this.elementRef.nativeElement.value = this.lastValue = value;
2426
+ setIonicClasses(this.elementRef);
2427
+ }
2428
+ /**
2429
+ * Notifies the ControlValueAccessor of a change in the value of the control.
2430
+ *
2431
+ * This is called by each of the ValueAccessor directives when we want to update
2432
+ * the status and validity of the form control. For example with text components this
2433
+ * is called when the ionInput event is fired. For select components this is called
2434
+ * when the ionChange event is fired.
2435
+ *
2436
+ * This also updates the Ionic form status classes on the element.
2437
+ *
2438
+ * @param el The component element.
2439
+ * @param value The new value of the control.
2440
+ */
2441
+ handleValueChange(el, value) {
2442
+ if (el === this.elementRef.nativeElement) {
2443
+ if (value !== this.lastValue) {
2444
+ this.lastValue = value;
2445
+ this.onChange(value);
2446
+ }
2447
+ setIonicClasses(this.elementRef);
2448
+ }
2449
+ }
2450
+ _handleBlurEvent(el) {
2451
+ if (el === this.elementRef.nativeElement) {
2452
+ this.onTouched();
2453
+ setIonicClasses(this.elementRef);
2454
+ }
2455
+ }
2456
+ registerOnChange(fn) {
2457
+ this.onChange = fn;
2458
+ }
2459
+ registerOnTouched(fn) {
2460
+ this.onTouched = fn;
2461
+ }
2462
+ setDisabledState(isDisabled) {
2463
+ this.elementRef.nativeElement.disabled = isDisabled;
2464
+ }
2465
+ ngOnDestroy() {
2466
+ if (this.statusChanges) {
2467
+ this.statusChanges.unsubscribe();
2468
+ }
2469
+ }
2470
+ ngAfterViewInit() {
2471
+ let ngControl;
2472
+ try {
2473
+ ngControl = this.injector.get(NgControl);
2474
+ }
2475
+ catch {
2476
+ /* No FormControl or ngModel binding */
2477
+ }
2478
+ if (!ngControl) {
2479
+ return;
2480
+ }
2481
+ // Listen for changes in validity, disabled, or pending states
2482
+ if (ngControl.statusChanges) {
2483
+ this.statusChanges = ngControl.statusChanges.subscribe(() => setIonicClasses(this.elementRef));
2484
+ }
2485
+ /**
2486
+ * TODO FW-2787: Remove this in favor of https://github.com/angular/angular/issues/10887
2487
+ * whenever it is implemented.
2488
+ */
2489
+ const formControl = ngControl.control;
2490
+ if (formControl) {
2491
+ const methodsToPatch = ['markAsTouched', 'markAllAsTouched', 'markAsUntouched', 'markAsDirty', 'markAsPristine'];
2492
+ methodsToPatch.forEach((method) => {
2493
+ if (typeof formControl[method] !== 'undefined') {
2494
+ const oldFn = formControl[method].bind(formControl);
2495
+ formControl[method] = (...params) => {
2496
+ oldFn(...params);
2497
+ setIonicClasses(this.elementRef);
2498
+ };
2499
+ }
2500
+ });
2501
+ }
2502
+ }
2503
+ }
2504
+ /** @nocollapse */ ValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ValueAccessor, deps: [{ token: i0.Injector }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
2505
+ /** @nocollapse */ ValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: ValueAccessor, host: { listeners: { "ionBlur": "_handleBlurEvent($event.target)" } }, ngImport: i0 });
2506
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ValueAccessor, decorators: [{
2507
+ type: Directive
2508
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.ElementRef }]; }, propDecorators: { _handleBlurEvent: [{
2509
+ type: HostListener,
2510
+ args: ['ionBlur', ['$event.target']]
2511
+ }] } });
2512
+ const setIonicClasses = (element) => {
2513
+ raf(() => {
2514
+ const input = element.nativeElement;
2515
+ const hasValue = input.value != null && input.value.toString().length > 0;
2516
+ const classes = getClasses(input);
2517
+ setClasses(input, classes);
2518
+ const item = input.closest('ion-item');
2519
+ if (item) {
2520
+ if (hasValue) {
2521
+ setClasses(item, [...classes, 'item-has-value']);
2522
+ }
2523
+ else {
2524
+ setClasses(item, classes);
2525
+ }
2526
+ }
2527
+ });
2528
+ };
2529
+ const getClasses = (element) => {
2530
+ const classList = element.classList;
2531
+ const classes = [];
2532
+ for (let i = 0; i < classList.length; i++) {
2533
+ const item = classList.item(i);
2534
+ if (item !== null && startsWith(item, 'ng-')) {
2535
+ classes.push(`ion-${item.substring(3)}`);
2536
+ }
2537
+ }
2538
+ return classes;
2539
+ };
2540
+ const setClasses = (element, classes) => {
2541
+ const classList = element.classList;
2542
+ classList.remove('ion-valid', 'ion-invalid', 'ion-touched', 'ion-untouched', 'ion-dirty', 'ion-pristine');
2543
+ classList.add(...classes);
2544
+ };
2545
+ const startsWith = (input, search) => {
2546
+ return input.substring(0, search.length) === search;
2547
+ };
2548
+
2549
+ /**
2550
+ * Provides a way to customize when activated routes get reused.
2551
+ */
2552
+ class IonicRouteStrategy {
2553
+ /**
2554
+ * Whether the given route should detach for later reuse.
2555
+ */
2556
+ shouldDetach(_route) {
2557
+ return false;
2558
+ }
2559
+ /**
2560
+ * Returns `false`, meaning the route (and its subtree) is never reattached
2561
+ */
2562
+ shouldAttach(_route) {
2563
+ return false;
2564
+ }
2565
+ /**
2566
+ * A no-op; the route is never stored since this strategy never detaches routes for later re-use.
2567
+ */
2568
+ store(_route, _detachedTree) {
2569
+ return;
2570
+ }
2571
+ /**
2572
+ * Returns `null` because this strategy does not store routes for later re-use.
2573
+ */
2574
+ retrieve(_route) {
2575
+ return null;
2576
+ }
2577
+ /**
2578
+ * Determines if a route should be reused.
2579
+ * This strategy returns `true` when the future route config and
2580
+ * current route config are identical and all route parameters are identical.
2581
+ */
2582
+ shouldReuseRoute(future, curr) {
2583
+ if (future.routeConfig !== curr.routeConfig) {
2584
+ return false;
2585
+ }
2586
+ // checking router params
2587
+ const futureParams = future.params;
2588
+ const currentParams = curr.params;
2589
+ const keysA = Object.keys(futureParams);
2590
+ const keysB = Object.keys(currentParams);
2591
+ if (keysA.length !== keysB.length) {
2592
+ return false;
2593
+ }
2594
+ // Test for A's keys different from B.
2595
+ for (const key of keysA) {
2596
+ if (currentParams[key] !== futureParams[key]) {
2597
+ return false;
2598
+ }
2599
+ }
2600
+ return true;
2601
+ }
2602
+ }
2603
+
2604
+ /**
2605
+ * Generated bundle index. Do not edit.
2606
+ */
2607
+
2608
+ export { ActionSheetController, AlertController, AngularDelegate, AnimationController, Config, ConfigToken, DomController, GestureController, IonBackButton, IonModal, IonNav, IonPopover, IonRouterOutlet, IonTabs, IonicRouteStrategy, LoadingController, MenuController, ModalController, NavController, NavParams, PickerController, Platform, PopoverController, ProxyCmp, RouterLinkDelegateDirective, RouterLinkWithHrefDelegateDirective, ToastController, ValueAccessor, bindLifecycleEvents, provideComponentInputBinding, raf, setIonicClasses };
2609
+ //# sourceMappingURL=ionic-angular-common.mjs.map