text: import{r as t,e as a,h as s,H as r,g as o}from"./p-ef4d1f35.js";import"./p-812c3cb0.js";import{i,p as e,a as n,d as l,e as c}from"./p-3caefa0c.js";import{s as d}from"./p-42719284.js";import{g as h,s as p}from"./p-09b2e663.js";import{c as b}from"./p-4dc40b90.js";const m=(t,a)=>{const s=b(),r=b(),o=t.host||t,i=t.querySelector(".toast-wrapper");switch(r.addElement(i),a){case"top":r.fromTo("transform","translateY(-100%)","translateY(calc(10px + var(--safe-area-top, 0px)))");break;case"middle":i.style.top="50%",r.fromTo("opacity",.01,1);break;default:r.fromTo("transform","translateY(100%)","translateY(calc(-10px - var(--safe-area-bottom, 0px)))")}return s.addElement(o).easing("cubic-bezier(.155,1.105,.295,1.12)").duration(400).addAnimation(r)},u=(t,a)=>{const s=b(),r=b(),o=t.host||t,i=t.querySelector(".toast-wrapper");switch(r.addElement(i),a){case"top":r.fromTo("transform","translateY(calc(10px + var(--safe-area-top, 0px)))","translateY(-100%)");break;case"middle":r.fromTo("opacity",.99,0);break;default:r.fromTo("transform","translateY(calc(-10px - var(--safe-area-bottom, 0px)))","translateY(100%)")}return s.addElement(o).easing("cubic-bezier(.36,.66,.04,1)").duration(300).addAnimation(r)},g=class{constructor(s){t(this,s),this.didPresent=a(this,"toastDidPresent",7),this.willPresent=a(this,"toastWillPresent",7),this.willDismiss=a(this,"toastWillDismiss",7),this.didDismiss=a(this,"toastDidDismiss",7),this.presented=!1,this.duration=0,this.keyboardClose=!1,this.position="top",this.animated=!0,this.dispatchCancelHandler=t=>{if(i(t.detail.role)){const t=this.getButtons().find((t=>"cancel"===t.role));this.callButtonHandler(t)}}}connectedCallback(){e(this.el)}async present(){await n(this,m,this.position),this.duration>0&&(this.durationTimeout=setTimeout((()=>this.dismiss(void 0,"timeout")),this.duration))}dismiss(t,a){return this.durationTimeout&&clearTimeout(this.durationTimeout),l(this,t,a,u,this.position)}onDidDismiss(){return c(this.el,"toastDidDismiss")}onWillDismiss(){return c(this.el,"toastWillDismiss")}getButtons(){return this.buttons?this.buttons.map((t=>"string"==typeof t?{text:t}:t)):[]}async buttonClick(t){const a=t.role;return i(a)||await this.callButtonHandler(t)?this.dismiss(void 0,a):Promise.resolve()}async callButtonHandler(t){if(t&&t.handler)try{if(!1===await t.handler())return!1}catch(t){console.error(t)}return!0}renderButtons(t,a){if(0!==t.length)return s("div",{class:{"toast-button-group":!0,["toast-button-group-"+a]:!0}},t.map((t=>s("button",{type:"button",class:x(t),tabIndex:0,onClick:()=>this.buttonClick(t),part:"button"},s("div",{class:"toast-button-inner"},t.icon&&s("BKKR-icon",{icon:t.icon,slot:void 0===t.text?"icon-only":void 0,class:"toast-icon"}),t.text)))))}render(){const t=this.getButtons(),a=t.filter((t=>"start"===t.side)),o=t.filter((t=>"start"!==t.side)),i={"toast-wrapper":!0,["toast-"+this.position]:!0};return s(r,{style:{zIndex:""+(6e4+this.overlayIndex)},class:p(this.color,Object.assign({},h(this.cssClass))),tabindex:"-1",onBkkrToastWillDismiss:this.dispatchCancelHandler},s("div",{class:i},s("div",{class:"toast-container",part:"container"},this.renderButtons(a,"start"),s("div",{class:"toast-content"},void 0!==this.header&&s("div",{class:"toast-header",part:"header"},this.header),void 0!==this.message&&s("div",{class:"toast-message",part:"message",innerHTML:d(this.message)})),this.renderButtons(o,"end"))))}get el(){return o(this)}},x=t=>Object.assign({"toast-button":!0,"toast-button-icon-only":void 0!==t.icon&&void 0===t.text,["toast-button-"+t.role]:void 0!==t.role,"bkkr-focusable":!0,"bkkr-activatable":!0},h(t.cssClass));g.style=":host{--border-width:0;--border-style:none;--border-color:initial;--box-shadow:0 0 30px 10px rgba(0, 0, 0, .1);--min-width:auto;--width:auto;--min-height:auto;--height:auto;--max-height:auto;--white-space:pre-wrap;--background:var(--bkkr-background-color, #fff);--border-radius:32px;--button-color:color-get(primary, base);--color:var(--bkkr-color-step-850, #262626);--max-width:700px;--start:calc(var(--bkkr-spacer, 16px) / 2);--end:var(--start);top:0;left:0;display:block;position:absolute;width:100%;height:100%;outline:none;color:var(--color);font-family:var(--default-font-sans-serif);font-size:14px;contain:strict;z-index:1060;pointer-events:none}.toast.overlay-hidden{display:none}:host(.bkkr-color){--button-color:inherit;color:current-color(contrast)}:host(.bkkr-color) .toast-button-cancel{color:inherit}:host(.bkkr-color) .toast-wrapper{background:current-color(base)}.toast-wrapper{border-radius:var(--border-radius);right:var(--end);left:var(--start);margin-left:auto;margin-right:auto;margin-top:auto;margin-bottom:auto;display:block;position:absolute;width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow)}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.toast-wrapper{margin-left:unset;margin-right:unset;-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto}}.toast-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;height:inherit;min-height:inherit;max-height:inherit;pointer-events:auto;contain:content}.toast-content{padding-left:15px;padding-right:15px;padding-top:15px;padding-bottom:15px;display:-ms-flexbox;display:flex;-ms-flex:1;flex:1;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;text-align:center}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.toast-content{padding-left:unset;padding-right:unset;-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px}}.toast-header{margin-bottom:2px;font-weight:500}.toast-message{-ms-flex:1;flex:1;white-space:var(--white-space)}.toast-button-group{display:-ms-flexbox;display:flex}.toast-button{border:0;outline:none;color:var(--button-color);z-index:0}.toast-icon{font-size:1.4em}.toast-button-inner{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.toast-wrapper.toast-top{top:0;-webkit-transform:translate3d(0, -100%, 0);transform:translate3d(0, -100%, 0)}.toast-wrapper.toast-middle{opacity:0.01}.toast-wrapper.toast-bottom{bottom:0;-webkit-transform:translate3d(0, 100%, 0);transform:translate3d(0, 100%, 0)}@media (any-hover: hover){.toast-button:hover{cursor:pointer}}";export{g as bkkr_toast}