import{r as t,h as o,H as e,a as s}from"./p-B2f84Zog.js";const i="pds-modal-content{display:block;-ms-flex:1 1 auto;flex:1 1 auto;width:100%}pds-modal-content:has(.pds-modal-content.pds-modal-content--border-none){border:0}pds-modal-content:has(.pds-modal-content.pds-modal-content--border-both){-webkit-border-after:1px solid var(--pine-color-border-subtle);border-block-end:1px solid var(--pine-color-border-subtle);-webkit-border-before:1px solid var(--pine-color-border-subtle);border-block-start:1px solid var(--pine-color-border-subtle)}pds-modal-content:has(.pds-modal-content.pds-modal-content--border-top){-webkit-border-before:1px solid var(--pine-color-border-subtle);border-block-start:1px solid var(--pine-color-border-subtle)}pds-modal-content:has(.pds-modal-content.pds-modal-content--border-bottom){-webkit-border-after:1px solid var(--pine-color-border-subtle);border-block-end:1px solid var(--pine-color-border-subtle)}.pds-modal-content{display:block;-ms-flex:1 1 auto;flex:1 1 auto;min-height:0;width:100%}";const n=class{constructor(o){t(this,o);this.border="none";this.contentMaxHeight="none";this.userSetBorder=false}componentWillLoad(){const t=this.el.getAttribute("border");const o=t!==null;this.userSetBorder=o||this.border!=="none"}componentDidLoad(){this.calculateMaxHeight();window.addEventListener("resize",this.handleResize.bind(this));if(!this.userSetBorder){setTimeout((()=>{this.el.addEventListener("scroll",this.handleScroll.bind(this));setTimeout((()=>this.updateBorders()),100)}),100)}}disconnectedCallback(){window.removeEventListener("resize",this.handleResize.bind(this));if(!this.userSetBorder){this.el.removeEventListener("scroll",this.handleScroll.bind(this))}if(this.mutationObserver){this.mutationObserver.disconnect()}}handleScroll(){this.updateBorders()}handleResize(){this.calculateMaxHeight();setTimeout((()=>this.updateBorders()),50)}updateBorders(){if(this.userSetBorder){return}const t=this.el.closest("pds-modal");if(!t)return;const o=t.scrollable!==false;if(!o){this.border="none";return}const e=this.el;const s=e.scrollHeight>e.clientHeight;if(!s){this.border="none";return}const{scrollTop:i,scrollHeight:n,clientHeight:r}=e;const d=i+r;const l=3;const c=i<=l;const a=d>=n-l;if(c&&a){this.border="none"}else if(c&&!a){this.border="bottom"}else if(!c&&a){this.border="top"}else{this.border="both"}}calculateMaxHeight(){const t=this.el.closest("pds-modal");if(!t)return;const o=t.scrollable!==false;setTimeout((()=>{if(!o){this.contentMaxHeight="none";const t=this.el.querySelector(".pds-modal-content");if(t){t.style.maxHeight="none"}return}const e=t.querySelector("pds-modal-header");const s=t.querySelector("pds-modal-footer");const i=e?e.offsetHeight:0;const n=s?s.offsetHeight:0;if(i>0||n>0){const t=Math.round(window.innerHeight*.06);const o=i+n+48+t+50;this.contentMaxHeight=`calc(100vh - ${o}px)`;const e=this.el.querySelector(".pds-modal-content");if(e){e.style.maxHeight=this.contentMaxHeight}}else{this.contentMaxHeight="none"}setTimeout((()=>this.updateBorders()),150)}),100);if(!this.mutationObserver&&t){this.mutationObserver=new MutationObserver((()=>{this.calculateMaxHeight()}));this.mutationObserver.observe(t,{childList:true,subtree:true,attributes:true,attributeFilter:["style","class"]})}}render(){const t=this.contentMaxHeight!=="none"?{maxHeight:this.contentMaxHeight}:{};return o(e,{key:"fae42c1fc151e4855cd2c731802c15851473be79"},o("div",{key:"feb61d6a7227d8113b931df6280358cd9b4fe583",class:{"pds-modal-content":true,[`pds-modal-content--border-${this.border}`]:true},style:t,tabindex:"-1"},o("slot",{key:"1c9e55ecd1ad353699e5a4590ee04c9005719f6d"})))}get el(){return s(this)}};n.style=i;export{n as pds_modal_content};
//# sourceMappingURL=p-3b087f24.entry.js.map