/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@neovici/cosmoz-viewinfo@4.1.2/cosmoz-viewinfo.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{PolymerElement}from"@polymer/polymer/polymer-element";import{Debouncer}from"@polymer/polymer/lib/utils/debounce";import{timeOut}from"@polymer/polymer/lib/utils/async";import{html}from"@polymer/polymer/lib/utils/html-tag";import{VIEW_INFO_INSTANCES,SHARED_VIEW_INFO}from"./cosmoz-viewinfo-mixin";import{createContext,useContext}from"@pionjs/pion";const ViewInfo=createContext(SHARED_VIEW_INFO),useViewInfo=()=>useContext(ViewInfo);export{viewInfoAware}from"./cosmoz-viewinfo-mixin";customElements.define("view-info-provider",ViewInfo.Provider);class CosmozViewInfo extends PolymerElement{static get template(){return html`
			<style>
				:host { display: block; }
				view-info-provider {
					all: inherit;
					width: 100%;
					height: 100%;
				}
			</style>
			<view-info-provider value="[[ _currentViewInfo ]]"><slot></slot></view-info-provider>
		`}static get is(){return"cosmoz-viewinfo"}static get properties(){return{effects:{type:Number,value:10,observer:"_effectsChanged"},mobileBreakpoint:{type:Number,value:600},tabletBreakpoint:{type:Number,value:960},throttleTimeout:{type:Number,value:250},_currentViewInfo:{type:Object,value:SHARED_VIEW_INFO}}}constructor(){super(),this._resizeObserver=new ResizeObserver(this._onResize.bind(this))}connectedCallback(){super.connectedCallback(),this._resizeObserver.observe(this),this._updateViewSize()}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver.unobserve(this),this._debouncer?.cancel()}_effectsChanged(e){this._notifyInstances({effects:e})}_notifyInstances(e){VIEW_INFO_INSTANCES.forEach((t=>{t&&Object.keys(e).forEach((i=>{t.notifyPath("viewInfo."+i,e[i])}))}))}_onResize([e]){0!==e.borderBoxSize?.[0]?.inlineSize&&0!==e.contentRect?.width&&Array.isArray(VIEW_INFO_INSTANCES)&&0!==VIEW_INFO_INSTANCES.length&&(this._debouncer=Debouncer.debounce(this._debouncer,timeOut.after(this.throttleTimeout),(()=>{const e=this._updateViewSize();null!=e&&VIEW_INFO_INSTANCES.filter((e=>null!==e.offsetParent)).forEach((t=>{t.dispatchEvent(new CustomEvent("viewinfo-resize",{bubbles:!0,composed:!0,detail:{bigger:e}}))}))})))}_updateViewSize(){const e=SHARED_VIEW_INFO.width,t={height:this.clientHeight||this.offsetHeight||this.scrollHeight,width:this.clientWidth||this.offsetWidth||this.scrollWidth};t.portrait=t.height>t.width,t.landscape=!t.portrait,t.width<=this.mobileBreakpoint?(t.mobile=!0,t.tablet=!1):t.width<=this.tabletBreakpoint?(t.mobile=!1,t.tablet=!0):(t.mobile=!1,t.tablet=!1),t.desktop=!t.mobile&&!t.tablet;const i=this._getDelta(SHARED_VIEW_INFO,t);return Object.keys(i).forEach((e=>{SHARED_VIEW_INFO[e]=i[e]})),this._currentViewInfo={...SHARED_VIEW_INFO},this._notifyInstances(i),e<t.width}_getDelta(e,t){return Object.keys(t).reduce(((i,o)=>{const r=t[o];return void 0!==e[o]&&e[o]===r||(i[o]=r),i}),{})}}customElements.define(CosmozViewInfo.is,CosmozViewInfo);export{CosmozViewInfo,ViewInfo,useViewInfo};
//# sourceMappingURL=/sm/760d872922dccfa03bfebd21cf502088c9c36f9189bb0a632bceb218ee05e141.map