@sbb-esta/lyne-elements-experimental-dev 4.7.0-dev.1773388997 → 4.7.0-dev.1773396173

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 (199) hide show
  1. package/autocomplete-grid/autocomplete-grid/autocomplete-grid.component.js +76 -65
  2. package/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.component.js +52 -72
  3. package/autocomplete-grid/autocomplete-grid-button.js +6 -3
  4. package/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.component.js +17 -2
  5. package/autocomplete-grid/autocomplete-grid-cell.js +7 -4
  6. package/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.component.js +21 -20
  7. package/autocomplete-grid/autocomplete-grid-optgroup.js +6 -3
  8. package/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.component.js +33 -2
  9. package/autocomplete-grid/autocomplete-grid-option.js +9 -4
  10. package/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.component.js +22 -2
  11. package/autocomplete-grid/autocomplete-grid-row.js +7 -4
  12. package/autocomplete-grid/autocomplete-grid.js +6 -3
  13. package/autocomplete-grid.js +21 -9
  14. package/autocomplete-grid.pure.js +15 -7
  15. package/core/datetime/date-helper.js +191 -2
  16. package/core/datetime.js +5 -2
  17. package/core/timetable/access-leg-helper.js +71 -76
  18. package/core/timetable/timetable-helper.js +11 -9
  19. package/core/timetable/timetable-properties.js +1 -0
  20. package/core/timetable.js +7 -3
  21. package/development/autocomplete-grid/autocomplete-grid/autocomplete-grid.component.js +122 -114
  22. package/development/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.component.js +70 -92
  23. package/development/autocomplete-grid/autocomplete-grid-button.js +4 -6
  24. package/development/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.component.js +29 -2
  25. package/development/autocomplete-grid/autocomplete-grid-cell.js +5 -7
  26. package/development/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.component.js +22 -27
  27. package/development/autocomplete-grid/autocomplete-grid-optgroup.js +4 -6
  28. package/development/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.component.js +109 -2
  29. package/development/autocomplete-grid/autocomplete-grid-option.js +7 -7
  30. package/development/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.component.js +91 -2
  31. package/development/autocomplete-grid/autocomplete-grid-row.js +5 -7
  32. package/development/autocomplete-grid/autocomplete-grid.js +4 -6
  33. package/development/autocomplete-grid.js +14 -10
  34. package/development/autocomplete-grid.pure.js +13 -4
  35. package/development/core/datetime/date-helper.js +285 -2
  36. package/development/core/datetime.js +6 -2
  37. package/development/core/timetable/access-leg-helper.js +82 -104
  38. package/development/core/timetable/timetable-helper.js +17 -16
  39. package/development/core/timetable/timetable-properties.js +2 -0
  40. package/development/core/timetable.js +8 -3
  41. package/development/differenceInMinutes-B0dawX-5.js +26 -0
  42. package/development/format-BMkeaqaF.js +1433 -0
  43. package/development/isValid-BYRch7pV.js +53 -0
  44. package/development/journey-summary/journey-summary.component.js +288 -2
  45. package/development/journey-summary.js +5 -8
  46. package/development/journey-summary.pure.js +5 -2
  47. package/development/pearl-chain/pearl-chain.component.js +634 -2
  48. package/development/pearl-chain-time/pearl-chain-time.component.js +306 -2
  49. package/development/pearl-chain-time.js +5 -8
  50. package/development/pearl-chain-time.pure.js +5 -2
  51. package/development/pearl-chain-vertical/pearl-chain-vertical.component.js +28 -2
  52. package/development/pearl-chain-vertical-item/pearl-chain-vertical-item.component.js +393 -2
  53. package/development/pearl-chain-vertical-item.js +5 -8
  54. package/development/pearl-chain-vertical-item.pure.js +5 -2
  55. package/development/pearl-chain-vertical.js +5 -8
  56. package/development/pearl-chain-vertical.pure.js +5 -2
  57. package/development/pearl-chain.js +5 -8
  58. package/development/pearl-chain.pure.js +5 -2
  59. package/development/seat-reservation/common/mapper/icon-mapper.js +71 -168
  60. package/development/seat-reservation/common/mapper/mapper.js +122 -153
  61. package/development/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-bus.js +559 -570
  62. package/development/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-decks.js +972 -992
  63. package/development/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-giruno.js +20367 -20334
  64. package/development/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-others.js +1738 -1731
  65. package/development/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-train.js +9782 -9741
  66. package/development/seat-reservation/common/mapper.js +8 -1
  67. package/development/seat-reservation/common/svgs.js +46 -2
  68. package/development/seat-reservation/common/translations/i18n.js +900 -1118
  69. package/development/seat-reservation/common/translations.js +4 -1
  70. package/development/seat-reservation/common/types.js +2 -0
  71. package/development/seat-reservation/common.js +11 -7
  72. package/development/seat-reservation/seat-reservation/seat-reservation-base-element.js +1230 -1305
  73. package/development/seat-reservation/seat-reservation/seat-reservation.component.js +859 -2
  74. package/development/seat-reservation/seat-reservation-area/seat-reservation-area.component.js +106 -2
  75. package/development/seat-reservation/seat-reservation-area.js +5 -7
  76. package/development/seat-reservation/seat-reservation-graphic/seat-reservation-assets.js +34 -35
  77. package/development/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.js +162 -2
  78. package/development/seat-reservation/seat-reservation-graphic.js +5 -7
  79. package/development/seat-reservation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.js +713 -2
  80. package/development/seat-reservation/seat-reservation-navigation-coach.js +5 -7
  81. package/development/seat-reservation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.js +131 -2
  82. package/development/seat-reservation/seat-reservation-navigation-services.js +5 -7
  83. package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.js +601 -2
  84. package/development/seat-reservation/seat-reservation-place-control.js +5 -7
  85. package/development/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.js +22 -2
  86. package/development/seat-reservation/seat-reservation-scoped.js +5 -7
  87. package/development/seat-reservation/seat-reservation.js +6 -7
  88. package/development/seat-reservation.js +28 -15
  89. package/development/seat-reservation.pure.js +28 -10
  90. package/development/timetable-duration/timetable-duration.component.js +108 -2
  91. package/development/timetable-duration.js +5 -8
  92. package/development/timetable-duration.pure.js +5 -2
  93. package/development/timetable-row/timetable-row.component.js +781 -2
  94. package/development/timetable-row.js +13 -8
  95. package/development/timetable-row.pure.js +12 -2
  96. package/development/toDate-BWb6Z1JD.js +24 -0
  97. package/differenceInMinutes-COvvdYsJ.js +23 -0
  98. package/format-CmKROkbc.js +1186 -0
  99. package/isValid-m3_OsPaB.js +45 -0
  100. package/journey-summary/journey-summary.component.js +194 -2
  101. package/journey-summary.js +4 -5
  102. package/journey-summary.pure.js +4 -2
  103. package/package.json +2 -2
  104. package/pearl-chain/pearl-chain.component.js +165 -2
  105. package/pearl-chain-time/pearl-chain-time.component.js +157 -2
  106. package/pearl-chain-time.js +4 -5
  107. package/pearl-chain-time.pure.js +4 -2
  108. package/pearl-chain-vertical/pearl-chain-vertical.component.js +17 -2
  109. package/pearl-chain-vertical-item/pearl-chain-vertical-item.component.js +77 -2
  110. package/pearl-chain-vertical-item.js +4 -5
  111. package/pearl-chain-vertical-item.pure.js +4 -2
  112. package/pearl-chain-vertical.js +4 -5
  113. package/pearl-chain-vertical.pure.js +4 -2
  114. package/pearl-chain.js +4 -5
  115. package/pearl-chain.pure.js +4 -2
  116. package/seat-reservation/common/mapper/icon-mapper.js +71 -71
  117. package/seat-reservation/common/mapper/mapper.js +89 -95
  118. package/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-bus.js +558 -568
  119. package/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-decks.js +970 -989
  120. package/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-giruno.js +20366 -20332
  121. package/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-others.js +1737 -1729
  122. package/seat-reservation/common/mapper/sample-data/seat-reservation-sample-data-train.js +9781 -9739
  123. package/seat-reservation/common/mapper.js +9 -3
  124. package/seat-reservation/common/svgs.js +243 -2
  125. package/seat-reservation/common/translations/i18n.js +891 -1084
  126. package/seat-reservation/common/translations.js +4 -2
  127. package/seat-reservation/common/types.js +1 -0
  128. package/seat-reservation/common.js +15 -9
  129. package/seat-reservation/seat-reservation/seat-reservation-base-element.js +810 -832
  130. package/seat-reservation/seat-reservation/seat-reservation.component.js +420 -2
  131. package/seat-reservation/seat-reservation-area/seat-reservation-area.component.js +51 -2
  132. package/seat-reservation/seat-reservation-area.js +7 -4
  133. package/seat-reservation/seat-reservation-graphic/seat-reservation-assets.js +71 -68
  134. package/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.js +75 -2
  135. package/seat-reservation/seat-reservation-graphic.js +7 -4
  136. package/seat-reservation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.js +234 -2
  137. package/seat-reservation/seat-reservation-navigation-coach.js +7 -4
  138. package/seat-reservation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.js +85 -2
  139. package/seat-reservation/seat-reservation-navigation-services.js +7 -4
  140. package/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.js +203 -2
  141. package/seat-reservation/seat-reservation-place-control.js +7 -4
  142. package/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.js +13 -2
  143. package/seat-reservation/seat-reservation-scoped.js +7 -4
  144. package/seat-reservation/seat-reservation.js +9 -5
  145. package/seat-reservation.js +39 -17
  146. package/seat-reservation.pure.js +32 -15
  147. package/timetable-duration/timetable-duration.component.js +57 -2
  148. package/timetable-duration.js +4 -5
  149. package/timetable-duration.pure.js +4 -2
  150. package/timetable-row/timetable-row.component.js +427 -2
  151. package/timetable-row.js +13 -6
  152. package/timetable-row.pure.js +11 -2
  153. package/toDate-Bw2KTWeq.js +15 -0
  154. package/autocomplete-grid-cell.component-Dak9wlBr.js +0 -24
  155. package/autocomplete-grid-option.component-DNRFHOwc.js +0 -37
  156. package/autocomplete-grid-row.component-DBHZQ0GQ.js +0 -27
  157. package/date-helper-CGproP5d.js +0 -185
  158. package/development/autocomplete-grid-cell.component-BBvM4o2H.js +0 -42
  159. package/development/autocomplete-grid-option.component-QzfM5eIE.js +0 -123
  160. package/development/autocomplete-grid-row.component-H8sCTCkT.js +0 -104
  161. package/development/date-helper-8_Y-PuHh.js +0 -520
  162. package/development/differenceInMinutes-DN_1Rk3O.js +0 -110
  163. package/development/format-Bbrn2bgo.js +0 -1848
  164. package/development/isValid-C-HzKv4v.js +0 -178
  165. package/development/journey-summary.component-uGhZvA4p.js +0 -385
  166. package/development/pearl-chain-time.component-B8mayTWD.js +0 -415
  167. package/development/pearl-chain-vertical-item.component-BDzbcIaf.js +0 -435
  168. package/development/pearl-chain-vertical.component-CswE7b3M.js +0 -39
  169. package/development/pearl-chain.component-wpsTvoSe.js +0 -704
  170. package/development/seat-reservation-area.component-BK92ZtFo.js +0 -138
  171. package/development/seat-reservation-graphic.component-cUnsHh5x.js +0 -193
  172. package/development/seat-reservation-navigation-coach.component-D6Bglus8.js +0 -828
  173. package/development/seat-reservation-navigation-services.component-DYJ6Ddkg.js +0 -179
  174. package/development/seat-reservation-place-control.component-Bg9evKBW.js +0 -726
  175. package/development/seat-reservation-scoped.component-DRQ_I702.js +0 -31
  176. package/development/seat-reservation.component-Cq_aJKR0.js +0 -818
  177. package/development/svgs-C3JMWR26.js +0 -28
  178. package/development/timetable-duration.component-DI0lET17.js +0 -125
  179. package/development/timetable-row.component-CAED6Zwc.js +0 -932
  180. package/development/toDate-Biiv3kyf.js +0 -150
  181. package/differenceInMinutes-Dr9gRqtu.js +0 -27
  182. package/format-CM5exOsN.js +0 -1103
  183. package/isValid-B9oVW3lA.js +0 -36
  184. package/journey-summary.component-Cq_4kaOp.js +0 -264
  185. package/pearl-chain-time.component-DGDW5S1c.js +0 -239
  186. package/pearl-chain-vertical-item.component-G22bWhLU.js +0 -108
  187. package/pearl-chain-vertical.component-CXIDT5RD.js +0 -21
  188. package/pearl-chain.component-DmjkVIva.js +0 -194
  189. package/seat-reservation-area.component-n-9rGn_y.js +0 -75
  190. package/seat-reservation-graphic.component-YTXRmKt0.js +0 -102
  191. package/seat-reservation-navigation-coach.component-YJ0vaYmO.js +0 -333
  192. package/seat-reservation-navigation-services.component-C3xnLJg2.js +0 -127
  193. package/seat-reservation-place-control.component-DmBAfM6K.js +0 -322
  194. package/seat-reservation-scoped.component-DPkz6u17.js +0 -17
  195. package/seat-reservation.component-C_anMkgw.js +0 -364
  196. package/svgs-D9arBcqr.js +0 -26
  197. package/timetable-duration.component-DCu8Phts.js +0 -65
  198. package/timetable-row.component-BVRCB3xK.js +0 -559
  199. package/toDate-p-Tpkb7t.js +0 -16
@@ -1,833 +1,811 @@
1
- import { __esDecorate as e, __runInitializers as t } from "tslib";
2
- import { SbbElement as n } from "@sbb-esta/lyne-elements/core/base-elements.js";
3
- import { forceType as r } from "@sbb-esta/lyne-elements/core/decorators.js";
4
- import { isServer as i } from "lit";
5
- import { isArrowKeyOrPageKeysPressed as a } from "@sbb-esta/lyne-elements/core/a11y.js";
6
- import { eventOptions as ee, property as o, state as s } from "lit/decorators.js";
7
- import { mapCoachInfosToCoachSelection as te, mapIconToSvg as c, mapPlaceAndCoachToSeatReservationPlaceSelection as ne, mapPlaceInfosToPlaceSelection as re } from "../common/mapper.js";
8
- //#region src/elements-experimental/seat-reservation/seat-reservation/seat-reservation-base-element.ts
9
- var l;
10
- (function(e) {
11
- e.right = "right", e.left = "left";
12
- })(l ||= {});
13
- var ie = 3, ae = [
14
- "sa-vo",
15
- "sa-rs",
16
- "sa-abteilkinderwagen",
17
- "sa-wr",
18
- "sa-fa",
19
- "sa-bz",
20
- "sa-rz"
21
- ], u = (() => {
22
- let u = n, d = [], f, p = [], m = [], h, g = [], _ = [], v, y = [], b = [], x, S = [], C = [], w, T = [], E = [], D, O = [], oe = [], k, A = [], j = [], M, N = [], P = [], F, I = [], L = [], R, z = [], B = [], V, H = [], U = [], W, G = [], K = [], q, J = [], Y = [], X, Z = [], Q = [], $;
23
- return class extends u {
24
- static {
25
- let t = typeof Symbol == "function" && Symbol.metadata ? Object.create(u[Symbol.metadata] ?? null) : void 0;
26
- f = [o({
27
- attribute: "seat-reservations",
28
- type: Array
29
- })], h = [o({
30
- attribute: "travel-direction",
31
- type: String
32
- })], v = [r(), o({
33
- attribute: "has-navigation",
34
- type: Boolean
35
- })], x = [r(), o({
36
- attribute: "align-vertical",
37
- type: Boolean,
38
- reflect: !0,
39
- useDefault: !0
40
- })], w = [r(), o({
41
- attribute: "base-grid-size",
42
- type: Number
43
- })], D = [r(), o({
44
- attribute: "height",
45
- type: Number
46
- })], k = [r(), o({
47
- attribute: "max-seat-reservations",
48
- type: Number
49
- })], M = [r(), o({
50
- attribute: "max-bicycle-reservations",
51
- type: Number
52
- })], F = [r(), o({
53
- attribute: "prevent-place-click",
54
- type: Boolean
55
- })], R = [r(), o({
56
- attribute: "preselect-coach-index",
57
- type: Number
58
- })], V = [r(), o({
59
- attribute: "show-title-info",
60
- type: Boolean
61
- })], W = [s()], q = [s()], X = [s()], $ = [ee({ passive: !0 })], e(this, null, f, {
62
- kind: "accessor",
63
- name: "seatReservations",
64
- static: !1,
65
- private: !1,
66
- access: {
67
- has: (e) => "seatReservations" in e,
68
- get: (e) => e.seatReservations,
69
- set: (e, t) => {
70
- e.seatReservations = t;
71
- }
72
- },
73
- metadata: t
74
- }, p, m), e(this, null, h, {
75
- kind: "accessor",
76
- name: "travelDirection",
77
- static: !1,
78
- private: !1,
79
- access: {
80
- has: (e) => "travelDirection" in e,
81
- get: (e) => e.travelDirection,
82
- set: (e, t) => {
83
- e.travelDirection = t;
84
- }
85
- },
86
- metadata: t
87
- }, g, _), e(this, null, v, {
88
- kind: "accessor",
89
- name: "hasNavigation",
90
- static: !1,
91
- private: !1,
92
- access: {
93
- has: (e) => "hasNavigation" in e,
94
- get: (e) => e.hasNavigation,
95
- set: (e, t) => {
96
- e.hasNavigation = t;
97
- }
98
- },
99
- metadata: t
100
- }, y, b), e(this, null, x, {
101
- kind: "accessor",
102
- name: "alignVertical",
103
- static: !1,
104
- private: !1,
105
- access: {
106
- has: (e) => "alignVertical" in e,
107
- get: (e) => e.alignVertical,
108
- set: (e, t) => {
109
- e.alignVertical = t;
110
- }
111
- },
112
- metadata: t
113
- }, S, C), e(this, null, w, {
114
- kind: "accessor",
115
- name: "baseGridSize",
116
- static: !1,
117
- private: !1,
118
- access: {
119
- has: (e) => "baseGridSize" in e,
120
- get: (e) => e.baseGridSize,
121
- set: (e, t) => {
122
- e.baseGridSize = t;
123
- }
124
- },
125
- metadata: t
126
- }, T, E), e(this, null, D, {
127
- kind: "accessor",
128
- name: "height",
129
- static: !1,
130
- private: !1,
131
- access: {
132
- has: (e) => "height" in e,
133
- get: (e) => e.height,
134
- set: (e, t) => {
135
- e.height = t;
136
- }
137
- },
138
- metadata: t
139
- }, O, oe), e(this, null, k, {
140
- kind: "accessor",
141
- name: "maxSeatReservations",
142
- static: !1,
143
- private: !1,
144
- access: {
145
- has: (e) => "maxSeatReservations" in e,
146
- get: (e) => e.maxSeatReservations,
147
- set: (e, t) => {
148
- e.maxSeatReservations = t;
149
- }
150
- },
151
- metadata: t
152
- }, A, j), e(this, null, M, {
153
- kind: "accessor",
154
- name: "maxBicycleReservations",
155
- static: !1,
156
- private: !1,
157
- access: {
158
- has: (e) => "maxBicycleReservations" in e,
159
- get: (e) => e.maxBicycleReservations,
160
- set: (e, t) => {
161
- e.maxBicycleReservations = t;
162
- }
163
- },
164
- metadata: t
165
- }, N, P), e(this, null, F, {
166
- kind: "accessor",
167
- name: "preventPlaceClick",
168
- static: !1,
169
- private: !1,
170
- access: {
171
- has: (e) => "preventPlaceClick" in e,
172
- get: (e) => e.preventPlaceClick,
173
- set: (e, t) => {
174
- e.preventPlaceClick = t;
175
- }
176
- },
177
- metadata: t
178
- }, I, L), e(this, null, R, {
179
- kind: "accessor",
180
- name: "preselectCoachIndex",
181
- static: !1,
182
- private: !1,
183
- access: {
184
- has: (e) => "preselectCoachIndex" in e,
185
- get: (e) => e.preselectCoachIndex,
186
- set: (e, t) => {
187
- e.preselectCoachIndex = t;
188
- }
189
- },
190
- metadata: t
191
- }, z, B), e(this, null, V, {
192
- kind: "accessor",
193
- name: "showTitleInfo",
194
- static: !1,
195
- private: !1,
196
- access: {
197
- has: (e) => "showTitleInfo" in e,
198
- get: (e) => e.showTitleInfo,
199
- set: (e, t) => {
200
- e.showTitleInfo = t;
201
- }
202
- },
203
- metadata: t
204
- }, H, U), e(this, null, W, {
205
- kind: "accessor",
206
- name: "selectedCoachIndex",
207
- static: !1,
208
- private: !1,
209
- access: {
210
- has: (e) => "selectedCoachIndex" in e,
211
- get: (e) => e.selectedCoachIndex,
212
- set: (e, t) => {
213
- e.selectedCoachIndex = t;
214
- }
215
- },
216
- metadata: t
217
- }, G, K), e(this, null, q, {
218
- kind: "accessor",
219
- name: "focusedCoachIndex",
220
- static: !1,
221
- private: !1,
222
- access: {
223
- has: (e) => "focusedCoachIndex" in e,
224
- get: (e) => e.focusedCoachIndex,
225
- set: (e, t) => {
226
- e.focusedCoachIndex = t;
227
- }
228
- },
229
- metadata: t
230
- }, J, Y), e(this, null, X, {
231
- kind: "accessor",
232
- name: "hoveredCoachIndex",
233
- static: !1,
234
- private: !1,
235
- access: {
236
- has: (e) => "hoveredCoachIndex" in e,
237
- get: (e) => e.hoveredCoachIndex,
238
- set: (e, t) => {
239
- e.hoveredCoachIndex = t;
240
- }
241
- },
242
- metadata: t
243
- }, Z, Q), e(this, null, $, {
244
- kind: "method",
245
- name: "coachAreaScrollend",
246
- static: !1,
247
- private: !1,
248
- access: {
249
- has: (e) => "coachAreaScrollend" in e,
250
- get: (e) => e.coachAreaScrollend
251
- },
252
- metadata: t
253
- }, null, d), t && Object.defineProperty(this, Symbol.metadata, {
254
- enumerable: !0,
255
- configurable: !0,
256
- writable: !0,
257
- value: t
258
- });
259
- }
260
- static {
261
- this.events = {
262
- selectedplaces: "selectedplaces",
263
- selectedcoach: "selectedcoach"
264
- };
265
- }
266
- #e;
267
- get seatReservations() {
268
- return this.#e;
269
- }
270
- set seatReservations(e) {
271
- this.#e = e;
272
- }
273
- #t;
274
- get travelDirection() {
275
- return this.#t;
276
- }
277
- set travelDirection(e) {
278
- this.#t = e;
279
- }
280
- #n;
281
- get hasNavigation() {
282
- return this.#n;
283
- }
284
- set hasNavigation(e) {
285
- this.#n = e;
286
- }
287
- #r;
288
- get alignVertical() {
289
- return this.#r;
290
- }
291
- set alignVertical(e) {
292
- this.#r = e;
293
- }
294
- #i;
295
- get baseGridSize() {
296
- return this.#i;
297
- }
298
- set baseGridSize(e) {
299
- this.#i = e;
300
- }
301
- #a;
302
- get height() {
303
- return this.#a;
304
- }
305
- set height(e) {
306
- this.#a = e;
307
- }
308
- #o;
309
- get maxSeatReservations() {
310
- return this.#o;
311
- }
312
- set maxSeatReservations(e) {
313
- this.#o = e;
314
- }
315
- #s;
316
- get maxBicycleReservations() {
317
- return this.#s;
318
- }
319
- set maxBicycleReservations(e) {
320
- this.#s = e;
321
- }
322
- #c;
323
- get preventPlaceClick() {
324
- return this.#c;
325
- }
326
- set preventPlaceClick(e) {
327
- this.#c = e;
328
- }
329
- #l;
330
- get preselectCoachIndex() {
331
- return this.#l;
332
- }
333
- set preselectCoachIndex(e) {
334
- this.#l = e;
335
- }
336
- #u;
337
- get showTitleInfo() {
338
- return this.#u;
339
- }
340
- set showTitleInfo(e) {
341
- this.#u = e;
342
- }
343
- #d;
344
- get selectedCoachIndex() {
345
- return this.#d;
346
- }
347
- set selectedCoachIndex(e) {
348
- this.#d = e;
349
- }
350
- #f;
351
- get focusedCoachIndex() {
352
- return this.#f;
353
- }
354
- set focusedCoachIndex(e) {
355
- this.#f = e;
356
- }
357
- #p;
358
- get hoveredCoachIndex() {
359
- return this.#p;
360
- }
361
- set hoveredCoachIndex(e) {
362
- this.#p = e;
363
- }
364
- constructor() {
365
- super(), this.#e = (t(this, d), t(this, p, null)), this.#t = (t(this, m), t(this, g, "NONE")), this.#n = (t(this, _), t(this, y, !0)), this.#r = (t(this, b), t(this, S, !1)), this.#i = (t(this, C), t(this, T, 16)), this.#a = (t(this, E), t(this, O, null)), this.#o = (t(this, oe), t(this, A, -1)), this.#s = (t(this, j), t(this, N, -1)), this.#c = (t(this, P), t(this, I, !1)), this.#l = (t(this, L), t(this, z, -1)), this.#u = (t(this, B), t(this, H, !1)), this.#d = (t(this, U), t(this, G, -1)), this.#f = (t(this, K), t(this, J, -1)), this.#p = (t(this, Y), t(this, Z, -1)), this.coachBorderPadding = (t(this, Q), 6), this.gapBetweenCoaches = 4, this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.gapBetweenCoachDecks = 48, this.coachNavButtonDim = 0, this.coachItemDetailsElements = [], this.currScrollDirection = l.right, this.maxCalcCoachesWidth = 0, this.scrollCoachesAreaWidth = 0, this.scrollNavigationAreaDim = 0, this.triggerCoachPositionsCollection = [], this.navigationScrollArea = null, this.coachScrollArea = null, this.currSelectedPlace = null, this.currSelectedPlaceElementId = null, this.currSelectedCoachIndex = -1, this.currSelectedDeckIndex = 0, this.preventCoachScrollByPlaceClick = !1, this.selectedSeatReservationPlaces = {
366
- seats: [],
367
- bicycles: []
368
- }, this.seatReservationWithoutNavigationHasFocus = !1, this.isCoachGridFocusable = !1, this.isAutoScrolling = !1, this.isKeyboardNavigation = !1, this.hasMultipleDecks = !1, this.hasSeatReservationNativeFocus = !1, this.keyboardNavigationEvents = {
369
- ArrowLeft: "ArrowLeft",
370
- ArrowRight: "ArrowRight",
371
- ArrowUp: "ArrowUp",
372
- ArrowDown: "ArrowDown",
373
- Tab: "Tab",
374
- Enter: "Enter"
375
- }, this.notAreaElements = [
376
- "DRIVER_AREA",
377
- "DRIVER_AREA_NO_VERTICAL_WALL",
378
- "COACH_PASSAGE",
379
- "COACH_WALL_NO_PASSAGE",
380
- "COMPARTMENT_PASSAGE",
381
- "COMPARTMENT_PASSAGE_HIGH",
382
- "COMPARTMENT_PASSAGE_MIDDLE",
383
- "COMPARTMENT_PASSAGE_LOW"
384
- ], this.overHangingElementInformation = [], this._isRunningInitPreselectCoachIndex = !1, this._lastStartScrollPos = -1, this._prepareServiceIconsNavigation = (e) => e && e?.map(function(e) {
385
- return {
386
- pId: e,
387
- svgName: c[e]?.svgName ? c[e]?.svgName : ""
388
- };
389
- }).filter((e) => ae.indexOf(e.svgName) !== -1).filter((e, t, n) => n.map((e) => e.svgName).indexOf(e.svgName) === t).map((e) => e.pId).slice(0, ie) || [], this.addEventListener("blur", () => this._onLeaveSeatReservationComponent());
390
- }
391
- willUpdate(e) {
392
- if (super.willUpdate(e), e.has("seatReservations") && (this.hasMultipleDecks = this.seatReservations?.length > 1, this._initPrepareSeatReservationData(), this._prepareCoachWidthAndGapCalculations(), this._initSeatReservationPlaceSelection(), this.initNavigationSelectionByScrollEvent()), e.has("baseGridSize") && (this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.style?.setProperty("--sbb-seat-reservation-grid-size", `${this.baseGridSize}px`), this.initNavigationSelectionByScrollEvent()), e.has("height") && this.height) {
393
- let e = this.seatReservations[this.currSelectedDeckIndex] || null;
394
- e?.coachItems.length && (this.baseGridSize = this.height / e.coachItems[0].dimension.h, this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.style?.setProperty("--sbb-seat-reservation-grid-size", `${this.baseGridSize}px`), this.initNavigationSelectionByScrollEvent());
395
- }
396
- e.has("alignVertical") && this.alignVertical && this.initNavigationSelectionByScrollEvent(), e.has("preselectCoachIndex") && (this._isRunningInitPreselectCoachIndex = !0, setTimeout(() => this.scrollToSelectedNavCoach(this.preselectCoachIndex), 1));
397
- }
398
- navigateByDirectionBtn(e) {
399
- this.unfocusPlaceElement();
400
- let t = this.currSelectedCoachIndex;
401
- e == "DIRECTION_LEFT" && t > 0 ? t = this.currSelectedCoachIndex == -1 ? 0 : this.currSelectedCoachIndex - 1 : e == "DIRECTION_RIGHT" && t < this.seatReservations[this.currSelectedDeckIndex]?.coachItems.length - 1 && (t = this.currSelectedCoachIndex == -1 ? 0 : this.currSelectedCoachIndex + 1), this.scrollToSelectedNavCoach(t);
402
- }
403
- _initPrepareSeatReservationData() {
404
- this._determineBaseFontSize(), this.hasMultipleDecks && this._initEmptyCoachDeckOffsets(), this._prepareCoachItemDetailsData();
405
- }
406
- initNavigationSelectionByScrollEvent() {
407
- this.coachScrollArea = this.shadowRoot?.querySelector("#sbb-sr__wrapper-scrollarea"), this.navigationScrollArea = this.shadowRoot?.querySelector("#sbb-sr__navigation-list-coaches");
408
- let e = this.seatReservations ? this.seatReservations[this.currSelectedDeckIndex] : null;
409
- if (e && e.coachItems.length > 0) {
410
- let t = e.coachItems[0].dimension.h * this.baseGridSize + this.coachBorderPadding, n = (this.seatReservations.length - 1) * this.gapBetweenCoachDecks;
411
- this.style?.setProperty("--sbb-seat-reservation-height", `${t * this.seatReservations.length + n}`), this.style?.setProperty("--sbb-seat-reservation-decks", `${this.seatReservations.length}`);
412
- }
413
- if (this.navigationScrollArea) {
414
- this.scrollNavigationAreaDim = this.alignVertical ? this.navigationScrollArea.getBoundingClientRect().height : this.navigationScrollArea.getBoundingClientRect().width;
415
- let e = this.navigationScrollArea.querySelector("ul > li");
416
- if (e) {
417
- let t = e?.getBoundingClientRect();
418
- this.coachNavButtonDim = this.alignVertical ? t.height : t.width;
419
- }
420
- }
421
- if (this.coachScrollArea && e) {
422
- let t = 0;
423
- this.scrollCoachesAreaWidth = this.alignVertical ? this.coachScrollArea.getBoundingClientRect().height : this.coachScrollArea.getBoundingClientRect().width, this.triggerCoachPositionsCollection = e.coachItems.map((e) => {
424
- let n = t, r = this.getCalculatedDimension(e.dimension).w, i = this.overHangingElementInformation.find((t) => t.coachId === e.id), a = i?.overhangingPlaces || i?.overhangingGraphicAreas;
425
- return t += r + (a ? 2 * this.gapBetweenCoaches : this.gapBetweenCoaches), {
426
- start: n,
427
- end: t,
428
- width: r
429
- };
430
- }), this.maxCalcCoachesWidth = t - this.gapBetweenCoaches;
431
- }
432
- }
433
- coachAreaScrollend() {
434
- this._scrollTimeout && clearTimeout(this._scrollTimeout), this._scrollTimeout = setTimeout(() => this._handleCoachAreaScrollendEvent(), 150);
435
- }
436
- onFocusTableCoachAndPreselectPlace(e) {
437
- !this.seatReservationWithoutNavigationHasFocus && !this.hasNavigation && (this.seatReservationWithoutNavigationHasFocus = !0, this.currSelectedCoachIndex = e === 0 ? this.getNextAvailableCoachIndex(-1) : this.getPrevAvailableCoachIndex(e), this.preselectPlaceInCoach());
438
- }
439
- onFocusNavDirectionButton() {
440
- this.focusedCoachIndex = -1;
441
- }
442
- onKeyNavigationNavCoachButton(e, t) {
443
- if (e.key === this.keyboardNavigationEvents.Tab) {
444
- this._handleTabKeyNavigation(e, "navigation", t);
445
- return;
446
- }
447
- a(e) && this.keyboardSeatmapEventHandling(e);
448
- }
449
- _handleTabKeyNavigation(e, t, n) {
450
- let r = e.key, i = e.shiftKey;
451
- r === this.keyboardNavigationEvents.Tab && (t == "navigation" ? (n == this.currSelectedCoachIndex ? !this.currSelectedPlace || !i || this.coachItemDetailsElements[n].isDriverArea || this.focusedCoachIndex == -1 ? this.focusedCoachIndex = n : i && this.currSelectedPlace && (this.focusedCoachIndex = -1, this.focusPlaceElement(this.currSelectedPlace)) : this.focusedCoachIndex = n, this._scrollToSelectedNavigationButton(n)) : t == "seatmap" && (e.preventDefault(), i ? this._navigateCoachNavigationByKeyboard("PREV_TAB") : this._navigateCoachNavigationByKeyboard("NEXT_TAB")));
452
- }
453
- keyboardSeatmapEventHandling(e) {
454
- let t = e.key === this.keyboardNavigationEvents.Tab, n = e.shiftKey && t;
455
- if (!this.hasNavigation && this.currSelectedCoachIndex === 0 && n || this.currSelectedCoachIndex === this.coachItemDetailsElements.length - 1 && t) return;
456
- let r = e.key;
457
- if (this.preventCoachScrollByPlaceClick = !1, !this.hasSeatReservationNativeFocus && (t || n) && (this.hasSeatReservationNativeFocus = !0), t) {
458
- this._handleTabKeyNavigation(e, "seatmap");
459
- return;
460
- }
461
- if (this.currSelectedCoachIndex !== -1 && a(e)) switch (e.preventDefault(), r) {
462
- case this.keyboardNavigationEvents.ArrowLeft:
463
- {
464
- let e = this.alignVertical ? this.keyboardNavigationEvents.ArrowDown : r;
465
- this._navigateToPlaceByKeyboard(e);
466
- }
467
- break;
468
- case this.keyboardNavigationEvents.ArrowRight:
469
- {
470
- let e = this.alignVertical ? this.keyboardNavigationEvents.ArrowUp : r;
471
- this._navigateToPlaceByKeyboard(e);
472
- }
473
- break;
474
- case this.keyboardNavigationEvents.ArrowUp:
475
- {
476
- let e = this.alignVertical ? this.keyboardNavigationEvents.ArrowLeft : r;
477
- this._navigateToPlaceByKeyboard(e);
478
- }
479
- break;
480
- case this.keyboardNavigationEvents.ArrowDown:
481
- {
482
- let e = this.alignVertical ? this.keyboardNavigationEvents.ArrowRight : r;
483
- this._navigateToPlaceByKeyboard(e);
484
- }
485
- break;
486
- default: break;
487
- }
488
- }
489
- preselectPlaceInCoach() {
490
- if (this.isAutoScrolling) {
491
- if (this._isRunningInitPreselectCoachIndex) {
492
- this._isRunningInitPreselectCoachIndex = !1;
493
- return;
494
- }
495
- if (this.coachItemDetailsElements[this.currSelectedCoachIndex] && this.coachItemDetailsElements[this.currSelectedCoachIndex].isDriverArea) {
496
- this._setFocusToSelectedCoachGrid();
497
- return;
498
- }
499
- if (this.isKeyboardNavigation && this.isAutoScrolling) {
500
- let e = this._getClosestPlaceByKeyDirection();
501
- e ? (this.unfocusPlaceElement(), this.focusPlaceElement(e), this.focusedCoachIndex = -1) : this._setFocusToSelectedCoachGrid();
502
- } else this.unfocusPlaceElement(), this.isCoachGridFocusable = !0, this._setFocusToSelectedCoachGrid();
503
- }
504
- }
505
- scrollToSelectedNavCoach(e) {
506
- if (this._isValidCoachIndex(e) && e !== this.currSelectedCoachIndex) {
507
- this.hoveredCoachIndex = e, this.isAutoScrolling = !0, this.isCoachGridFocusable = !0, this.currSelectedCoachIndex = e, this.currSelectedDeckIndex = this._getExistingCoachDeckIndex(), this._setScrollDirectionByCoachIndex();
508
- let t = this._getCoachScrollPositionX();
509
- (this.selectedCoachIndex !== -1 || this.currSelectedCoachIndex > 0) && this._isScrollableToSelectedCoach() ? (this._lastStartScrollPos = this.coachScrollArea.scrollLeft, this.coachScrollArea.scrollTo({
510
- top: this.alignVertical ? t : 0,
511
- left: this.alignVertical ? 0 : t,
512
- behavior: "smooth"
513
- })) : this.updateCurrentSelectedCoach(), this._scrollToSelectedNavigationButton(e);
514
- }
515
- }
516
- focusPlaceElement(e) {
517
- if (this.unfocusPlaceElement(), e) {
518
- this.currSelectedPlace = e, this._setCurrSelectedPlaceElementId(e);
519
- let t = this._getPlaceHtmlElement();
520
- if (t) {
521
- t.setAttribute("keyfocus", "focus");
522
- let n = setTimeout(() => {
523
- let t = this.getPlaceElementId(this.currSelectedDeckIndex, this.currSelectedCoachIndex, e.number);
524
- this._scrollPlaceIntoNearestViewport(t), clearTimeout(n);
525
- }, 0);
526
- }
527
- }
528
- }
529
- unfocusPlaceElement() {
530
- let e = this._getPlaceHtmlElement();
531
- e && (e.setAttribute("keyfocus", "unfocus"), this._setCurrSelectedPlaceElementId(null), this.currSelectedPlace = null);
532
- }
533
- getCalculatedDimension(e, t, n, r) {
534
- return t && !n && (e.h += this.coachBorderOffset * 2), r && (e.h += this.coachBorderOffset), {
535
- w: this.baseGridSize * e.w,
536
- h: this.baseGridSize * e.h
537
- };
538
- }
539
- getCalculatedPosition(e, t, n, r) {
540
- if (n && t) {
541
- let i = r ? n.h : n.h + this.coachBorderOffset;
542
- e.y === 0 ? e.y -= this.coachBorderOffset : e.y + t.h === i && (e.y += this.coachBorderOffset);
543
- }
544
- return {
545
- x: this.baseGridSize * e.x,
546
- y: this.baseGridSize * e.y,
547
- z: e.z
548
- };
549
- }
550
- isElementDirectlyOnBorder(e, t) {
551
- return e.position.y === 0 || e.position.y + e.dimension.h === t.h;
552
- }
553
- getAvailableFreePlacesNumFromCoach(e) {
554
- let t = {
555
- seats: 0,
556
- bicycles: 0
557
- };
558
- return e?.reduce((e, t) => (t.state === "FREE" && (t.type === "SEAT" ? e.seats++ : e.bicycles++), e), t) || t;
559
- }
560
- _handleCoachAreaScrollendEvent() {
561
- let e = this.isAutoScrolling ? this.currSelectedCoachIndex : this._getCoachIndexByScrollTriggerPosition();
562
- if (this.preventCoachScrollByPlaceClick) {
563
- Math.abs(this._lastStartScrollPos - this.coachScrollArea.scrollLeft) > this.baseGridSize * 2 && (this.selectedCoachIndex = e), this.preventCoachScrollByPlaceClick = !1;
564
- return;
565
- }
566
- this._lastStartScrollPos = this.coachScrollArea.scrollLeft, this.hoveredCoachIndex = -1, this.currSelectedCoachIndex === -1 && (this.currSelectedCoachIndex = e), this._isScrollableToSelectedCoach() ? this.currSelectedCoachIndex = e : this.currSelectedCoachIndex = e < this.currSelectedCoachIndex ? this.currSelectedCoachIndex : e, this.isAutoScrolling || this._scrollToSelectedNavigationButton(e), this.preventCoachScrollByPlaceClick = !1, this.updateCurrentSelectedCoach(), this.hasNavigation || (this.preselectPlaceInCoach(), this.isAutoScrolling = !1);
567
- }
568
- _scrollToSelectedNavigationButton(e) {
569
- setTimeout(() => {
570
- if (this.hasNavigation && this.navigationScrollArea) {
571
- let t = this.scrollNavigationAreaDim / 2, n = e * this.coachNavButtonDim - t + this.coachNavButtonDim;
572
- this.navigationScrollArea.scrollTo({
573
- top: this.alignVertical ? n : 0,
574
- left: this.alignVertical ? 0 : n,
575
- behavior: "smooth"
576
- });
577
- }
578
- }, 10);
579
- }
580
- _setScrollDirectionByCoachIndex() {
581
- this.currScrollDirection = this.currSelectedCoachIndex > this.selectedCoachIndex ? l.right : l.left;
582
- }
583
- _getCoachScrollPositionX() {
584
- let e = this.triggerCoachPositionsCollection[this.currSelectedCoachIndex];
585
- return this.isKeyboardNavigation && this.currScrollDirection === l.left && e.width > this.scrollCoachesAreaWidth ? e.end - this.scrollCoachesAreaWidth : e.start;
586
- }
587
- _setFocusToSelectedCoachGrid() {
588
- if (this.isCoachGridFocusable && this.hasSeatReservationNativeFocus) {
589
- this.isCoachGridFocusable = !1;
590
- let e = this.shadowRoot?.querySelector("#sbb-sr-coach-caption-" + this.currSelectedCoachIndex);
591
- e && e.focus();
592
- }
593
- }
594
- _isScrollableToSelectedCoach() {
595
- let e = this.alignVertical ? this.coachScrollArea.scrollTop : this.coachScrollArea.scrollLeft, t = this.alignVertical ? this.coachScrollArea.getBoundingClientRect().height : this.coachScrollArea.getBoundingClientRect().width, n = this.maxCalcCoachesWidth - t, r = this.triggerCoachPositionsCollection[this.currSelectedCoachIndex], i = e === this.triggerCoachPositionsCollection[this.currSelectedCoachIndex].start;
596
- return (e < n || e > r.start) && !i;
597
- }
598
- _getCoachIndexByScrollTriggerPosition() {
599
- let e = (this.alignVertical ? this.coachScrollArea.scrollTop : this.coachScrollArea.scrollLeft) + this.scrollCoachesAreaWidth / 2;
600
- return this.triggerCoachPositionsCollection.findIndex((t) => e >= t.start && e <= t.end);
601
- }
602
- _getFirstPlaceInSelectedCoach() {
603
- let e = null, t = this.seatReservations[this.currSelectedDeckIndex].coachItems[this.currSelectedCoachIndex], n = "cell-" + this.currSelectedDeckIndex + "-" + this.currSelectedCoachIndex + "-0-0", r = this.shadowRoot?.querySelector("#" + n)?.querySelector("sbb-seat-reservation-place-control")?.getAttribute("text") || null;
604
- return t && r && (e = t.places?.find((e) => e.number === r) || null), e;
605
- }
606
- _getSwitchedCoachDeckIndexByKeyNavigation(e, t) {
607
- return !this.currSelectedPlace || e === this.keyboardNavigationEvents.ArrowRight || e === this.keyboardNavigationEvents.ArrowLeft ? null : e === this.keyboardNavigationEvents.ArrowDown && this.currSelectedPlace.position.y + 2 === t.dimension.h && this.seatReservations[this.currSelectedDeckIndex + 1] ? this.currSelectedDeckIndex + 1 : e === this.keyboardNavigationEvents.ArrowUp && this.currSelectedPlace.position.y === 0 && this.seatReservations[this.currSelectedDeckIndex - 1] ? this.currSelectedDeckIndex - 1 : null;
608
- }
609
- _getClosestPlaceByKeyDirection(e) {
610
- let t = this.seatReservations[this.currSelectedDeckIndex].coachItems[this.currSelectedCoachIndex], n = null, r = t.places, i = null;
611
- if (r) {
612
- if (!this.currSelectedPlaceElementId) return this._getFirstPlaceInSelectedCoach();
613
- if (this.currSelectedPlace) {
614
- let a = { ...this.currSelectedPlace.position };
615
- e && (i = this._getSwitchedCoachDeckIndexByKeyNavigation(e, t), i !== null && (r = this.seatReservations[i].coachItems[this.currSelectedCoachIndex].places || [], a.y = i < this.currSelectedDeckIndex ? t.dimension.h : -1));
616
- for (let t of r) e ? t.number !== this.currSelectedPlace?.number && (e === this.keyboardNavigationEvents.ArrowRight && (t.position.y === a.y || t.position.y === a.y - 1) && t.position.x > a.x && (!n || t.position.x < n.position.x) || e === this.keyboardNavigationEvents.ArrowDown && (t.position.x === a.x || t.position.x === a.x + 1) && t.position.y > a.y && (!n || t.position.y < n.position.y) || e === this.keyboardNavigationEvents.ArrowLeft && (t.position.y === a.y || t.position.y === a.y + 1) && t.position.x < a.x && (!n || t.position.x > n.position.x) || e === this.keyboardNavigationEvents.ArrowUp && (t.position.x === a.x || t.position.x === a.x - 1) && t.position.y < a.y && (!n || t.position.y > n.position.y)) && (n = t) : (this.currScrollDirection === l.right && t.position.y === a.y && (!n || t.position.x < n.position.x) || this.currScrollDirection === l.left && t.position.y === a.y && (!n || t.position.x > n.position.x)) && (n = t);
617
- i !== null && n && (this.currSelectedDeckIndex = i);
618
- }
619
- }
620
- return n;
621
- }
622
- _navigateCoachNavigationByKeyboard(e) {
623
- let t = this.focusedCoachIndex === -1 ? this.currSelectedCoachIndex === -1 ? 0 : this.currSelectedCoachIndex : this.focusedCoachIndex, n = e === "NEXT_TAB" ? this.getNextAvailableCoachIndex(t) : this.getPrevAvailableCoachIndex(t);
624
- if (this.hasNavigation) {
625
- let r = this._getPlaceHtmlElement(), i = r ? r.getAttribute("keyfocus") === "focus" : !1;
626
- if (e === "PREV_TAB" && this.selectedCoachIndex === t) if (i || this.currSelectedPlace !== null) {
627
- this.focusedCoachIndex = t, this.unfocusPlaceElement();
628
- return;
629
- } else t === 0 ? this._refocusCurrentFocusedNavCoach(t) : this.focusedCoachIndex = n;
630
- else n === this.currSelectedCoachIndex ? e === "NEXT_TAB" && n === this.coachItemDetailsElements.length - 1 ? this._refocusCurrentFocusedNavCoach(t) : (this.focusedCoachIndex = -1, this.selectedCoachIndex = n, i ? this.focusPlaceElement(this.currSelectedPlace) : (this.isCoachGridFocusable = !0, this._setFocusToSelectedCoachGrid())) : this.focusedCoachIndex = n;
631
- this._scrollToSelectedNavigationButton(n);
632
- } else this.scrollToSelectedNavCoach(n);
633
- }
634
- _refocusCurrentFocusedNavCoach(e) {
635
- this.focusedCoachIndex = -1, setTimeout(() => this.focusedCoachIndex = e, 0);
636
- }
637
- _navigateToPlaceByKeyboard(e) {
638
- if (this.isKeyboardNavigation = !0, this.focusedCoachIndex !== -1 && (this.focusedCoachIndex = -1), !this.preventPlaceClick) {
639
- let t = this._getClosestPlaceByKeyDirection(e);
640
- if (t) this.focusPlaceElement(t);
641
- else if (e === this.keyboardNavigationEvents.ArrowRight || e === this.keyboardNavigationEvents.ArrowLeft || this.alignVertical && (e === this.keyboardNavigationEvents.ArrowUp || e === this.keyboardNavigationEvents.ArrowDown)) {
642
- let t = e === this.keyboardNavigationEvents.ArrowRight ? this.getNextAvailableCoachIndex() : this.getPrevAvailableCoachIndex();
643
- this.scrollToSelectedNavCoach(t);
644
- }
645
- }
646
- }
647
- getNextAvailableCoachIndex(e) {
648
- let t = e ?? this.currSelectedCoachIndex;
649
- return t < this.seatReservations[this.currSelectedDeckIndex].coachItems.length - 1 ? t + 1 : t;
650
- }
651
- getPrevAvailableCoachIndex(e) {
652
- let t = e ?? this.currSelectedCoachIndex;
653
- return t > 0 ? t - 1 : t;
654
- }
655
- updateSelectedSeatReservationPlaces(e) {
656
- let t = e.placeType === "SEAT" ? "seats" : "bicycles", n = e.placeType === "SEAT" ? this.maxSeatReservations : this.maxBicycleReservations, r = this.selectedSeatReservationPlaces[t];
657
- this.selectedSeatReservationPlaces[t] = this._updateSelectedSeatReservationPlaces(r, n, e), this.dispatchEvent(new CustomEvent("selectedplaces", {
658
- bubbles: !0,
659
- composed: !0,
660
- detail: this.selectedSeatReservationPlaces
661
- }));
662
- }
663
- _updateSelectedSeatReservationPlaces(e, t, n) {
664
- if (n.state === "SELECTED") {
665
- let t = this._getDeckIndexByPlaceId(n.id), r = this._getSeatReservationPlaceSelection(n, t);
666
- r && e.push(r);
667
- } else e = e.filter((e) => e.id !== n.id);
668
- if (t > -1 && e.length > t) {
669
- let r = t > 0 ? n : void 0;
670
- e = this._resetAllPlaceSelections(e, r);
671
- }
672
- return e;
673
- }
674
- updateCurrentSelectedPlaceInCoach(e) {
675
- let t = this._getDeckIndexByPlaceId(e.id), n = e.coachIndex;
676
- if (t === null) return;
677
- let r = this.seatReservations[t].coachItems[n].places?.find((t) => t.number == e.number);
678
- if (!r) return;
679
- this.currSelectedDeckIndex = t, this.currSelectedCoachIndex = n, this.currSelectedPlace = r, this.currSelectedCoachIndex !== this.selectedCoachIndex && this.updateCurrentSelectedCoach(), this._setCurrSelectedPlaceElementId(r);
680
- let i = setTimeout(() => {
681
- this._scrollPlaceIntoNearestViewport(e.id), clearTimeout(i);
682
- }, 0);
683
- }
684
- updateCurrentSelectedCoach() {
685
- if (this.currSelectedCoachIndex == this.selectedCoachIndex) return;
686
- this.focusedCoachIndex != -1 && (this.focusedCoachIndex = this.currSelectedCoachIndex), this.selectedCoachIndex = this.currSelectedCoachIndex;
687
- let e = this._getSeatReservationSelectedCoach(this.selectedCoachIndex);
688
- e && this.dispatchEvent(new CustomEvent("selectedcoach", {
689
- bubbles: !0,
690
- composed: !0,
691
- detail: e
692
- }));
693
- }
694
- getPlaceElementId(e, t, n) {
695
- return "seat-reservation__place-button-" + e + "-" + t + "-" + n;
696
- }
697
- _initEmptyCoachDeckOffsets() {
698
- let e = Array(this.seatReservations.length - 1).fill(0);
699
- this.seatReservations[this.seatReservations.length - 1].coachItems.forEach((t) => {
700
- for (let n = 0; n < this.seatReservations.length - 1; n++) {
701
- let r = this.seatReservations[n].coachItems[e[n]];
702
- if (t.id != r?.id) {
703
- let r = {
704
- ...t,
705
- places: void 0,
706
- propertyIds: void 0,
707
- graphicElements: void 0,
708
- serviceElements: void 0,
709
- travelClass: []
710
- };
711
- this.seatReservations[n].coachItems.splice(e[n], 0, r);
712
- }
713
- e[n]++;
714
- }
715
- });
716
- }
717
- _initSeatReservationPlaceSelection() {
718
- this.selectedSeatReservationPlaces.seats = [], this.selectedSeatReservationPlaces.bicycles = [], this.seatReservations?.forEach((e, t) => e.coachItems.map((n, r) => {
719
- n.places?.filter((e) => e.state === "SELECTED")?.forEach((n) => {
720
- let i = re(n, this.getPlaceElementId(t, r, n.number), e.deckCoachIndex, r), a = this._getSeatReservationPlaceSelection(i, t);
721
- a && (a.placeType === "SEAT" ? this.selectedSeatReservationPlaces.seats.push(a) : this.selectedSeatReservationPlaces.bicycles.push(a));
722
- });
723
- }));
724
- }
725
- _resetAllPlaceSelections(e, t) {
726
- for (let n of e) if (!t || t.id !== n.id) {
727
- let e = this.shadowRoot?.getElementById(n.id);
728
- e && e.setAttribute("state", "FREE");
729
- }
730
- return e = t ? e.filter((e) => e.id === t.id) : [], e;
731
- }
732
- _getSeatReservationPlaceSelection(e, t) {
733
- if (t === null) return null;
734
- let n = this.seatReservations[t].coachItems[e.coachIndex], r = n.places?.find((t) => t.number === e.number);
735
- return r ? ne(r, n, e.id, e.deckIndex, e.coachIndex) : null;
736
- }
737
- _getSeatReservationSelectedCoach(e) {
738
- if (!this.seatReservations[this.currSelectedDeckIndex].coachItems[e]) return null;
739
- let t = this.seatReservations[this.currSelectedDeckIndex].coachItems[e];
740
- return te(e, t, this.getAvailableFreePlacesNumFromCoach(t.places));
741
- }
742
- _setCurrSelectedPlaceElementId(e) {
743
- this.currSelectedPlaceElementId = e ? this.getPlaceElementId(this.currSelectedDeckIndex, this.currSelectedCoachIndex, e.number) : null;
744
- }
745
- _determineBaseFontSize() {
746
- if (!i) {
747
- let e = 1 / parseInt(window.getComputedStyle(document.body).fontSize, 10);
748
- this.style?.setProperty("--sbb-seat-reservation-one-px-rem", `${e + "rem"}`);
749
- }
750
- }
751
- _prepareCoachItemDetailsData() {
752
- if (this.seatReservations) {
753
- let e = this.seatReservations[this.seatReservations.length - 1].coachItems;
754
- this.coachItemDetailsElements = [], e.forEach((e, t) => {
755
- let n = [], r = [], i = [];
756
- this.seatReservations.map((e) => e.coachItems[t]).forEach((e) => {
757
- n.push(...e.travelClass), r.push(...e.propertyIds ? e.propertyIds : []), i.push(...e.places ? e.places : []);
758
- }), this.coachItemDetailsElements.push({
759
- id: e.id,
760
- travelClass: this._prepareTravelClassNavigation(n),
761
- propertyIds: this._prepareServiceIconsNavigation(r),
762
- isDriverArea: e.places ? e.places.length === 0 : !0,
763
- driverAreaSide: this._prepareDriverAreaSideNavigation(e),
764
- freePlaces: this.getAvailableFreePlacesNumFromCoach(i),
765
- driverAreaElements: this._setDriverAreasElements(e)
766
- });
767
- });
768
- }
769
- }
770
- _prepareTravelClassNavigation(e) {
771
- return e.indexOf("FIRST") === -1 ? e.indexOf("SECOND") === -1 ? "ANY_CLASS" : "SECOND" : "FIRST";
772
- }
773
- _prepareDriverAreaSideNavigation(e) {
774
- let t = e.graphicElements?.filter((e) => e.icon === "DRIVER_AREA");
775
- if (t && t.length > 0) {
776
- let e = t.find((e) => e.position.x === 0) || !1, n = t.find((e) => e.position.x > 0) || !1;
777
- return {
778
- left: !!e,
779
- right: !!n
780
- };
781
- }
782
- }
783
- _prepareCoachWidthAndGapCalculations() {
784
- this.seatReservations && (this.seatReservations[this.seatReservations.length - 1]?.coachItems)?.forEach((e) => {
785
- let t = this._isOverhangingElementsPresent(e.dimension.w, e.places), n = e.graphicElements?.filter((e) => e.icon && !this.notAreaElements.includes(e.icon)), r = this._isOverhangingElementsPresent(e.dimension.w, n);
786
- this.overHangingElementInformation.push({
787
- coachId: e.id,
788
- overhangingPlaces: t,
789
- overhangingGraphicAreas: r
790
- });
791
- });
792
- }
793
- _getPlaceHtmlElement() {
794
- return this.currSelectedPlaceElementId && this.shadowRoot?.getElementById(this.currSelectedPlaceElementId) || null;
795
- }
796
- _getDeckIndexByPlaceId(e) {
797
- let t = this.shadowRoot?.querySelector("#" + e)?.getAttribute("data-deck-index");
798
- return t && !isNaN(+t) ? +t : null;
799
- }
800
- _isValidCoachIndex(e) {
801
- return e >= 0 && e <= this.seatReservations[this.seatReservations.length - 1].coachItems.length;
802
- }
803
- _getExistingCoachDeckIndex() {
804
- if (this.seatReservations[this.currSelectedDeckIndex].coachItems[this.currSelectedCoachIndex].places !== void 0) return this.currSelectedDeckIndex;
805
- let e = this.seatReservations.findIndex((e) => e.coachItems[this.currSelectedCoachIndex].places !== void 0);
806
- return this.currSelectedDeckIndex >= e ? this.currSelectedDeckIndex : e;
807
- }
808
- _scrollPlaceIntoNearestViewport(e) {
809
- this.shadowRoot?.getElementById(e)?.scrollIntoView({
810
- behavior: "smooth",
811
- block: "nearest",
812
- inline: "nearest"
813
- });
814
- }
815
- _isOverhangingElementsPresent(e, t) {
816
- return t?.some((t) => t.position.x === 0 || t.position.x + t.dimension.w >= e) ?? !1;
817
- }
818
- _setDriverAreasElements(e) {
819
- return e ? {
820
- driverArea: e.graphicElements?.find((e) => e.icon === "DRIVER_AREA"),
821
- driverAreaNoVerticalWall: e.type === "LOCOMOTIVE_COACH" ? e.graphicElements?.find((e) => e.icon === "DRIVER_AREA_NO_VERTICAL_WALL") : void 0
822
- } : {
823
- driverArea: void 0,
824
- driverAreaNoVerticalWall: void 0
825
- };
826
- }
827
- _onLeaveSeatReservationComponent() {
828
- this.hasNavigation && (this.focusedCoachIndex = -1), this.unfocusPlaceElement();
829
- }
830
- };
1
+ var ye = (h) => {
2
+ throw TypeError(h);
3
+ };
4
+ var be = (h, d, f) => d.has(h) || ye("Cannot " + f);
5
+ var u = (h, d, f) => (be(h, d, "read from private field"), f ? f.call(h) : d.get(h)), g = (h, d, f) => d.has(h) ? ye("Cannot add the same private member more than once") : d instanceof WeakSet ? d.add(h) : d.set(h, f), r = (h, d, f, B) => (be(h, d, "write to private field"), B ? B.call(h, f) : d.set(h, f), f);
6
+ import { __esDecorate as v, __runInitializers as n } from "tslib";
7
+ import { isArrowKeyOrPageKeysPressed as Pe } from "@sbb-esta/lyne-elements/core/a11y.js";
8
+ import { SbbElement as Ee } from "@sbb-esta/lyne-elements/core/base-elements.js";
9
+ import { forceType as S } from "@sbb-esta/lyne-elements/core/decorators.js";
10
+ import { isServer as Re } from "lit";
11
+ import { property as C, state as z, eventOptions as Ne } from "lit/decorators.js";
12
+ import { mapIconToSvg as Ae, mapPlaceInfosToPlaceSelection as ke, mapPlaceAndCoachToSeatReservationPlaceSelection as De, mapCoachInfosToCoachSelection as Te } from "../common/mapper.js";
13
+ var I;
14
+ (function(h) {
15
+ h.right = "right", h.left = "left";
16
+ })(I || (I = {}));
17
+ const we = 3, Be = [
18
+ "sa-vo",
19
+ "sa-rs",
20
+ "sa-abteilkinderwagen",
21
+ "sa-wr",
22
+ "sa-fa",
23
+ "sa-bz",
24
+ "sa-rz"
25
+ ];
26
+ let Ke = (() => {
27
+ var x, p, _, m, y, b, P, A, E, R, N, k, D, T, l;
28
+ let h = Ee, d = [], f, B = [], O = [], V, F = [], G = [], L, W = [], H = [], M, K = [], X = [], U, q = [], $ = [], j, Y = [], J = [], Q, Z = [], ee = [], te, se = [], ie = [], ae, ce = [], oe = [], re, ne = [], le = [], he, de = [], ue = [], ge, ve = [], fe = [], Ce, Se = [], Ie = [], xe, pe = [], _e = [], me;
29
+ return l = class extends h {
30
+ constructor() {
31
+ super();
32
+ g(this, x);
33
+ g(this, p);
34
+ g(this, _);
35
+ g(this, m);
36
+ g(this, y);
37
+ g(this, b);
38
+ g(this, P);
39
+ g(this, A);
40
+ g(this, E);
41
+ g(this, R);
42
+ g(this, N);
43
+ g(this, k);
44
+ g(this, D);
45
+ g(this, T);
46
+ r(this, x, (n(this, d), n(this, B, null))), r(this, p, (n(this, O), n(this, F, "NONE"))), r(this, _, (n(this, G), n(this, W, !0))), r(this, m, (n(this, H), n(this, K, !1))), r(this, y, (n(this, X), n(this, q, 16))), r(this, b, (n(this, $), n(this, Y, null))), r(this, P, (n(this, J), n(this, Z, -1))), r(this, A, (n(this, ee), n(this, se, -1))), r(this, E, (n(this, ie), n(this, ce, !1))), r(this, R, (n(this, oe), n(this, ne, -1))), r(this, N, (n(this, le), n(this, de, !1))), r(this, k, (n(this, ue), n(this, ve, -1))), r(this, D, (n(this, fe), n(this, Se, -1))), r(this, T, (n(this, Ie), n(this, pe, -1))), this.coachBorderPadding = (n(this, _e), 6), this.gapBetweenCoaches = 4, this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.gapBetweenCoachDecks = 48, this.coachNavButtonDim = 0, this.coachItemDetailsElements = [], this.currScrollDirection = I.right, this.maxCalcCoachesWidth = 0, this.scrollCoachesAreaWidth = 0, this.scrollNavigationAreaDim = 0, this.triggerCoachPositionsCollection = [], this.navigationScrollArea = null, this.coachScrollArea = null, this.currSelectedPlace = null, this.currSelectedPlaceElementId = null, this.currSelectedCoachIndex = -1, this.currSelectedDeckIndex = 0, this.preventCoachScrollByPlaceClick = !1, this.selectedSeatReservationPlaces = {
47
+ seats: [],
48
+ bicycles: []
49
+ }, this.seatReservationWithoutNavigationHasFocus = !1, this.isCoachGridFocusable = !1, this.isAutoScrolling = !1, this.isKeyboardNavigation = !1, this.hasMultipleDecks = !1, this.hasSeatReservationNativeFocus = !1, this.keyboardNavigationEvents = {
50
+ ArrowLeft: "ArrowLeft",
51
+ ArrowRight: "ArrowRight",
52
+ ArrowUp: "ArrowUp",
53
+ ArrowDown: "ArrowDown",
54
+ Tab: "Tab",
55
+ Enter: "Enter"
56
+ }, this.notAreaElements = [
57
+ "DRIVER_AREA",
58
+ "DRIVER_AREA_NO_VERTICAL_WALL",
59
+ "COACH_PASSAGE",
60
+ "COACH_WALL_NO_PASSAGE",
61
+ "COMPARTMENT_PASSAGE",
62
+ "COMPARTMENT_PASSAGE_HIGH",
63
+ "COMPARTMENT_PASSAGE_MIDDLE",
64
+ "COMPARTMENT_PASSAGE_LOW"
65
+ ], this.overHangingElementInformation = [], this._isRunningInitPreselectCoachIndex = !1, this._lastStartScrollPos = -1, this._prepareServiceIconsNavigation = (e) => {
66
+ if (!e)
67
+ return [];
68
+ const t = e?.map(function(s) {
69
+ return {
70
+ pId: s,
71
+ svgName: Ae[s]?.svgName ? Ae[s]?.svgName : ""
72
+ };
73
+ }).filter((s) => Be.indexOf(s.svgName) !== -1).filter((s, i, a) => a.map((o) => o.svgName).indexOf(s.svgName) === i).map((s) => s.pId).slice(0, we);
74
+ return t || [];
75
+ }, this.addEventListener("blur", () => this._onLeaveSeatReservationComponent());
76
+ }
77
+ /** The seat reservations array contains all coaches and places */
78
+ get seatReservations() {
79
+ return u(this, x);
80
+ }
81
+ set seatReservations(e) {
82
+ r(this, x, e);
83
+ }
84
+ /** Displays an arrow showing what direction does train drive*/
85
+ get travelDirection() {
86
+ return u(this, p);
87
+ }
88
+ set travelDirection(e) {
89
+ r(this, p, e);
90
+ }
91
+ /** The seat reservation navigation can be toggled by this property */
92
+ get hasNavigation() {
93
+ return u(this, _);
94
+ }
95
+ set hasNavigation(e) {
96
+ r(this, _, e);
97
+ }
98
+ /** The seat reservation area is aligned vertically */
99
+ get alignVertical() {
100
+ return u(this, m);
101
+ }
102
+ set alignVertical(e) {
103
+ r(this, m, e);
104
+ }
105
+ /** The seat reservation area's base grid size */
106
+ get baseGridSize() {
107
+ return u(this, y);
108
+ }
109
+ set baseGridSize(e) {
110
+ r(this, y, e);
111
+ }
112
+ /** The seat reservation area's width */
113
+ get height() {
114
+ return u(this, b);
115
+ }
116
+ set height(e) {
117
+ r(this, b, e);
118
+ }
119
+ /** Maximal number of possible clickable seats */
120
+ get maxSeatReservations() {
121
+ return u(this, P);
122
+ }
123
+ set maxSeatReservations(e) {
124
+ r(this, P, e);
125
+ }
126
+ /** Maximal number of possible clickable bicycle places */
127
+ get maxBicycleReservations() {
128
+ return u(this, A);
129
+ }
130
+ set maxBicycleReservations(e) {
131
+ r(this, A, e);
132
+ }
133
+ /** Any click functionality is prevented */
134
+ get preventPlaceClick() {
135
+ return u(this, E);
136
+ }
137
+ set preventPlaceClick(e) {
138
+ r(this, E, e);
139
+ }
140
+ get preselectCoachIndex() {
141
+ return u(this, R);
142
+ }
143
+ set preselectCoachIndex(e) {
144
+ r(this, R, e);
145
+ }
146
+ /** The seat reservation title information at place-controls, navigation-coaches and navigation-services can be toggled by this property */
147
+ get showTitleInfo() {
148
+ return u(this, N);
149
+ }
150
+ set showTitleInfo(e) {
151
+ r(this, N, e);
152
+ }
153
+ get selectedCoachIndex() {
154
+ return u(this, k);
155
+ }
156
+ set selectedCoachIndex(e) {
157
+ r(this, k, e);
158
+ }
159
+ get focusedCoachIndex() {
160
+ return u(this, D);
161
+ }
162
+ set focusedCoachIndex(e) {
163
+ r(this, D, e);
164
+ }
165
+ get hoveredCoachIndex() {
166
+ return u(this, T);
167
+ }
168
+ set hoveredCoachIndex(e) {
169
+ r(this, T, e);
170
+ }
171
+ willUpdate(e) {
172
+ if (super.willUpdate(e), e.has("seatReservations") && (this.hasMultipleDecks = this.seatReservations?.length > 1, this._initPrepareSeatReservationData(), this._prepareCoachWidthAndGapCalculations(), this._initSeatReservationPlaceSelection(), this.initNavigationSelectionByScrollEvent()), e.has("baseGridSize") && (this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.style?.setProperty("--sbb-seat-reservation-grid-size", `${this.baseGridSize}px`), this.initNavigationSelectionByScrollEvent()), e.has("height") && this.height) {
173
+ const t = this.seatReservations[this.currSelectedDeckIndex] || null;
174
+ t?.coachItems.length && (this.baseGridSize = this.height / t.coachItems[0].dimension.h, this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.style?.setProperty("--sbb-seat-reservation-grid-size", `${this.baseGridSize}px`), this.initNavigationSelectionByScrollEvent());
175
+ }
176
+ e.has("alignVertical") && this.alignVertical && this.initNavigationSelectionByScrollEvent(), e.has("preselectCoachIndex") && (this._isRunningInitPreselectCoachIndex = !0, setTimeout(() => this.scrollToSelectedNavCoach(this.preselectCoachIndex), 1));
177
+ }
178
+ navigateByDirectionBtn(e) {
179
+ this.unfocusPlaceElement();
180
+ let t = this.currSelectedCoachIndex;
181
+ e == "DIRECTION_LEFT" && t > 0 ? t = this.currSelectedCoachIndex != -1 ? this.currSelectedCoachIndex - 1 : 0 : e == "DIRECTION_RIGHT" && t < this.seatReservations[this.currSelectedDeckIndex]?.coachItems.length - 1 && (t = this.currSelectedCoachIndex != -1 ? this.currSelectedCoachIndex + 1 : 0), this.scrollToSelectedNavCoach(t);
182
+ }
183
+ /**
184
+ * Data can be prepared once for the entire component
185
+ * in order to avoid recurring iteration processes in rendering.
186
+ */
187
+ _initPrepareSeatReservationData() {
188
+ this._determineBaseFontSize(), this.hasMultipleDecks && this._initEmptyCoachDeckOffsets(), this._prepareCoachItemDetailsData();
189
+ }
190
+ /** Init scroll event handling for coach navigation */
191
+ initNavigationSelectionByScrollEvent() {
192
+ this.coachScrollArea = this.shadowRoot?.querySelector("#sbb-sr__wrapper-scrollarea"), this.navigationScrollArea = this.shadowRoot?.querySelector("#sbb-sr__navigation-list-coaches");
193
+ const e = this.seatReservations ? this.seatReservations[this.currSelectedDeckIndex] : null;
194
+ if (e && e.coachItems.length > 0) {
195
+ const t = e.coachItems[0].dimension.h * this.baseGridSize + this.coachBorderPadding, s = (this.seatReservations.length - 1) * this.gapBetweenCoachDecks;
196
+ this.style?.setProperty("--sbb-seat-reservation-height", `${t * this.seatReservations.length + s}`), this.style?.setProperty("--sbb-seat-reservation-decks", `${this.seatReservations.length}`);
197
+ }
198
+ if (this.navigationScrollArea) {
199
+ this.scrollNavigationAreaDim = this.alignVertical ? this.navigationScrollArea.getBoundingClientRect().height : this.navigationScrollArea.getBoundingClientRect().width;
200
+ const t = this.navigationScrollArea.querySelector("ul > li");
201
+ if (t) {
202
+ const s = t?.getBoundingClientRect();
203
+ this.coachNavButtonDim = this.alignVertical ? s.height : s.width;
204
+ }
205
+ }
206
+ if (this.coachScrollArea && e) {
207
+ let t = 0;
208
+ this.scrollCoachesAreaWidth = this.alignVertical ? this.coachScrollArea.getBoundingClientRect().height : this.coachScrollArea.getBoundingClientRect().width, this.triggerCoachPositionsCollection = e.coachItems.map((s) => {
209
+ const i = t, a = this.getCalculatedDimension(s.dimension).w, o = this.overHangingElementInformation.find((w) => w.coachId === s.id), c = o?.overhangingPlaces || o?.overhangingGraphicAreas;
210
+ return t += a + (c ? 2 * this.gapBetweenCoaches : this.gapBetweenCoaches), {
211
+ start: i,
212
+ end: t,
213
+ width: a
214
+ };
215
+ }), this.maxCalcCoachesWidth = t - this.gapBetweenCoaches;
216
+ }
217
+ }
218
+ /**
219
+ * Scroll event handler managed the end of scrolling inside the coach scroll area.
220
+ * Timeout event handling to check if the scrolling has been completed.
221
+ * It is required because the Safari browser does not handle scrollend event,
222
+ * and we therefore imitate this event -> scrollend.
223
+ */
224
+ coachAreaScrollend() {
225
+ this._scrollTimeout && clearTimeout(this._scrollTimeout), this._scrollTimeout = setTimeout(() => this._handleCoachAreaScrollendEvent(), 150);
226
+ }
227
+ /**
228
+ * If no navigation exists (property setting -> hasNavigation) and a table coach gets the focus,
229
+ * the first place in the coach must be automatically preselected to control the place navigation via keyboard
230
+ *
231
+ * @param focusCoachIndex
232
+ */
233
+ onFocusTableCoachAndPreselectPlace(e) {
234
+ !this.seatReservationWithoutNavigationHasFocus && !this.hasNavigation && (this.seatReservationWithoutNavigationHasFocus = !0, this.currSelectedCoachIndex = e === 0 ? this.getNextAvailableCoachIndex(-1) : this.getPrevAvailableCoachIndex(e), this.preselectPlaceInCoach());
235
+ }
236
+ /** Will be triggered by focus navigation direction */
237
+ onFocusNavDirectionButton() {
238
+ this.focusedCoachIndex = -1;
239
+ }
240
+ /** TAB Key Event handling for Coach Navigation */
241
+ onKeyNavigationNavCoachButton(e, t) {
242
+ if (e.key === this.keyboardNavigationEvents.Tab) {
243
+ this._handleTabKeyNavigation(e, "navigation", t);
244
+ return;
245
+ }
246
+ Pe(e) && this.keyboardSeatmapEventHandling(e);
247
+ }
248
+ /** General TAB Key Event handling for tab navigation inside the coach navigation area and the seatmap area */
249
+ _handleTabKeyNavigation(e, t, s) {
250
+ const i = e.key, a = e.shiftKey;
251
+ i === this.keyboardNavigationEvents.Tab && (t == "navigation" ? (s == this.currSelectedCoachIndex ? !this.currSelectedPlace || !a || this.coachItemDetailsElements[s].isDriverArea || this.focusedCoachIndex == -1 ? this.focusedCoachIndex = s : a && this.currSelectedPlace && (this.focusedCoachIndex = -1, this.focusPlaceElement(this.currSelectedPlace)) : this.focusedCoachIndex = s, this._scrollToSelectedNavigationButton(s)) : t == "seatmap" && (e.preventDefault(), a ? this._navigateCoachNavigationByKeyboard("PREV_TAB") : this._navigateCoachNavigationByKeyboard("NEXT_TAB")));
252
+ }
253
+ /**
254
+ * Initialisation of Keyboard Seatmap event handling to navigation between each places inside a selected coach by using [arrow] keys.
255
+ * With the [TAB] key the user navigation goes to the next coach navigation element and the currently selected place is automatically reset.
256
+ */
257
+ keyboardSeatmapEventHandling(e) {
258
+ const t = e.key === this.keyboardNavigationEvents.Tab, s = e.shiftKey && t;
259
+ if (!this.hasNavigation && this.currSelectedCoachIndex === 0 && s || this.currSelectedCoachIndex === this.coachItemDetailsElements.length - 1 && t)
260
+ return;
261
+ const i = e.key;
262
+ if (this.preventCoachScrollByPlaceClick = !1, !this.hasSeatReservationNativeFocus && (t || s) && (this.hasSeatReservationNativeFocus = !0), t) {
263
+ this._handleTabKeyNavigation(e, "seatmap");
264
+ return;
265
+ }
266
+ if (this.currSelectedCoachIndex !== -1 && Pe(e))
267
+ switch (e.preventDefault(), i) {
268
+ case this.keyboardNavigationEvents.ArrowLeft:
269
+ {
270
+ const a = this.alignVertical ? this.keyboardNavigationEvents.ArrowDown : i;
271
+ this._navigateToPlaceByKeyboard(a);
272
+ }
273
+ break;
274
+ case this.keyboardNavigationEvents.ArrowRight:
275
+ {
276
+ const a = this.alignVertical ? this.keyboardNavigationEvents.ArrowUp : i;
277
+ this._navigateToPlaceByKeyboard(a);
278
+ }
279
+ break;
280
+ case this.keyboardNavigationEvents.ArrowUp:
281
+ {
282
+ const a = this.alignVertical ? this.keyboardNavigationEvents.ArrowLeft : i;
283
+ this._navigateToPlaceByKeyboard(a);
284
+ }
285
+ break;
286
+ case this.keyboardNavigationEvents.ArrowDown:
287
+ {
288
+ const a = this.alignVertical ? this.keyboardNavigationEvents.ArrowRight : i;
289
+ this._navigateToPlaceByKeyboard(a);
290
+ }
291
+ break;
292
+ }
293
+ }
294
+ /**
295
+ * Selects a place inside the coach if navigated via keyboard,
296
+ * otherwise the coach grid is selected (necessary for ScreenReader)
297
+ */
298
+ preselectPlaceInCoach() {
299
+ if (this.isAutoScrolling) {
300
+ if (this._isRunningInitPreselectCoachIndex) {
301
+ this._isRunningInitPreselectCoachIndex = !1;
302
+ return;
303
+ }
304
+ if (this.coachItemDetailsElements[this.currSelectedCoachIndex] && this.coachItemDetailsElements[this.currSelectedCoachIndex].isDriverArea) {
305
+ this._setFocusToSelectedCoachGrid();
306
+ return;
307
+ }
308
+ if (this.isKeyboardNavigation && this.isAutoScrolling) {
309
+ const e = this._getClosestPlaceByKeyDirection();
310
+ e ? (this.unfocusPlaceElement(), this.focusPlaceElement(e), this.focusedCoachIndex = -1) : this._setFocusToSelectedCoachGrid();
311
+ } else
312
+ this.unfocusPlaceElement(), this.isCoachGridFocusable = !0, this._setFocusToSelectedCoachGrid();
313
+ }
314
+ }
315
+ scrollToSelectedNavCoach(e) {
316
+ if (this._isValidCoachIndex(e) && e !== this.currSelectedCoachIndex) {
317
+ this.hoveredCoachIndex = e, this.isAutoScrolling = !0, this.isCoachGridFocusable = !0, this.currSelectedCoachIndex = e, this.currSelectedDeckIndex = this._getExistingCoachDeckIndex(), this._setScrollDirectionByCoachIndex();
318
+ const t = this._getCoachScrollPositionX();
319
+ (this.selectedCoachIndex !== -1 || this.currSelectedCoachIndex > 0) && this._isScrollableToSelectedCoach() ? (this._lastStartScrollPos = this.coachScrollArea.scrollLeft, this.coachScrollArea.scrollTo({
320
+ top: this.alignVertical ? t : 0,
321
+ left: this.alignVertical ? 0 : t,
322
+ behavior: "smooth"
323
+ })) : this.updateCurrentSelectedCoach(), this._scrollToSelectedNavigationButton(e);
324
+ }
325
+ }
326
+ focusPlaceElement(e) {
327
+ if (this.unfocusPlaceElement(), e) {
328
+ this.currSelectedPlace = e, this._setCurrSelectedPlaceElementId(e);
329
+ const t = this._getPlaceHtmlElement();
330
+ if (t) {
331
+ t.setAttribute("keyfocus", "focus");
332
+ const s = setTimeout(() => {
333
+ const i = this.getPlaceElementId(this.currSelectedDeckIndex, this.currSelectedCoachIndex, e.number);
334
+ this._scrollPlaceIntoNearestViewport(i), clearTimeout(s);
335
+ }, 0);
336
+ }
337
+ }
338
+ }
339
+ unfocusPlaceElement() {
340
+ const e = this._getPlaceHtmlElement();
341
+ e && (e.setAttribute("keyfocus", "unfocus"), this._setCurrSelectedPlaceElementId(null), this.currSelectedPlace = null);
342
+ }
343
+ getCalculatedDimension(e, t, s, i) {
344
+ return t && !s && (e.h += this.coachBorderOffset * 2), i && (e.h += this.coachBorderOffset), {
345
+ w: this.baseGridSize * e.w,
346
+ h: this.baseGridSize * e.h
347
+ };
348
+ }
349
+ getCalculatedPosition(e, t, s, i) {
350
+ if (s && t) {
351
+ const a = i ? s.h : s.h + this.coachBorderOffset;
352
+ e.y === 0 ? e.y -= this.coachBorderOffset : e.y + t.h === a && (e.y += this.coachBorderOffset);
353
+ }
354
+ return {
355
+ x: this.baseGridSize * e.x,
356
+ y: this.baseGridSize * e.y,
357
+ z: e.z
358
+ };
359
+ }
360
+ /**
361
+ * detects if a (graphical) element is on the border with its position (upper or lower border).
362
+ * @param baseElement
363
+ * @param coachDimension
364
+ * @protected
365
+ */
366
+ isElementDirectlyOnBorder(e, t) {
367
+ return e.position.y === 0 || e.position.y + e.dimension.h === t.h;
368
+ }
369
+ /**
370
+ * Counts all available seats together depending on the seat type
371
+ *
372
+ * @param places
373
+ * @returns An Object with count of free seats and free bicycle places
374
+ */
375
+ getAvailableFreePlacesNumFromCoach(e) {
376
+ const t = { seats: 0, bicycles: 0 }, s = e?.reduce((i, a) => (a.state !== "FREE" || (a.type === "SEAT" ? i.seats++ : i.bicycles++), i), t);
377
+ return s || t;
378
+ }
379
+ /**
380
+ * At the end of a scroll Event from the coach scrollable area,
381
+ * the reached coach is marked as selected
382
+ */
383
+ _handleCoachAreaScrollendEvent() {
384
+ const e = this.isAutoScrolling ? this.currSelectedCoachIndex : this._getCoachIndexByScrollTriggerPosition();
385
+ if (this.preventCoachScrollByPlaceClick) {
386
+ Math.abs(this._lastStartScrollPos - this.coachScrollArea.scrollLeft) > this.baseGridSize * 2 && (this.selectedCoachIndex = e), this.preventCoachScrollByPlaceClick = !1;
387
+ return;
388
+ }
389
+ this._lastStartScrollPos = this.coachScrollArea.scrollLeft, this.hoveredCoachIndex = -1, this.currSelectedCoachIndex === -1 && (this.currSelectedCoachIndex = e), this._isScrollableToSelectedCoach() ? this.currSelectedCoachIndex = e : this.currSelectedCoachIndex = e < this.currSelectedCoachIndex ? this.currSelectedCoachIndex : e, this.isAutoScrolling || this._scrollToSelectedNavigationButton(e), this.preventCoachScrollByPlaceClick = !1, this.updateCurrentSelectedCoach(), this.hasNavigation || (this.preselectPlaceInCoach(), this.isAutoScrolling = !1);
390
+ }
391
+ /**
392
+ * Performs an automatic main navigation scroll to the specified selectedNavCoachIndex.
393
+ * Calculates the central scroll offset of the nav coach to be selected.
394
+ * @param selectedNavCoachIndex
395
+ */
396
+ _scrollToSelectedNavigationButton(e) {
397
+ setTimeout(() => {
398
+ if (this.hasNavigation && this.navigationScrollArea) {
399
+ const t = this.scrollNavigationAreaDim / 2, i = e * this.coachNavButtonDim - t + this.coachNavButtonDim;
400
+ this.navigationScrollArea.scrollTo({
401
+ top: this.alignVertical ? i : 0,
402
+ left: this.alignVertical ? 0 : i,
403
+ behavior: "smooth"
404
+ });
405
+ }
406
+ }, 10);
407
+ }
408
+ /**
409
+ * Sets the new ScrollDirection by the new given target coach index.
410
+ */
411
+ _setScrollDirectionByCoachIndex() {
412
+ this.currScrollDirection = this.currSelectedCoachIndex > this.selectedCoachIndex ? I.right : I.left;
413
+ }
414
+ /**
415
+ * Returns the scroll start or end position X from the selected coach.
416
+ * In case the user is currently navigating through places by keyboard and goes to previous coach,
417
+ * then we return the end position of the coach to get the closest scroll position of the next focus place.
418
+ * @returns number
419
+ */
420
+ _getCoachScrollPositionX() {
421
+ const e = this.triggerCoachPositionsCollection[this.currSelectedCoachIndex];
422
+ return this.isKeyboardNavigation && this.currScrollDirection === I.left && e.width > this.scrollCoachesAreaWidth ? e.end - this.scrollCoachesAreaWidth : e.start;
423
+ }
424
+ /**
425
+ * Sets the focus on the HTML table (grid) caption element so that the heading is read out when using a ScreenReader.
426
+ */
427
+ _setFocusToSelectedCoachGrid() {
428
+ if (this.isCoachGridFocusable && this.hasSeatReservationNativeFocus) {
429
+ this.isCoachGridFocusable = !1;
430
+ const e = this.shadowRoot?.querySelector("#sbb-sr-coach-caption-" + this.currSelectedCoachIndex);
431
+ e && e.focus();
432
+ }
433
+ }
434
+ /**
435
+ * Returns whether the current scrolled position can be used to scroll to the selected wagon
436
+ * @returns boolean
437
+ */
438
+ _isScrollableToSelectedCoach() {
439
+ const e = this.alignVertical ? this.coachScrollArea.scrollTop : this.coachScrollArea.scrollLeft, t = this.alignVertical ? this.coachScrollArea.getBoundingClientRect().height : this.coachScrollArea.getBoundingClientRect().width, s = this.maxCalcCoachesWidth - t, i = this.triggerCoachPositionsCollection[this.currSelectedCoachIndex], a = e === this.triggerCoachPositionsCollection[this.currSelectedCoachIndex].start;
440
+ return (e < s || e > i.start) && !a;
441
+ }
442
+ /**
443
+ * Returns the coach index which is currently visible in the scroll area
444
+ * @returns number
445
+ */
446
+ _getCoachIndexByScrollTriggerPosition() {
447
+ const t = (this.alignVertical ? this.coachScrollArea.scrollTop : this.coachScrollArea.scrollLeft) + this.scrollCoachesAreaWidth / 2;
448
+ return this.triggerCoachPositionsCollection.findIndex((s) => t >= s.start && t <= s.end);
449
+ }
450
+ /**
451
+ * Get the first place of current selected coach by table cell coordinate 0-0 id.
452
+ * @returns Place or null
453
+ */
454
+ _getFirstPlaceInSelectedCoach() {
455
+ let e = null;
456
+ const t = this.seatReservations[this.currSelectedDeckIndex].coachItems[this.currSelectedCoachIndex], s = "cell-" + this.currSelectedDeckIndex + "-" + this.currSelectedCoachIndex + "-0-0", i = this.shadowRoot?.querySelector("#" + s)?.querySelector("sbb-seat-reservation-place-control")?.getAttribute("text") || null;
457
+ return t && i && (e = t.places?.find((a) => a.number === i) || null), e;
458
+ }
459
+ _getSwitchedCoachDeckIndexByKeyNavigation(e, t) {
460
+ return !this.currSelectedPlace || e === this.keyboardNavigationEvents.ArrowRight || e === this.keyboardNavigationEvents.ArrowLeft ? null : e === this.keyboardNavigationEvents.ArrowDown && this.currSelectedPlace.position.y + 2 === t.dimension.h && this.seatReservations[this.currSelectedDeckIndex + 1] ? this.currSelectedDeckIndex + 1 : e === this.keyboardNavigationEvents.ArrowUp && this.currSelectedPlace.position.y === 0 && this.seatReservations[this.currSelectedDeckIndex - 1] ? this.currSelectedDeckIndex - 1 : null;
461
+ }
462
+ /**
463
+ * To get the correct closest place of current pressed key and the current selected place,
464
+ * we have to investigate the coordinates of each place to find the closest place of the currSelectedPlaceElementId.
465
+ * @param pressedKey
466
+ * @returns Place or null
467
+ */
468
+ _getClosestPlaceByKeyDirection(e) {
469
+ const t = this.seatReservations[this.currSelectedDeckIndex].coachItems[this.currSelectedCoachIndex];
470
+ let s = null, i = t.places, a = null;
471
+ if (i)
472
+ if (this.currSelectedPlaceElementId) {
473
+ if (this.currSelectedPlace) {
474
+ const o = { ...this.currSelectedPlace.position };
475
+ e && (a = this._getSwitchedCoachDeckIndexByKeyNavigation(e, t), a !== null && (i = this.seatReservations[a].coachItems[this.currSelectedCoachIndex].places || [], o.y = a < this.currSelectedDeckIndex ? t.dimension.h : -1));
476
+ for (const c of i)
477
+ e ? c.number !== this.currSelectedPlace?.number && (e === this.keyboardNavigationEvents.ArrowRight && (c.position.y === o.y || c.position.y === o.y - 1) && c.position.x > o.x && (!s || c.position.x < s.position.x) || e === this.keyboardNavigationEvents.ArrowDown && (c.position.x === o.x || c.position.x === o.x + 1) && c.position.y > o.y && (!s || c.position.y < s.position.y) || e === this.keyboardNavigationEvents.ArrowLeft && (c.position.y === o.y || c.position.y === o.y + 1) && c.position.x < o.x && (!s || c.position.x > s.position.x) || e === this.keyboardNavigationEvents.ArrowUp && (c.position.x === o.x || c.position.x === o.x - 1) && c.position.y < o.y && (!s || c.position.y > s.position.y)) && (s = c) : (this.currScrollDirection === I.right && c.position.y === o.y && (!s || c.position.x < s.position.x) || this.currScrollDirection === I.left && c.position.y === o.y && (!s || c.position.x > s.position.x)) && (s = c);
478
+ a !== null && s && (this.currSelectedDeckIndex = a);
479
+ }
480
+ } else
481
+ return this._getFirstPlaceInSelectedCoach();
482
+ return s;
483
+ }
484
+ // Handling for Tab navigation if a place is selected inside the coach.
485
+ // This controls the focused coach from the current selected coach.
486
+ _navigateCoachNavigationByKeyboard(e) {
487
+ const t = this.focusedCoachIndex === -1 ? this.currSelectedCoachIndex === -1 ? 0 : this.currSelectedCoachIndex : this.focusedCoachIndex, s = e === "NEXT_TAB" ? this.getNextAvailableCoachIndex(t) : this.getPrevAvailableCoachIndex(t);
488
+ if (this.hasNavigation) {
489
+ const i = this._getPlaceHtmlElement(), a = i ? i.getAttribute("keyfocus") === "focus" : !1;
490
+ if (e === "PREV_TAB" && this.selectedCoachIndex === t)
491
+ if (a || this.currSelectedPlace !== null) {
492
+ this.focusedCoachIndex = t, this.unfocusPlaceElement();
493
+ return;
494
+ } else t === 0 ? this._refocusCurrentFocusedNavCoach(t) : this.focusedCoachIndex = s;
495
+ else s !== this.currSelectedCoachIndex ? this.focusedCoachIndex = s : e === "NEXT_TAB" && s === this.coachItemDetailsElements.length - 1 ? this._refocusCurrentFocusedNavCoach(t) : (this.focusedCoachIndex = -1, this.selectedCoachIndex = s, a ? this.focusPlaceElement(this.currSelectedPlace) : (this.isCoachGridFocusable = !0, this._setFocusToSelectedCoachGrid()));
496
+ this._scrollToSelectedNavigationButton(s);
497
+ } else
498
+ this.scrollToSelectedNavCoach(s);
499
+ }
500
+ // Refocused the current focused (visual) nav coach to get the native focus back to the navigation
501
+ _refocusCurrentFocusedNavCoach(e) {
502
+ this.focusedCoachIndex = -1, setTimeout(() => this.focusedCoachIndex = e, 0);
503
+ }
504
+ _navigateToPlaceByKeyboard(e) {
505
+ if (this.isKeyboardNavigation = !0, this.focusedCoachIndex !== -1 && (this.focusedCoachIndex = -1), !this.preventPlaceClick) {
506
+ const t = this._getClosestPlaceByKeyDirection(e);
507
+ if (t)
508
+ this.focusPlaceElement(t);
509
+ else if (e === this.keyboardNavigationEvents.ArrowRight || e === this.keyboardNavigationEvents.ArrowLeft || this.alignVertical && (e === this.keyboardNavigationEvents.ArrowUp || e === this.keyboardNavigationEvents.ArrowDown)) {
510
+ const s = e === this.keyboardNavigationEvents.ArrowRight ? this.getNextAvailableCoachIndex() : this.getPrevAvailableCoachIndex();
511
+ this.scrollToSelectedNavCoach(s);
512
+ }
513
+ }
514
+ }
515
+ getNextAvailableCoachIndex(e) {
516
+ const t = e ?? this.currSelectedCoachIndex;
517
+ return t < this.seatReservations[this.currSelectedDeckIndex].coachItems.length - 1 ? t + 1 : t;
518
+ }
519
+ getPrevAvailableCoachIndex(e) {
520
+ const t = e ?? this.currSelectedCoachIndex;
521
+ return t > 0 ? t - 1 : t;
522
+ }
523
+ updateSelectedSeatReservationPlaces(e) {
524
+ const t = e.placeType === "SEAT" ? "seats" : "bicycles", s = e.placeType === "SEAT" ? this.maxSeatReservations : this.maxBicycleReservations, i = this.selectedSeatReservationPlaces[t];
525
+ this.selectedSeatReservationPlaces[t] = this._updateSelectedSeatReservationPlaces(i, s, e), this.dispatchEvent(new CustomEvent("selectedplaces", {
526
+ bubbles: !0,
527
+ composed: !0,
528
+ detail: this.selectedSeatReservationPlaces
529
+ }));
530
+ }
531
+ _updateSelectedSeatReservationPlaces(e, t, s) {
532
+ if (s.state === "SELECTED") {
533
+ const i = this._getDeckIndexByPlaceId(s.id), a = this._getSeatReservationPlaceSelection(s, i);
534
+ a && e.push(a);
535
+ } else
536
+ e = e.filter((i) => i.id !== s.id);
537
+ if (t > -1 && e.length > t) {
538
+ const i = t > 0 ? s : void 0;
539
+ e = this._resetAllPlaceSelections(e, i);
540
+ }
541
+ return e;
542
+ }
543
+ updateCurrentSelectedPlaceInCoach(e) {
544
+ const t = this._getDeckIndexByPlaceId(e.id), s = e.coachIndex;
545
+ if (t === null)
546
+ return;
547
+ const i = this.seatReservations[t].coachItems[s].places?.find((o) => o.number == e.number);
548
+ if (!i)
549
+ return;
550
+ this.currSelectedDeckIndex = t, this.currSelectedCoachIndex = s, this.currSelectedPlace = i, this.currSelectedCoachIndex !== this.selectedCoachIndex && this.updateCurrentSelectedCoach(), this._setCurrSelectedPlaceElementId(i);
551
+ const a = setTimeout(() => {
552
+ this._scrollPlaceIntoNearestViewport(e.id), clearTimeout(a);
553
+ }, 0);
554
+ }
555
+ updateCurrentSelectedCoach() {
556
+ if (this.currSelectedCoachIndex == this.selectedCoachIndex)
557
+ return;
558
+ this.focusedCoachIndex != -1 && (this.focusedCoachIndex = this.currSelectedCoachIndex), this.selectedCoachIndex = this.currSelectedCoachIndex;
559
+ const e = this._getSeatReservationSelectedCoach(this.selectedCoachIndex);
560
+ e && this.dispatchEvent(new CustomEvent("selectedcoach", {
561
+ bubbles: !0,
562
+ composed: !0,
563
+ detail: e
564
+ }));
565
+ }
566
+ getPlaceElementId(e, t, s) {
567
+ return "seat-reservation__place-button-" + e + "-" + t + "-" + s;
568
+ }
569
+ /**
570
+ * In the case of coach layouts with different decks,
571
+ * it is necessary to extend the offset with empty coaches
572
+ * in order to create a stable vehicle layout.
573
+ *
574
+ * [ooo]-[ooo]-[ooo]
575
+ * [ooo]-[ooo]-[ooo]-[ooo]-[ooo]
576
+ */
577
+ _initEmptyCoachDeckOffsets() {
578
+ const e = Array(this.seatReservations.length - 1).fill(0);
579
+ this.seatReservations[this.seatReservations.length - 1].coachItems.forEach((s) => {
580
+ for (let i = 0; i < this.seatReservations.length - 1; i++) {
581
+ const a = this.seatReservations[i].coachItems[e[i]];
582
+ if (s.id != a?.id) {
583
+ const o = {
584
+ ...s,
585
+ places: void 0,
586
+ propertyIds: void 0,
587
+ graphicElements: void 0,
588
+ serviceElements: void 0,
589
+ travelClass: []
590
+ };
591
+ this.seatReservations[i].coachItems.splice(e[i], 0, o);
592
+ }
593
+ e[i]++;
594
+ }
595
+ });
596
+ }
597
+ /**
598
+ * Initialization of SeatReservationPlaceSelection Array based on the transferred places
599
+ * that have the state SELECTED within the seatReservation object
600
+ */
601
+ _initSeatReservationPlaceSelection() {
602
+ this.selectedSeatReservationPlaces.seats = [], this.selectedSeatReservationPlaces.bicycles = [], this.seatReservations?.forEach((e, t) => e.coachItems.map((s, i) => {
603
+ s.places?.filter((a) => a.state === "SELECTED")?.forEach((a) => {
604
+ const o = this.getPlaceElementId(t, i, a.number), c = ke(a, o, e.deckCoachIndex, i), w = this._getSeatReservationPlaceSelection(c, t);
605
+ w && (w.placeType === "SEAT" ? this.selectedSeatReservationPlaces.seats.push(w) : this.selectedSeatReservationPlaces.bicycles.push(w));
606
+ });
607
+ }));
608
+ }
609
+ /**
610
+ * All selected places will be reset or the currentSelectedPlace was given, then we reset all except currentSelectedPlace
611
+ * @param reservationPlaceSelections
612
+ * @param currSelectedPlace
613
+ */
614
+ _resetAllPlaceSelections(e, t) {
615
+ for (const s of e)
616
+ if (!t || t.id !== s.id) {
617
+ const i = this.shadowRoot?.getElementById(s.id);
618
+ i && i.setAttribute("state", "FREE");
619
+ }
620
+ return t ? e = e.filter((s) => s.id === t.id) : e = [], e;
621
+ }
622
+ _getSeatReservationPlaceSelection(e, t) {
623
+ if (t === null)
624
+ return null;
625
+ const s = this.seatReservations[t].coachItems[e.coachIndex], i = s.places?.find((a) => a.number === e.number);
626
+ return i ? De(i, s, e.id, e.deckIndex, e.coachIndex) : null;
627
+ }
628
+ _getSeatReservationSelectedCoach(e) {
629
+ if (!this.seatReservations[this.currSelectedDeckIndex].coachItems[e])
630
+ return null;
631
+ const t = this.seatReservations[this.currSelectedDeckIndex].coachItems[e], s = this.getAvailableFreePlacesNumFromCoach(t.places);
632
+ return Te(e, t, s);
633
+ }
634
+ _setCurrSelectedPlaceElementId(e) {
635
+ this.currSelectedPlaceElementId = e ? this.getPlaceElementId(this.currSelectedDeckIndex, this.currSelectedCoachIndex, e.number) : null;
636
+ }
637
+ /**
638
+ * Preparation of the used documents font-size which needs
639
+ * to be determined in order to correctly calculate CSS values with rem
640
+ * */
641
+ _determineBaseFontSize() {
642
+ if (!Re) {
643
+ const t = 1 / parseInt(window.getComputedStyle(document.body).fontSize, 10);
644
+ this.style?.setProperty("--sbb-seat-reservation-one-px-rem", `${t + "rem"}`);
645
+ }
646
+ }
647
+ /**
648
+ * Prepares data for displaying navigation area.
649
+ * Calculates the values which are not going to change during use of a component:
650
+ * - coach id
651
+ * - list of service icons
652
+ * - class (first, second, any)
653
+ * - whether there is a driver area left or right
654
+ * */
655
+ _prepareCoachItemDetailsData() {
656
+ if (this.seatReservations) {
657
+ const e = this.seatReservations[this.seatReservations.length - 1].coachItems;
658
+ this.coachItemDetailsElements = [], e.forEach((t, s) => {
659
+ const i = [], a = [], o = [];
660
+ this.seatReservations.map((c) => c.coachItems[s]).forEach((c) => {
661
+ i.push(...c.travelClass), a.push(...c.propertyIds ? c.propertyIds : []), o.push(...c.places ? c.places : []);
662
+ }), this.coachItemDetailsElements.push({
663
+ id: t.id,
664
+ travelClass: this._prepareTravelClassNavigation(i),
665
+ propertyIds: this._prepareServiceIconsNavigation(a),
666
+ isDriverArea: t.places ? t.places.length === 0 : !0,
667
+ driverAreaSide: this._prepareDriverAreaSideNavigation(t),
668
+ freePlaces: this.getAvailableFreePlacesNumFromCoach(o),
669
+ driverAreaElements: this._setDriverAreasElements(t)
670
+ });
671
+ });
672
+ }
673
+ }
674
+ _prepareTravelClassNavigation(e) {
675
+ return e.indexOf("FIRST") !== -1 ? "FIRST" : e.indexOf("SECOND") !== -1 ? "SECOND" : "ANY_CLASS";
676
+ }
677
+ _prepareDriverAreaSideNavigation(e) {
678
+ const t = e.graphicElements?.filter((s) => s.icon === "DRIVER_AREA");
679
+ if (t && t.length > 0) {
680
+ const s = t.find((a) => a.position.x === 0) || !1, i = t.find((a) => a.position.x > 0) || !1;
681
+ return {
682
+ left: !!s,
683
+ right: !!i
684
+ };
685
+ }
686
+ }
687
+ _prepareCoachWidthAndGapCalculations() {
688
+ this.seatReservations && this.seatReservations[this.seatReservations.length - 1]?.coachItems?.forEach((t) => {
689
+ const s = this._isOverhangingElementsPresent(t.dimension.w, t.places), i = t.graphicElements?.filter((o) => o.icon && !this.notAreaElements.includes(o.icon)), a = this._isOverhangingElementsPresent(t.dimension.w, i);
690
+ this.overHangingElementInformation.push({
691
+ coachId: t.id,
692
+ overhangingPlaces: s,
693
+ overhangingGraphicAreas: a
694
+ });
695
+ });
696
+ }
697
+ /**
698
+ * Returns the current selected place HTML element by currSelectedPlaceElementId.
699
+ * @returns HTMLElement or null
700
+ */
701
+ _getPlaceHtmlElement() {
702
+ return this.currSelectedPlaceElementId && this.shadowRoot?.getElementById(this.currSelectedPlaceElementId) || null;
703
+ }
704
+ /**
705
+ * Returns the extracted coach deck index from place id
706
+ * @returns number
707
+ */
708
+ _getDeckIndexByPlaceId(e) {
709
+ const t = this.shadowRoot?.querySelector("#" + e)?.getAttribute("data-deck-index");
710
+ return t && !isNaN(+t) ? +t : null;
711
+ }
712
+ _isValidCoachIndex(e) {
713
+ return e >= 0 && e <= this.seatReservations[this.seatReservations.length - 1].coachItems.length;
714
+ }
715
+ /**
716
+ * Returns existing coach deck index depending on the selected coach.
717
+ * This method is necessary to get an available coach deck index during keyboard navigation, which can vary between coaches with different decks.
718
+ * For example, when navigating from a coach with two decks to a coach with one deck.
719
+ *
720
+ * [ooo]-[ooo]-[ooo]
721
+ * [ooo]-[ooo]-[ooo]-[ooo]-[ooo]
722
+ *
723
+ * @returns number
724
+ */
725
+ _getExistingCoachDeckIndex() {
726
+ if (this.seatReservations[this.currSelectedDeckIndex].coachItems[this.currSelectedCoachIndex].places !== void 0)
727
+ return this.currSelectedDeckIndex;
728
+ const e = this.seatReservations.findIndex((t) => t.coachItems[this.currSelectedCoachIndex].places !== void 0);
729
+ return this.currSelectedDeckIndex >= e ? this.currSelectedDeckIndex : e;
730
+ }
731
+ /**
732
+ * If a selected place is slightly hidden by the overflow scroll content and is still clicked,
733
+ * the method tries to scroll the selected place into the nearest viewport, so that it is completely visible.
734
+ *
735
+ * @param placeId
736
+ */
737
+ _scrollPlaceIntoNearestViewport(e) {
738
+ this.shadowRoot?.getElementById(e)?.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
739
+ }
740
+ /**
741
+ * checks if any places or graphical elements (e.g. toilet area, etc.) are overhanging the coach borders
742
+ * @param coachItemWidth
743
+ * @param elements
744
+ */
745
+ _isOverhangingElementsPresent(e, t) {
746
+ return t?.some((s) => s.position.x === 0 || s.position.x + s.dimension.w >= e) ?? !1;
747
+ }
748
+ /**
749
+ * collect information about the driverAreas for one coach
750
+ * @param coachItem
751
+ * @private
752
+ */
753
+ _setDriverAreasElements(e) {
754
+ if (e) {
755
+ const t = e.graphicElements?.find((i) => i.icon === "DRIVER_AREA"), s = e.type === "LOCOMOTIVE_COACH" ? e.graphicElements?.find((i) => i.icon === "DRIVER_AREA_NO_VERTICAL_WALL") : void 0;
756
+ return {
757
+ driverArea: t,
758
+ driverAreaNoVerticalWall: s
759
+ };
760
+ }
761
+ return {
762
+ driverArea: void 0,
763
+ driverAreaNoVerticalWall: void 0
764
+ };
765
+ }
766
+ /**
767
+ * Is called when the SeatReservation loses focus, what happens when the user tabs out or clicks somewhere else.
768
+ * Then we reset the focused elements.
769
+ */
770
+ _onLeaveSeatReservationComponent() {
771
+ this.hasNavigation && (this.focusedCoachIndex = -1), this.unfocusPlaceElement();
772
+ }
773
+ }, x = new WeakMap(), p = new WeakMap(), _ = new WeakMap(), m = new WeakMap(), y = new WeakMap(), b = new WeakMap(), P = new WeakMap(), A = new WeakMap(), E = new WeakMap(), R = new WeakMap(), N = new WeakMap(), k = new WeakMap(), D = new WeakMap(), T = new WeakMap(), (() => {
774
+ const e = typeof Symbol == "function" && Symbol.metadata ? Object.create(h[Symbol.metadata] ?? null) : void 0;
775
+ f = [C({ attribute: "seat-reservations", type: Array })], V = [C({ attribute: "travel-direction", type: String })], L = [S(), C({ attribute: "has-navigation", type: Boolean })], M = [S(), C({ attribute: "align-vertical", type: Boolean, reflect: !0, useDefault: !0 })], U = [S(), C({ attribute: "base-grid-size", type: Number })], j = [S(), C({ attribute: "height", type: Number })], Q = [S(), C({ attribute: "max-seat-reservations", type: Number })], te = [S(), C({ attribute: "max-bicycle-reservations", type: Number })], ae = [S(), C({ attribute: "prevent-place-click", type: Boolean })], re = [S(), C({ attribute: "preselect-coach-index", type: Number })], he = [S(), C({ attribute: "show-title-info", type: Boolean })], ge = [z()], Ce = [z()], xe = [z()], me = [Ne({ passive: !0 })], v(l, null, f, { kind: "accessor", name: "seatReservations", static: !1, private: !1, access: { has: (t) => "seatReservations" in t, get: (t) => t.seatReservations, set: (t, s) => {
776
+ t.seatReservations = s;
777
+ } }, metadata: e }, B, O), v(l, null, V, { kind: "accessor", name: "travelDirection", static: !1, private: !1, access: { has: (t) => "travelDirection" in t, get: (t) => t.travelDirection, set: (t, s) => {
778
+ t.travelDirection = s;
779
+ } }, metadata: e }, F, G), v(l, null, L, { kind: "accessor", name: "hasNavigation", static: !1, private: !1, access: { has: (t) => "hasNavigation" in t, get: (t) => t.hasNavigation, set: (t, s) => {
780
+ t.hasNavigation = s;
781
+ } }, metadata: e }, W, H), v(l, null, M, { kind: "accessor", name: "alignVertical", static: !1, private: !1, access: { has: (t) => "alignVertical" in t, get: (t) => t.alignVertical, set: (t, s) => {
782
+ t.alignVertical = s;
783
+ } }, metadata: e }, K, X), v(l, null, U, { kind: "accessor", name: "baseGridSize", static: !1, private: !1, access: { has: (t) => "baseGridSize" in t, get: (t) => t.baseGridSize, set: (t, s) => {
784
+ t.baseGridSize = s;
785
+ } }, metadata: e }, q, $), v(l, null, j, { kind: "accessor", name: "height", static: !1, private: !1, access: { has: (t) => "height" in t, get: (t) => t.height, set: (t, s) => {
786
+ t.height = s;
787
+ } }, metadata: e }, Y, J), v(l, null, Q, { kind: "accessor", name: "maxSeatReservations", static: !1, private: !1, access: { has: (t) => "maxSeatReservations" in t, get: (t) => t.maxSeatReservations, set: (t, s) => {
788
+ t.maxSeatReservations = s;
789
+ } }, metadata: e }, Z, ee), v(l, null, te, { kind: "accessor", name: "maxBicycleReservations", static: !1, private: !1, access: { has: (t) => "maxBicycleReservations" in t, get: (t) => t.maxBicycleReservations, set: (t, s) => {
790
+ t.maxBicycleReservations = s;
791
+ } }, metadata: e }, se, ie), v(l, null, ae, { kind: "accessor", name: "preventPlaceClick", static: !1, private: !1, access: { has: (t) => "preventPlaceClick" in t, get: (t) => t.preventPlaceClick, set: (t, s) => {
792
+ t.preventPlaceClick = s;
793
+ } }, metadata: e }, ce, oe), v(l, null, re, { kind: "accessor", name: "preselectCoachIndex", static: !1, private: !1, access: { has: (t) => "preselectCoachIndex" in t, get: (t) => t.preselectCoachIndex, set: (t, s) => {
794
+ t.preselectCoachIndex = s;
795
+ } }, metadata: e }, ne, le), v(l, null, he, { kind: "accessor", name: "showTitleInfo", static: !1, private: !1, access: { has: (t) => "showTitleInfo" in t, get: (t) => t.showTitleInfo, set: (t, s) => {
796
+ t.showTitleInfo = s;
797
+ } }, metadata: e }, de, ue), v(l, null, ge, { kind: "accessor", name: "selectedCoachIndex", static: !1, private: !1, access: { has: (t) => "selectedCoachIndex" in t, get: (t) => t.selectedCoachIndex, set: (t, s) => {
798
+ t.selectedCoachIndex = s;
799
+ } }, metadata: e }, ve, fe), v(l, null, Ce, { kind: "accessor", name: "focusedCoachIndex", static: !1, private: !1, access: { has: (t) => "focusedCoachIndex" in t, get: (t) => t.focusedCoachIndex, set: (t, s) => {
800
+ t.focusedCoachIndex = s;
801
+ } }, metadata: e }, Se, Ie), v(l, null, xe, { kind: "accessor", name: "hoveredCoachIndex", static: !1, private: !1, access: { has: (t) => "hoveredCoachIndex" in t, get: (t) => t.hoveredCoachIndex, set: (t, s) => {
802
+ t.hoveredCoachIndex = s;
803
+ } }, metadata: e }, pe, _e), v(l, null, me, { kind: "method", name: "coachAreaScrollend", static: !1, private: !1, access: { has: (t) => "coachAreaScrollend" in t, get: (t) => t.coachAreaScrollend }, metadata: e }, null, d), e && Object.defineProperty(l, Symbol.metadata, { enumerable: !0, configurable: !0, writable: !0, value: e });
804
+ })(), l.events = {
805
+ selectedplaces: "selectedplaces",
806
+ selectedcoach: "selectedcoach"
807
+ }, l;
831
808
  })();
832
- //#endregion
833
- export { u as SeatReservationBaseElement };
809
+ export {
810
+ Ke as SeatReservationBaseElement
811
+ };