var __spreadArray=this&&this.__spreadArray||function(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t};import{a as getRenderingRef,f as forceUpdate,r as registerInstance,h,H as Host}from"./index-67f7ec52.js";var appendToMap=function(t,e,n){var r=t.get(e);if(!r){t.set(e,[n])}else if(!r.includes(n)){r.push(n)}};var debounce=function(t,e){var n;return function(){var r=[];for(var i=0;i<arguments.length;i++){r[i]=arguments[i]}if(n){clearTimeout(n)}n=setTimeout((function(){n=0;t.apply(void 0,r)}),e)}};var isConnected=function(t){return!("isConnected"in t)||t.isConnected};var cleanupElements=debounce((function(t){for(var e=0,n=t.keys();e<n.length;e++){var r=n[e];t.set(r,t.get(r).filter(isConnected))}}),2e3);var stencilSubscription=function(t){var e=t.on;var n=new Map;if(typeof getRenderingRef==="function"){e("dispose",(function(){n.clear()}));e("get",(function(t){var e=getRenderingRef();if(e){appendToMap(n,t,e)}}));e("set",(function(t){var e=n.get(t);if(e){n.set(t,e.filter(forceUpdate))}cleanupElements(n)}));e("reset",(function(){n.forEach((function(t){return t.forEach(forceUpdate)}));cleanupElements(n)}))}};var createObservableMap=function(t,e){if(e===void 0){e=function(t,e){return t!==e}}var n=new Map(Object.entries(t!==null&&t!==void 0?t:{}));var r={dispose:[],get:[],set:[],reset:[]};var i=function(){n=new Map(Object.entries(t!==null&&t!==void 0?t:{}));r.reset.forEach((function(t){return t()}))};var o=function(){r.dispose.forEach((function(t){return t()}));i()};var a=function(t){r.get.forEach((function(e){return e(t)}));return n.get(t)};var s=function(t,i){var o=n.get(t);if(e(i,o,t)){n.set(t,i);r.set.forEach((function(e){return e(t,i,o)}))}};var c=typeof Proxy==="undefined"?{}:new Proxy(t,{get:function(t,e){return a(e)},ownKeys:function(t){return Array.from(n.keys())},getOwnPropertyDescriptor:function(){return{enumerable:true,configurable:true}},has:function(t,e){return n.has(e)},set:function(t,e,n){s(e,n);return true}});var f=function(t,e){r[t].push(e);return function(){removeFromArray(r[t],e)}};var u=function(e,n){var r=f("set",(function(t,r){if(t===e){n(r)}}));var i=f("reset",(function(){return n(t[e])}));return function(){r();i()}};var p=function(){var t=[];for(var e=0;e<arguments.length;e++){t[e]=arguments[e]}return t.forEach((function(t){if(t.set){f("set",t.set)}if(t.get){f("get",t.get)}if(t.reset){f("reset",t.reset)}}))};var l=function(t){var e=n.get(t);r.set.forEach((function(n){return n(t,e,e)}))};return{state:c,get:a,set:s,on:f,onChange:u,use:p,dispose:o,reset:i,forceUpdate:l}};var removeFromArray=function(t,e){var n=t.indexOf(e);if(n>=0){t[n]=t[t.length-1];t.length--}};var createStore=function(t,e){var n=createObservableMap(t,e);stencilSubscription(n);return n};var initialState={items:[]};var NotificationsService=function(){function t(){var t=createStore(initialState).state;this._state=t}Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:false,configurable:true});t.prototype.closeCurrent=function(){var t=__spreadArray([],this._state.items);t.shift();this._state.items=t};t.prototype.clearNotifications=function(){this._state.items=[]};t.prototype.showErrorNotification=function(t,e){this.pushNotification(t,e!==null&&e!==void 0?e:0,"danger")};t.prototype.showInfoNotification=function(t,e){this.pushNotification(t,e!==null&&e!==void 0?e:0,"info")};t.prototype.showWarningNotification=function(t,e){this.pushNotification(t,e!==null&&e!==void 0?e:0,"warning")};t.prototype.showSuccessNotification=function(t,e){this.pushNotification(t,e!==null&&e!==void 0?e:0,"success")};t.prototype.pushNotification=function(t,e,n){var r=__spreadArray([],this._state.items);r.push({details:t,type:n,priority:e});this._state.items=r.sort((function(t,e){return e.priority-t.priority}))};return t}();var notificationsService=new NotificationsService;var NotificationsSection=function(){function t(t){registerInstance(this,t)}t.prototype.disconnectedCallback=function(){notificationsService.clearNotifications()};t.prototype.render=function(){var t=notificationsService.state.items;if(t.length<=0)return h(Host,null);var e=t[0];var n="alert alert-"+e.type;return h("div",{class:n,role:"alert"},h("div",{class:"d-flex"},h("p",{class:"mb-0 flex-grow-1"},h("strong",null,t[0].details.title)),h("button",{onClick:this.handleClose,type:"button",class:"close pb-1","aria-label":"Close"},h("span",{"aria-hidden":"true"},"×"))),h("p",{class:"mb-0 mt-1"},t[0].details.description))};t.prototype.handleClose=function(){notificationsService.closeCurrent()};return t}();export{NotificationsSection as ap_ben_notifications_section};