var __awaiter=this&&this.__awaiter||function(e,t,n,i){function a(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,r){function o(e){try{c(i.next(e))}catch(e){r(e)}}function l(e){try{c(i["throw"](e))}catch(e){r(e)}}function c(e){e.done?n(e.value):a(e.value).then(o,l)}c((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,a,r,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(e){return function(t){return c([e,t])}}function c(o){if(i)throw new TypeError("Generator is already executing.");while(n)try{if(i=1,a&&(r=o[0]&2?a["return"]:o[0]?a["throw"]||((r=a["return"])&&r.call(a),0):a.next)&&!(r=r.call(a,o[1])).done)return r;if(a=0,r)o=[o[0]&2,r.value];switch(o[0]){case 0:case 1:r=o;break;case 4:n.label++;return{value:o[1],done:false};case 5:n.label++;a=o[1];o=[0];continue;case 7:o=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!r||o[1]>r[0]&&o[1]e.offsetHeight?0:-1};this.setContainerRef=function(e){t.containerEl=e};this.setDismissRef=function(e){t.dismissButtonEl=e};this.setBackRef=function(e){t.backButtonEl=e};this.panelKeyDownHandler=function(e){if(e.key==="Escape"){t.dismiss()}};this.dismiss=function(){t.dismissed=true;t.calcitePanelDismiss.emit()};this.panelScrollHandler=function(){t.calcitePanelScroll.emit()};this.backButtonClick=function(){t.calcitePanelBackClick.emit()};this.setPanelScrollEl=function(e){var n,i;t.panelScrollEl=e;(n=t.resizeObserver)===null||n===void 0?void 0:n.disconnect();if(e){(i=t.resizeObserver)===null||i===void 0?void 0:i.observe(e);t.resizeHandler()}}}e.prototype.dismissedHandler=function(){this.calcitePanelDismissedChange.emit()};e.prototype.componentDidRender=function(){updateHostInteraction(this)};e.prototype.connectedCallback=function(){connectConditionalSlotComponent(this)};e.prototype.disconnectedCallback=function(){var e;disconnectConditionalSlotComponent(this);(e=this.resizeObserver)===null||e===void 0?void 0:e.disconnect()};e.prototype.setFocus=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,i;return __generator(this,(function(a){if(e==="dismiss-button"){(t=this.dismissButtonEl)===null||t===void 0?void 0:t.setFocus();return[2]}if(e==="back-button"){(n=this.backButtonEl)===null||n===void 0?void 0:n.setFocus();return[2]}(i=this.containerEl)===null||i===void 0?void 0:i.focus();return[2]}))}))};e.prototype.scrollContentTo=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(n){(t=this.panelScrollEl)===null||t===void 0?void 0:t.scrollTo(e);return[2]}))}))};e.prototype.renderBackButton=function(){var e=this.el;var t=getElementDir(e)==="rtl";var n=this,i=n.showBackButton,a=n.intlBack,r=n.backButtonClick;var o=a||TEXT.back;var l=t?ICONS.backRight:ICONS.backLeft;return i?h("calcite-action",{"aria-label":o,class:CSS.backButton,icon:l,key:"back-button",onClick:r,ref:this.setBackRef,scale:"s",slot:SLOTS.headerActionsStart,text:o}):null};e.prototype.renderHeaderContent=function(){var e=this,t=e.heading,n=e.headingLevel,i=e.summary;var a=t?h(Heading,{class:CSS.heading,level:n||HEADING_LEVEL},t):null;var r=i?h("span",{class:CSS.summary},i):null;return a||r?h("div",{class:CSS.headerContent,key:"header-content"},a,r):null};e.prototype.renderHeaderSlottedContent=function(){return h("div",{class:CSS.headerContent,key:"slotted-header-content"},h("slot",{name:SLOTS.headerContent}))};e.prototype.renderHeaderStartActions=function(){var e;var t=this.el;var n=getSlotted(t,SLOTS.headerActionsStart);return n?h("div",{class:(e={},e[CSS.headerActionsStart]=true,e[CSS.headerActions]=true,e),key:"header-actions-start"},h("slot",{name:SLOTS.headerActionsStart})):null};e.prototype.renderHeaderActionsEnd=function(){var e;var t=this,n=t.dismiss,i=t.dismissible,a=t.el,r=t.intlClose;var o=r||TEXT.close;var l=i?h("calcite-action",{"aria-label":o,icon:ICONS.close,onClick:n,ref:this.setDismissRef,text:o}):null;var c=h("slot",{name:SLOTS.headerActionsEnd});var s=getSlotted(a,SLOTS.headerActionsEnd);return s||l?h("div",{class:(e={},e[CSS.headerActionsEnd]=true,e[CSS.headerActions]=true,e),key:"header-actions-end"},c,l):null};e.prototype.renderMenu=function(){var e=this,t=e.el,n=e.intlOptions,i=e.menuOpen;var a=getSlotted(t,SLOTS.headerMenuActions);return a?h("calcite-action-menu",{flipPlacements:["top","bottom"],key:"menu",label:n||TEXT.options,open:i,placement:"bottom-end"},h("calcite-action",{icon:ICONS.menu,slot:SLOTS$1.trigger,text:n||TEXT.options}),h("slot",{name:SLOTS.headerMenuActions})):null};e.prototype.renderHeaderNode=function(){var e=this,t=e.el,n=e.showBackButton;var i=this.renderBackButton();var a=getSlotted(t,SLOTS.headerContent);var r=a?this.renderHeaderSlottedContent():this.renderHeaderContent();var o=this.renderHeaderStartActions();var l=this.renderHeaderActionsEnd();var c=this.renderMenu();return o||r||l||c||n?h("header",{class:CSS.header},i,o,r,l,c):null};e.prototype.renderFooterNode=function(){var e=this.el;var t=getSlotted(e,SLOTS.footer);var n=getSlotted(e,SLOTS.footerActions);return t||n?h("footer",{class:CSS.footer,key:"footer"},t?h("slot",{key:"footer-slot",name:SLOTS.footer}):null,n?h("slot",{key:"footer-actions-slot",name:SLOTS.footerActions}):null):null};e.prototype.renderContent=function(){var e,t;var n=this.el;var i=getSlotted(n,SLOTS.fab);var a=h("slot",{key:"default-slot"});var r="content-wrapper";return i?h("div",{class:(e={},e[CSS.contentWrapper]=true,e[CSS.contentHeight]=true,e),key:r,onScroll:this.panelScrollHandler,ref:this.setPanelScrollEl},h("section",{class:CSS.contentContainer},a),this.renderFab()):h("section",{class:(t={},t[CSS.contentWrapper]=true,t[CSS.contentContainer]=true,t),key:r,onScroll:this.panelScrollHandler,ref:this.setPanelScrollEl},a)};e.prototype.renderFab=function(){return h("div",{class:CSS.fabContainer},h("slot",{name:SLOTS.fab}))};e.prototype.render=function(){var e=this,t=e.dismissed,n=e.dismissible,i=e.loading,a=e.panelKeyDownHandler;var r=h("article",{"aria-busy":toAriaBoolean(i),class:CSS.container,hidden:n&&t,onKeyDown:a,ref:this.setContainerRef,tabIndex:n?0:-1},this.renderHeaderNode(),this.renderContent(),this.renderFooterNode());return h(Fragment,null,i?h("calcite-scrim",{loading:i}):null,r)};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{dismissed:["dismissedHandler"]}},enumerable:false,configurable:true});return e}();Panel.style=panelCss;export{Panel as calcite_panel};