import{k as t,o as s,p as i}from"./p-Ba5qjFjW.js";import{b as e}from"./p-B1u-Mq75.js";import{b as h}from"./p-MBsgW7uz.js";import{L as r,S as n}from"./p-C20cwFWy.js";import{j as o,k as u,l as c,m as a,n as l}from"./p-C22U88Bg.js";class d{constructor(t={}){this.previousWidth=e.window.width,this.previousHeight=e.window.height,this.previousIsLandscape=this.isLandscape,this.options={onlyListenToWidthChanges:!1},this.options=Object.assign(Object.assign({},this.options),t)}async hasResized(){if(h.hasTouchScreen){if(!this.sameWidth||this.previousIsLandscape!==this.isLandscape)return this.resetPreviousValues(),!0}else if(this.options.onlyListenToWidthChanges){if(!this.sameWidth)return this.resetPreviousValues(),!0}else if(!this.sameWidth||!this.sameHeight)return this.resetPreviousValues(),!0;return!1}get isLandscape(){return e.window.width>e.window.height}get sameWidth(){return this.previousWidth===e.window.width}get sameHeight(){return this.previousHeight===e.window.height}resetPreviousValues(){this.previousWidth=e.window.width,this.previousHeight=e.window.height,this.previousIsLandscape=this.isLandscape}}class p extends r{constructor(){super(...arguments),this.resizeHandler=new d({onlyListenToWidthChanges:!0}),this.debouncedNotify=t((()=>this.notify()),100),this.notify=async()=>{await this.resizeHandler.hasResized()&&super.notify(void 0)}}connect(t){super.connect(t),this.el&&s(this.el,"resize",this.debouncedNotify,{passive:!0})}disconnect(){super.disconnect(),this.el&&i(this.el,"resize",this.debouncedNotify)}}const f=t=>parseInt(t.slice(0,-2),10),g=f(o),b=f(u),m=f(c),w=f(a),j=f(l),k=t=>t.innerWidth<g,D=t=>{const s=t.innerWidth;return s>=g&&s<b},W=t=>k(t)||D(t),v={mobile:k,tablet:D,touch:W,desktop:t=>!W(t),highDefinition:t=>{const s=t.innerWidth;return s>=m&&s<w},widescreen:t=>{const s=t.innerWidth;return s>=w&&s<j},fullhd:t=>t.innerWidth>=j};class O{constructor(){this.breakpoints=[],e.hasWindow&&(this.win=window,this.win.BaloiseDesignSystem=this.win.BaloiseDesignSystem||{},this.detect())}get isMobile(){return this.includes("mobile")}get isTablet(){return this.includes("tablet")}get isTouch(){return this.includes("touch")}get isDesktop(){return this.includes("desktop")}get isHighDefinition(){return this.includes("highDefinition")}get isWidescreen(){return this.includes("widescreen")}get isFullHD(){return this.includes("fullhd")}includes(t){var s;return this.detect(),!!(null===(s=this.breakpoints)||void 0===s?void 0:s.includes(t))}detect(){return this.win&&(this.breakpoints=Object.keys(v).filter((t=>v[t](this.win))),this.win.BaloiseDesignSystem.breakpoints=this.breakpoints,this.win.BaloiseDesignSystem.platforms=this.breakpoints),this.breakpoints}toObject(){return{mobile:this.breakpoints.includes("mobile"),tablet:this.breakpoints.includes("tablet"),touch:this.breakpoints.includes("touch"),desktop:this.breakpoints.includes("desktop"),highDefinition:this.breakpoints.includes("highDefinition"),widescreen:this.breakpoints.includes("widescreen"),fullhd:this.breakpoints.includes("fullhd")}}}const y=new O,B={mobile:!1,tablet:!1,touch:!1,desktop:!1,highDefinition:!1,widescreen:!1,fullhd:!1};class z extends n{constructor(){super((t=>t.breakpointListener(this.state))),this.state=B,this.listener=new p,this.debouncedNotify=t((()=>this.notify()),50),this.listener.connect(),this.listener.add((()=>{y.detect();const t=y.toObject();this.isEqual(t)||(this.state=t,this.debouncedNotify())}))}attach(t){super.attach(t),y.detect();const s=y.toObject();this.isEqual(s)||(this.state=s,this.debouncedNotify())}isEqual(t){return JSON.stringify(this.state)===JSON.stringify(t)}}const C=new z;export{p as B,C as a,y as b,z as c,O as d}