'use strict'; var o = require('react'); var client = require('react-dom/client'); var _ = require('react-dom'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var o__default = /*#__PURE__*/_interopDefault(o); var ___default = /*#__PURE__*/_interopDefault(_); function i(t,{insertAt:h}={}){if(!t||typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css",h==="top"&&a.firstChild?a.insertBefore(c,a.firstChild):a.appendChild(c),c.styleSheet?c.styleSheet.cssText=t:c.appendChild(document.createTextNode(t));}i(`.toast_container{display:flex;box-sizing:border-box;border-radius:6px;flex-direction:column;font-family:Fira code;font-size:14px;color:#f0effb;padding:8px;z-index:3;-webkit-transform:translate3d(0,0,3);position:fixed;top:5%;width:30%;min-width:150px;max-width:500px;box-shadow:#0000001f 0 1px 3px,#0000003d 0 1px 2px;transition:.5s;overflow:hidden}.hide_toast{display:none}#right{right:4%;animation:toasting-right 2s normal}#left{left:4%;animation:toasting-left 2s normal}.bg_success{background-color:#7fb069}.bg_client_error{background-color:#ff3c38}.bg_server_error{background-color:#ff8c42}.bg_unknown{background-color:#76949f}.timer{position:absolute;bottom:0;left:0;height:2px;width:100%}.timer:before{content:"";position:absolute;bottom:0;right:0;height:100%;width:100%;background-color:#ddd}@keyframes timer{0%{transform:translateZ(0)}to{transform:translate3d(100%,0,0)}}@keyframes toasting-right{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translateZ(0)}}@keyframes toasting-left{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translateZ(0)}} `);var g=(r=>(r.SUCCESS="success",r.CLIENT_ERROR="client_error",r.SERVER_ERROR="server_error",r.UNKNOWN="unknown",r))(g||{});var E=t=>{let h=new Map([[200,"success"],[204,"success"],[400,"client_error"],[401,"client_error"],[403,"client_error"],[404,"client_error"],[409,"client_error"],[422,"client_error"],[429,"client_error"],[499,"client_error"],[500,"server_error"],[502,"server_error"],[504,"server_error"]]),a=String(t);for(let[c,r]of h.entries())if(a===String(c))return r;return "unknown"},u=E;var s={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},V=o__default.default.createContext&&o__default.default.createContext(s);var e=function(){return e=Object.assign||function(t){for(var h,a=1,c=arguments.length;a{let a={success:{en:"Success",es:"\xC9xito",pt:"Sucesso"},client_error:{en:"Client error",es:"Error de cliente",pt:"Erro de cliente"},server_error:{en:"Server error",es:"Error con el servidor",pt:"Erro de servidor"},unknown:{pt:"Status desconhecido",es:"Status desconocido",en:"Unknown status"}};return h?a[t][h]:a[t].en||""},x=W;i(`.theme_icon{display:flex;gap:10px;justify-content:flex-start;align-items:center} `);var U=(t,h)=>o__default.default.createElement("div",{className:"theme_icon"},{success:o__default.default.createElement(y,null),client_error:o__default.default.createElement(T,null),server_error:o__default.default.createElement(b,null),unknown:o__default.default.createElement(k,null)}[t],x(t,h)),m=U;var G=(t,h)=>{let a={success:{en:"Your request was submitted successfully!",es:"\xA1Su solicitud se envi\xF3 correctamente!",pt:"Sua solicita\xE7\xE3o foi enviada com sucesso!"},client_error:{en:"An error occurred with your client!",es:"\xA1Se produjo un error con su cliente!",pt:"Ocorreu um erro com o seu cliente!"},server_error:{en:"Resource not found, an error occurred with the system server",es:"Recurso no encontrado, se produjo un error con el servidor del sistema",pt:"Recurso n\xE3o encontrado, ocorreu um erro com o servidor do sistema"},unknown:{pt:"Retorno desconhecido para darmos alguma especifica\xE7\xE3o!",es:"\xA1Respuesta desconocida para especificaciones!",en:"Unknown response for specifications!"}};return h?a[t][h]:a[t].en||""},f=G;i(`.header{display:flex;flex-direction:row-reverse;flex-wrap:nowrap;align-items:flex-start;justify-content:space-between;box-sizing:border-box;width:100%;height:100%;cursor:default;word-break:break-word}.header svg{font-size:20px}.close-button{transition:.75s;cursor:pointer}.close-button:hover{transition:.75s;opacity:70%}.close-button svg{width:14px} `);var L=t=>{let h=o.useCallback(()=>t.currentHeader?t.currentHeader:m(t.currentTheme,t.currentLang),[t.currentHeader,t.currentLang,t.currentTheme]);return o__default.default.createElement("header",{className:"header"},o__default.default.createElement("div",{className:"close-button"},o__default.default.createElement(F,{onClick:()=>t.handleDisplayToast("false")})),h())};i(`.message_container{display:flex;flex-wrap:nowrap;word-break:break-word;text-align:justify;width:100%;box-sizing:border-box;padding:8px 4px} `);var w=t=>{let h=o.useCallback(()=>t.currentMessage?t.currentMessage:f(t.currentTheme,t.currentLang),[t.currentTheme,t.currentMessage,t.currentLang]);return o__default.default.createElement("section",{className:"message_container"},h())};var D=t=>{var z,p;let h=v=>{let[l,C]=o.useState("success"),[R,A]=o.useState("true");return o.useMemo(()=>{C(u(v.status));},[v.status]),setTimeout(()=>{A("false");},Number(v.duration)||7e3),o__default.default.createElement("div",{className:(()=>{let H=["toast_container"];return H.push(`bg_${l}`),R==="false"&&H.push("hide_toast"),H.join(" ")})(),id:v.position??"right",style:v.customStyle},o__default.default.createElement(L,{currentTheme:l,currentLang:v.lang,currentHeader:v.customHeader,handleDisplayToast:A}),o__default.default.createElement(w,{currentMessage:v.message,currentTheme:l,currentLang:v.lang}),o__default.default.createElement("div",{className:"timer active",style:{animation:`timer linear ${v.duration||7e3}ms forwards`}}))},a,c=document.getElementById("@ninamarq/http-status-toast"),r=v=>{let l=___default.default._internalRoot;l&&l.current?l.current.render(o__default.default.createElement(h,{...t})):client.createRoot(v).render(o__default.default.createElement(h,{...t}));};if(c)a=(z=document.querySelector("body"))==null?void 0:z.appendChild(c);else {let v=document.createElement("div");v.setAttribute("id","@ninamarq/http-status-toast"),a=(p=document.querySelector("body"))==null?void 0:p.appendChild(v);}if(a){r(a);return}console.warn("Error in http-status-toast render, please notify Marina at this link: https://github.com/ninamarq/http-status-toast/issues");}; exports.EStatusTheme = g; exports.getMessagesByTheme = f; exports.getThemeByStatusCode = u; exports.getThemeIcon = m; exports.getToastTitleByTheme = x; exports.httpStatusToast = D;