import{a as t,I as s,R as i,S as e}from"./p-PmQf2Yvi.js";import{b as h}from"./p-CS7huZb4.js";import{L as r,S as n}from"./p-DCgTymE2.js";import{j as o,k as u,l as a,m as c,n as l}from"./p-zxUpFKvW.js";class d{constructor(s={}){this.previousWidth=t.window.width,this.previousHeight=t.window.height,this.previousIsLandscape=this.isLandscape,this.options={onlyListenToWidthChanges:!1},this.options=Object.assign(Object.assign({},this.options),s)}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 t.window.width>t.window.height}get sameWidth(){return this.previousWidth===t.window.width}get sameHeight(){return this.previousHeight===t.window.height}resetPreviousValues(){this.previousWidth=t.window.width,this.previousHeight=t.window.height,this.previousIsLandscape=this.isLandscape}}class p extends r{constructor(){super(...arguments),this.resizeHandler=new d({onlyListenToWidthChanges:!0}),this.debouncedNotify=s((()=>this.notify()),100),this.notify=async()=>{await this.resizeHandler.hasResized()&&super.notify(void 0)}}connect(t){super.connect(t),this.el&&i(this.el,"resize",this.debouncedNotify,{passive:!0})}disconnect(){super.disconnect(),this.el&&e(this.el,"resize",this.debouncedNotify)}}const f=t=>parseInt(t.slice(0,-2),10),g=f(c),b=f(l),m=f(a),w=f(u),j=f(o),D=t=>t.innerWidth<g,v=t=>{const s=t.innerWidth;return s>=g&&s<b},k=t=>D(t)||v(t),O={mobile:D,tablet:v,touch:k,desktop:t=>!k(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 y{constructor(){this.breakpoints=[],t.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(O).filter((t=>O[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 S=new y,T={mobile:!1,tablet:!1,touch:!1,desktop:!1,highDefinition:!1,widescreen:!1,fullhd:!1};class W extends n{constructor(){super((t=>t.breakpointListener(this.state))),this.state=T,this.listener=new p,this.debouncedNotify=s((()=>this.notify()),50),this.listener.connect(),this.listener.add((()=>{S.detect();const t=S.toObject();this.isEqual(t)||(this.state=t,this.debouncedNotify())}))}attach(t){super.attach(t),S.detect();const s=S.toObject();this.isEqual(s)||(this.state=s,this.debouncedNotify())}isEqual(t){return JSON.stringify(this.state)===JSON.stringify(t)}}const x=new W;export{p as B,x as a,S as b,W as c,y as d}