import{r as registerInstance,h}from"./index-BntG-4Sv.js";import{ToastMessageList,ToastrConfig,WindowService,ToastType}from"@ontotext/workbench-api";import{s as sanitizeHTML,T as TranslationService}from"./translation.service-FB05Sh97.js";const ontoToastrCss=".onto-toastr-container{position:fixed;z-index:9999999;pointer-events:auto;flex-direction:column}.onto-toastr-container.bottom-right{bottom:12px;right:12px}.onto-toastr-container.bottom-left{bottom:12px;left:12px}.onto-toastr-container .onto-toast{display:flex;align-items:center;border-radius:0;box-shadow:0 0 12px rgba(0, 0, 0, 0.3);position:relative;width:400px;padding:25px 0;color:white;margin-bottom:5px;overflow-wrap:break-word}.onto-toastr-container .onto-toast:hover{box-shadow:0 0 12px #000;opacity:1;cursor:pointer}.onto-toastr-container .onto-toast.warning{color:var(--gw-toast-warn-color);background-color:var(--gw-toast-warn-background);border-color:var(--gw-toast-warn-border-color)}.onto-toastr-container .onto-toast.success{background-color:var(--gw-toast-success-background);border-color:var(--gw-toast-success-border-color);color:var(--gw-toast-success-color)}.onto-toastr-container .onto-toast.error{background-color:var(--gw-toast-error-background);border-color:var(--gw-toast-error-border-color);color:var(--gw-toast-error-color)}.onto-toastr-container .onto-toast.info{background-color:var(--gw-toast-info-background);border-color:var(--gw-toast-info-border-color);color:var(--gw-toast-info-color)}.onto-toastr-container .onto-toast i{font-size:1.8rem;padding:0 20px;color:inherit}.onto-toastr-container .onto-toast i:hover{transform:none}.onto-toastr-container .onto-toast .toast-message{font-size:1.2rem;opacity:1;max-width:370px}",toastTypeToIconMap={[ToastType.INFO]:"ri-information-2-fill",[ToastType.SUCCESS]:"ri-checkbox-circle-line",[ToastType.WARNING]:"ri-message-line",[ToastType.ERROR]:"ri-alert-line"},OntoToastr=class{constructor(o){registerInstance(this,o),this.toasts=new ToastMessageList([]),this.toastToTimeout=new Map,this.config=ToastrConfig.getDefaultConfig(),this.onToastMouseEnter=o=>()=>{this.clearToastTimeout(o)},this.onToastMouseLeave=o=>()=>{this.setTimeoutForToast(o)}}handleToastCreate(o){this.addToast(o.detail)}render(){var o;return h("section",{key:"21b2b0dd0f50aabbe2eed7ee6080eaf450c167e7",style:{display:this.toasts.isEmpty()?"none":"flex"},class:`onto-toastr-container ${this.config.position}`},null===(o=this.toasts)||void 0===o?void 0:o.getItems().map(o=>{var t,s,e;return h("div",{class:`onto-toast toast ${o.type}`,key:o.id,onMouseEnter:this.onToastMouseEnter(o),onMouseLeave:this.onToastMouseLeave(o),onClick:this.handleToastClick(o),onKeyUp:this.handleKeyUp(o)},h("i",{class:`${toastTypeToIconMap[o.type]}`}),h("span",null,(null===(t=o.config)||void 0===t?void 0:t.title)?h("div",{class:"toast-title",innerHTML:sanitizeHTML(TranslationService.translate(o.config.title,null===(s=o.config)||void 0===s?void 0:s.translationParams))}):"",h("div",{class:"toast-message",innerHTML:sanitizeHTML(TranslationService.translate(o.message,null===(e=o.config)||void 0===e?void 0:e.translationParams))})))}))}addToast(o){this.toasts.addToStart(o),this.setTimeoutForToast(o),this.updateToastrReference()}setTimeoutForToast(o){var t;const s=WindowService.getWindow().setTimeout(()=>{this.toasts.remove(o),this.clearToastTimeout(o)},(null===(t=o.config)||void 0===t?void 0:t.timeout)||this.config.timeout);this.toastToTimeout.set(o,s)}updateToastrReference(){this.toasts=new ToastMessageList(this.toasts.getItems())}clearToastTimeout(o){const t=this.toastToTimeout.get(o);clearTimeout(t),this.toastToTimeout.delete(o),this.updateToastrReference()}handleToastClick(o){return t=>{var s,e;(null===(s=o.config)||void 0===s?void 0:s.onClick)&&o.config.onClick(t),(null===(e=o.config)||void 0===e?void 0:e.removeOnClick)&&(this.toasts.remove(o),this.clearToastTimeout(o))}}handleKeyUp(o){return t=>{"Enter"===t.key&&this.handleToastClick(o)}}};OntoToastr.style=ontoToastrCss;export{OntoToastr as onto_toastr};