@sbb-esta/lyne-elements-dev 5.4.0-dev.1785608354 → 5.4.0-dev.1785742243

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.
@@ -1,15 +1,15 @@
1
- import{__esDecorate as e,__runInitializers as t}from"tslib";import{ResizeController as n}from"@lit-labs/observers/resize-controller.js";import{html as ee,isServer as r,nothing as i,unsafeCSS as a}from"lit";import{property as o}from"lit/decorators.js";import{ref as te}from"lit/directives/ref.js";import{SbbEscapableOverlayController as s,SbbNegativeMixin as c,SbbOpenCloseBaseElement as l,SbbPropertyWatcherController as u,forceType as d,getNextElementIndex as f,idReference as p,isEventOnElement as m,isSafari as h,isZeroAnimationDuration as g,popoverResetStyles as _,removeAriaComboBoxAttributes as v,scrollbarStyles as y,setAriaComboBoxAttributes as b,setOverlayPosition as x}from"./core.js";import{optionPanelStyles as S}from"./option.pure.js";var C=`:host{display:none}:host(:is(:is(:state(state-opening),[state--state-opening]),:is(:state(state-opened),[state--state-opened]),:is(:state(state-closing),[state--state-closing]))){display:block}
2
- `;const w=h;var T=class extends Event{get option(){return this._option}constructor(e){super(`inputAutocomplete`,{bubbles:!0,composed:!0}),this._option=e}};let E=(()=>{let f=c(l),h,b=[],E=[],D,O=[],k=[],A,j=[],M=[],N,P=[],F=[],I,L=[],R=[],z,B=[],V=[],H,U=[],W=[],G,K=[],q=[],J,Y=[],X=[],Z,Q=[],$=[];return class extends f{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(f[Symbol.metadata]??null):void 0;h=[p(),o()],D=[p(),o()],A=[d(),o({attribute:`preserve-icon-space`,reflect:!0,type:Boolean})],N=[d(),o({attribute:`auto-active-first-option`,type:Boolean})],I=[o({attribute:!1})],z=[o({reflect:!0})],H=[d(),o({attribute:`auto-select-active-option`,type:Boolean})],G=[d(),o({attribute:`auto-select-active-option-on-blur`,type:Boolean})],J=[d(),o({attribute:`require-selection`,type:Boolean})],Z=[o()],e(this,null,h,{kind:`accessor`,name:`origin`,static:!1,private:!1,access:{has:e=>`origin`in e,get:e=>e.origin,set:(e,t)=>{e.origin=t}},metadata:t},b,E),e(this,null,D,{kind:`accessor`,name:`trigger`,static:!1,private:!1,access:{has:e=>`trigger`in e,get:e=>e.trigger,set:(e,t)=>{e.trigger=t}},metadata:t},O,k),e(this,null,A,{kind:`accessor`,name:`preserveIconSpace`,static:!1,private:!1,access:{has:e=>`preserveIconSpace`in e,get:e=>e.preserveIconSpace,set:(e,t)=>{e.preserveIconSpace=t}},metadata:t},j,M),e(this,null,N,{kind:`accessor`,name:`autoActiveFirstOption`,static:!1,private:!1,access:{has:e=>`autoActiveFirstOption`in e,get:e=>e.autoActiveFirstOption,set:(e,t)=>{e.autoActiveFirstOption=t}},metadata:t},P,F),e(this,null,I,{kind:`accessor`,name:`displayWith`,static:!1,private:!1,access:{has:e=>`displayWith`in e,get:e=>e.displayWith,set:(e,t)=>{e.displayWith=t}},metadata:t},L,R),e(this,null,z,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:t},B,V),e(this,null,H,{kind:`accessor`,name:`autoSelectActiveOption`,static:!1,private:!1,access:{has:e=>`autoSelectActiveOption`in e,get:e=>e.autoSelectActiveOption,set:(e,t)=>{e.autoSelectActiveOption=t}},metadata:t},U,W),e(this,null,G,{kind:`accessor`,name:`autoSelectActiveOptionOnBlur`,static:!1,private:!1,access:{has:e=>`autoSelectActiveOptionOnBlur`in e,get:e=>e.autoSelectActiveOptionOnBlur,set:(e,t)=>{e.autoSelectActiveOptionOnBlur=t}},metadata:t},K,q),e(this,null,J,{kind:`accessor`,name:`requireSelection`,static:!1,private:!1,access:{has:e=>`requireSelection`in e,get:e=>e.requireSelection,set:(e,t)=>{e.requireSelection=t}},metadata:t},Y,X),e(this,null,Z,{kind:`accessor`,name:`position`,static:!1,private:!1,access:{has:e=>`position`in e,get:e=>e.position,set:(e,t)=>{e.position=t}},metadata:t},Q,$),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.styles=[_,y,S,a(C)]}#e;get origin(){return this.#e}set origin(e){this.#e=e}#t;get trigger(){return this.#t}set trigger(e){this.#t=e}#n;get preserveIconSpace(){return this.#n}set preserveIconSpace(e){this.#n=e}#r;get autoActiveFirstOption(){return this.#r}set autoActiveFirstOption(e){this.#r=e}#i;get displayWith(){return this.#i}set displayWith(e){this.#i=e}#a;get size(){return this.#a}set size(e){this.#a=e}#o;get autoSelectActiveOption(){return this.#o}set autoSelectActiveOption(e){this.#o=e}#s;get autoSelectActiveOptionOnBlur(){return this.#s}set autoSelectActiveOptionOnBlur(e){this.#s=e}#c;get requireSelection(){return this.#c}set requireSelection(e){this.#c=e}#l;get position(){return this.#l}set position(e){this.#l=e}get originElement(){return this.origin??this.closest?.(`sbb-form-field`)?.shadowRoot?.querySelector?.(`#overlay-anchor`)??this.trigger??null}get triggerElement(){return this._triggerElement??null}constructor(){super(),this.#e=t(this,b,null),this.#t=(t(this,E),t(this,O,null)),this.#n=(t(this,k),t(this,j,!1)),this.#r=(t(this,M),t(this,P,!1)),this.#i=(t(this,F),t(this,L,null)),this.#a=(t(this,R),t(this,B,null)),this.#o=(t(this,V),t(this,U,!1)),this.#s=(t(this,W),t(this,K,!1)),this.#c=(t(this,q),t(this,Y,!1)),this.#l=(t(this,X),t(this,Q,`auto`)),this._triggerElement=t(this,$),this.activeOption=null,this.pendingAutoSelectedOption=null,this._resizeObserver=new n(this,{target:null,skipInitial:!0,callback:(()=>{let e;return()=>{clearTimeout(e),e=setTimeout(()=>{this.state!==`closed`&&this._setOverlayPosition()},10)}})()}),this._triggerAttributeObserver=r?null:new MutationObserver(e=>{let t=e[0].target;(t.hasAttribute(`disabled`)||t.hasAttribute(`readonly`))&&this.close()}),this._isPointerDownEventOnMenu=!1,this._escapableOverlayController=new s(this),this._optionsCount=0,this._lastUserInput=null,this._isCustomChangeEvent=!1,this._pointerDownListener=e=>{this._isPointerDownEventOnMenu=m(this._overlay,e)},this._closeOnBackdropClick=e=>{!this._isPointerDownEventOnMenu&&!m(this._overlay,e)&&!m(this.originElement,e)&&this.close()},this.addEventListener?.(`optionselected`,e=>this.onOptionSelected(e)),this.addEventListener?.(`ɵoptgroupslotchange`,()=>this._handleSlotchange(),{capture:!0}),this.addController(new u(this,()=>this.closest(`sbb-form-field`),{negative:e=>{this.negative=e.negative,this.syncNegative()},borderless:e=>this.toggleState(`option-panel-origin-borderless`,e.borderless)}))}open(){if(this.state===`opening`||this.state===`opened`||!this._overlay||this.options.length===0||this._readonly()||!this.dispatchBeforeOpenEvent())return;this.showPopover?.(),this.state=`opening`,this.triggerElement?.toggleAttribute(`data-expanded`,!0);let e=this.originElement;if(!e)throw Error(`Cannot find the origin element. Please specify a valid element or check the usage of the "origin" property from the documentation`);this._setOverlayPosition(e),this._setNextActiveOptionIfAutoActiveFirstOption(),this._attachOpenPanelEvents(),this._escapableOverlayController.connect(),this._isZeroAnimationDuration()&&this._handleOpening()}close(){this.state===`closing`||this.state===`closed`||!this.dispatchBeforeCloseEvent()||(this.pendingAutoSelectedOption&&(this.pendingAutoSelectedOption.selected=!0,this._setValueAndDispatchEvents(this.pendingAutoSelectedOption,!0)),this.state=`closing`,this.triggerElement?.removeAttribute(`data-expanded`),this._openPanelEventsController.abort(),this.originElement&&this._resizeObserver.unobserve(this.originElement),this._isZeroAnimationDuration()&&this._handleClosing())}_isZeroAnimationDuration(){return g(this,`--sbb-options-panel-animation-duration`)}connectedCallback(){this.popover=`manual`,super.connectedCallback(),w&&(this.id||=this.overlayId),this.hasUpdated&&this._componentSetup(),this.syncNegative()}willUpdate(e){super.willUpdate(e),e.has(`negative`)&&this.syncNegative(),e.has(`autoActiveFirstOption`)&&this.isOpen&&this._setNextActiveOptionIfAutoActiveFirstOption()}firstUpdated(e){super.firstUpdated(e),this._componentSetup()}disconnectedCallback(){super.disconnectedCallback(),this._triggerElement=null,this._triggerAbortController?.abort(),this._openPanelEventsController?.abort()}requestUpdate(e,t,n){super.requestUpdate(e,t,n),!(r||!this.hasUpdated)&&(!e||e===`trigger`?this._configureTrigger():(!e||e===`origin`)&&this.isOpen&&this._setOverlayPosition())}onOptionSelected(e){let t=e.target;this._setValueAndDispatchEvents(t),this.close()}setPendingSelection(e){this.pendingAutoSelectedOption=e,this._setInputValue(e)}_setValueAndDispatchEvents(e,t=!1){this.options.filter(t=>t!==e&&t.selected).forEach(e=>e.selected=!1),this.pendingAutoSelectedOption=null,this.triggerElement&&(this._setInputValue(e),this._isCustomChangeEvent=!0,this.triggerElement.dispatchEvent(new Event(`change`,{bubbles:!0})),this.triggerElement.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this._lastUserInput=null,this.triggerElement.dispatchEvent(new T(e)),t||this.triggerElement.focus())}_setInputValue(e){if(!this.triggerElement)return;let t=this.displayWith?.(e.value)??e.value;Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`).set.call(this.triggerElement,t)}_handleSlotchange(){this._highlightOptions(this.triggerElement?.value);let e=Array.from(this.querySelectorAll(`*`));this._previousElements?.forEach(e=>this._resizeObserver.unobserve(e)),this._previousElements=e,this._previousElements.forEach(e=>this._resizeObserver.observe(e)),this.isOpen?(this._setOverlayPosition(),this._setNextActiveOptionIfAutoActiveFirstOption(),this._optionsCount>0&&this.options.length===0&&this.close()):document?.activeElement===this.triggerElement&&this._optionsCount===0&&this.options.length>0&&this.open(),this._optionsCount=this.options.length}_setNextActiveOptionIfAutoActiveFirstOption(){this.autoActiveFirstOption&&(this.resetActiveElement(),this.setNextActiveOption())}_readonly(){return this.triggerElement?.hasAttribute(`readonly`)??!1}_componentSetup(){r||this._configureTrigger()}_configureTrigger(){let e=this.trigger??this.closest?.(`sbb-form-field`)?.querySelector(`input`);if(e===this.triggerElement||(this._triggerAbortController?.abort(),v(this.triggerElement),this.triggerElement?.removeAttribute(`data-expanded`),this._triggerElement=e,!this.triggerElement))return;let t=this.originElement;this.triggerElement===t&&this.isOpen&&this._setOverlayPosition(t),this._triggerAttributeObserver?.observe(this.triggerElement,{attributes:!0,attributeFilter:[`disabled`,`readonly`]}),this.setTriggerAttributes(this.triggerElement),this._triggerAbortController=new AbortController,this.triggerElement.addEventListener(`focus`,()=>this.open(),{signal:this._triggerAbortController.signal}),this.triggerElement.addEventListener(`click`,()=>this.open(),{signal:this._triggerAbortController.signal}),this.triggerElement.addEventListener(`input`,e=>{let t=e.target.value;t&&e.isTrusted&&this.open(),this._highlightOptions(t),this._lastUserInput=t,this.pendingAutoSelectedOption=null},{signal:this._triggerAbortController.signal}),this.triggerElement.addEventListener(`change`,e=>{this.requireSelection&&!this._isCustomChangeEvent&&e.stopImmediatePropagation(),this._isCustomChangeEvent=!1},{signal:this._triggerAbortController.signal,capture:!0}),this.triggerElement.addEventListener(`keydown`,e=>this._closedPanelKeyboardInteraction(e),{signal:this._triggerAbortController.signal,capture:!0}),this.triggerElement.addEventListener(`blur`,e=>{this.contains(e.relatedTarget)||(this.autoSelectActiveOptionOnBlur&&this.activeOption&&this._lastUserInput&&this.triggerElement?.value&&(this.activeOption.selected=!0,this._setValueAndDispatchEvents(this.activeOption,!0)),this.requireSelection&&this.triggerElement&&this._lastUserInput!=null&&!this.pendingAutoSelectedOption&&(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`).set.call(this.triggerElement,``),this._highlightOptions(``),this._isCustomChangeEvent=!0,this.triggerElement.dispatchEvent(new Event(`change`,{bubbles:!0})),this.triggerElement.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0}))),this.close())},{signal:this._triggerAbortController.signal,capture:!0})}_setOverlayPosition(e=this.originElement){e&&x(this._overlay,e,this._overlay,this.shadowRoot.querySelector(`.sbb-option-panel__overlay-container`),this,this.position)}_onAnimationEnd(e){e.animationName===`open`&&this.state===`opening`?this._handleOpening():e.animationName===`close`&&this.state===`closing`&&this._handleClosing()}_handleOpening(){this.state=`opened`,this.originElement&&this._resizeObserver.observe(this.originElement),this.triggerElement?.setAttribute(`aria-expanded`,`true`),this.dispatchOpenEvent()}_handleClosing(){this.state=`closed`,this.hidePopover?.(),this.triggerElement?.setAttribute(`aria-expanded`,`false`),this.resetActiveElement(),this._overlay.scrollTop=0,this._escapableOverlayController.disconnect(),this.dispatchCloseEvent()}_attachOpenPanelEvents(){this._openPanelEventsController=new AbortController,document.addEventListener(`scroll`,()=>this._setOverlayPosition(),{passive:!0,signal:this._openPanelEventsController.signal,capture:!0}),window.addEventListener(`resize`,()=>this._setOverlayPosition(),{passive:!0,signal:this._openPanelEventsController.signal}),window.addEventListener(`pointerdown`,e=>this._pointerDownListener(e),{signal:this._openPanelEventsController.signal}),window.addEventListener(`pointerup`,e=>this._closeOnBackdropClick(e),{signal:this._openPanelEventsController.signal}),this.addEventListener(`ɵdisabledchange`,()=>{this.activeOption?.disabled&&this.resetActiveElement(),this._setNextActiveOptionIfAutoActiveFirstOption()},{signal:this._openPanelEventsController.signal}),this.triggerElement?.addEventListener(`keydown`,e=>this.openedPanelKeyboardInteraction(e),{signal:this._openPanelEventsController.signal,capture:!0})}_closedPanelKeyboardInteraction(e){if(this.state!==`opening`&&this.state!==`opened`)switch(e.key){case`ArrowDown`:case`ArrowUp`:this.open();break}}_highlightOptions(e){e!=null&&this.options.forEach(t=>t.highlight(e))}render(){return ee`
1
+ import{__esDecorate as e,__runInitializers as t}from"tslib";import{ResizeController as n}from"@lit-labs/observers/resize-controller.js";import{html as r,isServer as i,nothing as a,unsafeCSS as o}from"lit";import{property as s}from"lit/decorators.js";import{ref as c}from"lit/directives/ref.js";import{SbbEscapableOverlayController as ee,SbbNegativeMixin as l,SbbOpenCloseBaseElement as u,SbbPropertyWatcherController as d,forceType as f,getNextElementIndex as p,idReference as m,isEventOnElement as h,isSafari as g,isZeroAnimationDuration as _,popoverResetStyles as v,removeAriaComboBoxAttributes as te,scrollbarStyles as y,setAriaComboBoxAttributes as b,setOverlayPosition as x}from"./core.js";import{optionPanelStyles as S}from"./option.pure.js";var C=`:host{display:none}:host(:is(:is(:state(state-opening),[state--state-opening]),:is(:state(state-opened),[state--state-opened]),:is(:state(state-closing),[state--state-closing]))){display:block}
2
+ `;const w=g;var T=class extends Event{get option(){return this._option}constructor(e){super(`inputAutocomplete`,{bubbles:!0,composed:!0}),this._option=e}};let E=(()=>{let p=l(u),g,b=[],E=[],D,O=[],k=[],A,j=[],M=[],N,P=[],F=[],I,L=[],R=[],z,B=[],V=[],H,U=[],W=[],G,K=[],q=[],J,Y=[],X=[],Z,Q=[],$=[];return class extends p{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(p[Symbol.metadata]??null):void 0;g=[m(),s()],D=[m(),s()],A=[f(),s({attribute:`preserve-icon-space`,reflect:!0,type:Boolean})],N=[f(),s({attribute:`auto-active-first-option`,type:Boolean})],I=[s({attribute:!1})],z=[s({reflect:!0})],H=[f(),s({attribute:`auto-select-active-option`,type:Boolean})],G=[f(),s({attribute:`auto-select-active-option-on-blur`,type:Boolean})],J=[f(),s({attribute:`require-selection`,type:Boolean})],Z=[s()],e(this,null,g,{kind:`accessor`,name:`origin`,static:!1,private:!1,access:{has:e=>`origin`in e,get:e=>e.origin,set:(e,t)=>{e.origin=t}},metadata:t},b,E),e(this,null,D,{kind:`accessor`,name:`trigger`,static:!1,private:!1,access:{has:e=>`trigger`in e,get:e=>e.trigger,set:(e,t)=>{e.trigger=t}},metadata:t},O,k),e(this,null,A,{kind:`accessor`,name:`preserveIconSpace`,static:!1,private:!1,access:{has:e=>`preserveIconSpace`in e,get:e=>e.preserveIconSpace,set:(e,t)=>{e.preserveIconSpace=t}},metadata:t},j,M),e(this,null,N,{kind:`accessor`,name:`autoActiveFirstOption`,static:!1,private:!1,access:{has:e=>`autoActiveFirstOption`in e,get:e=>e.autoActiveFirstOption,set:(e,t)=>{e.autoActiveFirstOption=t}},metadata:t},P,F),e(this,null,I,{kind:`accessor`,name:`displayWith`,static:!1,private:!1,access:{has:e=>`displayWith`in e,get:e=>e.displayWith,set:(e,t)=>{e.displayWith=t}},metadata:t},L,R),e(this,null,z,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:t},B,V),e(this,null,H,{kind:`accessor`,name:`autoSelectActiveOption`,static:!1,private:!1,access:{has:e=>`autoSelectActiveOption`in e,get:e=>e.autoSelectActiveOption,set:(e,t)=>{e.autoSelectActiveOption=t}},metadata:t},U,W),e(this,null,G,{kind:`accessor`,name:`autoSelectActiveOptionOnBlur`,static:!1,private:!1,access:{has:e=>`autoSelectActiveOptionOnBlur`in e,get:e=>e.autoSelectActiveOptionOnBlur,set:(e,t)=>{e.autoSelectActiveOptionOnBlur=t}},metadata:t},K,q),e(this,null,J,{kind:`accessor`,name:`requireSelection`,static:!1,private:!1,access:{has:e=>`requireSelection`in e,get:e=>e.requireSelection,set:(e,t)=>{e.requireSelection=t}},metadata:t},Y,X),e(this,null,Z,{kind:`accessor`,name:`position`,static:!1,private:!1,access:{has:e=>`position`in e,get:e=>e.position,set:(e,t)=>{e.position=t}},metadata:t},Q,$),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.styles=[v,y,S,o(C)]}#e;get origin(){return this.#e}set origin(e){this.#e=e}#t;get trigger(){return this.#t}set trigger(e){this.#t=e}#n;get preserveIconSpace(){return this.#n}set preserveIconSpace(e){this.#n=e}#r;get autoActiveFirstOption(){return this.#r}set autoActiveFirstOption(e){this.#r=e}#i;get displayWith(){return this.#i}set displayWith(e){this.#i=e}#a;get size(){return this.#a}set size(e){this.#a=e}#o;get autoSelectActiveOption(){return this.#o}set autoSelectActiveOption(e){this.#o=e}#s;get autoSelectActiveOptionOnBlur(){return this.#s}set autoSelectActiveOptionOnBlur(e){this.#s=e}#c;get requireSelection(){return this.#c}set requireSelection(e){this.#c=e}#l;get position(){return this.#l}set position(e){this.#l=e}get originElement(){return this.origin??this.closest?.(`sbb-form-field`)?.shadowRoot?.querySelector?.(`#overlay-anchor`)??this.trigger??null}get triggerElement(){return this._triggerElement??null}constructor(){super(),this.#e=t(this,b,null),this.#t=(t(this,E),t(this,O,null)),this.#n=(t(this,k),t(this,j,!1)),this.#r=(t(this,M),t(this,P,!1)),this.#i=(t(this,F),t(this,L,null)),this.#a=(t(this,R),t(this,B,null)),this.#o=(t(this,V),t(this,U,!1)),this.#s=(t(this,W),t(this,K,!1)),this.#c=(t(this,q),t(this,Y,!1)),this.#l=(t(this,X),t(this,Q,`auto`)),this._triggerElement=t(this,$),this.activeOption=null,this.pendingAutoSelectedOption=null,this._resizeObserver=new n(this,{target:null,skipInitial:!0,callback:(()=>{let e;return()=>{clearTimeout(e),e=setTimeout(()=>{this.state!==`closed`&&this._setOverlayPosition()},10)}})()}),this._triggerAttributeObserver=i?null:new MutationObserver(e=>{let t=e[0].target;(t.hasAttribute(`disabled`)||t.hasAttribute(`readonly`))&&this.close()}),this._isPointerDownEventOnMenu=!1,this._escapableOverlayController=new ee(this),this._optionsCount=0,this._lastUserInput=null,this._isCustomChangeEvent=!1,this._pointerDownListener=e=>{this._isPointerDownEventOnMenu=h(this._overlay,e)},this._closeOnBackdropClick=e=>{!this._isPointerDownEventOnMenu&&!h(this._overlay,e)&&!h(this.originElement,e)&&this.close()},this.addEventListener?.(`optionselected`,e=>this.onOptionSelected(e)),this.addEventListener?.(`ɵoptgroupslotchange`,()=>this._handleSlotchange(),{capture:!0}),this.addController(new d(this,()=>this.closest(`sbb-form-field`),{negative:e=>{this.negative=e.negative,this.syncNegative()},borderless:e=>this.toggleState(`option-panel-origin-borderless`,e.borderless)}))}open(){if(this.state===`opening`||this.state===`opened`||!this._overlay||this.options.length===0||this._readonly()||!this.dispatchBeforeOpenEvent())return;this.showPopover?.(),this.state=`opening`,this.triggerElement?.toggleAttribute(`data-expanded`,!0);let e=this.originElement;if(!e)throw Error(`Cannot find the origin element. Please specify a valid element or check the usage of the "origin" property from the documentation`);this._setOverlayPosition(e),this._setNextActiveOptionIfAutoActiveFirstOption(),this._attachOpenPanelEvents(),this._escapableOverlayController.connect(),this._isZeroAnimationDuration()&&this._handleOpening()}close(){this.state===`closing`||this.state===`closed`||!this.dispatchBeforeCloseEvent()||(this.pendingAutoSelectedOption&&(this.pendingAutoSelectedOption.selected=!0,this._setValueAndDispatchEvents(this.pendingAutoSelectedOption,!0)),this.state=`closing`,this.triggerElement?.removeAttribute(`data-expanded`),this._openPanelEventsController.abort(),this.originElement&&this._resizeObserver.unobserve(this.originElement),this._isZeroAnimationDuration()&&this._handleClosing())}_isZeroAnimationDuration(){return _(this,`--sbb-options-panel-animation-duration`)}connectedCallback(){this.popover=`manual`,super.connectedCallback(),w&&(this.id||=this.overlayId),this.hasUpdated&&this._componentSetup(),this.syncNegative()}willUpdate(e){super.willUpdate(e),e.has(`negative`)&&this.syncNegative(),e.has(`autoActiveFirstOption`)&&this.isOpen&&this._setNextActiveOptionIfAutoActiveFirstOption()}firstUpdated(e){super.firstUpdated(e),this._componentSetup()}disconnectedCallback(){super.disconnectedCallback(),this._triggerElement=null,this._triggerAbortController?.abort(),this._openPanelEventsController?.abort()}requestUpdate(e,t,n){super.requestUpdate(e,t,n),!(i||!this.hasUpdated)&&(!e||e===`trigger`?this._configureTrigger():(!e||e===`origin`)&&this.isOpen&&this._setOverlayPosition())}onOptionSelected(e){let t=e.target;this._setValueAndDispatchEvents(t),this.close()}setPendingSelection(e){this.pendingAutoSelectedOption=e,this._setInputValue(e)}_setValueAndDispatchEvents(e,t=!1){this.options.filter(t=>t!==e&&t.selected).forEach(e=>e.selected=!1),this.pendingAutoSelectedOption=null,this.triggerElement&&(this._setInputValue(e),this._isCustomChangeEvent=!0,this.triggerElement.dispatchEvent(new Event(`change`,{bubbles:!0})),this.triggerElement.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this._lastUserInput=null,this.triggerElement.dispatchEvent(new T(e)),t||this.triggerElement.focus())}_setInputValue(e){if(!this.triggerElement)return;let t=this.displayWith?.(e.value)??e.value;Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`).set.call(this.triggerElement,t)}_handleSlotchange(){this._highlightOptions(this.triggerElement?.value);let e=Array.from(this.querySelectorAll(`*`));this._previousElements?.forEach(e=>this._resizeObserver.unobserve(e)),this._previousElements=e,this._previousElements.forEach(e=>this._resizeObserver.observe(e)),this.isOpen?(this._setOverlayPosition(),this._setNextActiveOptionIfAutoActiveFirstOption(),this._optionsCount>0&&this.options.length===0&&this.close()):document?.activeElement===this.triggerElement&&this._optionsCount===0&&this.options.length>0&&this.open(),this._optionsCount=this.options.length}_setNextActiveOptionIfAutoActiveFirstOption(){this.autoActiveFirstOption&&(this.resetActiveElement(),this.setNextActiveOption())}_readonly(){return this.triggerElement?.hasAttribute(`readonly`)??!1}_componentSetup(){i||this._configureTrigger()}_configureTrigger(){let e=this.trigger??this.closest?.(`sbb-form-field`)?.querySelector(`input`);if(e===this.triggerElement||(this._triggerAbortController?.abort(),te(this.triggerElement),this.triggerElement?.removeAttribute(`data-expanded`),this._triggerElement=e,!this.triggerElement))return;let t=this.originElement;this.triggerElement===t&&this.isOpen&&this._setOverlayPosition(t),this._triggerAttributeObserver?.observe(this.triggerElement,{attributes:!0,attributeFilter:[`disabled`,`readonly`]}),this.setTriggerAttributes(this.triggerElement),this._triggerAbortController=new AbortController,this.triggerElement.addEventListener(`focus`,()=>this.open(),{signal:this._triggerAbortController.signal}),this.triggerElement.addEventListener(`click`,()=>this.open(),{signal:this._triggerAbortController.signal}),this.triggerElement.addEventListener(`input`,e=>{let t=e.target.value;t&&e.isTrusted&&this.open(),this._highlightOptions(t),this._lastUserInput=t,this.pendingAutoSelectedOption=null},{signal:this._triggerAbortController.signal}),this.triggerElement.addEventListener(`change`,e=>{this.requireSelection&&!this._isCustomChangeEvent&&e.stopImmediatePropagation(),this._isCustomChangeEvent=!1},{signal:this._triggerAbortController.signal,capture:!0}),this.triggerElement.addEventListener(`keydown`,e=>this._closedPanelKeyboardInteraction(e),{signal:this._triggerAbortController.signal,capture:!0}),this.triggerElement.addEventListener(`blur`,e=>{this.contains(e.relatedTarget)||(this.autoSelectActiveOptionOnBlur&&this.activeOption&&this._lastUserInput&&this.triggerElement?.value&&(this.activeOption.selected=!0,this._setValueAndDispatchEvents(this.activeOption,!0)),this.requireSelection&&this.triggerElement&&this._lastUserInput!=null&&!this.pendingAutoSelectedOption&&(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`).set.call(this.triggerElement,``),this._highlightOptions(``),this._isCustomChangeEvent=!0,this.triggerElement.dispatchEvent(new Event(`change`,{bubbles:!0})),this.triggerElement.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0}))),this.close())},{signal:this._triggerAbortController.signal,capture:!0})}_setOverlayPosition(e=this.originElement){e&&x(this._overlay,e,this._overlay,this.shadowRoot.querySelector(`.sbb-option-panel__overlay-container`),this,this.position)}_onAnimationEnd(e){e.animationName===`open`&&this.state===`opening`?this._handleOpening():e.animationName===`close`&&this.state===`closing`&&this._handleClosing()}_handleOpening(){this.state=`opened`,this.originElement&&this._resizeObserver.observe(this.originElement),this.triggerElement?.setAttribute(`aria-expanded`,`true`),this.dispatchOpenEvent()}_handleClosing(){this.state=`closed`,this.hidePopover?.(),this.triggerElement?.setAttribute(`aria-expanded`,`false`),this.resetActiveElement(),this._overlay.scrollTop=0,this._escapableOverlayController.disconnect(),this.dispatchCloseEvent()}_attachOpenPanelEvents(){this._openPanelEventsController=new AbortController,document.addEventListener(`scroll`,()=>this._setOverlayPosition(),{passive:!0,signal:this._openPanelEventsController.signal,capture:!0}),window.addEventListener(`resize`,()=>this._setOverlayPosition(),{passive:!0,signal:this._openPanelEventsController.signal}),window.addEventListener(`pointerdown`,e=>this._pointerDownListener(e),{signal:this._openPanelEventsController.signal}),window.addEventListener(`pointerup`,e=>this._closeOnBackdropClick(e),{signal:this._openPanelEventsController.signal}),this.addEventListener(`ɵdisabledchange`,()=>{this.activeOption?.disabled&&this.resetActiveElement(),this._setNextActiveOptionIfAutoActiveFirstOption()},{signal:this._openPanelEventsController.signal}),this.triggerElement?.addEventListener(`keydown`,e=>this.openedPanelKeyboardInteraction(e),{signal:this._openPanelEventsController.signal,capture:!0})}_closedPanelKeyboardInteraction(e){if(this.state!==`opening`&&this.state!==`opened`)switch(e.key){case`ArrowDown`:case`ArrowUp`:this.open()}}_highlightOptions(e){e!=null&&this.options.forEach(t=>t.highlight(e))}render(){return r`
3
3
  <div class="sbb-option-panel__overlay-container">
4
4
  <div
5
5
  class="sbb-option-panel__overlay ${this.negative?`sbb-scrollbar-negative`:`sbb-scrollbar`}"
6
- role=${w?i:this.panelRole}
7
- id=${w?i:this.overlayId}
6
+ role=${w?a:this.panelRole}
7
+ id=${w?a:this.overlayId}
8
8
  tabindex="-1"
9
9
  @animationend=${this._onAnimationEnd}
10
- ${te(e=>this._overlay=e)}
10
+ ${c(e=>this._overlay=e)}
11
11
  >
12
12
  <slot @slotchange=${this._handleSlotchange}></slot>
13
13
  </div>
14
14
  </div>
15
- `}}})(),D=0;const O=h;var k=class extends E{constructor(){super(...arguments),this.overlayId=`sbb-autocomplete-${++D}`,this.panelRole=`listbox`}static{this.elementName=`sbb-autocomplete`}static{this.role=O?`listbox`:null}get options(){return Array.from(this.querySelectorAll?.(`sbb-option`)??[])}syncNegative(){this.querySelectorAll?.(`sbb-divider, sbb-option-hint`).forEach(e=>e.negative=this.negative)}openedPanelKeyboardInteraction(e){if(this.isOpen)switch(e.key){case`Enter`:this.selectByKeyboard(e);break;case`ArrowDown`:case`ArrowUp`:this.setNextActiveOption(e);break}}selectByKeyboard(e){this.activeOption&&(e.preventDefault(),this.activeOption.selectViaUserInteraction(!0))}setNextActiveOption(e){let t=this.options.filter(e=>!e.matches(`:is(:state(disabled),[state--disabled])`));if(this.activeOption?.setActive(!1),this.triggerElement.ariaActiveDescendantElement=null,!t.length){this.activeOption=null;return}let n=f(e,this.activeOption?t.indexOf(this.activeOption):-1,t.length);this.activeOption=t[n],this.activeOption.setActive(!0),this.triggerElement.ariaActiveDescendantElement=this.activeOption,this.activeOption.scrollIntoView({block:`nearest`}),e&&e.preventDefault(),this.autoSelectActiveOption&&e&&this.setPendingSelection(this.activeOption)}resetActiveElement(){this.activeOption?.setActive(!1),this.activeOption=null,this.triggerElement&&(this.triggerElement.ariaActiveDescendantElement=null)}setTriggerAttributes(e){b(e,O?this.id:this.overlayId,!1)}};export{E as SbbAutocompleteBaseElement,k as SbbAutocompleteElement,T as SbbInputAutocompleteEvent};
15
+ `}}})(),D=0;const O=g;var k=class extends E{constructor(){super(...arguments),this.overlayId=`sbb-autocomplete-${++D}`,this.panelRole=`listbox`}static{this.elementName=`sbb-autocomplete`}static{this.role=O?`listbox`:null}get options(){return Array.from(this.querySelectorAll?.(`sbb-option`)??[])}syncNegative(){this.querySelectorAll?.(`sbb-divider, sbb-option-hint`).forEach(e=>e.negative=this.negative)}openedPanelKeyboardInteraction(e){if(this.isOpen)switch(e.key){case`Enter`:this.selectByKeyboard(e);break;case`ArrowDown`:case`ArrowUp`:this.setNextActiveOption(e)}}selectByKeyboard(e){this.activeOption&&(e.preventDefault(),this.activeOption.selectViaUserInteraction(!0))}setNextActiveOption(e){let t=this.options.filter(e=>!e.matches(`:is(:state(disabled),[state--disabled])`));if(this.activeOption?.setActive(!1),this.triggerElement.ariaActiveDescendantElement=null,!t.length){this.activeOption=null;return}let n=this.activeOption?t.indexOf(this.activeOption):-1,r=p(e,n,t.length);this.activeOption=t[r],this.activeOption.setActive(!0),this.triggerElement.ariaActiveDescendantElement=this.activeOption,this.activeOption.scrollIntoView({block:`nearest`}),e&&e.preventDefault(),this.autoSelectActiveOption&&e&&this.setPendingSelection(this.activeOption)}resetActiveElement(){this.activeOption?.setActive(!1),this.activeOption=null,this.triggerElement&&(this.triggerElement.ariaActiveDescendantElement=null)}setTriggerAttributes(e){b(e,O?this.id:this.overlayId,!1)}};export{E as SbbAutocompleteBaseElement,k as SbbAutocompleteElement,T as SbbInputAutocompleteEvent};
@@ -1,5 +1,5 @@
1
1
  import{__esDecorate as e,__runInitializers as t}from"tslib";import{ResizeController as n}from"@lit-labs/observers/resize-controller.js";import{html as r,nothing as i,unsafeCSS as a}from"lit";import{state as o}from"lit/decorators.js";import{SbbElement as s,SbbLanguageController as c,SbbLinkBaseElement as l,SbbNamedSlotListMixin as u,buttonResetStyles as d,getNextElementIndex as f,i18nBreadcrumbEllipsisButtonLabel as p,isArrowKeyPressed as m,listResetStyles as h,sbbInputModalityDetector as g}from"./core.js";import{SbbIconElement as _,SbbIconNameMixin as v}from"./icon.pure.js";import{html as y}from"lit/static-html.js";var b=`:host{min-width:0;line-height:var(--sbb-typo-line-height-text);display:block}:host(:is(:state(loaded),[state--loaded])){--sbb-breadcrumb-group-visibility:visible}:host(:is(:is(:state(state-collapsed),[state--state-collapsed]),:is(:state(state-manually-expanded),[state--state-manually-expanded]))){--sbb-breadcrumb-group-wrap:wrap}.sbb-breadcrumb-group{flex-wrap:var(--sbb-breadcrumb-group-wrap);column-gap:var(--sbb-spacing-fixed-1x);visibility:var(--sbb-breadcrumb-group-visibility);display:flex}.sbb-breadcrumb-group__item{column-gap:var(--sbb-spacing-fixed-1x);flex:none;display:flex}.sbb-breadcrumb-group__divider-icon{color:var(--sbb-breadcrumb-group-ellipsis-color)}#sbb-breadcrumb-ellipsis{font-family:var(--sbb-typo-font-family);font-weight:400;font-size:var(--sbb-text-font-size-xxs);letter-spacing:.01em;width:var(--sbb-size-icon-ui-small);height:var(--sbb-size-icon-ui-small);border:var(--sbb-breadcrumb-group-ellipsis-border-width) solid var(--sbb-breadcrumb-group-ellipsis-border-color);cursor:var(--sbb-cursor-pointer);color:var(--sbb-breadcrumb-group-ellipsis-color);background-color:var(--sbb-breadcrumb-group-ellipsis-background-color);border-radius:50%;padding-block-end:.5em;line-height:0;overflow:hidden}@media (forced-colors:active){#sbb-breadcrumb-ellipsis{--sbb-breadcrumb-group-ellipsis-border-width:var(--sbb-border-width-2x);--sbb-breadcrumb-group-ellipsis-border-color:CanvasText}}@media (any-hover:hover){#sbb-breadcrumb-ellipsis:hover{--sbb-breadcrumb-group-ellipsis-color:var(--sbb-color-2);--sbb-breadcrumb-group-ellipsis-background-color:var(--sbb-background-color-3)}}@media (any-hover:hover) and (forced-colors:active){#sbb-breadcrumb-ellipsis:hover{--sbb-breadcrumb-group-ellipsis-border-color:Highlight}}#sbb-breadcrumb-ellipsis:focus-visible{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style,solid) var(--sbb-focus-outline-width)}
2
- `;let x=(()=>{let l=u(s),v=[],y;return class extends l{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(l[Symbol.metadata]??null):void 0;y=[o()],e(this,null,y,{kind:`setter`,name:`_state`,static:!1,private:!1,access:{has:e=>`_state`in e,set:(e,t)=>{e._state=t}},metadata:t},null,v),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-breadcrumb-group`}static{this.elementDependencies=[_]}static{this.role=`navigation`}static{this.styles=[h,d,a(b)]}set _state(e){this._stateInternal&&this.internals.states.delete(`state-${this._stateInternal}`),this._stateInternal=e,this._stateInternal&&this.internals.states.add(`state-${this._stateInternal}`)}get _state(){return this._stateInternal}constructor(){super(),this.listChildLocalNames=(t(this,v),[`sbb-breadcrumb`]),this._stateInternal=null,this._resizeObserver=new n(this,{target:null,skipInitial:!0,callback:()=>this._evaluateCollapsedState()}),this._language=new c(this),this._markForFocus=!1,this.addEventListener?.(`keydown`,e=>this._handleKeyDown(e))}_handleKeyDown(e){if(!(!this.listChildren.length||e.target!==this&&e.target.parentElement!==this)&&m(e)){if(this._state===`collapsed`)return this._focusNextCollapsed(e);this._focusNext(e)}}firstUpdated(e){super.firstUpdated(e),this._resizeObserver.observe(this),this.internals.states.add(`loaded`)}willUpdate(e){super.willUpdate(e),e.has(`listChildren`)&&this._syncBreadcrumbs()}updated(e){super.updated(e),e.has(`listChildren`)&&Promise.resolve().then(()=>this._evaluateCollapsedState()),this._markForFocus&&g.mostRecentModality===`keyboard`&&(this.listChildren[1]?.focus(),this._markForFocus=!1)}_syncBreadcrumbs(){this.listChildren.slice(0,-1).filter(e=>e.hasAttribute(`accessibility-current`)).forEach(e=>e.removeAttribute(`accessibility-current`)),this.listChildren[this.listChildren.length-1]?.setAttribute(`accessibility-current`,`page`),this.listChildren.length<3&&(this._state=null)}_focusNextCollapsed(e){let t=[this.listChildren[0],this.shadowRoot.querySelector(`#sbb-breadcrumb-ellipsis`),this.listChildren[this.listChildren.length-1]];this._focusNext(e,t)}_focusNext(e,t=this.listChildren){t[f(e,t.findIndex(e=>e===document.activeElement||e===this.shadowRoot.activeElement),t.length)]?.focus(),e.preventDefault()}_expandBreadcrumbs(){this._state=`manually-expanded`,this._markForFocus=!0}_evaluateCollapsedState(){!this._state&&this.scrollWidth>this.offsetWidth&&this.listChildren.length>=3&&(this._state=`collapsed`,this._resizeObserver.hostDisconnected(),this.removeController(this._resizeObserver))}_renderCollapsed(){return r`
2
+ `;let x=(()=>{let l=u(s),v=[],y;return class extends l{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(l[Symbol.metadata]??null):void 0;y=[o()],e(this,null,y,{kind:`setter`,name:`_state`,static:!1,private:!1,access:{has:e=>`_state`in e,set:(e,t)=>{e._state=t}},metadata:t},null,v),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-breadcrumb-group`}static{this.elementDependencies=[_]}static{this.role=`navigation`}static{this.styles=[h,d,a(b)]}set _state(e){this._stateInternal&&this.internals.states.delete(`state-${this._stateInternal}`),this._stateInternal=e,this._stateInternal&&this.internals.states.add(`state-${this._stateInternal}`)}get _state(){return this._stateInternal}constructor(){super(),this.listChildLocalNames=(t(this,v),[`sbb-breadcrumb`]),this._stateInternal=null,this._resizeObserver=new n(this,{target:null,skipInitial:!0,callback:()=>this._evaluateCollapsedState()}),this._language=new c(this),this._markForFocus=!1,this.addEventListener?.(`keydown`,e=>this._handleKeyDown(e))}_handleKeyDown(e){if(!(!this.listChildren.length||e.target!==this&&e.target.parentElement!==this)&&m(e)){if(this._state===`collapsed`)return this._focusNextCollapsed(e);this._focusNext(e)}}firstUpdated(e){super.firstUpdated(e),this._resizeObserver.observe(this),this.internals.states.add(`loaded`)}willUpdate(e){super.willUpdate(e),e.has(`listChildren`)&&this._syncBreadcrumbs()}updated(e){super.updated(e),e.has(`listChildren`)&&Promise.resolve().then(()=>this._evaluateCollapsedState()),this._markForFocus&&g.mostRecentModality===`keyboard`&&(this.listChildren[1]?.focus(),this._markForFocus=!1)}_syncBreadcrumbs(){this.listChildren.slice(0,-1).filter(e=>e.hasAttribute(`accessibility-current`)).forEach(e=>e.removeAttribute(`accessibility-current`)),this.listChildren[this.listChildren.length-1]?.setAttribute(`accessibility-current`,`page`),this.listChildren.length<3&&(this._state=null)}_focusNextCollapsed(e){let t=[this.listChildren[0],this.shadowRoot.querySelector(`#sbb-breadcrumb-ellipsis`),this.listChildren[this.listChildren.length-1]];this._focusNext(e,t)}_focusNext(e,t=this.listChildren){let n=t.findIndex(e=>e===document.activeElement||e===this.shadowRoot.activeElement);t[f(e,n,t.length)]?.focus(),e.preventDefault()}_expandBreadcrumbs(){this._state=`manually-expanded`,this._markForFocus=!0}_evaluateCollapsedState(){!this._state&&this.scrollWidth>this.offsetWidth&&this.listChildren.length>=3&&(this._state=`collapsed`,this._resizeObserver.hostDisconnected(),this.removeController(this._resizeObserver))}_renderCollapsed(){return r`
3
3
  <li class="sbb-breadcrumb-group__item">
4
4
  <slot name="li-0"></slot>
5
5
  </li>
package/calendar.pure.js CHANGED
@@ -6,7 +6,7 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
6
6
  <span class="sbb-calendar-day__extra">
7
7
  <slot @slotchange=${e=>this._handleSlotchange(e)}></slot>
8
8
  </span>`}}})(),C=(()=>{let r=b,i=[],a;return class o extends r{constructor(){super(...arguments),this._monthShortNames=(t(this,i),this.dateAdapter.getMonthNames(`short`)),this._monthLongNames=this.dateAdapter.getMonthNames(`long`),this._monthValue=null,this._yearValue=null,this._value=null}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(r[Symbol.metadata]??null):void 0;a=[s()],e(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,i),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar-month`}static{this._monthFormatRegex=/^\d{4}-(0[1-9]|1[0-2])$/}set value(e){if(!e||!o._monthFormatRegex.test(e))return;this._value=e;let t=e.split(`-`);this._yearValue=Number(t[0]),this._monthValue=Number(t[1]);let n=this._yearValue===this.dateAdapter.getYear(this.dateAdapter.today())&&this._monthValue===this.dateAdapter.getMonth(this.dateAdapter.today());this.toggleState(`current`,n),this.internals.ariaLabel=`${this._monthLongNames[this._monthValue-1]} ${this._yearValue}`;let r=this.getParent();r&&(this.setDisabledFilteredState(r),this.setSelectedState(r))}get value(){return this._value}connectedCallback(){super.connectedCallback(),this.tabIndex=-1}setSelectedState(e){let t=!!this.value&&(e.multiple?e.value?.some(e=>this._yearValue===this.dateAdapter.getYear(e)&&this._monthValue===this.dateAdapter.getMonth(e))??!1:!!e.value&&this.dateAdapter.getYear(e.value)===this._yearValue&&this.dateAdapter.getMonth(e.value)===this._monthValue);this.toggleState(`selected`,t),this.internals.ariaPressed=String(t)}setDisabledFilteredState(e){let t=!this._isActiveMonth(e),n=!this._isMonthInRange(e.min,e.max);this.disabled=t||n,this.internals.ariaDisabled=String(this.disabled),this.toggleState(`crossed-out`,t&&!n)}_isActiveMonth(e){if(!e.dateFilter||!this._yearValue||!this._monthValue)return!0;let t=this.dateAdapter.createDate(this._yearValue,this._monthValue,1);for(let n=t;this.dateAdapter.getMonth(n)==this._monthValue;n=this.dateAdapter.addCalendarDays(n,1))if(e.dateFilter(n))return!0;return!1}_isMonthInRange(e,t){if(!e&&!t||!this._yearValue||!this._monthValue)return!0;let n=this.dateAdapter.isValid(e)&&(this._yearValue<this.dateAdapter.getYear(e)||this._yearValue===this.dateAdapter.getYear(e)&&this._monthValue<this.dateAdapter.getMonth(e)),r=this.dateAdapter.isValid(t)&&(this._yearValue>this.dateAdapter.getYear(t)||this._yearValue===this.dateAdapter.getYear(t)&&this._monthValue>this.dateAdapter.getMonth(t));return!(n||r)}renderTemplate(){return n`${this._monthShortNames[this._monthValue-1]}`}}})(),w=(()=>{let r=b,i=[],a;return class extends r{constructor(){super(...arguments),this._value=(t(this,i),null)}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(r[Symbol.metadata]??null):void 0;a=[s()],e(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,i),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar-year`}set value(e){let t=Number(e);if(isNaN(t))return;this._value=e;let n=this.dateAdapter.getYear(this.dateAdapter.today())===t;this.toggleState(`current`,n),this.internals.ariaLabel=String(t);let r=this.getParent();r&&(this.setDisabledFilteredState(r),this.setSelectedState(r))}get value(){return this._value}connectedCallback(){super.connectedCallback(),this.tabIndex=-1}setSelectedState(e){let t=!!this.value&&(e.multiple?e.value?.some(e=>Number(this.value)===this.dateAdapter.getYear(e))??!1:!!e.value&&this.dateAdapter.getYear(e.value)===Number(this.value));this.toggleState(`selected`,t),this.internals.ariaPressed=String(t)}setDisabledFilteredState(e){let t=!this._isActiveYear(e),n=!this._isYearInRange(e.min,e.max);this.disabled=t||n,this.internals.ariaDisabled=String(this.disabled),this.toggleState(`crossed-out`,t&&!n)}_isActiveYear(e){if(!e.dateFilter||!this.value)return!0;let t=this.dateAdapter.createDate(Number(this.value),1,1);for(let n=t;this.dateAdapter.getYear(n)==Number(this.value);n=this.dateAdapter.addCalendarDays(n,1))if(e.dateFilter(n))return!0;return!1}_isYearInRange(e,t){if(!e&&!t||!this.value)return!0;let n=this.dateAdapter.isValid(e)&&this.dateAdapter.getYear(e)>Number(this.value),r=this.dateAdapter.isValid(t)&&this.dateAdapter.getYear(t)<Number(this.value);return!(n||r)}renderTemplate(){return n`${this.value}`}}})(),T=(()=>{let r=b,i=[],a;return class extends r{constructor(){super(...arguments),this._value=(t(this,i),null)}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(r[Symbol.metadata]??null):void 0;a=[s()],e(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,i),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar-weekday`}set value(e){e&&(this._value=e,this.internals.ariaLabel=e.long)}get value(){return this._value}setSelectedState(){}setDisabledFilteredState(){}renderTemplate(){return n`${this.value?.narrow}`}}})(),E=(()=>{let r=b,i=[],a;return class extends r{constructor(){super(...arguments),this._language=(t(this,i),new d(this)),this._value=null}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(r[Symbol.metadata]??null):void 0;a=[s()],e(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,i),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar-weeknumber`}set value(e){e&&(this._value=String(e),this.internals.ariaLabel=`${g[this._language.current]} ${e}`)}get value(){return this._value}setSelectedState(){}setDisabledFilteredState(){}renderTemplate(){return n`${this.value}`}}})();var ve=`:host{width:max-content;max-width:100%;line-height:var(--sbb-typo-line-height-text);display:block}:host(:is(:state(enhanced),[state--enhanced])){--sbb-calendar-cell-padding-block-end:var(--sbb-spacing-fixed-3x)}.sbb-calendar__wrapper{gap:var(--sbb-calendar-tables-gap);flex-wrap:wrap;width:100%;display:flex;position:relative}:is(.sbb-calendar__year-view,.sbb-calendar__month-view){position:absolute;inset-block-start:0;inset-inline-start:0}:host(:not(:is(:state(view-day),[state--view-day]))) .sbb-calendar__day-view{visibility:hidden}.sbb-calendar__table-header{align-items:center;gap:var(--sbb-calendar-control-gap);height:var(--sbb-size-element-xs);margin-block-end:var(--sbb-spacing-fixed-4x);display:flex}.sbb-calendar__table-header span{color:var(--sbb-calendar-control-view-change-color);flex:auto;padding-inline-start:var(--sbb-spacing-fixed-3x)}.sbb-calendar__control{-webkit-tap-highlight-color:transparent}.sbb-calendar__table{border-collapse:collapse;flex:0 0;width:100%;height:max-content}.sbb-calendar__table :is(thead,tbody){text-align:center}.sbb-calendar__table-header-cell,.sbb-calendar__table-header-cell-vertical{width:var(--sbb-calendar-cell-size);min-width:var(--sbb-calendar-cell-size);color:var(--sbb-calendar-header-color);font-size:var(--sbb-text-font-size-xs);letter-spacing:var(--sbb-typo-letter-spacing-text);padding:0;font-weight:400}:host(:not([multiple])) .sbb-calendar__table-header-cell,:host(:not([multiple])) .sbb-calendar__table-header-cell-vertical{height:var(--sbb-calendar-cell-size)}.sbb-calendar__table-header-cell-vertical{padding-block-end:var(--sbb-calendar-cell-padding-block-end)}.sbb-calendar__table-data{text-align:center;padding:0;position:relative}.sbb-calendar__day-cell{padding-block-end:var(--sbb-calendar-cell-padding-block-end)}:host(:not(:is(:state(enhanced),[state--enhanced]))) sbb-calendar-day{--sbb-calendar-day-justify-content:center;--sbb-calendar-day-height:var(--sbb-calendar-day-size);--sbb-calendar-day-extra-display:none;--sbb-calendar-day-value-height:unset}
9
- `,D=class extends Event{get range(){return this._range}constructor(e){super(`monthchange`,{bubbles:!0,composed:!0}),this._range=Object.freeze(e||[])}},ye=class extends Event{get dateSelected(){return this._dateSelected}constructor(e){super(`dateselected`,{bubbles:!0,composed:!0}),this._dateSelected=Object.freeze(e)}};let O=(()=>{let l=te(ee),u=[],f,y=[],b=[],x,O=[],k=[],A,j=[],M=[],N,P=[],F=[],I,L=[],R=[],z,B,V=[],H=[],U,W=[],G=[],K,q,J=[],Y=[],X,Z=[],be=[],xe,Q=[],Se=[],Ce,we=[],Te=[],Ee,De=[],$=[];return class extends l{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(l[Symbol.metadata]??null):void 0;f=[m(),o({type:Number})],x=[o()],A=[_(),o()],N=[_(),o()],I=[m(),oe((e,t)=>e._onMultipleChanged(t)),o({type:Boolean})],z=[o()],B=[s()],U=[o({attribute:`date-filter`})],K=[m(),o({attribute:`fixed-month`})],q=[o({reflect:!0})],X=[m(),o({attribute:`week-numbers`,type:Boolean})],xe=[s()],Ce=[s()],Ee=[s()],e(this,null,f,{kind:`accessor`,name:`amount`,static:!1,private:!1,access:{has:e=>`amount`in e,get:e=>e.amount,set:(e,t)=>{e.amount=t}},metadata:t},y,b),e(this,null,x,{kind:`accessor`,name:`view`,static:!1,private:!1,access:{has:e=>`view`in e,get:e=>e.view,set:(e,t)=>{e.view=t}},metadata:t},O,k),e(this,null,A,{kind:`accessor`,name:`min`,static:!1,private:!1,access:{has:e=>`min`in e,get:e=>e.min,set:(e,t)=>{e.min=t}},metadata:t},j,M),e(this,null,N,{kind:`accessor`,name:`max`,static:!1,private:!1,access:{has:e=>`max`in e,get:e=>e.max,set:(e,t)=>{e.max=t}},metadata:t},P,F),e(this,null,I,{kind:`accessor`,name:`multiple`,static:!1,private:!1,access:{has:e=>`multiple`in e,get:e=>e.multiple,set:(e,t)=>{e.multiple=t}},metadata:t},L,R),e(this,null,z,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,u),e(this,null,B,{kind:`accessor`,name:`_value`,static:!1,private:!1,access:{has:e=>`_value`in e,get:e=>e._value,set:(e,t)=>{e._value=t}},metadata:t},V,H),e(this,null,U,{kind:`accessor`,name:`dateFilter`,static:!1,private:!1,access:{has:e=>`dateFilter`in e,get:e=>e.dateFilter,set:(e,t)=>{e.dateFilter=t}},metadata:t},W,G),e(this,null,K,{kind:`setter`,name:`fixedMonth`,static:!1,private:!1,access:{has:e=>`fixedMonth`in e,set:(e,t)=>{e.fixedMonth=t}},metadata:t},null,u),e(this,null,q,{kind:`accessor`,name:`orientation`,static:!1,private:!1,access:{has:e=>`orientation`in e,get:e=>e.orientation,set:(e,t)=>{e.orientation=t}},metadata:t},J,Y),e(this,null,X,{kind:`accessor`,name:`weekNumbers`,static:!1,private:!1,access:{has:e=>`weekNumbers`in e,get:e=>e.weekNumbers,set:(e,t)=>{e.weekNumbers=t}},metadata:t},Z,be),e(this,null,xe,{kind:`accessor`,name:`_activeDate`,static:!1,private:!1,access:{has:e=>`_activeDate`in e,get:e=>e._activeDate,set:(e,t)=>{e._activeDate=t}},metadata:t},Q,Se),e(this,null,Ce,{kind:`accessor`,name:`_calendarView`,static:!1,private:!1,access:{has:e=>`_calendarView`in e,get:e=>e._calendarView,set:(e,t)=>{e._calendarView=t}},metadata:t},we,Te),e(this,null,Ee,{kind:`accessor`,name:`_initialized`,static:!1,private:!1,access:{has:e=>`_initialized`in e,get:e=>e._initialized,set:(e,t)=>{e._initialized=t}},metadata:t},De,$),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar`}static{this.elementDependencies=[S,C,T,E,w,_e,ge]}static{this.styles=[ae,he,a(ve)]}static{this.events={dateselected:`dateselected`,monthchange:`monthchange`}}#e;get amount(){return this.#e}set amount(e){this.#e=e}#t;get view(){return this.#t}set view(e){this.#t=e}#n;get min(){return this.#n}set min(e){this.#n=e}#r;get max(){return this.#r}set max(e){this.#r=e}#i;get multiple(){return this.#i}set multiple(e){this.#i=e}set value(e){if(Array.isArray(e))this._value=e.map(e=>this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e))).filter(e=>e!==null).filter(e=>!this._isDayInRange(this._dateAdapter.toIso8601(e))||this._dateFilter(e)).sort(this._sortDate);else{let t=this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));t&&(!this._isDayInRange(this._dateAdapter.toIso8601(t))||this._dateFilter(t))?this._value=t:this._value=null}}get value(){return this._value}#a;get _value(){return this.#a}set _value(e){this.#a=e}#o;get dateFilter(){return this.#o}set dateFilter(e){this.#o=e}set fixedMonth(e){let t=e?e.match(/^(\d{4})-(\d{2})$/):null;this._fixedMonth=t?this._dateAdapter.createDate(Number(t[1]),Number(t[2]),1):null}get fixedMonth(){return this._fixedMonth?this._dateAdapter.toIso8601(this._fixedMonth).split(`-`).slice(0,2).join(`-`):``}#s;get orientation(){return this.#s}set orientation(e){this.#s=e}#c;get weekNumbers(){return this.#c}set weekNumbers(e){this.#c=e}#l;get _activeDate(){return this.#l}set _activeDate(e){this.#l=e}#u;get _calendarView(){return this.#u}set _calendarView(e){this.#u=e}get _cells(){return Array.from((this._calendarView===`day`?Array.from(this.shadowRoot.querySelectorAll(`slot`)).flatMap(e=>e.assignedElements({flatten:!0})):this.shadowRoot?.querySelectorAll(`sbb-calendar-${this._calendarView}`))??[])}#d;get _initialized(){return this.#d}set _initialized(e){this.#d=e}constructor(){super(),this.#e=(t(this,u),t(this,y,1)),this.#t=(t(this,b),t(this,O,`day`)),this.#n=(t(this,k),t(this,j,null)),this.#r=(t(this,M),t(this,P,null)),this.#i=(t(this,F),t(this,L,!1)),this.#a=(t(this,R),t(this,V,null)),this.#o=(t(this,H),t(this,W,null)),this._fixedMonth=(t(this,G),null),this.#s=t(this,J,`horizontal`),this.#c=(t(this,Y),t(this,Z,!1)),this._dateAdapter=(t(this,be),v().datetime?.dateAdapter??p),this.#l=t(this,Q,this._dateAdapter.today()),this.#u=(t(this,Se),t(this,we,`day`)),this._weekdays=t(this,Te),this._weeks=[],this._firstVisibleDay=``,this._lastVisibleDay=``,this._monthNames=this._dateAdapter.getMonthNames(`long`),this._enhancedVariant=!1,this._resetFocus=!1,this._containingFocus=!1,this._lastSelection=null,this.#d=t(this,De,!1),this._language=(t(this,$),new d(this).withHandler(()=>{this._monthNames=this._dateAdapter.getMonthNames(`long`),this._createMonthRows()})),this._sortDate=(e,t)=>this._dateAdapter.compareDate(e,t),this._onSlotChange=()=>{this._enhancedVariant=Array.from(this.children).some(e=>e.localName===`sbb-calendar-day`),this.toggleState(`enhanced`,this._enhancedVariant),this._setTabIndex()},this._createMonthRows(),this._setWeekdays(),this.addEventListener(`focusin`,()=>this._containingFocus=!0),this.addEventListener(`focusout`,()=>this._containingFocus=!1);let e=e=>e.target.closest(`sbb-calendar-day`)??e.composedPath().find(e=>e.localName===`sbb-calendar-day`)??null;this.addEventListener(`click`,t=>{let n=e(t);n&&this._selectDate(n.value,t)}),this.addEventListener(`keydown`,t=>{let n=e(t);n&&this._handleKeyboardEvent(t,n)}),this.addEventListener(`blur`,()=>this._lastSelection=null)}_dateFilter(e){return this.dateFilter?.(e)??!0}resetPosition(){this._resetCalendarView(),this._init()}connectedCallback(){super.connectedCallback(),this.resetPosition(),this.shadowRoot?.addEventListener(`slotchange`,this._onSlotChange,{capture:!0})}disconnectedCallback(){super.disconnectedCallback(),this.shadowRoot?.removeEventListener(`slotchange`,this._onSlotChange,{capture:!0})}visibleDays(){return this._weeks.flat(2).sort((e,t)=>e.value.localeCompare(t.value))}formResetCallback(){}formStateRestoreCallback(e,t){if(t===`autocomplete`||e==null)return;let n=e=>this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));if(typeof e==`string`)this.value=n(e);else if(e instanceof FormData){if(this.multiple){this._readFormData(e).then(e=>this.value=e.map(n).filter(e=>e!=null));return}let t=e.get(this.name);t instanceof Blob?t.text().then(e=>this.value=n(JSON.parse(e))):this.value=n(t)}}async _readFormData(e){return Promise.all(e.getAll(this.name).map(async e=>e instanceof Blob?JSON.parse(await e.text()):e))}focus(){this._resetFocus=!0,this._focusCell()}willUpdate(e){super.willUpdate(e),this._initialized&&((e.has(`amount`)||e.has(`orientation`)||e.has(`fixedMonth`))&&this.resetPosition(),e.has(`view`)&&(this._setChosenYear(),this._chosenMonth=void 0,this._calendarView=this.view))}requestUpdate(e,t,n){super.requestUpdate(e,t,n),e===`_calendarView`&&(this.internals.states.delete(`view-${t}`),this.internals.states.add(`view-${this._calendarView}`),this._containingFocus&&(this._resetFocus=!0))}updated(e){super.updated(e),this._setTabIndex(),this._focusCell()}firstUpdated(e){super.firstUpdated(e),this._emitMonthChange()}_onMultipleChanged(e){e&&!Array.isArray(this._value)&&(this._value=this._value?[this._value]:[]),!e&&Array.isArray(this._value)&&(this._value=this._value.length?this._value[0]:null)}_init(e){if(r)return;if(this.hydrationRequired){this.hydrationComplete.then(()=>this._init());return}e&&this._assignActiveDate(e);let t=this._fixedMonth??this._activeDate,n=this.amount<1?1:this.amount;this._weeks=Array.from({length:n},(e,n)=>this._createWeekRows(this._dateAdapter.addCalendarMonths(t,n)));let i=this._weeks[0][0][0].dateValue;this._firstVisibleDay=this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(i),this._dateAdapter.getMonth(i),1));let a=this._weeks[n-1][0][0].dateValue;this._lastVisibleDay=this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(a),this._dateAdapter.getMonth(a),this._dateAdapter.getNumDaysInMonth(a))),this._years=this._createYearRows(),this._weekNumbers=this._weeks.map(e=>e.flat().sort((e,t)=>e.value.localeCompare(t.value)).map(e=>e.weekValue).filter((e,t,n)=>n.indexOf(e)===t)),this._initialized=!0}_focusCell(){this._resetFocus&&=(this._getFirstFocusable()?.focus(),!1)}_setWeekdays(){let e=this._dateAdapter.getDayOfWeekNames(`narrow`),t=this._dateAdapter.getDayOfWeekNames(`long`).map((t,n)=>({long:t,narrow:e[n]})),n=this._dateAdapter.getFirstDayOfWeek();this._weekdays=t.slice(n).concat(t.slice(0,n))}_createWeekRows(e){let t=this._dateAdapter.getNumDaysInMonth(e),n=this._dateAdapter.getFirstWeekOffset(e);return this.orientation===`horizontal`?this._createWeekRowsHorizontal(e,t,n):this._createWeekRowsVertical(e,t,n)}_createWeekRowsHorizontal(e,t,n){let r=[[]];for(let i=0,a=n;i<t;i++,a++){a===7&&(r.push([]),a=0);let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),i+1);r[r.length-1].push(this._mapDateToDay(t))}return r}_createWeekRowsVertical(e,t,n){let r=Array.from({length:7},()=>[]);for(let i=0,a=n;i<t;i++,a++){a===7&&(a=0);let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),i+1);r[a].push(this._mapDateToDay(t))}return r}_mapDateToDay(e){return{value:this._dateAdapter.toIso8601(e),dateValue:e,dayValue:String(this._dateAdapter.getDate(e)),monthValue:String(this._dateAdapter.getMonth(e)),yearValue:String(this._dateAdapter.getYear(e)),weekValue:this._getWeek(e),weekDayValue:this._dateAdapter.getDayOfWeek(e)}}_getWeek(e){let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),1,1),n=this._dateAdapter.getDayOfWeek(t),r=+!![c,re,ie,ne].includes(n),i=this._dateAdapter.addCalendarDays(t,this._dateAdapter.getFirstWeekOffset(t)*-1);for(;this._dateAdapter.compareDate(i,e)<=0;){let n=this._dateAdapter.addCalendarDays(i,6);if(this._dateAdapter.compareDate(e,n)<=0)return r>0?r:this._getWeek(this._dateAdapter.addCalendarDays(t,-1));i=this._dateAdapter.addCalendarDays(i,7),r++}throw Error(`The provided date is invalid`)}_mapValueToISODate(e){return typeof e==`string`?e:this._dateAdapter.toIso8601(e)}_createMonthRows(){let e=Array(12).fill(null).map((e,t)=>({value:String(t+1).padStart(2,`0`),monthValue:t+1})),t=[];for(let n=0;n<3;n++)t.push(e.slice(4*n,4*(n+1)));this._months=t}_createYearRows(){let e=this._getStartValueYearView(),t=Array(24).fill(0).map((t,n)=>e+n),n=[];for(let e=0;e<6;e++)n.push(t.slice(4*e,4*(e+1)));return n}_getStartValueYearView(){let e=0;this.max?e=this._dateAdapter.getYear(this.max)-24+1:this.min&&(e=this._dateAdapter.getYear(this.min));let t=this._dateAdapter.getYear(this._activeDate);return t-((t-e)%24+24)%24}_isDayInRange(e){if(!this.min&&!this.max)return!0;let t=this._dateAdapter.deserialize(e);return this._dateAdapter.sameDate(t,this._dateAdapter.clampDate(t,this.min,this.max))}_selectDate(e,t){if(this._chosenMonth=void 0,this._setChosenYear(),this.multiple){window.getSelection()?.removeAllRanges();let n=this._value?Array.isArray(this._value)?this._value:[this._value]:[],r=n.map(e=>this._dateAdapter.toIso8601(e));if(t.shiftKey&&this._lastSelection&&r.includes(this._dateAdapter.toIso8601(this._lastSelection))&&!r.includes(this._dateAdapter.toIso8601(e))){let t=this._dateAdapter.compareDate(this._lastSelection,e)<0?1:-1,i=[],a=this._lastSelection;for(;!this._dateAdapter.sameDate(a,e);){a=this._dateAdapter.addCalendarDays(a,t);let e=this._dateAdapter.toIso8601(a);r.includes(e)||i.push(e)}n=this._mergeDates(i,r)}else n=n.some(t=>this._dateAdapter.sameDate(t,e))?n.filter(t=>!this._dateAdapter.sameDate(t,e)):[...n,e].sort(this._sortDate);this._lastSelection=e,this._value=n,this._emitDateSelectedEvent(this._value.map(e=>this._dateAdapter.deserialize(e)))}else(!this._value||this._dateAdapter.compareDate(this._value,e)!==0)&&(this._value=e,this._emitDateSelectedEvent(this._dateAdapter.deserialize(e)))}_selectMultipleDates(e){this._value=this._mergeDates(e.map(e=>e.value)),this._emitDateSelectedEvent(this._value.map(e=>this._dateAdapter.deserialize(e)))}_mergeDates(e,t){t??=this._value.map(e=>this._dateAdapter.toIso8601(e));let n=this._cells.filter(e=>!e.disabled).map(e=>this._mapValueToISODate(e.value)),r=e.filter(e=>n.includes(e));return t=r.every(e=>t.includes(e))?t.filter(e=>!r.includes(e)):[...t,...r].filter((e,t,n)=>n.indexOf(e)===t),t.map(e=>this._dateAdapter.deserialize(e)).sort(this._sortDate)}_emitDateSelectedEvent(e){this.dispatchEvent(new ye(e)),this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_emitMonthChange(){let e=this.visibleDays();this.dispatchEvent(new D(e))}_setChosenYear(){if(this.view===`month`){let e;e=this.multiple?this.value.at(-1):this.value,this._chosenYear=this._dateAdapter.getYear(e??this._dateAdapter.today())}else this._chosenYear=void 0}_assignActiveDate(e){this._activeDate=this._dateAdapter.clampDate(e,this.min,this.max)}_goToDifferentMonth(e){this._init(this._dateAdapter.addCalendarMonths(this._activeDate,e)),this._emitMonthChange()}_goToDifferentYear(e){this._chosenYear+=e,this._activeDate=this._dateAdapter.createDate(this._chosenYear,this._dateAdapter.getMonth(this._activeDate),this._dateAdapter.getDate(this._activeDate)),this._init()}_goToDifferentYearRange(e){this._init(this._dateAdapter.addCalendarYears(this._activeDate,e))}_prevDisabled(e){return this.min?this._dateAdapter.compareDate(e,this.min)<0:!1}_nextDisabled(e){return this.max?this._dateAdapter.compareDate(e,this.max)>0:!1}_previousMonthDisabled(){let e=this._dateAdapter.addCalendarDays(this._activeDate,this._dateAdapter.getDate(this._activeDate)*-1);return this._prevDisabled(e)}_nextMonthDisabled(){let e=this._dateAdapter.addCalendarMonths(this._activeDate,this.amount<1?1:this.amount);return e=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),1),this._nextDisabled(e)}_previousYearDisabled(){let e=this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate)-1,12,31);return this._prevDisabled(e)}_nextYearDisabled(){let e=this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate)+(this.amount<1?1:this.amount),1,1);return this._nextDisabled(e)}_previousYearRangeDisabled(){let e=this._dateAdapter.createDate(this._years[0][0]-1,12,31);return this._prevDisabled(e)}_nextYearRangeDisabled(){let e=this._years.flat(2).at(-1),t=this._dateAdapter.createDate(e+1,1,1);return this._nextDisabled(t)}_handleTableBlur(e){e?.localName!==`sbb-calendar-day`&&this._setTabIndex()}_setTabIndex(){Array.from(this._cells.filter(e=>e.tabIndex===0)??[]).forEach(e=>e.tabIndex=-1);let e=this._getFirstFocusable();e&&(e.tabIndex=0)}_getFirstFocusable(){if(this._calendarView===`day`){let e=this._cells.find(e=>e.matches(`:is(:state(selected),[state--selected])`))??this._cells.find(e=>e.matches(`:is(:state(current),[state--current])`));return e&&!e.disabled?e:this._getFirstFocusableDay()}else{let e=this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(selected),[state--selected])`)??this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(current),[state--current])`);return e&&!e.disabled?e:this.shadowRoot.querySelector(`sbb-calendar-${this._calendarView}:not([disabled])`)}}_getFirstFocusableDay(){let e=this._cells,t=e.filter(e=>!e.disabled);if(!t||t.length===0)return null;{let n=t.map(e=>this._dateAdapter.toIso8601(e.value)).sort()[0];return e.find(e=>e.matches(`[slot="${n}"]`))??null}}_handleKeyboardEvent(e,t){me(e)&&e.preventDefault();let n=t??e.target,r=this._cells,i=r.indexOf(n),a;a=t?this._navigateByKeyboardDayView(e,i,r,this._mapDateToDay(t.value)):this._navigateByKeyboard(e,i,r);let o=(this._enhancedVariant?document:this.shadowRoot).activeElement;a!==o&&(a.tabIndex=0,a.focus(),r.includes(o)&&(o.tabIndex=-1))}_navigateByKeyboardDayView(e,t,n,r){let i=this.orientation===`horizontal`?{leftRight:1,upDown:7}:{leftRight:7,upDown:1};switch(e.key){case`ArrowUp`:return this._findDayArrows(n,t,r.dateValue,-i.upDown);case`ArrowDown`:return this._findDayArrows(n,t,r.dateValue,i.upDown);case`ArrowLeft`:return this._findDayArrows(n,t,r.dateValue,-i.leftRight);case`ArrowRight`:return this._findDayArrows(n,t,r.dateValue,i.leftRight);case`PageUp`:if(this.orientation===`horizontal`){let e=(r.dayValue%7||7)-r.dayValue;return this._findDayPageUpDown(n,t,r,e,i.upDown)}else{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue),a=(Math.ceil((+r.dayValue+e)/7)-1)*7-e+1-r.dayValue;return this._findDayPageUpDown(n,t,r,a,i.upDown)}case`PageDown`:if(this.orientation===`horizontal`){let e=+r.monthValue+1>12?1:+r.monthValue+1,a=+r.monthValue+1>12?+r.yearValue+1:+r.yearValue,o=this._dateAdapter.createDate(a,e,1),s=this._dateAdapter.getDate(this._dateAdapter.addCalendarDays(o,-1)),c=Math.trunc((s-+r.dayValue)/7)*7;return this._findDayPageUpDown(n,t,r,c,-i.upDown)}else{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue),a=Math.ceil((+r.dayValue+e)/7)*7-e-r.dayValue;return this._findDayPageUpDown(n,t,r,a,-i.upDown)}case`Home`:return this._findDayFirst(n,t,r,1);case`End`:{let e=+r.monthValue+1>12?1:+r.monthValue+1,i=+r.monthValue+1>12?+r.yearValue+1:+r.yearValue,a=this._dateAdapter.createDate(i,e,1);return this._findDayLast(n,t,a)}default:return n[t]}}_isDayOutOfView(e){return e<this._firstVisibleDay||e>this._lastVisibleDay}_findDayArrows(e,t,n,r){let i=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n,r));if(this._isDayOutOfView(i))return e[t];let a=e.find(e=>this._mapValueToISODate(e.value)===i);return!a||a.disabled?this._findDayArrows(e,t,this._dateAdapter.deserialize(i),r):a}_findDayPageUpDown(e,t,n,r,i){let a=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n.dateValue,r));if(this._isDayOutOfView(a))return e[t];let o=e.find(e=>this._mapValueToISODate(e.value)===a);return!o||o.disabled?this._findDayPageUpDown(e,t,n,r+i,i):o}_findDayFirst(e,t,n,r){let i=this._dateAdapter.toIso8601(this._dateAdapter.createDate(+n.yearValue,+n.monthValue,r));if(this._isDayOutOfView(i))return e[t];let a=e.find(e=>this._mapValueToISODate(e.value)===i);return!a||a.disabled?this._findDayFirst(e,t,n,r+1):a}_findDayLast(e,t,n){let r=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n,-1));if(this._isDayOutOfView(r))return e[t];let i=e.find(e=>this._mapValueToISODate(e.value)===r);return!i||i.disabled?this._findDayLast(e,t,this._dateAdapter.deserialize(r)):i}_navigateByKeyboard(e,t,n){let{elementIndexForWideMode:r,offsetForWideMode:i,lastElementIndexForWideMode:a,verticalOffset:o}=this._calculateParametersForKeyboardNavigation(t,this._calendarView===`year`);switch(e.key){case`ArrowUp`:return this._findNext(n,t,-o);case`ArrowDown`:return this._findNext(n,t,o);case`ArrowLeft`:return this._findNext(n,t,-1);case`ArrowRight`:return this._findNext(n,t,1);case`Home`:return this._findFirst(n,i);case`PageUp`:return this._findFirstOnColumn(n,r,i,o);case`PageDown`:return this._findLastOnColumn(n,t,a,o);case`End`:return this._findLast(n,a-1);default:return n[t]}}_calculateParametersForKeyboardNavigation(e,t){let n=t?24:12,r=Math.trunc(e/n)*n,i=r===0?e:e-n;return{verticalOffset:4,elementIndexForWideMode:i,offsetForWideMode:e-i,lastElementIndexForWideMode:r===0?n:n*2}}_findNext(e,t,n){let r=t+n;for(;r<e.length&&e[r]?.disabled;)r+=n;return e[r]??e[t]}_findFirst(e,t){return e[t].disabled?this._findNext(e,t,1):e[t]}_findLast(e,t){return e[t].disabled?this._findNext(e,t,-1):e[t]}_findFirstOnColumn(e,t,n,r){let i=t%r+n;return e[i].disabled?this._findNext(e,i,r):e[i]}_findLastOnColumn(e,t,n,r){let i=t+Math.trunc((n-t-1)/r)*r;return e[i].disabled?this._findNext(e,i,-r):e[i]}_resetCalendarViewAndEmitMonthChange(){this._resetCalendarView(),this._emitMonthChange()}_resetCalendarView(){this._containingFocus&&(this._resetFocus=!0),this._activeDate=(this.multiple?this._value.at(-1):this._value)??this._dateAdapter.today(),this._setChosenYear(),this._chosenMonth=void 0,this._init(),this._calendarView=this.view}_createDayTable(e,t,r){let a=e[0][0].dateValue,o=`${this._monthNames[this._dateAdapter.getMonth(a)-1]} ${this._dateAdapter.getYear(a)}`,s=e.flat(),c=e.flat();return n`
9
+ `,D=class extends Event{get range(){return this._range}constructor(e){super(`monthchange`,{bubbles:!0,composed:!0}),this._range=Object.freeze(e||[])}},ye=class extends Event{get dateSelected(){return this._dateSelected}constructor(e){super(`dateselected`,{bubbles:!0,composed:!0}),this._dateSelected=Object.freeze(e)}};let O=(()=>{let l=te(ee),u=[],f,y=[],b=[],x,O=[],k=[],A,j=[],M=[],N,P=[],F=[],I,L=[],R=[],z,B,V=[],H=[],U,W=[],G=[],K,q,J=[],Y=[],X,Z=[],be=[],xe,Q=[],Se=[],Ce,we=[],Te=[],Ee,De=[],$=[];return class extends l{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(l[Symbol.metadata]??null):void 0;f=[m(),o({type:Number})],x=[o()],A=[_(),o()],N=[_(),o()],I=[m(),oe((e,t)=>e._onMultipleChanged(t)),o({type:Boolean})],z=[o()],B=[s()],U=[o({attribute:`date-filter`})],K=[m(),o({attribute:`fixed-month`})],q=[o({reflect:!0})],X=[m(),o({attribute:`week-numbers`,type:Boolean})],xe=[s()],Ce=[s()],Ee=[s()],e(this,null,f,{kind:`accessor`,name:`amount`,static:!1,private:!1,access:{has:e=>`amount`in e,get:e=>e.amount,set:(e,t)=>{e.amount=t}},metadata:t},y,b),e(this,null,x,{kind:`accessor`,name:`view`,static:!1,private:!1,access:{has:e=>`view`in e,get:e=>e.view,set:(e,t)=>{e.view=t}},metadata:t},O,k),e(this,null,A,{kind:`accessor`,name:`min`,static:!1,private:!1,access:{has:e=>`min`in e,get:e=>e.min,set:(e,t)=>{e.min=t}},metadata:t},j,M),e(this,null,N,{kind:`accessor`,name:`max`,static:!1,private:!1,access:{has:e=>`max`in e,get:e=>e.max,set:(e,t)=>{e.max=t}},metadata:t},P,F),e(this,null,I,{kind:`accessor`,name:`multiple`,static:!1,private:!1,access:{has:e=>`multiple`in e,get:e=>e.multiple,set:(e,t)=>{e.multiple=t}},metadata:t},L,R),e(this,null,z,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,u),e(this,null,B,{kind:`accessor`,name:`_value`,static:!1,private:!1,access:{has:e=>`_value`in e,get:e=>e._value,set:(e,t)=>{e._value=t}},metadata:t},V,H),e(this,null,U,{kind:`accessor`,name:`dateFilter`,static:!1,private:!1,access:{has:e=>`dateFilter`in e,get:e=>e.dateFilter,set:(e,t)=>{e.dateFilter=t}},metadata:t},W,G),e(this,null,K,{kind:`setter`,name:`fixedMonth`,static:!1,private:!1,access:{has:e=>`fixedMonth`in e,set:(e,t)=>{e.fixedMonth=t}},metadata:t},null,u),e(this,null,q,{kind:`accessor`,name:`orientation`,static:!1,private:!1,access:{has:e=>`orientation`in e,get:e=>e.orientation,set:(e,t)=>{e.orientation=t}},metadata:t},J,Y),e(this,null,X,{kind:`accessor`,name:`weekNumbers`,static:!1,private:!1,access:{has:e=>`weekNumbers`in e,get:e=>e.weekNumbers,set:(e,t)=>{e.weekNumbers=t}},metadata:t},Z,be),e(this,null,xe,{kind:`accessor`,name:`_activeDate`,static:!1,private:!1,access:{has:e=>`_activeDate`in e,get:e=>e._activeDate,set:(e,t)=>{e._activeDate=t}},metadata:t},Q,Se),e(this,null,Ce,{kind:`accessor`,name:`_calendarView`,static:!1,private:!1,access:{has:e=>`_calendarView`in e,get:e=>e._calendarView,set:(e,t)=>{e._calendarView=t}},metadata:t},we,Te),e(this,null,Ee,{kind:`accessor`,name:`_initialized`,static:!1,private:!1,access:{has:e=>`_initialized`in e,get:e=>e._initialized,set:(e,t)=>{e._initialized=t}},metadata:t},De,$),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar`}static{this.elementDependencies=[S,C,T,E,w,_e,ge]}static{this.styles=[ae,he,a(ve)]}static{this.events={dateselected:`dateselected`,monthchange:`monthchange`}}#e;get amount(){return this.#e}set amount(e){this.#e=e}#t;get view(){return this.#t}set view(e){this.#t=e}#n;get min(){return this.#n}set min(e){this.#n=e}#r;get max(){return this.#r}set max(e){this.#r=e}#i;get multiple(){return this.#i}set multiple(e){this.#i=e}set value(e){if(Array.isArray(e))this._value=e.map(e=>this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e))).filter(e=>e!==null).filter(e=>!this._isDayInRange(this._dateAdapter.toIso8601(e))||this._dateFilter(e)).sort(this._sortDate);else{let t=this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));this._value=t&&(!this._isDayInRange(this._dateAdapter.toIso8601(t))||this._dateFilter(t))?t:null}}get value(){return this._value}#a;get _value(){return this.#a}set _value(e){this.#a=e}#o;get dateFilter(){return this.#o}set dateFilter(e){this.#o=e}set fixedMonth(e){let t=e?e.match(/^(\d{4})-(\d{2})$/):null;this._fixedMonth=t?this._dateAdapter.createDate(Number(t[1]),Number(t[2]),1):null}get fixedMonth(){return this._fixedMonth?this._dateAdapter.toIso8601(this._fixedMonth).split(`-`).slice(0,2).join(`-`):``}#s;get orientation(){return this.#s}set orientation(e){this.#s=e}#c;get weekNumbers(){return this.#c}set weekNumbers(e){this.#c=e}#l;get _activeDate(){return this.#l}set _activeDate(e){this.#l=e}#u;get _calendarView(){return this.#u}set _calendarView(e){this.#u=e}get _cells(){return Array.from((this._calendarView===`day`?Array.from(this.shadowRoot.querySelectorAll(`slot`)).flatMap(e=>e.assignedElements({flatten:!0})):this.shadowRoot?.querySelectorAll(`sbb-calendar-${this._calendarView}`))??[])}#d;get _initialized(){return this.#d}set _initialized(e){this.#d=e}constructor(){super(),this.#e=(t(this,u),t(this,y,1)),this.#t=(t(this,b),t(this,O,`day`)),this.#n=(t(this,k),t(this,j,null)),this.#r=(t(this,M),t(this,P,null)),this.#i=(t(this,F),t(this,L,!1)),this.#a=(t(this,R),t(this,V,null)),this.#o=(t(this,H),t(this,W,null)),this._fixedMonth=(t(this,G),null),this.#s=t(this,J,`horizontal`),this.#c=(t(this,Y),t(this,Z,!1)),this._dateAdapter=(t(this,be),v().datetime?.dateAdapter??p),this.#l=t(this,Q,this._dateAdapter.today()),this.#u=(t(this,Se),t(this,we,`day`)),this._weekdays=t(this,Te),this._weeks=[],this._firstVisibleDay=``,this._lastVisibleDay=``,this._monthNames=this._dateAdapter.getMonthNames(`long`),this._enhancedVariant=!1,this._resetFocus=!1,this._containingFocus=!1,this._lastSelection=null,this.#d=t(this,De,!1),this._language=(t(this,$),new d(this).withHandler(()=>{this._monthNames=this._dateAdapter.getMonthNames(`long`),this._createMonthRows()})),this._sortDate=(e,t)=>this._dateAdapter.compareDate(e,t),this._onSlotChange=()=>{this._enhancedVariant=Array.from(this.children).some(e=>e.localName===`sbb-calendar-day`),this.toggleState(`enhanced`,this._enhancedVariant),this._setTabIndex()},this._createMonthRows(),this._setWeekdays(),this.addEventListener(`focusin`,()=>this._containingFocus=!0),this.addEventListener(`focusout`,()=>this._containingFocus=!1);let e=e=>e.target.closest(`sbb-calendar-day`)??e.composedPath().find(e=>e.localName===`sbb-calendar-day`)??null;this.addEventListener(`click`,t=>{let n=e(t);n&&this._selectDate(n.value,t)}),this.addEventListener(`keydown`,t=>{let n=e(t);n&&this._handleKeyboardEvent(t,n)}),this.addEventListener(`blur`,()=>this._lastSelection=null)}_dateFilter(e){return this.dateFilter?.(e)??!0}resetPosition(){this._resetCalendarView(),this._init()}connectedCallback(){super.connectedCallback(),this.resetPosition(),this.shadowRoot?.addEventListener(`slotchange`,this._onSlotChange,{capture:!0})}disconnectedCallback(){super.disconnectedCallback(),this.shadowRoot?.removeEventListener(`slotchange`,this._onSlotChange,{capture:!0})}visibleDays(){return this._weeks.flat(2).sort((e,t)=>e.value.localeCompare(t.value))}formResetCallback(){}formStateRestoreCallback(e,t){if(t===`autocomplete`||e==null)return;let n=e=>this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));if(typeof e==`string`)this.value=n(e);else if(e instanceof FormData){if(this.multiple){this._readFormData(e).then(e=>this.value=e.map(n).filter(e=>e!=null));return}let t=e.get(this.name);t instanceof Blob?t.text().then(e=>this.value=n(JSON.parse(e))):this.value=n(t)}}async _readFormData(e){return Promise.all(e.getAll(this.name).map(async e=>e instanceof Blob?JSON.parse(await e.text()):e))}focus(){this._resetFocus=!0,this._focusCell()}willUpdate(e){super.willUpdate(e),this._initialized&&((e.has(`amount`)||e.has(`orientation`)||e.has(`fixedMonth`))&&this.resetPosition(),e.has(`view`)&&(this._setChosenYear(),this._chosenMonth=void 0,this._calendarView=this.view))}requestUpdate(e,t,n){super.requestUpdate(e,t,n),e===`_calendarView`&&(this.internals.states.delete(`view-${t}`),this.internals.states.add(`view-${this._calendarView}`),this._containingFocus&&(this._resetFocus=!0))}updated(e){super.updated(e),this._setTabIndex(),this._focusCell()}firstUpdated(e){super.firstUpdated(e),this._emitMonthChange()}_onMultipleChanged(e){e&&!Array.isArray(this._value)&&(this._value=this._value?[this._value]:[]),!e&&Array.isArray(this._value)&&(this._value=this._value.length?this._value[0]:null)}_init(e){if(r)return;if(this.hydrationRequired){this.hydrationComplete.then(()=>this._init());return}e&&this._assignActiveDate(e);let t=this._fixedMonth??this._activeDate,n=this.amount<1?1:this.amount;this._weeks=Array.from({length:n},(e,n)=>this._createWeekRows(this._dateAdapter.addCalendarMonths(t,n)));let i=this._weeks[0][0][0].dateValue;this._firstVisibleDay=this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(i),this._dateAdapter.getMonth(i),1));let a=this._weeks[n-1][0][0].dateValue;this._lastVisibleDay=this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(a),this._dateAdapter.getMonth(a),this._dateAdapter.getNumDaysInMonth(a))),this._years=this._createYearRows(),this._weekNumbers=this._weeks.map(e=>e.flat().sort((e,t)=>e.value.localeCompare(t.value)).map(e=>e.weekValue).filter((e,t,n)=>n.indexOf(e)===t)),this._initialized=!0}_focusCell(){this._resetFocus&&=(this._getFirstFocusable()?.focus(),!1)}_setWeekdays(){let e=this._dateAdapter.getDayOfWeekNames(`narrow`),t=this._dateAdapter.getDayOfWeekNames(`long`).map((t,n)=>({long:t,narrow:e[n]})),n=this._dateAdapter.getFirstDayOfWeek();this._weekdays=t.slice(n).concat(t.slice(0,n))}_createWeekRows(e){let t=this._dateAdapter.getNumDaysInMonth(e),n=this._dateAdapter.getFirstWeekOffset(e);return this.orientation===`horizontal`?this._createWeekRowsHorizontal(e,t,n):this._createWeekRowsVertical(e,t,n)}_createWeekRowsHorizontal(e,t,n){let r=[[]];for(let i=0,a=n;i<t;i++,a++){a===7&&(r.push([]),a=0);let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),i+1);r[r.length-1].push(this._mapDateToDay(t))}return r}_createWeekRowsVertical(e,t,n){let r=Array.from({length:7},()=>[]);for(let i=0,a=n;i<t;i++,a++){a===7&&(a=0);let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),i+1);r[a].push(this._mapDateToDay(t))}return r}_mapDateToDay(e){return{value:this._dateAdapter.toIso8601(e),dateValue:e,dayValue:String(this._dateAdapter.getDate(e)),monthValue:String(this._dateAdapter.getMonth(e)),yearValue:String(this._dateAdapter.getYear(e)),weekValue:this._getWeek(e),weekDayValue:this._dateAdapter.getDayOfWeek(e)}}_getWeek(e){let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),1,1),n=this._dateAdapter.getDayOfWeek(t),r=+!![c,re,ie,ne].includes(n),i=this._dateAdapter.addCalendarDays(t,this._dateAdapter.getFirstWeekOffset(t)*-1);for(;this._dateAdapter.compareDate(i,e)<=0;){let n=this._dateAdapter.addCalendarDays(i,6);if(this._dateAdapter.compareDate(e,n)<=0)return r>0?r:this._getWeek(this._dateAdapter.addCalendarDays(t,-1));i=this._dateAdapter.addCalendarDays(i,7),r++}throw Error(`The provided date is invalid`)}_mapValueToISODate(e){return typeof e==`string`?e:this._dateAdapter.toIso8601(e)}_createMonthRows(){let e=Array(12).fill(null).map((e,t)=>({value:String(t+1).padStart(2,`0`),monthValue:t+1})),t=[];for(let n=0;n<3;n++)t.push(e.slice(4*n,4*(n+1)));this._months=t}_createYearRows(){let e=this._getStartValueYearView(),t=Array(24).fill(0).map((t,n)=>e+n),n=[];for(let e=0;e<6;e++)n.push(t.slice(4*e,4*(e+1)));return n}_getStartValueYearView(){let e=0;this.max?e=this._dateAdapter.getYear(this.max)-24+1:this.min&&(e=this._dateAdapter.getYear(this.min));let t=this._dateAdapter.getYear(this._activeDate);return t-((t-e)%24+24)%24}_isDayInRange(e){if(!this.min&&!this.max)return!0;let t=this._dateAdapter.deserialize(e);return this._dateAdapter.sameDate(t,this._dateAdapter.clampDate(t,this.min,this.max))}_selectDate(e,t){if(this._chosenMonth=void 0,this._setChosenYear(),this.multiple){window.getSelection()?.removeAllRanges();let n=this._value?Array.isArray(this._value)?this._value:[this._value]:[],r=n.map(e=>this._dateAdapter.toIso8601(e));if(t.shiftKey&&this._lastSelection&&r.includes(this._dateAdapter.toIso8601(this._lastSelection))&&!r.includes(this._dateAdapter.toIso8601(e))){let t=this._dateAdapter.compareDate(this._lastSelection,e)<0?1:-1,i=[],a=this._lastSelection;for(;!this._dateAdapter.sameDate(a,e);){a=this._dateAdapter.addCalendarDays(a,t);let e=this._dateAdapter.toIso8601(a);r.includes(e)||i.push(e)}n=this._mergeDates(i,r)}else n=n.some(t=>this._dateAdapter.sameDate(t,e))?n.filter(t=>!this._dateAdapter.sameDate(t,e)):[...n,e].sort(this._sortDate);this._lastSelection=e,this._value=n,this._emitDateSelectedEvent(this._value.map(e=>this._dateAdapter.deserialize(e)))}else(!this._value||this._dateAdapter.compareDate(this._value,e)!==0)&&(this._value=e,this._emitDateSelectedEvent(this._dateAdapter.deserialize(e)))}_selectMultipleDates(e){this._value=this._mergeDates(e.map(e=>e.value)),this._emitDateSelectedEvent(this._value.map(e=>this._dateAdapter.deserialize(e)))}_mergeDates(e,t){t??=this._value.map(e=>this._dateAdapter.toIso8601(e));let n=this._cells.filter(e=>!e.disabled).map(e=>this._mapValueToISODate(e.value)),r=e.filter(e=>n.includes(e));return t=r.every(e=>t.includes(e))?t.filter(e=>!r.includes(e)):[...t,...r].filter((e,t,n)=>n.indexOf(e)===t),t.map(e=>this._dateAdapter.deserialize(e)).sort(this._sortDate)}_emitDateSelectedEvent(e){this.dispatchEvent(new ye(e)),this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_emitMonthChange(){let e=this.visibleDays();this.dispatchEvent(new D(e))}_setChosenYear(){if(this.view===`month`){let e;e=this.multiple?this.value.at(-1):this.value,this._chosenYear=this._dateAdapter.getYear(e??this._dateAdapter.today())}else this._chosenYear=void 0}_assignActiveDate(e){this._activeDate=this._dateAdapter.clampDate(e,this.min,this.max)}_goToDifferentMonth(e){this._init(this._dateAdapter.addCalendarMonths(this._activeDate,e)),this._emitMonthChange()}_goToDifferentYear(e){this._chosenYear+=e,this._activeDate=this._dateAdapter.createDate(this._chosenYear,this._dateAdapter.getMonth(this._activeDate),this._dateAdapter.getDate(this._activeDate)),this._init()}_goToDifferentYearRange(e){this._init(this._dateAdapter.addCalendarYears(this._activeDate,e))}_prevDisabled(e){return this.min?this._dateAdapter.compareDate(e,this.min)<0:!1}_nextDisabled(e){return this.max?this._dateAdapter.compareDate(e,this.max)>0:!1}_previousMonthDisabled(){let e=this._dateAdapter.addCalendarDays(this._activeDate,this._dateAdapter.getDate(this._activeDate)*-1);return this._prevDisabled(e)}_nextMonthDisabled(){let e=this._dateAdapter.addCalendarMonths(this._activeDate,this.amount<1?1:this.amount);return e=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),1),this._nextDisabled(e)}_previousYearDisabled(){let e=this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate)-1,12,31);return this._prevDisabled(e)}_nextYearDisabled(){let e=this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate)+(this.amount<1?1:this.amount),1,1);return this._nextDisabled(e)}_previousYearRangeDisabled(){let e=this._dateAdapter.createDate(this._years[0][0]-1,12,31);return this._prevDisabled(e)}_nextYearRangeDisabled(){let e=this._years.flat(2).at(-1),t=this._dateAdapter.createDate(e+1,1,1);return this._nextDisabled(t)}_handleTableBlur(e){e?.localName!==`sbb-calendar-day`&&this._setTabIndex()}_setTabIndex(){Array.from(this._cells.filter(e=>e.tabIndex===0)??[]).forEach(e=>e.tabIndex=-1);let e=this._getFirstFocusable();e&&(e.tabIndex=0)}_getFirstFocusable(){if(this._calendarView===`day`){let e=this._cells.find(e=>e.matches(`:is(:state(selected),[state--selected])`))??this._cells.find(e=>e.matches(`:is(:state(current),[state--current])`));return e&&!e.disabled?e:this._getFirstFocusableDay()}{let e=this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(selected),[state--selected])`)??this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(current),[state--current])`);return e&&!e.disabled?e:this.shadowRoot.querySelector(`sbb-calendar-${this._calendarView}:not([disabled])`)}}_getFirstFocusableDay(){let e=this._cells,t=e.filter(e=>!e.disabled);if(!t||t.length===0)return null;{let n=t.map(e=>this._dateAdapter.toIso8601(e.value)).sort()[0];return e.find(e=>e.matches(`[slot="${n}"]`))??null}}_handleKeyboardEvent(e,t){me(e)&&e.preventDefault();let n=t??e.target,r=this._cells,i=r.indexOf(n),a;a=t?this._navigateByKeyboardDayView(e,i,r,this._mapDateToDay(t.value)):this._navigateByKeyboard(e,i,r);let o=(this._enhancedVariant?document:this.shadowRoot).activeElement;a!==o&&(a.tabIndex=0,a.focus(),r.includes(o)&&(o.tabIndex=-1))}_navigateByKeyboardDayView(e,t,n,r){let i=this.orientation===`horizontal`?{leftRight:1,upDown:7}:{leftRight:7,upDown:1};switch(e.key){case`ArrowUp`:return this._findDayArrows(n,t,r.dateValue,-i.upDown);case`ArrowDown`:return this._findDayArrows(n,t,r.dateValue,i.upDown);case`ArrowLeft`:return this._findDayArrows(n,t,r.dateValue,-i.leftRight);case`ArrowRight`:return this._findDayArrows(n,t,r.dateValue,i.leftRight);case`PageUp`:if(this.orientation===`horizontal`){let e=(r.dayValue%7||7)-r.dayValue;return this._findDayPageUpDown(n,t,r,e,i.upDown)}{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue),a=(Math.ceil((+r.dayValue+e)/7)-1)*7-e+1-r.dayValue;return this._findDayPageUpDown(n,t,r,a,i.upDown)}case`PageDown`:if(this.orientation===`horizontal`){let e=+r.monthValue+1>12?1:+r.monthValue+1,a=+r.monthValue+1>12?+r.yearValue+1:+r.yearValue,o=this._dateAdapter.createDate(a,e,1),s=this._dateAdapter.getDate(this._dateAdapter.addCalendarDays(o,-1)),c=Math.trunc((s-+r.dayValue)/7)*7;return this._findDayPageUpDown(n,t,r,c,-i.upDown)}{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue),a=Math.ceil((+r.dayValue+e)/7)*7-e-r.dayValue;return this._findDayPageUpDown(n,t,r,a,-i.upDown)}case`Home`:return this._findDayFirst(n,t,r,1);case`End`:{let e=+r.monthValue+1>12?1:+r.monthValue+1,i=+r.monthValue+1>12?+r.yearValue+1:+r.yearValue,a=this._dateAdapter.createDate(i,e,1);return this._findDayLast(n,t,a)}default:return n[t]}}_isDayOutOfView(e){return e<this._firstVisibleDay||e>this._lastVisibleDay}_findDayArrows(e,t,n,r){let i=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n,r));if(this._isDayOutOfView(i))return e[t];let a=e.find(e=>this._mapValueToISODate(e.value)===i);return!a||a.disabled?this._findDayArrows(e,t,this._dateAdapter.deserialize(i),r):a}_findDayPageUpDown(e,t,n,r,i){let a=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n.dateValue,r));if(this._isDayOutOfView(a))return e[t];let o=e.find(e=>this._mapValueToISODate(e.value)===a);return!o||o.disabled?this._findDayPageUpDown(e,t,n,r+i,i):o}_findDayFirst(e,t,n,r){let i=this._dateAdapter.toIso8601(this._dateAdapter.createDate(+n.yearValue,+n.monthValue,r));if(this._isDayOutOfView(i))return e[t];let a=e.find(e=>this._mapValueToISODate(e.value)===i);return!a||a.disabled?this._findDayFirst(e,t,n,r+1):a}_findDayLast(e,t,n){let r=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n,-1));if(this._isDayOutOfView(r))return e[t];let i=e.find(e=>this._mapValueToISODate(e.value)===r);return!i||i.disabled?this._findDayLast(e,t,this._dateAdapter.deserialize(r)):i}_navigateByKeyboard(e,t,n){let{elementIndexForWideMode:r,offsetForWideMode:i,lastElementIndexForWideMode:a,verticalOffset:o}=this._calculateParametersForKeyboardNavigation(t,this._calendarView===`year`);switch(e.key){case`ArrowUp`:return this._findNext(n,t,-o);case`ArrowDown`:return this._findNext(n,t,o);case`ArrowLeft`:return this._findNext(n,t,-1);case`ArrowRight`:return this._findNext(n,t,1);case`Home`:return this._findFirst(n,i);case`PageUp`:return this._findFirstOnColumn(n,r,i,o);case`PageDown`:return this._findLastOnColumn(n,t,a,o);case`End`:return this._findLast(n,a-1);default:return n[t]}}_calculateParametersForKeyboardNavigation(e,t){let n=t?24:12,r=Math.trunc(e/n)*n,i=r===0?e:e-n;return{verticalOffset:4,elementIndexForWideMode:i,offsetForWideMode:e-i,lastElementIndexForWideMode:r===0?n:n*2}}_findNext(e,t,n){let r=t+n;for(;r<e.length&&e[r]?.disabled;)r+=n;return e[r]??e[t]}_findFirst(e,t){return e[t].disabled?this._findNext(e,t,1):e[t]}_findLast(e,t){return e[t].disabled?this._findNext(e,t,-1):e[t]}_findFirstOnColumn(e,t,n,r){let i=t%r+n;return e[i].disabled?this._findNext(e,i,r):e[i]}_findLastOnColumn(e,t,n,r){let i=t+Math.trunc((n-t-1)/r)*r;return e[i].disabled?this._findNext(e,i,-r):e[i]}_resetCalendarViewAndEmitMonthChange(){this._resetCalendarView(),this._emitMonthChange()}_resetCalendarView(){this._containingFocus&&(this._resetFocus=!0),this._activeDate=(this.multiple?this._value.at(-1):this._value)??this._dateAdapter.today(),this._setChosenYear(),this._chosenMonth=void 0,this._init(),this._calendarView=this.view}_createDayTable(e,t,r){let a=e[0][0].dateValue,o=`${this._monthNames[this._dateAdapter.getMonth(a)-1]} ${this._dateAdapter.getYear(a)}`,s=e.flat(),c=e.flat();return n`
10
10
  <div class="sbb-calendar__table-wrapper sbb-calendar__day-view">
11
11
  <div class="sbb-calendar__table-header">
12
12
  <span>${o}</span> ${r?this._createDayTableControls(o):i}
@@ -1 +1 @@
1
- import{SbbSelectionGroupBaseElement as e,getNextElementIndex as t,interactivityChecker as n,isArrowKeyPressed as r}from"./core.js";var i=class extends e{static{this.elementName=`sbb-checkbox-group`}get checkboxes(){return this.selectionElements}constructor(){super(),this.selectionElementSelectors=`sbb-checkbox, sbb-checkbox-panel`,this.panelElementSelector=`sbb-checkbox-panel`,this.addEventListener?.(`keydown`,e=>this._handleKeyDown(e))}_handleKeyDown(e){let i=this.checkboxes.filter(e=>!e.disabled&&n.isVisible(e));!i||e.target!==this&&e.target.parentElement!==this&&e.target.parentElement.localName!==`sbb-selection-expansion-panel`&&e.target.parentElement.localName!==`sbb-selection-action-panel`||r(e)&&i[t(e,i.findIndex(t=>t===e.target),i.length)]?.focus()}};export{i as SbbCheckboxGroupElement};
1
+ import{SbbSelectionGroupBaseElement as e,getNextElementIndex as t,interactivityChecker as n,isArrowKeyPressed as r}from"./core.js";var i=class extends e{static{this.elementName=`sbb-checkbox-group`}get checkboxes(){return this.selectionElements}constructor(){super(),this.selectionElementSelectors=`sbb-checkbox, sbb-checkbox-panel`,this.panelElementSelector=`sbb-checkbox-panel`,this.addEventListener?.(`keydown`,e=>this._handleKeyDown(e))}_handleKeyDown(e){let i=this.checkboxes.filter(e=>!e.disabled&&n.isVisible(e));if(!(!i||e.target!==this&&e.target.parentElement!==this&&e.target.parentElement.localName!==`sbb-selection-expansion-panel`&&e.target.parentElement.localName!==`sbb-selection-action-panel`)&&r(e)){let n=i.findIndex(t=>t===e.target);i[t(e,n,i.length)]?.focus()}}};export{i as SbbCheckboxGroupElement};
package/chip.pure.js CHANGED
@@ -14,4 +14,4 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
14
14
  </sbb-mini-button>
15
15
  <span class="sbb-screen-reader-only">, ${g[this._language.current]}</span>
16
16
  `}}})();var w=`:host{gap:var(--sbb-chip-group-gap);width:100%;margin-block:var(--sbb-chip-group-margin-block);line-height:var(--sbb-typo-line-height-text);flex-wrap:wrap;align-items:center;display:flex}:host(:is(:is(:state(size-s),[state--size-s]),:is(:state(empty),[state--empty]))){--sbb-chip-group-margin-block:0}:host(:is(:state(size-s),[state--size-s]):not(:is(:state(empty),[state--empty]))){--sbb-chip-group-margin-block:var(--_sbb-chip-group-margin-block-with-label-s)}:host(:is(:state(without-label),[state--without-label]):is(:state(size-s),[state--size-s]):not(:is(:state(empty),[state--empty]))){--sbb-chip-group-margin-block:var(--_sbb-chip-group-margin-block-without-label-s)}:host(:is(:is(:state(size-l),[state--size-l]),:is(:state(size-m),[state--size-m]))){--sbb-chip-group-margin-block:var(--_sbb-chip-group-margin-block-base-lm)}:host(:is(:state(without-label),[state--without-label]):is(:state(size-m),[state--size-m]):not(:is(:state(empty),[state--empty]))){--sbb-chip-group-margin-block:var(--_sbb-chip-group-margin-block-without-label-m)}:host(:is(:state(without-label),[state--without-label]):not(:is(:state(empty),[state--empty]),:is(:state(size-s),[state--size-s]),:is(:state(size-m),[state--size-m]),:is(:state(size-l),[state--size-l]))){--sbb-chip-group-margin-block:var(--sbb-chip-group-margin-block-no-label-not-empty)}:host(:not(:is(:state(without-label),[state--without-label])):is(:state(size-m),[state--size-m]):not(:is(:state(empty),[state--empty]))){--sbb-chip-group-margin-block:var(--_sbb-chip-group-margin-block-with-label-m)}:host(:not(:is(:state(without-label),[state--without-label]),:is(:state(empty),[state--empty]),:is(:state(size-s),[state--size-s]),:is(:state(size-m),[state--size-m]),:is(:state(size-l),[state--size-l]))){--sbb-chip-group-margin-block:var(--sbb-chip-group-margin-block-with-label-not-empty)}:host(:is(:state(without-label),[state--without-label]):is(:state(size-l),[state--size-l]):not(:is(:state(empty),[state--empty]))){--sbb-chip-group-margin-block:var(--_sbb-chip-group-margin-block-without-label-l)}:host(:not(:is(:state(without-label),[state--without-label])):is(:state(size-l),[state--size-l]):not(:is(:state(empty),[state--empty]))){--sbb-chip-group-margin-block:var(--_sbb-chip-group-margin-block-with-label-l)}::slotted(input){flex:1 1 var(--sbb-chip-group-input-min-width);max-height:1.5rem}::slotted(sbb-chip){max-width:100%}
17
- `,T=class extends Event{constructor(e){super(`chipinputtokenend`,{cancelable:!0,bubbles:!0,composed:!0}),this.origin=e.origin,this.value=e.value,this.label=e.label}setValue(e){this.value=e}setLabel(e){this.label=e}};let E=(()=>{let f=p(o(u(c(s)))),g=[],b,x,S=[],E=[],D,O=[],k=[],A,j=[],M=[];return class extends f{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(f[Symbol.metadata]??null):void 0;b=[a({type:Array})],x=[a({attribute:!1})],D=[a({attribute:`separator-keys`,type:Array})],A=[m(),a({attribute:`add-on-blur`,type:Boolean})],e(this,null,b,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,g),e(this,null,x,{kind:`accessor`,name:`displayWith`,static:!1,private:!1,access:{has:e=>`displayWith`in e,get:e=>e.displayWith,set:(e,t)=>{e.displayWith=t}},metadata:t},S,E),e(this,null,D,{kind:`accessor`,name:`separatorKeys`,static:!1,private:!1,access:{has:e=>`separatorKeys`in e,get:e=>e.separatorKeys,set:(e,t)=>{e.separatorKeys=t}},metadata:t},O,k),e(this,null,A,{kind:`accessor`,name:`addOnBlur`,static:!1,private:!1,access:{has:e=>`addOnBlur`in e,get:e=>e.addOnBlur,set:(e,t)=>{e.addOnBlur=t}},metadata:t},j,M),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-chip-group`}static{this.elementDependencies=[C]}static{this.role=`listbox`}static{this.styles=[i(w)]}static{this.events={input:`input`,change:`change`,chipinputtokenend:`chipinputtokenend`}}set value(e){e??=[];let t=this.value,n=[...t];for(let t of e)n.includes(t)&&n.splice(n.indexOf(t),1);n.forEach(e=>this._chipElements().find(t=>t.value===e)?.remove());let r=[...e];for(let e of t)r.includes(e)&&r.splice(r.indexOf(e),1);r.forEach(e=>this._createChipElement(e))}get value(){return this._chipElements().map(e=>e.value)}#e;get displayWith(){return this.#e}set displayWith(e){this.#e=e}#t;get separatorKeys(){return this.#t}set separatorKeys(e){this.#t=e}#n;get addOnBlur(){return this.#n}set addOnBlur(e){this.#n=e}constructor(){super(),this.#e=(t(this,g),t(this,S,null)),this.#t=(t(this,E),t(this,O,[`Enter`])),this.#n=(t(this,k),t(this,j,!1)),this._inputAttributeObserver=(t(this,M),r?null:new MutationObserver(()=>this._reactToInputChanges())),this._language=new l(this),this._previousSize=null,this.addEventListener?.(C.events.requestdelete,e=>this._deleteChip(e.target)),this.addEventListener?.(`keydown`,e=>this._onChipKeyDown(e)),this.addController(new d(this,()=>this.closest(`sbb-form-field`),{size:e=>this._updateSize(e.size),label:e=>this._updateLabelState(e),hiddenLabel:e=>this._updateLabelState(e)}))}_updateLabelState(e){this.toggleState(`without-label`,!e.label||e.hiddenLabel)}connectedCallback(){super.connectedCallback(),this._setupComponent()}willUpdate(e){super.willUpdate(e),(e.has(`disabled`)||e.has(`formDisabled`)||e.has(`negative`))&&this._proxyStateToChips()}formResetCallback(){this.value=null}formStateRestoreCallback(e,t){if(!e){this.value=null;return}this._readFormData(e).then(e=>this.value=e)}async _readFormData(e){return Promise.all(e.getAll(this.name).map(async e=>e instanceof Blob?JSON.parse(await e.text()):e))}shouldValidate(e){return super.shouldValidate(e)||e===`required`||e===`value`}validate(){super.validate(),this.required&&this.value.length===0?this.setValidityFlag(`valueMissing`,v[this._language.current]):this.removeValidityFlag(`valueMissing`)}_chipElements(){return Array.from(this.querySelectorAll?.(`sbb-chip`)??[])}_enabledChipElements(){return Array.from(this.querySelectorAll?.(`sbb-chip:not([disabled])`)??[])}_setupComponent(){let e=this.querySelector(`input`);e&&e!==this._inputElement&&(this._inputAbortController?.abort(),this._inputAttributeObserver?.disconnect(),this._inputElement=e,this._inputAbortController=new AbortController,this._inputElement.addEventListener(`keydown`,e=>this._onInputKeyDown(e),{signal:this._inputAbortController.signal}),this._inputElement.addEventListener(`blur`,()=>this._onInputBlur(),{signal:this._inputAbortController.signal,capture:!0}),this._inputElement.addEventListener(`inputAutocomplete`,e=>this._createChipFromInput(`autocomplete`,e.option.value),{signal:this._inputAbortController.signal}),this._inputAttributeObserver?.observe(this._inputElement,{attributes:!0,attributeFilter:[`readonly`,`disabled`]})),this.closest(`sbb-form-field`)||this._updateSize(null),this.toggleState(`empty`,this.value.length===0),this._reactToInputChanges(),this._updateInputDescription(),this.updateFormValue()}_onChipKeyDown(e){let t=e.target;if(t.localName===`sbb-chip`){if(y(e)){let n=this._enabledChipElements();n[h(e,n.indexOf(t),n.length)].focus();return}switch(e.key){case`Backspace`:case`Delete`:!t.readOnly&&!t.disabled&&(e.preventDefault(),this._deleteChip(t));break}}}_onInputKeyDown(e){switch(e.key){case`Backspace`:case`ArrowLeft`:this._inputElement.value||this._focusChip();break;case`Enter`:e.preventDefault();break}this.separatorKeys.includes(e.key)&&(e.preventDefault(),this._createChipFromInput(`input`))}_onInputBlur(){this.addOnBlur&&this._createChipFromInput(`input`)}_createChipFromInput(e=`input`,t){let n=t??this._inputElement.value.trim();if(!n)return;let r=new T({origin:e,value:n,label:(t?this.displayWith?.(t):null)??void 0});this.dispatchEvent(r)&&(this._createChipElement(r.value,r.label),this._inputElement.value=``,this._emitInputEvents())}_deleteChip(e){let t=this._enabledChipElements();e.remove(),this._emitInputEvents(),this._focusChip(t.indexOf(e))}_focusChip(e){let t=this._enabledChipElements();if(e!==void 0&&t[e]){t[e].focus();return}if(t.length>0){t[t.length-1].focus();return}this._inputElement?.focus()}_emitInputEvents(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_createChipElement(e,t){if(r)return;let n=document.createElement(`sbb-chip`);n.value=e,n.innerText=t??(e?this.displayWith?.(e):null)??``,this.insertBefore(n,this._inputElement??this.querySelector(`input`))}_reactToInputChanges(){this.disabled=this._inputElement?.disabled??!1,this._proxyStateToChips()}_proxyStateToChips(){this._chipElements().forEach(e=>{e.disabled=this.disabled||this.formDisabled,e.readOnly=this._inputElement?.hasAttribute(`readonly`)??!1,e.negative=this.negative})}_updateSize(e){this._previousSize&&this.internals.states.delete(`size-${this._previousSize}`),this._previousSize=e,this._previousSize&&this.internals.states.add(`size-${this._previousSize}`)}_updateInputDescription(){this._inputElement&&this._inputElement.setAttribute(`aria-description`,`${_[this._language.current]} ${this.value.length}`)}render(){return n`<slot @slotchange=${this._setupComponent}></slot>`}}})();export{C as SbbChipElement,E as SbbChipGroupElement,T as SbbChipInputTokenEndEvent};
17
+ `,T=class extends Event{constructor(e){super(`chipinputtokenend`,{cancelable:!0,bubbles:!0,composed:!0}),this.origin=e.origin,this.value=e.value,this.label=e.label}setValue(e){this.value=e}setLabel(e){this.label=e}};let E=(()=>{let f=p(o(u(c(s)))),g=[],b,x,S=[],E=[],D,O=[],k=[],A,j=[],M=[];return class extends f{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(f[Symbol.metadata]??null):void 0;b=[a({type:Array})],x=[a({attribute:!1})],D=[a({attribute:`separator-keys`,type:Array})],A=[m(),a({attribute:`add-on-blur`,type:Boolean})],e(this,null,b,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,g),e(this,null,x,{kind:`accessor`,name:`displayWith`,static:!1,private:!1,access:{has:e=>`displayWith`in e,get:e=>e.displayWith,set:(e,t)=>{e.displayWith=t}},metadata:t},S,E),e(this,null,D,{kind:`accessor`,name:`separatorKeys`,static:!1,private:!1,access:{has:e=>`separatorKeys`in e,get:e=>e.separatorKeys,set:(e,t)=>{e.separatorKeys=t}},metadata:t},O,k),e(this,null,A,{kind:`accessor`,name:`addOnBlur`,static:!1,private:!1,access:{has:e=>`addOnBlur`in e,get:e=>e.addOnBlur,set:(e,t)=>{e.addOnBlur=t}},metadata:t},j,M),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-chip-group`}static{this.elementDependencies=[C]}static{this.role=`listbox`}static{this.styles=[i(w)]}static{this.events={input:`input`,change:`change`,chipinputtokenend:`chipinputtokenend`}}set value(e){e??=[];let t=this.value,n=[...t];for(let t of e)n.includes(t)&&n.splice(n.indexOf(t),1);n.forEach(e=>this._chipElements().find(t=>t.value===e)?.remove());let r=[...e];for(let e of t)r.includes(e)&&r.splice(r.indexOf(e),1);r.forEach(e=>this._createChipElement(e))}get value(){return this._chipElements().map(e=>e.value)}#e;get displayWith(){return this.#e}set displayWith(e){this.#e=e}#t;get separatorKeys(){return this.#t}set separatorKeys(e){this.#t=e}#n;get addOnBlur(){return this.#n}set addOnBlur(e){this.#n=e}constructor(){super(),this.#e=(t(this,g),t(this,S,null)),this.#t=(t(this,E),t(this,O,[`Enter`])),this.#n=(t(this,k),t(this,j,!1)),this._inputAttributeObserver=(t(this,M),r?null:new MutationObserver(()=>this._reactToInputChanges())),this._language=new l(this),this._previousSize=null,this.addEventListener?.(C.events.requestdelete,e=>this._deleteChip(e.target)),this.addEventListener?.(`keydown`,e=>this._onChipKeyDown(e)),this.addController(new d(this,()=>this.closest(`sbb-form-field`),{size:e=>this._updateSize(e.size),label:e=>this._updateLabelState(e),hiddenLabel:e=>this._updateLabelState(e)}))}_updateLabelState(e){this.toggleState(`without-label`,!e.label||e.hiddenLabel)}connectedCallback(){super.connectedCallback(),this._setupComponent()}willUpdate(e){super.willUpdate(e),(e.has(`disabled`)||e.has(`formDisabled`)||e.has(`negative`))&&this._proxyStateToChips()}formResetCallback(){this.value=null}formStateRestoreCallback(e,t){if(!e){this.value=null;return}this._readFormData(e).then(e=>this.value=e)}async _readFormData(e){return Promise.all(e.getAll(this.name).map(async e=>e instanceof Blob?JSON.parse(await e.text()):e))}shouldValidate(e){return super.shouldValidate(e)||e===`required`||e===`value`}validate(){super.validate(),this.required&&this.value.length===0?this.setValidityFlag(`valueMissing`,v[this._language.current]):this.removeValidityFlag(`valueMissing`)}_chipElements(){return Array.from(this.querySelectorAll?.(`sbb-chip`)??[])}_enabledChipElements(){return Array.from(this.querySelectorAll?.(`sbb-chip:not([disabled])`)??[])}_setupComponent(){let e=this.querySelector(`input`);e&&e!==this._inputElement&&(this._inputAbortController?.abort(),this._inputAttributeObserver?.disconnect(),this._inputElement=e,this._inputAbortController=new AbortController,this._inputElement.addEventListener(`keydown`,e=>this._onInputKeyDown(e),{signal:this._inputAbortController.signal}),this._inputElement.addEventListener(`blur`,()=>this._onInputBlur(),{signal:this._inputAbortController.signal,capture:!0}),this._inputElement.addEventListener(`inputAutocomplete`,e=>this._createChipFromInput(`autocomplete`,e.option.value),{signal:this._inputAbortController.signal}),this._inputAttributeObserver?.observe(this._inputElement,{attributes:!0,attributeFilter:[`readonly`,`disabled`]})),this.closest(`sbb-form-field`)||this._updateSize(null),this.toggleState(`empty`,this.value.length===0),this._reactToInputChanges(),this._updateInputDescription(),this.updateFormValue()}_onChipKeyDown(e){let t=e.target;if(t.localName===`sbb-chip`){if(y(e)){let n=this._enabledChipElements();n[h(e,n.indexOf(t),n.length)].focus();return}switch(e.key){case`Backspace`:case`Delete`:!t.readOnly&&!t.disabled&&(e.preventDefault(),this._deleteChip(t))}}}_onInputKeyDown(e){switch(e.key){case`Backspace`:case`ArrowLeft`:this._inputElement.value||this._focusChip();break;case`Enter`:e.preventDefault()}this.separatorKeys.includes(e.key)&&(e.preventDefault(),this._createChipFromInput(`input`))}_onInputBlur(){this.addOnBlur&&this._createChipFromInput(`input`)}_createChipFromInput(e=`input`,t){let n=t??this._inputElement.value.trim();if(!n)return;let r=new T({origin:e,value:n,label:(t?this.displayWith?.(t):null)??void 0});this.dispatchEvent(r)&&(this._createChipElement(r.value,r.label),this._inputElement.value=``,this._emitInputEvents())}_deleteChip(e){let t=this._enabledChipElements();e.remove(),this._emitInputEvents(),this._focusChip(t.indexOf(e))}_focusChip(e){let t=this._enabledChipElements();if(e!==void 0&&t[e]){t[e].focus();return}if(t.length>0){t[t.length-1].focus();return}this._inputElement?.focus()}_emitInputEvents(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_createChipElement(e,t){if(r)return;let n=document.createElement(`sbb-chip`);n.value=e,n.innerText=t??(e?this.displayWith?.(e):null)??``,this.insertBefore(n,this._inputElement??this.querySelector(`input`))}_reactToInputChanges(){this.disabled=this._inputElement?.disabled??!1,this._proxyStateToChips()}_proxyStateToChips(){this._chipElements().forEach(e=>{e.disabled=this.disabled||this.formDisabled,e.readOnly=this._inputElement?.hasAttribute(`readonly`)??!1,e.negative=this.negative})}_updateSize(e){this._previousSize&&this.internals.states.delete(`size-${this._previousSize}`),this._previousSize=e,this._previousSize&&this.internals.states.add(`size-${this._previousSize}`)}_updateInputDescription(){this._inputElement&&this._inputElement.setAttribute(`aria-description`,`${_[this._language.current]} ${this.value.length}`)}render(){return n`<slot @slotchange=${this._setupComponent}></slot>`}}})();export{C as SbbChipElement,E as SbbChipGroupElement,T as SbbChipInputTokenEndEvent};
package/clock.pure.js CHANGED
@@ -3,7 +3,7 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
3
3
  `,u=`<svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 105 105"><path d="M55.1,64.5h-5.2l0.8-58h3.6L55.1,64.5z"/></svg>
4
4
  `,d=`<svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 105 105"><path d="M57.8,21.3c0-2.9-2.4-5.2-5.2-5.2s-5.3,2.3-5.3,5.2c0,2.7,2,4.8,4.5,5.2V69h1.5V26.5C55.8,26.2,57.8,24,57.8,21.3z"/></svg>
5
5
  `,f=`:host{aspect-ratio:1;contain:content;display:block;position:relative;overflow:hidden}.sbb-clock__face,.sbb-clock__hand-hours,.sbb-clock__hand-minutes,.sbb-clock__hand-seconds{transform-origin:50%;transform-style:preserve-3d;backface-visibility:hidden;position:absolute;inset:0;transform:rotate(0)}.sbb-clock__hand-hours,.sbb-clock__hand-minutes,.sbb-clock__face{fill:var(--sbb-clock-face-color)}.sbb-clock__hand-minutes{transition:transform var(--sbb-disable-animation-duration,.2s) cubic-bezier(.4, 2.08, .55, .44)}@supports not (aspect-ratio:1/1){.sbb-clock__hand-minutes{transform-origin:50% 49.625%}}.sbb-clock__hand-hours{animation-name:rotate;animation-duration:43200s;animation-timing-function:linear;animation-iteration-count:infinite;animation-play-state:var(--sbb-clock-animation-play-state,"paused")}.sbb-clock__hand-hours--initial-hour{animation-name:hand-hours-animation-initial-hour;animation-duration:var(--sbb-clock-hours-animation-duration,0s);animation-play-state:var(--sbb-clock-animation-play-state,"paused");animation-iteration-count:1}.sbb-clock__hand-minutes--no-transition{transition:none}.sbb-clock__hand-seconds{animation-name:hand-seconds-animation;animation-duration:60s;animation-timing-function:linear;animation-play-state:var(--sbb-clock-animation-play-state,"paused");fill:var(--sbb-clock-seconds-hand-color);animation-iteration-count:infinite}.sbb-clock__hand-seconds--initial-minute{animation-name:hand-seconds-animation-initial-minute;animation-duration:var(--sbb-clock-seconds-animation-duration,0s);animation-play-state:var(--sbb-clock-animation-play-state,"paused");animation-iteration-count:1}:host(:not(:is(:state(initialized),[state--initialized]))) :is(.sbb-clock__hand-hours,.sbb-clock__hand-minutes,.sbb-clock__hand-seconds){display:none}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes hand-hours-animation-initial-hour{0%{transform:rotateZ(var(--sbb-clock-hours-animation-start-angle,0deg))}to{transform:rotate(360deg)}}@keyframes hand-seconds-animation{0%{transform:rotate(0)}97.5%,to{transform:rotate(360deg)}}@keyframes hand-seconds-animation-initial-minute{0%{transform:rotateZ(var(--sbb-clock-seconds-animation-start-angle,0deg))}97.5%,to{transform:rotate(360deg)}}
6
- `;const p={once:!0,passive:!0};let m=(()=>{let m=s,h,g=[],_=[];return class extends m{constructor(){super(...arguments),this.#e=t(this,g,null),this._state=(t(this,_),`paused`),this._moveHoursHandFn=()=>this._moveHoursHand(),this._moveMinutesHandFn=()=>this._moveMinutesHand(),this._handlePageVisibilityChange=()=>{this.now||(document.visibilityState===`hidden`?this._stopClock():this._startClock())}}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(m[Symbol.metadata]??null):void 0;h=[a()],e(this,null,h,{kind:`accessor`,name:`now`,static:!1,private:!1,access:{has:e=>`now`in e,get:e=>e.now,set:(e,t)=>{e.now=t}},metadata:t},g,_),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-clock`}static{this.styles=[i(f)]}#e;get now(){return this.#e}set now(e){this.#e=e}connectedCallback(){super.connectedCallback(),this._resetIntervalId=setInterval(()=>this._resetClock(),1800*1e3)}willUpdate(e){super.willUpdate(e),!(r||!this.hasUpdated)&&e.has(`now`)&&this._startOrConfigureClock()}firstUpdated(e){super.firstUpdated(e),r||(document.addEventListener(`visibilitychange`,this._handlePageVisibilityChange,!1),this._startOrConfigureClock())}disconnectedCallback(){super.disconnectedCallback(),this._removeEventListeners(),clearInterval(this._resetIntervalId)}_startOrConfigureClock(){this.now?(this._stopClock(),this._resetSecondsHandAnimation(),this._setHandsStartingPosition()):this._startClock()}_startClock(){this._clockHandHours?.addEventListener(`animationend`,this._moveHoursHandFn,p),this._clockHandSeconds?.addEventListener(`animationend`,this._moveMinutesHandFn,p),this._setHandsStartingPosition(),this.style?.setProperty(`--sbb-clock-animation-play-state`,`running`),this._state=`running`}_stopClock(){clearInterval(this._handMovement),this._removeSecondsAnimationStyles(),this._removeHoursAnimationStyles(),this._clockHandHours?.removeEventListener(`animationend`,this._moveHoursHandFn),this._clockHandSeconds?.removeEventListener(`animationend`,this._moveMinutesHandFn),this._clockHandMinutes?.classList.add(`sbb-clock__hand-minutes--no-transition`),this.style?.setProperty(`--sbb-clock-animation-play-state`,`paused`),this._state=`paused`}async _resetClock(){this._state===`running`&&(this._stopClock(),setTimeout(()=>this._startClock(),50))}_setHandsStartingPosition(){this._assignCurrentTime();let e=60-this._seconds,t=60-this._minutes,n=12-this._hours,r=0,i=0;e>0&&(r+=e,i=1),t>0&&(r+=(t-i)*60,i=1),n>0&&(r+=(n-i)*3600),this.style?.setProperty(`--sbb-clock-hours-animation-start-angle`,`${Math.ceil(this._hours*30+this._minutes/2)}deg`),this.style?.setProperty(`--sbb-clock-hours-animation-duration`,`${r}s`),this.style?.setProperty(`--sbb-clock-seconds-animation-start-angle`,`${Math.ceil(this._seconds*6.153846153846154)}deg`),this.style?.setProperty(`--sbb-clock-seconds-animation-duration`,`${e}s`),this._setMinutesHand(),this._clockHandSeconds?.classList.add(`sbb-clock__hand-seconds--initial-minute`),this._clockHandHours?.classList.add(`sbb-clock__hand-hours--initial-hour`),this.internals.states.add(`initialized`)}_assignCurrentTime(){let e=this.now?null:new Date,[t,n,r]=e?[e.getHours(),e.getMinutes(),e.getSeconds()]:this.now.split(`:`).map(e=>+e);this._hours=t%12,this._minutes=n,this._seconds=r}_setMinutesHand(){this._clockHandMinutes?.style.setProperty(`transform`,`rotateZ(${Math.ceil(this._minutes*6)}deg)`)}_moveHoursHand(){this._removeHoursAnimationStyles();let e=Math.ceil(this._hours*30+this._minutes/2);e>=360&&(e-=360),this._clockHandHours?.style.setProperty(`transform`,`rotateZ(${e}deg)`)}_moveMinutesHand(){this._clockHandSeconds?.removeEventListener(`animationend`,this._moveMinutesHandFn),this._removeSecondsAnimationStyles(),this._addMinutesAndSetHands(),this._handMovement=setInterval(()=>this._addMinutesAndSetHands(),60*1e3)}_addMinutesAndSetHands(){this._minutes++,this._setMinutesHand()}_resetSecondsHandAnimation(){this._clockHandSeconds&&(this._clockHandSeconds.style.animation=``,this._clockHandSeconds.offsetHeight,this._clockHandSeconds.style.removeProperty(`animation`))}_removeEventListeners(){document?.removeEventListener(`visibilitychange`,this._handlePageVisibilityChange),this._clockHandHours?.removeEventListener(`animationend`,this._moveHoursHandFn),this._clockHandSeconds?.removeEventListener(`animationend`,this._moveMinutesHandFn),clearInterval(this._handMovement)}_removeHoursAnimationStyles(){this._clockHandHours?.classList.remove(`sbb-clock__hand-hours--initial-hour`),this.style.removeProperty(`--sbb-clock-hours-animation-start-angle`),this.style.removeProperty(`--sbb-clock-hours-animation-duration`)}_removeSecondsAnimationStyles(){this._clockHandSeconds?.classList.remove(`sbb-clock__hand-seconds--initial-minute`),this._clockHandMinutes?.classList.remove(`sbb-clock__hand-minutes--no-transition`),this.style.removeProperty(`--sbb-clock-seconds-animation-start-angle`),this.style.removeProperty(`--sbb-clock-seconds-animation-duration`)}render(){return n`
6
+ `;const p={once:!0,passive:!0};let m=(()=>{let m=s,h,g=[],_=[];return class extends m{constructor(){super(...arguments),this.#e=t(this,g,null),this._state=(t(this,_),`paused`),this._moveHoursHandFn=()=>this._moveHoursHand(),this._moveMinutesHandFn=()=>this._moveMinutesHand(),this._handlePageVisibilityChange=()=>{this.now||(document.visibilityState===`hidden`?this._stopClock():this._startClock())}}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(m[Symbol.metadata]??null):void 0;h=[a()],e(this,null,h,{kind:`accessor`,name:`now`,static:!1,private:!1,access:{has:e=>`now`in e,get:e=>e.now,set:(e,t)=>{e.now=t}},metadata:t},g,_),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-clock`}static{this.styles=[i(f)]}#e;get now(){return this.#e}set now(e){this.#e=e}connectedCallback(){super.connectedCallback(),this._resetIntervalId=setInterval(()=>this._resetClock(),18e5)}willUpdate(e){super.willUpdate(e),!(r||!this.hasUpdated)&&e.has(`now`)&&this._startOrConfigureClock()}firstUpdated(e){super.firstUpdated(e),r||(document.addEventListener(`visibilitychange`,this._handlePageVisibilityChange,!1),this._startOrConfigureClock())}disconnectedCallback(){super.disconnectedCallback(),this._removeEventListeners(),clearInterval(this._resetIntervalId)}_startOrConfigureClock(){this.now?(this._stopClock(),this._resetSecondsHandAnimation(),this._setHandsStartingPosition()):this._startClock()}_startClock(){this._clockHandHours?.addEventListener(`animationend`,this._moveHoursHandFn,p),this._clockHandSeconds?.addEventListener(`animationend`,this._moveMinutesHandFn,p),this._setHandsStartingPosition(),this.style?.setProperty(`--sbb-clock-animation-play-state`,`running`),this._state=`running`}_stopClock(){clearInterval(this._handMovement),this._removeSecondsAnimationStyles(),this._removeHoursAnimationStyles(),this._clockHandHours?.removeEventListener(`animationend`,this._moveHoursHandFn),this._clockHandSeconds?.removeEventListener(`animationend`,this._moveMinutesHandFn),this._clockHandMinutes?.classList.add(`sbb-clock__hand-minutes--no-transition`),this.style?.setProperty(`--sbb-clock-animation-play-state`,`paused`),this._state=`paused`}async _resetClock(){this._state===`running`&&(this._stopClock(),setTimeout(()=>this._startClock(),50))}_setHandsStartingPosition(){this._assignCurrentTime();let e=60-this._seconds,t=60-this._minutes,n=12-this._hours,r=0,i=0;e>0&&(r+=e,i=1),t>0&&(r+=(t-i)*60,i=1),n>0&&(r+=(n-i)*3600),this.style?.setProperty(`--sbb-clock-hours-animation-start-angle`,`${Math.ceil(this._hours*30+this._minutes/2)}deg`),this.style?.setProperty(`--sbb-clock-hours-animation-duration`,`${r}s`),this.style?.setProperty(`--sbb-clock-seconds-animation-start-angle`,`${Math.ceil(this._seconds*6.153846153846154)}deg`),this.style?.setProperty(`--sbb-clock-seconds-animation-duration`,`${e}s`),this._setMinutesHand(),this._clockHandSeconds?.classList.add(`sbb-clock__hand-seconds--initial-minute`),this._clockHandHours?.classList.add(`sbb-clock__hand-hours--initial-hour`),this.internals.states.add(`initialized`)}_assignCurrentTime(){let e=this.now?null:new Date,[t,n,r]=e?[e.getHours(),e.getMinutes(),e.getSeconds()]:this.now.split(`:`).map(e=>+e);this._hours=t%12,this._minutes=n,this._seconds=r}_setMinutesHand(){this._clockHandMinutes?.style.setProperty(`transform`,`rotateZ(${Math.ceil(this._minutes*6)}deg)`)}_moveHoursHand(){this._removeHoursAnimationStyles();let e=Math.ceil(this._hours*30+this._minutes/2);e>=360&&(e-=360),this._clockHandHours?.style.setProperty(`transform`,`rotateZ(${e}deg)`)}_moveMinutesHand(){this._clockHandSeconds?.removeEventListener(`animationend`,this._moveMinutesHandFn),this._removeSecondsAnimationStyles(),this._addMinutesAndSetHands(),this._handMovement=setInterval(()=>this._addMinutesAndSetHands(),6e4)}_addMinutesAndSetHands(){this._minutes++,this._setMinutesHand()}_resetSecondsHandAnimation(){this._clockHandSeconds&&(this._clockHandSeconds.style.animation=``,this._clockHandSeconds.offsetHeight,this._clockHandSeconds.style.removeProperty(`animation`))}_removeEventListeners(){document?.removeEventListener(`visibilitychange`,this._handlePageVisibilityChange),this._clockHandHours?.removeEventListener(`animationend`,this._moveHoursHandFn),this._clockHandSeconds?.removeEventListener(`animationend`,this._moveMinutesHandFn),clearInterval(this._handMovement)}_removeHoursAnimationStyles(){this._clockHandHours?.classList.remove(`sbb-clock__hand-hours--initial-hour`),this.style.removeProperty(`--sbb-clock-hours-animation-start-angle`),this.style.removeProperty(`--sbb-clock-hours-animation-duration`)}_removeSecondsAnimationStyles(){this._clockHandSeconds?.classList.remove(`sbb-clock__hand-seconds--initial-minute`),this._clockHandMinutes?.classList.remove(`sbb-clock__hand-minutes--no-transition`),this.style.removeProperty(`--sbb-clock-seconds-animation-start-angle`),this.style.removeProperty(`--sbb-clock-seconds-animation-duration`)}render(){return n`
7
7
  <span class="sbb-clock__face" .innerHTML=${c}></span>
8
8
  <span
9
9
  class="sbb-clock__hand-hours"
package/core/testing.js CHANGED
@@ -1 +1 @@
1
- import{isServer as e}from"lit";var t=class{get count(){return this._count}get events(){return this._events}get firstEvent(){return this.events.length?this.events[0]:null}get lastEvent(){return this.events.length?this.events[this.events.length-1]:null}constructor(e,t=null,n=null){this._event=e,this._target=t,this._options=n,this._count=0,this._events=[],this._promiseEventMap=new Map,this._target||=document,this._listenForEvent()}calledOnce(e){return this.calledTimes(1,e)}calledTimes(e,t=2e3){if(this.count>e)return Promise.reject(`Event '${this._event}' has been emitted more than expected (expected ${e}, actual ${this.count}`);if(this.count===e)return Promise.resolve(this.events[e-1]);if(this._promiseEventMap.has(e))return this._promiseEventMap.get(e).promise;{let n,r,i={promise:new Promise((e,t)=>{n=e,r=t}),resolve:n,reject:r};return this._promiseEventMap.set(e,i),this._wrapPromiseWithTimeout(i,e,t)}}_wrapPromiseWithTimeout(e,t,n){let r=setTimeout(()=>e.reject(`awaiting calledTimes(${t}) for event '${this._event}' results in timeout`),n);return e.promise.then(()=>clearTimeout(r)),e.promise}_listenForEvent(){this._target?.addEventListener(this._event,e=>{this._events.push(e),this._count++,this._promiseEventMap.get(this.count)?.resolve(e)},this._options??void 0)}};const n=(e,t,n)=>{if(e)return Mocha.describe(t,n)},r=(e,t,n)=>{if(e)return Mocha.test(t,n)};async function i(e,t=30,n=2*1e3){let r=new Date,i=0;function a(){return i++,e()}for(;!await a()&&r.getTime()+n>=new Date().getTime();)await new Promise(e=>setTimeout(e,t));return r.getTime()+n<new Date().getTime()?Promise.reject(`waitForCondition timeout: ${e.toString()}, attempts: ${i}, start: ${r.getTime()}, end: ${new Date().getTime()}`):Promise.resolve(!0)}let a;try{a=typeof Intl<`u`&&Intl.v8BreakIterator}catch{a=!1}const o=!e&&/(edge)/i.test(navigator.userAgent),s=!e&&/(msie|trident)/i.test(navigator.userAgent),c=!e&&!!(window.chrome||a)&&typeof CSS<`u`&&!o&&!s,l=!e&&/AppleWebKit/i.test(navigator.userAgent)&&!c&&!o&&!s;!e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&`MSStream`in window,!e&&/(Mac)/i.test(navigator.platform),!e&&/(firefox|minefield)/i.test(navigator.userAgent),!e&&/android/i.test(navigator.userAgent);const u=!e&&/safari/i.test(navigator.userAgent)&&l;async function d(e,t=2*1e3){let n=e.localName===`sbb-image`?e.shadowRoot?.querySelector(`.sbb-image__img`)??null:e;if(!n)throw Error(`img tag not found`);n.complete?u&&await n.decode():await new Promise((e,r)=>{let i=setTimeout(()=>r(`image loading timeout`),t);n.addEventListener(`load`,()=>{clearTimeout(i),!n.complete||u?n.decode().then(()=>e()):e()}),n.addEventListener(`error`,()=>{clearTimeout(i),r(`image error`)})})}const f=e=>!!e.updateComplete,p=Promise.resolve(),m=async e=>{let t=await e;(t.parentElement??t).querySelectorAll?.(`[defer-hydration]`).forEach(e=>e.removeAttribute(`defer-hydration`));let n=[t,...t.querySelectorAll(`*`)].filter(f).map(e=>[e.updateComplete,e.hydrationComplete??p,m(e.renderRoot)]).flat(1/0);return await Promise.all(n),t};export{t as EventSpy,n as describeIf,f as isReactiveElement,r as testIf,i as waitForCondition,d as waitForImageReady,m as waitForLitRender};
1
+ import{isServer as e}from"lit";var t=class{get count(){return this._count}get events(){return this._events}get firstEvent(){return this.events.length?this.events[0]:null}get lastEvent(){return this.events.length?this.events[this.events.length-1]:null}constructor(e,t=null,n=null){this._event=e,this._target=t,this._options=n,this._count=0,this._events=[],this._promiseEventMap=new Map,this._target||=document,this._listenForEvent()}calledOnce(e){return this.calledTimes(1,e)}calledTimes(e,t=2e3){if(this.count>e)return Promise.reject(`Event '${this._event}' has been emitted more than expected (expected ${e}, actual ${this.count}`);if(this.count===e)return Promise.resolve(this.events[e-1]);if(this._promiseEventMap.has(e))return this._promiseEventMap.get(e).promise;{let n,r,i={promise:new Promise((e,t)=>{n=e,r=t}),resolve:n,reject:r};return this._promiseEventMap.set(e,i),this._wrapPromiseWithTimeout(i,e,t)}}_wrapPromiseWithTimeout(e,t,n){let r=setTimeout(()=>e.reject(`awaiting calledTimes(${t}) for event '${this._event}' results in timeout`),n);return e.promise.then(()=>clearTimeout(r)),e.promise}_listenForEvent(){this._target?.addEventListener(this._event,e=>{this._events.push(e),this._count++,this._promiseEventMap.get(this.count)?.resolve(e)},this._options??void 0)}};const n=(e,t,n)=>{if(e)return Mocha.describe(t,n)},r=(e,t,n)=>{if(e)return Mocha.test(t,n)};async function i(e,t=30,n=2e3){let r=new Date,i=0;function a(){return i++,e()}for(;!await a()&&r.getTime()+n>=new Date().getTime();)await new Promise(e=>setTimeout(e,t));return r.getTime()+n<new Date().getTime()?Promise.reject(`waitForCondition timeout: ${e.toString()}, attempts: ${i}, start: ${r.getTime()}, end: ${new Date().getTime()}`):Promise.resolve(!0)}let a;try{a=typeof Intl<`u`&&Intl.v8BreakIterator}catch{a=!1}const o=!e&&/(edge)/i.test(navigator.userAgent),s=!e&&/(msie|trident)/i.test(navigator.userAgent),c=!e&&!!(window.chrome||a)&&typeof CSS<`u`&&!o&&!s,l=!e&&/AppleWebKit/i.test(navigator.userAgent)&&!c&&!o&&!s;!e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&`MSStream`in window,!e&&/(Mac)/i.test(navigator.platform),!e&&/(firefox|minefield)/i.test(navigator.userAgent),!e&&/android/i.test(navigator.userAgent);const u=!e&&/safari/i.test(navigator.userAgent)&&l;async function d(e,t=2e3){let n=e.localName===`sbb-image`?e.shadowRoot?.querySelector(`.sbb-image__img`)??null:e;if(!n)throw Error(`img tag not found`);n.complete?u&&await n.decode():await new Promise((e,r)=>{let i=setTimeout(()=>r(`image loading timeout`),t);n.addEventListener(`load`,()=>{clearTimeout(i),!n.complete||u?n.decode().then(()=>e()):e()}),n.addEventListener(`error`,()=>{clearTimeout(i),r(`image error`)})})}const f=e=>!!e.updateComplete,p=Promise.resolve(),m=async e=>{let t=await e;(t.parentElement??t).querySelectorAll?.(`[defer-hydration]`).forEach(e=>e.removeAttribute(`defer-hydration`));let n=[t,...t.querySelectorAll(`*`)].filter(f).map(e=>[e.updateComplete,e.hydrationComplete??p,m(e.renderRoot)]).flat(1/0);return await Promise.all(n),t};export{t as EventSpy,n as describeIf,f as isReactiveElement,r as testIf,i as waitForCondition,d as waitForImageReady,m as waitForLitRender};
package/core.js CHANGED
@@ -40,7 +40,7 @@ let xe=0;var Se=class{constructor(){r||(document.body?this._liveElement=this._cr
40
40
  `;let Ln=(()=>{let e=V(H(P)),t,r=[],i=[],c,u=[],f=[],p,m=[],h=[];return class extends e{static{let n=typeof Symbol==`function`&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;t=[l()],c=[l({attribute:`horizontal-from`,reflect:!0})],p=[l({reflect:!0})],o(this,null,t,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:n},r,i),o(this,null,c,{kind:`accessor`,name:`horizontalFrom`,static:!1,private:!1,access:{has:e=>`horizontalFrom`in e,get:e=>e.horizontalFrom,set:(e,t)=>{e.horizontalFrom=t}},metadata:n},u,f),o(this,null,p,{kind:`accessor`,name:`orientation`,static:!1,private:!1,access:{has:e=>`orientation`in e,get:e=>e.orientation,set:(e,t)=>{e.orientation=t}},metadata:n},m,h),n&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:n})}static{this.styles=[a(In)]}#e=s(this,r,null);get size(){return this.#e}set size(e){this.#e=e}#t=(s(this,i),s(this,u,null));get horizontalFrom(){return this.#t}set horizontalFrom(e){this.#t=e}#n=(s(this,f),s(this,m,`horizontal`));get orientation(){return this.#n}set orientation(e){this.#n=e}get selectionElements(){return Array.from(this.querySelectorAll?.(this.selectionElementSelectors)??[]).filter(e=>e.closest?.(this.localName)===this)}constructor(){super(),s(this,h),this.addController(new d(this,{config:{childList:!0,subtree:!0},callback:()=>this.toggleState(`has-panel`,!!this.querySelector?.(this.panelElementSelector))}))}onSlotChange(){}render(){return n`
41
41
  <slot @slotchange=${()=>this.onSlotChange()}></slot>
42
42
  <slot name="error"></slot>
43
- `}}})();var Rn=class{get size(){return this._handlers.size}constructor(e,t){this._host=e,this._property=t,this._handlers=new Set,this._hostDefinedPromise=null,r||(customElements.get(this._host.localName)?customElements.upgrade(this._host):this._hostDefinedPromise=customElements.whenDefined(this._host.localName).then(()=>{customElements.upgrade(this._host),this._hostDefinedPromise=null})),this._value=this._host[this._property]}addHandler(e){this._handlers.size||(this._host.addController?this._host.addController(this):this._hostDefinedPromise&&this._hostDefinedPromise.then(()=>this._host.addController(this))),this._handlers.add(e),this._hostDefinedPromise?this._hostDefinedPromise.then(()=>e(this._host)):e(this._host)}removeHandler(e){this._handlers.delete(e),this._handlers.size||(this._host.removeController?this._host.removeController(this):this._hostDefinedPromise&&this._hostDefinedPromise.then(()=>this._host.removeController(this)))}hostUpdate(){let e=this._host[this._property];if(this._value!==e){this._value=e;for(let e of this._handlers)e(this._host)}}};const U=new WeakMap;var zn=class{constructor(e,t,n){this._host=e,this._referenceResolver=t,this._handlers=n,this._host.addController(this)}hostConnected(){this.connect()}hostDisconnected(){this._reference!==this._referenceResolver()&&this.disconnect()}connect(){let e=this._referenceResolver();if(this._reference===e||(this.disconnect(),this._reference=e,!this._reference))return;let t=U.get(this._reference);t||(t=new Map,U.set(this._reference,t)),this._watchers=t;for(let[e,t]of Object.entries(this._handlers)){let n=this._watchers.get(e);n||(n=new Rn(this._reference,e),this._watchers.set(e,n)),n.addHandler(t)}}disconnect(){if(this._reference){for(let[e,t]of Object.entries(this._handlers)){let n=this._watchers?.get(e);n&&(n.removeHandler(t),n.size||(this._watchers.delete(e),!this._watchers.size&&this._reference&&U.delete(this._reference)))}this._reference=null}}};const Bn=[];r||window.addEventListener(`keydown`,e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),Bn.at(-1)?.escapeStrategy())});var Vn=class{constructor(e,t=Bn){this._host=e,this._overlayStack=t,this._host.addController?.(this)}hostDisconnected(){this.disconnect()}connect(){this.disconnect(),this._overlayStack.push(this._host)}disconnect(){if(this._overlayStack.length){let e=this._overlayStack.findIndex(e=>e===this._host);e!==-1&&this._overlayStack.splice(e,1)}}};const Hn=new WeakMap;var Un=class{constructor(e,t,n=Hn){this._host=e,this._idRef=t,this._observers=n,this._rootNode=null,this._host.addController(this)}hostConnected(){if(r)return;this._rootNode=this._host.getRootNode();let e=this._observers.get(this._rootNode);if(e)e.controllers.add(this);else{let e=new Set([this]),t=new MutationObserver(t=>{let n=new Set;for(let e of t)if(e.type===`attributes`)n.add(e.oldValue),n.add(e.target.id);else if(e.type===`childList`)for(let t of[...e.addedNodes,...e.removedNodes])t instanceof HTMLElement&&(n.add(t.id),t.querySelectorAll(`[id]`).forEach(e=>n.add(e.id)));for(let t of e){let e=t._host[t._idRef];e&&typeof e==`string`&&n.has(e)&&t._host.requestUpdate()}});t.observe(this._rootNode,{attributeFilter:[`id`],childList:!0,subtree:!0,attributeOldValue:!0}),this._observers.set(this._rootNode,{observer:t,controllers:e})}}hostDisconnected(){if(r||!this._rootNode)return;let e=this._observers.get(this._rootNode);if(!e){this._rootNode=null;return}e.controllers.delete(this),e.controllers.size===0&&(e.observer.disconnect(),this._observers.delete(this._rootNode)),this._rootNode=null}find(){if(r||!this._rootNode)return null;{let e=this._host[this._idRef];return typeof e==`string`?this._rootNode?.getElementById(e):null}}};const Wn=[`script`,`head`,`template`,`style`],Gn=new Set,Kn=new Set,qn=new Set;var Jn=class{constructor(e,t=Gn,n=qn,r=Kn){this._host=e,this._inertElements=t,this._inertOverlays=n,this._exemptedElements=r,this._host.addController?.(this)}hostConnected(){this._host.isOpen&&this.activate()}hostDisconnected(){this.isInert()&&this.deactivate()}activate(){this._inertOverlays.size&&this._removeAllInertAttributes(),this._inertOverlays.add(this._host),this._addAllInertAttributes()}deactivate(){if(this._currentOverlay()!==this._host){this._inertOverlays.has(this._host)&&this._inertOverlays.delete(this._host);return}this._removeAllInertAttributes(),this._inertOverlays.delete(this._host),this._inertOverlays.size&&this._addAllInertAttributes()}isInert(){return this._inertOverlays.has(this._host)}exempt(e){this._inertElements.has(e)&&!this._exemptedElements.has(e)&&(this._removeInertAttributes(e),this._inertElements.delete(e),this._exemptedElements.add(e))}restoreAllExempted(){this._exemptedElements.forEach(e=>this._addInertAttributes(e)),this._exemptedElements.clear()}_currentOverlay(){return[...this._inertOverlays].pop()??null}_removeAllInertAttributes(){this._inertElements.forEach(e=>this._removeInertAttributes(e)),this._inertElements.clear()}_removeInertAttributes(e){e&&(e.hasAttribute(`data-sbb-inert`)&&(e.inert=!1,e.removeAttribute(`data-sbb-inert`)),e.hasAttribute(`data-sbb-aria-hidden`)&&(e.removeAttribute(`aria-hidden`),e.removeAttribute(`data-sbb-aria-hidden`)))}_addAllInertAttributes(){let e=this._currentOverlay();for(;e!==document.documentElement&&e!==null;)Array.from((e?.parentElement??e?.getRootNode())?.childNodes??[]).filter(t=>t!==e&&t instanceof window.HTMLElement&&!Wn.includes(t.localName)&&!t.classList.contains(`sbb-live-announcer-element`)).forEach(e=>{this._addInertAttributes(e)}),e=e?.parentElement??e?.getRootNode()?.host??null}_addInertAttributes(e){this._inertElements.add(e),e.inert||(e.inert=!0,e.toggleAttribute(`data-sbb-inert`,!0)),e.hasAttribute(`aria-hidden`)||(e.setAttribute(`aria-hidden`,`true`),e.toggleAttribute(`data-sbb-aria-hidden`,!0))}};const Yn=`(forced-colors: active)`,W=`(prefers-color-scheme: dark)`,Xn=`(any-hover: hover)`,Zn=`(pointer: coarse)`,Qn=`(min-width: 0rem)`,$n=`(min-width: 37.5rem)`,er=`(min-width: 64rem)`,tr=`(min-width: 90rem)`,nr=`(max-width: 63.9375rem)`,rr=`(max-width: 89.9375rem)`,G=new Map;var ir=class{constructor(e,t){this._queries=t,e.addController(this)}matches(e){return r?null:matchMedia(e).matches}hostConnected(){if(!r)for(let[e,t]of Object.entries(this._queries)){let n=G.get(e);if(n)n.handlers.add(t);else{let n=matchMedia(e),r=new Set([t]),i=e=>r.forEach(t=>t(e.matches));n.addEventListener(`change`,i),G.set(e,{mediaQueryList:n,handlers:r,eventHandler:i})}}}hostDisconnected(){for(let[e,t]of Object.entries(this._queries)){let n=G.get(e);n&&(n.handlers.delete(t),n.handlers.size||G.delete(e))}}},ar=class e extends ir{static{this._currentMode=this._readLightDarkClass()}static{this._observer=r?null:new MutationObserver(t=>{if(t[0].oldValue!==document.documentElement.getAttribute(`class`)){let t=this._readLightDarkClass();this._currentMode!==t&&(e.requestUpdate(),this._currentMode=t)}})}static{this._observerConfig={attributeFilter:[`class`],attributeOldValue:!0}}constructor(e,t){let n=()=>{t(this.matches()),this._host.toggleState?.(`dark`,this.matches())};super(e,{[W]:n}),this._host=e,this._onChangeWithStateUpdater=n}static _readLightDarkClass(){if(r)return null;let e=document.documentElement.classList;return[`sbb-light-dark`,`sbb-dark`,`sbb-light`].find(t=>e.contains(t))??null}static requestUpdate(){let e=G.get(W);e&&e.handlers.forEach(t=>t(e.mediaQueryList.matches))}hostConnected(){let t=(G.get(`(prefers-color-scheme: dark)`)?.handlers.size??0)===0;super.hostConnected(),t&&e._observer.observe(document.documentElement,e._observerConfig),this._onChangeWithStateUpdater()}hostDisconnected(){super.hostDisconnected(),(G.get(`(prefers-color-scheme: dark)`)?.handlers.size??0)===0&&e._observer.disconnect()}matches(){if(r)return!1;let e=getComputedStyle(this._host).getPropertyValue(`color-scheme`),t=e.includes(`dark`),n=e.trim()===`dark`;return super.matches(`(prefers-color-scheme: dark)`)&&t||n}};const or=!r&&CSS.supports(`anchor-name`,`--test`),sr=[`top`,`bottom`,`left`,`right`,`top span-left`,`top span-right`,`bottom span-left`,`bottom span-right`,`left span-top`,`left span-bottom`,`right span-top`,`right span-bottom`],cr=[`block-start`,`block-end`,`inline-start`,`inline-end`,`block-start span-inline-start`,`block-start span-inline-end`,`block-end span-inline-start`,`block-end span-inline-end`,`inline-start span-block-start`,`inline-start span-block-end`,`inline-end span-block-start`,`inline-end span-block-end`],lr={"block-start":`block-start`,"block-end":`block-end`,"inline-start":`inline-end`,"inline-end":`inline-start`,"block-start span-inline-start":`block-start span-inline-end`,"block-start span-inline-end":`block-start span-inline-start`,"block-end span-inline-start":`block-end span-inline-end`,"block-end span-inline-end":`block-end span-inline-start`,"inline-start span-block-start":`inline-end span-block-start`,"inline-start span-block-end":`inline-end span-block-end`,"inline-end span-block-start":`inline-start span-block-start`,"inline-end span-block-end":`inline-start span-block-end`};[...sr,...cr];let ur=0;var dr=class{get currentPosition(){return this._usePolyfill?this._lastPosition??this._positions[0]??``:(this._overlayStyles??=getComputedStyle(this._overlay),this._overlayStyles.getPropertyValue(`position-area`))}constructor(e,t=!or){this._usePolyfill=t,this._resizeObserver=r?null:new ResizeObserver(()=>this._requestCalculatePosition()),this._anchorName=`--sbb-overlay-anchor-${++ur}`,this._positions=[],e.addController(this),this._overlay=e}hostConnected(){this._usePolyfill?this._overlay.style.setProperty(`position-area`,`initial`):this._overlay.style.setProperty(`position-anchor`,this._anchorName)}hostUpdate(){r||this._readPositionsFromCss()}connect(e){r||(this._anchor&&this.disconnect(),this._anchor=e,this._usePolyfill||this._anchor.style.setProperty(`anchor-name`,this._anchorName),this._readPositionsFromCss(),this._calculatePosition(),this._abortController?.abort(),this._abortController=new AbortController,document.addEventListener(`scroll`,()=>this._requestCalculatePosition(),{capture:!0,passive:!0,signal:this._abortController.signal}),window.addEventListener(`resize`,()=>this._requestCalculatePosition(),{passive:!0,signal:this._abortController.signal}),this._resizeObserver.observe(e,{box:`border-box`}),this._resizeObserver.observe(this._overlay,{box:`border-box`}))}disconnect(){this._anchor?.style.removeProperty(`anchor-name`),this._anchor=void 0,this._abortController?.abort(),this._resizeObserver.disconnect()}_requestCalculatePosition(){this._frame??=requestAnimationFrame(()=>{this._calculatePosition(),this._frame=void 0})}_calculatePosition(){if(this._anchor){if(this._usePolyfill){let e=this._getOptimalPosition(this._positions);this._applyOverlayPosition(e.position,e.left,e.top)}this._overlay.setAttribute(`data-position`,this.currentPosition)}}_getOptimalPosition(e){let{offsetHeight:t,offsetWidth:n}=this._overlay,{innerHeight:r,innerWidth:i}=window,{top:a,left:o,height:s,width:c}=this._anchor.getBoundingClientRect(),l=this._overlay.matches(`:dir(rtl)`),u=a,d=r-s-a,f=o,p=i-c-o,m=n-c,h=t-s,g=m/2,_=h/2;this._overlay.style.setProperty(`--sbb-overlay-controller-trigger-height`,`${s}px`),this._overlay.style.setProperty(`--sbb-overlay-controller-trigger-width`,`${c}px`);let v={left:0,top:0,position:``},y;for(let r of e){switch(l&&cr.includes(r)?lr[r]:r){default:case`bottom`:case`block-end`:v={position:r,left:o-g,top:a+s,fits:t<=d&&g<=f&&g<=p};break;case`top`:case`block-start`:v={position:r,left:o-g,top:a-t,fits:t<=u&&g<=f&&g<=p};break;case`right`:case`inline-end`:v={position:r,left:o+c,top:a-_,fits:n<=p&&_<=u&&_<=d};break;case`left`:case`inline-start`:v={position:r,left:o-n,top:a-_,fits:n<=f&&_<=u&&_<=d};break;case`top span-left`:case`block-start span-inline-start`:v={position:r,left:o-m,top:a-t,fits:t<=u&&m<=f};break;case`top span-right`:case`block-start span-inline-end`:v={position:r,left:o,top:a-t,fits:t<=u&&m<=p};break;case`bottom span-left`:case`block-end span-inline-start`:v={position:r,left:o-m,top:a+s,fits:t<=d&&m<=f};break;case`bottom span-right`:case`block-end span-inline-end`:v={position:r,left:o,top:a+s,fits:t<=d&&m<=p};break;case`left span-top`:case`inline-start span-block-start`:v={position:r,left:o-n,top:a+s-t,fits:n<=f&&h<=u};break;case`left span-bottom`:case`inline-start span-block-end`:v={position:r,left:o-n,top:a,fits:n<=f&&h<=d};break;case`right span-top`:case`inline-end span-block-start`:v={position:r,left:o+c,top:a+s-t,fits:n<=p&&h<=u};break;case`right span-bottom`:case`inline-end span-block-end`:v={position:r,left:o+c,top:a,fits:n<=p&&h<=d};break}if(v.fits)return v;y??=v}return y}_applyOverlayPosition(e,t,n){this._lastPosition=e,this._overlay.style.left=`${t}px`,this._overlay.style.top=`${n}px`}_readPositionsFromCss(){if(!this._usePolyfill)return;this._overlayStyles??=getComputedStyle(this._overlay);let e=[this._overlayStyles.getPropertyValue(`--sbb-overlay-position-area`)||`block-end`,...this._overlayStyles.getPropertyValue(`--sbb-overlay-position-try-fallbacks`).split(`,`).map(e=>e.trim()).filter(e=>!!e)];this._positions=e,this._lastPosition&&!this._positions.includes(this._lastPosition)&&(this._lastPosition=void 0)}};const fr=/(0?[1-9]|[12][0-9]|3[01])[.,\\/\-\s](0?[1-9]|1[0-2])[.,\\/\-\s]([0-9]{1,4}$)?/,pr=/^([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-3][0-9])$/,mr=1,hr=2,gr=3,_r=4,vr=5,yr=6,br=0;var K=class{constructor(e=15){this._cutoffYearOffset=e}deserialize(e){return e==null||this.isDateInstance(e)&&this.isValid(e)?e:this.invalid()}parse(e){if(!e)return null;let t=null,n=e.match(pr);try{t=n?this.createDate(+n[1],+n[2],+n[3]):null}catch{}if(this.isValid(t))return t;let r=e.replace(/\D/g,` `).trim()?.match(fr);if(!r||r.index!==0||r.length<=2||r.some(e=>e===void 0)||!this.isValid(this.createDate(+r[3],+r[2],+r[1])))return null;let i=+r[3];if(typeof i==`number`&&i<100&&i>=0){let e=this.getYear(this.today())-2e3+this._cutoffYearOffset;i=i<=e?2e3+i:1900+i}return this.createDate(i,+r[2],+r[1])}format(e,t){if(!this.isValid(e))return``;let n=new Date(this.toIso8601(e)+`T00:00:00`),r=new Intl.DateTimeFormat(`de-CH`,{day:`2-digit`,month:`2-digit`,year:`numeric`});if(t?.weekdayStyle===`none`)return r.format(n);let i=t?.weekdayStyle??`short`,a=this.getDayOfWeekNames(i)[this.getDayOfWeek(e)];return a=a.charAt(0).toUpperCase()+a.substring(1),i===`short`&&(a=a.substring(0,2)),`${a}, ${r.format(n)}`}toIso8601(e){let t=(e,t=2)=>`${e}`.padStart(t,`0`);return`${t(this.getYear(e),4)}-${t(this.getMonth(e))}-${t(this.getDate(e))}`}getValidDateOrNull(e){return this.isDateInstance(e)&&this.isValid(e)?e:null}getFirstWeekOffset(e){let t=this.createDate(this.getYear(e),this.getMonth(e),1);return(7+this.getDayOfWeek(t)-this.getFirstDayOfWeek())%7}compareDate(e,t){return this.getYear(e)-this.getYear(t)||this.getMonth(e)-this.getMonth(t)||this.getDate(e)-this.getDate(t)}sameDate(e,t){if(e&&t){let n=this.isValid(e),r=this.isValid(t);return n&&r?!this.compareDate(e,t):n==r}return e==t}clampDate(e,t,n){return t&&this.compareDate(e,t)<0?t:n&&this.compareDate(e,n)>0?n:e}};const xr=/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;var Sr=class extends K{getYear(e){return e.getFullYear()}getMonth(e){return e.getMonth()+1}getDate(e){return e.getDate()}getDayOfWeek(e){return e.getDay()}getAccessibilityFormatDate(e){return new Intl.DateTimeFormat(z.current,{year:`numeric`,month:`long`,day:`numeric`}).format(new Date(e))}getMonthNames(e){let t=new Intl.DateTimeFormat(z.current,{month:e});return this._range(12,e=>t.format(new Date(2017,e,1)))}getDateNames(){let e=new Intl.DateTimeFormat(z.current,{day:`numeric`});return this._range(31,t=>e.format(new Date(2017,0,t+1)))}getDayOfWeekNames(e){let t=new Intl.DateTimeFormat(z.current,{weekday:e});return this._range(7,e=>t.format(new Date(2017,0,e+1)))}getFirstDayOfWeek(){return 1}getNumDaysInMonth(e){return this.getDate(this._createDateWithOverflow(this.getYear(e),this.getMonth(e),0))}today(){return new Date(new Date().setHours(0,0,0,0))}createDate(e,t,n){if(t<1||t>12)throw Error(`Invalid month "${t}". Month has to be between 1 and 12.`);if(n<1)throw Error(`Invalid day "${n}". Day has to be greater than 0.`);let r=this._createDateWithOverflow(e,t-1,n);if(r.getMonth()+1!==t)throw Error(`Invalid day "${n}" for month "${t}".`);return r}isDateInstance(e){return e instanceof Date}isValid(e){return!!e&&!isNaN(e.valueOf())}clone(e){return new Date(e.valueOf())}addCalendarYears(e,t){return this.addCalendarMonths(e,t*12)}addCalendarMonths(e,t){let n=e.getMonth()+t,r=new Date(e.getFullYear(),n,1,0,0,0,0),i=this.getNumDaysInMonth(r);return new Date(this.clone(e).setMonth(n,Math.min(i,e.getDate())))}addCalendarDays(e,t){let n=e.getDate()+t;return new Date(e.getFullYear(),e.getMonth(),n,0,0,0,0)}deserialize(e){if(typeof e==`string`){if(!e)return null;if(xr.test(e))return this.getValidDateOrNull(new Date(e.includes(`T`)?e:e+`T00:00:00`))}return super.deserialize(e)}invalid(){return new Date(NaN)}_range(e,t){return Array.from({length:e},(e,n)=>t(n))}_createDateWithOverflow(e,t,n){let r=new Date(e,t,n);return e>=0&&e<100&&r.setFullYear(this.getYear(r)-1900),r}};const q=new Sr,Cr=/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;var wr=class extends K{constructor(e){if(super(e),typeof Temporal!=`object`)throw Error(`Temporal is not available in the current environment. Please make sure to include the temporal polyfill.`)}getYear(e){return e.year}getMonth(e){return e.month}getDate(e){return e.day}getDayOfWeek(e){return e.dayOfWeek%7}getAccessibilityFormatDate(e){return this.deserialize(e).toLocaleString(z.current,{year:`numeric`,month:`long`,day:`numeric`})}getMonthNames(e){let t=new Intl.DateTimeFormat(z.current,{month:e});return this._range(12,e=>t.format(Temporal.PlainDate.from({year:2017,month:e+1,day:1})))}getDateNames(){let e=new Intl.DateTimeFormat(z.current,{day:`numeric`});return this._range(31,t=>e.format(Temporal.PlainDate.from({year:2017,month:1,day:t+1})))}getDayOfWeekNames(e){let t=new Intl.DateTimeFormat(z.current,{weekday:e});return this._range(7,e=>t.format(Temporal.PlainDate.from({year:2017,month:1,day:e+1})))}getFirstDayOfWeek(){return 1}getNumDaysInMonth(e){return e.daysInMonth}today(){return Temporal.Now.plainDateISO()}createDate(e,t,n){if(t<1||t>12)throw Error(`Invalid month "${t}". Month has to be between 1 and 12.`);if(n<1)throw Error(`Invalid day "${n}". Day has to be greater than 0.`);try{return Temporal.PlainDate.from({year:e,month:t,day:n},{overflow:`reject`})}catch{throw Error(`Invalid date "${n}" for month with index "${t}".`)}}isDateInstance(e){return e instanceof Temporal.PlainDate}isValid(e){return this.isDateInstance(e)}clone(e){return Temporal.PlainDate.from(e)}addCalendarYears(e,t){return e.add({years:t})}addCalendarMonths(e,t){return e.add({months:t})}addCalendarDays(e,t){return e.add({days:t})}deserialize(e){if(typeof e==`string`){if(!e)return null;if(Cr.test(e))return this.getValidDateOrNull(Temporal.PlainDate.from(e.split(`T`)[0]))}return super.deserialize(e)}invalid(){return null}toIso8601(e){return e.toJSON()}_range(e,t){return Array.from({length:e},(e,n)=>t(n))}};const Tr=e=>(t,n)=>{let{kind:r}=n;if(r===`accessor`)return{get(){let n=t.get.call(this);return e(this,n)}};throw Error(`Unsupported decorator location: ${r}`)},Er=e=>(t,n)=>{let{kind:r}=n;if(r===`accessor`)return{set(r){let i=n.access.get(this);t.set.call(this,r);let a=n.access.get(this);a!==i&&e(this,a,i)}};throw Error(`Unsupported decorator location: ${r}`)},J=new WeakMap,Y=new WeakMap,Dr=()=>(e,t)=>{let{kind:n,metadata:i,name:a}=t;if(n===`accessor`){if(r)return{};let n=globalThis.litPropertyMetadata.get(i)?.get(a)?.attribute,o=typeof n==`string`?n:a;return t.addInitializer(function(){this.addController({host:this,rootNode:null,checkIdReference(e){let n=this.host.getAttribute(o)??Y.get(this.host);if(n&&typeof n==`string`&&(!e||e.has(n))){let e=this.rootNode?.getElementById?.(n)??null;t.access.get(this.host)!==e&&t.access.set(this.host,e)}},hostConnected(){this.rootNode=this.host.getRootNode(),this.checkIdReference();let e=J.get(this.rootNode);if(e)e.controllers.add(this);else{let e=new Set([this]),t=new MutationObserver(t=>{let n=new Set;for(let e of t)if(e.type===`attributes`)e.oldValue&&n.add(e.oldValue),e.target.id&&n.add(e.target.id);else if(e.type===`childList`)for(let t of[...e.addedNodes,...e.removedNodes])t instanceof HTMLElement&&(t.id&&n.add(t.id),t.querySelectorAll(`[id]`).forEach(e=>{e.id&&n.add(e.id)}));e.forEach(e=>e.checkIdReference(n))});t.observe(this.rootNode,{attributeFilter:[`id`],attributeOldValue:!0,childList:!0,subtree:!0}),J.set(this.rootNode,{observer:t,controllers:e})}},hostDisconnected(){if(r||!this.rootNode)return;let e=J.get(this.rootNode);if(!e){this.rootNode=null;return}e.controllers.delete(this),e.controllers.size===0&&(e.observer.disconnect(),J.delete(this.rootNode)),this.rootNode=null}})}),{set(t){if(typeof t!=`string`)Y.delete(this),t instanceof HTMLElement&&this.hasAttribute(o)&&t.id!==this.getAttribute(o)&&this.removeAttribute(o);else if(this.hasAttribute(o)&&this.getAttribute(o)!==t)return;else{let e=t?this.getRootNode?.()?.getElementById?.(t):null;e?t=e:t&&=(Y.set(this,t),null)}e.set.call(this,t)}}}throw Error(`Unsupported decorator location: ${n}`)},Or={toAttribute(e,t){let n=R().datetime?.dateAdapter??q;return n.isValid(e)?n.toIso8601(e):null}},kr=e=>(t,n)=>{let{kind:r}=n;if(r===`accessor`)return{set(e){let n=R().datetime?.dateAdapter??q;e=n.getValidDateOrNull(n.deserialize(e)),e=e?n.createDate(n.getYear(e),n.getMonth(e),n.getDate(e)):null,t.set.call(this,e)},get(){let n=R().datetime?.dateAdapter??q,r=t.get.call(this);return n.isValid(r)?n.clone(r):e?.fallback?.(n)}};throw Error(`Unsupported decorator location: ${r}`)};function Ar(e,t){if(r||globalThis.disableAnimation)return!0;let n=getComputedStyle(e).getPropertyValue(t);return parseFloat(n)===0}function X(e,t){let n=t;for(;n;){if(n===e)return!0;n=n instanceof ShadowRoot?n.host:n.parentNode}return!1}function jr(e,t,n){n?e.setAttribute(t,n):e.removeAttribute(t)}function Mr(e){let t=()=>queueMicrotask(e);document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,t):t()}function Z(){return document.body.hasAttribute(`data-sbb-scroll-disabled`)}var Nr=class{disableScroll(){if(Z())return;this._height=document.body.style.height,this._position=document.body.style.position,this._overflow=document.body.style.overflow,this._marginInlineEnd=document.body.style.marginInlineEnd;let e=window.innerWidth-document.documentElement.clientWidth;document.body.style.overflow=`hidden`,document.body.style.height=`100dvh`,document.body.style.position=`relative`,document.body.style.marginInlineEnd=`${e}px`,document.body.style.setProperty(`--sbb-scrollbar-width`,`${e}px`),document.body.toggleAttribute(`data-sbb-scroll-disabled`,!0)}enableScroll(){Z()&&(document.body.style.height=this._height||``,document.body.style.position=this._position||``,document.body.style.overflow=this._overflow||``,document.body.style.marginInlineEnd=this._marginInlineEnd||``,document.body.style.setProperty(`--sbb-scrollbar-width`,`0`),document.body.removeAttribute(`data-sbb-scroll-disabled`))}};function Pr(e){e.key===` `&&e.preventDefault()}function Fr(e,t){let n=Object.getPrototypeOf(e).constructor,r=new n(e.type,e);t.dispatchEvent(r)}const Ir=e=>{class t extends e{constructor(){super(...arguments),this.isAnimating=!1,this._animationPromise=Promise.resolve()}get animationComplete(){return this._animationPromise}disconnectedCallback(){super.disconnectedCallback(),this.stopAnimation()}startAnimation(){this.isAnimating||(this._animationPromise=this._enqueueAnimation())}stopAnimation(){}async _enqueueAnimation(){this.isAnimating=!0;let e=this.stopAnimation,t=new Promise(t=>{this.stopAnimation=()=>{e(),this.isAnimating=!1,t()}});try{await this._animationPromise}catch(e){Promise.reject(e)}return t}}return t},Lr=e=>(()=>{let n=V(H(L(e))),r=[],i;return class extends n{static{let e=typeof Symbol==`function`&&Symbol.metadata?Object.create(n[Symbol.metadata]??null):void 0;i=[l({type:Boolean,converter:{...t,fromAttribute:(e,n)=>({value:t.fromAttribute?.(e,n),attribute:!0})}})],o(this,null,i,{kind:`setter`,name:`checked`,static:!1,private:!1,access:{has:e=>`checked`in e,set:(e,t)=>{e.checked=t}},metadata:e},null,r),e&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}static{this.role=`checkbox`}set checked(e){let t=typeof e==`object`&&e.attribute;t&&(e=e.value),this.hasUpdated&&!t&&(this._attributeMutationBlocked=!0),this._checked=!!e,this.updateFormValue()}get checked(){return this._checked}get type(){return`checkbox`}constructor(){super(),this._attributeMutationBlocked=(s(this,r),!1),this._languageController=new z(this),this._checked=!1,this._handleKeyboardInteraction=e=>{e.key===` `&&this._handleUserInteraction()},this._handleUserInteraction=()=>{this.disabled||(this.withUserInteraction?.(),this.checked=!this.checked,this._attributeMutationBlocked=!0,this.dispatchEvent(new InputEvent(`input`,{composed:!0,bubbles:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},this.addEventListener?.(`click`,this._handleUserInteraction),this.addEventListener?.(`keydown`,Pr),this.addEventListener?.(`keyup`,this._handleKeyboardInteraction)}connectedCallback(){super.connectedCallback(),this.tabIndex=0}attributeChangedCallback(e,t,n){(e!==`checked`||!this._attributeMutationBlocked)&&super.attributeChangedCallback(e,t,n)}formResetCallback(){this.checked=this.hasAttribute(`checked`),this._attributeMutationBlocked=!1}formStateRestoreCallback(e,t){e&&(this.checked=e===`true`)}updateFormValue(){this.checked?super.updateFormValue():this.internals.setFormValue(null)}formState(){return`${this.checked}`}shouldValidate(e){return super.shouldValidate(e)||e===`checked`||e===`required`}validate(){super.validate(),this.required&&!this.checked?this.setValidityFlag(`valueMissing`,fn[this._languageController.current]):this.removeValidityFlag(`valueMissing`)}}})(),Rr=e=>(()=>{let t=e,n=[],r;return class extends t{static{let e=typeof Symbol==`function`&&Symbol.metadata?Object.create(t[Symbol.metadata]??null):void 0;r=[l({type:Boolean,attribute:`readonly`})],o(this,null,r,{kind:`setter`,name:`readOnly`,static:!1,private:!1,access:{has:e=>`readOnly`in e,set:(e,t)=>{e.readOnly=t}},metadata:e},null,n),e&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}set readOnly(e){this.#e=!!e,this.toggleAttribute(`readonly`,this.#e)}get readOnly(){return this.#e}#e=(s(this,n),!1)}})(),zr=(()=>{if(r)return!1;let e=document.createElement(`div`);return e.setAttribute(`contenteditable`,`PLAINTEXT-ONLY`),e.contentEditable===`plaintext-only`})(),Br=e=>(()=>{let t=Rr(V(H(L(e)))),i=[],a,u,d;return class extends t{static{let e=typeof Symbol==`function`&&Symbol.metadata?Object.create(t[Symbol.metadata]??null):void 0;a=[l()],u=[l({attribute:!1})],d=[c({passive:!0})],o(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:e},null,i),o(this,null,u,{kind:`setter`,name:`placeholder`,static:!1,private:!1,access:{has:e=>`placeholder`in e,set:(e,t)=>{e.placeholder=t}},metadata:e},null,i),o(this,null,d,{kind:`method`,name:`_cleanChildren`,static:!1,private:!1,access:{has:e=>`_cleanChildren`in e,get:e=>e._cleanChildren},metadata:e},null,i),e&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}static{this.role=`textbox`}static{this.formFieldAssociated=!0}get type(){return`text`}set value(e){this._value=this._cleanText(e),this.hasUpdated&&this._assignValue(this._value),this.dispatchEvent(new Event(`displayvaluechange`,{bubbles:!0,composed:!0}))}get value(){return this._value??``}set placeholder(e){e?this.setAttribute(`placeholder`,e):this.removeAttribute(`placeholder`),this.internals.ariaPlaceholder=e||null}get placeholder(){return this.getAttribute(`placeholder`)??``}constructor(){super(),this._shouldEmitChange=(s(this,i),!1),this._shouldTriggerSubmit=!1,this.language=new z(this),this._value=``,this.addEventListener?.(`input`,()=>{let e=this._value;this._value=this._cleanText(this.textContent??``),this.requestUpdate(`value`,e),this.internals.states.add(`interacted`),this._shouldEmitChange=!0},{capture:!0}),this.addEventListener?.(`change`,()=>this._shouldEmitChange=!1,{capture:!0}),this.addEventListener?.(`keydown`,e=>{if(this._requiresEmptyPatch()&&this._assignValue(``),(e.key===`Enter`||e.key===`
43
+ `}}})();var Rn=class{get size(){return this._handlers.size}constructor(e,t){this._host=e,this._property=t,this._handlers=new Set,this._hostDefinedPromise=null,r||(customElements.get(this._host.localName)?customElements.upgrade(this._host):this._hostDefinedPromise=customElements.whenDefined(this._host.localName).then(()=>{customElements.upgrade(this._host),this._hostDefinedPromise=null})),this._value=this._host[this._property]}addHandler(e){this._handlers.size||(this._host.addController?this._host.addController(this):this._hostDefinedPromise&&this._hostDefinedPromise.then(()=>this._host.addController(this))),this._handlers.add(e),this._hostDefinedPromise?this._hostDefinedPromise.then(()=>e(this._host)):e(this._host)}removeHandler(e){this._handlers.delete(e),this._handlers.size||(this._host.removeController?this._host.removeController(this):this._hostDefinedPromise&&this._hostDefinedPromise.then(()=>this._host.removeController(this)))}hostUpdate(){let e=this._host[this._property];if(this._value!==e){this._value=e;for(let e of this._handlers)e(this._host)}}};const U=new WeakMap;var zn=class{constructor(e,t,n){this._host=e,this._referenceResolver=t,this._handlers=n,this._host.addController(this)}hostConnected(){this.connect()}hostDisconnected(){this._reference!==this._referenceResolver()&&this.disconnect()}connect(){let e=this._referenceResolver();if(this._reference===e||(this.disconnect(),this._reference=e,!this._reference))return;let t=U.get(this._reference);t||(t=new Map,U.set(this._reference,t)),this._watchers=t;for(let[e,t]of Object.entries(this._handlers)){let n=this._watchers.get(e);n||(n=new Rn(this._reference,e),this._watchers.set(e,n)),n.addHandler(t)}}disconnect(){if(this._reference){for(let[e,t]of Object.entries(this._handlers)){let n=this._watchers?.get(e);n&&(n.removeHandler(t),n.size||(this._watchers.delete(e),!this._watchers.size&&this._reference&&U.delete(this._reference)))}this._reference=null}}};const Bn=[];r||window.addEventListener(`keydown`,e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),Bn.at(-1)?.escapeStrategy())});var Vn=class{constructor(e,t=Bn){this._host=e,this._overlayStack=t,this._host.addController?.(this)}hostDisconnected(){this.disconnect()}connect(){this.disconnect(),this._overlayStack.push(this._host)}disconnect(){if(this._overlayStack.length){let e=this._overlayStack.findIndex(e=>e===this._host);e!==-1&&this._overlayStack.splice(e,1)}}};const Hn=new WeakMap;var Un=class{constructor(e,t,n=Hn){this._host=e,this._idRef=t,this._observers=n,this._rootNode=null,this._host.addController(this)}hostConnected(){if(r)return;this._rootNode=this._host.getRootNode();let e=this._observers.get(this._rootNode);if(e)e.controllers.add(this);else{let e=new Set([this]),t=new MutationObserver(t=>{let n=new Set;for(let e of t)if(e.type===`attributes`)n.add(e.oldValue),n.add(e.target.id);else if(e.type===`childList`)for(let t of[...e.addedNodes,...e.removedNodes])t instanceof HTMLElement&&(n.add(t.id),t.querySelectorAll(`[id]`).forEach(e=>n.add(e.id)));for(let t of e){let e=t._host[t._idRef];e&&typeof e==`string`&&n.has(e)&&t._host.requestUpdate()}});t.observe(this._rootNode,{attributeFilter:[`id`],childList:!0,subtree:!0,attributeOldValue:!0}),this._observers.set(this._rootNode,{observer:t,controllers:e})}}hostDisconnected(){if(r||!this._rootNode)return;let e=this._observers.get(this._rootNode);if(!e){this._rootNode=null;return}e.controllers.delete(this),e.controllers.size===0&&(e.observer.disconnect(),this._observers.delete(this._rootNode)),this._rootNode=null}find(){if(r||!this._rootNode)return null;{let e=this._host[this._idRef];return typeof e==`string`?this._rootNode?.getElementById(e):null}}};const Wn=[`script`,`head`,`template`,`style`],Gn=new Set,Kn=new Set,qn=new Set;var Jn=class{constructor(e,t=Gn,n=qn,r=Kn){this._host=e,this._inertElements=t,this._inertOverlays=n,this._exemptedElements=r,this._host.addController?.(this)}hostConnected(){this._host.isOpen&&this.activate()}hostDisconnected(){this.isInert()&&this.deactivate()}activate(){this._inertOverlays.size&&this._removeAllInertAttributes(),this._inertOverlays.add(this._host),this._addAllInertAttributes()}deactivate(){if(this._currentOverlay()!==this._host){this._inertOverlays.has(this._host)&&this._inertOverlays.delete(this._host);return}this._removeAllInertAttributes(),this._inertOverlays.delete(this._host),this._inertOverlays.size&&this._addAllInertAttributes()}isInert(){return this._inertOverlays.has(this._host)}exempt(e){this._inertElements.has(e)&&!this._exemptedElements.has(e)&&(this._removeInertAttributes(e),this._inertElements.delete(e),this._exemptedElements.add(e))}restoreAllExempted(){this._exemptedElements.forEach(e=>this._addInertAttributes(e)),this._exemptedElements.clear()}_currentOverlay(){return[...this._inertOverlays].pop()??null}_removeAllInertAttributes(){this._inertElements.forEach(e=>this._removeInertAttributes(e)),this._inertElements.clear()}_removeInertAttributes(e){e&&(e.hasAttribute(`data-sbb-inert`)&&(e.inert=!1,e.removeAttribute(`data-sbb-inert`)),e.hasAttribute(`data-sbb-aria-hidden`)&&(e.removeAttribute(`aria-hidden`),e.removeAttribute(`data-sbb-aria-hidden`)))}_addAllInertAttributes(){let e=this._currentOverlay();for(;e!==document.documentElement&&e!==null;)Array.from((e?.parentElement??e?.getRootNode())?.childNodes??[]).filter(t=>t!==e&&t instanceof window.HTMLElement&&!Wn.includes(t.localName)&&!t.classList.contains(`sbb-live-announcer-element`)).forEach(e=>{this._addInertAttributes(e)}),e=e?.parentElement??e?.getRootNode()?.host??null}_addInertAttributes(e){this._inertElements.add(e),e.inert||(e.inert=!0,e.toggleAttribute(`data-sbb-inert`,!0)),e.hasAttribute(`aria-hidden`)||(e.setAttribute(`aria-hidden`,`true`),e.toggleAttribute(`data-sbb-aria-hidden`,!0))}};const Yn=`(forced-colors: active)`,W=`(prefers-color-scheme: dark)`,Xn=`(any-hover: hover)`,Zn=`(pointer: coarse)`,Qn=`(min-width: 0rem)`,$n=`(min-width: 37.5rem)`,er=`(min-width: 64rem)`,tr=`(min-width: 90rem)`,nr=`(max-width: 63.9375rem)`,rr=`(max-width: 89.9375rem)`,G=new Map;var ir=class{constructor(e,t){this._queries=t,e.addController(this)}matches(e){return r?null:matchMedia(e).matches}hostConnected(){if(!r)for(let[e,t]of Object.entries(this._queries)){let n=G.get(e);if(n)n.handlers.add(t);else{let n=matchMedia(e),r=new Set([t]),i=e=>r.forEach(t=>t(e.matches));n.addEventListener(`change`,i),G.set(e,{mediaQueryList:n,handlers:r,eventHandler:i})}}}hostDisconnected(){for(let[e,t]of Object.entries(this._queries)){let n=G.get(e);n&&(n.handlers.delete(t),n.handlers.size||G.delete(e))}}},ar=class e extends ir{static{this._currentMode=this._readLightDarkClass()}static{this._observer=r?null:new MutationObserver(t=>{if(t[0].oldValue!==document.documentElement.getAttribute(`class`)){let t=this._readLightDarkClass();this._currentMode!==t&&(e.requestUpdate(),this._currentMode=t)}})}static{this._observerConfig={attributeFilter:[`class`],attributeOldValue:!0}}constructor(e,t){let n=()=>{t(this.matches()),this._host.toggleState?.(`dark`,this.matches())};super(e,{[W]:n}),this._host=e,this._onChangeWithStateUpdater=n}static _readLightDarkClass(){if(r)return null;let e=document.documentElement.classList;return[`sbb-light-dark`,`sbb-dark`,`sbb-light`].find(t=>e.contains(t))??null}static requestUpdate(){let e=G.get(W);e&&e.handlers.forEach(t=>t(e.mediaQueryList.matches))}hostConnected(){let t=(G.get(`(prefers-color-scheme: dark)`)?.handlers.size??0)===0;super.hostConnected(),t&&e._observer.observe(document.documentElement,e._observerConfig),this._onChangeWithStateUpdater()}hostDisconnected(){super.hostDisconnected(),(G.get(`(prefers-color-scheme: dark)`)?.handlers.size??0)===0&&e._observer.disconnect()}matches(){if(r)return!1;let e=getComputedStyle(this._host).getPropertyValue(`color-scheme`),t=e.includes(`dark`),n=e.trim()===`dark`;return super.matches(`(prefers-color-scheme: dark)`)&&t||n}};const or=!r&&CSS.supports(`anchor-name`,`--test`),sr=[`top`,`bottom`,`left`,`right`,`top span-left`,`top span-right`,`bottom span-left`,`bottom span-right`,`left span-top`,`left span-bottom`,`right span-top`,`right span-bottom`],cr=[`block-start`,`block-end`,`inline-start`,`inline-end`,`block-start span-inline-start`,`block-start span-inline-end`,`block-end span-inline-start`,`block-end span-inline-end`,`inline-start span-block-start`,`inline-start span-block-end`,`inline-end span-block-start`,`inline-end span-block-end`],lr={"block-start":`block-start`,"block-end":`block-end`,"inline-start":`inline-end`,"inline-end":`inline-start`,"block-start span-inline-start":`block-start span-inline-end`,"block-start span-inline-end":`block-start span-inline-start`,"block-end span-inline-start":`block-end span-inline-end`,"block-end span-inline-end":`block-end span-inline-start`,"inline-start span-block-start":`inline-end span-block-start`,"inline-start span-block-end":`inline-end span-block-end`,"inline-end span-block-start":`inline-start span-block-start`,"inline-end span-block-end":`inline-start span-block-end`};[...sr,...cr];let ur=0;var dr=class{get currentPosition(){return this._usePolyfill?this._lastPosition??this._positions[0]??``:(this._overlayStyles??=getComputedStyle(this._overlay),this._overlayStyles.getPropertyValue(`position-area`))}constructor(e,t=!or){this._usePolyfill=t,this._resizeObserver=r?null:new ResizeObserver(()=>this._requestCalculatePosition()),this._anchorName=`--sbb-overlay-anchor-${++ur}`,this._positions=[],e.addController(this),this._overlay=e}hostConnected(){this._usePolyfill?this._overlay.style.setProperty(`position-area`,`initial`):this._overlay.style.setProperty(`position-anchor`,this._anchorName)}hostUpdate(){r||this._readPositionsFromCss()}connect(e){r||(this._anchor&&this.disconnect(),this._anchor=e,this._usePolyfill||this._anchor.style.setProperty(`anchor-name`,this._anchorName),this._readPositionsFromCss(),this._calculatePosition(),this._abortController?.abort(),this._abortController=new AbortController,document.addEventListener(`scroll`,()=>this._requestCalculatePosition(),{capture:!0,passive:!0,signal:this._abortController.signal}),window.addEventListener(`resize`,()=>this._requestCalculatePosition(),{passive:!0,signal:this._abortController.signal}),this._resizeObserver.observe(e,{box:`border-box`}),this._resizeObserver.observe(this._overlay,{box:`border-box`}))}disconnect(){this._anchor?.style.removeProperty(`anchor-name`),this._anchor=void 0,this._abortController?.abort(),this._resizeObserver.disconnect()}_requestCalculatePosition(){this._frame??=requestAnimationFrame(()=>{this._calculatePosition(),this._frame=void 0})}_calculatePosition(){if(this._anchor){if(this._usePolyfill){let e=this._getOptimalPosition(this._positions);this._applyOverlayPosition(e.position,e.left,e.top)}this._overlay.setAttribute(`data-position`,this.currentPosition)}}_getOptimalPosition(e){let{offsetHeight:t,offsetWidth:n}=this._overlay,{innerHeight:r,innerWidth:i}=window,{top:a,left:o,height:s,width:c}=this._anchor.getBoundingClientRect(),l=this._overlay.matches(`:dir(rtl)`),u=a,d=r-s-a,f=o,p=i-c-o,m=n-c,h=t-s,g=m/2,_=h/2;this._overlay.style.setProperty(`--sbb-overlay-controller-trigger-height`,`${s}px`),this._overlay.style.setProperty(`--sbb-overlay-controller-trigger-width`,`${c}px`);let v={left:0,top:0,position:``},y;for(let r of e){switch(l&&cr.includes(r)?lr[r]:r){default:case`bottom`:case`block-end`:v={position:r,left:o-g,top:a+s,fits:t<=d&&g<=f&&g<=p};break;case`top`:case`block-start`:v={position:r,left:o-g,top:a-t,fits:t<=u&&g<=f&&g<=p};break;case`right`:case`inline-end`:v={position:r,left:o+c,top:a-_,fits:n<=p&&_<=u&&_<=d};break;case`left`:case`inline-start`:v={position:r,left:o-n,top:a-_,fits:n<=f&&_<=u&&_<=d};break;case`top span-left`:case`block-start span-inline-start`:v={position:r,left:o-m,top:a-t,fits:t<=u&&m<=f};break;case`top span-right`:case`block-start span-inline-end`:v={position:r,left:o,top:a-t,fits:t<=u&&m<=p};break;case`bottom span-left`:case`block-end span-inline-start`:v={position:r,left:o-m,top:a+s,fits:t<=d&&m<=f};break;case`bottom span-right`:case`block-end span-inline-end`:v={position:r,left:o,top:a+s,fits:t<=d&&m<=p};break;case`left span-top`:case`inline-start span-block-start`:v={position:r,left:o-n,top:a+s-t,fits:n<=f&&h<=u};break;case`left span-bottom`:case`inline-start span-block-end`:v={position:r,left:o-n,top:a,fits:n<=f&&h<=d};break;case`right span-top`:case`inline-end span-block-start`:v={position:r,left:o+c,top:a+s-t,fits:n<=p&&h<=u};break;case`right span-bottom`:case`inline-end span-block-end`:v={position:r,left:o+c,top:a,fits:n<=p&&h<=d}}if(v.fits)return v;y??=v}return y}_applyOverlayPosition(e,t,n){this._lastPosition=e,this._overlay.style.left=`${t}px`,this._overlay.style.top=`${n}px`}_readPositionsFromCss(){if(!this._usePolyfill)return;this._overlayStyles??=getComputedStyle(this._overlay);let e=[this._overlayStyles.getPropertyValue(`--sbb-overlay-position-area`)||`block-end`,...this._overlayStyles.getPropertyValue(`--sbb-overlay-position-try-fallbacks`).split(`,`).map(e=>e.trim()).filter(e=>!!e)];this._positions=e,this._lastPosition&&!this._positions.includes(this._lastPosition)&&(this._lastPosition=void 0)}};const fr=/(0?[1-9]|[12][0-9]|3[01])[.,\\/\-\s](0?[1-9]|1[0-2])[.,\\/\-\s]([0-9]{1,4}$)?/,pr=/^([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-3][0-9])$/,mr=1,hr=2,gr=3,_r=4,vr=5,yr=6,br=0;var K=class{constructor(e=15){this._cutoffYearOffset=e}deserialize(e){return e==null||this.isDateInstance(e)&&this.isValid(e)?e:this.invalid()}parse(e){if(!e)return null;let t=null,n=e.match(pr);try{t=n?this.createDate(+n[1],+n[2],+n[3]):null}catch{}if(this.isValid(t))return t;let r=e.replace(/\D/g,` `).trim()?.match(fr);if(!r||r.index!==0||r.length<=2||r.some(e=>e===void 0)||!this.isValid(this.createDate(+r[3],+r[2],+r[1])))return null;let i=+r[3];if(typeof i==`number`&&i<100&&i>=0){let e=this.getYear(this.today())-2e3+this._cutoffYearOffset;i=i<=e?2e3+i:1900+i}return this.createDate(i,+r[2],+r[1])}format(e,t){if(!this.isValid(e))return``;let n=new Date(this.toIso8601(e)+`T00:00:00`),r=new Intl.DateTimeFormat(`de-CH`,{day:`2-digit`,month:`2-digit`,year:`numeric`});if(t?.weekdayStyle===`none`)return r.format(n);let i=t?.weekdayStyle??`short`,a=this.getDayOfWeekNames(i)[this.getDayOfWeek(e)];return a=a.charAt(0).toUpperCase()+a.substring(1),i===`short`&&(a=a.substring(0,2)),`${a}, ${r.format(n)}`}toIso8601(e){let t=(e,t=2)=>`${e}`.padStart(t,`0`);return`${t(this.getYear(e),4)}-${t(this.getMonth(e))}-${t(this.getDate(e))}`}getValidDateOrNull(e){return this.isDateInstance(e)&&this.isValid(e)?e:null}getFirstWeekOffset(e){let t=this.createDate(this.getYear(e),this.getMonth(e),1);return(7+this.getDayOfWeek(t)-this.getFirstDayOfWeek())%7}compareDate(e,t){return this.getYear(e)-this.getYear(t)||this.getMonth(e)-this.getMonth(t)||this.getDate(e)-this.getDate(t)}sameDate(e,t){if(e&&t){let n=this.isValid(e),r=this.isValid(t);return n&&r?!this.compareDate(e,t):n==r}return e==t}clampDate(e,t,n){return t&&this.compareDate(e,t)<0?t:n&&this.compareDate(e,n)>0?n:e}};const xr=/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;var Sr=class extends K{getYear(e){return e.getFullYear()}getMonth(e){return e.getMonth()+1}getDate(e){return e.getDate()}getDayOfWeek(e){return e.getDay()}getAccessibilityFormatDate(e){return new Intl.DateTimeFormat(z.current,{year:`numeric`,month:`long`,day:`numeric`}).format(new Date(e))}getMonthNames(e){let t=new Intl.DateTimeFormat(z.current,{month:e});return this._range(12,e=>t.format(new Date(2017,e,1)))}getDateNames(){let e=new Intl.DateTimeFormat(z.current,{day:`numeric`});return this._range(31,t=>e.format(new Date(2017,0,t+1)))}getDayOfWeekNames(e){let t=new Intl.DateTimeFormat(z.current,{weekday:e});return this._range(7,e=>t.format(new Date(2017,0,e+1)))}getFirstDayOfWeek(){return 1}getNumDaysInMonth(e){return this.getDate(this._createDateWithOverflow(this.getYear(e),this.getMonth(e),0))}today(){return new Date(new Date().setHours(0,0,0,0))}createDate(e,t,n){if(t<1||t>12)throw Error(`Invalid month "${t}". Month has to be between 1 and 12.`);if(n<1)throw Error(`Invalid day "${n}". Day has to be greater than 0.`);let r=this._createDateWithOverflow(e,t-1,n);if(r.getMonth()+1!==t)throw Error(`Invalid day "${n}" for month "${t}".`);return r}isDateInstance(e){return e instanceof Date}isValid(e){return!!e&&!isNaN(e.valueOf())}clone(e){return new Date(e.valueOf())}addCalendarYears(e,t){return this.addCalendarMonths(e,t*12)}addCalendarMonths(e,t){let n=e.getMonth()+t,r=new Date(e.getFullYear(),n,1,0,0,0,0),i=this.getNumDaysInMonth(r);return new Date(this.clone(e).setMonth(n,Math.min(i,e.getDate())))}addCalendarDays(e,t){let n=e.getDate()+t;return new Date(e.getFullYear(),e.getMonth(),n,0,0,0,0)}deserialize(e){if(typeof e==`string`){if(!e)return null;if(xr.test(e))return this.getValidDateOrNull(new Date(e.includes(`T`)?e:e+`T00:00:00`))}return super.deserialize(e)}invalid(){return new Date(NaN)}_range(e,t){return Array.from({length:e},(e,n)=>t(n))}_createDateWithOverflow(e,t,n){let r=new Date(e,t,n);return e>=0&&e<100&&r.setFullYear(this.getYear(r)-1900),r}};const q=new Sr,Cr=/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;var wr=class extends K{constructor(e){if(super(e),typeof Temporal!=`object`)throw Error(`Temporal is not available in the current environment. Please make sure to include the temporal polyfill.`)}getYear(e){return e.year}getMonth(e){return e.month}getDate(e){return e.day}getDayOfWeek(e){return e.dayOfWeek%7}getAccessibilityFormatDate(e){return this.deserialize(e).toLocaleString(z.current,{year:`numeric`,month:`long`,day:`numeric`})}getMonthNames(e){let t=new Intl.DateTimeFormat(z.current,{month:e});return this._range(12,e=>t.format(Temporal.PlainDate.from({year:2017,month:e+1,day:1})))}getDateNames(){let e=new Intl.DateTimeFormat(z.current,{day:`numeric`});return this._range(31,t=>e.format(Temporal.PlainDate.from({year:2017,month:1,day:t+1})))}getDayOfWeekNames(e){let t=new Intl.DateTimeFormat(z.current,{weekday:e});return this._range(7,e=>t.format(Temporal.PlainDate.from({year:2017,month:1,day:e+1})))}getFirstDayOfWeek(){return 1}getNumDaysInMonth(e){return e.daysInMonth}today(){return Temporal.Now.plainDateISO()}createDate(e,t,n){if(t<1||t>12)throw Error(`Invalid month "${t}". Month has to be between 1 and 12.`);if(n<1)throw Error(`Invalid day "${n}". Day has to be greater than 0.`);try{return Temporal.PlainDate.from({year:e,month:t,day:n},{overflow:`reject`})}catch{throw Error(`Invalid date "${n}" for month with index "${t}".`)}}isDateInstance(e){return e instanceof Temporal.PlainDate}isValid(e){return this.isDateInstance(e)}clone(e){return Temporal.PlainDate.from(e)}addCalendarYears(e,t){return e.add({years:t})}addCalendarMonths(e,t){return e.add({months:t})}addCalendarDays(e,t){return e.add({days:t})}deserialize(e){if(typeof e==`string`){if(!e)return null;if(Cr.test(e))return this.getValidDateOrNull(Temporal.PlainDate.from(e.split(`T`)[0]))}return super.deserialize(e)}invalid(){return null}toIso8601(e){return e.toJSON()}_range(e,t){return Array.from({length:e},(e,n)=>t(n))}};const Tr=e=>(t,n)=>{let{kind:r}=n;if(r===`accessor`)return{get(){let n=t.get.call(this);return e(this,n)}};throw Error(`Unsupported decorator location: ${r}`)},Er=e=>(t,n)=>{let{kind:r}=n;if(r===`accessor`)return{set(r){let i=n.access.get(this);t.set.call(this,r);let a=n.access.get(this);a!==i&&e(this,a,i)}};throw Error(`Unsupported decorator location: ${r}`)},J=new WeakMap,Y=new WeakMap,Dr=()=>(e,t)=>{let{kind:n,metadata:i,name:a}=t;if(n===`accessor`){if(r)return{};let n=globalThis.litPropertyMetadata.get(i)?.get(a)?.attribute,o=typeof n==`string`?n:a;return t.addInitializer(function(){this.addController({host:this,rootNode:null,checkIdReference(e){let n=this.host.getAttribute(o)??Y.get(this.host);if(n&&typeof n==`string`&&(!e||e.has(n))){let e=this.rootNode?.getElementById?.(n)??null;t.access.get(this.host)!==e&&t.access.set(this.host,e)}},hostConnected(){this.rootNode=this.host.getRootNode(),this.checkIdReference();let e=J.get(this.rootNode);if(e)e.controllers.add(this);else{let e=new Set([this]),t=new MutationObserver(t=>{let n=new Set;for(let e of t)if(e.type===`attributes`)e.oldValue&&n.add(e.oldValue),e.target.id&&n.add(e.target.id);else if(e.type===`childList`)for(let t of[...e.addedNodes,...e.removedNodes])t instanceof HTMLElement&&(t.id&&n.add(t.id),t.querySelectorAll(`[id]`).forEach(e=>{e.id&&n.add(e.id)}));e.forEach(e=>e.checkIdReference(n))});t.observe(this.rootNode,{attributeFilter:[`id`],attributeOldValue:!0,childList:!0,subtree:!0}),J.set(this.rootNode,{observer:t,controllers:e})}},hostDisconnected(){if(r||!this.rootNode)return;let e=J.get(this.rootNode);if(!e){this.rootNode=null;return}e.controllers.delete(this),e.controllers.size===0&&(e.observer.disconnect(),J.delete(this.rootNode)),this.rootNode=null}})}),{set(t){if(typeof t!=`string`)Y.delete(this),t instanceof HTMLElement&&this.hasAttribute(o)&&t.id!==this.getAttribute(o)&&this.removeAttribute(o);else if(this.hasAttribute(o)&&this.getAttribute(o)!==t)return;else{let e=t?this.getRootNode?.()?.getElementById?.(t):null;e?t=e:t&&=(Y.set(this,t),null)}e.set.call(this,t)}}}throw Error(`Unsupported decorator location: ${n}`)},Or={toAttribute(e,t){let n=R().datetime?.dateAdapter??q;return n.isValid(e)?n.toIso8601(e):null}},kr=e=>(t,n)=>{let{kind:r}=n;if(r===`accessor`)return{set(e){let n=R().datetime?.dateAdapter??q;e=n.getValidDateOrNull(n.deserialize(e)),e=e?n.createDate(n.getYear(e),n.getMonth(e),n.getDate(e)):null,t.set.call(this,e)},get(){let n=R().datetime?.dateAdapter??q,r=t.get.call(this);return n.isValid(r)?n.clone(r):e?.fallback?.(n)}};throw Error(`Unsupported decorator location: ${r}`)};function Ar(e,t){if(r||globalThis.disableAnimation)return!0;let n=getComputedStyle(e).getPropertyValue(t);return parseFloat(n)===0}function X(e,t){let n=t;for(;n;){if(n===e)return!0;n=n instanceof ShadowRoot?n.host:n.parentNode}return!1}function jr(e,t,n){n?e.setAttribute(t,n):e.removeAttribute(t)}function Mr(e){let t=()=>queueMicrotask(e);document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,t):t()}function Z(){return document.body.hasAttribute(`data-sbb-scroll-disabled`)}var Nr=class{disableScroll(){if(Z())return;this._height=document.body.style.height,this._position=document.body.style.position,this._overflow=document.body.style.overflow,this._marginInlineEnd=document.body.style.marginInlineEnd;let e=window.innerWidth-document.documentElement.clientWidth;document.body.style.overflow=`hidden`,document.body.style.height=`100dvh`,document.body.style.position=`relative`,document.body.style.marginInlineEnd=`${e}px`,document.body.style.setProperty(`--sbb-scrollbar-width`,`${e}px`),document.body.toggleAttribute(`data-sbb-scroll-disabled`,!0)}enableScroll(){Z()&&(document.body.style.height=this._height||``,document.body.style.position=this._position||``,document.body.style.overflow=this._overflow||``,document.body.style.marginInlineEnd=this._marginInlineEnd||``,document.body.style.setProperty(`--sbb-scrollbar-width`,`0`),document.body.removeAttribute(`data-sbb-scroll-disabled`))}};function Pr(e){e.key===` `&&e.preventDefault()}function Fr(e,t){let n=Object.getPrototypeOf(e).constructor,r=new n(e.type,e);t.dispatchEvent(r)}const Ir=e=>{class t extends e{constructor(){super(...arguments),this.isAnimating=!1,this._animationPromise=Promise.resolve()}get animationComplete(){return this._animationPromise}disconnectedCallback(){super.disconnectedCallback(),this.stopAnimation()}startAnimation(){this.isAnimating||(this._animationPromise=this._enqueueAnimation())}stopAnimation(){}async _enqueueAnimation(){this.isAnimating=!0;let e=this.stopAnimation,t=new Promise(t=>{this.stopAnimation=()=>{e(),this.isAnimating=!1,t()}});try{await this._animationPromise}catch(e){Promise.reject(e)}return t}}return t},Lr=e=>(()=>{let n=V(H(L(e))),r=[],i;return class extends n{static{let e=typeof Symbol==`function`&&Symbol.metadata?Object.create(n[Symbol.metadata]??null):void 0;i=[l({type:Boolean,converter:{...t,fromAttribute:(e,n)=>({value:t.fromAttribute?.(e,n),attribute:!0})}})],o(this,null,i,{kind:`setter`,name:`checked`,static:!1,private:!1,access:{has:e=>`checked`in e,set:(e,t)=>{e.checked=t}},metadata:e},null,r),e&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}static{this.role=`checkbox`}set checked(e){let t=typeof e==`object`&&e.attribute;t&&(e=e.value),this.hasUpdated&&!t&&(this._attributeMutationBlocked=!0),this._checked=!!e,this.updateFormValue()}get checked(){return this._checked}get type(){return`checkbox`}constructor(){super(),this._attributeMutationBlocked=(s(this,r),!1),this._languageController=new z(this),this._checked=!1,this._handleKeyboardInteraction=e=>{e.key===` `&&this._handleUserInteraction()},this._handleUserInteraction=()=>{this.disabled||(this.withUserInteraction?.(),this.checked=!this.checked,this._attributeMutationBlocked=!0,this.dispatchEvent(new InputEvent(`input`,{composed:!0,bubbles:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},this.addEventListener?.(`click`,this._handleUserInteraction),this.addEventListener?.(`keydown`,Pr),this.addEventListener?.(`keyup`,this._handleKeyboardInteraction)}connectedCallback(){super.connectedCallback(),this.tabIndex=0}attributeChangedCallback(e,t,n){(e!==`checked`||!this._attributeMutationBlocked)&&super.attributeChangedCallback(e,t,n)}formResetCallback(){this.checked=this.hasAttribute(`checked`),this._attributeMutationBlocked=!1}formStateRestoreCallback(e,t){e&&(this.checked=e===`true`)}updateFormValue(){this.checked?super.updateFormValue():this.internals.setFormValue(null)}formState(){return`${this.checked}`}shouldValidate(e){return super.shouldValidate(e)||e===`checked`||e===`required`}validate(){super.validate(),this.required&&!this.checked?this.setValidityFlag(`valueMissing`,fn[this._languageController.current]):this.removeValidityFlag(`valueMissing`)}}})(),Rr=e=>(()=>{let t=e,n=[],r;return class extends t{static{let e=typeof Symbol==`function`&&Symbol.metadata?Object.create(t[Symbol.metadata]??null):void 0;r=[l({type:Boolean,attribute:`readonly`})],o(this,null,r,{kind:`setter`,name:`readOnly`,static:!1,private:!1,access:{has:e=>`readOnly`in e,set:(e,t)=>{e.readOnly=t}},metadata:e},null,n),e&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}set readOnly(e){this.#e=!!e,this.toggleAttribute(`readonly`,this.#e)}get readOnly(){return this.#e}#e=(s(this,n),!1)}})(),zr=(()=>{if(r)return!1;let e=document.createElement(`div`);return e.setAttribute(`contenteditable`,`PLAINTEXT-ONLY`),e.contentEditable===`plaintext-only`})(),Br=e=>(()=>{let t=Rr(V(H(L(e)))),i=[],a,u,d;return class extends t{static{let e=typeof Symbol==`function`&&Symbol.metadata?Object.create(t[Symbol.metadata]??null):void 0;a=[l()],u=[l({attribute:!1})],d=[c({passive:!0})],o(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:e},null,i),o(this,null,u,{kind:`setter`,name:`placeholder`,static:!1,private:!1,access:{has:e=>`placeholder`in e,set:(e,t)=>{e.placeholder=t}},metadata:e},null,i),o(this,null,d,{kind:`method`,name:`_cleanChildren`,static:!1,private:!1,access:{has:e=>`_cleanChildren`in e,get:e=>e._cleanChildren},metadata:e},null,i),e&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}static{this.role=`textbox`}static{this.formFieldAssociated=!0}get type(){return`text`}set value(e){this._value=this._cleanText(e),this.hasUpdated&&this._assignValue(this._value),this.dispatchEvent(new Event(`displayvaluechange`,{bubbles:!0,composed:!0}))}get value(){return this._value??``}set placeholder(e){e?this.setAttribute(`placeholder`,e):this.removeAttribute(`placeholder`),this.internals.ariaPlaceholder=e||null}get placeholder(){return this.getAttribute(`placeholder`)??``}constructor(){super(),this._shouldEmitChange=(s(this,i),!1),this._shouldTriggerSubmit=!1,this.language=new z(this),this._value=``,this.addEventListener?.(`input`,()=>{let e=this._value;this._value=this._cleanText(this.textContent??``),this.requestUpdate(`value`,e),this.internals.states.add(`interacted`),this._shouldEmitChange=!0},{capture:!0}),this.addEventListener?.(`change`,()=>this._shouldEmitChange=!1,{capture:!0}),this.addEventListener?.(`keydown`,e=>{if(this._requiresEmptyPatch()&&this._assignValue(``),(e.key===`Enter`||e.key===`
44
44
  `)&&e.isTrusted)e.preventDefault(),e.stopImmediatePropagation(),this._shouldTriggerSubmit=this.dispatchEvent(new KeyboardEvent(`keydown`,e));else if(A&&this.value&&(e.key===`Backspace`||e.key===`Delete`)&&e.isTrusted){if(e.preventDefault(),e.stopImmediatePropagation(),!this.dispatchEvent(new KeyboardEvent(`keydown`,e)))return;let t=window.getSelection()?.getRangeAt(0);if(!t)return;t.startOffset===t.endOffset?e.key===`Backspace`&&t.startOffset>0?(t.setStart(t.startContainer,t.startOffset-1),t.deleteContents(),this._dispatchInputEvent()):e.key===`Delete`&&t.endOffset<this.value.length&&(t.setEnd(t.endContainer,t.endOffset+1),t.deleteContents(),this._dispatchInputEvent()):(t.deleteContents(),this._dispatchInputEvent())}},{capture:!0}),this.addEventListener?.(`keyup`,e=>{e.key===`Enter`||e.key===`
45
45
  `?(this._emitChangeIfNecessary(),this._shouldTriggerSubmit&&(this._shouldTriggerSubmit=!1,this.form?.requestSubmit())):this._requiresEmptyPatch()&&this._setCursorAt(0)},{capture:!0}),this.addEventListener?.(`paste`,e=>{e.preventDefault(),this._requiresEmptyPatch()&&this._assignValue(``);let t=this._cleanText(e.clipboardData?.getData(`text/plain`)??``),n=window.getSelection()?.getRangeAt(0);!n||!t||(n.deleteContents(),n.insertNode(document.createTextNode(this.preparePastedText(t))),n.setStart(n.endContainer,n.endOffset),this._dispatchInputEvent())}),this.addEventListener?.(`focus`,()=>{T.mostRecentModality===`keyboard`&&window.getSelection()?.selectAllChildren(this)}),this.addEventListener?.(`touchend`,()=>{this._requiresEmptyPatch()&&(this._assignValue(`&nbsp;`),this._setCursorAt(0))}),this.addEventListener?.(`click`,()=>{this._requiresEmptyPatch()&&T.mostRecentModality===`touch`&&this._setCursorAt(0)}),this.addEventListener?.(`blur`,()=>{window.getSelection()?.removeAllRanges(),this.value===``&&this._assignValue(``),this._emitChangeIfNecessary(),this.scrollLeft=0},{capture:!0})}isDisabledExternally(){return this.formDisabled}connectedCallback(){super.connectedCallback(),this.internals.ariaMultiLine=`false`,this._updateContenteditable(),this._assignValue(this.value)}focus(e){if(super.focus(e),this._canSelect()){let e=window.getSelection();if(!e)return;let t=e.rangeCount>0?e.getRangeAt(0):null;if(t&&t.startOffset!==0)return;this._setCursorAt(this.textContent.length)}}attributeChangedCallback(e,t,n){(e!==`value`||!this.matches?.(`:is(:state(interacted),[state--interacted])`))&&super.attributeChangedCallback(e,t,n)}formResetCallback(){this.internals.states.delete(`interacted`),this.value=this.getAttribute(`value`)??``}formStateRestoreCallback(e,t){e&&typeof e==`string`&&(this.value=e)}select(){window.getSelection()?.selectAllChildren(this)}firstUpdated(e){super.firstUpdated(e),this.value&&!this.innerHTML.length&&this._assignValue(this.value)}requestUpdate(e,t,n){super.requestUpdate(e,t,n),this.isConnected&&(e===`disabled`||e===`formDisabled`||e===`readOnly`)&&this._updateContenteditable()}shouldValidate(e){return super.shouldValidate(e)||e===`value`||e===`required`}validate(){super.validate(),this.required&&!this.value?this.setValidityFlag(`valueMissing`,mn[this.language.current]):this.removeValidityFlag(`valueMissing`)}isSelected(){if(r)return!1;let e=window.getSelection();return!!e&&e.rangeCount>0&&this.contains(e.anchorNode)}preparePastedText(e){return e}_requiresEmptyPatch(){return!r&&k&&this.value===``&&window.matchMedia(`(pointer: coarse)`).matches}_assignValue(e){this.innerHTML=e}_setCursorAt(e){let t=window.getSelection();if(!this.firstChild||!t)return;let n=document.createRange();n.setStart(this.firstChild,e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}_cleanText(e){return e===null?``:`${e}`.replace(/[\n\r]+/g,``)}_dispatchInputEvent(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0}))}_cleanChildren(){if(this.childElementCount)for(let e of this.children)e.remove()}_updateContenteditable(){if(!r&&this.isConnected){this.internals.ariaReadOnly=this.readOnly?`true`:null,this.internals.ariaDisabled=this.disabled?`true`:null;let e=this.disabled||this.readOnly?`false`:zr?`plaintext-only`:`true`;this.setAttribute(`contenteditable`,e),this.readOnly?this.setAttribute(`tabindex`,`0`):this.removeAttribute(`tabindex`)}}_emitChangeIfNecessary(){this._shouldEmitChange&&(this._shouldEmitChange=!1,this.dispatchEvent(new Event(`change`,{bubbles:!0})))}_canSelect(){return!r&&!this.disabled&&!this.readOnly&&!!this.value}render(){return n`<slot @slotchange=${this._cleanChildren}></slot>`}}})(),Q=new WeakMap,Vr=e=>(()=>{let t=V(H(L(e))),n=[],i,a;return class extends t{static{let e=typeof Symbol==`function`&&Symbol.metadata?Object.create(t[Symbol.metadata]??null):void 0;i=[l({type:Boolean})],a=[l()],o(this,null,i,{kind:`setter`,name:`checked`,static:!1,private:!1,access:{has:e=>`checked`in e,set:(e,t)=>{e.checked=t}},metadata:e},null,n),o(this,null,a,{kind:`setter`,name:`name`,static:!1,private:!1,access:{has:e=>`name`in e,set:(e,t)=>{e.name=t}},metadata:e},null,n),e&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}static{this.role=`radio`}set checked(e){this._checked=!!e,this.toggleState(`checked`,this.checked),this.internals.ariaChecked=this.checked.toString(),this.updateFormValue(),this._synchronizeGroupState()}get checked(){return this._checked}set name(e){let t=this.name;e!==t&&(super.name=e,this._disconnectFromRegistry(t),this._connectToRegistry(),this._synchronizeGroupState())}get name(){return super.name}get type(){return`radio`}constructor(){super(),this._checked=(s(this,n),!1),this._languageController=new z(this),this.addEventListener?.(`keydown`,e=>this._handleArrowKeyDown(e))}connectedCallback(){super.connectedCallback(),this._connectToRegistry(),this._synchronizeGroupState()}disconnectedCallback(){super.disconnectedCallback(),this._disconnectFromRegistry(this.name)}formResetCallback(){this.checked=this.hasAttribute(`checked`)}formStateRestoreCallback(e,t){typeof e==`string`||e==null?this.checked=e===this.value:e instanceof FormData&&this._readFormData(e).then(e=>{this.checked=e===this.value})}async _readFormData(e){let t=e.get(this.name);return t instanceof Blob?JSON.parse(await t.text()):t}willUpdate(e){super.willUpdate(e),e.has(`disabled`)&&this.updateFocusableRadios()}firstUpdated(e){super.firstUpdated(e),this.updateFocusableRadios()}updateFormValue(){this.checked?super.updateFormValue():this.internals.setFormValue(null)}shouldValidate(e){return super.shouldValidate(e)||e===`checked`||e===`required`}validate(){if(super.validate(),!this.associatedRadioButtons)return;let e=!1,t=!1;for(let n of this.associatedRadioButtons)e||=n.required,t||=n.checked;e&&!t?this.associatedRadioButtons.forEach(e=>e.setValidityFlag(`valueMissing`,pn[this._languageController.current])):this.associatedRadioButtons.forEach(e=>e.removeValidityFlag(`valueMissing`))}updateFocusableRadios(){if(!this.hasUpdated)return;let e=this._interactableGroupedRadios(),t=e.findIndex(e=>e.checked&&!e.disabled&&!e.formDisabled),n=t===-1?e.findIndex(e=>!e.disabled&&!e.formDisabled):t;n!==-1&&(e[n].tabIndex=0,e.splice(n,1)),e.forEach(e=>e.removeAttribute(`tabindex`))}async navigateByKeyboard(e){e.checked=!0,this.emitChangeEvents(),await e.updateComplete,e.focus()}emitChangeEvents(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_synchronizeGroupState(){this.checked&&this._deselectGroupedRadios(),this.updateFocusableRadios()}_connectToRegistry(){if(!this.name||r)return;let e=this.form??this.getRootNode();this._radioButtonGroupsMap=Q.get(e),this._radioButtonGroupsMap||(this._radioButtonGroupsMap=new Map,Q.set(e,this._radioButtonGroupsMap)),this.associatedRadioButtons=this._radioButtonGroupsMap.get(this.name),this.associatedRadioButtons||(this.associatedRadioButtons=new Set,this._radioButtonGroupsMap.set(this.name,this.associatedRadioButtons));let t=Array.from(this.associatedRadioButtons);this.associatedRadioButtons.clear();let n=t.findIndex(e=>this.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING);n===-1?t.push(this):t.splice(n,0,this),t.forEach(e=>this.associatedRadioButtons.add(e)),this.validate()}_disconnectFromRegistry(e){this.associatedRadioButtons?.delete(this),this.associatedRadioButtons?.size===0?this._radioButtonGroupsMap?.delete(e):this.validate(),this.associatedRadioButtons=void 0,this._radioButtonGroupsMap=void 0}_interactableGroupedRadios(){return Array.from(this.associatedRadioButtons??[]).filter(e=>M.isVisible(e))}_deselectGroupedRadios(){Array.from(this.associatedRadioButtons??[]).filter(e=>e!==this).forEach(e=>e.checked=!1)}async _handleArrowKeyDown(e){if(!p(e))return;e.preventDefault();let t=this._interactableGroupedRadios().filter(e=>!e.disabled&&!e.formDisabled),n=y(e,t.indexOf(this),t.length);await this.navigateByKeyboard(t[n])}}})();var Hr=`:is(.sbb-scrollbar,.sbb-scrollbar-negative,.sbb-scrollbar-thick,.sbb-scrollbar-thick-negative,.sbb-scrollbar-track-visible,.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-track-visible,.sbb-scrollbar-thick-negative-track-visible){--sbb-scrollbar-width:var(--sbb-spacing-fixed-3x);--sbb-scrollbar-thumb-width:.125rem;--sbb-scrollbar-thumb-width-hover:.25rem;--sbb-scrollbar-width-firefox:thin;--sbb-scrollbar-color:light-dark(color-mix(in srgb, var(--sbb-color-black) 30%, transparent),color-mix(in srgb, var(--sbb-color-white) 30%, transparent));--sbb-scrollbar-color-hover:light-dark(color-mix(in srgb, var(--sbb-color-black) 60%, transparent),color-mix(in srgb, var(--sbb-color-white) 60%, transparent));--sbb-scrollbar-track-color:transparent}:is(.sbb-scrollbar,.sbb-scrollbar-negative,.sbb-scrollbar-thick,.sbb-scrollbar-thick-negative,.sbb-scrollbar-track-visible,.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-track-visible,.sbb-scrollbar-thick-negative-track-visible)::-webkit-scrollbar{width:var(--sbb-scrollbar-width);height:var(--sbb-scrollbar-width);background-color:var(--sbb-scrollbar-track-color,transparent)}:is(.sbb-scrollbar,.sbb-scrollbar-negative,.sbb-scrollbar-thick,.sbb-scrollbar-thick-negative,.sbb-scrollbar-track-visible,.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-track-visible,.sbb-scrollbar-thick-negative-track-visible)::-webkit-scrollbar-corner{background-color:var(--sbb-scrollbar-track-color,transparent)}:is(.sbb-scrollbar,.sbb-scrollbar-negative,.sbb-scrollbar-thick,.sbb-scrollbar-thick-negative,.sbb-scrollbar-track-visible,.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-track-visible,.sbb-scrollbar-thick-negative-track-visible)::-webkit-scrollbar-thumb{background-color:var(--sbb-scrollbar-color,currentcolor);border:calc(.5 * (var(--sbb-scrollbar-width) - var(--sbb-scrollbar-thumb-width))) solid transparent;border-radius:var(--sbb-border-radius-4x);background-clip:padding-box}:is(.sbb-scrollbar,.sbb-scrollbar-negative,.sbb-scrollbar-thick,.sbb-scrollbar-thick-negative,.sbb-scrollbar-track-visible,.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-track-visible,.sbb-scrollbar-thick-negative-track-visible)::-webkit-scrollbar-thumb:hover{background-color:var(--sbb-scrollbar-color-hover,currentcolor);border-width:calc(.5 * (var(--sbb-scrollbar-width) - var(--sbb-scrollbar-thumb-width-hover)))}:is(.sbb-scrollbar,.sbb-scrollbar-negative,.sbb-scrollbar-thick,.sbb-scrollbar-thick-negative,.sbb-scrollbar-track-visible,.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-track-visible,.sbb-scrollbar-thick-negative-track-visible)::-webkit-scrollbar-button,:is(.sbb-scrollbar,.sbb-scrollbar-negative,.sbb-scrollbar-thick,.sbb-scrollbar-thick-negative,.sbb-scrollbar-track-visible,.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-track-visible,.sbb-scrollbar-thick-negative-track-visible)::-webkit-scrollbar-corner{display:none}@supports not selector(::-webkit-scrollbar){:is(.sbb-scrollbar,.sbb-scrollbar-negative,.sbb-scrollbar-thick,.sbb-scrollbar-thick-negative,.sbb-scrollbar-track-visible,.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-track-visible,.sbb-scrollbar-thick-negative-track-visible){scrollbar-width:var(--sbb-scrollbar-width-firefox);scrollbar-color:var(--sbb-scrollbar-color,currentcolor) var(--sbb-scrollbar-track-color,transparent)}}:is(.sbb-scrollbar-negative,.sbb-scrollbar-thick-negative,.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-negative-track-visible){--sbb-scrollbar-color:color-mix(in srgb, var(--sbb-color-white) 30%, transparent);--sbb-scrollbar-color-hover:color-mix(in srgb, var(--sbb-color-white) 60%, transparent)}:is(.sbb-scrollbar-thick-negative,.sbb-scrollbar-thick,.sbb-scrollbar-thick-track-visible,.sbb-scrollbar-thick-negative-track-visible){--sbb-scrollbar-thumb-width:.5rem;--sbb-scrollbar-thumb-width-hover:var(--sbb-scrollbar-thumb-width);--sbb-scrollbar-width-firefox:auto}:is(.sbb-scrollbar-track-visible,.sbb-scrollbar-thick-track-visible){--sbb-scrollbar-track-color:var(--sbb-background-color-4)}:is(.sbb-scrollbar-negative-track-visible,.sbb-scrollbar-thick-negative-track-visible){--sbb-scrollbar-track-color:var(--sbb-background-color-4-negative)}
46
46
  `,Ur=`button{appearance:none;box-sizing:border-box;-webkit-tap-highlight-color:transparent;color:inherit;background:0 0;border:none;border-radius:0;outline:none;margin:0;padding:0}
@@ -663,9 +663,7 @@ let SbbAutocompleteBaseElement = (() => {
663
663
  if (this.state === "opening" || this.state === "opened") return;
664
664
  switch (event.key) {
665
665
  case "ArrowDown":
666
- case "ArrowUp":
667
- this.open();
668
- break;
666
+ case "ArrowUp": this.open();
669
667
  }
670
668
  }
671
669
  /** Highlight the searched text on the options. */
@@ -735,9 +733,7 @@ var SbbAutocompleteElement = class extends SbbAutocompleteBaseElement {
735
733
  this.selectByKeyboard(event);
736
734
  break;
737
735
  case "ArrowDown":
738
- case "ArrowUp":
739
- this.setNextActiveOption(event);
740
- break;
736
+ case "ArrowUp": this.setNextActiveOption(event);
741
737
  }
742
738
  }
743
739
  selectByKeyboard(event) {
@@ -754,7 +750,8 @@ var SbbAutocompleteElement = class extends SbbAutocompleteBaseElement {
754
750
  this.activeOption = null;
755
751
  return;
756
752
  }
757
- const next = getNextElementIndex(event, this.activeOption ? enabledOptions.indexOf(this.activeOption) : -1, enabledOptions.length);
753
+ const activeItemIndex = this.activeOption ? enabledOptions.indexOf(this.activeOption) : -1;
754
+ const next = getNextElementIndex(event, activeItemIndex, enabledOptions.length);
758
755
  this.activeOption = enabledOptions[next];
759
756
  this.activeOption.setActive(true);
760
757
  this.triggerElement.ariaActiveDescendantElement = this.activeOption;
@@ -125,7 +125,8 @@ let SbbBreadcrumbGroupElement = (() => {
125
125
  this._focusNext(evt, arrayCollapsed);
126
126
  }
127
127
  _focusNext(evt, breadcrumbs = this.listChildren) {
128
- breadcrumbs[getNextElementIndex(evt, breadcrumbs.findIndex((e) => e === document.activeElement || e === this.shadowRoot.activeElement), breadcrumbs.length)]?.focus();
128
+ const current = breadcrumbs.findIndex((e) => e === document.activeElement || e === this.shadowRoot.activeElement);
129
+ breadcrumbs[getNextElementIndex(evt, current, breadcrumbs.length)]?.focus();
129
130
  evt.preventDefault();
130
131
  }
131
132
  /**
@@ -25,7 +25,10 @@ var SbbCheckboxGroupElement = class extends SbbSelectionGroupBaseElement {
25
25
  _handleKeyDown(evt) {
26
26
  const enabledCheckboxes = this.checkboxes.filter((checkbox) => !checkbox.disabled && interactivityChecker.isVisible(checkbox));
27
27
  if (!enabledCheckboxes || evt.target !== this && evt.target.parentElement !== this && evt.target.parentElement.localName !== "sbb-selection-expansion-panel" && evt.target.parentElement.localName !== "sbb-selection-action-panel") return;
28
- if (isArrowKeyPressed(evt)) enabledCheckboxes[getNextElementIndex(evt, enabledCheckboxes.findIndex((e) => e === evt.target), enabledCheckboxes.length)]?.focus();
28
+ if (isArrowKeyPressed(evt)) {
29
+ const current = enabledCheckboxes.findIndex((e) => e === evt.target);
30
+ enabledCheckboxes[getNextElementIndex(evt, current, enabledCheckboxes.length)]?.focus();
31
+ }
29
32
  }
30
33
  };
31
34