scb-wc 0.1.20 → 0.1.22

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.
@@ -0,0 +1,296 @@
1
+ import"../../vendor/vendor-material.js";import{_ as x,b as $,g as M,h as m,m as h,y as c}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as l}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-divider/scb-divider.js";(function(){try{var g=typeof globalThis<"u"?globalThis:window;if(!g.__scb_ce_guard_installed__){g.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,o,d){try{customElements.get(e)||t(e,o,d)}catch(r){var a=String(r||"");if(a.indexOf("already been used")===-1&&a.indexOf("NotSupportedError")===-1)throw r}}}}catch{}})();var w,p=(w=class extends x{constructor(...t){super(...t),this._currentDate=new Date,this._selectedDate=null,this._showMonthDropdown=!1,this._showYearDropdown=!1,this.variant="date",this.lang="sv",this.selectedValue="",this.open=!0,this._selectedHour=0,this._selectedMinute=0,this._viewportMargin=8,this._popupOffset=4,this._onWindowReposition=()=>{this._positionPopupWithinViewport()},this._monthNames=[this.lang=="sv"?"Januari":"January",this.lang=="sv"?"Februari":"February",this.lang=="sv"?"Mars":"March",(this.lang=="sv","April"),this.lang=="sv"?"Maj":"May",this.lang=="sv"?"Juni":"June",this.lang=="sv"?"Juli":"July",this.lang=="sv"?"Augusti":"August",(this.lang=="sv","September"),this.lang=="sv"?"Oktober":"October",(this.lang=="sv","November"),(this.lang=="sv","December")],this._outsideClickHandler=e=>{this.open&&(e.composedPath().includes(this)||this._close())},this._prevMonth=()=>{const e=this._currentDate.getFullYear(),o=this._currentDate.getMonth();o===0?this._currentDate=new Date(e-1,11,1):this._currentDate=new Date(e,o-1,1)},this._prevYear=()=>{const e=this._currentDate.getFullYear(),o=this._currentDate.getMonth();this._currentDate=new Date(e-1,o,1)},this._nextMonth=()=>{const e=this._currentDate.getFullYear(),o=this._currentDate.getMonth();o===11?this._currentDate=new Date(e+1,0,1):this._currentDate=new Date(e,o+1,1)},this._nextYear=()=>{const e=this._currentDate.getFullYear(),o=this._currentDate.getMonth();this._currentDate=new Date(e+1,o,1)},this._onTimeChange=e=>{const[o,d]=e.target.value.split(":"),a=parseInt(o,10),r=parseInt(d,10);this._selectedHour=isNaN(a)?0:Math.max(0,Math.min(23,a)),this._selectedMinute=isNaN(r)?0:Math.max(0,Math.min(59,r)),this._fireDateTimeChange()},this._close=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("datepicker-closed",{bubbles:!0,composed:!0}))}}_isRenderedInsideDialog(){const t=this.getRootNode(),e=t instanceof ShadowRoot?t.host:null;return e instanceof HTMLElement&&e.closest("scb-dialog")?!0:!!this.closest("scb-dialog")}_positionPopupWithinViewport(){if(!this.open)return;const t=this.renderRoot.querySelector(".datepicker-popup");if(!t)return;const e=this.parentElement?.getBoundingClientRect();if(!e)return;const o=window.innerWidth,d=window.innerHeight,a=Math.max(220,o-this._viewportMargin*2);if(this._isRenderedInsideDialog()){const v=Math.min(t.offsetWidth||380,a),_=t.offsetHeight||420,f=(o-v)/2,y=(d-_)/2,D=f-e.left,k=y-e.top;this.style.setProperty("--scb-datepicker-position","absolute"),this.style.setProperty("--scb-datepicker-top",`${k}px`),this.style.setProperty("--scb-datepicker-bottom","auto"),this.style.setProperty("--scb-datepicker-left",`${D}px`),this.style.setProperty("--scb-datepicker-transform","none"),this.style.setProperty("--scb-datepicker-computed-width",`${v}px`),this.style.setProperty("--scb-datepicker-max-height",`${Math.max(220,d-this._viewportMargin*2)}px`);return}const r=Math.min(t.offsetWidth||380,a),s=t.offsetHeight||420,i=Math.min(Math.max(e.left,this._viewportMargin),o-this._viewportMargin-r)-e.left,n=d-e.bottom-this._viewportMargin,u=e.top-this._viewportMargin,b=n<s+this._popupOffset&&u>n;this.style.setProperty("--scb-datepicker-position","absolute"),this.style.setProperty("--scb-datepicker-computed-width",`${r}px`),this.style.setProperty("--scb-datepicker-left","0"),this.style.setProperty("--scb-datepicker-transform",`translateX(${i}px)`),b?(this.style.setProperty("--scb-datepicker-top","auto"),this.style.setProperty("--scb-datepicker-bottom",`calc(100% + ${this._popupOffset}px)`),this.style.setProperty("--scb-datepicker-max-height",`${Math.max(0,u-this._popupOffset)}px`)):(this.style.setProperty("--scb-datepicker-top",`calc(100% + ${this._popupOffset}px)`),this.style.setProperty("--scb-datepicker-bottom","auto"),this.style.setProperty("--scb-datepicker-max-height",`${Math.max(0,n-this._popupOffset)}px`))}updated(t){if(super.updated(t),this.open?(window.addEventListener("mousedown",this._outsideClickHandler),window.addEventListener("resize",this._onWindowReposition,{passive:!0}),window.addEventListener("scroll",this._onWindowReposition,{passive:!0,capture:!0}),requestAnimationFrame(()=>this._positionPopupWithinViewport())):(window.removeEventListener("mousedown",this._outsideClickHandler),window.removeEventListener("resize",this._onWindowReposition),window.removeEventListener("scroll",this._onWindowReposition,!0)),t.has("selectedValue")&&this.selectedValue){const e=new Date(this.selectedValue);isNaN(e.getTime())||(this._selectedDate=e,this._currentDate=new Date(e.getFullYear(),e.getMonth(),1),this.variant==="datetime-local"&&(this._selectedHour=e.getHours(),this._selectedMinute=e.getMinutes()))}this.open&&requestAnimationFrame(()=>this._positionPopupWithinViewport())}disconnectedCallback(){window.removeEventListener("mousedown",this._outsideClickHandler),window.removeEventListener("resize",this._onWindowReposition),window.removeEventListener("scroll",this._onWindowReposition,!0),super.disconnectedCallback()}render(){if(!this.open)return c``;const t=this._currentDate.getFullYear(),e=this._currentDate.getMonth(),o=new Date,d=this._getMonthDays(t,e),a=Array.from({length:101},(s,i)=>o.getFullYear()-50+i),r=this.variant==="datetime-local"&&!this._showMonthDropdown&&!this._showYearDropdown;return c`
2
+ <div class="datepicker-popup popup">
3
+ <div class="header">
4
+ <div class="month-selector ${this._showMonthDropdown?"open":""} ${this._showYearDropdown?"disable":""}">
5
+ <scb-icon-button icon="chevron_left" @click=${this._prevMonth} aria-label=${this.lang=="sv"?"Föregående månad":"Previous month"}></scb-icon-button>
6
+ <div class="custom-dropdown month-dropdown">
7
+ <div
8
+ tabindex=${this._showYearDropdown?-1:0}
9
+ class="dropdown-selected"
10
+ @click=${()=>this._toggleMonthDropdown()}
11
+ @keydown=${s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),this._toggleMonthDropdown())}}
12
+ >
13
+ ${this._monthNames[e].slice(0,3)}
14
+ <md-icon>arrow_drop_down</md-icon>
15
+ <md-focus-ring></md-focus-ring>
16
+ <md-ripple></md-ripple>
17
+ </div>
18
+ </div>
19
+ <scb-icon-button icon="chevron_right" @click=${this._nextMonth} aria-label=${this.lang=="sv"?"Nästa månad":"Next month"}></scb-icon-button>
20
+ </div>
21
+ <div class="year-selector ${this._showMonthDropdown?"disable":""} ${this._showYearDropdown?"open":""}">
22
+ <scb-icon-button icon="chevron_left" @click=${this._prevYear} aria-label=${this.lang=="sv"?"Föregående år":"Previous year"}></scb-icon-button>
23
+ <div class="custom-dropdown year-dropdown">
24
+ <div
25
+ tabindex=${this._showMonthDropdown?-1:0}
26
+ class="dropdown-selected"
27
+ @click=${()=>this._toggleYearDropdown()}
28
+ @keydown=${s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),this._toggleYearDropdown())}}
29
+ >
30
+ ${t}
31
+ <md-icon>arrow_drop_down</md-icon>
32
+ <md-focus-ring></md-focus-ring>
33
+ <md-ripple></md-ripple>
34
+ </div>
35
+ </div>
36
+ <scb-icon-button icon="chevron_right" @click=${this._nextYear} aria-label=${this.lang=="sv"?"Nästa år":"Next year"}></scb-icon-button>
37
+ </div>
38
+ </div>
39
+ ${this._showMonthDropdown||this._showYearDropdown?c`<scb-divider></scb-divider>`:""}
40
+ <div class="datepicker-content" style="position:relative;">
41
+ ${this._showMonthDropdown?c`
42
+ <div class="dropdown-list">
43
+ ${this._monthNames.map((s,i)=>c`
44
+ <div
45
+ @keydown=${n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._onMonthChangeCustom(i))}}
46
+ tabindex="0"
47
+ class="dropdown-item${i===e?" selected":""}"
48
+ @click=${()=>this._onMonthChangeCustom(i)}
49
+ id=${i===e?"selected-month":""}
50
+ >
51
+ ${i===e?c`<md-icon>check</md-icon>`:""}
52
+ ${s}
53
+ <md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
54
+ </div>
55
+ `)}
56
+ </div>
57
+ `:""}
58
+ ${this._showYearDropdown?c`
59
+ <div class="dropdown-list">
60
+ ${a.map(s=>c`
61
+ <div
62
+ @keydown=${i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),this._onYearChangeCustom(s))}}
63
+ tabindex="0"
64
+ class="dropdown-item${s===t?" selected":""}"
65
+ @click=${()=>this._onYearChangeCustom(s)}
66
+ id=${s===t?"selected-year":""}
67
+ >
68
+ ${s===t?c`<md-icon>check</md-icon>`:""}
69
+ ${s}
70
+ <md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
71
+ </div>
72
+ `)}
73
+ </div>
74
+ `:""}
75
+ ${!this._showMonthDropdown&&!this._showYearDropdown?c`
76
+ <div class="datepicker-calendar">
77
+ <table>
78
+ <thead>
79
+ <tr>
80
+ <th>${this.lang=="sv"?"Må":"Mo"}</th><th>${this.lang=="sv"?"Ti":"Tu"}</th><th>${this.lang=="sv"?"On":"We"}</th><th>${this.lang=="sv"?"To":"Th"}</th><th>${this.lang=="sv","Fr"}</th><th>${this.lang=="sv"?"Lö":"Sa"}</th><th>${this.lang=="sv"?"Sö":"Su"}</th>
81
+ </tr>
82
+ </thead>
83
+ <tbody>
84
+ ${d.map(s=>c`
85
+ <tr>
86
+ ${s.map(i=>i?c`
87
+ <td>
88
+ <div
89
+ @keydown=${n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._selectDate(i))}}
90
+ role="button"
91
+ tabindex="0"
92
+ class="day${this._isToday(i,o)?" today":""}${this._isSelected(i)?" selected":""}"
93
+ @click=${()=>this._selectDate(i)}
94
+ >${i.getDate()}<md-ripple></md-ripple><md-focus-ring></md-focus-ring></div>
95
+ </td>
96
+ `:c`<td></td>`)}
97
+ </tr>
98
+ `)}
99
+ </tbody>
100
+ </table>
101
+ </div>
102
+ `:""}
103
+ </div>
104
+ ${r?c`
105
+ <div style="padding: 0 24px;">
106
+ <label style="display:flex;align-items:center;gap:8px;">
107
+ <span>${this.lang=="sv"?"Tid:":"Time:"}</span>
108
+ <scb-textfield type="time" .value=${`${String(this._selectedHour).padStart(2,"0")}:${String(this._selectedMinute).padStart(2,"0")}`} @blur=${this._onTimeChange} aria-label="${this.lang=="sv"?"Tid":"Time"}"></scb-textfield>
109
+ </label>
110
+ </div>
111
+ `:""}
112
+ <div class="datepicker-footer">
113
+ ${!this._showMonthDropdown&&!this._showYearDropdown?c`
114
+ <scb-button variant="text" label=${this.lang=="sv"?"Stäng":"Close"} @click=${this._close}></scb-button>
115
+ `:""}
116
+ </div>
117
+ </div>
118
+ `}_getMonthDays(t,e){const o=new Date(Date.UTC(t,e,1)),d=new Date(Date.UTC(t,e+1,0)),a=[];let r=[],s=o.getUTCDay(),i=s===0?6:s-1;for(let n=0;n<i;n++)r.push(null);for(let n=1;n<=d.getUTCDate();n++){const u=new Date(Date.UTC(t,e,n));r.push(u),r.length===7&&(a.push(r),r=[])}if(r.length){for(;r.length<7;)r.push(null);a.push(r)}return a}_toggleMonthDropdown(){this._showMonthDropdown=!this._showMonthDropdown,this._showMonthDropdown&&(this._showYearDropdown=!1,setTimeout(()=>{const t=this.renderRoot.querySelector("#selected-month");t&&t.scrollIntoView({block:"center"})},0))}_toggleYearDropdown(){this._showYearDropdown=!this._showYearDropdown,this._showYearDropdown&&(this._showMonthDropdown=!1,setTimeout(()=>{const t=this.renderRoot.querySelector("#selected-year");t&&t.scrollIntoView({block:"center"})},0))}_onMonthChangeCustom(t){const e=this._currentDate.getFullYear();this._currentDate=new Date(e,t,1),this._showMonthDropdown=!1}_onYearChangeCustom(t){const e=this._currentDate.getMonth();this._currentDate=new Date(t,e,1),this._showYearDropdown=!1}_isToday(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_isSelected(t){return this._selectedDate&&t.getDate()===this._selectedDate.getDate()&&t.getMonth()===this._selectedDate.getMonth()&&t.getFullYear()===this._selectedDate.getFullYear()}_selectDate(t){if(this._selectedDate=t,this.variant==="datetime-local"){const e=new Date(t);e.setHours(this._selectedHour??0,this._selectedMinute??0,0,0),this._selectedHour=e.getHours(),this._selectedMinute=e.getMinutes();const o=a=>a.toString().padStart(2,"0"),d=`${e.getFullYear()}-${o(e.getMonth()+1)}-${o(e.getDate())} ${o(e.getHours())}:${o(e.getMinutes())}`;this.dispatchEvent(new CustomEvent("date-selected",{detail:{value:d},bubbles:!0,composed:!0}))}else{const e=t.toISOString().slice(0,10);this.dispatchEvent(new CustomEvent("date-selected",{detail:{value:e},bubbles:!0,composed:!0}))}}_fireDateTimeChange(){if(this.variant==="datetime-local"&&this._selectedDate){const t=new Date(this._selectedDate);t.setHours(this._selectedHour??0,this._selectedMinute??0,0,0);const e=d=>d.toString().padStart(2,"0"),o=`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())} ${e(t.getHours())}:${e(t.getMinutes())}`;this.dispatchEvent(new CustomEvent("date-selected",{detail:{value:o},bubbles:!0,composed:!0}))}}},w.styles=[$`
119
+ :host {
120
+ --scb-datepicker-width: 380px;
121
+ --scb-datepicker-z-index: 1100;
122
+ --scb-datepicker-viewport-margin: 8px;
123
+ --scb-datepicker-offset: var(--spacing-2, 4px);
124
+ max-width: var(--scb-datepicker-computed-width, min(var(--scb-datepicker-width), calc(100vw - (var(--scb-datepicker-viewport-margin) * 2))));
125
+ font-family: var(--brand-font);
126
+ color: var(--md-sys-color-on-surface);
127
+ display: block;
128
+ position: var(--scb-datepicker-position, absolute);
129
+ top: var(--scb-datepicker-top, calc(100% + var(--scb-datepicker-offset)));
130
+ bottom: var(--scb-datepicker-bottom, auto);
131
+ left: var(--scb-datepicker-left, 0);
132
+ width: var(--scb-datepicker-computed-width, min(var(--scb-datepicker-width), calc(100vw - (var(--scb-datepicker-viewport-margin) * 2))));
133
+ transform: var(--scb-datepicker-transform, translateX(0px));
134
+ z-index: var(--scb-datepicker-z-index);
135
+ }
136
+ .month-selector, .year-selector {
137
+ display: flex;
138
+ align-items: center;
139
+ &.disable{
140
+ pointer-events: none;
141
+ opacity: 0.3;
142
+ scb-icon-button{
143
+ visibility: hidden;
144
+ }
145
+ }
146
+ &.open{
147
+ scb-icon-button{
148
+ visibility: hidden;
149
+ }
150
+ .dropdown-selected{
151
+ background: var(--md-sys-color-secondary-container);
152
+ }
153
+ }
154
+ }
155
+ .dropdown-selected {
156
+ position: relative;
157
+ border-radius: 8px;
158
+ font-size: 16px;
159
+ cursor: pointer;
160
+ text-align: left;
161
+ display: flex;
162
+ gap: 8px;
163
+ align-items: center;
164
+ padding: 4px 8px;
165
+ }
166
+ .dropdown-selected:focus {
167
+ outline: none;
168
+ }
169
+ .dropdown-selected md-focus-ring {
170
+ border-radius: 8px;
171
+ }
172
+ .dropdown-list {
173
+ position: relative;
174
+ background: var(--md-sys-color-surface);
175
+ padding: 4px 0;
176
+ }
177
+ .dropdown-item {
178
+ display: flex;
179
+ position: relative;
180
+ cursor: pointer;
181
+ padding: var(--spacing-3) 56px;
182
+ min-height: 40px;
183
+ align-items: center;
184
+ }
185
+ .dropdown-item:focus-within {
186
+ outline: none;
187
+ }
188
+ .dropdown-item md-focus-ring {
189
+ border-radius: var(--md-sys-shape-corner-small);
190
+ }
191
+ .dropdown-item.selected {
192
+ background: var(--md-sys-color-secondary-container, #e3f2fd);
193
+ font-weight: 500;
194
+ padding-left: 16px;
195
+ gap: 16px;
196
+ }
197
+ .datepicker-popup {
198
+ background: var(--md-sys-color-surface);
199
+ border-radius: var(--md-sys-shape-corner-small);
200
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.30), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
201
+ max-width: 100%;
202
+ width: 100%;
203
+ max-height: var(--scb-datepicker-max-height, 80vh);
204
+ overflow: auto;
205
+ font-family: var(--brand-font);
206
+ }
207
+ .datepicker-content{
208
+ overflow-y: auto;
209
+ max-height: 290px;
210
+ }
211
+ .datepicker-content::-webkit-scrollbar {
212
+ width: 12px;
213
+ background: var(--md-sys-color-surface);
214
+ border-radius: var(--md-sys-shape-corner-small);
215
+ }
216
+ .datepicker-content::-webkit-scrollbar-thumb {
217
+ background: var(--md-sys-color-outline);
218
+ border-radius: var(--md-sys-shape-corner-small);
219
+ border: 4px solid var(--md-sys-color-surface);
220
+
221
+ }
222
+ .datepicker-content::-webkit-scrollbar-track {
223
+ background: var(--md-sys-color-surface);
224
+ border-radius: var(--md-sys-shape-corner-small);
225
+ }
226
+ .popup {
227
+ position:absolute;
228
+ top:0;
229
+ left:0;
230
+ z-index:1;
231
+ }
232
+ .header {
233
+ display: flex;
234
+ align-items: center;
235
+ justify-content: space-between;
236
+ margin-bottom: 30px;
237
+ padding: 20px 16px 0px 16px;
238
+ flex-wrap: wrap;
239
+ }
240
+ .datepicker-footer{
241
+ padding: 8px 16px 24px 16px;
242
+ }
243
+ .month-label {
244
+ font-size: 18px;
245
+ font-weight: 500;
246
+ }
247
+ .datepicker-calendar{
248
+ padding: 0 16px;
249
+ }
250
+ table {
251
+ width: 100%;
252
+ border-collapse: collapse;
253
+ margin-bottom: 8px;
254
+ }
255
+ th {
256
+ color: var(--md-sys-color-on-surface-variant, #757575);
257
+ font-size: 16px;
258
+ font-weight: 600;
259
+ padding-bottom: 20px;
260
+ }
261
+ td {
262
+ text-align: center;
263
+ }
264
+
265
+ .day:focus-within{
266
+ outline: none;
267
+ }
268
+ .day {
269
+ position: relative;
270
+ width: 40px;
271
+ height: 40px;
272
+ border-radius: 50%;
273
+ border: none;
274
+ background: none;
275
+ font-size: 16px;
276
+ cursor: pointer;
277
+ font-family: 'Inter';
278
+ align-content: center;
279
+ }
280
+ .day.selected {
281
+ background: var(--md-sys-color-secondary-container);
282
+ }
283
+ .close-datepicker {
284
+ margin-top: 8px;
285
+ background: none;
286
+ border-color: none;
287
+ color: var(--md-sys-color-primary, #0057b8);
288
+ font-size: 16px;
289
+ cursor: pointer;
290
+ padding: 4px 12px;
291
+ border-radius: 8px;
292
+ }
293
+ .close-datepicker:hover {
294
+ background: var(--md-sys-color-primary-container, #e3f2fd);
295
+ }
296
+ `],w);l([h()],p.prototype,"_currentDate",void 0);l([h()],p.prototype,"_selectedDate",void 0);l([h()],p.prototype,"_showMonthDropdown",void 0);l([h()],p.prototype,"_showYearDropdown",void 0);l([m({type:String})],p.prototype,"variant",void 0);l([m({type:String})],p.prototype,"lang",void 0);l([m({type:String})],p.prototype,"selectedValue",void 0);l([m({type:Boolean})],p.prototype,"open",void 0);l([h()],p.prototype,"_selectedHour",void 0);l([h()],p.prototype,"_selectedMinute",void 0);p=l([M("scb-datepicker")],p);
@@ -1,4 +1,4 @@
1
- import"../../vendor/vendor-material.js";import{_ as y,b as v,g as w,h as d,p as b,v as f,y as m}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as a}from"../../vendor/decorate.js";import"../../vendor/scb-chevron.js";import"../scb-button/scb-button.js";import"../scb-options-menu/scb-options-menu.js";(function(){try{var h=typeof globalThis<"u"?globalThis:window;if(!h.__scb_ce_guard_installed__){h.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,i,s){try{customElements.get(e)||t(e,i,s)}catch(o){var n=String(o||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var g,_=()=>{if(typeof window>"u"||typeof document>"u"||!("customElements"in window)||document.head.querySelector("style[data-scb-dropdown-pre-upgrade]"))return;const h=document.createElement("style");h.setAttribute("data-scb-dropdown-pre-upgrade",""),h.textContent=`
1
+ import"../../vendor/vendor-material.js";import{_ as y,b as v,g as w,h as d,p as b,v as f,y as m}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as a}from"../../vendor/decorate.js";import"../scb-chevron/scb-chevron.js";import"../scb-button/scb-button.js";import"../scb-options-menu/scb-options-menu.js";(function(){try{var h=typeof globalThis<"u"?globalThis:window;if(!h.__scb_ce_guard_installed__){h.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,i,s){try{customElements.get(e)||t(e,i,s)}catch(o){var n=String(o||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var g,_=()=>{if(typeof window>"u"||typeof document>"u"||!("customElements"in window)||document.head.querySelector("style[data-scb-dropdown-pre-upgrade]"))return;const h=document.createElement("style");h.setAttribute("data-scb-dropdown-pre-upgrade",""),h.textContent=`
2
2
  scb-dropdown:not(:defined) {
3
3
  display: inline-block;
4
4
  position: relative;
@@ -43,7 +43,7 @@ import"../../vendor/vendor-material.js";import{_ as k,b as C,g as T,h as d,m as
43
43
  );
44
44
  }
45
45
  }
46
- `,document.head.appendChild(b);const e=i=>{const r=String(i??"").trim();if(r)return/^\d+$/.test(r)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(r,10)))})`:r},s=i=>{const r=String(i??"").trim();if(!r)return!1;try{const u=JSON.parse(r);return Array.isArray(u)&&u.length>0}catch{return!1}},t=i=>{for(const r of Array.from(i.children)){const u=r.tagName.toLowerCase();if(u==="scb-header-tab"||u==="scb-dropdown")return!0}return!1},a=i=>{t(i)||s(i.getAttribute("tabs"))?i.setAttribute("data-pre-has-tabs",""):i.removeAttribute("data-pre-has-tabs");const r=e(i.getAttribute("spacing")),u=e(i.getAttribute("spacing-top"))??r,h=e(i.getAttribute("spacing-bottom"))??r;u?i.style.setProperty("--scb-header-spacing-block-start",u):i.style.removeProperty("--scb-header-spacing-block-start"),h?i.style.setProperty("--scb-header-spacing-block-end",h):i.style.removeProperty("--scb-header-spacing-block-end");const p=(i.getAttribute("logo-width")??"").trim();p?i.style.setProperty("--scb-header-pre-logo-w",p):i.style.removeProperty("--scb-header-pre-logo-w");const v=(i.getAttribute("logo-height")??"").trim();v?i.style.setProperty("--scb-header-pre-logo-img-h",v):i.style.removeProperty("--scb-header-pre-logo-img-h");const f=(i.getAttribute("search-height")??"").trim();f?i.style.setProperty("--scb-header-pre-control-size",f):i.style.removeProperty("--scb-header-pre-control-size")};document.querySelectorAll("scb-header").forEach(a);const o=new MutationObserver(i=>{for(const r of i){if(r.type==="attributes"){const u=r.target;u instanceof HTMLElement&&u.tagName.toLowerCase()==="scb-header"&&a(u);continue}if(r.type==="childList"){const u=[...Array.from(r.addedNodes),...Array.from(r.removedNodes)];for(const h of u){if(!(h instanceof HTMLElement))continue;if(h.tagName.toLowerCase()==="scb-header"){a(h);continue}const p=h.closest?.("scb-header");p&&a(p)}}}});o.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabs","spacing","spacing-top","spacing-bottom","logo-width","logo-height","logo-aspect-ratio","search-height"]}),customElements.whenDefined("scb-header").then(()=>{o.disconnect()})};E();var x={fromAttribute:b=>b==null?!0:!/^(false|0|off|no)$/i.test(b),toAttribute:b=>String(!!b)},S={fromAttribute:b=>b==null?!1:!/^(false|0|off|no)$/i.test(b),toAttribute:b=>String(!!b)},M={fromAttribute:b=>b==="small"||b==="large"?b:"medium",toAttribute:b=>{const e=String(b??"");return e==="small"||e==="large"?e:null}},l=(_=class extends k{constructor(){super(),this.maxWidth="1440px",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.size="medium",this.logoText="",this.logoHref="/",this.logoSrc="",this.logoWidth="",this.logoHeight="",this.logoAspectRatio="",this.logoInvertDm=!1,this.banner=!1,this.tabs=[],this.activeTab=null,this.reserveTabs=!1,this.utilityItems=[],this.showDrawer=!0,this.showSearch=!0,this.includeUtilityInMenu=!1,this.drawerOverlay=!0,this.searchText="",this._drawerId="main-drawer",this._menuExpanded=!1,this._searchId="header-search",this._slotNavItems=[],this._slotUtils=[],this._slotMenu=[],this._measureScheduled=!1,this._scheduleMeasure=()=>{this._measureScheduled||(this._measureScheduled=!0,requestAnimationFrame(()=>{this._measureScheduled=!1,this._measure()}))},this._onWindowResize=()=>{this._scheduleMeasure()},this._onMenuSelect=s=>{const t=s.detail;this.dispatchEvent(new CustomEvent("scb-menu-select",{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbmenuselect",{detail:t,bubbles:!0,composed:!0}));const a=t?.item,n=typeof t?.href=="string"?t.href:typeof t?.itemHref=="string"?t.itemHref:typeof t?.item_href=="string"?t.item_href:"",o=a?a.getAttribute("item-href")??a.getAttribute("href")??"":"";String(n||o||"").trim()&&this._closeDrawerNow()},this._collapsed=!1,this._unlockAtWidth=0,this._hideLogoText=!1,this._logoTextUnlockAt=0,this._slotWatchers=[],this._harvestPending=!1,this._harvest=()=>{const s=Array.from(this.children),t=[],a=[],n=[];let o=-1;const i=r=>({label:r.getAttribute("label")??"",href:r.getAttribute("href")??void 0,icon:r.getAttribute("icon")??void 0});for(const r of s){const u=r.tagName.toLowerCase();if(u==="scb-header-tab"){const h=r.getAttribute("label")??"",p=r.getAttribute("href"),v=p&&p.trim()!==""?p:void 0;(r.hasAttribute("selected")||r.getAttribute("selected")==="true"||r.getAttribute("active")==="true"||r.getAttribute("aria-current")==="page")&&o===-1&&(o=t.length),t.push({kind:"tab",label:h,href:v});continue}if(u==="scb-badge"){const h=r.querySelector("scb-dropdown");if(h){const p=h.getAttribute("label")??"";(h.hasAttribute("selected")||h.getAttribute("selected")==="true"||h.getAttribute("active")==="true"||h.getAttribute("aria-current")==="page")&&o===-1&&(o=t.length);const v=`scb-header-tab-${t.length}`;r.getAttribute("slot")!==v&&r.setAttribute("slot",v),h.hasAttribute("slot")&&h.removeAttribute("slot"),h.hasAttribute("as-tab")||h.setAttribute("as-tab",""),t.push({kind:"dropdown",slotName:v,label:p});continue}}if(u==="scb-dropdown"){const h=r.getAttribute("label")??"";(r.hasAttribute("selected")||r.getAttribute("selected")==="true"||r.getAttribute("active")==="true"||r.getAttribute("aria-current")==="page")&&o===-1&&(o=t.length);const p=`scb-header-tab-${t.length}`;r.getAttribute("slot")!==p&&r.setAttribute("slot",p),r.hasAttribute("as-tab")||r.setAttribute("as-tab",""),t.push({kind:"dropdown",slotName:p,label:h});continue}if(u==="scb-header-utility"){a.push({label:r.getAttribute("label")??"",href:r.getAttribute("href")??"#",target:r.getAttribute("target")??void 0});continue}if(u==="scb-header-menu-group"){const h={label:r.getAttribute("label")??"",icon:r.getAttribute("icon")??void 0,children:[]};r.querySelectorAll("scb-header-menu-item").forEach(p=>h.children.push(i(p))),n.push(h);continue}u==="scb-header-menu-item"&&n.push(i(r))}this._slotNavItems=t,this._slotUtils=a,this._slotMenu=n,!this.hasAttribute("active-tab")&&o>=0&&(this.activeTab=o),queueMicrotask(()=>{this.updateComplete.then(()=>{this._scheduleMeasure()})})},this._measure=()=>{const s=this._top,t=this._logoGroup;if(!s||!t)return;const a=window.innerWidth,n=s.clientWidth,o=this._overflows(this._util),i=this._tabsOverflows(),r=a<this.BP_MD||o||i;this._collapsed?!r&&n>=this._unlockAtWidth&&this._setCollapsed(!1):r&&(this._unlockAtWidth=n+this._HYST,this._setCollapsed(!0));let u=!1;if(this.showSearch&&a>=this.BP_SM&&a<this.BP_MD&&this._searchWrap){const p=getComputedStyle(this._searchWrap),v=Math.max(this._num(p.minWidth,this._tokenPx("--scb-header-search-min",320)),this._tokenPx("--scb-header-search-min",320)),f=this._num(getComputedStyle(s).gap,this._tokenPx("--spacing-7",24)),A=this.showDrawer&&(a<this.BP_MD||this._collapsed)?this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48):0;u=t.getBoundingClientRect().width+f+v+f+A+8>n+.5}this._setHideSearch(u);let h=!1;if(this.showDrawer&&(a<this.BP_MD||this._collapsed)&&!this._visible(this._util)&&!this._visible(this._searchWrap)){const p=this._num(getComputedStyle(s).gap,this._tokenPx("--spacing-7",24)),v=this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48),f=(this._logoGroup?.getBoundingClientRect().width||0)+p+v;this._hideLogoText?h=!(n>=this._logoTextUnlockAt):f>n+.5&&(h=!0,this._logoTextUnlockAt=n+this._HYST)}else h=!1,this._logoTextUnlockAt=0;this._setHideLogoText(h)},this._onDrawerOpened=()=>{this._menuExpanded=!0,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("draweropen",{bubbles:!0,composed:!0}))},this._onDrawerClosed=()=>{this._menuExpanded=!1,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-close",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("drawerclose",{bubbles:!0,composed:!0}))},this._onMenuClick=s=>{this.showDrawer&&(this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("menuclick",{bubbles:!0,composed:!0})))},this._onSearchClick=s=>{const t=this._searchEl;if(t?.submit&&typeof t.submit=="function"){t.submit();return}const a=t?.value??"";this.searchText=a,this.dispatchEvent(new CustomEvent("search-click",{detail:{value:a},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchclick",{detail:{value:a},bubbles:!0,composed:!0})),t?.focus?.()},this._onTabClick=s=>{const t=s.currentTarget;if(!t)return;const a=t.tagName.toLowerCase()==="a";if(a&&(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey))return;const n=t.getAttribute("data-index"),o=n!=null?Number(n):0,i=this._getNavItems()[o];if(i?.kind==="dropdown")return;this.activeTab=o;const r=i?.kind==="tab"?i.href??"":"",u=new CustomEvent("tab-change",{detail:{index:o,href:r},bubbles:!0,composed:!0,cancelable:!0}),h=new CustomEvent("tabchange",{detail:{index:o,href:r},bubbles:!0,composed:!0,cancelable:!0});!(this.dispatchEvent(u)&&this.dispatchEvent(h))&&a&&s.preventDefault()},this._onDropdownTabActivate=s=>{const t=s.detail?.dataIndex,a=typeof t=="number"?t:typeof t=="string"?Number(t):this._readTabIndexFromEvent(s);if(a==null||!Number.isFinite(a))return;const n=this._getNavItems();a<0||a>=n.length||n[a]?.kind==="dropdown"&&(this.activeTab=a,this.dispatchEvent(new CustomEvent("tab-change",{detail:{index:a,href:""},bubbles:!0,composed:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("tabchange",{detail:{index:a,href:""},bubbles:!0,composed:!0,cancelable:!0})))},this._onTabsKeydown=s=>{const t=s.key;if(t!=="ArrowLeft"&&t!=="ArrowRight"&&t!=="Home"&&t!=="End")return;const a=this._getNavItems();if(!a.length)return;const n=this._readTabIndexFromEvent(s);if(n==null)return;let o=Math.max(0,Math.min(a.length-1,n));t==="ArrowRight"?o=(o+1)%a.length:t==="ArrowLeft"?o=(o-1+a.length)%a.length:t==="Home"?o=0:t==="End"&&(o=a.length-1),s.preventDefault(),this._focusTabAtIndex(o)},this._onSearchInput=s=>{this.searchText=s.detail?.value??"",this.dispatchEvent(new CustomEvent("search-input",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchinput",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:this.searchText},bubbles:!0,composed:!0}))},this._onSearchSubmit=s=>{this.searchText=s.detail?.value??"",this.dispatchEvent(new CustomEvent("search-change",{detail:{value:this.searchText,active:s.detail?.active},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchchange",{detail:{value:this.searchText,active:s.detail?.active},bubbles:!0,composed:!0}))},this._onSearchClear=()=>{this.searchText="",this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:""},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:""},bubbles:!0,composed:!0}))};const e=++$;this._drawerId=`scb-header-drawer-${e}`,this._searchId=`scb-header-search-${e}`}get _HYST(){return this._tokenPx("--spacing-11",64)}get BP_SM(){return this._tokenPx("--bp-sm",w.BP_SM_DEFAULT)}get BP_MD(){return this._tokenPx("--bp-md",w.BP_MD_DEFAULT)}_scheduleHarvest(){this._harvestPending||(this._harvestPending=!0,queueMicrotask(()=>{this._harvestPending=!1,this._harvest()}))}get _top(){return this.renderRoot.querySelector(".top-row")}get _util(){return this.renderRoot.querySelector(".utility")}get _logoGroup(){return this.renderRoot.querySelector(".logo-wrap")||this.renderRoot.querySelector(".logo-group")}get _searchWrap(){return this.renderRoot.querySelector(".search")}get _menuBtn(){return this.renderRoot.querySelector(".menu-trigger")}get _searchEl(){return this.renderRoot.querySelector(`#${this._searchId}`)}get _tabsNav(){return this.renderRoot.querySelector(".tabs-nav")}_attachSlotObservers(){this._slotMo?.disconnect(),this._slotWatchers.forEach(n=>n.disconnect()),this._slotWatchers=[];const e=["label","href","icon","target","selected","aria-current","active"],s=n=>{const o=new MutationObserver(i=>{this._scheduleHarvest()});this._slotWatchers.push(o),o.observe(n,{attributes:!0,attributeFilter:e})},t=()=>{this._slotWatchers.forEach(o=>o.disconnect()),this._slotWatchers=[];const n=Array.from(this.children);for(const o of n){const i=o.tagName.toLowerCase();if((i==="scb-header-tab"||i==="scb-dropdown"||i==="scb-header-utility"||i==="scb-header-menu-item"||i==="scb-header-menu-group"||i==="scb-badge")&&s(o),i==="scb-badge"){const r=o,u=new MutationObserver(p=>{t(),this._scheduleHarvest()});this._slotWatchers.push(u),u.observe(r,{childList:!0});const h=r.querySelector("scb-dropdown");h&&s(h);continue}if(i==="scb-header-menu-group"){const r=o,u=new MutationObserver(h=>{t(),this._scheduleHarvest()});this._slotWatchers.push(u),u.observe(r,{childList:!0,subtree:!0}),r.querySelectorAll("scb-header-menu-item").forEach(h=>s(h))}}},a=new MutationObserver(n=>{let o=!1;for(const i of n)if(i.type==="childList"){o=!0;break}o&&t(),this._scheduleHarvest()});this._slotMo=a,a.observe(this,{childList:!0}),t()}_setCollapsed(e){this._collapsed!==e&&(this._collapsed=e,e?this.setAttribute("data-collapsed",""):this.removeAttribute("data-collapsed"))}_setHideSearch(e){e?this.setAttribute("data-hide-search",""):this.removeAttribute("data-hide-search")}_setHideLogoText(e){this._hideLogoText!==e&&(this._hideLogoText=e,e?this.setAttribute("data-hide-logo-text",""):this.removeAttribute("data-hide-logo-text"))}_num(e,s){const t=Number.parseFloat(String(e??"").trim());return Number.isFinite(t)?t:s}_tokenPx(e,s){const t=getComputedStyle(this);return this._num(t.getPropertyValue(e),s)}_visible(e){return e?getComputedStyle(e).display!=="none":!1}_overflows(e){return!e||!this._visible(e)?!1:e.scrollWidth>e.clientWidth+1}_tabsOverflows(){const e=this._tabsNav;if(!e||!this._visible(e))return!1;const s=Array.from(e.querySelectorAll(".tab-wrap"));if(s.length===0)return!1;const t=e.getBoundingClientRect();let a=t.left;for(const n of s){const o=n.getBoundingClientRect();o.width<=0||o.right>a&&(a=o.right)}return a-t.left>t.width+1}firstUpdated(){this.updateComplete.then(()=>{this._harvest(),this._attachSlotObservers(),this._syncDropdownTabs()});const e=this._top;e&&(this._ro=new ResizeObserver(()=>this._scheduleMeasure()),this._ro.observe(e)),window.addEventListener("resize",this._onWindowResize,{passive:!0})}updated(e){e.has("searchMax")&&this.style.setProperty("--scb-header-search-max",this.searchMax??"480px"),e.has("searchMin")&&this.style.setProperty("--scb-header-search-min",this.searchMin??"320px"),e.has("searchHeight")&&(this.searchHeight&&this.searchHeight.trim()?this.style.setProperty("--scb-search-height",this.searchHeight.trim()):this.style.removeProperty("--scb-search-height")),(e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio"))&&this._applyLogoSizing(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom"))&&this._applySpacing(),(e.has("utilityItems")||e.has("tabs")||e.has("logoText")||e.has("logoSrc")||e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio")||e.has("activeTab")||e.has("_slotNavItems")||e.has("_slotUtils")||e.has("_slotMenu")||e.has("showDrawer")||e.has("showSearch")||e.has("searchMax")||e.has("searchMin")||e.has("size"))&&this.updateComplete.then(()=>{this._scheduleMeasure()}),(e.has("activeTab")||e.has("_slotNavItems")||e.has("tabs")||e.has("size"))&&this.updateComplete.then(()=>{this._syncDropdownTabs()})}disconnectedCallback(){this._ro?.disconnect(),this._slotMo?.disconnect(),this._slotWatchers.forEach(e=>e.disconnect()),this._slotWatchers=[],window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}_mapSpacingToken(e){if(!e)return;const s=String(e).trim();if(s)return/^\d+$/.test(s)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(s,10)))})`:s}_applySpacing(){const e=this._mapSpacingToken(this.spacing),s=this._mapSpacingToken(this.spacingTop)??e,t=this._mapSpacingToken(this.spacingBottom)??e;s?this.style.setProperty("--scb-header-spacing-block-start",s):this.style.removeProperty("--scb-header-spacing-block-start"),t?this.style.setProperty("--scb-header-spacing-block-end",t):this.style.removeProperty("--scb-header-spacing-block-end")}_applyLogoSizing(){const e=(this.logoWidth??"").trim(),s=(this.logoHeight??"").trim(),t=(this.logoAspectRatio??"").trim();e?this.style.setProperty("--scb-header-logo-img-w",e):this.style.removeProperty("--scb-header-logo-img-w"),s?this.style.setProperty("--scb-header-logo-img-h",s):e?this.style.setProperty("--scb-header-logo-img-h","auto"):this.style.removeProperty("--scb-header-logo-img-h"),t?this.style.setProperty("--scb-header-logo-img-aspect-ratio",t):this.style.removeProperty("--scb-header-logo-img-aspect-ratio")}_closeDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!1)}_syncMenuBtnAria(){const e=this.renderRoot.querySelector(".menu-trigger");e&&e.setAttribute("aria-expanded",String(this._menuExpanded))}_getNavItems(){return this._slotNavItems.length?this._slotNavItems:(this.tabs??[]).map(e=>({kind:"tab",...e}))}_getDropdownForSlot(e){const s=this.querySelector(`[slot="${e}"]`);return s?s.tagName.toLowerCase()==="scb-dropdown"?s:s.querySelector("scb-dropdown"):null}_syncDropdownTabs(){this._getNavItems().forEach((e,s)=>{if(e.kind!=="dropdown")return;const t=this._getDropdownForSlot(e.slotName);if(!t)return;const a=String(s);t.getAttribute("data-index")!==a&&t.setAttribute("data-index",a),t.hasAttribute("as-tab")||t.setAttribute("as-tab","");const n=this.size,o=t;o?.size!==n&&(o.size=n),s===this.activeTab?t.getAttribute("aria-current")!=="page"&&t.setAttribute("aria-current","page"):t.hasAttribute("aria-current")&&t.removeAttribute("aria-current")})}_readTabIndexFromEvent(e){const s=e.composedPath?e.composedPath():[];for(const t of s){if(!(t instanceof HTMLElement))continue;const a=t.getAttribute("data-index");if(a==null)continue;const n=Number(a);if(Number.isFinite(n))return n}return null}_focusTabAtIndex(e){const s=this._getNavItems()[e];if(s){if(s.kind==="dropdown"){this._getDropdownForSlot(s.slotName)?.focus?.();return}this.renderRoot.querySelector(`.tab-link[data-index="${e}"]`)?.focus?.()}}_renderMenuNodes(e){return!e||e.length===0?m``:m`${e.map(s=>this._renderMenuNode(s))}`}_renderMenuNode(e){const s=Array.isArray(e.children)&&e.children.length>0,t=(e.href??"").trim(),a=(e.icon??"").trim();return m`
46
+ `,document.head.appendChild(b);const e=i=>{const r=String(i??"").trim();if(r)return/^\d+$/.test(r)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(r,10)))})`:r},s=i=>{const r=String(i??"").trim();if(!r)return!1;try{const u=JSON.parse(r);return Array.isArray(u)&&u.length>0}catch{return!1}},t=i=>{for(const r of Array.from(i.children)){const u=r.tagName.toLowerCase();if(u==="scb-header-tab"||u==="scb-dropdown")return!0}return!1},a=i=>{t(i)||s(i.getAttribute("tabs"))?i.setAttribute("data-pre-has-tabs",""):i.removeAttribute("data-pre-has-tabs");const r=e(i.getAttribute("spacing")),u=e(i.getAttribute("spacing-top"))??r,h=e(i.getAttribute("spacing-bottom"))??r;u?i.style.setProperty("--scb-header-spacing-block-start",u):i.style.removeProperty("--scb-header-spacing-block-start"),h?i.style.setProperty("--scb-header-spacing-block-end",h):i.style.removeProperty("--scb-header-spacing-block-end");const p=(i.getAttribute("logo-width")??"").trim();p?i.style.setProperty("--scb-header-pre-logo-w",p):i.style.removeProperty("--scb-header-pre-logo-w");const v=(i.getAttribute("logo-height")??"").trim();v?i.style.setProperty("--scb-header-pre-logo-img-h",v):i.style.removeProperty("--scb-header-pre-logo-img-h");const f=(i.getAttribute("search-height")??"").trim();f?i.style.setProperty("--scb-header-pre-control-size",f):i.style.removeProperty("--scb-header-pre-control-size")};document.querySelectorAll("scb-header").forEach(a);const o=new MutationObserver(i=>{for(const r of i){if(r.type==="attributes"){const u=r.target;u instanceof HTMLElement&&u.tagName.toLowerCase()==="scb-header"&&a(u);continue}if(r.type==="childList"){const u=[...Array.from(r.addedNodes),...Array.from(r.removedNodes)];for(const h of u){if(!(h instanceof HTMLElement))continue;if(h.tagName.toLowerCase()==="scb-header"){a(h);continue}const p=h.closest?.("scb-header");p&&a(p)}}}});o.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabs","spacing","spacing-top","spacing-bottom","logo-width","logo-height","logo-aspect-ratio","search-height"]}),customElements.whenDefined("scb-header").then(()=>{o.disconnect()})};E();var S={fromAttribute:b=>b==null?!0:!/^(false|0|off|no)$/i.test(b),toAttribute:b=>String(!!b)},x={fromAttribute:b=>b==null?!1:!/^(false|0|off|no)$/i.test(b),toAttribute:b=>b?"":null},M={fromAttribute:b=>b==="small"||b==="large"?b:"medium",toAttribute:b=>{const e=String(b??"");return e==="small"||e==="large"?e:null}},l=(_=class extends k{constructor(){super(),this.maxWidth="1440px",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.size="medium",this.logoText="",this.logoHref="/",this.logoSrc="",this.logoWidth="",this.logoHeight="",this.logoAspectRatio="",this.logoInvertDm=!1,this.banner=!1,this.tabs=[],this.activeTab=null,this.reserveTabs=!1,this.utilityItems=[],this.showDrawer=!0,this.alwaysShowMenuButton=!1,this.showSearch=!0,this.includeUtilityInMenu=!1,this.drawerOverlay=!0,this.searchText="",this._drawerId="main-drawer",this._menuExpanded=!1,this._searchId="header-search",this._slotNavItems=[],this._slotUtils=[],this._slotMenu=[],this._measureScheduled=!1,this._scheduleMeasure=()=>{this._measureScheduled||(this._measureScheduled=!0,requestAnimationFrame(()=>{this._measureScheduled=!1,this._measure()}))},this._onWindowResize=()=>{this._scheduleMeasure()},this._onMenuSelect=s=>{const t=s.detail;this.dispatchEvent(new CustomEvent("scb-menu-select",{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbmenuselect",{detail:t,bubbles:!0,composed:!0}));const a=t?.item,n=typeof t?.href=="string"?t.href:typeof t?.itemHref=="string"?t.itemHref:typeof t?.item_href=="string"?t.item_href:"",o=a?a.getAttribute("item-href")??a.getAttribute("href")??"":"";String(n||o||"").trim()&&this._closeDrawerNow()},this._collapsed=!1,this._unlockAtWidth=0,this._hideLogoText=!1,this._logoTextUnlockAt=0,this._slotWatchers=[],this._harvestPending=!1,this._harvest=()=>{const s=Array.from(this.children),t=[],a=[],n=[];let o=-1;const i=r=>({label:r.getAttribute("label")??"",href:r.getAttribute("href")??void 0,icon:r.getAttribute("icon")??void 0});for(const r of s){const u=r.tagName.toLowerCase();if(u==="scb-header-tab"){const h=r.getAttribute("label")??"",p=r.getAttribute("href"),v=p&&p.trim()!==""?p:void 0;(r.hasAttribute("selected")||r.getAttribute("selected")==="true"||r.getAttribute("active")==="true"||r.getAttribute("aria-current")==="page")&&o===-1&&(o=t.length),t.push({kind:"tab",label:h,href:v});continue}if(u==="scb-badge"){const h=r.querySelector("scb-dropdown");if(h){const p=h.getAttribute("label")??"";(h.hasAttribute("selected")||h.getAttribute("selected")==="true"||h.getAttribute("active")==="true"||h.getAttribute("aria-current")==="page")&&o===-1&&(o=t.length);const v=`scb-header-tab-${t.length}`;r.getAttribute("slot")!==v&&r.setAttribute("slot",v),h.hasAttribute("slot")&&h.removeAttribute("slot"),h.hasAttribute("as-tab")||h.setAttribute("as-tab",""),t.push({kind:"dropdown",slotName:v,label:p});continue}}if(u==="scb-dropdown"){const h=r.getAttribute("label")??"";(r.hasAttribute("selected")||r.getAttribute("selected")==="true"||r.getAttribute("active")==="true"||r.getAttribute("aria-current")==="page")&&o===-1&&(o=t.length);const p=`scb-header-tab-${t.length}`;r.getAttribute("slot")!==p&&r.setAttribute("slot",p),r.hasAttribute("as-tab")||r.setAttribute("as-tab",""),t.push({kind:"dropdown",slotName:p,label:h});continue}if(u==="scb-header-utility"){a.push({label:r.getAttribute("label")??"",href:r.getAttribute("href")??"#",target:r.getAttribute("target")??void 0});continue}if(u==="scb-header-menu-group"){const h={label:r.getAttribute("label")??"",icon:r.getAttribute("icon")??void 0,children:[]};r.querySelectorAll("scb-header-menu-item").forEach(p=>h.children.push(i(p))),n.push(h);continue}u==="scb-header-menu-item"&&n.push(i(r))}this._slotNavItems=t,this._slotUtils=a,this._slotMenu=n,!this.hasAttribute("active-tab")&&o>=0&&(this.activeTab=o),queueMicrotask(()=>{this.updateComplete.then(()=>{this._scheduleMeasure()})})},this._measure=()=>{const s=this._top,t=this._logoGroup;if(!s||!t)return;const a=window.innerWidth,n=s.clientWidth,o=this._overflows(this._util),i=this._tabsOverflows(),r=a<this.BP_MD||o||i;this._collapsed?!r&&n>=this._unlockAtWidth&&this._setCollapsed(!1):r&&(this._unlockAtWidth=n+this._HYST,this._setCollapsed(!0));let u=!1;if(this.showSearch&&a>=this.BP_SM&&a<this.BP_MD&&this._searchWrap){const p=getComputedStyle(this._searchWrap),v=Math.max(this._num(p.minWidth,this._tokenPx("--scb-header-search-min",320)),this._tokenPx("--scb-header-search-min",320)),f=this._num(getComputedStyle(s).gap,this._tokenPx("--spacing-7",24)),A=this.showDrawer&&(this.alwaysShowMenuButton||a<this.BP_MD||this._collapsed)?this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48):0;u=t.getBoundingClientRect().width+f+v+f+A+8>n+.5}this._setHideSearch(u);let h=!1;if(this.showDrawer&&(this.alwaysShowMenuButton||a<this.BP_MD||this._collapsed)&&!this._visible(this._util)&&!this._visible(this._searchWrap)){const p=this._num(getComputedStyle(s).gap,this._tokenPx("--spacing-7",24)),v=this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48),f=(this._logoGroup?.getBoundingClientRect().width||0)+p+v;this._hideLogoText?h=!(n>=this._logoTextUnlockAt):f>n+.5&&(h=!0,this._logoTextUnlockAt=n+this._HYST)}else h=!1,this._logoTextUnlockAt=0;this._setHideLogoText(h)},this._onDrawerOpened=()=>{this._menuExpanded=!0,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("draweropen",{bubbles:!0,composed:!0}))},this._onDrawerClosed=()=>{this._menuExpanded=!1,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-close",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("drawerclose",{bubbles:!0,composed:!0}))},this._onMenuClick=s=>{this.showDrawer&&(this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("menuclick",{bubbles:!0,composed:!0})))},this._onSearchClick=s=>{const t=this._searchEl;if(t?.submit&&typeof t.submit=="function"){t.submit();return}const a=t?.value??"";this.searchText=a,this.dispatchEvent(new CustomEvent("search-click",{detail:{value:a},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchclick",{detail:{value:a},bubbles:!0,composed:!0})),t?.focus?.()},this._onTabClick=s=>{const t=s.currentTarget;if(!t)return;const a=t.tagName.toLowerCase()==="a";if(a&&(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey))return;const n=t.getAttribute("data-index"),o=n!=null?Number(n):0,i=this._getNavItems()[o];if(i?.kind==="dropdown")return;this.activeTab=o;const r=i?.kind==="tab"?i.href??"":"",u=new CustomEvent("tab-change",{detail:{index:o,href:r},bubbles:!0,composed:!0,cancelable:!0}),h=new CustomEvent("tabchange",{detail:{index:o,href:r},bubbles:!0,composed:!0,cancelable:!0});!(this.dispatchEvent(u)&&this.dispatchEvent(h))&&a&&s.preventDefault()},this._onDropdownTabActivate=s=>{const t=s.detail?.dataIndex,a=typeof t=="number"?t:typeof t=="string"?Number(t):this._readTabIndexFromEvent(s);if(a==null||!Number.isFinite(a))return;const n=this._getNavItems();a<0||a>=n.length||n[a]?.kind==="dropdown"&&(this.activeTab=a,this.dispatchEvent(new CustomEvent("tab-change",{detail:{index:a,href:""},bubbles:!0,composed:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("tabchange",{detail:{index:a,href:""},bubbles:!0,composed:!0,cancelable:!0})))},this._onTabsKeydown=s=>{const t=s.key;if(t!=="ArrowLeft"&&t!=="ArrowRight"&&t!=="Home"&&t!=="End")return;const a=this._getNavItems();if(!a.length)return;const n=this._readTabIndexFromEvent(s);if(n==null)return;let o=Math.max(0,Math.min(a.length-1,n));t==="ArrowRight"?o=(o+1)%a.length:t==="ArrowLeft"?o=(o-1+a.length)%a.length:t==="Home"?o=0:t==="End"&&(o=a.length-1),s.preventDefault(),this._focusTabAtIndex(o)},this._onSearchInput=s=>{this.searchText=s.detail?.value??"",this.dispatchEvent(new CustomEvent("search-input",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchinput",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:this.searchText},bubbles:!0,composed:!0}))},this._onSearchSubmit=s=>{this.searchText=s.detail?.value??"",this.dispatchEvent(new CustomEvent("search-change",{detail:{value:this.searchText,active:s.detail?.active},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchchange",{detail:{value:this.searchText,active:s.detail?.active},bubbles:!0,composed:!0}))},this._onSearchClear=()=>{this.searchText="",this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:""},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:""},bubbles:!0,composed:!0}))};const e=++$;this._drawerId=`scb-header-drawer-${e}`,this._searchId=`scb-header-search-${e}`}get _HYST(){return this._tokenPx("--spacing-11",64)}get BP_SM(){return this._tokenPx("--bp-sm",w.BP_SM_DEFAULT)}get BP_MD(){return this._tokenPx("--bp-md",w.BP_MD_DEFAULT)}_scheduleHarvest(){this._harvestPending||(this._harvestPending=!0,queueMicrotask(()=>{this._harvestPending=!1,this._harvest()}))}get _top(){return this.renderRoot.querySelector(".top-row")}get _util(){return this.renderRoot.querySelector(".utility")}get _logoGroup(){return this.renderRoot.querySelector(".logo-wrap")||this.renderRoot.querySelector(".logo-group")}get _searchWrap(){return this.renderRoot.querySelector(".search")}get _menuBtn(){return this.renderRoot.querySelector(".menu-trigger")}get _searchEl(){return this.renderRoot.querySelector(`#${this._searchId}`)}get _tabsNav(){return this.renderRoot.querySelector(".tabs-nav")}_attachSlotObservers(){this._slotMo?.disconnect(),this._slotWatchers.forEach(n=>n.disconnect()),this._slotWatchers=[];const e=["label","href","icon","target","selected","aria-current","active"],s=n=>{const o=new MutationObserver(i=>{this._scheduleHarvest()});this._slotWatchers.push(o),o.observe(n,{attributes:!0,attributeFilter:e})},t=()=>{this._slotWatchers.forEach(o=>o.disconnect()),this._slotWatchers=[];const n=Array.from(this.children);for(const o of n){const i=o.tagName.toLowerCase();if((i==="scb-header-tab"||i==="scb-dropdown"||i==="scb-header-utility"||i==="scb-header-menu-item"||i==="scb-header-menu-group"||i==="scb-badge")&&s(o),i==="scb-badge"){const r=o,u=new MutationObserver(p=>{t(),this._scheduleHarvest()});this._slotWatchers.push(u),u.observe(r,{childList:!0});const h=r.querySelector("scb-dropdown");h&&s(h);continue}if(i==="scb-header-menu-group"){const r=o,u=new MutationObserver(h=>{t(),this._scheduleHarvest()});this._slotWatchers.push(u),u.observe(r,{childList:!0,subtree:!0}),r.querySelectorAll("scb-header-menu-item").forEach(h=>s(h))}}},a=new MutationObserver(n=>{let o=!1;for(const i of n)if(i.type==="childList"){o=!0;break}o&&t(),this._scheduleHarvest()});this._slotMo=a,a.observe(this,{childList:!0}),t()}_setCollapsed(e){this._collapsed!==e&&(this._collapsed=e,e?this.setAttribute("data-collapsed",""):this.removeAttribute("data-collapsed"))}_setHideSearch(e){e?this.setAttribute("data-hide-search",""):this.removeAttribute("data-hide-search")}_setHideLogoText(e){this._hideLogoText!==e&&(this._hideLogoText=e,e?this.setAttribute("data-hide-logo-text",""):this.removeAttribute("data-hide-logo-text"))}_num(e,s){const t=Number.parseFloat(String(e??"").trim());return Number.isFinite(t)?t:s}_tokenPx(e,s){const t=getComputedStyle(this);return this._num(t.getPropertyValue(e),s)}_visible(e){return e?getComputedStyle(e).display!=="none":!1}_overflows(e){return!e||!this._visible(e)?!1:e.scrollWidth>e.clientWidth+1}_tabsOverflows(){const e=this._tabsNav;if(!e||!this._visible(e))return!1;const s=Array.from(e.querySelectorAll(".tab-wrap"));if(s.length===0)return!1;const t=e.getBoundingClientRect();let a=t.left;for(const n of s){const o=n.getBoundingClientRect();o.width<=0||o.right>a&&(a=o.right)}return a-t.left>t.width+1}firstUpdated(){this.updateComplete.then(()=>{this._harvest(),this._attachSlotObservers(),this._syncDropdownTabs()});const e=this._top;e&&(this._ro=new ResizeObserver(()=>this._scheduleMeasure()),this._ro.observe(e)),window.addEventListener("resize",this._onWindowResize,{passive:!0})}updated(e){e.has("searchMax")&&this.style.setProperty("--scb-header-search-max",this.searchMax??"480px"),e.has("searchMin")&&this.style.setProperty("--scb-header-search-min",this.searchMin??"320px"),e.has("searchHeight")&&(this.searchHeight&&this.searchHeight.trim()?this.style.setProperty("--scb-search-height",this.searchHeight.trim()):this.style.removeProperty("--scb-search-height")),(e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio"))&&this._applyLogoSizing(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom"))&&this._applySpacing(),(e.has("utilityItems")||e.has("tabs")||e.has("logoText")||e.has("logoSrc")||e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio")||e.has("activeTab")||e.has("_slotNavItems")||e.has("_slotUtils")||e.has("_slotMenu")||e.has("showDrawer")||e.has("alwaysShowMenuButton")||e.has("showSearch")||e.has("searchMax")||e.has("searchMin")||e.has("size"))&&this.updateComplete.then(()=>{this._scheduleMeasure()}),(e.has("activeTab")||e.has("_slotNavItems")||e.has("tabs")||e.has("size"))&&this.updateComplete.then(()=>{this._syncDropdownTabs()})}disconnectedCallback(){this._ro?.disconnect(),this._slotMo?.disconnect(),this._slotWatchers.forEach(e=>e.disconnect()),this._slotWatchers=[],window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}_mapSpacingToken(e){if(!e)return;const s=String(e).trim();if(s)return/^\d+$/.test(s)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(s,10)))})`:s}_applySpacing(){const e=this._mapSpacingToken(this.spacing),s=this._mapSpacingToken(this.spacingTop)??e,t=this._mapSpacingToken(this.spacingBottom)??e;s?this.style.setProperty("--scb-header-spacing-block-start",s):this.style.removeProperty("--scb-header-spacing-block-start"),t?this.style.setProperty("--scb-header-spacing-block-end",t):this.style.removeProperty("--scb-header-spacing-block-end")}_applyLogoSizing(){const e=(this.logoWidth??"").trim(),s=(this.logoHeight??"").trim(),t=(this.logoAspectRatio??"").trim();e?this.style.setProperty("--scb-header-logo-img-w",e):this.style.removeProperty("--scb-header-logo-img-w"),s?this.style.setProperty("--scb-header-logo-img-h",s):e?this.style.setProperty("--scb-header-logo-img-h","auto"):this.style.removeProperty("--scb-header-logo-img-h"),t?this.style.setProperty("--scb-header-logo-img-aspect-ratio",t):this.style.removeProperty("--scb-header-logo-img-aspect-ratio")}_closeDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!1)}_syncMenuBtnAria(){const e=this.renderRoot.querySelector(".menu-trigger");e&&e.setAttribute("aria-expanded",String(this._menuExpanded))}_getNavItems(){return this._slotNavItems.length?this._slotNavItems:(this.tabs??[]).map(e=>({kind:"tab",...e}))}_getDropdownForSlot(e){const s=this.querySelector(`[slot="${e}"]`);return s?s.tagName.toLowerCase()==="scb-dropdown"?s:s.querySelector("scb-dropdown"):null}_syncDropdownTabs(){this._getNavItems().forEach((e,s)=>{if(e.kind!=="dropdown")return;const t=this._getDropdownForSlot(e.slotName);if(!t)return;const a=String(s);t.getAttribute("data-index")!==a&&t.setAttribute("data-index",a),t.hasAttribute("as-tab")||t.setAttribute("as-tab","");const n=this.size,o=t;o?.size!==n&&(o.size=n),s===this.activeTab?t.getAttribute("aria-current")!=="page"&&t.setAttribute("aria-current","page"):t.hasAttribute("aria-current")&&t.removeAttribute("aria-current")})}_readTabIndexFromEvent(e){const s=e.composedPath?e.composedPath():[];for(const t of s){if(!(t instanceof HTMLElement))continue;const a=t.getAttribute("data-index");if(a==null)continue;const n=Number(a);if(Number.isFinite(n))return n}return null}_focusTabAtIndex(e){const s=this._getNavItems()[e];if(s){if(s.kind==="dropdown"){this._getDropdownForSlot(s.slotName)?.focus?.();return}this.renderRoot.querySelector(`.tab-link[data-index="${e}"]`)?.focus?.()}}_renderMenuNodes(e){return!e||e.length===0?m``:m`${e.map(s=>this._renderMenuNode(s))}`}_renderMenuNode(e){const s=Array.isArray(e.children)&&e.children.length>0,t=(e.href??"").trim(),a=(e.icon??"").trim();return m`
47
47
  <scb-menu-item
48
48
  label=${e.label}
49
49
  ?selected=${!1}
@@ -527,6 +527,9 @@ import"../../vendor/vendor-material.js";import{_ as k,b as C,g as T,h as d,m as
527
527
  display: inline-flex;
528
528
  }
529
529
  }
530
+ :host([always-show-menu-button]) .menu-trigger {
531
+ display: inline-flex;
532
+ }
530
533
  :host([data-collapsed]) .menu-trigger {
531
534
  display: inline-flex;
532
535
  }
@@ -678,4 +681,4 @@ import"../../vendor/vendor-material.js";import{_ as k,b as C,g as T,h as d,m as
678
681
  :host([data-hide-logo-text]) .logo-text {
679
682
  display: none;
680
683
  }
681
- `,_);c([d({type:String,attribute:"max-width"})],l.prototype,"maxWidth",void 0);c([d({type:String,reflect:!0})],l.prototype,"spacing",void 0);c([d({type:String,attribute:"spacing-top",reflect:!0})],l.prototype,"spacingTop",void 0);c([d({type:String,attribute:"spacing-bottom",reflect:!0})],l.prototype,"spacingBottom",void 0);c([d({type:String,reflect:!0,converter:M})],l.prototype,"size",void 0);c([d({type:String,attribute:"logo-text"})],l.prototype,"logoText",void 0);c([d({type:String,attribute:"logo-href"})],l.prototype,"logoHref",void 0);c([d({type:String,attribute:"logo-src"})],l.prototype,"logoSrc",void 0);c([d({type:String,attribute:"logo-width"})],l.prototype,"logoWidth",void 0);c([d({type:String,attribute:"logo-height"})],l.prototype,"logoHeight",void 0);c([d({type:String,attribute:"logo-aspect-ratio"})],l.prototype,"logoAspectRatio",void 0);c([d({type:Boolean,attribute:"logo-invert-dm",reflect:!0,converter:S})],l.prototype,"logoInvertDm",void 0);c([d({type:Boolean,reflect:!0})],l.prototype,"banner",void 0);c([d({type:String,attribute:"banner-label"})],l.prototype,"bannerLabel",void 0);c([d({type:Array,attribute:"tabs",converter:l._JSON_ARRAY})],l.prototype,"tabs",void 0);c([d({type:Number,attribute:"active-tab"})],l.prototype,"activeTab",void 0);c([d({type:Boolean,attribute:"reserve-tabs",reflect:!0,converter:S})],l.prototype,"reserveTabs",void 0);c([d({type:Number,attribute:"reserve-tabs-count"})],l.prototype,"reserveTabsCount",void 0);c([d({type:String,attribute:"reserve-tabs-widths"})],l.prototype,"reserveTabsWidths",void 0);c([d({type:Array,attribute:"utility-items",converter:l._JSON_ARRAY})],l.prototype,"utilityItems",void 0);c([d({type:String,attribute:"search-placeholder"})],l.prototype,"searchPlaceholder",void 0);c([d({type:String,attribute:"menu-label"})],l.prototype,"menuLabel",void 0);c([d({type:String,attribute:"menu-sub-label"})],l.prototype,"menuSubLabel",void 0);c([d({type:String,attribute:"menu-section-label"})],l.prototype,"menuSectionLabel",void 0);c([d({type:String,attribute:"menu-search-placeholder"})],l.prototype,"menuSearchPlaceholder",void 0);c([d({type:Array,attribute:"menu-data",converter:l._JSON_ARRAY})],l.prototype,"menuData",void 0);c([d({type:Boolean,attribute:"show-drawer",reflect:!0,converter:x})],l.prototype,"showDrawer",void 0);c([d({type:Boolean,attribute:"show-search",reflect:!0,converter:x})],l.prototype,"showSearch",void 0);c([d({type:Boolean,attribute:"include-utility-in-menu",reflect:!0,converter:S})],l.prototype,"includeUtilityInMenu",void 0);c([d({type:Boolean,attribute:"drawer-overlay",reflect:!0,converter:x})],l.prototype,"drawerOverlay",void 0);c([d({type:String,attribute:"search-max"})],l.prototype,"searchMax",void 0);c([d({type:String,attribute:"search-min"})],l.prototype,"searchMin",void 0);c([d({type:String,attribute:"search-height"})],l.prototype,"searchHeight",void 0);c([d({type:String,attribute:"search-text",reflect:!0})],l.prototype,"searchText",void 0);c([y()],l.prototype,"_drawerId",void 0);c([y()],l.prototype,"_menuExpanded",void 0);c([y()],l.prototype,"_searchId",void 0);c([y()],l.prototype,"_slotNavItems",void 0);c([y()],l.prototype,"_slotUtils",void 0);c([y()],l.prototype,"_slotMenu",void 0);c([y()],l.prototype,"_collapsed",void 0);c([y()],l.prototype,"_hideLogoText",void 0);l=w=c([T("scb-header")],l);
684
+ `,_);c([d({type:String,attribute:"max-width"})],l.prototype,"maxWidth",void 0);c([d({type:String,reflect:!0})],l.prototype,"spacing",void 0);c([d({type:String,attribute:"spacing-top",reflect:!0})],l.prototype,"spacingTop",void 0);c([d({type:String,attribute:"spacing-bottom",reflect:!0})],l.prototype,"spacingBottom",void 0);c([d({type:String,reflect:!0,converter:M})],l.prototype,"size",void 0);c([d({type:String,attribute:"logo-text"})],l.prototype,"logoText",void 0);c([d({type:String,attribute:"logo-href"})],l.prototype,"logoHref",void 0);c([d({type:String,attribute:"logo-src"})],l.prototype,"logoSrc",void 0);c([d({type:String,attribute:"logo-width"})],l.prototype,"logoWidth",void 0);c([d({type:String,attribute:"logo-height"})],l.prototype,"logoHeight",void 0);c([d({type:String,attribute:"logo-aspect-ratio"})],l.prototype,"logoAspectRatio",void 0);c([d({type:Boolean,attribute:"logo-invert-dm",reflect:!0,converter:x})],l.prototype,"logoInvertDm",void 0);c([d({type:Boolean,reflect:!0})],l.prototype,"banner",void 0);c([d({type:String,attribute:"banner-label"})],l.prototype,"bannerLabel",void 0);c([d({type:Array,attribute:"tabs",converter:l._JSON_ARRAY})],l.prototype,"tabs",void 0);c([d({type:Number,attribute:"active-tab"})],l.prototype,"activeTab",void 0);c([d({type:Boolean,attribute:"reserve-tabs",reflect:!0,converter:x})],l.prototype,"reserveTabs",void 0);c([d({type:Number,attribute:"reserve-tabs-count"})],l.prototype,"reserveTabsCount",void 0);c([d({type:String,attribute:"reserve-tabs-widths"})],l.prototype,"reserveTabsWidths",void 0);c([d({type:Array,attribute:"utility-items",converter:l._JSON_ARRAY})],l.prototype,"utilityItems",void 0);c([d({type:String,attribute:"search-placeholder"})],l.prototype,"searchPlaceholder",void 0);c([d({type:String,attribute:"menu-label"})],l.prototype,"menuLabel",void 0);c([d({type:String,attribute:"menu-sub-label"})],l.prototype,"menuSubLabel",void 0);c([d({type:String,attribute:"menu-section-label"})],l.prototype,"menuSectionLabel",void 0);c([d({type:String,attribute:"menu-search-placeholder"})],l.prototype,"menuSearchPlaceholder",void 0);c([d({type:Array,attribute:"menu-data",converter:l._JSON_ARRAY})],l.prototype,"menuData",void 0);c([d({type:Boolean,attribute:"show-drawer",reflect:!0,converter:S})],l.prototype,"showDrawer",void 0);c([d({type:Boolean,attribute:"always-show-menu-button",reflect:!0,converter:x})],l.prototype,"alwaysShowMenuButton",void 0);c([d({type:Boolean,attribute:"show-search",reflect:!0,converter:S})],l.prototype,"showSearch",void 0);c([d({type:Boolean,attribute:"include-utility-in-menu",reflect:!0,converter:x})],l.prototype,"includeUtilityInMenu",void 0);c([d({type:Boolean,attribute:"drawer-overlay",reflect:!0,converter:S})],l.prototype,"drawerOverlay",void 0);c([d({type:String,attribute:"search-max"})],l.prototype,"searchMax",void 0);c([d({type:String,attribute:"search-min"})],l.prototype,"searchMin",void 0);c([d({type:String,attribute:"search-height"})],l.prototype,"searchHeight",void 0);c([d({type:String,attribute:"search-text",reflect:!0})],l.prototype,"searchText",void 0);c([y()],l.prototype,"_drawerId",void 0);c([y()],l.prototype,"_menuExpanded",void 0);c([y()],l.prototype,"_searchId",void 0);c([y()],l.prototype,"_slotNavItems",void 0);c([y()],l.prototype,"_slotUtils",void 0);c([y()],l.prototype,"_slotMenu",void 0);c([y()],l.prototype,"_collapsed",void 0);c([y()],l.prototype,"_hideLogoText",void 0);l=w=c([T("scb-header")],l);
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../../vendor/vendor-material.js","../../vendor/vendor.js","../../vendor/vendor-lit.js"])))=>i.map(i=>d[i]);
2
- import{_ as b,b as g,g as _,h as c,m as f,v as u,y as d}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as o}from"../../vendor/decorate.js";import"../../vendor/scb-chevron.js";import{t as m}from"../../vendor/preload-helper.js";(function(){try{var l=typeof globalThis<"u"?globalThis:window;if(!l.__scb_ce_guard_installed__){l.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,n,a){try{customElements.get(t)||e(t,n,a)}catch(h){var p=String(h||"");if(p.indexOf("already been used")===-1&&p.indexOf("NotSupportedError")===-1)throw h}}}}catch{}})();var r,s,i=(r=class extends b{constructor(...e){super(...e),this.label="",this.selected=!1,this.noHighlightSelected=!1,this.leadingIcon="",this.itemHref="",this.hasSlotContent=!1,this.expanded=!1,this.__submenuId=`sub-${Math.random().toString(36).slice(2)}`,this.__focusId=`f-${Math.random().toString(36).slice(2)}`,this._toggleExpand=t=>{t&&t.stopPropagation(),this.hasSlotContent&&this.__setExpanded(!this.expanded)},this._onButtonClick=t=>{t.stopPropagation(),this._dispatchSelect(),this._toggleExpand()},this._onLinkClick=()=>{this._dispatchSelect()},this._onKeyDown=t=>{const n=Array.from(this.closest("scb-sub-menu, scb-menu")?.querySelectorAll("scb-menu-item")||[]),a=n.indexOf(this);switch(t.key){case"ArrowDown":t.preventDefault(),(n[a+1]||n[0]).shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break;case"ArrowUp":t.preventDefault(),(n[a-1]||n[n.length-1]).shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break;case"Home":t.preventDefault(),n[0].shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break;case"End":t.preventDefault(),n[n.length-1].shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break}}}get __submenuEl(){return this.renderRoot.querySelector(`#${this.__submenuId}`)}async __ensureDepsLoaded(){s.__rippleLoaded||(await m(()=>import("../../vendor/vendor-material.js").then(e=>e.f),__vite__mapDeps([0,1,2]),import.meta.url),s.__rippleLoaded=!0),s.__focusRingLoaded||(await m(()=>import("../../vendor/vendor-material.js").then(e=>e.m),__vite__mapDeps([0,1,2]),import.meta.url),s.__focusRingLoaded=!0),this.leadingIcon&&!s.__iconLoaded&&(await m(()=>import("../../vendor/vendor-material.js").then(e=>e.p),__vite__mapDeps([0,1,2]),import.meta.url),s.__iconLoaded=!0)}__syncHasSlotContentFromLightDom(){const e=Array.from(this.children);this.hasSlotContent=e.length>0&&e.every(t=>t.tagName==="SCB-SUB-MENU")}connectedCallback(){super.connectedCallback(),this.__syncHasSlotContentFromLightDom()}_onSlotChange(e){const t=e.target.assignedElements({flatten:!0});this.hasSlotContent=t.length>0&&t.every(n=>n.tagName==="SCB-SUB-MENU")}__setExpanded(e){this.hasSlotContent&&(this.expanded=e,this.dispatchEvent(new CustomEvent("scb-menu-expand",{bubbles:!0,composed:!0,detail:{item:this,expanded:e}})),this.dispatchEvent(new CustomEvent("scbmenuexpand",{bubbles:!0,composed:!0,detail:{item:this,expanded:e}})))}_dispatchSelect(){this.dispatchEvent(new CustomEvent("scb-menu-select",{bubbles:!0,composed:!0,detail:{item:this}})),this.dispatchEvent(new CustomEvent("scbmenuselect",{bubbles:!0,composed:!0,detail:{item:this}}))}async firstUpdated(){await this.__ensureDepsLoaded()}updated(e){e.has("leadingIcon")&&this.leadingIcon&&this.__ensureDepsLoaded(),e.has("hasSlotContent")&&this.hasSlotContent&&this.__ensureDepsLoaded(),e.has("expanded")&&this.__applyInert()}__applyInert(){const e=this.__submenuEl;e&&(this.expanded?(e.removeAttribute("inert"),e.setAttribute("aria-hidden","false")):(e.setAttribute("inert",""),e.setAttribute("aria-hidden","true")))}render(){const e=!!this.leadingIcon,t=!!this.itemHref,n=this.hasSlotContent;return d`
2
+ import{_ as b,b as g,g as _,h as c,m as f,v as u,y as d}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as o}from"../../vendor/decorate.js";import"../scb-chevron/scb-chevron.js";import{t as m}from"../../vendor/preload-helper.js";(function(){try{var l=typeof globalThis<"u"?globalThis:window;if(!l.__scb_ce_guard_installed__){l.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,n,a){try{customElements.get(t)||e(t,n,a)}catch(h){var p=String(h||"");if(p.indexOf("already been used")===-1&&p.indexOf("NotSupportedError")===-1)throw h}}}}catch{}})();var r,s,i=(r=class extends b{constructor(...e){super(...e),this.label="",this.selected=!1,this.noHighlightSelected=!1,this.leadingIcon="",this.itemHref="",this.hasSlotContent=!1,this.expanded=!1,this.__submenuId=`sub-${Math.random().toString(36).slice(2)}`,this.__focusId=`f-${Math.random().toString(36).slice(2)}`,this._toggleExpand=t=>{t&&t.stopPropagation(),this.hasSlotContent&&this.__setExpanded(!this.expanded)},this._onButtonClick=t=>{t.stopPropagation(),this._dispatchSelect(),this._toggleExpand()},this._onLinkClick=()=>{this._dispatchSelect()},this._onKeyDown=t=>{const n=Array.from(this.closest("scb-sub-menu, scb-menu")?.querySelectorAll("scb-menu-item")||[]),a=n.indexOf(this);switch(t.key){case"ArrowDown":t.preventDefault(),(n[a+1]||n[0]).shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break;case"ArrowUp":t.preventDefault(),(n[a-1]||n[n.length-1]).shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break;case"Home":t.preventDefault(),n[0].shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break;case"End":t.preventDefault(),n[n.length-1].shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break}}}get __submenuEl(){return this.renderRoot.querySelector(`#${this.__submenuId}`)}async __ensureDepsLoaded(){s.__rippleLoaded||(await m(()=>import("../../vendor/vendor-material.js").then(e=>e.f),__vite__mapDeps([0,1,2]),import.meta.url),s.__rippleLoaded=!0),s.__focusRingLoaded||(await m(()=>import("../../vendor/vendor-material.js").then(e=>e.m),__vite__mapDeps([0,1,2]),import.meta.url),s.__focusRingLoaded=!0),this.leadingIcon&&!s.__iconLoaded&&(await m(()=>import("../../vendor/vendor-material.js").then(e=>e.p),__vite__mapDeps([0,1,2]),import.meta.url),s.__iconLoaded=!0)}__syncHasSlotContentFromLightDom(){const e=Array.from(this.children);this.hasSlotContent=e.length>0&&e.every(t=>t.tagName==="SCB-SUB-MENU")}connectedCallback(){super.connectedCallback(),this.__syncHasSlotContentFromLightDom()}_onSlotChange(e){const t=e.target.assignedElements({flatten:!0});this.hasSlotContent=t.length>0&&t.every(n=>n.tagName==="SCB-SUB-MENU")}__setExpanded(e){this.hasSlotContent&&(this.expanded=e,this.dispatchEvent(new CustomEvent("scb-menu-expand",{bubbles:!0,composed:!0,detail:{item:this,expanded:e}})),this.dispatchEvent(new CustomEvent("scbmenuexpand",{bubbles:!0,composed:!0,detail:{item:this,expanded:e}})))}_dispatchSelect(){this.dispatchEvent(new CustomEvent("scb-menu-select",{bubbles:!0,composed:!0,detail:{item:this}})),this.dispatchEvent(new CustomEvent("scbmenuselect",{bubbles:!0,composed:!0,detail:{item:this}}))}async firstUpdated(){await this.__ensureDepsLoaded()}updated(e){e.has("leadingIcon")&&this.leadingIcon&&this.__ensureDepsLoaded(),e.has("hasSlotContent")&&this.hasSlotContent&&this.__ensureDepsLoaded(),e.has("expanded")&&this.__applyInert()}__applyInert(){const e=this.__submenuEl;e&&(this.expanded?(e.removeAttribute("inert"),e.setAttribute("aria-hidden","false")):(e.setAttribute("inert",""),e.setAttribute("aria-hidden","true")))}render(){const e=!!this.leadingIcon,t=!!this.itemHref,n=this.hasSlotContent;return d`
3
3
  <div class="scb-menu-item">
4
4
  <div class="scb-menu-item-label" ?selected=${this.selected} ?no-highlight-selected=${this.noHighlightSelected}>
5
5
  ${t?d`
@@ -1,4 +1,4 @@
1
- import"../../vendor/vendor-material.js";import{_ as h,b as u,g as b,h as a,s as g,y as d}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as l}from"../../vendor/decorate.js";import"../../vendor/scb-chevron.js";import"./scb-select-option.js";(function(){try{var p=typeof globalThis<"u"?globalThis:window;if(!p.__scb_ce_guard_installed__){p.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,s,r){try{customElements.get(t)||e(t,s,r)}catch(o){var n=String(o||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var c,i=(c=class extends h{constructor(){super(),this._optionsObserver=null,this._internals=null,this.focusedIndex=-1,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.required=!1,this.open=!1,this.label="",this.name="",this.placeholder="",this.supportingText="",this.withRadiobuttons=!1,this.noHighlightSelected=!1,this.size="large",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.zIndex=void 0,this._form=null,this._formResetHandler=null,this._formSubmitHandler=null,this._initialValue="",this._initialValues=[],this._customValidationMessage="",this._onDocumentClick=e=>{this.open&&(e.composedPath().includes(this)||this._setOpen(!1))},this._onSlotClick=e=>{const t=this.shadowRoot?.querySelector("slot");if(!t)return;const s=t.assignedElements({flatten:!0}).filter(o=>o.tagName.toLowerCase()==="scb-select-option"),r=e.composedPath(),n=s.find(o=>r.includes(o));n&&(this._selectOption(n),e.stopPropagation())},this._onKeyDown=e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._toggleOpen())},this._onOptionKeyDown=e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();const t=this.shadowRoot?.querySelector("slot");if(!t)return;const s=t.assignedElements({flatten:!0}).filter(o=>o.tagName.toLowerCase()==="scb-select-option"),r=e.composedPath(),n=s.find(o=>r.includes(o));n&&this._selectOption(n)}},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="extra-small"?this.setAttribute("data-density","-5"):this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._onDocumentClick),this._optionsObserver=new MutationObserver(()=>{this.requestUpdate()}),this._optionsObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]}),this._syncDensityForSize(),this._initialValue=this.value,this._initialValues=Array.isArray(this.values)?[...this.values]:[],this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{this.value=this._initialValue,this.values=Array.isArray(this._initialValues)?[...this._initialValues]:[],this._syncFormValue(),this._syncValidity(),this.requestUpdate()},this._formSubmitHandler=e=>{this.reportValidity()||(e.preventDefault(),e.stopPropagation())},this._form.addEventListener("reset",this._formResetHandler,!0),this._form.addEventListener("submit",this._formSubmitHandler,!0))}disconnectedCallback(){document.removeEventListener("mousedown",this._onDocumentClick),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler,!0),this._optionsObserver?.disconnect(),this._optionsObserver=null,super.disconnectedCallback()}_getMultiValues(){return Array.isArray(this.values)&&this.values.length>0?this.values:this.value?this.value.split(",").map(e=>e.trim()).filter(Boolean):[]}_mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_applySpacing(){const e=this._mapSpacingToken(this.spacing),t=this._mapSpacingToken(this.spacingTop)??e,s=this._mapSpacingToken(this.spacingBottom)??e,r=this._mapSpacingToken(this.spacingLeft),n=this._mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-select-spacing-block-start",t):this.style.removeProperty("--scb-select-spacing-block-start"),s?this.style.setProperty("--scb-select-spacing-block-end",s):this.style.removeProperty("--scb-select-spacing-block-end"),r?this.style.setProperty("--scb-select-spacing-inline-start",r):this.style.removeProperty("--scb-select-spacing-inline-start"),n?this.style.setProperty("--scb-select-spacing-inline-end",n):this.style.removeProperty("--scb-select-spacing-inline-end")}_setOpen(e){this.open!==e&&(this.open=e,e?(this.focusedIndex=0,this.requestUpdate()):this.focusedIndex=-1)}_toggleOpen(){this.disabled||this._setOpen(!this.open)}_hasMoreThanFourOptions(){const e=this.shadowRoot?.querySelector("slot");if(!e)return!1;const t=e.assignedElements({flatten:!0}).filter(s=>s.tagName.toLowerCase()==="scb-select-option");return["extra-small","small","medium"].includes(this.size)?t.length>5:t.length>4}_selectOption(e){if(!e.disabled){if(this.variant==="multi-select"){const t=this._getMultiValues();t.indexOf(e.value)>-1?this.values=t.filter(s=>s!==e.value):this.values=[...t,e.value],this.value=this.values.join(","),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0}))}else this.variant==="single-select"&&this.withRadiobuttons?(this.value=e.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))):(this.value=e.value,this._setOpen(!1),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})));this._updateOptionsChecked(),this.requestUpdate()}}_getOptionLabel(e){return e.label||e.textContent?.trim()||""}_getSelectedLabel(){const e=this.shadowRoot?.querySelector("slot");if(!e)return"";const t=e.assignedElements({flatten:!0}).filter(s=>s.tagName.toLowerCase()==="scb-select-option");if(this.variant==="multi-select"){const s=this._getMultiValues(),r=t.filter(n=>s.includes(n.value));return r&&r.length>0?r.map(n=>this._getOptionLabel(n)).join(", "):""}else{const s=t.find(r=>r.value===this.value);return s?this._getOptionLabel(s):""}}firstUpdated(){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),this._applySpacing()}updated(e){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),e.has("size")&&this._syncDensityForSize(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this._applySpacing()}_syncFormValue(){if(this._internals){if(this.disabled||!this.name){this._internals.setFormValue(null);return}if(this.variant==="multi-select"){const e=this._getMultiValues();if(e.length===0){this._internals.setFormValue(null);return}const t=new FormData;e.forEach(s=>t.append(this.name,s)),this._internals.setFormValue(t);return}this._internals.setFormValue(this.value||null)}}_getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!(this.variant==="multi-select"?this._getMultiValues().length>0:this.value)?"Välj ett alternativ.":""}_syncValidity(){if(!this._internals)return;const e=this.disabled?"":this._getValidationMessage(),t=this.shadowRoot?.querySelector(".selected-value");if(!e){this._internals.setValidity({}),this.removeAttribute("aria-invalid"),t&&t.setCustomValidity("");return}t&&t.setCustomValidity(e),this._internals.setValidity({valueMissing:!0},e,t??void 0),this.setAttribute("aria-invalid","true")}checkValidity(){return!this._getValidationMessage()}reportValidity(){return this._syncValidity(),this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(e){this._customValidationMessage=e,this._syncValidity()}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??this._getValidationMessage()}get willValidate(){return this._internals?.willValidate??!0}_updateOptionsChecked(){const e=this.shadowRoot?.querySelector("slot");e&&e.assignedElements({flatten:!0}).filter(t=>t.tagName.toLowerCase()==="scb-select-option").forEach(t=>{if(this.noHighlightSelected?t.setAttribute("no-highlight-selected",""):t.removeAttribute("no-highlight-selected"),this.variant==="multi-select"){const s=this._getMultiValues();t.showCheckbox=!0,t.checked=s.includes(t.value),t.showRadio=!1}else t.showCheckbox=!1,t.checked=this.value===t.value,this.withRadiobuttons&&(t.showRadio=!0)})}render(){return d`
1
+ import"../../vendor/vendor-material.js";import{_ as h,b as u,g as b,h as a,s as g,y as d}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as l}from"../../vendor/decorate.js";import"../scb-chevron/scb-chevron.js";import"./scb-select-option.js";(function(){try{var p=typeof globalThis<"u"?globalThis:window;if(!p.__scb_ce_guard_installed__){p.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,s,r){try{customElements.get(t)||e(t,s,r)}catch(o){var n=String(o||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var c,i=(c=class extends h{constructor(){super(),this._optionsObserver=null,this._internals=null,this.focusedIndex=-1,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.required=!1,this.open=!1,this.label="",this.name="",this.placeholder="",this.supportingText="",this.withRadiobuttons=!1,this.noHighlightSelected=!1,this.size="large",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.zIndex=void 0,this._form=null,this._formResetHandler=null,this._formSubmitHandler=null,this._initialValue="",this._initialValues=[],this._customValidationMessage="",this._onDocumentClick=e=>{this.open&&(e.composedPath().includes(this)||this._setOpen(!1))},this._onSlotClick=e=>{const t=this.shadowRoot?.querySelector("slot");if(!t)return;const s=t.assignedElements({flatten:!0}).filter(o=>o.tagName.toLowerCase()==="scb-select-option"),r=e.composedPath(),n=s.find(o=>r.includes(o));n&&(this._selectOption(n),e.stopPropagation())},this._onKeyDown=e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._toggleOpen())},this._onOptionKeyDown=e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();const t=this.shadowRoot?.querySelector("slot");if(!t)return;const s=t.assignedElements({flatten:!0}).filter(o=>o.tagName.toLowerCase()==="scb-select-option"),r=e.composedPath(),n=s.find(o=>r.includes(o));n&&this._selectOption(n)}},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="extra-small"?this.setAttribute("data-density","-5"):this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._onDocumentClick),this._optionsObserver=new MutationObserver(()=>{this.requestUpdate()}),this._optionsObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]}),this._syncDensityForSize(),this._initialValue=this.value,this._initialValues=Array.isArray(this.values)?[...this.values]:[],this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{this.value=this._initialValue,this.values=Array.isArray(this._initialValues)?[...this._initialValues]:[],this._syncFormValue(),this._syncValidity(),this.requestUpdate()},this._formSubmitHandler=e=>{this.reportValidity()||(e.preventDefault(),e.stopPropagation())},this._form.addEventListener("reset",this._formResetHandler,!0),this._form.addEventListener("submit",this._formSubmitHandler,!0))}disconnectedCallback(){document.removeEventListener("mousedown",this._onDocumentClick),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler,!0),this._optionsObserver?.disconnect(),this._optionsObserver=null,super.disconnectedCallback()}_getMultiValues(){return Array.isArray(this.values)&&this.values.length>0?this.values:this.value?this.value.split(",").map(e=>e.trim()).filter(Boolean):[]}_mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_applySpacing(){const e=this._mapSpacingToken(this.spacing),t=this._mapSpacingToken(this.spacingTop)??e,s=this._mapSpacingToken(this.spacingBottom)??e,r=this._mapSpacingToken(this.spacingLeft),n=this._mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-select-spacing-block-start",t):this.style.removeProperty("--scb-select-spacing-block-start"),s?this.style.setProperty("--scb-select-spacing-block-end",s):this.style.removeProperty("--scb-select-spacing-block-end"),r?this.style.setProperty("--scb-select-spacing-inline-start",r):this.style.removeProperty("--scb-select-spacing-inline-start"),n?this.style.setProperty("--scb-select-spacing-inline-end",n):this.style.removeProperty("--scb-select-spacing-inline-end")}_setOpen(e){this.open!==e&&(this.open=e,e?(this.focusedIndex=0,this.requestUpdate()):this.focusedIndex=-1)}_toggleOpen(){this.disabled||this._setOpen(!this.open)}_hasMoreThanFourOptions(){const e=this.shadowRoot?.querySelector("slot");if(!e)return!1;const t=e.assignedElements({flatten:!0}).filter(s=>s.tagName.toLowerCase()==="scb-select-option");return["extra-small","small","medium"].includes(this.size)?t.length>5:t.length>4}_selectOption(e){if(!e.disabled){if(this.variant==="multi-select"){const t=this._getMultiValues();t.indexOf(e.value)>-1?this.values=t.filter(s=>s!==e.value):this.values=[...t,e.value],this.value=this.values.join(","),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0}))}else this.variant==="single-select"&&this.withRadiobuttons?(this.value=e.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))):(this.value=e.value,this._setOpen(!1),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})));this._updateOptionsChecked(),this.requestUpdate()}}_getOptionLabel(e){return e.label||e.textContent?.trim()||""}_getSelectedLabel(){const e=this.shadowRoot?.querySelector("slot");if(!e)return"";const t=e.assignedElements({flatten:!0}).filter(s=>s.tagName.toLowerCase()==="scb-select-option");if(this.variant==="multi-select"){const s=this._getMultiValues(),r=t.filter(n=>s.includes(n.value));return r&&r.length>0?r.map(n=>this._getOptionLabel(n)).join(", "):""}else{const s=t.find(r=>r.value===this.value);return s?this._getOptionLabel(s):""}}firstUpdated(){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),this._applySpacing()}updated(e){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),e.has("size")&&this._syncDensityForSize(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this._applySpacing()}_syncFormValue(){if(this._internals){if(this.disabled||!this.name){this._internals.setFormValue(null);return}if(this.variant==="multi-select"){const e=this._getMultiValues();if(e.length===0){this._internals.setFormValue(null);return}const t=new FormData;e.forEach(s=>t.append(this.name,s)),this._internals.setFormValue(t);return}this._internals.setFormValue(this.value||null)}}_getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!(this.variant==="multi-select"?this._getMultiValues().length>0:this.value)?"Välj ett alternativ.":""}_syncValidity(){if(!this._internals)return;const e=this.disabled?"":this._getValidationMessage(),t=this.shadowRoot?.querySelector(".selected-value");if(!e){this._internals.setValidity({}),this.removeAttribute("aria-invalid"),t&&t.setCustomValidity("");return}t&&t.setCustomValidity(e),this._internals.setValidity({valueMissing:!0},e,t??void 0),this.setAttribute("aria-invalid","true")}checkValidity(){return!this._getValidationMessage()}reportValidity(){return this._syncValidity(),this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(e){this._customValidationMessage=e,this._syncValidity()}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??this._getValidationMessage()}get willValidate(){return this._internals?.willValidate??!0}_updateOptionsChecked(){const e=this.shadowRoot?.querySelector("slot");e&&e.assignedElements({flatten:!0}).filter(t=>t.tagName.toLowerCase()==="scb-select-option").forEach(t=>{if(this.noHighlightSelected?t.setAttribute("no-highlight-selected",""):t.removeAttribute("no-highlight-selected"),this.variant==="multi-select"){const s=this._getMultiValues();t.showCheckbox=!0,t.checked=s.includes(t.value),t.showRadio=!1}else t.showCheckbox=!1,t.checked=this.value===t.value,this.withRadiobuttons&&(t.showRadio=!0)})}render(){return d`
2
2
  ${this.label?d`
3
3
  <label
4
4
  class="select-label ${this.supportingText?"":"select-label--without-supporting"}"