import{i as t,w as e,r as s,d as n,h as i,H as o,e as a}from"./p-2a37a33f.js";import{c as r}from"./p-251a23b9.js";const l=t=>{const e=document.querySelector(`${t}.ion-cloned-element`);if(null!==e)return e;const s=document.createElement(t);return s.classList.add("ion-cloned-element"),s.style.setProperty("display","none"),document.body.appendChild(s),s},c=t=>{if(!t)return;const e=t.querySelectorAll("ion-toolbar");return{el:t,toolbars:Array.from(e).map(t=>{const e=t.querySelector("ion-title");return{el:t,background:t.shadowRoot.querySelector(".toolbar-background"),ionTitleEl:e,innerTitleEl:e?e.shadowRoot.querySelector(".toolbar-title"):null,ionButtonsEl:Array.from(t.querySelectorAll("ion-buttons"))||[]}})||[]}},h=(t,e)=>{void 0===e?t.background.style.removeProperty("--opacity"):t.background.style.setProperty("--opacity",e.toString())},d=(t,e=!0)=>{e?t.el.classList.remove("header-collapse-condense-inactive"):t.el.classList.add("header-collapse-condense-inactive")},u=class{constructor(t){s(this,t),this.collapsibleHeaderInitialized=!1,this.translucent=!1}async componentDidLoad(){await this.checkCollapsibleHeader()}async componentDidUpdate(){await this.checkCollapsibleHeader()}componentDidUnload(){this.destroyCollapsibleHeader()}async checkCollapsibleHeader(){const t="condense"===this.collapse,e=!(!t||"ios"!==n(this))&&t;if(!e&&this.collapsibleHeaderInitialized)this.destroyCollapsibleHeader();else if(e&&!this.collapsibleHeaderInitialized){const t=this.el.closest("ion-app,ion-page,.ion-page,page-inner"),e=t?t.querySelector("ion-content"):null;await this.setupCollapsibleHeader(e,t)}}destroyCollapsibleHeader(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=void 0),this.scrollEl&&this.contentScrollCallback&&(this.scrollEl.removeEventListener("scroll",this.contentScrollCallback),this.contentScrollCallback=void 0),this.collapsibleMainHeader&&(this.collapsibleMainHeader.classList.remove("header-collapse-main"),this.collapsibleMainHeader=void 0)}async setupCollapsibleHeader(s,n){if(!s||!n)return void console.error("ion-header requires a content to collapse, make sure there is an ion-content.");this.scrollEl=await s.getScrollElement();const i=n.querySelectorAll("ion-header");if(this.collapsibleMainHeader=Array.from(i).find(t=>"condense"!==t.collapse),!this.collapsibleMainHeader)return;const o=c(this.collapsibleMainHeader),a=c(this.el);o&&a&&(d(o,!1),o.toolbars.forEach(t=>{h(t,0)}),this.intersectionObserver=new IntersectionObserver(t=>{((t,s,n)=>{e(()=>{((t,e)=>{if(!t[0].isIntersecting)return;const s=t[0].intersectionRatio>.9?0:100*(1-t[0].intersectionRatio)/75;e.toolbars.forEach(t=>{h(t,1===s?void 0:s)})})(t,s);const e=t[0],i=e.intersectionRect,o=i.width*i.height,a=0===o&&0==e.rootBounds.width*e.rootBounds.height,r=Math.abs(i.left-e.boundingClientRect.left),l=Math.abs(i.right-e.boundingClientRect.right);a||o>0&&(r>=5||l>=5)||(e.isIntersecting?(d(s,!1),d(n)):(0===i.x&&0===i.y||0!==i.width&&0!==i.height)&&(d(s),d(n,!1),h(s.toolbars[0])))})})(t,o,a)},{root:s,threshold:[.25,.3,.4,.5,.6,.7,.8,.9,1]}),this.intersectionObserver.observe(a.toolbars[a.toolbars.length-1].el),this.contentScrollCallback=()=>{((s,n,i)=>{t(()=>{const t=r(1,1+-s.scrollTop/500,1.1);null===i.querySelector("ion-refresher.refresher-native")&&e(()=>{((t=[],e=1,s=!1)=>{t.forEach(t=>{const n=t.ionTitleEl,i=t.innerTitleEl;n&&"large"===n.size&&(i.style.transformOrigin="left center",i.style.transition=s?"all 0.2s ease-in-out":"",i.style.transform=`scale3d(${e}, ${e}, 1)`)})})(n.toolbars,t)})})})(this.scrollEl,a,s)},this.scrollEl.addEventListener("scroll",this.contentScrollCallback),e(()=>{l("ion-title"),l("ion-back-button"),this.collapsibleMainHeader.classList.add("header-collapse-main")}),this.collapsibleHeaderInitialized=!0)}render(){const{translucent:t}=this,e=n(this);return i(o,{role:"banner",class:{[e]:!0,[`header-${e}`]:!0,"header-translucent":this.translucent,[`header-collapse-${this.collapse||"none"}`]:!0,[`header-translucent-${e}`]:this.translucent}},"ios"===e&&t&&i("div",{class:"header-background"}),i("slot",null))}get el(){return a(this)}static get style(){return"ion-header{display:block;position:relative;-ms-flex-order:-1;order:-1;width:100%;z-index:10}ion-header ion-toolbar:first-of-type{padding-top:var(--ion-safe-area-top,0)}.header-md:after{left:0;bottom:-5px;background-position:left 0 top -2px;position:absolute;width:100%;height:5px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAHBAMAAADzDtBxAAAAD1BMVEUAAAAAAAAAAAAAAAAAAABPDueNAAAABXRSTlMUCS0gBIh/TXEAAAAaSURBVAjXYxCEAgY4UIICBmMogMsgFLtAAQCNSwXZKOdPxgAAAABJRU5ErkJggg==);background-repeat:repeat-x;content:\"\"}:host-context([dir=rtl]) .header-md:after,[dir=rtl] .header-md:after{left:unset;right:unset;right:0;background-position:right 0 top -2px}.header-collapse-condense,.header-md.ion-no-border:after{display:none}"}};export{u as ion_header};