@telia/teddy 0.7.16 → 0.7.26

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 (72) hide show
  1. package/dist/components/card/card.cjs +52 -52
  2. package/dist/components/card/card.js +52 -52
  3. package/dist/components/checkbox-card-group/checkbox-card-group-content.cjs +64 -0
  4. package/dist/components/checkbox-card-group/checkbox-card-group-content.d.ts +5 -0
  5. package/dist/components/checkbox-card-group/checkbox-card-group-content.js +64 -0
  6. package/dist/components/checkbox-card-group/checkbox-card-group-indicator.cjs +1465 -0
  7. package/dist/components/checkbox-card-group/checkbox-card-group-indicator.d.ts +12 -0
  8. package/dist/components/checkbox-card-group/checkbox-card-group-indicator.js +1446 -0
  9. package/dist/components/checkbox-card-group/checkbox-card-group-item-body.cjs +15 -0
  10. package/dist/components/checkbox-card-group/checkbox-card-group-item-body.d.ts +5 -0
  11. package/dist/components/checkbox-card-group/checkbox-card-group-item-body.js +15 -0
  12. package/dist/components/checkbox-card-group/checkbox-card-group-item-title.cjs +65 -0
  13. package/dist/components/checkbox-card-group/checkbox-card-group-item-title.d.ts +14 -0
  14. package/dist/components/checkbox-card-group/checkbox-card-group-item-title.js +65 -0
  15. package/dist/components/checkbox-card-group/checkbox-card-group-item.cjs +66 -0
  16. package/dist/components/checkbox-card-group/checkbox-card-group-item.d.ts +22 -0
  17. package/dist/components/checkbox-card-group/checkbox-card-group-item.js +66 -0
  18. package/dist/components/checkbox-card-group/checkbox-card-group-label.cjs +29 -0
  19. package/dist/components/checkbox-card-group/checkbox-card-group-label.d.ts +65 -0
  20. package/dist/components/checkbox-card-group/checkbox-card-group-label.js +29 -0
  21. package/dist/components/checkbox-card-group/checkbox-card-group-root.cjs +42 -0
  22. package/dist/components/checkbox-card-group/checkbox-card-group-root.d.ts +39 -0
  23. package/dist/components/checkbox-card-group/checkbox-card-group-root.js +42 -0
  24. package/dist/components/checkbox-card-group/index.cjs +7 -0
  25. package/dist/components/checkbox-card-group/index.d.ts +76 -0
  26. package/dist/components/checkbox-card-group/index.js +7 -0
  27. package/dist/components/index.cjs +6 -5
  28. package/dist/components/index.d.ts +1 -0
  29. package/dist/components/index.js +2 -1
  30. package/dist/components/modal/index.cjs +2 -2
  31. package/dist/components/modal/index.js +1 -1
  32. package/dist/components/modal/modal-close.cjs +2 -2
  33. package/dist/components/modal/modal-close.js +2 -2
  34. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop-simplified.cjs +2 -2
  35. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop-simplified.js +2 -2
  36. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop.cjs +2 -2
  37. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop.js +1 -1
  38. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile-simplified.cjs +2 -2
  39. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile-simplified.js +2 -2
  40. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile.cjs +3 -3
  41. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile.js +2 -2
  42. package/dist/components/navigation-menu/global-navigation/global-navigation-my-pages.cjs +2 -2
  43. package/dist/components/navigation-menu/global-navigation/global-navigation-my-pages.js +2 -2
  44. package/dist/components/navigation-menu/global-navigation/global-navigation-root.cjs +4 -4
  45. package/dist/components/navigation-menu/global-navigation/global-navigation-root.js +4 -4
  46. package/dist/components/navigation-menu/global-navigation/global-navigation-search-field.cjs +2 -2
  47. package/dist/components/navigation-menu/global-navigation/global-navigation-search-field.js +2 -2
  48. package/dist/components/navigation-menu/global-navigation/global-navigation-search.cjs +2 -2
  49. package/dist/components/navigation-menu/global-navigation/global-navigation-search.js +2 -2
  50. package/dist/components/navigation-menu/global-navigation/global-navigation-shopping-cart.cjs +2 -2
  51. package/dist/components/navigation-menu/global-navigation/global-navigation-shopping-cart.js +2 -2
  52. package/dist/components/navigation-menu/global-navigation/index.cjs +2 -2
  53. package/dist/components/navigation-menu/global-navigation/index.js +1 -1
  54. package/dist/components/navigation-menu/index.cjs +3 -3
  55. package/dist/components/navigation-menu/index.js +1 -1
  56. package/dist/components/navigation-menu/navigation-menu.cjs +4 -4
  57. package/dist/components/navigation-menu/navigation-menu.js +1 -1
  58. package/dist/components/radio-card-group/index.cjs +2 -2
  59. package/dist/components/radio-card-group/index.js +1 -1
  60. package/dist/components/radio-card-group/radio-card-group-content.cjs +2 -2
  61. package/dist/components/radio-card-group/radio-card-group-content.js +2 -2
  62. package/dist/components/radio-card-group/radio-card-group-item-title.cjs +21 -1328
  63. package/dist/components/radio-card-group/radio-card-group-item-title.js +21 -1309
  64. package/dist/components/radio-card-group/radio-card-group-item.cjs +3 -3
  65. package/dist/components/radio-card-group/radio-card-group-item.js +3 -3
  66. package/dist/main.cjs +6 -5
  67. package/dist/main.js +2 -1
  68. package/dist/style.css +425 -213
  69. package/dist/tokens/color/variables.cjs +32 -32
  70. package/dist/tokens/color/variables.d.ts +32 -32
  71. package/dist/tokens/color/variables.js +32 -32
  72. package/package.json +5 -5
@@ -0,0 +1,1446 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import React__default, { useEffect } from "react";
3
+ import clsx from "clsx";
4
+ import { MY_PAGE_RETAILER_LINKS, MY_PAGE_LINKS, LOGGED_IN_LINKS_BUSINESS, getLinks, getActiveSubLink, DEFAULT_PRIVATE_LINKS, DEFAULT_BUSINESS_LINKS, DEFAULT_MDU_LINKS } from "../navigation-menu/global-navigation/utils.js";
5
+ import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
6
+ import { useComposedRefs } from "../../utils/composeRefs.js";
7
+ import { VisuallyHidden } from "../visually-hidden/visually-hidden.js";
8
+ import { composeEventHandlers } from "../../utils/composeEventHandlers.js";
9
+ import { Slot } from "@radix-ui/react-slot";
10
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
11
+ import { mergeStyles } from "../../utils/generate-styling/index.js";
12
+ import { teddyMotionDuration300 } from "../../tokens/motion/variables.js";
13
+ import "../metric-meter/metric-meter.js";
14
+ import "../footer/index.js";
15
+ import "../pagination/index.js";
16
+ import "../select/index.js";
17
+ import "../avatar/index.js";
18
+ import "../dashboard-card/index.js";
19
+ import "../table/index.js";
20
+ import "../flip-card/index.js";
21
+ import "../channel-button/index.js";
22
+ import "../collapsible/index.js";
23
+ import "../meter-bar/index.js";
24
+ import "../skeleton/index.js";
25
+ import { Checkbox } from "../checkbox/index.js";
26
+ import { s as styles$2, rootClassName as rootClassName$2, Root as Root$2 } from "./checkbox-card-group-root.js";
27
+ import { GroupLabel } from "./checkbox-card-group-label.js";
28
+ import "../toast/toast-root.js";
29
+ import "sonner";
30
+ import "../toggletip/index.js";
31
+ import "../breadcrumbs/index.js";
32
+ import { s as styles$3, rootClassName as rootClassName$3, Root as Root$3 } from "../radio-card-group/radio-card-group-root.js";
33
+ import { GroupLabel as GroupLabel$1 } from "../radio-card-group/radio-card-group-label.js";
34
+ import "../ribbon/index.js";
35
+ import "../expandable-card/index.js";
36
+ import "../color-dot/color-dot-root.js";
37
+ import "../progress-bar/progress-bar.js";
38
+ import "../notabene/index.js";
39
+ import "../tooltip/index.js";
40
+ import { List as List$1 } from "../list/index.js";
41
+ import "../scroll-area/index.js";
42
+ import { Tabs } from "../tabs/index.js";
43
+ import { Drawer } from "../drawer/index.js";
44
+ import "../image/image.js";
45
+ import "../chip/index.js";
46
+ import "../../assets/sprite.6511e521-teddy.svg";
47
+ import { rootClassName as rootClassName$4, RootContext as RootContext$1, Root as Root$4 } from "../modal/modal-root.js";
48
+ import { Trigger as Trigger$1 } from "../modal/modal-trigger.js";
49
+ import { Content as Content$3 } from "../modal/modal-content.js";
50
+ import { Title as Title$2 } from "../modal/modal-title.js";
51
+ import { Description } from "../modal/modal-description.js";
52
+ import { Overlay } from "../modal/modal-overlay.js";
53
+ import { Group } from "../modal/modal-group.js";
54
+ import * as DrawerPrimitive from "@radix-ui/react-dialog";
55
+ import { Icon } from "../icon/icon.js";
56
+ import "../notification/index.js";
57
+ import "../radio-group/index.js";
58
+ import { Box } from "../box/box.js";
59
+ import { Flex } from "../flex/flex.js";
60
+ import "../card/index.js";
61
+ import { Grid } from "../grid/grid.js";
62
+ import "../toggle/toggle.js";
63
+ import "../accordion/index.js";
64
+ import "../link/link.js";
65
+ import "../badge/badge.js";
66
+ import "../badge/alert-badge.js";
67
+ import { CounterBadge } from "../badge/counter-badge.js";
68
+ import { Button } from "../button/button.js";
69
+ import "../field-error-text/field-error-text.js";
70
+ import "../helper-text/helper-text.js";
71
+ import "../input/index.js";
72
+ import "../label/label.js";
73
+ import "../spinner/spinner.js";
74
+ import { Text } from "../text/text.js";
75
+ import { TextField } from "../text-field/index.js";
76
+ import { Heading } from "../heading/heading.js";
77
+ import { TextSpacing } from "../text-spacing/text-spacing.js";
78
+ import "../container/container.js";
79
+ import "../carousel/carousel-root.js";
80
+ import "../slider/slider.js";
81
+ import { s as styles$4 } from "../../modal.module-DuP4in7f.js";
82
+ import { Image } from "../modal/modal-image.js";
83
+ import { Indicator as Indicator$2 } from "../radio-card-group/radio-card-group-indicator.js";
84
+ import { Body as Body$1 } from "../radio-card-group/radio-card-group-item-body.js";
85
+ import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
86
+ import { Body } from "./checkbox-card-group-item-body.js";
87
+ import { useSize } from "../../utils/useSize.js";
88
+ const Indicator$1 = React__default.forwardRef(
89
+ ({ className, checked, onCheckedChange, disabled, ...props }, forwardRef) => {
90
+ const classes = clsx([styles$2[`${rootClassName$2}__checkbox-wrapper`]], className);
91
+ return /* @__PURE__ */ jsx("div", { ref: forwardRef, className: classes, ...props, children: /* @__PURE__ */ jsx(Checkbox, { children: /* @__PURE__ */ jsx(
92
+ Checkbox.Trigger,
93
+ {
94
+ className: styles$2[`${rootClassName$2}__trigger`],
95
+ checked,
96
+ onCheckedChange,
97
+ disabled
98
+ }
99
+ ) }) });
100
+ }
101
+ );
102
+ Indicator$1.displayName = "Indicator";
103
+ const Title$1 = React__default.forwardRef(
104
+ ({ className, children, asChild, checked, onCheckedChange, disabled, ...props }, forwardRef) => {
105
+ const classes = clsx([styles$2[`${rootClassName$2}__title`]], className);
106
+ return /* @__PURE__ */ jsxs(Flex, { width: "100%", gap: "150", className: styles$2[`${rootClassName$2}__title-wrapper`], children: [
107
+ asChild ? /* @__PURE__ */ jsx(Slot, { ...props, ref: forwardRef, className: classes, children }) : /* @__PURE__ */ jsx(Text, { variant: "paragraph-100-bold", ref: forwardRef, className: classes, children }),
108
+ /* @__PURE__ */ jsx(Indicator$1, { checked, onCheckedChange, disabled })
109
+ ] });
110
+ }
111
+ );
112
+ Title$1.displayName = "Title";
113
+ const Content$2 = React__default.forwardRef(
114
+ ({ className, children, ...props }, forwardRef) => {
115
+ const classes = clsx([styles$2[`${rootClassName$2}__content-wrapper`]], className);
116
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", width: "100%", gap: "50", ...props, ref: forwardRef, className: classes, children });
117
+ }
118
+ );
119
+ Content$2.displayName = "Content";
120
+ const ItemContext$1 = React__default.createContext(void 0);
121
+ const Item$2 = React__default.forwardRef(
122
+ ({ className, children, value, imageUrl, checked, onCheckedChange, disabled, ...props }, forwardedRef) => {
123
+ const classes = clsx([styles$2[`${rootClassName$2}__card-item`]], className);
124
+ const context = React__default.useContext(ItemContext$1);
125
+ const ref = useComposedRefs(forwardedRef, context == null ? void 0 : context.triggerRef);
126
+ const id = props.id || (context == null ? void 0 : context.id);
127
+ return /* @__PURE__ */ jsxs(
128
+ "div",
129
+ {
130
+ id,
131
+ ...props,
132
+ ref,
133
+ className: classes,
134
+ "data-state": checked ? "checked" : "unchecked",
135
+ "data-disabled": disabled ? "" : void 0,
136
+ "aria-checked": checked,
137
+ children: [
138
+ imageUrl ? /* @__PURE__ */ jsx(Flex, { className: clsx([styles$2[`${rootClassName$2}__illustration`]], className), justify: "center", align: "center", children: /* @__PURE__ */ jsx("img", { src: imageUrl, alt: value }) }) : null,
139
+ /* @__PURE__ */ jsx(Content$2, { children: React__default.Children.map(children, (child) => {
140
+ if (React__default.isValidElement(child) && child.type === Title$1) {
141
+ return React__default.cloneElement(child, {
142
+ ...child.props,
143
+ checked,
144
+ onCheckedChange,
145
+ disabled
146
+ });
147
+ }
148
+ return child;
149
+ }) })
150
+ ]
151
+ }
152
+ );
153
+ }
154
+ );
155
+ Item$2.displayName = "Item";
156
+ Root$2.displayName = "CheckboxCardGroup";
157
+ GroupLabel.displayName = "CheckboxCardGroup.GroupLabel";
158
+ Item$2.displayName = "CheckboxCardGroup.Item";
159
+ Title$1.displayName = "CheckboxCardGroup.Title";
160
+ Body.displayName = "CheckboxCardGroup.Body";
161
+ Indicator$1.displayName = "CheckboxCardGroup.Indicator";
162
+ const CheckboxCardGroup = Object.assign(Root$2, {
163
+ GroupLabel,
164
+ Item: Item$2,
165
+ Title: Title$1,
166
+ Body,
167
+ Indicator: Indicator$1
168
+ });
169
+ const Title = React__default.forwardRef(
170
+ ({ className, children, asChild, ...props }, forwardRef) => {
171
+ const classes = clsx([styles$3[`${rootClassName$3}__title`]], className);
172
+ return /* @__PURE__ */ jsxs(Flex, { width: "100%", gap: "150", className: styles$3[`${rootClassName$3}__title-wrapper`], children: [
173
+ asChild ? /* @__PURE__ */ jsx(Slot, { ...props, ref: forwardRef, className: classes, children }) : /* @__PURE__ */ jsx(Text, { variant: "paragraph-100-bold", ref: forwardRef, className: classes, children }),
174
+ /* @__PURE__ */ jsx(Indicator$2, {})
175
+ ] });
176
+ }
177
+ );
178
+ Title.displayName = "Title";
179
+ const Content$1 = React__default.forwardRef(
180
+ ({ className, children, ...props }, forwardRef) => {
181
+ const classes = clsx([styles$3[`${rootClassName$3}__content-wrapper`]], className);
182
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", width: "100%", gap: "50", ...props, ref: forwardRef, className: classes, children });
183
+ }
184
+ );
185
+ Content$1.displayName = "Content";
186
+ const ItemContext = React__default.createContext(void 0);
187
+ const Item$1 = React__default.forwardRef(
188
+ ({ className, children, value, ...props }, forwardedRef) => {
189
+ const classes = clsx([styles$3[`${rootClassName$3}__card-item`]], className);
190
+ const context = React__default.useContext(ItemContext);
191
+ const ref = useComposedRefs(forwardedRef, context == null ? void 0 : context.triggerRef);
192
+ const id = props.id || (context == null ? void 0 : context.id);
193
+ return /* @__PURE__ */ jsxs(RadioGroupPrimitive.Item, { value, id, ...props, asChild: false, ref, className: classes, children: [
194
+ props.imageUrl ? /* @__PURE__ */ jsx(Flex, { className: clsx([styles$3[`${rootClassName$3}__illustration`]], className), justify: "center", align: "center", children: /* @__PURE__ */ jsx("img", { src: props.imageUrl, alt: value }) }) : null,
195
+ /* @__PURE__ */ jsx(Content$1, { children })
196
+ ] });
197
+ }
198
+ );
199
+ Item$1.displayName = "Item";
200
+ Root$3.displayName = "RadioCardGroup";
201
+ GroupLabel$1.displayName = "RadioCardGroup.GroupLabel";
202
+ Item$1.displayName = "RadioCardGroup.Item";
203
+ Title.displayName = "RadioCardGroup.Title";
204
+ Body$1.displayName = "RadioCardGroup.Body";
205
+ const RadioCardGroup = Object.assign(Root$3, {
206
+ GroupLabel: GroupLabel$1,
207
+ Item: Item$1,
208
+ Title,
209
+ Body: Body$1
210
+ });
211
+ const Close = React__default.forwardRef(
212
+ ({ className, ...props }, forwardedRef) => {
213
+ const classes = clsx([styles$4[`${rootClassName$4}__close`]], {
214
+ [styles$4[`${rootClassName$4}__close--floating`]]: props.slot === "floating",
215
+ className
216
+ });
217
+ const imageRef = React__default.useContext(RootContext$1).imageRef;
218
+ const [hasImage, setHasImage] = React__default.useState(false);
219
+ useEffect(() => {
220
+ if (imageRef == null ? void 0 : imageRef.current) {
221
+ setHasImage(true);
222
+ }
223
+ }, [imageRef]);
224
+ return /* @__PURE__ */ jsx(DrawerPrimitive.Close, { ...props, className: classes, ref: forwardedRef, asChild: true, children: props.children || /* @__PURE__ */ jsx(
225
+ Button,
226
+ {
227
+ variant: hasImage ? "primary-negative" : "tertiary-purple",
228
+ iconOnly: true,
229
+ "aria-label": props["aria-label"] ?? "Lukk",
230
+ children: /* @__PURE__ */ jsx(Icon, { name: "close" })
231
+ }
232
+ ) });
233
+ }
234
+ );
235
+ Close.displayName = "Close";
236
+ const Modal = Root$4;
237
+ Modal.displayName = "Modal";
238
+ Modal.Trigger = Trigger$1;
239
+ Modal.Trigger.displayName = "Modal.Trigger";
240
+ Modal.Content = Content$3;
241
+ Modal.Content.displayName = "Modal.Content";
242
+ Modal.Title = Title$2;
243
+ Modal.Title.displayName = "Modal.Title";
244
+ Modal.Description = Description;
245
+ Modal.Description.displayName = "Modal.Description";
246
+ Modal.Overlay = Overlay;
247
+ Modal.Overlay.displayName = "Modal.Overlay";
248
+ Modal.Group = Group;
249
+ Modal.Group.displayName = "Modal.Group";
250
+ Modal.Close = Close;
251
+ Modal.Close.displayName = "Modal.Close";
252
+ Modal.Image = Image;
253
+ Modal.Image.displayName = "Modal.Image";
254
+ const styles$1 = {
255
+ "teddy-navigation-menu": "_teddy-navigation-menu_6p30v_1",
256
+ "teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_6p30v_34",
257
+ "teddy-navigation-menu__separator": "_teddy-navigation-menu__separator_6p30v_37",
258
+ "teddy-navigation-menu__list": "_teddy-navigation-menu__list_6p30v_40",
259
+ "teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_6p30v_66",
260
+ "teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_6p30v_87",
261
+ "teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_6p30v_106",
262
+ "teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_6p30v_112",
263
+ "teddy-navigation-menu__content": "_teddy-navigation-menu__content_6p30v_187",
264
+ "teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_6p30v_219",
265
+ "teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_6p30v_239",
266
+ "teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_6p30v_245",
267
+ "teddy-navigation-menu__link": "_teddy-navigation-menu__link_6p30v_313",
268
+ "teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_6p30v_333",
269
+ "teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_6p30v_339"
270
+ };
271
+ const rootClassName$1 = "teddy-navigation-menu";
272
+ const NavigationMenuContext = React__default.createContext({
273
+ selectedTopMenu: void 0,
274
+ setSelectedTopMenu: () => {
275
+ },
276
+ contentRef: { current: null },
277
+ focusProxyRef: { current: null },
278
+ topMenuRef: { current: null },
279
+ id: "",
280
+ dir: "ltr",
281
+ orientation: "horizontal",
282
+ onEntryKeyDown: () => {
283
+ },
284
+ onFocusProxyEnter: () => {
285
+ },
286
+ onContentFocusOutside: () => {
287
+ }
288
+ });
289
+ const Root$1 = React__default.forwardRef(
290
+ ({ className, defaultTopMenuValue, topMenuValue, onTopMenuValueChange, ...props }, forwardRef) => {
291
+ const [selectedTopMenu, setSelectedTopMenu] = useControllableState({
292
+ defaultProp: defaultTopMenuValue,
293
+ prop: topMenuValue,
294
+ onChange: onTopMenuValueChange
295
+ });
296
+ const contentRef = React__default.useRef(null);
297
+ const [allowAnimationOfHeight, setAllowAnimationOfHeight] = React__default.useState(false);
298
+ const timerRef = React__default.useRef(void 0);
299
+ const restoreContentTabOrderRef = React__default.useRef(() => {
300
+ });
301
+ const focusProxyRef = React__default.useRef(null);
302
+ const topMenuRef = React__default.useRef(null);
303
+ const id = React__default.useId();
304
+ const handleContentEntry = React__default.useCallback((side = "start") => {
305
+ if (contentRef.current) {
306
+ restoreContentTabOrderRef.current();
307
+ const candidates = getTabbableCandidates(contentRef.current);
308
+ if (candidates.length) focusFirst(side === "start" ? candidates : candidates.reverse());
309
+ }
310
+ }, []);
311
+ const handleContentExit = React__default.useCallback(() => {
312
+ if (contentRef.current) {
313
+ const candidates = getTabbableCandidates(contentRef.current);
314
+ if (candidates.length) restoreContentTabOrderRef.current = removeFromTabOrder(candidates);
315
+ }
316
+ }, []);
317
+ React__default.useEffect(() => {
318
+ timerRef.current = setTimeout(() => {
319
+ setAllowAnimationOfHeight(true);
320
+ }, 500);
321
+ return () => {
322
+ timerRef.current && clearTimeout(timerRef.current);
323
+ };
324
+ }, []);
325
+ const classes = clsx([styles$1[`${rootClassName$1}`]], className);
326
+ return /* @__PURE__ */ jsx(
327
+ NavigationMenuContext.Provider,
328
+ {
329
+ value: {
330
+ contentRef,
331
+ focusProxyRef,
332
+ topMenuRef,
333
+ id,
334
+ dir: props.dir || "ltr",
335
+ orientation: props.orientation || "horizontal",
336
+ onEntryKeyDown: handleContentEntry,
337
+ onFocusProxyEnter: handleContentEntry,
338
+ onContentFocusOutside: handleContentExit,
339
+ selectedTopMenu,
340
+ setSelectedTopMenu
341
+ },
342
+ children: /* @__PURE__ */ jsx(
343
+ NavigationMenuPrimitive.Root,
344
+ {
345
+ ...props,
346
+ style: allowAnimationOfHeight ? mergeStyles(props.style, { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 }) : props.style,
347
+ ref: forwardRef,
348
+ className: classes
349
+ }
350
+ )
351
+ }
352
+ );
353
+ }
354
+ );
355
+ Root$1.displayName = "NavigationMenu";
356
+ const TopMenuList = React__default.forwardRef(
357
+ ({ className, ...props }, forwardRef) => {
358
+ const classes = clsx([styles$1[`${rootClassName$1}__top-menu-list`]], className);
359
+ const context = React__default.useContext(NavigationMenuContext);
360
+ const ref = useComposedRefs(context.topMenuRef, forwardRef);
361
+ return /* @__PURE__ */ jsx("ul", { ...props, ref, className: classes });
362
+ }
363
+ );
364
+ TopMenuList.displayName = "NavigationMenu.TopMenuList";
365
+ const TopMenuItem = React__default.forwardRef(
366
+ ({ className, ...props }, forwardRef) => {
367
+ const classes = clsx([styles$1[`${rootClassName$1}__top-menu-item`]], className);
368
+ return /* @__PURE__ */ jsx("li", { ...props, ref: forwardRef, className: classes });
369
+ }
370
+ );
371
+ const TopMenuTrigger = React__default.forwardRef(
372
+ ({ className, asChild, active, ...props }, forwardRef) => {
373
+ const classes = clsx(
374
+ [styles$1[`${rootClassName$1}__top-menu-trigger`], styles$1[`${rootClassName$1}__top-menu-trigger--small`]],
375
+ className
376
+ );
377
+ const Comp = asChild ? Slot : "button";
378
+ const context = React__default.useContext(NavigationMenuContext);
379
+ const innerRef = React__default.useRef(null);
380
+ const ref = useComposedRefs(innerRef, forwardRef);
381
+ const isOpen = context.selectedTopMenu === props.value;
382
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
383
+ /* @__PURE__ */ jsx(
384
+ Comp,
385
+ {
386
+ ...props,
387
+ ref,
388
+ className: classes,
389
+ "data-state": isOpen ? "open" : "closed",
390
+ "data-active": active ? "true" : void 0,
391
+ "aria-expanded": isOpen,
392
+ "aria-controls": makeContentId({ value: props.value, baseId: context.id }),
393
+ ...{ [ITEM_DATA_ATTR]: "" },
394
+ onClick: composeEventHandlers(props.onClick, () => {
395
+ context.setSelectedTopMenu(props.value);
396
+ }),
397
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
398
+ var _a;
399
+ const verticalEntryKey = context.dir === "rtl" ? "ArrowLeft" : "ArrowRight";
400
+ const entryKey = { horizontal: "ArrowDown", vertical: verticalEntryKey }[context.orientation];
401
+ if (isOpen && event.key === entryKey) {
402
+ context.onEntryKeyDown();
403
+ return event.preventDefault();
404
+ }
405
+ const isFocusNavigationKey = ["Home", "End", ...ARROW_KEYS].includes(event.key);
406
+ if (isFocusNavigationKey) {
407
+ const triggers = (_a = context.topMenuRef.current) == null ? void 0 : _a.querySelectorAll(`[${ITEM_DATA_ATTR}]`);
408
+ if (!triggers) return;
409
+ let candidateNodes = Array.from(triggers == null ? void 0 : triggers.values());
410
+ const prevItemKey = context.dir === "rtl" ? "ArrowRight" : "ArrowLeft";
411
+ const prevKeys = [prevItemKey, "ArrowUp", "End"];
412
+ if (prevKeys.includes(event.key)) candidateNodes.reverse();
413
+ if (ARROW_KEYS.includes(event.key)) {
414
+ const currentIndex = candidateNodes.indexOf(event.currentTarget);
415
+ candidateNodes = candidateNodes.slice(currentIndex + 1);
416
+ focusFirst(candidateNodes);
417
+ event.preventDefault();
418
+ }
419
+ }
420
+ })
421
+ }
422
+ ),
423
+ isOpen && /* @__PURE__ */ jsx(
424
+ VisuallyHidden,
425
+ {
426
+ tabIndex: 0,
427
+ ref: context.focusProxyRef,
428
+ onFocus: (event) => {
429
+ const content = context.contentRef.current;
430
+ const prevFocusedElement = event.relatedTarget;
431
+ const wasTriggerFocused = prevFocusedElement === innerRef.current;
432
+ const wasFocusFromContent = content == null ? void 0 : content.contains(prevFocusedElement);
433
+ if (wasTriggerFocused || !wasFocusFromContent) {
434
+ context.onFocusProxyEnter(wasTriggerFocused ? "start" : "end");
435
+ }
436
+ }
437
+ }
438
+ )
439
+ ] });
440
+ }
441
+ );
442
+ const List = React__default.forwardRef(
443
+ ({ className, variant, value, ...props }, forwardRef) => {
444
+ const classes = clsx([styles$1[`${rootClassName$1}__list`]], [styles$1[`${rootClassName$1}__list--${variant}`]], className);
445
+ const context = React__default.useContext(NavigationMenuContext);
446
+ const refOnOpen = useComposedRefs(context.contentRef, forwardRef);
447
+ const hasTopMenu = context.selectedTopMenu !== void 0;
448
+ const isOpen = context.selectedTopMenu === value;
449
+ if (!isOpen) return null;
450
+ return /* @__PURE__ */ jsx(
451
+ NavigationMenuPrimitive.List,
452
+ {
453
+ ref: hasTopMenu ? refOnOpen : forwardRef,
454
+ id: value && makeContentId({ value, baseId: context.id }),
455
+ ...props,
456
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
457
+ var _a;
458
+ if (!value) return;
459
+ const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
460
+ const isTabKey = event.key === "Tab" && !isMetaKey;
461
+ if (isTabKey) {
462
+ const candidates = getTabbableCandidates(event.currentTarget);
463
+ const focusedElement = document.activeElement;
464
+ const index = candidates.findIndex((candidate) => candidate === focusedElement);
465
+ const isMovingBackwards = event.shiftKey;
466
+ const nextCandidates = isMovingBackwards ? candidates.slice(0, index).reverse() : candidates.slice(index + 1, candidates.length);
467
+ if (focusFirst(nextCandidates)) {
468
+ event.preventDefault();
469
+ } else {
470
+ (_a = context.focusProxyRef.current) == null ? void 0 : _a.focus();
471
+ context.onContentFocusOutside();
472
+ }
473
+ }
474
+ }),
475
+ className: classes
476
+ }
477
+ );
478
+ }
479
+ );
480
+ List.displayName = "NavigationMenu.List";
481
+ const Separator = React__default.forwardRef(({ className, ...props }, forwardRef) => {
482
+ const classes = clsx(
483
+ [styles$1[`${rootClassName$1}__separator`]],
484
+ className
485
+ );
486
+ return /* @__PURE__ */ jsx(Box, { width: "100%", p: "0", m: "0", ...props, ref: forwardRef, className: classes, asChild: true, children: /* @__PURE__ */ jsx("hr", {}) });
487
+ });
488
+ Separator.displayName = "NavigationMenu.Separator";
489
+ const Item = React__default.forwardRef(
490
+ ({ className, ...props }, forwardRef) => {
491
+ const classes = clsx([styles$1[`${rootClassName$1}__item`]], className);
492
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Item, { ...props, ref: forwardRef, className: classes });
493
+ }
494
+ );
495
+ Item.displayName = "NavigationMenu.Item";
496
+ const Trigger = React__default.forwardRef(
497
+ ({ className, active, variant = "default", ...props }, forwardRef) => {
498
+ const classes = clsx(
499
+ [styles$1[`${rootClassName$1}__trigger`]],
500
+ [styles$1[`${rootClassName$1}__trigger--${variant}`]],
501
+ className
502
+ );
503
+ const innerRef = React__default.useRef(null);
504
+ const ref = useComposedRefs(forwardRef, innerRef);
505
+ return /* @__PURE__ */ jsx(
506
+ NavigationMenuPrimitive.Trigger,
507
+ {
508
+ ...props,
509
+ ref,
510
+ "data-active": active ? "true" : void 0,
511
+ className: classes,
512
+ "data-text": getLabelFromChildren(props.children)
513
+ }
514
+ );
515
+ }
516
+ );
517
+ Trigger.displayName = "NavigationMenu.Trigger";
518
+ const Content = React__default.forwardRef(
519
+ ({ className, variant = "default", ...props }, forwardRef) => {
520
+ const classes = clsx(
521
+ [styles$1[`${rootClassName$1}__content`]],
522
+ [styles$1[`${rootClassName$1}__content--${variant}`]],
523
+ className
524
+ );
525
+ return /* @__PURE__ */ jsx(
526
+ NavigationMenuPrimitive.Content,
527
+ {
528
+ ...props,
529
+ ref: forwardRef,
530
+ className: classes
531
+ }
532
+ );
533
+ }
534
+ );
535
+ const Link = React__default.forwardRef(
536
+ ({ className, variant = "default", ...props }, forwardRef) => {
537
+ const classes = clsx([styles$1[`${rootClassName$1}__link`]], [styles$1[`${rootClassName$1}__link--${variant}`]], className);
538
+ return /* @__PURE__ */ jsx(
539
+ NavigationMenuPrimitive.Link,
540
+ {
541
+ ...props,
542
+ ref: forwardRef,
543
+ className: classes,
544
+ "data-text": getLabelFromChildren(props.children)
545
+ }
546
+ );
547
+ }
548
+ );
549
+ Link.displayName = "NavigationMenu.Link";
550
+ const Indicator = React__default.forwardRef(
551
+ ({ className, ...props }, forwardRef) => {
552
+ const classes = clsx([styles$1[`${rootClassName$1}__indicator`]], className);
553
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Indicator, { ...props, ref: forwardRef, className: classes });
554
+ }
555
+ );
556
+ Indicator.displayName = "NavigationMenu.Indicator";
557
+ const Viewport = React__default.forwardRef(
558
+ ({ className, ...props }, forwardRef) => {
559
+ const classes = clsx([styles$1[`${rootClassName$1}__viewport`]], className);
560
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Viewport, { ...props, ref: forwardRef, className: classes });
561
+ }
562
+ );
563
+ Viewport.displayName = "NavigationMenu.Viewport";
564
+ const Sub = React__default.forwardRef(
565
+ ({ className, ...props }, forwardRef) => {
566
+ const classes = clsx([styles$1[`${rootClassName$1}__sub`]], className);
567
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Sub, { ...props, ref: forwardRef, className: classes });
568
+ }
569
+ );
570
+ Sub.displayName = "NavigationMenu.Sub";
571
+ function getLabelFromChildren(children) {
572
+ function findLabel(node) {
573
+ if (typeof node === "string") {
574
+ return node;
575
+ }
576
+ if (React__default.isValidElement(node) && node.props.children) {
577
+ return findLabel(node.props.children);
578
+ }
579
+ if (Array.isArray(node)) {
580
+ for (let i = node.length - 1; i >= 0; i--) {
581
+ const label = findLabel(node[i]);
582
+ if (label) {
583
+ return label;
584
+ }
585
+ }
586
+ }
587
+ return void 0;
588
+ }
589
+ return findLabel(children);
590
+ }
591
+ function getTabbableCandidates(container) {
592
+ const nodes = [];
593
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
594
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
595
+ acceptNode: (node) => {
596
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
597
+ if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
598
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
599
+ }
600
+ });
601
+ while (walker.nextNode()) nodes.push(walker.currentNode);
602
+ return nodes;
603
+ }
604
+ function focusFirst(candidates) {
605
+ const previouslyFocusedElement = document.activeElement;
606
+ return candidates.some((candidate) => {
607
+ if (candidate === previouslyFocusedElement) return true;
608
+ candidate.focus();
609
+ return document.activeElement !== previouslyFocusedElement;
610
+ });
611
+ }
612
+ function removeFromTabOrder(candidates) {
613
+ candidates.forEach((candidate) => {
614
+ candidate.dataset.tabindex = candidate.getAttribute("tabindex") || "";
615
+ candidate.setAttribute("tabindex", "-1");
616
+ });
617
+ return () => {
618
+ candidates.forEach((candidate) => {
619
+ const prevTabIndex = candidate.dataset.tabindex;
620
+ candidate.setAttribute("tabindex", prevTabIndex);
621
+ });
622
+ };
623
+ }
624
+ const ITEM_DATA_ATTR = "data-teddy-top-selector-trigger";
625
+ const ARROW_KEYS = ["ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown"];
626
+ function makeContentId(args) {
627
+ return `teddy-navigation-menu-${args.baseId}-${args.value}-content`;
628
+ }
629
+ const NavigationMenu = Object.assign(Root$1, {
630
+ List,
631
+ Separator,
632
+ Item,
633
+ Trigger,
634
+ Content,
635
+ Link,
636
+ Indicator,
637
+ Viewport,
638
+ Sub,
639
+ TopMenuList,
640
+ TopMenuItem,
641
+ TopMenuTrigger
642
+ });
643
+ const styles = {
644
+ "teddy-global-navigation": "_teddy-global-navigation_1eacg_1",
645
+ "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1eacg_6",
646
+ "teddy-global-navigation__top-icon-wrapper": "_teddy-global-navigation__top-icon-wrapper_1eacg_26",
647
+ "teddy-global-navigation__top-menu-icons": "_teddy-global-navigation__top-menu-icons_1eacg_31",
648
+ "teddy-global-navigation__link": "_teddy-global-navigation__link_1eacg_35",
649
+ "teddy-global-navigation__header": "_teddy-global-navigation__header_1eacg_48",
650
+ "teddy-global-navigation__colored-box": "_teddy-global-navigation__colored-box_1eacg_51",
651
+ "teddy-global-navigation__colored-box--mobile": "_teddy-global-navigation__colored-box--mobile_1eacg_55",
652
+ "teddy-global-navigation__sublink-button--mobile": "_teddy-global-navigation__sublink-button--mobile_1eacg_59",
653
+ "teddy-global-navigation__list": "_teddy-global-navigation__list_1eacg_65",
654
+ "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1eacg_70",
655
+ "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1eacg_73",
656
+ "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1eacg_77",
657
+ "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1eacg_84",
658
+ "close-viewport": "_close-viewport_1eacg_1",
659
+ "teddy-global-navigation__top-menu-color": "_teddy-global-navigation__top-menu-color_1eacg_101",
660
+ "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1eacg_104"
661
+ };
662
+ function MyPages(props) {
663
+ var _a, _b;
664
+ const rootContext = React__default.useContext(RootContext);
665
+ const isLoggedIn = (((_a = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _a.name.length) || 0) > 0;
666
+ return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
667
+ /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: ((_b = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _b.name.length) ? /* @__PURE__ */ jsxs("button", { "data-di-mask": true, children: [
668
+ /* @__PURE__ */ jsx(Icon, { name: "end-user", size: "sm" }),
669
+ rootContext.loggedInUser.name
670
+ ] }) : /* @__PURE__ */ jsxs("button", { children: [
671
+ /* @__PURE__ */ jsx(Icon, { name: "login", size: "sm" }),
672
+ "Logg inn"
673
+ ] }) }) }),
674
+ /* @__PURE__ */ jsxs(Drawer.Content, { asChild: true, size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
675
+ /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
676
+ isLoggedIn ? /* @__PURE__ */ jsx(LoggedInContent, {}) : /* @__PURE__ */ jsx(LoggedOutContent, {}),
677
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
678
+ ] })
679
+ ] });
680
+ }
681
+ function LoggedOutContent() {
682
+ return /* @__PURE__ */ jsxs(Grid, { gap: "400", children: [
683
+ /* @__PURE__ */ jsx(Drawer.Title, { children: "Logg inn" }),
684
+ /* @__PURE__ */ jsxs(TextSpacing, { children: [
685
+ /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", children: "Privat" }),
686
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", asChild: true, children: /* @__PURE__ */ jsxs("a", { href: MY_PAGE_LINKS.link, children: [
687
+ MY_PAGE_LINKS.name,
688
+ " ",
689
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
690
+ ] }) })
691
+ ] }),
692
+ /* @__PURE__ */ jsxs(TextSpacing, { children: [
693
+ /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", children: "Bedrift" }),
694
+ /* @__PURE__ */ jsx(Grid, { gap: "150", children: LOGGED_IN_LINKS_BUSINESS.map((link) => /* @__PURE__ */ jsx(Button, { variant: "secondary", asChild: true, children: /* @__PURE__ */ jsxs("a", { href: link.link, children: [
695
+ link.name,
696
+ " ",
697
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
698
+ ] }) })) })
699
+ ] })
700
+ ] });
701
+ }
702
+ function LoggedInContent() {
703
+ var _a, _b, _c;
704
+ const rootContext = React__default.useContext(RootContext);
705
+ const isRetailerLoggedIn = (_a = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _a.isRetailer;
706
+ if (isRetailerLoggedIn) {
707
+ return /* @__PURE__ */ jsxs(TextSpacing, { children: [
708
+ /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Min Side" }),
709
+ (_b = MY_PAGE_RETAILER_LINKS.links) == null ? void 0 : _b.map((link) => /* @__PURE__ */ jsx(Button, { variant: "list-item", fullWidth: true, asChild: true, children: /* @__PURE__ */ jsx("a", { href: link.link, children: /* @__PURE__ */ jsx(Icon, { name: link.icon, children: link.name }) }) }, link.link)),
710
+ /* @__PURE__ */ jsx(Button, { mt: "200", onClick: () => rootContext == null ? void 0 : rootContext.onLogoutClick(), variant: "secondary", children: /* @__PURE__ */ jsx(Icon, { name: "logout", children: "Logg ut" }) })
711
+ ] });
712
+ }
713
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
714
+ /* @__PURE__ */ jsx(Drawer.Title, { children: "Mine sider" }),
715
+ /* @__PURE__ */ jsxs(Tabs, { defaultValue: "private", children: [
716
+ /* @__PURE__ */ jsxs(Tabs.List, { children: [
717
+ /* @__PURE__ */ jsx(Tabs.Trigger, { value: "private", children: "Privat" }),
718
+ /* @__PURE__ */ jsx(Tabs.Trigger, { value: "business", children: "Bedrift" })
719
+ ] }),
720
+ /* @__PURE__ */ jsxs(TextSpacing, { children: [
721
+ /* @__PURE__ */ jsxs(Tabs.Content, { value: "private", children: [
722
+ /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Min Side" }),
723
+ (_c = MY_PAGE_LINKS.links) == null ? void 0 : _c.map((link) => /* @__PURE__ */ jsx(Button, { variant: "list-item", fullWidth: true, asChild: true, children: /* @__PURE__ */ jsx("a", { href: link.link, children: /* @__PURE__ */ jsx(Icon, { name: link.icon, children: link.name }) }) }, link.link))
724
+ ] }),
725
+ /* @__PURE__ */ jsxs(Tabs.Content, { value: "business", children: [
726
+ /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Bedriftsportaler" }),
727
+ LOGGED_IN_LINKS_BUSINESS.map((link) => /* @__PURE__ */ jsx(Button, { variant: "list-item", fullWidth: true, asChild: true, children: /* @__PURE__ */ jsx("a", { href: link.link, children: /* @__PURE__ */ jsx(Icon, { name: link.icon, children: link.name }) }) }, link.link))
728
+ ] }),
729
+ /* @__PURE__ */ jsx(Button, { mt: "200", onClick: () => rootContext == null ? void 0 : rootContext.onLogoutClick(), variant: "secondary", children: /* @__PURE__ */ jsx(Icon, { name: "logout", children: "Logg ut" }) })
730
+ ] })
731
+ ] })
732
+ ] });
733
+ }
734
+ MyPages.displayName = "MyPages";
735
+ const SearchField = React__default.forwardRef(
736
+ (props, forwardRef) => {
737
+ const ref = React__default.useRef(null);
738
+ const context = React__default.useContext(RootContext);
739
+ const composedRef = useComposedRefs(forwardRef, ref);
740
+ return /* @__PURE__ */ jsx(
741
+ "form",
742
+ {
743
+ onSubmit: (e) => {
744
+ var _a, _b;
745
+ if (context == null ? void 0 : context.onSearchSubmit) {
746
+ context.onSearchSubmit(e, (_a = ref.current) == null ? void 0 : _a.value);
747
+ }
748
+ if (!window || e.isDefaultPrevented()) return;
749
+ e.preventDefault();
750
+ window.location.href = `/sok?q=${encodeURIComponent(((_b = ref.current) == null ? void 0 : _b.value) || "")}`;
751
+ },
752
+ children: /* @__PURE__ */ jsxs(TextField, { ...props, children: [
753
+ /* @__PURE__ */ jsx(TextField.Label, { children: "Søk i innhold" }),
754
+ /* @__PURE__ */ jsxs(TextField.InputGroup, { children: [
755
+ /* @__PURE__ */ jsx(Icon, { name: "search" }),
756
+ /* @__PURE__ */ jsx(
757
+ TextField.Input,
758
+ {
759
+ ref: composedRef,
760
+ value: context == null ? void 0 : context.searchValue,
761
+ onChange: (e) => {
762
+ var _a, _b;
763
+ if (((_a = ref.current) == null ? void 0 : _a.value) && (context == null ? void 0 : context.onSearchInputChange)) {
764
+ context == null ? void 0 : context.onSearchInputChange(e, (_b = ref.current) == null ? void 0 : _b.value);
765
+ }
766
+ },
767
+ onKeyDown: (e) => {
768
+ if (context == null ? void 0 : context.onSearchKeyDown) {
769
+ context.onSearchKeyDown(e);
770
+ }
771
+ },
772
+ placeholder: "Søk her"
773
+ }
774
+ ),
775
+ /* @__PURE__ */ jsx(TextField.ClearButton, { onClick: () => {
776
+ if (context == null ? void 0 : context.onClear) {
777
+ context.onClear();
778
+ }
779
+ } })
780
+ ] }),
781
+ /* @__PURE__ */ jsx(TextField.Button, { variant: "separated", children: "Søk" })
782
+ ] })
783
+ }
784
+ );
785
+ }
786
+ );
787
+ SearchField.displayName = "SearchField";
788
+ function Search(props) {
789
+ const rootContext = React__default.useContext(RootContext);
790
+ const additionalSearchContent = rootContext == null ? void 0 : rootContext.additionalSearchContent;
791
+ const searchFieldRef = React__default.useRef(null);
792
+ return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
793
+ /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
794
+ /* @__PURE__ */ jsx(Icon, { name: "search", size: "sm" }),
795
+ " Søk"
796
+ ] }) }) }),
797
+ /* @__PURE__ */ jsxs(
798
+ Drawer.Content,
799
+ {
800
+ size: rootContext == null ? void 0 : rootContext.drawerSize,
801
+ onOpenAutoFocus: (e) => {
802
+ var _a;
803
+ e.preventDefault();
804
+ (_a = searchFieldRef.current) == null ? void 0 : _a.focus();
805
+ },
806
+ children: [
807
+ /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
808
+ /* @__PURE__ */ jsx(Drawer.Title, { children: "Hva leter du etter?" }),
809
+ /* @__PURE__ */ jsx(SearchField, { ref: searchFieldRef }),
810
+ additionalSearchContent ? additionalSearchContent : null,
811
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
812
+ ]
813
+ }
814
+ )
815
+ ] });
816
+ }
817
+ Search.displayName = "Search";
818
+ const ShoppingCart = React__default.forwardRef(() => {
819
+ const rootContext = React__default.useContext(RootContext);
820
+ const shoppingCartContent = rootContext == null ? void 0 : rootContext.shoppingCart;
821
+ const numberOfItemsInCart = (rootContext == null ? void 0 : rootContext.shoppingCartNumberOfItems) || 0;
822
+ const titleSuffix = numberOfItemsInCart > 0 ? `(${numberOfItemsInCart})` : "";
823
+ if (!numberOfItemsInCart) return null;
824
+ return /* @__PURE__ */ jsxs(Drawer, { open: rootContext == null ? void 0 : rootContext.isCartOpen, onOpenChange: rootContext == null ? void 0 : rootContext.onCartOpenChange, children: [
825
+ /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
826
+ /* @__PURE__ */ jsxs("div", { className: clsx([styles[`${rootClassName}__item-wrapper`]]), children: [
827
+ /* @__PURE__ */ jsx(Icon, { name: "cart", size: "sm" }),
828
+ numberOfItemsInCart > 0 && /* @__PURE__ */ jsx("span", { className: clsx([styles[`${rootClassName}__item-count`]]), children: /* @__PURE__ */ jsx(CounterBadge, { variant: "attention", children: numberOfItemsInCart }) })
829
+ ] }),
830
+ "Handlekurv"
831
+ ] }) }) }),
832
+ /* @__PURE__ */ jsxs(Drawer.Content, { size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
833
+ /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
834
+ /* @__PURE__ */ jsxs(Drawer.Title, { children: [
835
+ "Handlekurv ",
836
+ titleSuffix
837
+ ] }),
838
+ shoppingCartContent ? shoppingCartContent : null,
839
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
840
+ ] })
841
+ ] });
842
+ });
843
+ ShoppingCart.displayName = "ShoppingCart";
844
+ const Desktop = React__default.forwardRef(() => {
845
+ const rootContext = React__default.useContext(RootContext);
846
+ const [showMenu, setShowMenu] = React__default.useState(false);
847
+ const [isClientSide, setIsClientSide] = React__default.useState(false);
848
+ const topMenuRef = React__default.useRef(null);
849
+ const topMenuSize = useSize(topMenuRef.current);
850
+ React__default.useEffect(() => {
851
+ setIsClientSide(true);
852
+ }, []);
853
+ if (!rootContext) return null;
854
+ const links = getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale"), rootContext.customLinks);
855
+ const shouldShowViewport = links.flatMap((link) => link.links || []).some((link) => {
856
+ var _a;
857
+ const sameParent = link.link.split("/")[1] === (rootContext == null ? void 0 : rootContext.pathname.split("/")[1]) || !link.link && (rootContext == null ? void 0 : rootContext.pathname) === "/";
858
+ return (((_a = link.links) == null ? void 0 : _a.length) || 0) > 0 && link.name === (rootContext == null ? void 0 : rootContext.specifiedLink) && sameParent;
859
+ });
860
+ const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
861
+ const { selectedMenuItem, setSelectedMenuItem, linkComponent: Link2, specifiedLink, setSpecifiedLink } = rootContext;
862
+ const currentLocation = rootContext.pathname.endsWith("/") ? rootContext.pathname : `${rootContext.pathname}/`;
863
+ const handleInteractions = (linkName) => {
864
+ setSpecifiedLink(linkName || "");
865
+ setSelectedMenuItem(linkName || "", true);
866
+ };
867
+ const viewPortHeight = shouldShowViewport ? "333px" : void 0;
868
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
869
+ /* @__PURE__ */ jsx("div", { className: styles[`${rootClassName}__top-menu-color`], children: /* @__PURE__ */ jsx(
870
+ "div",
871
+ {
872
+ style: mergeStyles({ ["--teddy-top-menu-height"]: topMenuHeight }),
873
+ className: styles[`${rootClassName}__top-menu-wrapper`],
874
+ children: /* @__PURE__ */ jsxs(NavigationMenu.TopMenuList, { ref: topMenuRef, children: [
875
+ links.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(
876
+ NavigationMenu.TopMenuTrigger,
877
+ {
878
+ value: link.name,
879
+ asChild: true,
880
+ onClick: () => {
881
+ rootContext.setPathname(link.link);
882
+ setSpecifiedLink("");
883
+ },
884
+ children: link.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: link.link, children: link.name }) : /* @__PURE__ */ jsx("a", { href: link.link, children: link.name })
885
+ }
886
+ ) }, link.name)),
887
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { style: { marginLeft: "auto" } }),
888
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) }),
889
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(Search, {}) }),
890
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
891
+ ] })
892
+ }
893
+ ) }),
894
+ links.map((link) => {
895
+ var _a;
896
+ return /* @__PURE__ */ jsx(NavigationMenu.List, { value: link.name, children: (_a = link.links) == null ? void 0 : _a.map(
897
+ (subLink) => /* @__PURE__ */ jsxs(
898
+ NavigationMenu.Item,
899
+ {
900
+ value: subLink.name,
901
+ onMouseEnter: () => setShowMenu(true),
902
+ onMouseLeave: () => setShowMenu(false),
903
+ children: [
904
+ subLink.name === "Logo" ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(
905
+ Link2,
906
+ {
907
+ href: subLink.link,
908
+ onMouseEnter: () => handleInteractions(),
909
+ onClick: () => handleInteractions(),
910
+ children: /* @__PURE__ */ jsx(
911
+ "img",
912
+ {
913
+ src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
914
+ draggable: "false",
915
+ alt: "Telia logo"
916
+ }
917
+ )
918
+ }
919
+ ) : /* @__PURE__ */ jsx(
920
+ "a",
921
+ {
922
+ href: subLink.link,
923
+ onMouseEnter: () => handleInteractions(),
924
+ onClick: () => handleInteractions(),
925
+ children: /* @__PURE__ */ jsx(
926
+ "img",
927
+ {
928
+ src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
929
+ draggable: "false",
930
+ alt: "Telia logo"
931
+ }
932
+ )
933
+ }
934
+ ) }) : /* @__PURE__ */ jsx(
935
+ NavigationMenu.Link,
936
+ {
937
+ asChild: true,
938
+ active: selectedMenuItem === subLink.name && currentLocation === subLink.link,
939
+ onFocus: () => {
940
+ handleInteractions(subLink.name);
941
+ setShowMenu(true);
942
+ },
943
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(
944
+ Link2,
945
+ {
946
+ onMouseEnter: () => handleInteractions(subLink.name),
947
+ onClick: () => {
948
+ handleInteractions(subLink.name);
949
+ setShowMenu(false);
950
+ },
951
+ href: subLink.link,
952
+ children: subLink.name
953
+ }
954
+ ) : /* @__PURE__ */ jsx(
955
+ "a",
956
+ {
957
+ onMouseEnter: () => handleInteractions(subLink.name),
958
+ onClick: () => {
959
+ handleInteractions(subLink.name);
960
+ setShowMenu(false);
961
+ },
962
+ onFocus: () => {
963
+ setShowMenu(true);
964
+ },
965
+ href: subLink.link,
966
+ children: subLink.name
967
+ }
968
+ )
969
+ }
970
+ ),
971
+ /* @__PURE__ */ jsx(
972
+ "div",
973
+ {
974
+ style: mergeStyles({ ["--teddy-viewport-wrapper-height"]: viewPortHeight }),
975
+ className: styles[`${rootClassName}__viewport-wrapper`],
976
+ "data-state": showMenu ? "open" : "closed",
977
+ children: isClientSide && /* @__PURE__ */ jsx(NavigationMenu.Content, { children: !!specifiedLink && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
978
+ subLink.links && subLink.links.length > 0 && /* @__PURE__ */ jsx(
979
+ HightlightedLinksDesktop,
980
+ {
981
+ listName: subLink.name,
982
+ setShowMenu,
983
+ links: subLink.links
984
+ }
985
+ ),
986
+ subLink.highlightedLinks && subLink.highlightedLinks.length > 0 && /* @__PURE__ */ jsx(
987
+ HightlightedLinksDesktop,
988
+ {
989
+ colored: true,
990
+ listName: "Nyttige snarveier",
991
+ setShowMenu,
992
+ links: subLink.highlightedLinks
993
+ }
994
+ )
995
+ ] }) })
996
+ }
997
+ )
998
+ ]
999
+ },
1000
+ subLink.name
1001
+ )
1002
+ ) }, link.name);
1003
+ })
1004
+ ] });
1005
+ });
1006
+ Desktop.displayName = "Desktop";
1007
+ const HightlightedLinksDesktop = ({ links, listName, colored, setShowMenu }) => {
1008
+ const rootContext = React__default.useContext(RootContext);
1009
+ if (!rootContext) return null;
1010
+ const { linkComponent: Link2, setSpecifiedLink, setSelectedMenuItem } = rootContext;
1011
+ const currentLocation = rootContext.pathname.endsWith("/") ? rootContext.pathname : `${rootContext.pathname}/`;
1012
+ const firstPart = links.slice(0, 4);
1013
+ const secondPart = links.slice(4);
1014
+ return /* @__PURE__ */ jsxs(Box, { pt: "40px", pb: "40px", className: colored ? styles[`${rootClassName}__colored-box`] : "", children: [
1015
+ /* @__PURE__ */ jsx(Heading, { pl: "100", pb: "100", variant: "title-200", as: "h2", children: listName }),
1016
+ /* @__PURE__ */ jsxs(Flex, { gap: "400", children: [
1017
+ /* @__PURE__ */ jsx(Box, { children: firstPart == null ? void 0 : firstPart.map((subSubLink) => {
1018
+ return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
1019
+ NavigationMenu.Link,
1020
+ {
1021
+ asChild: true,
1022
+ variant: "small",
1023
+ active: getActiveSubLink(currentLocation, links || []) === subSubLink.link,
1024
+ onClick: () => {
1025
+ rootContext.setPathname(subSubLink.link);
1026
+ setSpecifiedLink("");
1027
+ setSelectedMenuItem("", true);
1028
+ setShowMenu(false);
1029
+ },
1030
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
1031
+ subSubLink.name,
1032
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1033
+ ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
1034
+ subSubLink.name,
1035
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1036
+ ] }) })
1037
+ }
1038
+ ) }, subSubLink.name);
1039
+ }) }),
1040
+ /* @__PURE__ */ jsx(Box, { children: secondPart.map((subSubLink) => {
1041
+ return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
1042
+ NavigationMenu.Link,
1043
+ {
1044
+ asChild: true,
1045
+ variant: "small",
1046
+ active: getActiveSubLink(currentLocation, links || []) === subSubLink.link,
1047
+ onClick: () => {
1048
+ rootContext.setPathname(subSubLink.link);
1049
+ setSpecifiedLink("");
1050
+ setSelectedMenuItem("", true);
1051
+ setShowMenu(false);
1052
+ },
1053
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
1054
+ subSubLink.name,
1055
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1056
+ ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
1057
+ subSubLink.name,
1058
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1059
+ ] }) })
1060
+ }
1061
+ ) }, subSubLink.name);
1062
+ }) })
1063
+ ] })
1064
+ ] });
1065
+ };
1066
+ function Mobile(props) {
1067
+ const [specifiedLink, setSpecifiedLink] = React__default.useState("");
1068
+ const rootContext = React__default.useContext(RootContext);
1069
+ const drawerRef = React__default.useRef(null);
1070
+ if (!rootContext) return null;
1071
+ const links = getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale"), rootContext.customLinks);
1072
+ const { linkComponent: NavLink } = rootContext;
1073
+ const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
1074
+ const linkClasses = clsx([styles[`${rootClassName}__link`]]);
1075
+ const headerClasses = clsx([styles[`${rootClassName}__header`]]);
1076
+ return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
1077
+ Flex,
1078
+ {
1079
+ flexGrow: "1",
1080
+ justify: "between",
1081
+ align: "center",
1082
+ gap: "200",
1083
+ className: styles[`${rootClassName}__top-icon-wrapper`],
1084
+ children: [
1085
+ /* @__PURE__ */ jsx(Box, { flexShrink: "0", children: /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: rootContext.appKey === "open-pages" ? /* @__PURE__ */ jsx(NavLink, { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) : /* @__PURE__ */ jsx("a", { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) }) }),
1086
+ /* @__PURE__ */ jsxs(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, className: styles[`${rootClassName}__top-menu-icons`], children: [
1087
+ /* @__PURE__ */ jsx(Search, {}),
1088
+ /* @__PURE__ */ jsx(ShoppingCart, {}),
1089
+ /* @__PURE__ */ jsx(MyPages, {}),
1090
+ /* @__PURE__ */ jsxs(Drawer, { children: [
1091
+ /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
1092
+ /* @__PURE__ */ jsx(Icon, { name: "menu", size: "sm" }),
1093
+ " Meny"
1094
+ ] }) }) }),
1095
+ /* @__PURE__ */ jsxs(Drawer.Content, { gap: "400", size: rootContext.drawerSize, children: [
1096
+ /* @__PURE__ */ jsx(Drawer.Close, { ref: drawerRef, slot: "floating", "aria-label": "Lukk" }),
1097
+ !specifiedLink ? /* @__PURE__ */ jsxs(Fragment, { children: [
1098
+ /* @__PURE__ */ jsx(Drawer.Title, { children: "Meny" }),
1099
+ /* @__PURE__ */ jsxs(
1100
+ Tabs,
1101
+ {
1102
+ value: rootContext.selectedDomainItem,
1103
+ onValueChange: (v) => rootContext.setSelectedDomainItem(v, true),
1104
+ children: [
1105
+ /* @__PURE__ */ jsx(Tabs.List, { children: links.map((link) => /* @__PURE__ */ jsx(Tabs.Trigger, { asChild: true, value: link.name, children: link.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: link.link, children: link.name }) : /* @__PURE__ */ jsx("a", { href: link.link, children: link.name }) }, link.name)) }),
1106
+ /* @__PURE__ */ jsx(Fragment, { children: links.map((link) => {
1107
+ var _a, _b;
1108
+ return /* @__PURE__ */ jsxs(Tabs.Content, { value: link.name, children: [
1109
+ /* @__PURE__ */ jsx(Box, { mt: "400", children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
1110
+ (subLink) => subLink.links && subLink.links.length > 0 ? /* @__PURE__ */ jsxs(Box, { onClick: () => setSpecifiedLink(subLink.name), className: linkClasses, children: [
1111
+ /* @__PURE__ */ jsx(Heading, { asChild: true, variant: "title-300", children: /* @__PURE__ */ jsx(Button, { className: styles[`${rootClassName}__sublink-button--mobile`], children: subLink.name }) }),
1112
+ /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
1113
+ ] }) : /* @__PURE__ */ jsx(Fragment, { children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxs(NavLink, { href: subLink.link, className: linkClasses, children: [
1114
+ /* @__PURE__ */ jsx(Heading, { variant: "title-300", as: "h2", className: headerClasses, children: subLink.name }),
1115
+ /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
1116
+ ] }) : /* @__PURE__ */ jsxs("a", { href: subLink.link, className: linkClasses, children: [
1117
+ /* @__PURE__ */ jsx(Heading, { variant: "title-300", as: "h2", children: subLink.name }),
1118
+ /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
1119
+ ] }) })
1120
+ ) }),
1121
+ link.highlightedLinks && ((_b = link.highlightedLinks) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ jsx(Box, { className: styles[`${rootClassName}__colored-box--mobile`], children: /* @__PURE__ */ jsx(Box, { mt: "400", pt: "250", pb: "250", pl: "300", children: /* @__PURE__ */ jsx(
1122
+ HighlightedLinks,
1123
+ {
1124
+ item: link,
1125
+ links: link.highlightedLinks,
1126
+ drawerRef,
1127
+ listTitle: "Nyttige snarveier"
1128
+ }
1129
+ ) }) })
1130
+ ] }, link.name);
1131
+ }) })
1132
+ ]
1133
+ }
1134
+ )
1135
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1136
+ /* @__PURE__ */ jsx(Drawer.Title, { children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "secondary", onClick: () => setSpecifiedLink(""), children: [
1137
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-left" }),
1138
+ "Tilbake"
1139
+ ] }) }),
1140
+ /* @__PURE__ */ jsx(Box, { mt: "100", children: links.filter((item) => item.name === rootContext.selectedDomainItem).map(
1141
+ (link) => {
1142
+ var _a;
1143
+ return (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
1144
+ (subLink) => subLink.links && subLink.links.length > 0 && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
1145
+ /* @__PURE__ */ jsx(
1146
+ HighlightedLinks,
1147
+ {
1148
+ item: subLink,
1149
+ listTitle: subLink.name,
1150
+ links: subLink.links,
1151
+ drawerRef
1152
+ }
1153
+ ),
1154
+ subLink.highlightedLinks && subLink.highlightedLinks.length > 0 && /* @__PURE__ */ jsx(Box, { className: styles[`${rootClassName}__colored-box--mobile`], children: /* @__PURE__ */ jsx(Box, { mt: "400", pt: "250", pb: "250", pl: "300", children: /* @__PURE__ */ jsx(
1155
+ HighlightedLinks,
1156
+ {
1157
+ item: subLink,
1158
+ listTitle: "Nyttige snarveier",
1159
+ links: subLink.highlightedLinks,
1160
+ drawerRef
1161
+ }
1162
+ ) }) })
1163
+ ] })
1164
+ );
1165
+ }
1166
+ ) })
1167
+ ] })
1168
+ ] })
1169
+ ] })
1170
+ ] })
1171
+ ]
1172
+ }
1173
+ ) });
1174
+ }
1175
+ Mobile.displayName = "Mobile";
1176
+ const HighlightedLinks = ({
1177
+ listTitle,
1178
+ links,
1179
+ item,
1180
+ drawerRef
1181
+ }) => {
1182
+ const rootContext = React__default.useContext(RootContext);
1183
+ if (!rootContext) return null;
1184
+ const { linkComponent: NavLink } = rootContext;
1185
+ const currentLocation = rootContext.pathname;
1186
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1187
+ /* @__PURE__ */ jsx(Heading, { pl: "100", pb: "100", variant: "title-200", as: "h2", children: listTitle }),
1188
+ /* @__PURE__ */ jsx(List$1, { gap: "10", pl: "25", children: links == null ? void 0 : links.map((subSubLink) => /* @__PURE__ */ jsx(List$1.Item, { children: /* @__PURE__ */ jsx(
1189
+ NavigationMenu.Link,
1190
+ {
1191
+ asChild: true,
1192
+ variant: "small",
1193
+ active: getActiveSubLink(currentLocation, item.links || []) === subSubLink.link,
1194
+ onClick: () => {
1195
+ var _a;
1196
+ (_a = drawerRef == null ? void 0 : drawerRef.current) == null ? void 0 : _a.click();
1197
+ rootContext.setPathname(subSubLink.link);
1198
+ },
1199
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "icon" in subSubLink ? "25" : "100", align: "center", children: [
1200
+ subSubLink.name,
1201
+ subSubLink.icon ? /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon }) : /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1202
+ ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "icon" in subSubLink ? "25" : "100", align: "center", children: [
1203
+ subSubLink.name,
1204
+ subSubLink.icon ? /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon }) : /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1205
+ ] }) })
1206
+ }
1207
+ ) }, subSubLink.name)) })
1208
+ ] });
1209
+ };
1210
+ const DesktopSimplified = React__default.forwardRef(() => {
1211
+ var _a;
1212
+ const rootContext = React__default.useContext(RootContext);
1213
+ const isRetailerLoggedIn = (_a = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _a.isRetailer;
1214
+ if (!rootContext) return null;
1215
+ const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
1216
+ const isBusinessRental = rootContext.pathname.includes("bedrift/utstyrsavtale");
1217
+ const links = getLinks(isBusinessRental, rootContext.customLinks);
1218
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1219
+ links.map((link) => {
1220
+ var _a2;
1221
+ return /* @__PURE__ */ jsxs(NavigationMenu.List, { value: link.name, children: [
1222
+ (_a2 = link.links) == null ? void 0 : _a2.map((subLink) => /* @__PURE__ */ jsxs(NavigationMenu.Item, { value: subLink.name, children: [
1223
+ subLink.name === "Logo" && /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
1224
+ "img",
1225
+ {
1226
+ src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
1227
+ draggable: "false",
1228
+ alt: "Telia logo"
1229
+ }
1230
+ ) }) : /* @__PURE__ */ jsx("a", { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
1231
+ "img",
1232
+ {
1233
+ src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
1234
+ draggable: "false",
1235
+ alt: "Telia logo"
1236
+ }
1237
+ ) }) }),
1238
+ subLink.name === "Hjem" && isBusinessRental && /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, children: /* @__PURE__ */ jsx("a", { href: subLink.link, children: subLink.name }) })
1239
+ ] }, subLink.name)),
1240
+ /* @__PURE__ */ jsx(Box, { ml: "auto" }),
1241
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) }),
1242
+ isRetailerLoggedIn && /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
1243
+ ] }, link.name);
1244
+ }),
1245
+ /* @__PURE__ */ jsx(NavigationMenu.Viewport, { className: styles[`${rootClassName}__viewport`] })
1246
+ ] });
1247
+ });
1248
+ DesktopSimplified.displayName = "DesktopSimplified";
1249
+ function MobileSimplified(props) {
1250
+ const rootContext = React__default.useContext(RootContext);
1251
+ if (!rootContext) return null;
1252
+ const { linkComponent: NavLink } = rootContext;
1253
+ const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
1254
+ return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(Flex, { flexGrow: "1", justify: "between", align: "center", gap: "200", children: [
1255
+ /* @__PURE__ */ jsx(Box, { flexShrink: "0", children: /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: rootContext.appKey === "open-pages" ? /* @__PURE__ */ jsx(NavLink, { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) : /* @__PURE__ */ jsx("a", { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) }) }),
1256
+ /* @__PURE__ */ jsx(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, children: /* @__PURE__ */ jsx(ShoppingCart, {}) })
1257
+ ] }) });
1258
+ }
1259
+ MobileSimplified.displayName = "MobileSimplified";
1260
+ const rootClassName = "teddy-global-navigation";
1261
+ const RootContext = React__default.createContext(null);
1262
+ function Root({
1263
+ className,
1264
+ appKey,
1265
+ loggedInUser,
1266
+ linkComponent,
1267
+ onLogoutClick,
1268
+ shoppingCart,
1269
+ shoppingCartNumberOfItems,
1270
+ onSearchSubmit,
1271
+ additionalSearchContent,
1272
+ isCartOpen,
1273
+ onCartOpenChange,
1274
+ drawerSize = "md",
1275
+ isSimplified,
1276
+ customLinks,
1277
+ currentPath,
1278
+ onSearchInputChange,
1279
+ onSearchKeyDown,
1280
+ searchValue,
1281
+ onClear,
1282
+ ...props
1283
+ }) {
1284
+ const [selectedMenuItem, setSelectedMenuItem] = React__default.useState(getInitialMenuItem(currentPath, customLinks));
1285
+ const [selectedDomainItem, setSelectedDomainItem] = React__default.useState(getInitialDomain(currentPath, customLinks));
1286
+ const [pathname, setPathname] = React__default.useState(currentPath || "");
1287
+ const [specifiedLink, setSpecifiedLink] = React__default.useState(getInitialMenuItem(currentPath, customLinks));
1288
+ const classes = clsx([styles[`${rootClassName}`]], className);
1289
+ useEffect(() => {
1290
+ setPathname(currentPath || "");
1291
+ }, [currentPath]);
1292
+ return /* @__PURE__ */ jsx(
1293
+ RootContext.Provider,
1294
+ {
1295
+ value: {
1296
+ appKey,
1297
+ loggedInUser,
1298
+ selectedMenuItem,
1299
+ setSelectedMenuItem(v, onlyStateChange) {
1300
+ if (appKey === "open-pages" && !onlyStateChange) return;
1301
+ setSelectedMenuItem(v);
1302
+ },
1303
+ linkComponent,
1304
+ selectedDomainItem,
1305
+ setSelectedDomainItem(v, onlyStateChange) {
1306
+ if (appKey === "open-pages" && !onlyStateChange) return;
1307
+ setSelectedDomainItem(v);
1308
+ },
1309
+ pathname,
1310
+ setPathname(v) {
1311
+ if (appKey === "open-pages") return;
1312
+ setPathname(v);
1313
+ },
1314
+ onLogoutClick,
1315
+ shoppingCart,
1316
+ shoppingCartNumberOfItems,
1317
+ onSearchSubmit,
1318
+ additionalSearchContent,
1319
+ isCartOpen,
1320
+ onCartOpenChange,
1321
+ drawerSize,
1322
+ specifiedLink,
1323
+ setSpecifiedLink,
1324
+ onSearchInputChange,
1325
+ onSearchKeyDown,
1326
+ searchValue,
1327
+ onClear,
1328
+ customLinks
1329
+ },
1330
+ children: /* @__PURE__ */ jsx(Box, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
1331
+ NavigationMenu,
1332
+ {
1333
+ topMenuValue: selectedDomainItem,
1334
+ onTopMenuValueChange: setSelectedDomainItem,
1335
+ value: selectedMenuItem,
1336
+ onValueChange: (v) => {
1337
+ if (v === "" || appKey === "open-pages") return;
1338
+ setSelectedMenuItem(v);
1339
+ },
1340
+ children: [
1341
+ /* @__PURE__ */ jsxs(Box, { display: { sm: "none", lg: "block" }, children: [
1342
+ isSimplified && /* @__PURE__ */ jsx(DesktopSimplified, {}),
1343
+ !isSimplified && /* @__PURE__ */ jsx(Desktop, {})
1344
+ ] }),
1345
+ /* @__PURE__ */ jsxs(Box, { display: { lg: "none" }, children: [
1346
+ isSimplified && /* @__PURE__ */ jsx(MobileSimplified, {}),
1347
+ !isSimplified && /* @__PURE__ */ jsx(Mobile, {})
1348
+ ] })
1349
+ ]
1350
+ }
1351
+ ) })
1352
+ }
1353
+ );
1354
+ }
1355
+ Root.displayName = "Root";
1356
+ function getInitialDomain(currentPath, customLinks) {
1357
+ const privateLinks = (customLinks == null ? void 0 : customLinks.privateLinks) || DEFAULT_PRIVATE_LINKS;
1358
+ const businessLinks = (customLinks == null ? void 0 : customLinks.businessLinks) || DEFAULT_BUSINESS_LINKS;
1359
+ const mduLinks = (customLinks == null ? void 0 : customLinks.mduLinks) || DEFAULT_MDU_LINKS;
1360
+ if (!currentPath) return privateLinks.name;
1361
+ const locationArray = currentPath ? currentPath.split("/") : [];
1362
+ const domainPartOfLocation = `/${locationArray[1].toLowerCase()}/`;
1363
+ const initDomain = domainPartOfLocation === businessLinks.link ? businessLinks.name : domainPartOfLocation === mduLinks.link ? mduLinks.name : privateLinks.name;
1364
+ return initDomain;
1365
+ }
1366
+ function getInitialMenuItem(currentPath, customLinks) {
1367
+ var _a, _b, _c, _d, _e, _f;
1368
+ const privateLinks = (customLinks == null ? void 0 : customLinks.privateLinks) || DEFAULT_PRIVATE_LINKS;
1369
+ const businessLinks = (customLinks == null ? void 0 : customLinks.businessLinks) || DEFAULT_BUSINESS_LINKS;
1370
+ const mduLinks = (customLinks == null ? void 0 : customLinks.mduLinks) || DEFAULT_MDU_LINKS;
1371
+ if (!currentPath) return;
1372
+ const locationArray = currentPath ? currentPath.split("/") : [];
1373
+ const initialDomain = getInitialDomain(currentPath, customLinks);
1374
+ if (initialDomain === businessLinks.name) {
1375
+ const mainMenuPartOfLocation2 = locationArray[2];
1376
+ return (_b = (_a = businessLinks.links) == null ? void 0 : _a.find(
1377
+ (link) => {
1378
+ var _a2;
1379
+ return link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/` || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`));
1380
+ }
1381
+ )) == null ? void 0 : _b.name;
1382
+ }
1383
+ if (initialDomain === mduLinks.name) {
1384
+ const mainMenuPartOfLocation2 = locationArray[2];
1385
+ return (_d = (_c = mduLinks.links) == null ? void 0 : _c.find((link) => link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`)) == null ? void 0 : _d.name;
1386
+ }
1387
+ const mainMenuPartOfLocation = locationArray[1];
1388
+ return (_f = (_e = privateLinks.links) == null ? void 0 : _e.find((link) => {
1389
+ var _a2;
1390
+ return link.name.toLowerCase() === mainMenuPartOfLocation || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${mainMenuPartOfLocation}/`));
1391
+ })) == null ? void 0 : _f.name;
1392
+ }
1393
+ Root.displayName = "GlobalNavigation";
1394
+ const GlobalNavigation = Root;
1395
+ export {
1396
+ CheckboxCardGroup as C,
1397
+ CheckboxCardGroup,
1398
+ Close,
1399
+ Content$2 as Content,
1400
+ Desktop as D,
1401
+ Desktop,
1402
+ DesktopSimplified,
1403
+ GlobalNavigation as G,
1404
+ GlobalNavigation,
1405
+ HighlightedLinks as H,
1406
+ HighlightedLinks,
1407
+ ItemContext$1 as I,
1408
+ Indicator$1 as Indicator,
1409
+ Item$2 as Item,
1410
+ ItemContext$1 as ItemContext,
1411
+ Modal as M,
1412
+ Mobile,
1413
+ MobileSimplified,
1414
+ Modal,
1415
+ MyPages,
1416
+ NavigationMenu as N,
1417
+ NavigationMenu,
1418
+ RadioCardGroup as R,
1419
+ RadioCardGroup,
1420
+ Separator as S,
1421
+ Search,
1422
+ SearchField,
1423
+ Separator,
1424
+ ShoppingCart,
1425
+ Title$1 as T,
1426
+ Title$1 as Title,
1427
+ Content$2 as a,
1428
+ Item$2 as b,
1429
+ Title as c,
1430
+ Content$1 as d,
1431
+ ItemContext as e,
1432
+ Item$1 as f,
1433
+ Close as g,
1434
+ MyPages as h,
1435
+ SearchField as i,
1436
+ Search as j,
1437
+ ShoppingCart as k,
1438
+ Mobile as l,
1439
+ DesktopSimplified as m,
1440
+ MobileSimplified as n,
1441
+ rootClassName as o,
1442
+ RootContext as p,
1443
+ Root as q,
1444
+ rootClassName$1 as r,
1445
+ rootClassName$1 as rootClassName
1446
+ };