minerva-plexus-csd 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6235,7 +6235,7 @@ const zx = F(Vn)`
|
|
|
6235
6235
|
trigger: "click",
|
|
6236
6236
|
rootClose: !0,
|
|
6237
6237
|
placement: "top",
|
|
6238
|
-
overlay: /* @__PURE__ */ f.jsx($u, { id: "popover-email-input", children: /* @__PURE__ */ f.jsx($u.Body, { children: /* @__PURE__ */ f.jsxs(
|
|
6238
|
+
overlay: /* @__PURE__ */ f.jsx($u, { id: "popover-email-input", style: { zIndex: 1e3 }, children: /* @__PURE__ */ f.jsx($u.Body, { children: /* @__PURE__ */ f.jsxs(
|
|
6239
6239
|
"div",
|
|
6240
6240
|
{
|
|
6241
6241
|
style: {
|
|
@@ -37271,7 +37271,7 @@ const $9 = ({
|
|
|
37271
37271
|
createWhenLogin: a = !1,
|
|
37272
37272
|
createWhenCsd: i = !1,
|
|
37273
37273
|
showControlButtons: o = !0,
|
|
37274
|
-
chatVersion: s = "
|
|
37274
|
+
chatVersion: s = "mini",
|
|
37275
37275
|
className: l,
|
|
37276
37276
|
showLogoutButton: u = !0,
|
|
37277
37277
|
showCreateConversation: c = !0,
|
|
@@ -832,7 +832,7 @@ Valid keys: `+JSON.stringify(Object.keys(L),null," "));var H=Ae(ee,re,K,W,J+"."
|
|
|
832
832
|
border-color: #aaa;
|
|
833
833
|
}
|
|
834
834
|
}
|
|
835
|
-
`,Rx=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),vf=({serviceTicketingNoUSer:e})=>{const{selectedConversation:t}=Mt(),[n,r]=_.useState(""),[a,i]=_.useState(!1),[o,s]=_.useState(null),[l,u]=_.useState(null),[c,d]=_.useState(!1),[g,p]=_.useState(null),[h,v]=_.useState(!1),{isBotWriting:T}=tr(),S=t==null?void 0:t.id,E=async A=>{if(!S){u("No hay conversación seleccionada"),v(!0);return}i(!0),u(null),s(null);try{const y=await y1(S,A);y.success&&y.ticket_id?(p(y.ticket_id),s("✅ Ticket creado correctamente"),d(!0)):(u("❌ Error: No se pudo crear el ticket."),v(!0))}catch(y){u(`❌ Error: ${y.message}`),v(!0)}finally{i(!1)}},m=()=>{const A=xS.get("access_token");if(!A)return"";try{return JSON.parse(atob(A.split(".")[1])).email||""}catch(y){return console.error("No se pudo leer el token:",y),""}};return f.jsxs("div",{children:[e&&f.jsx("div",{style:{marginLeft:"0.5rem"},children:f.jsx(Na,{trigger:"click",rootClose:!0,placement:"top",overlay:f.jsx(Ra,{id:"popover-email-input",children:f.jsx(Ra.Body,{children:f.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",margin:"0.5rem"},children:[f.jsx("h3",{children:"Crear ticket"}),f.jsx(d1,{haveIcon:!0,iconClickable:!1,value:n,placeholder:"Introduce el email",onChange:A=>r(A.target.value),id:"email",required:!0,"data-testid":"email-input",type:"email"}),f.jsx(kx,{disabled:a||!Rx(n),variant:"filled",size:"middle",width:"50",color:"tertiary",className:"add-button",onClick:()=>E(n),children:a?f.jsx(Oa,{animation:"border",size:"sm"}):"Enviar ticket"})]})})}),children:f.jsx("div",{style:{display:"inline-block",cursor:"pointer"},children:f.jsx(Na,{placement:"top",overlay:f.jsx(Ia,{id:"tooltip-ticket-user",children:"Enviar ticket a usuario notificado"}),children:f.jsx(bd,{})})})})}),!e&&f.jsx("div",{children:f.jsx(Na,{placement:"top",overlay:f.jsx(Ia,{id:"tooltip-ticket-icon",children:"Abrir ticket de soporte"}),children:f.jsx(gd,{onClick:()=>{const A=m();A?E(A):(u("No se pudo extraer el email del token."),v(!0))},disabled:T||a,children:a?f.jsx(Oa,{animation:"border",size:"sm"}):f.jsx(bd,{})})})}),f.jsxs(yf,{position:"top-center",className:"p-3",children:[f.jsxs(ln,{onClose:()=>d(!1),show:c,delay:5e3,autohide:!0,bg:"success",children:[f.jsx(ln.Header,{children:f.jsx("strong",{className:"me-auto",children:"Ticket creado"})}),f.jsxs(ln.Body,{style:{color:"white"},children:["El ticket con identificador ",f.jsx("strong",{children:g})," se ha añadido. Recibirá información cuando sea tramitado."]})]}),f.jsxs(ln,{onClose:()=>v(!1),show:h,delay:5e3,autohide:!0,bg:"danger",children:[f.jsx(ln.Header,{children:f.jsx("strong",{className:"me-auto",children:"Error"})}),f.jsx(ln.Body,{style:{color:"white"},children:l})]})]})]})},Ix=D.div.attrs({className:"styled-chat-area-container"})`
|
|
835
|
+
`,Rx=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),vf=({serviceTicketingNoUSer:e})=>{const{selectedConversation:t}=Mt(),[n,r]=_.useState(""),[a,i]=_.useState(!1),[o,s]=_.useState(null),[l,u]=_.useState(null),[c,d]=_.useState(!1),[g,p]=_.useState(null),[h,v]=_.useState(!1),{isBotWriting:T}=tr(),S=t==null?void 0:t.id,E=async A=>{if(!S){u("No hay conversación seleccionada"),v(!0);return}i(!0),u(null),s(null);try{const y=await y1(S,A);y.success&&y.ticket_id?(p(y.ticket_id),s("✅ Ticket creado correctamente"),d(!0)):(u("❌ Error: No se pudo crear el ticket."),v(!0))}catch(y){u(`❌ Error: ${y.message}`),v(!0)}finally{i(!1)}},m=()=>{const A=xS.get("access_token");if(!A)return"";try{return JSON.parse(atob(A.split(".")[1])).email||""}catch(y){return console.error("No se pudo leer el token:",y),""}};return f.jsxs("div",{children:[e&&f.jsx("div",{style:{marginLeft:"0.5rem"},children:f.jsx(Na,{trigger:"click",rootClose:!0,placement:"top",overlay:f.jsx(Ra,{id:"popover-email-input",style:{zIndex:1e3},children:f.jsx(Ra.Body,{children:f.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",margin:"0.5rem"},children:[f.jsx("h3",{children:"Crear ticket"}),f.jsx(d1,{haveIcon:!0,iconClickable:!1,value:n,placeholder:"Introduce el email",onChange:A=>r(A.target.value),id:"email",required:!0,"data-testid":"email-input",type:"email"}),f.jsx(kx,{disabled:a||!Rx(n),variant:"filled",size:"middle",width:"50",color:"tertiary",className:"add-button",onClick:()=>E(n),children:a?f.jsx(Oa,{animation:"border",size:"sm"}):"Enviar ticket"})]})})}),children:f.jsx("div",{style:{display:"inline-block",cursor:"pointer"},children:f.jsx(Na,{placement:"top",overlay:f.jsx(Ia,{id:"tooltip-ticket-user",children:"Enviar ticket a usuario notificado"}),children:f.jsx(bd,{})})})})}),!e&&f.jsx("div",{children:f.jsx(Na,{placement:"top",overlay:f.jsx(Ia,{id:"tooltip-ticket-icon",children:"Abrir ticket de soporte"}),children:f.jsx(gd,{onClick:()=>{const A=m();A?E(A):(u("No se pudo extraer el email del token."),v(!0))},disabled:T||a,children:a?f.jsx(Oa,{animation:"border",size:"sm"}):f.jsx(bd,{})})})}),f.jsxs(yf,{position:"top-center",className:"p-3",children:[f.jsxs(ln,{onClose:()=>d(!1),show:c,delay:5e3,autohide:!0,bg:"success",children:[f.jsx(ln.Header,{children:f.jsx("strong",{className:"me-auto",children:"Ticket creado"})}),f.jsxs(ln.Body,{style:{color:"white"},children:["El ticket con identificador ",f.jsx("strong",{children:g})," se ha añadido. Recibirá información cuando sea tramitado."]})]}),f.jsxs(ln,{onClose:()=>v(!1),show:h,delay:5e3,autohide:!0,bg:"danger",children:[f.jsx(ln.Header,{children:f.jsx("strong",{className:"me-auto",children:"Error"})}),f.jsx(ln.Body,{style:{color:"white"},children:l})]})]})]})},Ix=D.div.attrs({className:"styled-chat-area-container"})`
|
|
836
836
|
position: absolute;
|
|
837
837
|
bottom: 0;
|
|
838
838
|
left: 0;
|
|
@@ -1249,7 +1249,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1249
1249
|
padding-top: 19px;
|
|
1250
1250
|
margin-bottom: 20px;
|
|
1251
1251
|
box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.5);
|
|
1252
|
-
`;const eD=({showHeader:e,customLogo:t,showDate:n,showCreateConversation:r,showControlButtons:a,className:i,showConversationTitle:o})=>{const s=!!t;return f.jsx(Q3,{className:i,showHeader:e,hasCustomLogo:s,showCreateConversation:r,showDate:n,showConversationTitle:o,showControlButtons:a})},mS=_.createContext(void 0),hS=({children:e})=>{const[t,n]=_.useState([]),[r,a]=_.useState(!1),[i,o]=_.useState(!1),s=_.useRef(null),l=_.useRef(null),[u,c]=_.useState(!1),{preloadInteractions:d,typeWritterSpeed:g}=Xg(),p=_.useRef(null),h=async m=>{try{a(!0);const y=(await NS(m)).map(b=>({...b}));d(y),n(b=>{const R=b.find(M=>M.pendingSync&&M.sender_type==="ai");if(!R)return y;const N=y.find(M=>M.sender_type==="ai"&&Math.abs(new Date(M.created_at).getTime()-new Date(R.created_at).getTime())<3e3);return N?y.map(M=>M.id===N.id?{...N,content:R.content}:M):y})}catch(A){console.error("Failed to fetch messages:",A)}finally{a(!1)}},v=async(m,A,y)=>{const b={id:`user-${new Date().toISOString()}`,content:A,sender_type:"user",conversation_id:m,created_at:new Date().toISOString()};n(M=>[...M,b].sort((F,$)=>new Date(F.created_at).getTime()-new Date($.created_at).getTime()));const R=`bot-loading-${new Date().toISOString()}`;s.current=R;const N={id:R,content:"",loadingContent:f.jsx(bi,{}),sender_type:"ai",conversation_id:m,created_at:new Date().toISOString(),pendingSync:!0};n(M=>[...M,N].sort((F,$)=>new Date(F.created_at).getTime()-new Date($.created_at).getTime())),a(!0),o(!0);const I=new AbortController;l.current=I,c(!0);try{const M=await OS(m,A,y,I.signal);if(!M)throw new Error("Error: La respuesta en streaming es nula.");const O=M.getReader();p.current=O;const F=new TextDecoder;let $="";for(;;){const{done:z,value:B}=await O.read();if(z)break;const X=F.decode(B,{stream:!0});i&&o(!1),await ud(X,g,Z=>{$+=Z,n(Y=>Y.map(x=>x.id===R?{...x,content:$,loadingContent:void 0}:x).sort((x,L)=>new Date(x.created_at).getTime()-new Date(L.created_at).getTime()))})}await h(m)}catch(M){M instanceof Error&&M.message.includes("cancel")?console.log("Stream cancelado por el usuario"):console.error("Error en el streaming del bot:",M)}finally{a(!1),c(!1),l.current=null,p.current=null,s.current=null}},T=async(m,A,y)=>{n(N=>{const I=N.findIndex(O=>O.id===A);return I===-1?N:[...N.slice(0,I),{...N[I],content:y,created_at:new Date().toISOString()}]});const b=`bot-edit-loading-${Date.now()}`;let R={id:b,content:"",loadingContent:f.jsx(bi,{}),sender_type:"ai",conversation_id:m,created_at:new Date().toISOString(),pendingSync:!0};n(N=>[...N,R]),a(!0);try{const I=(await LS(m,A,y)).getReader();p.current=I;const M=new TextDecoder;let O="";for(;;){const{done:F,value:$}=await I.read();if(F)break;const z=M.decode($,{stream:!0});await ud(z,g,B=>{O+=B,n(X=>X.map(Z=>Z.id===b?{...Z,content:O,loadingContent:void 0}:Z))})}await h(m)}catch(N){N instanceof Error&&N.message.includes("cancel")?console.log("Stream de edición cancelado por el usuario"):console.error("Error al editar mensaje y relanzar:",N)}finally{a(!1),c(!1),p.current=null,s.current=null}},S=async m=>{try{if(console.log("🔄 Intentando detener el stream desde MessageContext..."),l.current&&(l.current.abort(),l.current=null),s.current)try{await Yg.register(s.current,At.STOP)}catch(A){console.warn("Error al cancelar el reader:",A)}return await ld(m),console.log("AAA Stream detenido correctamente en el backend"),c(!1),a(!1),o(!1),console.log("✅ Stream detenido correctamente"),!0}catch(A){return console.error("❌ Error al detener el stream:",A),!1}},E=_.useMemo(()=>({messages:t,fetchMessages:h,addMessage:v,isBotWriting:r,isBotStreaming:u,isWaitingForFirstResponse:i,setIsWaitingForFirstResponse:o,currentBotMessageId:s.current,editAndReplayMessage:T,stopStreamingResponse:S}),[t,r,u,i]);return f.jsx(mS.Provider,{value:E,children:e})},tr=()=>{const e=_.useContext(mS);if(!e)throw new Error("useMessage must be used within a MessageProvider");return e},tD=({theme:e,customLogo:t,showDate:n=!0,showHeader:r=!0,createWhenLogin:a=!1,createWhenCsd:i=!1,showControlButtons:o=!0,chatVersion:s="
|
|
1252
|
+
`;const eD=({showHeader:e,customLogo:t,showDate:n,showCreateConversation:r,showControlButtons:a,className:i,showConversationTitle:o})=>{const s=!!t;return f.jsx(Q3,{className:i,showHeader:e,hasCustomLogo:s,showCreateConversation:r,showDate:n,showConversationTitle:o,showControlButtons:a})},mS=_.createContext(void 0),hS=({children:e})=>{const[t,n]=_.useState([]),[r,a]=_.useState(!1),[i,o]=_.useState(!1),s=_.useRef(null),l=_.useRef(null),[u,c]=_.useState(!1),{preloadInteractions:d,typeWritterSpeed:g}=Xg(),p=_.useRef(null),h=async m=>{try{a(!0);const y=(await NS(m)).map(b=>({...b}));d(y),n(b=>{const R=b.find(M=>M.pendingSync&&M.sender_type==="ai");if(!R)return y;const N=y.find(M=>M.sender_type==="ai"&&Math.abs(new Date(M.created_at).getTime()-new Date(R.created_at).getTime())<3e3);return N?y.map(M=>M.id===N.id?{...N,content:R.content}:M):y})}catch(A){console.error("Failed to fetch messages:",A)}finally{a(!1)}},v=async(m,A,y)=>{const b={id:`user-${new Date().toISOString()}`,content:A,sender_type:"user",conversation_id:m,created_at:new Date().toISOString()};n(M=>[...M,b].sort((F,$)=>new Date(F.created_at).getTime()-new Date($.created_at).getTime()));const R=`bot-loading-${new Date().toISOString()}`;s.current=R;const N={id:R,content:"",loadingContent:f.jsx(bi,{}),sender_type:"ai",conversation_id:m,created_at:new Date().toISOString(),pendingSync:!0};n(M=>[...M,N].sort((F,$)=>new Date(F.created_at).getTime()-new Date($.created_at).getTime())),a(!0),o(!0);const I=new AbortController;l.current=I,c(!0);try{const M=await OS(m,A,y,I.signal);if(!M)throw new Error("Error: La respuesta en streaming es nula.");const O=M.getReader();p.current=O;const F=new TextDecoder;let $="";for(;;){const{done:z,value:B}=await O.read();if(z)break;const X=F.decode(B,{stream:!0});i&&o(!1),await ud(X,g,Z=>{$+=Z,n(Y=>Y.map(x=>x.id===R?{...x,content:$,loadingContent:void 0}:x).sort((x,L)=>new Date(x.created_at).getTime()-new Date(L.created_at).getTime()))})}await h(m)}catch(M){M instanceof Error&&M.message.includes("cancel")?console.log("Stream cancelado por el usuario"):console.error("Error en el streaming del bot:",M)}finally{a(!1),c(!1),l.current=null,p.current=null,s.current=null}},T=async(m,A,y)=>{n(N=>{const I=N.findIndex(O=>O.id===A);return I===-1?N:[...N.slice(0,I),{...N[I],content:y,created_at:new Date().toISOString()}]});const b=`bot-edit-loading-${Date.now()}`;let R={id:b,content:"",loadingContent:f.jsx(bi,{}),sender_type:"ai",conversation_id:m,created_at:new Date().toISOString(),pendingSync:!0};n(N=>[...N,R]),a(!0);try{const I=(await LS(m,A,y)).getReader();p.current=I;const M=new TextDecoder;let O="";for(;;){const{done:F,value:$}=await I.read();if(F)break;const z=M.decode($,{stream:!0});await ud(z,g,B=>{O+=B,n(X=>X.map(Z=>Z.id===b?{...Z,content:O,loadingContent:void 0}:Z))})}await h(m)}catch(N){N instanceof Error&&N.message.includes("cancel")?console.log("Stream de edición cancelado por el usuario"):console.error("Error al editar mensaje y relanzar:",N)}finally{a(!1),c(!1),p.current=null,s.current=null}},S=async m=>{try{if(console.log("🔄 Intentando detener el stream desde MessageContext..."),l.current&&(l.current.abort(),l.current=null),s.current)try{await Yg.register(s.current,At.STOP)}catch(A){console.warn("Error al cancelar el reader:",A)}return await ld(m),console.log("AAA Stream detenido correctamente en el backend"),c(!1),a(!1),o(!1),console.log("✅ Stream detenido correctamente"),!0}catch(A){return console.error("❌ Error al detener el stream:",A),!1}},E=_.useMemo(()=>({messages:t,fetchMessages:h,addMessage:v,isBotWriting:r,isBotStreaming:u,isWaitingForFirstResponse:i,setIsWaitingForFirstResponse:o,currentBotMessageId:s.current,editAndReplayMessage:T,stopStreamingResponse:S}),[t,r,u,i]);return f.jsx(mS.Provider,{value:E,children:e})},tr=()=>{const e=_.useContext(mS);if(!e)throw new Error("useMessage must be used within a MessageProvider");return e},tD=({theme:e,customLogo:t,showDate:n=!0,showHeader:r=!0,createWhenLogin:a=!1,createWhenCsd:i=!1,showControlButtons:o=!0,chatVersion:s="mini",className:l,showLogoutButton:u=!0,showCreateConversation:c=!0,showConversationTitle:d=!0,showPlexo:g=!0,showFeedbackButtons:p=!0,showeditIcon:h=!0})=>{const v=od[e];console.log("theme que llega",e);const{addConversation:T,selectConversation:S,service:E,conversations:m}=Mt();return jr({enableAutoCreate:a,enableAutoCreateCsd:i,addConversation:T,selectConversation:S,service:E,conversations:m}),f.jsx(hS,{children:s==="mini"?f.jsx(K3,{showeditIcon:h,showPlexo:g,showFeedbackButtons:p,showLogoutButton:u,showDate:n,customLogo:t,themeDisplayName:v,showHeader:r,showCreateConversation:c,showControlButtons:o,className:l,showConversationTitle:d}):f.jsx(eD,{showDate:n,customLogo:t,showHeader:r,showCreateConversation:c,showControlButtons:o,className:l,showConversationTitle:d})})},Pr=D.pre`
|
|
1253
1253
|
display: flex;
|
|
1254
1254
|
justify-content: start;
|
|
1255
1255
|
align-items: center;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "minerva-plexus-csd",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "A reusable chat logic library for React applications",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.10",
|
|
6
6
|
"main": "dist/minerva-plexus-csd.umd.js",
|
|
7
7
|
"module": "dist/minerva-plexus-csd.es.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|