@rustic-ai/ui-components 0.3.0 → 1.0.0
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.
- package/dist/components/calendar/index.js +1 -1
- package/dist/components/codeSnippet/index.js +1 -1
- package/dist/components/dynamicForm/index.js +1 -1
- package/dist/components/elementRenderer/elementRenderer.d.ts.map +1 -1
- package/dist/components/elementRenderer/index.js +1 -1
- package/dist/components/image/index.js +1 -1
- package/dist/components/index.d.ts +1 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/input/multimodal/multimodalInput/index.js +1 -1
- package/dist/components/input/multimodal/uploader/index.js +1 -1
- package/dist/components/input/textInput/index.js +1 -1
- package/dist/components/map/index.js +1 -1
- package/dist/components/markdown/index.d.ts +1 -2
- package/dist/components/markdown/index.d.ts.map +1 -1
- package/dist/components/markdown/index.js +1 -1
- package/dist/components/markdown/markedMarkdown.d.ts +5 -9
- package/dist/components/markdown/markedMarkdown.d.ts.map +1 -1
- package/dist/components/media/audio/index.js +1 -1
- package/dist/components/media/video/index.js +1 -1
- package/dist/components/messageArchive/index.js +1 -1
- package/dist/components/messageArchive/messageArchive.d.ts +23 -5
- package/dist/components/messageArchive/messageArchive.d.ts.map +1 -1
- package/dist/components/messageCanvas/actions/copy/index.js +1 -1
- package/dist/components/messageCanvas/actions/index.js +1 -1
- package/dist/components/messageCanvas/actions/textToSpeech/index.js +1 -1
- package/dist/components/messageSpace/index.js +1 -1
- package/dist/components/messageSpace/messageSpace.d.ts +21 -5
- package/dist/components/messageSpace/messageSpace.d.ts.map +1 -1
- package/dist/components/multipart/chatCompletion/index.js +1 -1
- package/dist/components/multipart/multipart/index.js +1 -1
- package/dist/components/participantsContainer/index.js +1 -1
- package/dist/components/pdfViewer/index.js +1 -1
- package/dist/components/promptBuilder/index.js +1 -1
- package/dist/components/question/index.js +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/text/index.d.ts +1 -2
- package/dist/components/text/index.d.ts.map +1 -1
- package/dist/components/text/index.js +1 -1
- package/dist/components/text/text.d.ts +6 -6
- package/dist/components/text/text.d.ts.map +1 -1
- package/dist/components/types.d.ts +8 -0
- package/dist/components/types.d.ts.map +1 -1
- package/dist/components/visualization/mermaidViz/index.js +1 -1
- package/dist/components/visualization/perspectiveViz/index.js +1 -1
- package/dist/components/visualization/plotlyGraph/index.js +1 -1
- package/dist/components/visualization/vegaLiteViz/index.js +1 -1
- package/dist/components/visualization/vegaLiteViz/vegaLiteViz.d.ts +2 -1
- package/dist/components/visualization/vegaLiteViz/vegaLiteViz.d.ts.map +1 -1
- package/dist/components/weather/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/components/markdown/markedStreamingMarkdown.d.ts +0 -4
- package/dist/components/markdown/markedStreamingMarkdown.d.ts.map +0 -1
- package/dist/components/text/streamingText.d.ts +0 -4
- package/dist/components/text/streamingText.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MessageProcessStatus:()=>R,ParticipantRole:()=>k,ParticipantType:()=>q,default:()=>M});const r=require("react/jsx-runtime"),a=require("@fullcalendar/daygrid");var
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MessageProcessStatus:()=>R,ParticipantRole:()=>k,ParticipantType:()=>q,UpdateType:()=>S,default:()=>M});const r=require("react/jsx-runtime"),a=require("@fullcalendar/daygrid");var n=e.n(a);const o=require("@fullcalendar/react");var i=e.n(o);const d=require("@fullcalendar/timegrid");var c=e.n(d);const u=require("@mui/material/Box");var l=e.n(u);const s=require("@mui/material/styles"),p=require("@mui/material/Typography");var f=e.n(p);const m=require("@mui/material/useMediaQuery");var y=e.n(m);const b=require("react"),v=require("@mui/material/Alert");var g=e.n(v);const h=require("dompurify");var x=e.n(h);const j=require("marked");var R,S,k,q;!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(R||(R={})),function(e){e.Append="append",e.Replace="replace"}(S||(S={})),function(e){e.Owner="owner",e.Member="member"}(k||(k={})),function(e){e.Human="human",e.Agent="agent"}(q||(q={}));const D=function(e){var t=(0,b.useState)(e.text),a=t[0],n=t[1],o=(0,b.useState)(""),i=o[0],d=o[1];function c(e){return"string"!=typeof e?(d("Some of the incoming text was not correctly formatted. Some data may be missing.")," [MISSING TEXT]"):e}function u(e){return(0,r.jsx)(f(),{component:"div",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:(t=e,a=t.replace(/^[\u200B-\u200F\uFEFF]/,""),n=j.marked.parse(a,{async:!1}),x().sanitize(n))}});var t,a,n}return(0,b.useEffect)(function(){if(e.updatedData&&e.updatedData.length>0){var t=e.text,r=e.updatedData.at(-1);if(e.updatedData.length>1&&(null==r?void 0:r.updateType)===S.Replace)t=c(r.text);else for(var a=0,o=e.updatedData;a<o.length;a++){var i=o[a],d=i.updateType||S.Append,u=c(i.text);d===S.Append?t+=u:d===S.Replace&&(t=u)}n(t)}},[e.text,e.updatedData]),(0,r.jsxs)(r.Fragment,{children:[e.title&&(0,r.jsx)(f(),{variant:"h6",children:e.title}),e.description&&u(e.description),u(a),i&&(0,r.jsx)(g(),{severity:"error",children:i})]})};var T=function(){return T=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},T.apply(this,arguments)};function w(e){return{title:e.title?e.title:"",start:e.start,end:e.end,allDay:e.isAllDay}}const M=function(e){var t=(0,s.useTheme)(),a=y()(t.breakpoints.up("md"));return(0,r.jsxs)(l(),{className:"rustic-fc-calendar",sx:{border:"1px solid ".concat(t.palette.divider),borderRadius:"".concat(t.shape.borderRadius,"px"),".fc .fc-toolbar-title":T({},t.typography.h6),".fc .fc-scrollgrid-liquid":{borderRadius:"".concat(t.shape.borderRadius,"px")},".fc td":{borderRadius:"0 0 ".concat(t.shape.borderRadius,"px ").concat(t.shape.borderRadius,"px")},".fc .fc-scrollgrid-section-header > th":{borderRadius:"".concat(t.shape.borderRadius,"px ").concat(t.shape.borderRadius,"px 0 0")},".fc .fc-button, .fc .fc-button:active":{color:t.palette.primary.main,backgroundColor:t.palette.background.paper,border:"1px solid ".concat(t.palette.divider),borderRadius:"".concat(t.shape.borderRadius,"px"),"&:hover":{backgroundColor:t.palette.secondary.light,border:"1px solid ".concat(t.palette.divider)}},".fc .fc-button-group .fc-button.fc-button-active":{backgroundColor:t.palette.secondary.main,border:"1px solid ".concat(t.palette.divider)},".fc a, .fc .fc-event-title, .fc .fc-button, .fc .fc-timegrid-slot":T({},t.typography.caption)},children:[e.title&&(0,r.jsx)(f(),{variant:"h6",children:e.title}),e.description&&(0,r.jsx)(D,{text:e.description}),(0,r.jsx)(i(),{plugins:[c(),n()],initialView:a?"dayGridMonth":"timeGridDay",headerToolbar:{left:"title",right:"prev,next dayGridMonth,timeGridWeek,timeGridDay"},eventColor:t.palette.secondary.main,displayEventTime:!1,titleFormat:{year:"numeric",month:"long"},views:{dayGridMonth:{dayHeaderFormat:{weekday:a?"long":"narrow"}},timeGridWeek:{dayHeaderFormat:{weekday:"short",day:"numeric"}},timeGridDay:{dayHeaderFormat:{weekday:"long",day:"numeric"}}},allDaySlot:!1,initialDate:e.events[0].start,events:e.events.map(w)})]})};return t})());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MessageProcessStatus:()=>y,ParticipantRole:()=>
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MessageProcessStatus:()=>y,ParticipantRole:()=>x,ParticipantType:()=>v,UpdateType:()=>h,default:()=>j});const r=require("react/jsx-runtime"),n=require("@codemirror/language"),a=require("@codemirror/language-data"),i=require("@codemirror/state"),o=require("@codemirror/view"),u=require("@mui/material/Typography");var c=e.n(u);const d=require("@mui/system"),s=require("react"),l=require("@mui/material/Alert");var p=e.n(l);const f=require("dompurify");var m=e.n(f);const g=require("marked");var y,h,x,v;!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(y||(y={})),function(e){e.Append="append",e.Replace="replace"}(h||(h={})),function(e){e.Owner="owner",e.Member="member"}(x||(x={})),function(e){e.Human="human",e.Agent="agent"}(v||(v={}));const b=function(e){var t=(0,s.useState)(e.text),n=t[0],a=t[1],i=(0,s.useState)(""),o=i[0],u=i[1];function d(e){return"string"!=typeof e?(u("Some of the incoming text was not correctly formatted. Some data may be missing.")," [MISSING TEXT]"):e}function l(e){return(0,r.jsx)(c(),{component:"div",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:(t=e,n=t.replace(/^[\u200B-\u200F\uFEFF]/,""),a=g.marked.parse(n,{async:!1}),m().sanitize(a))}});var t,n,a}return(0,s.useEffect)(function(){if(e.updatedData&&e.updatedData.length>0){var t=e.text,r=e.updatedData.at(-1);if(e.updatedData.length>1&&(null==r?void 0:r.updateType)===h.Replace)t=d(r.text);else for(var n=0,i=e.updatedData;n<i.length;n++){var o=i[n],u=o.updateType||h.Append,c=d(o.text);u===h.Append?t+=c:u===h.Replace&&(t=c)}a(t)}},[e.text,e.updatedData]),(0,r.jsxs)(r.Fragment,{children:[e.title&&(0,r.jsx)(c(),{variant:"h6",children:e.title}),e.description&&l(e.description),l(n),o&&(0,r.jsx)(p(),{severity:"error",children:o})]})},j=function(e){var t=(0,s.useRef)(null),u=(0,s.useRef)(),l=new i.Compartment,p=[i.EditorState.readOnly.of(!0),(0,o.highlightSpecialChars)(),(0,n.syntaxHighlighting)(n.defaultHighlightStyle,{fallback:!0}),l.of([])],f=a.languages.find(function(t){return t.name.toLowerCase()===e.language.toLowerCase()});return(0,s.useEffect)(function(){if(t.current&&!u.current){var r=t.current,n=i.EditorState.create({doc:e.code,extensions:p});u.current=new o.EditorView({state:n,parent:r}),f&&u.current&&f.load().then(function(e){var t;null===(t=u.current)||void 0===t||t.dispatch({effects:l.reconfigure(e.extension)})})}},[]),(0,r.jsxs)(d.Box,{children:[e.title&&(0,r.jsx)(c(),{variant:"h6",children:e.title}),e.description&&(0,r.jsx)(b,{text:e.description}),(0,r.jsx)(d.Box,{className:"rustic-code-snippet",sx:{backgroundColor:"background.default"},"aria-label":"code snippet",ref:t,children:(0,r.jsx)(c(),{variant:"body2","aria-label":"language type",children:e.language})})]})};return t})());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,()=>(()=>{"use strict";var e={227:(e,r,t)=>{t.d(r,{A:()=>
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,()=>(()=>{"use strict";var e={227:(e,r,t)=>{t.d(r,{A:()=>m});var n=t(8732),a=t(5642),o=t.n(a),i=t(785),s=t.n(i),u=t(7447),d=t.n(u),c=t(3840),p=t(2015),l=t(7159);const m=function(e){var r=(0,p.useState)(e.text),t=r[0],a=r[1],i=(0,p.useState)(""),u=i[0],m=i[1];function f(e){return"string"!=typeof e?(m("Some of the incoming text was not correctly formatted. Some data may be missing.")," [MISSING TEXT]"):e}function v(e){return(0,n.jsx)(s(),{component:"div",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:(r=e,t=r.replace(/^[\u200B-\u200F\uFEFF]/,""),a=c.marked.parse(t,{async:!1}),d().sanitize(a))}});var r,t,a}return(0,p.useEffect)(function(){if(e.updatedData&&e.updatedData.length>0){var r=e.text,t=e.updatedData.at(-1);if(e.updatedData.length>1&&(null==t?void 0:t.updateType)===l.Ur.Replace)r=f(t.text);else for(var n=0,o=e.updatedData;n<o.length;n++){var i=o[n],s=i.updateType||l.Ur.Append,u=f(i.text);s===l.Ur.Append?r+=u:s===l.Ur.Replace&&(r=u)}a(r)}},[e.text,e.updatedData]),(0,n.jsxs)(n.Fragment,{children:[e.title&&(0,n.jsx)(s(),{variant:"h6",children:e.title}),e.description&&v(e.description),v(t),u&&(0,n.jsx)(o(),{severity:"error",children:u})]})}},7159:(e,r,t)=>{var n,a,o,i;t.d(r,{Ur:()=>a}),function(e){e.Running="running",e.Completed="completed",e.Error="error"}(n||(n={})),function(e){e.Append="append",e.Replace="replace"}(a||(a={})),function(e){e.Owner="owner",e.Member="member"}(o||(o={})),function(e){e.Human="human",e.Agent="agent"}(i||(i={}))},5642:e=>{e.exports=require("@mui/material/Alert")},6989:e=>{e.exports=require("@mui/material/Box")},785:e=>{e.exports=require("@mui/material/Typography")},7447:e=>{e.exports=require("dompurify")},3840:e=>{e.exports=require("marked")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")},3903:e=>{e.exports=require("uuid")}},r={};function t(n){var a=r[n];if(void 0!==a)return a.exports;var o=r[n]={exports:{}};return e[n](o,o.exports,t),o.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};t.r(n),t.d(n,{UniformsForm:()=>x});var a=t(8732),o=t(6989),i=t.n(o),s=t(785),u=t.n(s);const d=require("ajv");var c=t.n(d),p=t(2015);const l=require("uniforms-bridge-json-schema"),m=require("uniforms-mui");var f=t(3903),v=t(227);function x(e){var r=(0,p.useState)(e.data),t=r[0],n=r[1];(0,p.useEffect)(function(){e.data&&n(e.data)},[e.data]);var o,s,d=new(c())({allErrors:!0,useDefaults:!0,keywords:["uniforms"]}),x=(o=e.schema,s=d.compile(o),function(e){var r;return s(e),(null===(r=s.errors)||void 0===r?void 0:r.length)?{details:s.errors}:null}),y=new l.JSONSchemaBridge({schema:e.schema,validator:x});return(0,a.jsxs)(i(),{className:"rustic-form",children:[e.title&&(0,a.jsx)(u(),{variant:"h6",children:e.title}),e.description&&(0,a.jsx)(v.A,{text:e.description}),(0,a.jsx)(m.AutoForm,{schema:y,onSubmit:function(r){return function(r){var t,a=(new Date).toISOString(),o={id:(0,f.v4)(),timestamp:a,sender:e.sender,conversationId:e.conversationId,format:"formResponse",data:{data:r,inReplyTo:e.messageId}};n(r),null===(t=e.ws)||void 0===t||t.send(o)}(r)},model:t,disabled:!!t||!e.ws})]})}return n})());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elementRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/elementRenderer/elementRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE9E,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,eAAe,CAAA;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,iBAAiB,EAAE,YAAY,CAAA;CAChC;AAED,QAAA,MAAM,eAAe,GAAI,OAAO,oBAAoB,
|
|
1
|
+
{"version":3,"file":"elementRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/elementRenderer/elementRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE9E,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,eAAe,CAAA;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,iBAAiB,EAAE,YAAY,CAAA;CAChC;AAED,QAAA,MAAM,eAAe,GAAI,OAAO,oBAAoB,4CA6BnD,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>u});const r=require("react/jsx-runtime"),n=require("@mui/material/Typography");var o=e.n(n);const a=require("react");var s=e.n(a),i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)};const u=function(e){var t=e.messages[0],n=e.messages.slice(1),a=t.format;a.startsWith("update")&&(a=a.replace("update",""));var u=e.supportedElements[a];return(0,r.jsx)(r.Fragment,{children:u?s().createElement(u,i(i({sender:e.sender,ws:e.ws,messageId:t.id,conversationId:t.conversationId},t.data),n.length>0&&{updatedData:n.map(function(e){return e.data})})):(0,r.jsxs)(o(),{variant:"body2",children:["Unsupported element format: ",a]})})};return t})());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MessageProcessStatus:()=>
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MessageProcessStatus:()=>h,ParticipantRole:()=>g,ParticipantType:()=>v,UpdateType:()=>y,default:()=>O});const r=require("react/jsx-runtime"),n=require("@mui/material/CircularProgress");var a=e.n(n);const o=require("@mui/material/Typography");var i=e.n(o);const c=require("react");var u,s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},s.apply(this,arguments)};!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(u||(u={}));const d=require("@mui/material/Alert");var l=e.n(d);const p=require("dompurify");var f=e.n(p);const m=require("marked");var h,y,g,v;!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(h||(h={})),function(e){e.Append="append",e.Replace="replace"}(y||(y={})),function(e){e.Owner="owner",e.Member="member"}(g||(g={})),function(e){e.Human="human",e.Agent="agent"}(v||(v={}));const b=function(e){var t=(0,c.useState)(e.text),n=t[0],a=t[1],o=(0,c.useState)(""),u=o[0],s=o[1];function d(e){return"string"!=typeof e?(s("Some of the incoming text was not correctly formatted. Some data may be missing.")," [MISSING TEXT]"):e}function p(e){return(0,r.jsx)(i(),{component:"div",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:(t=e,n=t.replace(/^[\u200B-\u200F\uFEFF]/,""),a=m.marked.parse(n,{async:!1}),f().sanitize(a))}});var t,n,a}return(0,c.useEffect)(function(){if(e.updatedData&&e.updatedData.length>0){var t=e.text,r=e.updatedData.at(-1);if(e.updatedData.length>1&&(null==r?void 0:r.updateType)===y.Replace)t=d(r.text);else for(var n=0,o=e.updatedData;n<o.length;n++){var i=o[n],c=i.updateType||y.Append,u=d(i.text);c===y.Append?t+=u:c===y.Replace&&(t=u)}a(t)}},[e.text,e.updatedData]),(0,r.jsxs)(r.Fragment,{children:[e.title&&(0,r.jsx)(i(),{variant:"h6",children:e.title}),e.description&&p(e.description),p(n),u&&(0,r.jsx)(l(),{severity:"error",children:u})]})};var j=function(){return j=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},j.apply(this,arguments)};const O=function(e){var t,n,o,u=e.alt,d=void 0===u?"An image is displayed":u,l=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r}(e,["alt"]),p=(0,c.useState)(!0),f=p[0],m=p[1],h=(0,c.useState)(""),y=h[0],g=h[1],v=(0,c.useState)(""),O=v[0],x=v[1];return(0,c.useEffect)(function(){l.getAuthHeaders&&(m(!0),l.getAuthHeaders().then(function(e){return fetch(l.src,{headers:e.headers})}).then(function(e){return e.blob()}).then(function(e){var t=URL.createObjectURL(e);x(t)}).catch(function(){g("Image failed to load"),m(!1)}))},[l.src,l.getAuthHeaders]),y.length>0?(0,r.jsx)(i(),{variant:"body2",children:y}):(0,r.jsxs)("figure",{children:[f&&(0,r.jsx)(a(),{}),l.title&&(0,r.jsx)(i(),{variant:"h6",children:l.title}),(!l.getAuthHeaders||O)&&(0,r.jsx)("img",j({},(t=l.width,n=l.height,o={},t&&(o={width:t}),n&&(o=s(s({},o),{height:n})),t||n||(o={className:"rustic-fit-container"}),o),{src:l.getAuthHeaders?O:l.src,alt:d,onError:function(){g("Image failed to load"),m(!1)},onLoad:function(){m(!1)}})),l.description&&(0,r.jsx)("figcaption",{children:(0,r.jsx)(b,{text:l.description})})]})};return t})());
|
|
@@ -9,7 +9,6 @@ import Uploader from './input/multimodal/uploader/uploader';
|
|
|
9
9
|
import TextInput from './input/textInput/textInput';
|
|
10
10
|
import OpenLayersMap from './map/openLayersMap';
|
|
11
11
|
import MarkedMarkdown from './markdown/markedMarkdown';
|
|
12
|
-
import MarkedStreamingMarkdown from './markdown/markedStreamingMarkdown';
|
|
13
12
|
import Sound from './media/audio/sound';
|
|
14
13
|
import Video from './media/video/video';
|
|
15
14
|
import PopoverMenu from './menu/popoverMenu';
|
|
@@ -27,7 +26,6 @@ import PromptBuilder from './promptBuilder/promptBuilder';
|
|
|
27
26
|
import Prompts from './prompts/prompts';
|
|
28
27
|
import Question from './question/question';
|
|
29
28
|
import Table from './table/table';
|
|
30
|
-
import StreamingText from './text/streamingText';
|
|
31
29
|
import Text from './text/text';
|
|
32
30
|
import Timestamp from './timestamp/timestamp';
|
|
33
31
|
import MermaidViz from './visualization/mermaidViz/mermaidViz';
|
|
@@ -35,7 +33,7 @@ import PerspectiveViz from './visualization/perspectiveViz/perspectiveViz';
|
|
|
35
33
|
import PlotlyGraph from './visualization/plotlyGraph/plotlyGraph';
|
|
36
34
|
import VegaLiteViz from './visualization/vegaLiteViz/vegaLiteViz';
|
|
37
35
|
import Weather from './weather/weather';
|
|
38
|
-
export { Action, ChatCompletion, CodeSnippet, CopyText, ElementRenderer, FCCalendar, Icon, Image, MarkedMarkdown,
|
|
36
|
+
export { Action, ChatCompletion, CodeSnippet, CopyText, ElementRenderer, FCCalendar, Icon, Image, MarkedMarkdown, MermaidViz, MessageArchive, MessageCanvas, MessageSpace, MultimodalInput, Multipart, OpenLayersMap, ParticipantsContainer, PDFViewer, PerspectiveViz, PlotlyGraph, PopoverMenu, PromptBuilder, Prompts, Question, Sound, Table, Text, TextInput, TextToSpeech, Timestamp, UniformsForm, Uploader, VegaLiteViz, Video, Weather, };
|
|
39
37
|
export * from '../rusticTheme';
|
|
40
38
|
export { formatDateAndTime, getCombinedMessages } from './helper';
|
|
41
39
|
export type * from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,uBAAuB,CAAA;AAC9C,OAAO,WAAW,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,eAAe,MAAM,mCAAmC,CAAA;AAC/D,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,KAAK,MAAM,eAAe,CAAA;AACjC,OAAO,eAAe,MAAM,oDAAoD,CAAA;AAChF,OAAO,QAAQ,MAAM,sCAAsC,CAAA;AAC3D,OAAO,SAAS,MAAM,6BAA6B,CAAA;AACnD,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAC/C,OAAO,cAAc,MAAM,2BAA2B,CAAA;AACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,uBAAuB,CAAA;AAC9C,OAAO,WAAW,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,eAAe,MAAM,mCAAmC,CAAA;AAC/D,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,KAAK,MAAM,eAAe,CAAA;AACjC,OAAO,eAAe,MAAM,oDAAoD,CAAA;AAChF,OAAO,QAAQ,MAAM,sCAAsC,CAAA;AAC3D,OAAO,SAAS,MAAM,6BAA6B,CAAA;AACnD,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAC/C,OAAO,cAAc,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAC5C,OAAO,cAAc,MAAM,iCAAiC,CAAA;AAC5D,OAAO,QAAQ,MAAM,uCAAuC,CAAA;AAC5D,OAAO,MAAM,MAAM,+BAA+B,CAAA;AAClD,OAAO,YAAY,MAAM,mDAAmD,CAAA;AAC5E,OAAO,aAAa,MAAM,+BAA+B,CAAA;AACzD,OAAO,YAAY,MAAM,6BAA6B,CAAA;AACtD,OAAO,cAAc,MAAM,2CAA2C,CAAA;AACtE,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,OAAO,qBAAqB,MAAM,+CAA+C,CAAA;AACjF,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,aAAa,MAAM,+BAA+B,CAAA;AACzD,OAAO,OAAO,MAAM,mBAAmB,CAAA;AACvC,OAAO,QAAQ,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,MAAM,eAAe,CAAA;AACjC,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,UAAU,MAAM,uCAAuC,CAAA;AAC9D,OAAO,cAAc,MAAM,+CAA+C,CAAA;AAC1E,OAAO,WAAW,MAAM,yCAAyC,CAAA;AACjE,OAAO,WAAW,MAAM,yCAAyC,CAAA;AACjE,OAAO,OAAO,MAAM,mBAAmB,CAAA;AAEvC,OAAO,EACL,MAAM,EACN,cAAc,EACd,WAAW,EACX,QAAQ,EACR,eAAe,EACf,UAAU,EACV,IAAI,EACJ,KAAK,EACL,cAAc,EACd,UAAU,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,OAAO,EACP,QAAQ,EACR,KAAK,EACL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,OAAO,GACR,CAAA;AAED,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACjE,mBAAmB,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC1D,mBAAmB,6CAA6C,CAAA;AAChE,mBAAmB,+CAA+C,CAAA;AAClE,mBAAmB,+CAA+C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e,t,n={9767:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(8732),o=(n(2015),function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)});function a(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:o({},t),children:e.name})}},3110:(e,t,n)=>{n.d(t,{default:()=>r});const r=n(9767).A},8342:e=>{e.exports=require("emoji-picker-element")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var a=r[e]={exports:{}};return n[e](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var a=Object.create(null);o.r(a);var i={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&n;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>i[e]=()=>n[e]);return i.default=()=>n,o.d(a,i),a},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};o.r(a),o.d(a,{MessageProcessStatus:()=>Se,ParticipantRole:()=>Oe,ParticipantType:()=>Ce,default:()=>ke});var i=o(8732);const c=require("@mui/material/Box");var l=o.n(c);const s=require("@mui/material/styles");var u=o(2015);const d=require("uuid");var p;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(p||(p={}));const f=require("@mui/material/Avatar");var m=o.n(f);const h=require("@mui/material/CircularProgress");var v=o.n(h);const g=require("@mui/material/IconButton");var x=o.n(g);const b=require("@mui/material/InputAdornment");var y=o.n(b);const j=require("@mui/material/MenuItem");var w=o.n(j);const S=require("@mui/material/MenuList");var O=o.n(S);const C=require("@mui/material/Popover");var N=o.n(C);const F=require("@mui/material/TextField");var k=o.n(F);const P=require("@mui/material/Tooltip");var E=o.n(P);const I=require("@mui/material/Typography");var q=o.n(I),T=o(8342),A=o(9767);const R=function(e){var t=(0,s.useTheme)(),n=(0,u.useRef)(null),r=(0,u.useRef)(null),a=(0,u.useState)(!1),c=a[0],l=a[1],d={"--indicator-color":t.palette.divider,"--background":t.palette.background.paper,"--input-border-color":t.palette.divider,"--outline-color":t.palette.secondary.main};function p(){l(!1)}function f(t){t.detail.unicode&&e.onEmojiClick(t.detail.unicode),p()}return(0,u.useEffect)(function(){r.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then(function(n){var o=new(0,n.Picker)({dataSource:e.dataSource}),a="dark"===t.palette.mode?"dark":"light";o.classList.add(a),Object.keys(d).forEach(function(e){o.style.setProperty(e,d[e])}),r.current=o}).catch(function(e){console.error("Failed to load emoji picker",e)})},[]),(0,u.useEffect)(function(){return r.current&&r.current.addEventListener("emoji-click",f),function(){var e;null===(e=r.current)||void 0===e||e.removeEventListener("emoji-click",f)}},[c,e.onEmojiClick]),(0,i.jsxs)("div",{children:[(0,i.jsx)(E(),{title:"Emoji",children:(0,i.jsx)(x(),{size:"small",ref:n,onClick:function(){l(function(e){return!e})},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:"Mood"})})}),r.current&&(0,i.jsx)(N(),{open:c,anchorEl:n.current,onClose:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,i.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&r.current&&!e.contains(r.current)&&e.appendChild(r.current)}})})]})};var D={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function L(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}function M(e){return(0,i.jsxs)(l(),{className:"rustic-participant-profile",children:[(0,i.jsx)(m(),{src:e.icon,className:"rustic-participant-avatar"}),(0,i.jsx)(q(),{variant:"body1Bold",children:e.displayName})]})}function U(e){var t=e.items,n=e.isOpen,r=e.onClose,o=e.onSelect,a=e.renderItem,c=e.anchorEl,l=e.selectedIndex;return(0,i.jsx)(N(),{disableAutoFocus:!0,open:n&&t.length>0,anchorEl:c,onClose:r,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,i.jsx)(O(),{children:t.map(function(e,t){return(0,i.jsx)(w(),{onClick:function(){return o(e)},selected:t===l,children:a(e)},t)})})})}const _=(0,u.forwardRef)(function(e,t){var n=e.multiline,r=void 0===n||n,o=e.fullWidth,a=void 0===o||o,c=e.maxRows,s=void 0===c?6:c,p=e.enableSpeechToText,f=void 0!==p&&p,m=e.maximumEmojiSearchResults,h=void 0===m?5:m,g=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,u.useState)(""),j=b[0],w=b[1],S=(0,u.useState)(!1),O=S[0],C=S[1],N=(0,u.useState)(!1),F=N[0],P=N[1],I=(0,u.useState)(!1),_=I[0],z=I[1],H=(0,u.useState)(""),B=H[0],$=H[1],W=(0,u.useState)([]),K=W[0],G=W[1],Q=(0,u.useState)(!1),V=Q[0],Y=Q[1],Z=(0,u.useState)(0),J=Z[0],X=Z[1],ee=(0,u.useRef)(null),te=new T.Database({dataSource:g.emojiDataSource}),ne=!j.trim().length,re="".concat(O?"Stop":"Start"," speech to text"),oe=F?"primary.main":"primary.light",ae=O?"error.main":oe,ie=O?"stop_circle":"speech_to_text",ce=(0,u.useState)([]),le=ce[0],se=ce[1],ue=(0,u.useState)(!1),de=ue[0],pe=ue[1],fe=f&&"undefined"!=typeof window&&!!window.webkitSpeechRecognition;function me(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:ne}function he(e,t){if(ee.current){var n=ee.current,r=n.selectionStart,o=n.selectionEnd;if("number"==typeof r&&"number"==typeof o){var a,i=j||"",c=i.substring(0,r),l=i.substring(o),s=void 0;t?(s=c.replace(t,e)+l,a=c.replace(t,e).length):(s=c+e+l,a=r+e.length),w(s),setTimeout(function(){var e,t;null===(e=ee.current)||void 0===e||e.focus(),null===(t=ee.current)||void 0===t||t.setSelectionRange(a,a)},0)}}}function ve(e){he("@".concat(e," "),/@(\w*)$/),se([])}function ge(e,t){void 0===t&&(t=!1),he(e,t?/:(\w+)$/:void 0),Y(!1)}var xe=_?(0,i.jsx)(v(),{size:24}):(0,i.jsx)(E(),{title:re,children:(0,i.jsx)(x(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),z(!0),C(!1)):(e.start(),$(""),C(!0)),e.onstart=function(){C(!0)},e.onresult=function(e){var t,n=e.results[0][0].transcript;j.length>0?w(j+" "+n):w(n),null===(t=ee.current)||void 0===t||t.focus(),C(!1)},e.onerror=function(e){var t=D[e.error];$(t),C(!1)},e.onend=function(){z(!1),C(!1)}},size:"small",sx:{color:ae,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:ie})})});function be(){var e,t,n=(new Date).toISOString(),r={id:(0,d.v4)(),timestamp:n,sender:g.sender,conversationId:g.conversationId,format:"chatCompletionRequest",data:{text:j},inReplyTo:null===(e=g.lastMsg)||void 0===e?void 0:e.id,messageHistory:null===(t=g.lastMsg)||void 0===t?void 0:t.messageHistory};g.send(r),w(""),$("")}return(0,i.jsxs)(l(),{className:"rustic-base-input",ref:t,children:[(0,i.jsxs)(l(),{className:"rustic-error-and-input-container",children:[(0,i.jsx)(l(),{className:"rustic-error-container",children:(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:B})}),(0,i.jsxs)(l(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:F?"secondary.main":"action.disabled",backgroundColor:"background.paper"},children:[K.length>0&&ee.current&&(0,i.jsx)(U,{anchorEl:ee.current,items:K.filter(function(e){return"unicode"in e}),isOpen:V,onClose:function(){Y(!1),X(0)},onSelect:function(e){return ge(e.unicode,!0)},selectedIndex:J,renderItem:L}),le.length>0&&ee.current&&(0,i.jsx)(U,{anchorEl:ee.current,items:le,isOpen:de,onClose:function(){pe(!1),X(0)},onSelect:function(e){return ve(e.displayName)},renderItem:M,selectedIndex:J}),(0,i.jsx)(k(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:s,multiline:r,fullWidth:a,onKeyDown:function(e){var t,n="ArrowDown"===e.key,r="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),V&&K.length>0&&"unicode"in K[J]?ge(K[J].unicode,!0):de&&le.length>0?ve(le[J].displayName):e.shiftKey||me()||be();else{if(n||r)return e.preventDefault(),t=n?1:-1,void(V?X(function(e){return(e+t+K.length)%K.length}):de&&X(function(e){return(e+t+le.length)%le.length}));0!==J&&X(0)}},onChange:function(e){$("");var t=e.target.value;w(t),function(e){var t=e.match(/@(\w*)$/);if(t&&g.getMembers){var n=t[1].toLowerCase();g.getMembers().then(function(e){var t=e.filter(function(e){return e.displayName.toLowerCase().startsWith(n)});se(t),t.length>0?pe(!0):pe(!1)})}else se([])}(t);var n,r=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(r){var a=r[0].replace(/:/g,"");te.getEmojiByShortcode(a).then(function(e){if(e&&"unicode"in e){var n=t.replace(r[0],e.unicode);w(n)}else w(t)}).catch(function(){w(t)}),Y(!1)}else o?(n=o[0].replace(":",""),te.getEmojiBySearchQuery(n).then(function(e){e.length?(G(e.slice(0,h)),Y(!0)):(G([]),Y(!1))}).catch(function(){G([]),Y(!1)})):Y(!1)},onFocus:function(){return P(!0)},onBlur:function(){return P(!1)},inputRef:ee,color:"secondary",size:"small",autoFocus:g.autoFocus,slotProps:{input:{endAdornment:(0,i.jsxs)(y(),{position:"end",className:"rustic-input-adornment",children:[(0,i.jsx)(R,{dataSource:g.emojiDataSource,onEmojiClick:ge,buttonColor:oe}),fe&&xe]})},inputLabel:{className:F?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,i.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,i.jsxs)(l(),{className:"rustic-input-actions",children:[g.children,(0,i.jsx)(E(),{title:"Send",children:(0,i.jsx)("span",{className:"rustic-send-button",children:(0,i.jsx)(x(),{"aria-label":"send message",onClick:be,disabled:me(),color:"secondary",children:(0,i.jsx)(A.A,{name:"send"})})})})]})]})}),z=require("@mui/material/LinearProgress");var H=o.n(z);const B=require("axios");var $=o.n(B);const W=require("react-dom"),K=require("@mui/material/Card");var G=o.n(K);const Q=require("@mui/material/Modal");var V=o.n(Q);const Y=require("@mui/material/useMediaQuery");var Z=o.n(Y);const J=require("@mui/system/Stack");var X=o.n(J);const ee=require("@mui/system/useTheme");var te=o.n(ee);const ne=require("pdfjs-dist"),re=function(e){var t={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(t[e.action].label.replaceAll(" ","-").toLowerCase(),t[e.action]);return(0,i.jsx)(E(),{title:n.label,children:(0,i.jsx)("span",{children:(0,i.jsx)(x(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,i.jsx)(A.A,{name:n.symbol})})})})};var oe={pdf:function(e){var t,n=(0,u.useRef)(null),r=(0,u.useState)(1),o=r[0],a=r[1],c=(0,u.useState)(1),s=c[0],d=c[1],p=(0,u.useState)(1),f=p[0],m=p[1],h=(0,u.useState)(!1),v=h[0],g=h[1],x=(0,u.useState)(),b=x[0],y=x[1],j=te()(),w=Z()(j.breakpoints.down("sm")),S=Z()(j.breakpoints.between("sm","md"));if(t=e.url,!/\/[^/]+\.pdf$/.test(t))return(0,i.jsx)(G(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(q(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var O=(0,u.useState)(function(){return w?.5:S?1:1.5}),C=O[0],N=O[1];function F(t){ne.getDocument({url:e.url,httpHeaders:t}).promise.then(function(e){d(e.numPages),function(e){e.getPage(o).then(function(e){var t=e.getViewport({scale:C}),r=n.current;if(r){var o=r.getContext("2d");if(o){var a=window.devicePixelRatio||1;r.style.width="".concat(t.width,"px"),r.style.height="".concat(t.height,"px"),r.width=t.width*a,r.height=t.height*a;var i={canvasContext:o,viewport:t,transform:[a,0,0,a,0,0]};b&&b.cancel();var c=e.render(i);y(c),c.promise.then(function(){y(void 0)}).catch(function(e){console.error(e)})}}})}(e)}).catch(function(){g(!0)})}return(0,u.useEffect)(function(){ne.GlobalWorkerOptions.workerSrc||(ne.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(ne.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then(function(e){return F(e.headers)}).catch(function(){return g(!0)}):F()},[e.url,o,C]),v?(0,i.jsx)(G(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(q(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,i.jsxs)(G(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,i.jsxs)(l(),{className:"rustic-pdf-viewer-header",children:[(0,i.jsx)(re,{action:"zoomOut",onClick:function(){N(function(e){return Math.max(e-.2,.2)})}}),(0,i.jsx)(re,{action:"zoomIn",onClick:function(){N(function(e){return e+.2})}})]}),(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:n})})}),(0,i.jsxs)(X(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(re,{action:"previousPage",onClick:function(){o>1&&(a(o-1),m(o-1))},isDisabled:1===o}),(0,i.jsx)(q(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,i.jsx)(k(),{type:"number",value:f,onChange:function(e){var t=parseInt(e.target.value);m(t),!isNaN(t)&&t>=1&&t<=s&&a(t)},size:"small",className:"rustic-pdf-page-input"}),(0,i.jsxs)(q(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,i.jsx)(re,{action:"nextPage",onClick:function(){o<s&&(a(o+1),m(o+1))},isDisabled:o===s})]})]})}};function ae(e){var t=e.supportedViewers,n=void 0===t?oe:t,r=e.showFullName,o=void 0===r||r,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["supportedViewers","showFullName"]),c=(0,s.useTheme)(),l=(0,u.useState)(!1),d=l[0],p=l[1];function f(){p(!1)}var m,h,v=a.file.url&&(m=a.file.url.split("."))[m.length-1].toLowerCase(),g=v&&n?n[v]:null,b=!!g,y=b?" rustic-cursor-pointer":"",j="rustic-file-preview ".concat(o?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width").concat(y),w=o?a.file.name:(h=a.file.name).length<=15?h:h.substring(0,12)+"...";return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(G(),{className:j,variant:"outlined",sx:{boxShadow:c.shadows[1]},onClick:function(){p(!0)},children:[(0,i.jsx)(q(),{variant:"subtitle2",className:"rustic-file-preview-name",children:w}),(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:a.children})]}),b&&(0,i.jsx)(V(),{open:d,onClose:f,className:"rustic-file-preview-modal",children:(0,i.jsxs)("div",{className:"rustic-modal-content",children:[(0,i.jsx)(E(),{title:"Close",children:(0,i.jsx)(x(),{onClick:f,className:"rustic-close-button",children:(0,i.jsx)(A.A,{name:"close"})})}),a.file.url&&(0,i.jsx)(g,{url:a.file.url,getAuthHeaders:a.getAuthHeaders})]})})]})}var ie=o(3110);const ce=require("@mui/material"),le=require("@mui/material/Button");var se=o.n(le);const ue=require("@mui/material/Drawer");var de=o.n(ue);const pe=require("@mui/material/ListItemText");var fe=o.n(pe);const me=require("@mui/material/Menu");var he=o.n(me);const ve=require("@mui/system");var ge=function(){return ge=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ge.apply(this,arguments)};function xe(e){var t=(0,u.useState)(!1),n=t[0],r=t[1],o=(0,u.useRef)(null),a=(0,s.useTheme)(),c=(0,ce.useMediaQuery)(a.breakpoints.down("md")),l=c?de():he(),d={borderRadius:"".concat(a.shape.borderRadius,"px"),border:"1px solid ".concat(a.palette.divider)};function p(e){return(0,i.jsxs)(i.Fragment,{children:[e.startDecorator&&(0,i.jsx)(ve.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,i.jsx)(fe(),{children:(0,i.jsx)(q(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,i.jsx)(ve.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}c&&(d=ge(ge({},d),{borderRadius:"".concat(a.shape.borderRadius,"px ").concat(a.shape.borderRadius,"px 0 0"),borderBottom:0}));var f=e.menuItems.map(function(e){return e.href?(0,i.jsx)(w(),{component:"a",onClick:function(){return r(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:p(e)},e.label):(0,i.jsx)(w(),{onClick:function(t){e.onClick&&e.onClick(t),r(!1)},disabled:!e.onClick,children:p(e)},e.label)});var m,h,v=c?{}:{anchorEl:o.current};return(0,i.jsxs)(i.Fragment,{children:[(m={onClick:function(e){e.stopPropagation(),r(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,i.jsx)(A.A,{name:"more_vert"}),e.buttonText?(0,i.jsx)(se(),ge({},m,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,i.jsx)(E(),{title:e.ariaLabel,children:(0,i.jsx)(x(),ge({},m,{children:e.icon?e.icon:h}))})),(0,i.jsx)(l,ge({open:n,onClose:function(){return r(!1)}},v,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":ge(ge({},d),{backgroundImage:"none",boxShadow:a.shadows[2]})},children:f}))]})}var be=function(){return be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},ye=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function je(e){for(var t=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<t.length-1;)e/=1024,n++;var r=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(r," ").concat(t[n])}const we=function(e){var t,n=(0,u.useState)([]),r=n[0],o=n[1],a=(0,u.useState)([]),c=a[0],s=a[1],p=(0,u.useState)({}),f=p[0],m=p[1],h=(0,u.useRef)({}),v=(0,d.v4)();(0,u.useEffect)(function(){o([]),s([]),h.current={}},[e.messageId]);var g=e.getUploadHeaders?e.getUploadHeaders():Promise.resolve({headers:{}});function b(e,t,n){var r;h.current=be(be({},h.current),((r={})[e]=h.current[e]--,r)),function(e,t,n){s(function(t){return ye(ye([],t,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)}),o(function(e){return e.filter(function(e){return e.id!==t})})}(e,t,n)}var y=(0,i.jsx)(l(),{className:"rustic-files rustic-padding-16",children:r.map(function(t,n){return(0,i.jsx)(ae,{file:{name:t.name},showFullName:e.showFullName,children:(0,i.jsxs)(l(),{className:"rustic-flex-center",children:[t.loadingProgress<100&&(0,i.jsx)(H(),{variant:"determinate",color:"secondary",value:t.loadingProgress,className:"rustic-upload-progress"}),(0,i.jsx)(E(),{title:"Delete",children:(0,i.jsx)(x(),{color:"primary",onClick:function(){return function(t,n){var r,a;s([]);var i=t.name;if(h.current=be(be({},h.current),((r={})[i]=h.current[i]--,r)),e.onFileUpdate("remove",i),100===t.loadingProgress){var c="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",t.id);g.then(function(t){$().delete(c,be({},t)).then(function(){return o(function(e){return e.filter(function(e,t){return t!==n})})}).catch(function(){return e.onFileUpdate("add",i),s(function(e){return ye(ye([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)})})})}else t.abortController.abort(),o(function(e){return e.filter(function(e,t){return t!==n})}),h.current=be(be({},h.current),((a={})[i]=h.current[i]++,a))}(t,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)})}),j=(0,i.jsx)(l(),{children:c.map(function(e,t){return(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},t)})});function w(e,t){return t?(0,W.createPortal)(e,t):e}var S=null===(t=e.uploadOptions)||void 0===t?void 0:t.map(function(t){return{label:t.label,onClick:function(){return function(t){m(t.metadata);var n=document.getElementById(v);n&&(n.accept=t.acceptedFileTypes||e.acceptedFileTypes),n.click()}(t)},startDecorator:t.iconName&&(0,i.jsx)(ie.default,{name:t.iconName})}});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(l(),{className:"rustic-uploader",children:[(0,i.jsx)("label",{htmlFor:v,children:(null==S?void 0:S.length)?(0,i.jsx)(xe,{ariaLabel:"Upload",icon:(0,i.jsx)(ie.default,{name:"upload_2"}),menuItems:S}):(0,i.jsx)(E(),{title:"Upload",children:(0,i.jsx)(x(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,i.jsx)("input",{type:"file",id:v,onChange:function(t){s([]);var n=t.target.files&&Array.from(t.target.files),a=r.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&s(function(t){return ye(ye([],t,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)});var i=n&&function(e,t,n){return n?t<=n?e:e.slice(0,n-t):e}(n,a,e.maxFileCount);i&&i.forEach(function(t){!function(t){var n;e.maxFileSize&&t.size>e.maxFileSize?(n=t.name,s(function(t){return ye(ye([],t,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&je(e.maxFileSize),".")],!1)})):function(t){var n=new FormData,r=new AbortController,a=function(e){var t,n,r=e.name,o=h.current[r];if(o){var a=o+1,i=r.lastIndexOf("."),c=r.substring(0,i),l=r.substring(i);r="".concat(c,"(").concat(o,")").concat(l),h.current=be(be({},h.current),((t={})[e.name]=a,t))}else h.current=be(be({},h.current),((n={})[e.name]=1,n));return r}(t),i=new File([t],a,{type:t.type});if(e.getUploadData||f){var c=e.getUploadData?e.getUploadData(a):{},l=be(be({},c),f);Object.keys(l).forEach(function(e){var t=l[e];n.append(e,"object"==typeof t?JSON.stringify(t):t)})}n.append("file",i);var s=(0,d.v4)(),u={name:a,loadingProgress:0,abortController:r,id:s};function p(e){var t,n;e.total&&(t=e.loaded/e.total*100,n=u.id,o(function(e){var r=e.map(function(e){return e.id===n?be(be({},e),{loadingProgress:t}):e});return r}))}o(function(e){return ye(ye([],e,!0),[u],!1)}),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);!function i(){return g.then(function(c){return $().post(m,n,be(be({},c),{onUploadProgress:p,signal:r.signal})).then(function(t){var r,a,i=n.get("file");t.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,t.data.url),t.data.fileId&&(r=t.data,a=u.id,o(function(e){var t=e.findIndex(function(e){return e.id===a});if(-1!==t){var n=ye([],e,!0);return n[t]=be(be({},n[t]),{id:r.fileId}),n}return e}))}).catch(function(r){var c,l,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var p,f,m,h;409===(null===(c=r.response)||void 0===c?void 0:c.status)&&e.listFiles?(p=a.lastIndexOf("."),f=a.substring(0,p),m=a.substring(p),h=new RegExp("^".concat(f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(m,"$"),"i"),e.listFiles?e.listFiles().then(function(e){for(var t=0,n=0,r=e;n<r.length;n++){var o=r[n];if(h.test(o.name)){var a=o.name.match(h),i=a&&a[1]?parseInt(a[1].slice(1,-1),10):0;t=Math.max(t,i)}}return"".concat(f,"(").concat(t+1,")").concat(m)}):Promise.resolve(a)).then(function(r){e.onFileUpdate("add",r);var a=new File([t],r,{type:t.type});n.set("file",a),o(function(e){return e.map(function(e){return e.id===s?be(be({},e),{name:r,loadingProgress:0}):e})}),i()}).catch(function(){var e;b(t.name,u.id,null===(e=r.response)||void 0===e?void 0:e.data)}):b(t.name,u.id,null===(l=r.response)||void 0===l?void 0:l.data)})})}()}(t)}(t)}),t.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),c.length>0&&w(j,e.errorMessagesContainer),r.length>0&&w(y,e.filePreviewsContainer)]})};var Se,Oe,Ce,Ne=function(){return Ne=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ne.apply(this,arguments)},Fe=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(Se||(Se={})),function(e){e.Owner="owner",e.Member="member"}(Oe||(Oe={})),function(e){e.Human="human",e.Agent="agent"}(Ce||(Ce={}));const ke=function(e){var t=e.maxFileSize,n=void 0===t?2097152:t,r=e.maxFileCount,o=void 0===r?1:r,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["maxFileSize","maxFileCount"]),c=(0,u.useState)({uploaded:[],fileList:[]}),p=c[0],f=c[1],m=(0,u.useState)((0,d.v4)()),h=m[0],v=m[1],g=(0,u.useState)(),x=g[0],b=g[1],y=(0,u.useState)(),j=y[0],w=y[1],S=(0,u.useRef)(null),O=(0,s.useTheme)(),C=p.fileList.length>0,N=p.uploaded.length===p.fileList.length&&p.uploaded.length>0;return(0,u.useEffect)(function(){S.current&&(w(S.current.querySelector(".rustic-error-container")),b(S.current.querySelector(".rustic-input-extras")))}),(0,i.jsx)(l(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(O.palette.action.disabled),borderRadius:"".concat(O.shape.borderRadius,"px"),":focus-within":{borderColor:O.palette.secondary.main},background:O.palette.background.paper},children:(0,i.jsx)(_,Ne({},a,{send:function(e){e.data=function(e,t,n){var r=e.id,o=[];if(t&&(null==t?void 0:t.trim().length)&&o.push({type:"text",text:t}),n&&n.length>0)for(var a=0;a<(null==n?void 0:n.length);a++)o.push({type:"file_url",file_url:{url:n[a].url,name:n[a].name}});return{messages:[{content:o,role:"user",name:r}]}}(e.sender,e.data.text,p.uploaded.map(function(e){return{url:e.url,name:e.name}})),e.id=h,a.ws.send(e),v((0,d.v4)()),f({uploaded:[],fileList:[]})},isSendEnabled:C?N:void 0,ref:S,children:(0,i.jsx)(l(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(we,{acceptedFileTypes:a.acceptedFileTypes,maxFileCount:o,maxFileSize:n,uploadFileEndpoint:a.uploadFileEndpoint,deleteFileEndpoint:a.deleteFileEndpoint,onFileUpdate:function(e,t,n){if("add"===e)f(function(e){return Ne(Ne({},e),{fileList:Fe(Fe([],e.fileList,!0),[{name:t}],!1)})});else if("update"===e){if(!n)return void console.error("URL is required for the 'update' action");f(function(e){var r=e.fileList.findIndex(function(e){return e.name===t}),o=Fe(Fe(Fe([],e.uploaded.slice(0,r),!0),[{name:t,url:n}],!1),e.uploaded.slice(r),!0);return Ne(Ne({},e),{uploaded:o})})}else f(function(e){return{uploaded:e.uploaded.filter(function(e){return e.name!==t}),fileList:e.fileList.filter(function(e){return e.name!==t})}})},messageId:h,filePreviewsContainer:x,errorMessagesContainer:j,showFullName:a.showFullName,getUploadData:a.getUploadData,uploadOptions:a.uploadOptions,listFiles:a.listFiles,getUploadHeaders:a.getUploadHeaders})})}))})};return a})());
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e,t,n={9767:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(8732),o=(n(2015),function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)});function a(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:o({},t),children:e.name})}},3110:(e,t,n)=>{n.d(t,{default:()=>r});const r=n(9767).A},8342:e=>{e.exports=require("emoji-picker-element")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var a=r[e]={exports:{}};return n[e](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var a=Object.create(null);o.r(a);var i={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&n;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>i[e]=()=>n[e]);return i.default=()=>n,o.d(a,i),a},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};o.r(a),o.d(a,{MessageProcessStatus:()=>Se,ParticipantRole:()=>Ce,ParticipantType:()=>Ne,UpdateType:()=>Oe,default:()=>Pe});var i=o(8732);const c=require("@mui/material/Box");var l=o.n(c);const s=require("@mui/material/styles");var u=o(2015);const d=require("uuid");var p;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(p||(p={}));const f=require("@mui/material/Avatar");var m=o.n(f);const h=require("@mui/material/CircularProgress");var v=o.n(h);const g=require("@mui/material/IconButton");var x=o.n(g);const b=require("@mui/material/InputAdornment");var y=o.n(b);const j=require("@mui/material/MenuItem");var w=o.n(j);const S=require("@mui/material/MenuList");var O=o.n(S);const C=require("@mui/material/Popover");var N=o.n(C);const F=require("@mui/material/TextField");var k=o.n(F);const P=require("@mui/material/Tooltip");var E=o.n(P);const I=require("@mui/material/Typography");var q=o.n(I),T=o(8342),A=o(9767);const R=function(e){var t=(0,s.useTheme)(),n=(0,u.useRef)(null),r=(0,u.useRef)(null),a=(0,u.useState)(!1),c=a[0],l=a[1],d={"--indicator-color":t.palette.divider,"--background":t.palette.background.paper,"--input-border-color":t.palette.divider,"--outline-color":t.palette.secondary.main};function p(){l(!1)}function f(t){t.detail.unicode&&e.onEmojiClick(t.detail.unicode),p()}return(0,u.useEffect)(function(){r.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then(function(n){var o=new(0,n.Picker)({dataSource:e.dataSource}),a="dark"===t.palette.mode?"dark":"light";o.classList.add(a),Object.keys(d).forEach(function(e){o.style.setProperty(e,d[e])}),r.current=o}).catch(function(e){console.error("Failed to load emoji picker",e)})},[]),(0,u.useEffect)(function(){return r.current&&r.current.addEventListener("emoji-click",f),function(){var e;null===(e=r.current)||void 0===e||e.removeEventListener("emoji-click",f)}},[c,e.onEmojiClick]),(0,i.jsxs)("div",{children:[(0,i.jsx)(E(),{title:"Emoji",children:(0,i.jsx)(x(),{size:"small",ref:n,onClick:function(){l(function(e){return!e})},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:"Mood"})})}),r.current&&(0,i.jsx)(N(),{open:c,anchorEl:n.current,onClose:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,i.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&r.current&&!e.contains(r.current)&&e.appendChild(r.current)}})})]})};var D={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function U(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}function L(e){return(0,i.jsxs)(l(),{className:"rustic-participant-profile",children:[(0,i.jsx)(m(),{src:e.icon,className:"rustic-participant-avatar"}),(0,i.jsx)(q(),{variant:"body1Bold",children:e.displayName})]})}function M(e){var t=e.items,n=e.isOpen,r=e.onClose,o=e.onSelect,a=e.renderItem,c=e.anchorEl,l=e.selectedIndex;return(0,i.jsx)(N(),{disableAutoFocus:!0,open:n&&t.length>0,anchorEl:c,onClose:r,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,i.jsx)(O(),{children:t.map(function(e,t){return(0,i.jsx)(w(),{onClick:function(){return o(e)},selected:t===l,children:a(e)},t)})})})}const _=(0,u.forwardRef)(function(e,t){var n=e.multiline,r=void 0===n||n,o=e.fullWidth,a=void 0===o||o,c=e.maxRows,s=void 0===c?6:c,p=e.enableSpeechToText,f=void 0!==p&&p,m=e.maximumEmojiSearchResults,h=void 0===m?5:m,g=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,u.useState)(""),j=b[0],w=b[1],S=(0,u.useState)(!1),O=S[0],C=S[1],N=(0,u.useState)(!1),F=N[0],P=N[1],I=(0,u.useState)(!1),_=I[0],z=I[1],H=(0,u.useState)(""),B=H[0],$=H[1],W=(0,u.useState)([]),K=W[0],G=W[1],Q=(0,u.useState)(!1),V=Q[0],Y=Q[1],Z=(0,u.useState)(0),J=Z[0],X=Z[1],ee=(0,u.useRef)(null),te=new T.Database({dataSource:g.emojiDataSource}),ne=!j.trim().length,re="".concat(O?"Stop":"Start"," speech to text"),oe=F?"primary.main":"primary.light",ae=O?"error.main":oe,ie=O?"stop_circle":"speech_to_text",ce=(0,u.useState)([]),le=ce[0],se=ce[1],ue=(0,u.useState)(!1),de=ue[0],pe=ue[1],fe=f&&"undefined"!=typeof window&&!!window.webkitSpeechRecognition;function me(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:ne}function he(e,t){if(ee.current){var n=ee.current,r=n.selectionStart,o=n.selectionEnd;if("number"==typeof r&&"number"==typeof o){var a,i=j||"",c=i.substring(0,r),l=i.substring(o),s=void 0;t?(s=c.replace(t,e)+l,a=c.replace(t,e).length):(s=c+e+l,a=r+e.length),w(s),setTimeout(function(){var e,t;null===(e=ee.current)||void 0===e||e.focus(),null===(t=ee.current)||void 0===t||t.setSelectionRange(a,a)},0)}}}function ve(e){he("@".concat(e," "),/@(\w*)$/),se([])}function ge(e,t){void 0===t&&(t=!1),he(e,t?/:(\w+)$/:void 0),Y(!1)}var xe=_?(0,i.jsx)(v(),{size:24}):(0,i.jsx)(E(),{title:re,children:(0,i.jsx)(x(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),z(!0),C(!1)):(e.start(),$(""),C(!0)),e.onstart=function(){C(!0)},e.onresult=function(e){var t,n=e.results[0][0].transcript;j.length>0?w(j+" "+n):w(n),null===(t=ee.current)||void 0===t||t.focus(),C(!1)},e.onerror=function(e){var t=D[e.error];$(t),C(!1)},e.onend=function(){z(!1),C(!1)}},size:"small",sx:{color:ae,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:ie})})});function be(){var e,t,n=(new Date).toISOString(),r={id:(0,d.v4)(),timestamp:n,sender:g.sender,conversationId:g.conversationId,format:"chatCompletionRequest",data:{text:j},inReplyTo:null===(e=g.lastMsg)||void 0===e?void 0:e.id,messageHistory:null===(t=g.lastMsg)||void 0===t?void 0:t.messageHistory};g.send(r),w(""),$("")}return(0,i.jsxs)(l(),{className:"rustic-base-input",ref:t,children:[(0,i.jsxs)(l(),{className:"rustic-error-and-input-container",children:[(0,i.jsx)(l(),{className:"rustic-error-container",children:(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:B})}),(0,i.jsxs)(l(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:F?"secondary.main":"action.disabled",backgroundColor:"background.paper"},children:[K.length>0&&ee.current&&(0,i.jsx)(M,{anchorEl:ee.current,items:K.filter(function(e){return"unicode"in e}),isOpen:V,onClose:function(){Y(!1),X(0)},onSelect:function(e){return ge(e.unicode,!0)},selectedIndex:J,renderItem:U}),le.length>0&&ee.current&&(0,i.jsx)(M,{anchorEl:ee.current,items:le,isOpen:de,onClose:function(){pe(!1),X(0)},onSelect:function(e){return ve(e.displayName)},renderItem:L,selectedIndex:J}),(0,i.jsx)(k(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:s,multiline:r,fullWidth:a,onKeyDown:function(e){var t,n="ArrowDown"===e.key,r="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),V&&K.length>0&&"unicode"in K[J]?ge(K[J].unicode,!0):de&&le.length>0?ve(le[J].displayName):e.shiftKey||me()||be();else{if(n||r)return e.preventDefault(),t=n?1:-1,void(V?X(function(e){return(e+t+K.length)%K.length}):de&&X(function(e){return(e+t+le.length)%le.length}));0!==J&&X(0)}},onChange:function(e){$("");var t=e.target.value;w(t),function(e){var t=e.match(/@(\w*)$/);if(t&&g.getMembers){var n=t[1].toLowerCase();g.getMembers().then(function(e){var t=e.filter(function(e){return e.displayName.toLowerCase().startsWith(n)});se(t),t.length>0?pe(!0):pe(!1)})}else se([])}(t);var n,r=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(r){var a=r[0].replace(/:/g,"");te.getEmojiByShortcode(a).then(function(e){if(e&&"unicode"in e){var n=t.replace(r[0],e.unicode);w(n)}else w(t)}).catch(function(){w(t)}),Y(!1)}else o?(n=o[0].replace(":",""),te.getEmojiBySearchQuery(n).then(function(e){e.length?(G(e.slice(0,h)),Y(!0)):(G([]),Y(!1))}).catch(function(){G([]),Y(!1)})):Y(!1)},onFocus:function(){return P(!0)},onBlur:function(){return P(!1)},inputRef:ee,color:"secondary",size:"small",autoFocus:g.autoFocus,slotProps:{input:{endAdornment:(0,i.jsxs)(y(),{position:"end",className:"rustic-input-adornment",children:[(0,i.jsx)(R,{dataSource:g.emojiDataSource,onEmojiClick:ge,buttonColor:oe}),fe&&xe]})},inputLabel:{className:F?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,i.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,i.jsxs)(l(),{className:"rustic-input-actions",children:[g.children,(0,i.jsx)(E(),{title:"Send",children:(0,i.jsx)("span",{className:"rustic-send-button",children:(0,i.jsx)(x(),{"aria-label":"send message",onClick:be,disabled:me(),color:"secondary",children:(0,i.jsx)(A.A,{name:"send"})})})})]})]})}),z=require("@mui/material/LinearProgress");var H=o.n(z);const B=require("axios");var $=o.n(B);const W=require("react-dom"),K=require("@mui/material/Card");var G=o.n(K);const Q=require("@mui/material/Modal");var V=o.n(Q);const Y=require("@mui/material/useMediaQuery");var Z=o.n(Y);const J=require("@mui/system/Stack");var X=o.n(J);const ee=require("@mui/system/useTheme");var te=o.n(ee);const ne=require("pdfjs-dist"),re=function(e){var t={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(t[e.action].label.replaceAll(" ","-").toLowerCase(),t[e.action]);return(0,i.jsx)(E(),{title:n.label,children:(0,i.jsx)("span",{children:(0,i.jsx)(x(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,i.jsx)(A.A,{name:n.symbol})})})})};var oe={pdf:function(e){var t,n=(0,u.useRef)(null),r=(0,u.useState)(1),o=r[0],a=r[1],c=(0,u.useState)(1),s=c[0],d=c[1],p=(0,u.useState)(1),f=p[0],m=p[1],h=(0,u.useState)(!1),v=h[0],g=h[1],x=(0,u.useState)(),b=x[0],y=x[1],j=te()(),w=Z()(j.breakpoints.down("sm")),S=Z()(j.breakpoints.between("sm","md"));if(t=e.url,!/\/[^/]+\.pdf$/.test(t))return(0,i.jsx)(G(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(q(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var O=(0,u.useState)(function(){return w?.5:S?1:1.5}),C=O[0],N=O[1];function F(t){ne.getDocument({url:e.url,httpHeaders:t}).promise.then(function(e){d(e.numPages),function(e){e.getPage(o).then(function(e){var t=e.getViewport({scale:C}),r=n.current;if(r){var o=r.getContext("2d");if(o){var a=window.devicePixelRatio||1;r.style.width="".concat(t.width,"px"),r.style.height="".concat(t.height,"px"),r.width=t.width*a,r.height=t.height*a;var i={canvasContext:o,viewport:t,transform:[a,0,0,a,0,0]};b&&b.cancel();var c=e.render(i);y(c),c.promise.then(function(){y(void 0)}).catch(function(e){console.error(e)})}}})}(e)}).catch(function(){g(!0)})}return(0,u.useEffect)(function(){ne.GlobalWorkerOptions.workerSrc||(ne.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(ne.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then(function(e){return F(e.headers)}).catch(function(){return g(!0)}):F()},[e.url,o,C]),v?(0,i.jsx)(G(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(q(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,i.jsxs)(G(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,i.jsxs)(l(),{className:"rustic-pdf-viewer-header",children:[(0,i.jsx)(re,{action:"zoomOut",onClick:function(){N(function(e){return Math.max(e-.2,.2)})}}),(0,i.jsx)(re,{action:"zoomIn",onClick:function(){N(function(e){return e+.2})}})]}),(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:n})})}),(0,i.jsxs)(X(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(re,{action:"previousPage",onClick:function(){o>1&&(a(o-1),m(o-1))},isDisabled:1===o}),(0,i.jsx)(q(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,i.jsx)(k(),{type:"number",value:f,onChange:function(e){var t=parseInt(e.target.value);m(t),!isNaN(t)&&t>=1&&t<=s&&a(t)},size:"small",className:"rustic-pdf-page-input"}),(0,i.jsxs)(q(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,i.jsx)(re,{action:"nextPage",onClick:function(){o<s&&(a(o+1),m(o+1))},isDisabled:o===s})]})]})}};function ae(e){var t=e.supportedViewers,n=void 0===t?oe:t,r=e.showFullName,o=void 0===r||r,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["supportedViewers","showFullName"]),c=(0,s.useTheme)(),l=(0,u.useState)(!1),d=l[0],p=l[1];function f(){p(!1)}var m,h,v=a.file.url&&(m=a.file.url.split("."))[m.length-1].toLowerCase(),g=v&&n?n[v]:null,b=!!g,y=b?" rustic-cursor-pointer":"",j="rustic-file-preview ".concat(o?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width").concat(y),w=o?a.file.name:(h=a.file.name).length<=15?h:h.substring(0,12)+"...";return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(G(),{className:j,variant:"outlined",sx:{boxShadow:c.shadows[1]},onClick:function(){p(!0)},children:[(0,i.jsx)(q(),{variant:"subtitle2",className:"rustic-file-preview-name",children:w}),(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:a.children})]}),b&&(0,i.jsx)(V(),{open:d,onClose:f,className:"rustic-file-preview-modal",children:(0,i.jsxs)("div",{className:"rustic-modal-content",children:[(0,i.jsx)(E(),{title:"Close",children:(0,i.jsx)(x(),{onClick:f,className:"rustic-close-button",children:(0,i.jsx)(A.A,{name:"close"})})}),a.file.url&&(0,i.jsx)(g,{url:a.file.url,getAuthHeaders:a.getAuthHeaders})]})})]})}var ie=o(3110);const ce=require("@mui/material"),le=require("@mui/material/Button");var se=o.n(le);const ue=require("@mui/material/Drawer");var de=o.n(ue);const pe=require("@mui/material/ListItemText");var fe=o.n(pe);const me=require("@mui/material/Menu");var he=o.n(me);const ve=require("@mui/system");var ge=function(){return ge=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ge.apply(this,arguments)};function xe(e){var t=(0,u.useState)(!1),n=t[0],r=t[1],o=(0,u.useRef)(null),a=(0,s.useTheme)(),c=(0,ce.useMediaQuery)(a.breakpoints.down("md")),l=c?de():he(),d={borderRadius:"".concat(a.shape.borderRadius,"px"),border:"1px solid ".concat(a.palette.divider)};function p(e){return(0,i.jsxs)(i.Fragment,{children:[e.startDecorator&&(0,i.jsx)(ve.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,i.jsx)(fe(),{children:(0,i.jsx)(q(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,i.jsx)(ve.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}c&&(d=ge(ge({},d),{borderRadius:"".concat(a.shape.borderRadius,"px ").concat(a.shape.borderRadius,"px 0 0"),borderBottom:0}));var f=e.menuItems.map(function(e){return e.href?(0,i.jsx)(w(),{component:"a",onClick:function(){return r(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:p(e)},e.label):(0,i.jsx)(w(),{onClick:function(t){e.onClick&&e.onClick(t),r(!1)},disabled:!e.onClick,children:p(e)},e.label)});var m,h,v=c?{}:{anchorEl:o.current};return(0,i.jsxs)(i.Fragment,{children:[(m={onClick:function(e){e.stopPropagation(),r(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,i.jsx)(A.A,{name:"more_vert"}),e.buttonText?(0,i.jsx)(se(),ge({},m,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,i.jsx)(E(),{title:e.ariaLabel,children:(0,i.jsx)(x(),ge({},m,{children:e.icon?e.icon:h}))})),(0,i.jsx)(l,ge({open:n,onClose:function(){return r(!1)}},v,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":ge(ge({},d),{backgroundImage:"none",boxShadow:a.shadows[2]})},children:f}))]})}var be=function(){return be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},ye=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function je(e){for(var t=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<t.length-1;)e/=1024,n++;var r=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(r," ").concat(t[n])}const we=function(e){var t,n=(0,u.useState)([]),r=n[0],o=n[1],a=(0,u.useState)([]),c=a[0],s=a[1],p=(0,u.useState)({}),f=p[0],m=p[1],h=(0,u.useRef)({}),v=(0,d.v4)();(0,u.useEffect)(function(){o([]),s([]),h.current={}},[e.messageId]);var g=e.getUploadHeaders?e.getUploadHeaders():Promise.resolve({headers:{}});function b(e,t,n){var r;h.current=be(be({},h.current),((r={})[e]=h.current[e]--,r)),function(e,t,n){s(function(t){return ye(ye([],t,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)}),o(function(e){return e.filter(function(e){return e.id!==t})})}(e,t,n)}var y=(0,i.jsx)(l(),{className:"rustic-files rustic-padding-16",children:r.map(function(t,n){return(0,i.jsx)(ae,{file:{name:t.name},showFullName:e.showFullName,children:(0,i.jsxs)(l(),{className:"rustic-flex-center",children:[t.loadingProgress<100&&(0,i.jsx)(H(),{variant:"determinate",color:"secondary",value:t.loadingProgress,className:"rustic-upload-progress"}),(0,i.jsx)(E(),{title:"Delete",children:(0,i.jsx)(x(),{color:"primary",onClick:function(){return function(t,n){var r,a;s([]);var i=t.name;if(h.current=be(be({},h.current),((r={})[i]=h.current[i]--,r)),e.onFileUpdate("remove",i),100===t.loadingProgress){var c="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",t.id);g.then(function(t){$().delete(c,be({},t)).then(function(){return o(function(e){return e.filter(function(e,t){return t!==n})})}).catch(function(){return e.onFileUpdate("add",i),s(function(e){return ye(ye([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)})})})}else t.abortController.abort(),o(function(e){return e.filter(function(e,t){return t!==n})}),h.current=be(be({},h.current),((a={})[i]=h.current[i]++,a))}(t,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)})}),j=(0,i.jsx)(l(),{children:c.map(function(e,t){return(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},t)})});function w(e,t){return t?(0,W.createPortal)(e,t):e}var S=null===(t=e.uploadOptions)||void 0===t?void 0:t.map(function(t){return{label:t.label,onClick:function(){return function(t){m(t.metadata);var n=document.getElementById(v);n&&(n.accept=t.acceptedFileTypes||e.acceptedFileTypes),n.click()}(t)},startDecorator:t.iconName&&(0,i.jsx)(ie.default,{name:t.iconName})}});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(l(),{className:"rustic-uploader",children:[(0,i.jsx)("label",{htmlFor:v,children:(null==S?void 0:S.length)?(0,i.jsx)(xe,{ariaLabel:"Upload",icon:(0,i.jsx)(ie.default,{name:"upload_2"}),menuItems:S}):(0,i.jsx)(E(),{title:"Upload",children:(0,i.jsx)(x(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,i.jsx)("input",{type:"file",id:v,onChange:function(t){s([]);var n=t.target.files&&Array.from(t.target.files),a=r.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&s(function(t){return ye(ye([],t,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)});var i=n&&function(e,t,n){return n?t<=n?e:e.slice(0,n-t):e}(n,a,e.maxFileCount);i&&i.forEach(function(t){!function(t){var n;e.maxFileSize&&t.size>e.maxFileSize?(n=t.name,s(function(t){return ye(ye([],t,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&je(e.maxFileSize),".")],!1)})):function(t){var n=new FormData,r=new AbortController,a=function(e){var t,n,r=e.name,o=h.current[r];if(o){var a=o+1,i=r.lastIndexOf("."),c=r.substring(0,i),l=r.substring(i);r="".concat(c,"(").concat(o,")").concat(l),h.current=be(be({},h.current),((t={})[e.name]=a,t))}else h.current=be(be({},h.current),((n={})[e.name]=1,n));return r}(t),i=new File([t],a,{type:t.type});if(e.getUploadData||f){var c=e.getUploadData?e.getUploadData(a):{},l=be(be({},c),f);Object.keys(l).forEach(function(e){var t=l[e];n.append(e,"object"==typeof t?JSON.stringify(t):t)})}n.append("file",i);var s=(0,d.v4)(),u={name:a,loadingProgress:0,abortController:r,id:s};function p(e){var t,n;e.total&&(t=e.loaded/e.total*100,n=u.id,o(function(e){var r=e.map(function(e){return e.id===n?be(be({},e),{loadingProgress:t}):e});return r}))}o(function(e){return ye(ye([],e,!0),[u],!1)}),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);!function i(){return g.then(function(c){return $().post(m,n,be(be({},c),{onUploadProgress:p,signal:r.signal})).then(function(t){var r,a,i=n.get("file");t.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,t.data.url),t.data.fileId&&(r=t.data,a=u.id,o(function(e){var t=e.findIndex(function(e){return e.id===a});if(-1!==t){var n=ye([],e,!0);return n[t]=be(be({},n[t]),{id:r.fileId}),n}return e}))}).catch(function(r){var c,l,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var p,f,m,h;409===(null===(c=r.response)||void 0===c?void 0:c.status)&&e.listFiles?(p=a.lastIndexOf("."),f=a.substring(0,p),m=a.substring(p),h=new RegExp("^".concat(f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(m,"$"),"i"),e.listFiles?e.listFiles().then(function(e){for(var t=0,n=0,r=e;n<r.length;n++){var o=r[n];if(h.test(o.name)){var a=o.name.match(h),i=a&&a[1]?parseInt(a[1].slice(1,-1),10):0;t=Math.max(t,i)}}return"".concat(f,"(").concat(t+1,")").concat(m)}):Promise.resolve(a)).then(function(r){e.onFileUpdate("add",r);var a=new File([t],r,{type:t.type});n.set("file",a),o(function(e){return e.map(function(e){return e.id===s?be(be({},e),{name:r,loadingProgress:0}):e})}),i()}).catch(function(){var e;b(t.name,u.id,null===(e=r.response)||void 0===e?void 0:e.data)}):b(t.name,u.id,null===(l=r.response)||void 0===l?void 0:l.data)})})}()}(t)}(t)}),t.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),c.length>0&&w(j,e.errorMessagesContainer),r.length>0&&w(y,e.filePreviewsContainer)]})};var Se,Oe,Ce,Ne,Fe=function(){return Fe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Fe.apply(this,arguments)},ke=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(Se||(Se={})),function(e){e.Append="append",e.Replace="replace"}(Oe||(Oe={})),function(e){e.Owner="owner",e.Member="member"}(Ce||(Ce={})),function(e){e.Human="human",e.Agent="agent"}(Ne||(Ne={}));const Pe=function(e){var t=e.maxFileSize,n=void 0===t?2097152:t,r=e.maxFileCount,o=void 0===r?1:r,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["maxFileSize","maxFileCount"]),c=(0,u.useState)({uploaded:[],fileList:[]}),p=c[0],f=c[1],m=(0,u.useState)((0,d.v4)()),h=m[0],v=m[1],g=(0,u.useState)(),x=g[0],b=g[1],y=(0,u.useState)(),j=y[0],w=y[1],S=(0,u.useRef)(null),O=(0,s.useTheme)(),C=p.fileList.length>0,N=p.uploaded.length===p.fileList.length&&p.uploaded.length>0;return(0,u.useEffect)(function(){S.current&&(w(S.current.querySelector(".rustic-error-container")),b(S.current.querySelector(".rustic-input-extras")))}),(0,i.jsx)(l(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(O.palette.action.disabled),borderRadius:"".concat(O.shape.borderRadius,"px"),":focus-within":{borderColor:O.palette.secondary.main},background:O.palette.background.paper},children:(0,i.jsx)(_,Fe({},a,{send:function(e){e.data=function(e,t,n){var r=e.id,o=[];if(t&&(null==t?void 0:t.trim().length)&&o.push({type:"text",text:t}),n&&n.length>0)for(var a=0;a<(null==n?void 0:n.length);a++)o.push({type:"file_url",file_url:{url:n[a].url,name:n[a].name}});return{messages:[{content:o,role:"user",name:r}]}}(e.sender,e.data.text,p.uploaded.map(function(e){return{url:e.url,name:e.name}})),e.id=h,a.ws.send(e),v((0,d.v4)()),f({uploaded:[],fileList:[]})},isSendEnabled:C?N:void 0,ref:S,children:(0,i.jsx)(l(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(we,{acceptedFileTypes:a.acceptedFileTypes,maxFileCount:o,maxFileSize:n,uploadFileEndpoint:a.uploadFileEndpoint,deleteFileEndpoint:a.deleteFileEndpoint,onFileUpdate:function(e,t,n){if("add"===e)f(function(e){return Fe(Fe({},e),{fileList:ke(ke([],e.fileList,!0),[{name:t}],!1)})});else if("update"===e){if(!n)return void console.error("URL is required for the 'update' action");f(function(e){var r=e.fileList.findIndex(function(e){return e.name===t}),o=ke(ke(ke([],e.uploaded.slice(0,r),!0),[{name:t,url:n}],!1),e.uploaded.slice(r),!0);return Fe(Fe({},e),{uploaded:o})})}else f(function(e){return{uploaded:e.uploaded.filter(function(e){return e.name!==t}),fileList:e.fileList.filter(function(e){return e.name!==t})}})},messageId:h,filePreviewsContainer:x,errorMessagesContainer:j,showFullName:a.showFullName,getUploadData:a.getUploadData,uploadOptions:a.uploadOptions,listFiles:a.listFiles,getUploadHeaders:a.getUploadHeaders})})}))})};return a})());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,()=>(()=>{"use strict";var e={9767:(e,r,n)=>{n.d(r,{A:()=>o});var t=n(8732),a=(n(2015),function(){return a=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},a.apply(this,arguments)});function o(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:a({},r),children:e.name})}},3110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(9767).A},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function n(t){var a=r[t];if(void 0!==a)return a.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};n.r(t),n.d(t,{MessageProcessStatus:()=>te,ParticipantRole:()=>ae,ParticipantType:()=>oe,default:()=>ie});var a=n(8732);const o=require("@mui/material/Box");var i=n.n(o);const l=require("@mui/material/IconButton");var c=n.n(l);const s=require("@mui/material/LinearProgress");var u=n.n(s);const d=require("@mui/material/Tooltip");var m=n.n(d);const p=require("@mui/material/Typography");var f=n.n(p);const v=require("axios");var h=n.n(v),x=n(2015);const g=require("react-dom"),b=require("uuid"),j=require("@mui/material/Card");var y=n.n(j);const w=require("@mui/material/Modal");var F=n.n(w);const N=require("@mui/material/styles");var P;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(P||(P={}));var C=n(9767);const O=require("@mui/material/TextField");var k=n.n(O);const S=require("@mui/material/useMediaQuery");var q=n.n(S);const I=require("@mui/system/Stack");var A=n.n(I);const T=require("@mui/system/useTheme");var D=n.n(T);const U=require("pdfjs-dist"),M=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,a.jsx)(m(),{title:n.label,children:(0,a.jsx)("span",{children:(0,a.jsx)(c(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,a.jsx)(C.A,{name:n.symbol})})})})};var R={pdf:function(e){var r,n=(0,x.useRef)(null),t=(0,x.useState)(1),o=t[0],l=t[1],c=(0,x.useState)(1),s=c[0],u=c[1],d=(0,x.useState)(1),m=d[0],p=d[1],v=(0,x.useState)(!1),h=v[0],g=v[1],b=(0,x.useState)(),j=b[0],w=b[1],F=D()(),N=q()(F.breakpoints.down("sm")),P=q()(F.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var C=(0,x.useState)(function(){return N?.5:P?1:1.5}),O=C[0],S=C[1];function I(r){U.getDocument({url:e.url,httpHeaders:r}).promise.then(function(e){u(e.numPages),function(e){e.getPage(o).then(function(e){var r=e.getViewport({scale:O}),t=n.current;if(t){var a=t.getContext("2d");if(a){var o=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*o,t.height=r.height*o;var i={canvasContext:a,viewport:r,transform:[o,0,0,o,0,0]};j&&j.cancel();var l=e.render(i);w(l),l.promise.then(function(){w(void 0)}).catch(function(e){console.error(e)})}}})}(e)}).catch(function(){g(!0)})}return(0,x.useEffect)(function(){U.GlobalWorkerOptions.workerSrc||(U.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(U.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then(function(e){return I(e.headers)}).catch(function(){return g(!0)}):I()},[e.url,o,O]),h?(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,a.jsxs)(y(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,a.jsxs)(i(),{className:"rustic-pdf-viewer-header",children:[(0,a.jsx)(M,{action:"zoomOut",onClick:function(){S(function(e){return Math.max(e-.2,.2)})}}),(0,a.jsx)(M,{action:"zoomIn",onClick:function(){S(function(e){return e+.2})}})]}),(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body",children:(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body-inner",children:(0,a.jsx)("canvas",{ref:n})})}),(0,a.jsxs)(A(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,a.jsx)(M,{action:"previousPage",onClick:function(){o>1&&(l(o-1),p(o-1))},isDisabled:1===o}),(0,a.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,a.jsx)(k(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=s&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,a.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,a.jsx)(M,{action:"nextPage",onClick:function(){o<s&&(l(o+1),p(o+1))},isDisabled:o===s})]})]})}};function _(e){var r=e.supportedViewers,n=void 0===r?R:r,t=e.showFullName,o=void 0===t||t,i=function(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(n[t[a]]=e[t[a]])}return n}(e,["supportedViewers","showFullName"]),l=(0,N.useTheme)(),s=(0,x.useState)(!1),u=s[0],d=s[1];function p(){d(!1)}var v,h,g=i.file.url&&(v=i.file.url.split("."))[v.length-1].toLowerCase(),b=g&&n?n[g]:null,j=!!b,w=j?" rustic-cursor-pointer":"",P="rustic-file-preview ".concat(o?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width").concat(w),O=o?i.file.name:(h=i.file.name).length<=15?h:h.substring(0,12)+"...";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y(),{className:P,variant:"outlined",sx:{boxShadow:l.shadows[1]},onClick:function(){d(!0)},children:[(0,a.jsx)(f(),{variant:"subtitle2",className:"rustic-file-preview-name",children:O}),(0,a.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:i.children})]}),j&&(0,a.jsx)(F(),{open:u,onClose:p,className:"rustic-file-preview-modal",children:(0,a.jsxs)("div",{className:"rustic-modal-content",children:[(0,a.jsx)(m(),{title:"Close",children:(0,a.jsx)(c(),{onClick:p,className:"rustic-close-button",children:(0,a.jsx)(C.A,{name:"close"})})}),i.file.url&&(0,a.jsx)(b,{url:i.file.url,getAuthHeaders:i.getAuthHeaders})]})})]})}var E=n(3110);const z=require("@mui/material"),H=require("@mui/material/Button");var B=n.n(H);const L=require("@mui/material/Drawer");var $=n.n(L);const G=require("@mui/material/ListItemText");var V=n.n(G);const Q=require("@mui/material/Menu");var W=n.n(Q);const Y=require("@mui/material/MenuItem");var Z=n.n(Y);const J=require("@mui/system");var K=function(){return K=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},K.apply(this,arguments)};function X(e){var r=(0,x.useState)(!1),n=r[0],t=r[1],o=(0,x.useRef)(null),i=(0,N.useTheme)(),l=(0,z.useMediaQuery)(i.breakpoints.down("md")),s=l?$():W(),u={borderRadius:"".concat(i.shape.borderRadius,"px"),border:"1px solid ".concat(i.palette.divider)};function d(e){return(0,a.jsxs)(a.Fragment,{children:[e.startDecorator&&(0,a.jsx)(J.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,a.jsx)(V(),{children:(0,a.jsx)(f(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,a.jsx)(J.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}l&&(u=K(K({},u),{borderRadius:"".concat(i.shape.borderRadius,"px ").concat(i.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=e.menuItems.map(function(e){return e.href?(0,a.jsx)(Z(),{component:"a",onClick:function(){return t(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:d(e)},e.label):(0,a.jsx)(Z(),{onClick:function(r){e.onClick&&e.onClick(r),t(!1)},disabled:!e.onClick,children:d(e)},e.label)});var v,h,g=l?{}:{anchorEl:o.current};return(0,a.jsxs)(a.Fragment,{children:[(v={onClick:function(e){e.stopPropagation(),t(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,a.jsx)(C.A,{name:"more_vert"}),e.buttonText?(0,a.jsx)(B(),K({},v,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,a.jsx)(m(),{title:e.ariaLabel,children:(0,a.jsx)(c(),K({},v,{children:e.icon?e.icon:h}))})),(0,a.jsx)(s,K({open:n,onClose:function(){return t(!1)}},g,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":K(K({},u),{backgroundImage:"none",boxShadow:i.shadows[2]})},children:p}))]})}var ee=function(){return ee=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},ee.apply(this,arguments)},re=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,o=r.length;a<o;a++)!t&&a in r||(t||(t=Array.prototype.slice.call(r,0,a)),t[a]=r[a]);return e.concat(t||Array.prototype.slice.call(r))};function ne(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}var te,ae,oe;!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(te||(te={})),function(e){e.Owner="owner",e.Member="member"}(ae||(ae={})),function(e){e.Human="human",e.Agent="agent"}(oe||(oe={}));const ie=function(e){var r,n=(0,x.useState)([]),t=n[0],o=n[1],l=(0,x.useState)([]),s=l[0],d=l[1],p=(0,x.useState)({}),v=p[0],j=p[1],y=(0,x.useRef)({}),w=(0,b.v4)();(0,x.useEffect)(function(){o([]),d([]),y.current={}},[e.messageId]);var F=e.getUploadHeaders?e.getUploadHeaders():Promise.resolve({headers:{}});function N(e,r,n){var t;y.current=ee(ee({},y.current),((t={})[e]=y.current[e]--,t)),function(e,r,n){d(function(r){return re(re([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)}),o(function(e){return e.filter(function(e){return e.id!==r})})}(e,r,n)}var P=(0,a.jsx)(i(),{className:"rustic-files rustic-padding-16",children:t.map(function(r,n){return(0,a.jsx)(_,{file:{name:r.name},showFullName:e.showFullName,children:(0,a.jsxs)(i(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,a.jsx)(u(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,a.jsx)(m(),{title:"Delete",children:(0,a.jsx)(c(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var i=r.name;if(y.current=ee(ee({},y.current),((t={})[i]=y.current[i]--,t)),e.onFileUpdate("remove",i),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);F.then(function(r){h().delete(l,ee({},r)).then(function(){return o(function(e){return e.filter(function(e,r){return r!==n})})}).catch(function(){return e.onFileUpdate("add",i),d(function(e){return re(re([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)})})})}else r.abortController.abort(),o(function(e){return e.filter(function(e,r){return r!==n})}),y.current=ee(ee({},y.current),((a={})[i]=y.current[i]++,a))}(r,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)})}),C=(0,a.jsx)(i(),{children:s.map(function(e,r){return(0,a.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)})});function O(e,r){return r?(0,g.createPortal)(e,r):e}var k=null===(r=e.uploadOptions)||void 0===r?void 0:r.map(function(r){return{label:r.label,onClick:function(){return function(r){j(r.metadata);var n=document.getElementById(w);n&&(n.accept=r.acceptedFileTypes||e.acceptedFileTypes),n.click()}(r)},startDecorator:r.iconName&&(0,a.jsx)(E.default,{name:r.iconName})}});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i(),{className:"rustic-uploader",children:[(0,a.jsx)("label",{htmlFor:w,children:(null==k?void 0:k.length)?(0,a.jsx)(X,{ariaLabel:"Upload",icon:(0,a.jsx)(E.default,{name:"upload_2"}),menuItems:k}):(0,a.jsx)(m(),{title:"Upload",children:(0,a.jsx)(c(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,a.jsx)("input",{type:"file",id:w,onChange:function(r){d([]);var n=r.target.files&&Array.from(r.target.files),a=t.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&d(function(r){return re(re([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)});var i=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);i&&i.forEach(function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,d(function(r){return re(re([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&ne(e.maxFileSize),".")],!1)})):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,a=y.current[t];if(a){var o=a+1,i=t.lastIndexOf("."),l=t.substring(0,i),c=t.substring(i);t="".concat(l,"(").concat(a,")").concat(c),y.current=ee(ee({},y.current),((r={})[e.name]=o,r))}else y.current=ee(ee({},y.current),((n={})[e.name]=1,n));return t}(r),i=new File([r],a,{type:r.type});if(e.getUploadData||v){var l=e.getUploadData?e.getUploadData(a):{},c=ee(ee({},l),v);Object.keys(c).forEach(function(e){var r=c[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)})}n.append("file",i);var s=(0,b.v4)(),u={name:a,loadingProgress:0,abortController:t,id:s};function d(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=u.id,o(function(e){var t=e.map(function(e){return e.id===n?ee(ee({},e),{loadingProgress:r}):e});return t}))}o(function(e){return re(re([],e,!0),[u],!1)}),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);!function i(){return F.then(function(l){return h().post(m,n,ee(ee({},l),{onUploadProgress:d,signal:t.signal})).then(function(r){var t,a,i=n.get("file");r.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,r.data.url),r.data.fileId&&(t=r.data,a=u.id,o(function(e){var r=e.findIndex(function(e){return e.id===a});if(-1!==r){var n=re([],e,!0);return n[r]=ee(ee({},n[r]),{id:t.fileId}),n}return e}))}).catch(function(t){var l,c,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var m,p,f,v;409===(null===(l=t.response)||void 0===l?void 0:l.status)&&e.listFiles?(m=a.lastIndexOf("."),p=a.substring(0,m),f=a.substring(m),v=new RegExp("^".concat(p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(f,"$"),"i"),e.listFiles?e.listFiles().then(function(e){for(var r=0,n=0,t=e;n<t.length;n++){var a=t[n];if(v.test(a.name)){var o=a.name.match(v),i=o&&o[1]?parseInt(o[1].slice(1,-1),10):0;r=Math.max(r,i)}}return"".concat(p,"(").concat(r+1,")").concat(f)}):Promise.resolve(a)).then(function(t){e.onFileUpdate("add",t);var a=new File([r],t,{type:r.type});n.set("file",a),o(function(e){return e.map(function(e){return e.id===s?ee(ee({},e),{name:t,loadingProgress:0}):e})}),i()}).catch(function(){var e;N(r.name,u.id,null===(e=t.response)||void 0===e?void 0:e.data)}):N(r.name,u.id,null===(c=t.response)||void 0===c?void 0:c.data)})})}()}(r)}(r)}),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),s.length>0&&O(C,e.errorMessagesContainer),t.length>0&&O(P,e.filePreviewsContainer)]})};return t})());
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,()=>(()=>{"use strict";var e={9767:(e,r,n)=>{n.d(r,{A:()=>o});var t=n(8732),a=(n(2015),function(){return a=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},a.apply(this,arguments)});function o(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:a({},r),children:e.name})}},3110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(9767).A},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function n(t){var a=r[t];if(void 0!==a)return a.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};n.r(t),n.d(t,{MessageProcessStatus:()=>te,ParticipantRole:()=>oe,ParticipantType:()=>ie,UpdateType:()=>ae,default:()=>le});var a=n(8732);const o=require("@mui/material/Box");var i=n.n(o);const l=require("@mui/material/IconButton");var c=n.n(l);const s=require("@mui/material/LinearProgress");var u=n.n(s);const d=require("@mui/material/Tooltip");var m=n.n(d);const p=require("@mui/material/Typography");var f=n.n(p);const v=require("axios");var h=n.n(v),x=n(2015);const g=require("react-dom"),b=require("uuid"),j=require("@mui/material/Card");var y=n.n(j);const w=require("@mui/material/Modal");var F=n.n(w);const N=require("@mui/material/styles");var P;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(P||(P={}));var C=n(9767);const O=require("@mui/material/TextField");var k=n.n(O);const S=require("@mui/material/useMediaQuery");var q=n.n(S);const I=require("@mui/system/Stack");var A=n.n(I);const T=require("@mui/system/useTheme");var D=n.n(T);const U=require("pdfjs-dist"),M=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,a.jsx)(m(),{title:n.label,children:(0,a.jsx)("span",{children:(0,a.jsx)(c(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,a.jsx)(C.A,{name:n.symbol})})})})};var R={pdf:function(e){var r,n=(0,x.useRef)(null),t=(0,x.useState)(1),o=t[0],l=t[1],c=(0,x.useState)(1),s=c[0],u=c[1],d=(0,x.useState)(1),m=d[0],p=d[1],v=(0,x.useState)(!1),h=v[0],g=v[1],b=(0,x.useState)(),j=b[0],w=b[1],F=D()(),N=q()(F.breakpoints.down("sm")),P=q()(F.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var C=(0,x.useState)(function(){return N?.5:P?1:1.5}),O=C[0],S=C[1];function I(r){U.getDocument({url:e.url,httpHeaders:r}).promise.then(function(e){u(e.numPages),function(e){e.getPage(o).then(function(e){var r=e.getViewport({scale:O}),t=n.current;if(t){var a=t.getContext("2d");if(a){var o=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*o,t.height=r.height*o;var i={canvasContext:a,viewport:r,transform:[o,0,0,o,0,0]};j&&j.cancel();var l=e.render(i);w(l),l.promise.then(function(){w(void 0)}).catch(function(e){console.error(e)})}}})}(e)}).catch(function(){g(!0)})}return(0,x.useEffect)(function(){U.GlobalWorkerOptions.workerSrc||(U.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(U.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then(function(e){return I(e.headers)}).catch(function(){return g(!0)}):I()},[e.url,o,O]),h?(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,a.jsxs)(y(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,a.jsxs)(i(),{className:"rustic-pdf-viewer-header",children:[(0,a.jsx)(M,{action:"zoomOut",onClick:function(){S(function(e){return Math.max(e-.2,.2)})}}),(0,a.jsx)(M,{action:"zoomIn",onClick:function(){S(function(e){return e+.2})}})]}),(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body",children:(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body-inner",children:(0,a.jsx)("canvas",{ref:n})})}),(0,a.jsxs)(A(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,a.jsx)(M,{action:"previousPage",onClick:function(){o>1&&(l(o-1),p(o-1))},isDisabled:1===o}),(0,a.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,a.jsx)(k(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=s&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,a.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,a.jsx)(M,{action:"nextPage",onClick:function(){o<s&&(l(o+1),p(o+1))},isDisabled:o===s})]})]})}};function _(e){var r=e.supportedViewers,n=void 0===r?R:r,t=e.showFullName,o=void 0===t||t,i=function(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(n[t[a]]=e[t[a]])}return n}(e,["supportedViewers","showFullName"]),l=(0,N.useTheme)(),s=(0,x.useState)(!1),u=s[0],d=s[1];function p(){d(!1)}var v,h,g=i.file.url&&(v=i.file.url.split("."))[v.length-1].toLowerCase(),b=g&&n?n[g]:null,j=!!b,w=j?" rustic-cursor-pointer":"",P="rustic-file-preview ".concat(o?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width").concat(w),O=o?i.file.name:(h=i.file.name).length<=15?h:h.substring(0,12)+"...";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y(),{className:P,variant:"outlined",sx:{boxShadow:l.shadows[1]},onClick:function(){d(!0)},children:[(0,a.jsx)(f(),{variant:"subtitle2",className:"rustic-file-preview-name",children:O}),(0,a.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:i.children})]}),j&&(0,a.jsx)(F(),{open:u,onClose:p,className:"rustic-file-preview-modal",children:(0,a.jsxs)("div",{className:"rustic-modal-content",children:[(0,a.jsx)(m(),{title:"Close",children:(0,a.jsx)(c(),{onClick:p,className:"rustic-close-button",children:(0,a.jsx)(C.A,{name:"close"})})}),i.file.url&&(0,a.jsx)(b,{url:i.file.url,getAuthHeaders:i.getAuthHeaders})]})})]})}var E=n(3110);const z=require("@mui/material"),H=require("@mui/material/Button");var B=n.n(H);const L=require("@mui/material/Drawer");var $=n.n(L);const G=require("@mui/material/ListItemText");var V=n.n(G);const Q=require("@mui/material/Menu");var W=n.n(Q);const Y=require("@mui/material/MenuItem");var Z=n.n(Y);const J=require("@mui/system");var K=function(){return K=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},K.apply(this,arguments)};function X(e){var r=(0,x.useState)(!1),n=r[0],t=r[1],o=(0,x.useRef)(null),i=(0,N.useTheme)(),l=(0,z.useMediaQuery)(i.breakpoints.down("md")),s=l?$():W(),u={borderRadius:"".concat(i.shape.borderRadius,"px"),border:"1px solid ".concat(i.palette.divider)};function d(e){return(0,a.jsxs)(a.Fragment,{children:[e.startDecorator&&(0,a.jsx)(J.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,a.jsx)(V(),{children:(0,a.jsx)(f(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,a.jsx)(J.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}l&&(u=K(K({},u),{borderRadius:"".concat(i.shape.borderRadius,"px ").concat(i.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=e.menuItems.map(function(e){return e.href?(0,a.jsx)(Z(),{component:"a",onClick:function(){return t(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:d(e)},e.label):(0,a.jsx)(Z(),{onClick:function(r){e.onClick&&e.onClick(r),t(!1)},disabled:!e.onClick,children:d(e)},e.label)});var v,h,g=l?{}:{anchorEl:o.current};return(0,a.jsxs)(a.Fragment,{children:[(v={onClick:function(e){e.stopPropagation(),t(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,a.jsx)(C.A,{name:"more_vert"}),e.buttonText?(0,a.jsx)(B(),K({},v,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,a.jsx)(m(),{title:e.ariaLabel,children:(0,a.jsx)(c(),K({},v,{children:e.icon?e.icon:h}))})),(0,a.jsx)(s,K({open:n,onClose:function(){return t(!1)}},g,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":K(K({},u),{backgroundImage:"none",boxShadow:i.shadows[2]})},children:p}))]})}var ee=function(){return ee=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},ee.apply(this,arguments)},re=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,o=r.length;a<o;a++)!t&&a in r||(t||(t=Array.prototype.slice.call(r,0,a)),t[a]=r[a]);return e.concat(t||Array.prototype.slice.call(r))};function ne(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}var te,ae,oe,ie;!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(te||(te={})),function(e){e.Append="append",e.Replace="replace"}(ae||(ae={})),function(e){e.Owner="owner",e.Member="member"}(oe||(oe={})),function(e){e.Human="human",e.Agent="agent"}(ie||(ie={}));const le=function(e){var r,n=(0,x.useState)([]),t=n[0],o=n[1],l=(0,x.useState)([]),s=l[0],d=l[1],p=(0,x.useState)({}),v=p[0],j=p[1],y=(0,x.useRef)({}),w=(0,b.v4)();(0,x.useEffect)(function(){o([]),d([]),y.current={}},[e.messageId]);var F=e.getUploadHeaders?e.getUploadHeaders():Promise.resolve({headers:{}});function N(e,r,n){var t;y.current=ee(ee({},y.current),((t={})[e]=y.current[e]--,t)),function(e,r,n){d(function(r){return re(re([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)}),o(function(e){return e.filter(function(e){return e.id!==r})})}(e,r,n)}var P=(0,a.jsx)(i(),{className:"rustic-files rustic-padding-16",children:t.map(function(r,n){return(0,a.jsx)(_,{file:{name:r.name},showFullName:e.showFullName,children:(0,a.jsxs)(i(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,a.jsx)(u(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,a.jsx)(m(),{title:"Delete",children:(0,a.jsx)(c(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var i=r.name;if(y.current=ee(ee({},y.current),((t={})[i]=y.current[i]--,t)),e.onFileUpdate("remove",i),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);F.then(function(r){h().delete(l,ee({},r)).then(function(){return o(function(e){return e.filter(function(e,r){return r!==n})})}).catch(function(){return e.onFileUpdate("add",i),d(function(e){return re(re([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)})})})}else r.abortController.abort(),o(function(e){return e.filter(function(e,r){return r!==n})}),y.current=ee(ee({},y.current),((a={})[i]=y.current[i]++,a))}(r,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)})}),C=(0,a.jsx)(i(),{children:s.map(function(e,r){return(0,a.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)})});function O(e,r){return r?(0,g.createPortal)(e,r):e}var k=null===(r=e.uploadOptions)||void 0===r?void 0:r.map(function(r){return{label:r.label,onClick:function(){return function(r){j(r.metadata);var n=document.getElementById(w);n&&(n.accept=r.acceptedFileTypes||e.acceptedFileTypes),n.click()}(r)},startDecorator:r.iconName&&(0,a.jsx)(E.default,{name:r.iconName})}});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i(),{className:"rustic-uploader",children:[(0,a.jsx)("label",{htmlFor:w,children:(null==k?void 0:k.length)?(0,a.jsx)(X,{ariaLabel:"Upload",icon:(0,a.jsx)(E.default,{name:"upload_2"}),menuItems:k}):(0,a.jsx)(m(),{title:"Upload",children:(0,a.jsx)(c(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,a.jsx)("input",{type:"file",id:w,onChange:function(r){d([]);var n=r.target.files&&Array.from(r.target.files),a=t.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&d(function(r){return re(re([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)});var i=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);i&&i.forEach(function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,d(function(r){return re(re([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&ne(e.maxFileSize),".")],!1)})):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,a=y.current[t];if(a){var o=a+1,i=t.lastIndexOf("."),l=t.substring(0,i),c=t.substring(i);t="".concat(l,"(").concat(a,")").concat(c),y.current=ee(ee({},y.current),((r={})[e.name]=o,r))}else y.current=ee(ee({},y.current),((n={})[e.name]=1,n));return t}(r),i=new File([r],a,{type:r.type});if(e.getUploadData||v){var l=e.getUploadData?e.getUploadData(a):{},c=ee(ee({},l),v);Object.keys(c).forEach(function(e){var r=c[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)})}n.append("file",i);var s=(0,b.v4)(),u={name:a,loadingProgress:0,abortController:t,id:s};function d(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=u.id,o(function(e){var t=e.map(function(e){return e.id===n?ee(ee({},e),{loadingProgress:r}):e});return t}))}o(function(e){return re(re([],e,!0),[u],!1)}),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);!function i(){return F.then(function(l){return h().post(m,n,ee(ee({},l),{onUploadProgress:d,signal:t.signal})).then(function(r){var t,a,i=n.get("file");r.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,r.data.url),r.data.fileId&&(t=r.data,a=u.id,o(function(e){var r=e.findIndex(function(e){return e.id===a});if(-1!==r){var n=re([],e,!0);return n[r]=ee(ee({},n[r]),{id:t.fileId}),n}return e}))}).catch(function(t){var l,c,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var m,p,f,v;409===(null===(l=t.response)||void 0===l?void 0:l.status)&&e.listFiles?(m=a.lastIndexOf("."),p=a.substring(0,m),f=a.substring(m),v=new RegExp("^".concat(p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(f,"$"),"i"),e.listFiles?e.listFiles().then(function(e){for(var r=0,n=0,t=e;n<t.length;n++){var a=t[n];if(v.test(a.name)){var o=a.name.match(v),i=o&&o[1]?parseInt(o[1].slice(1,-1),10):0;r=Math.max(r,i)}}return"".concat(p,"(").concat(r+1,")").concat(f)}):Promise.resolve(a)).then(function(t){e.onFileUpdate("add",t);var a=new File([r],t,{type:r.type});n.set("file",a),o(function(e){return e.map(function(e){return e.id===s?ee(ee({},e),{name:t,loadingProgress:0}):e})}),i()}).catch(function(){var e;N(r.name,u.id,null===(e=t.response)||void 0===e?void 0:e.data)}):N(r.name,u.id,null===(c=t.response)||void 0===c?void 0:c.data)})})}()}(r)}(r)}),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),s.length>0&&O(C,e.errorMessagesContainer),t.length>0&&O(P,e.filePreviewsContainer)]})};return t})());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e,t,n={8342:e=>{e.exports=require("emoji-picker-element")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&n;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>n[e]);return a.default=()=>n,o.d(i,a),i},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.r(i),o.d(i,{MessageProcessStatus:()=>B,ParticipantRole:()=>W,ParticipantType:()=>K,default:()=>$});const a=require("react/jsx-runtime"),c=require("react");var s;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(s||(s={}));const u=require("@mui/material/Avatar");var l=o.n(u);const d=require("@mui/material/Box");var p=o.n(d);const m=require("@mui/material/CircularProgress");var f=o.n(m);const h=require("@mui/material/IconButton");var v=o.n(h);const g=require("@mui/material/InputAdornment");var y=o.n(g);const b=require("@mui/material/MenuItem");var j=o.n(b);const x=require("@mui/material/MenuList");var w=o.n(x);const O=require("@mui/material/Popover");var S=o.n(O);const k=require("@mui/material/TextField");var E=o.n(k);const C=require("@mui/material/Tooltip");var N=o.n(C);const P=require("@mui/material/Typography");var T=o.n(P),R=o(8342);const q=require("uuid");var _=function(){return _=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_.apply(this,arguments)};function M(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,a.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:_({},t),children:e.name})}const I=require("@mui/material/styles"),A=function(e){var t=(0,I.useTheme)(),n=(0,c.useRef)(null),r=(0,c.useRef)(null),i=(0,c.useState)(!1),s=i[0],u=i[1],l={"--indicator-color":t.palette.divider,"--background":t.palette.background.paper,"--input-border-color":t.palette.divider,"--outline-color":t.palette.secondary.main};function d(){u(!1)}function p(t){t.detail.unicode&&e.onEmojiClick(t.detail.unicode),d()}return(0,c.useEffect)(function(){r.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then(function(n){var o=new(0,n.Picker)({dataSource:e.dataSource}),i="dark"===t.palette.mode?"dark":"light";o.classList.add(i),Object.keys(l).forEach(function(e){o.style.setProperty(e,l[e])}),r.current=o}).catch(function(e){console.error("Failed to load emoji picker",e)})},[]),(0,c.useEffect)(function(){return r.current&&r.current.addEventListener("emoji-click",p),function(){var e;null===(e=r.current)||void 0===e||e.removeEventListener("emoji-click",p)}},[s,e.onEmojiClick]),(0,a.jsxs)("div",{children:[(0,a.jsx)(N(),{title:"Emoji",children:(0,a.jsx)(v(),{size:"small",ref:n,onClick:function(){u(function(e){return!e})},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(M,{name:"Mood"})})}),r.current&&(0,a.jsx)(S(),{open:s,anchorEl:n.current,onClose:d,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,a.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&r.current&&!e.contains(r.current)&&e.appendChild(r.current)}})})]})};var D={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function z(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}function F(e){return(0,a.jsxs)(p(),{className:"rustic-participant-profile",children:[(0,a.jsx)(l(),{src:e.icon,className:"rustic-participant-avatar"}),(0,a.jsx)(T(),{variant:"body1Bold",children:e.displayName})]})}function H(e){var t=e.items,n=e.isOpen,r=e.onClose,o=e.onSelect,i=e.renderItem,c=e.anchorEl,s=e.selectedIndex;return(0,a.jsx)(S(),{disableAutoFocus:!0,open:n&&t.length>0,anchorEl:c,onClose:r,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,a.jsx)(w(),{children:t.map(function(e,t){return(0,a.jsx)(j(),{onClick:function(){return o(e)},selected:t===s,children:i(e)},t)})})})}const L=(0,c.forwardRef)(function(e,t){var n=e.multiline,r=void 0===n||n,o=e.fullWidth,i=void 0===o||o,s=e.maxRows,u=void 0===s?6:s,l=e.enableSpeechToText,d=void 0!==l&&l,m=e.maximumEmojiSearchResults,h=void 0===m?5:m,g=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,c.useState)(""),j=b[0],x=b[1],w=(0,c.useState)(!1),O=w[0],S=w[1],k=(0,c.useState)(!1),C=k[0],P=k[1],_=(0,c.useState)(!1),I=_[0],L=_[1],B=(0,c.useState)(""),W=B[0],K=B[1],U=(0,c.useState)([]),$=U[0],Q=U[1],G=(0,c.useState)(!1),J=G[0],V=G[1],X=(0,c.useState)(0),Y=X[0],Z=X[1],ee=(0,c.useRef)(null),te=new R.Database({dataSource:g.emojiDataSource}),ne=!j.trim().length,re="".concat(O?"Stop":"Start"," speech to text"),oe=C?"primary.main":"primary.light",ie=O?"error.main":oe,ae=O?"stop_circle":"speech_to_text",ce=(0,c.useState)([]),se=ce[0],ue=ce[1],le=(0,c.useState)(!1),de=le[0],pe=le[1],me=d&&"undefined"!=typeof window&&!!window.webkitSpeechRecognition;function fe(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:ne}function he(e,t){if(ee.current){var n=ee.current,r=n.selectionStart,o=n.selectionEnd;if("number"==typeof r&&"number"==typeof o){var i,a=j||"",c=a.substring(0,r),s=a.substring(o),u=void 0;t?(u=c.replace(t,e)+s,i=c.replace(t,e).length):(u=c+e+s,i=r+e.length),x(u),setTimeout(function(){var e,t;null===(e=ee.current)||void 0===e||e.focus(),null===(t=ee.current)||void 0===t||t.setSelectionRange(i,i)},0)}}}function ve(e){he("@".concat(e," "),/@(\w*)$/),ue([])}function ge(e,t){void 0===t&&(t=!1),he(e,t?/:(\w+)$/:void 0),V(!1)}var ye=I?(0,a.jsx)(f(),{size:24}):(0,a.jsx)(N(),{title:re,children:(0,a.jsx)(v(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),L(!0),S(!1)):(e.start(),K(""),S(!0)),e.onstart=function(){S(!0)},e.onresult=function(e){var t,n=e.results[0][0].transcript;j.length>0?x(j+" "+n):x(n),null===(t=ee.current)||void 0===t||t.focus(),S(!1)},e.onerror=function(e){var t=D[e.error];K(t),S(!1)},e.onend=function(){L(!1),S(!1)}},size:"small",sx:{color:ie,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(M,{name:ae})})});function be(){var e,t,n=(new Date).toISOString(),r={id:(0,q.v4)(),timestamp:n,sender:g.sender,conversationId:g.conversationId,format:"chatCompletionRequest",data:{text:j},inReplyTo:null===(e=g.lastMsg)||void 0===e?void 0:e.id,messageHistory:null===(t=g.lastMsg)||void 0===t?void 0:t.messageHistory};g.send(r),x(""),K("")}return(0,a.jsxs)(p(),{className:"rustic-base-input",ref:t,children:[(0,a.jsxs)(p(),{className:"rustic-error-and-input-container",children:[(0,a.jsx)(p(),{className:"rustic-error-container",children:(0,a.jsx)(T(),{variant:"caption",color:"error",className:"rustic-error-message",children:W})}),(0,a.jsxs)(p(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:C?"secondary.main":"action.disabled",backgroundColor:"background.paper"},children:[$.length>0&&ee.current&&(0,a.jsx)(H,{anchorEl:ee.current,items:$.filter(function(e){return"unicode"in e}),isOpen:J,onClose:function(){V(!1),Z(0)},onSelect:function(e){return ge(e.unicode,!0)},selectedIndex:Y,renderItem:z}),se.length>0&&ee.current&&(0,a.jsx)(H,{anchorEl:ee.current,items:se,isOpen:de,onClose:function(){pe(!1),Z(0)},onSelect:function(e){return ve(e.displayName)},renderItem:F,selectedIndex:Y}),(0,a.jsx)(E(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:u,multiline:r,fullWidth:i,onKeyDown:function(e){var t,n="ArrowDown"===e.key,r="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),J&&$.length>0&&"unicode"in $[Y]?ge($[Y].unicode,!0):de&&se.length>0?ve(se[Y].displayName):e.shiftKey||fe()||be();else{if(n||r)return e.preventDefault(),t=n?1:-1,void(J?Z(function(e){return(e+t+$.length)%$.length}):de&&Z(function(e){return(e+t+se.length)%se.length}));0!==Y&&Z(0)}},onChange:function(e){K("");var t=e.target.value;x(t),function(e){var t=e.match(/@(\w*)$/);if(t&&g.getMembers){var n=t[1].toLowerCase();g.getMembers().then(function(e){var t=e.filter(function(e){return e.displayName.toLowerCase().startsWith(n)});ue(t),t.length>0?pe(!0):pe(!1)})}else ue([])}(t);var n,r=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(r){var i=r[0].replace(/:/g,"");te.getEmojiByShortcode(i).then(function(e){if(e&&"unicode"in e){var n=t.replace(r[0],e.unicode);x(n)}else x(t)}).catch(function(){x(t)}),V(!1)}else o?(n=o[0].replace(":",""),te.getEmojiBySearchQuery(n).then(function(e){e.length?(Q(e.slice(0,h)),V(!0)):(Q([]),V(!1))}).catch(function(){Q([]),V(!1)})):V(!1)},onFocus:function(){return P(!0)},onBlur:function(){return P(!1)},inputRef:ee,color:"secondary",size:"small",autoFocus:g.autoFocus,slotProps:{input:{endAdornment:(0,a.jsxs)(y(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(A,{dataSource:g.emojiDataSource,onEmojiClick:ge,buttonColor:oe}),me&&ye]})},inputLabel:{className:C?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,a.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,a.jsxs)(p(),{className:"rustic-input-actions",children:[g.children,(0,a.jsx)(N(),{title:"Send",children:(0,a.jsx)("span",{className:"rustic-send-button",children:(0,a.jsx)(v(),{"aria-label":"send message",onClick:be,disabled:fe(),color:"secondary",children:(0,a.jsx)(M,{name:"send"})})})})]})]})});var B,W,K,U=function(){return U=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},U.apply(this,arguments)};!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(B||(B={})),function(e){e.Owner="owner",e.Member="member"}(W||(W={})),function(e){e.Human="human",e.Agent="agent"}(K||(K={}));const $=function(e){var t=e.ws,n=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["ws"]);return(0,a.jsx)(L,U({},n,{send:function(e){var n,r,o,i;e.data=(n=e.sender,r=e.data.text,o=n.id,i=[],r&&(null==r?void 0:r.trim().length)&&i.push({type:"text",text:r}),{messages:[{content:i,role:"user",name:o}]}),t.send(e)}}))};return i})());
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e,t,n={8342:e=>{e.exports=require("emoji-picker-element")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&n;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>n[e]);return a.default=()=>n,o.d(i,a),i},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.r(i),o.d(i,{MessageProcessStatus:()=>B,ParticipantRole:()=>W,ParticipantType:()=>K,UpdateType:()=>U,default:()=>Q});const a=require("react/jsx-runtime"),c=require("react");var s;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(s||(s={}));const u=require("@mui/material/Avatar");var l=o.n(u);const d=require("@mui/material/Box");var p=o.n(d);const m=require("@mui/material/CircularProgress");var f=o.n(m);const h=require("@mui/material/IconButton");var v=o.n(h);const g=require("@mui/material/InputAdornment");var y=o.n(g);const b=require("@mui/material/MenuItem");var j=o.n(b);const x=require("@mui/material/MenuList");var w=o.n(x);const O=require("@mui/material/Popover");var S=o.n(O);const k=require("@mui/material/TextField");var E=o.n(k);const C=require("@mui/material/Tooltip");var N=o.n(C);const P=require("@mui/material/Typography");var T=o.n(P),R=o(8342);const q=require("uuid");var _=function(){return _=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_.apply(this,arguments)};function M(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,a.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:_({},t),children:e.name})}const I=require("@mui/material/styles"),A=function(e){var t=(0,I.useTheme)(),n=(0,c.useRef)(null),r=(0,c.useRef)(null),i=(0,c.useState)(!1),s=i[0],u=i[1],l={"--indicator-color":t.palette.divider,"--background":t.palette.background.paper,"--input-border-color":t.palette.divider,"--outline-color":t.palette.secondary.main};function d(){u(!1)}function p(t){t.detail.unicode&&e.onEmojiClick(t.detail.unicode),d()}return(0,c.useEffect)(function(){r.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then(function(n){var o=new(0,n.Picker)({dataSource:e.dataSource}),i="dark"===t.palette.mode?"dark":"light";o.classList.add(i),Object.keys(l).forEach(function(e){o.style.setProperty(e,l[e])}),r.current=o}).catch(function(e){console.error("Failed to load emoji picker",e)})},[]),(0,c.useEffect)(function(){return r.current&&r.current.addEventListener("emoji-click",p),function(){var e;null===(e=r.current)||void 0===e||e.removeEventListener("emoji-click",p)}},[s,e.onEmojiClick]),(0,a.jsxs)("div",{children:[(0,a.jsx)(N(),{title:"Emoji",children:(0,a.jsx)(v(),{size:"small",ref:n,onClick:function(){u(function(e){return!e})},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(M,{name:"Mood"})})}),r.current&&(0,a.jsx)(S(),{open:s,anchorEl:n.current,onClose:d,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,a.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&r.current&&!e.contains(r.current)&&e.appendChild(r.current)}})})]})};var D={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function z(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}function F(e){return(0,a.jsxs)(p(),{className:"rustic-participant-profile",children:[(0,a.jsx)(l(),{src:e.icon,className:"rustic-participant-avatar"}),(0,a.jsx)(T(),{variant:"body1Bold",children:e.displayName})]})}function H(e){var t=e.items,n=e.isOpen,r=e.onClose,o=e.onSelect,i=e.renderItem,c=e.anchorEl,s=e.selectedIndex;return(0,a.jsx)(S(),{disableAutoFocus:!0,open:n&&t.length>0,anchorEl:c,onClose:r,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,a.jsx)(w(),{children:t.map(function(e,t){return(0,a.jsx)(j(),{onClick:function(){return o(e)},selected:t===s,children:i(e)},t)})})})}const L=(0,c.forwardRef)(function(e,t){var n=e.multiline,r=void 0===n||n,o=e.fullWidth,i=void 0===o||o,s=e.maxRows,u=void 0===s?6:s,l=e.enableSpeechToText,d=void 0!==l&&l,m=e.maximumEmojiSearchResults,h=void 0===m?5:m,g=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,c.useState)(""),j=b[0],x=b[1],w=(0,c.useState)(!1),O=w[0],S=w[1],k=(0,c.useState)(!1),C=k[0],P=k[1],_=(0,c.useState)(!1),I=_[0],L=_[1],B=(0,c.useState)(""),U=B[0],W=B[1],K=(0,c.useState)([]),$=K[0],Q=K[1],G=(0,c.useState)(!1),J=G[0],V=G[1],X=(0,c.useState)(0),Y=X[0],Z=X[1],ee=(0,c.useRef)(null),te=new R.Database({dataSource:g.emojiDataSource}),ne=!j.trim().length,re="".concat(O?"Stop":"Start"," speech to text"),oe=C?"primary.main":"primary.light",ie=O?"error.main":oe,ae=O?"stop_circle":"speech_to_text",ce=(0,c.useState)([]),se=ce[0],ue=ce[1],le=(0,c.useState)(!1),de=le[0],pe=le[1],me=d&&"undefined"!=typeof window&&!!window.webkitSpeechRecognition;function fe(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:ne}function he(e,t){if(ee.current){var n=ee.current,r=n.selectionStart,o=n.selectionEnd;if("number"==typeof r&&"number"==typeof o){var i,a=j||"",c=a.substring(0,r),s=a.substring(o),u=void 0;t?(u=c.replace(t,e)+s,i=c.replace(t,e).length):(u=c+e+s,i=r+e.length),x(u),setTimeout(function(){var e,t;null===(e=ee.current)||void 0===e||e.focus(),null===(t=ee.current)||void 0===t||t.setSelectionRange(i,i)},0)}}}function ve(e){he("@".concat(e," "),/@(\w*)$/),ue([])}function ge(e,t){void 0===t&&(t=!1),he(e,t?/:(\w+)$/:void 0),V(!1)}var ye=I?(0,a.jsx)(f(),{size:24}):(0,a.jsx)(N(),{title:re,children:(0,a.jsx)(v(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),L(!0),S(!1)):(e.start(),W(""),S(!0)),e.onstart=function(){S(!0)},e.onresult=function(e){var t,n=e.results[0][0].transcript;j.length>0?x(j+" "+n):x(n),null===(t=ee.current)||void 0===t||t.focus(),S(!1)},e.onerror=function(e){var t=D[e.error];W(t),S(!1)},e.onend=function(){L(!1),S(!1)}},size:"small",sx:{color:ie,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(M,{name:ae})})});function be(){var e,t,n=(new Date).toISOString(),r={id:(0,q.v4)(),timestamp:n,sender:g.sender,conversationId:g.conversationId,format:"chatCompletionRequest",data:{text:j},inReplyTo:null===(e=g.lastMsg)||void 0===e?void 0:e.id,messageHistory:null===(t=g.lastMsg)||void 0===t?void 0:t.messageHistory};g.send(r),x(""),W("")}return(0,a.jsxs)(p(),{className:"rustic-base-input",ref:t,children:[(0,a.jsxs)(p(),{className:"rustic-error-and-input-container",children:[(0,a.jsx)(p(),{className:"rustic-error-container",children:(0,a.jsx)(T(),{variant:"caption",color:"error",className:"rustic-error-message",children:U})}),(0,a.jsxs)(p(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:C?"secondary.main":"action.disabled",backgroundColor:"background.paper"},children:[$.length>0&&ee.current&&(0,a.jsx)(H,{anchorEl:ee.current,items:$.filter(function(e){return"unicode"in e}),isOpen:J,onClose:function(){V(!1),Z(0)},onSelect:function(e){return ge(e.unicode,!0)},selectedIndex:Y,renderItem:z}),se.length>0&&ee.current&&(0,a.jsx)(H,{anchorEl:ee.current,items:se,isOpen:de,onClose:function(){pe(!1),Z(0)},onSelect:function(e){return ve(e.displayName)},renderItem:F,selectedIndex:Y}),(0,a.jsx)(E(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:u,multiline:r,fullWidth:i,onKeyDown:function(e){var t,n="ArrowDown"===e.key,r="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),J&&$.length>0&&"unicode"in $[Y]?ge($[Y].unicode,!0):de&&se.length>0?ve(se[Y].displayName):e.shiftKey||fe()||be();else{if(n||r)return e.preventDefault(),t=n?1:-1,void(J?Z(function(e){return(e+t+$.length)%$.length}):de&&Z(function(e){return(e+t+se.length)%se.length}));0!==Y&&Z(0)}},onChange:function(e){W("");var t=e.target.value;x(t),function(e){var t=e.match(/@(\w*)$/);if(t&&g.getMembers){var n=t[1].toLowerCase();g.getMembers().then(function(e){var t=e.filter(function(e){return e.displayName.toLowerCase().startsWith(n)});ue(t),t.length>0?pe(!0):pe(!1)})}else ue([])}(t);var n,r=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(r){var i=r[0].replace(/:/g,"");te.getEmojiByShortcode(i).then(function(e){if(e&&"unicode"in e){var n=t.replace(r[0],e.unicode);x(n)}else x(t)}).catch(function(){x(t)}),V(!1)}else o?(n=o[0].replace(":",""),te.getEmojiBySearchQuery(n).then(function(e){e.length?(Q(e.slice(0,h)),V(!0)):(Q([]),V(!1))}).catch(function(){Q([]),V(!1)})):V(!1)},onFocus:function(){return P(!0)},onBlur:function(){return P(!1)},inputRef:ee,color:"secondary",size:"small",autoFocus:g.autoFocus,slotProps:{input:{endAdornment:(0,a.jsxs)(y(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(A,{dataSource:g.emojiDataSource,onEmojiClick:ge,buttonColor:oe}),me&&ye]})},inputLabel:{className:C?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,a.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,a.jsxs)(p(),{className:"rustic-input-actions",children:[g.children,(0,a.jsx)(N(),{title:"Send",children:(0,a.jsx)("span",{className:"rustic-send-button",children:(0,a.jsx)(v(),{"aria-label":"send message",onClick:be,disabled:fe(),color:"secondary",children:(0,a.jsx)(M,{name:"send"})})})})]})]})});var B,U,W,K,$=function(){return $=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},$.apply(this,arguments)};!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(B||(B={})),function(e){e.Append="append",e.Replace="replace"}(U||(U={})),function(e){e.Owner="owner",e.Member="member"}(W||(W={})),function(e){e.Human="human",e.Agent="agent"}(K||(K={}));const Q=function(e){var t=e.ws,n=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["ws"]);return(0,a.jsx)(L,$({},n,{send:function(e){var n,r,o,i;e.data=(n=e.sender,r=e.data.text,o=n.id,i=[],r&&(null==r?void 0:r.trim().length)&&i.push({type:"text",text:r}),{messages:[{content:i,role:"user",name:o}]}),t.send(e)}}))};return i})());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{MessageProcessStatus:()=>
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{MessageProcessStatus:()=>T,ParticipantRole:()=>P,ParticipantType:()=>_,UpdateType:()=>M,default:()=>N});const t=require("react/jsx-runtime"),n=(require("ol/ol.css"),require("@mui/material/Alert"));var a=e.n(n);const o=require("@mui/material/Box");var i=e.n(o);const u=require("@mui/material/Typography");var s=e.n(u);const c=require("ol/layer/Tile.js");var l=e.n(c);const d=require("ol/Map.js");var p=e.n(d);const m=require("ol/Overlay.js");var f=e.n(m);const v=require("ol/proj.js"),y=require("ol/source/OSM.js");var g=e.n(y);const j=require("ol/View.js");var x=e.n(j);const h=require("react");var b=function(){return b=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},b.apply(this,arguments)};function S(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:b({},r),children:e.name})}const q=require("dompurify");var w=e.n(q);const O=require("marked");var T,M,P,_;!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(T||(T={})),function(e){e.Append="append",e.Replace="replace"}(M||(M={})),function(e){e.Owner="owner",e.Member="member"}(P||(P={})),function(e){e.Human="human",e.Agent="agent"}(_||(_={}));const A=function(e){var r=(0,h.useState)(e.text),n=r[0],o=r[1],i=(0,h.useState)(""),u=i[0],c=i[1];function l(e){return"string"!=typeof e?(c("Some of the incoming text was not correctly formatted. Some data may be missing.")," [MISSING TEXT]"):e}function d(e){return(0,t.jsx)(s(),{component:"div",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:(r=e,n=r.replace(/^[\u200B-\u200F\uFEFF]/,""),a=O.marked.parse(n,{async:!1}),w().sanitize(a))}});var r,n,a}return(0,h.useEffect)(function(){if(e.updatedData&&e.updatedData.length>0){var r=e.text,t=e.updatedData.at(-1);if(e.updatedData.length>1&&(null==t?void 0:t.updateType)===M.Replace)r=l(t.text);else for(var n=0,a=e.updatedData;n<a.length;n++){var i=a[n],u=i.updateType||M.Append,s=l(i.text);u===M.Append?r+=s:u===M.Replace&&(r=s)}o(r)}},[e.text,e.updatedData]),(0,t.jsxs)(t.Fragment,{children:[e.title&&(0,t.jsx)(s(),{variant:"h6",children:e.title}),e.description&&d(e.description),d(n),u&&(0,t.jsx)(a(),{severity:"error",children:u})]})},N=function(e){var r=(0,h.useState)(""),n=r[0],o=r[1],u=(0,h.useRef)(null),c=(0,h.useRef)(null);return(0,h.useEffect)(function(){if(o(""),e.latitude<-90||e.latitude>90||e.longitude<-180||e.longitude>180)return o("Invalid coordinates");if(u.current&&c.current){var r=new(p())({layers:[new(l())({source:new(g())})],view:new(x())({center:(0,v.fromLonLat)([e.longitude,e.latitude]),zoom:12}),target:u.current}),t=new(f())({element:c.current,position:(0,v.fromLonLat)([e.longitude,e.latitude]),positioning:"bottom-center",stopEvent:!1});return r.addOverlay(t),r.once("postrender",function(){var e;if(!(null===(e=u.current)||void 0===e?void 0:e.querySelector("canvas")))return o("An error occurred while loading the map")}),function(){r.setTarget(""),r.removeOverlay(t)}}},[]),(0,t.jsx)(t.Fragment,{children:n.length>0?(0,t.jsx)(a(),{severity:"error",children:n}):(0,t.jsxs)(i(),{children:[e.title&&(0,t.jsx)(s(),{variant:"h6",children:e.title}),e.description&&(0,t.jsx)(A,{text:e.description}),(0,t.jsx)(i(),{ref:c,children:(0,t.jsx)(S,{className:"rustic-open-layers-map-marker",name:"location_on"})}),(0,t.jsx)("div",{ref:u,className:"rustic-open-layers-map-canvas"})]})})};return r})());
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import MarkedMarkdown from './markedMarkdown';
|
|
2
|
-
import MarkedStreamingMarkdown from './markedStreamingMarkdown';
|
|
3
2
|
export * from '../types';
|
|
4
3
|
export default MarkedMarkdown;
|
|
5
|
-
export { MarkedMarkdown
|
|
4
|
+
export { MarkedMarkdown };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/markdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/markdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,cAAc,UAAU,CAAA;AACxB,eAAe,cAAc,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={227:(e,t,r)=>{r.d(t,{A:()=>
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,()=>(()=>{"use strict";var e={227:(e,t,r)=>{r.d(t,{A:()=>f});var n=r(8732),a=r(5642),o=r.n(a),i=r(785),u=r.n(i),p=r(7447),d=r.n(p),s=r(3840),c=r(2015),l=r(7159);const f=function(e){var t=(0,c.useState)(e.text),r=t[0],a=t[1],i=(0,c.useState)(""),p=i[0],f=i[1];function m(e){return"string"!=typeof e?(f("Some of the incoming text was not correctly formatted. Some data may be missing.")," [MISSING TEXT]"):e}function x(e){return(0,n.jsx)(u(),{component:"div",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:(t=e,r=t.replace(/^[\u200B-\u200F\uFEFF]/,""),a=s.marked.parse(r,{async:!1}),d().sanitize(a))}});var t,r,a}return(0,c.useEffect)(function(){if(e.updatedData&&e.updatedData.length>0){var t=e.text,r=e.updatedData.at(-1);if(e.updatedData.length>1&&(null==r?void 0:r.updateType)===l.Ur.Replace)t=m(r.text);else for(var n=0,o=e.updatedData;n<o.length;n++){var i=o[n],u=i.updateType||l.Ur.Append,p=m(i.text);u===l.Ur.Append?t+=p:u===l.Ur.Replace&&(t=p)}a(t)}},[e.text,e.updatedData]),(0,n.jsxs)(n.Fragment,{children:[e.title&&(0,n.jsx)(u(),{variant:"h6",children:e.title}),e.description&&x(e.description),x(r),p&&(0,n.jsx)(o(),{severity:"error",children:p})]})}},7159:(e,t,r)=>{var n,a,o,i;r.d(t,{Ur:()=>a,sW:()=>o,xx:()=>n,yJ:()=>i}),function(e){e.Running="running",e.Completed="completed",e.Error="error"}(n||(n={})),function(e){e.Append="append",e.Replace="replace"}(a||(a={})),function(e){e.Owner="owner",e.Member="member"}(o||(o={})),function(e){e.Human="human",e.Agent="agent"}(i||(i={}))},5642:e=>{e.exports=require("@mui/material/Alert")},785:e=>{e.exports=require("@mui/material/Typography")},7447:e=>{e.exports=require("dompurify")},3840:e=>{e.exports=require("marked")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{MarkedMarkdown:()=>a.A,MessageProcessStatus:()=>o.xx,ParticipantRole:()=>o.sW,ParticipantType:()=>o.yJ,UpdateType:()=>o.Ur,default:()=>i});var a=r(227),o=r(7159);const i=a.A;return n})());
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import './markedMarkdown.css';
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* On the other hand, the `MarkedStreamingMarkdown` component is designed to handle streams of markdown-formatted text data. This component supports updates involving continuous appending of new markdown data to the existing content through the `updatedData` attribute.
|
|
9
|
-
*
|
|
10
|
-
* Tip: Use `MarkedMarkdown` when displaying static content or when you'd like to support content overwrite updates, and use `MarkedStreamingMarkdown` when its being updated dynamically and new content should be appended to existing content.*/
|
|
2
|
+
import { type TextData } from '../types';
|
|
3
|
+
/** The `MarkedMarkdown` component renders markdown-formatted text content into HTML.
|
|
4
|
+
* It uses [Marked](https://marked.js.org/) markdown parsing library.
|
|
5
|
+
* This component supports updates by appending/replacing the existing content through the `updatedData` attribute.
|
|
6
|
+
*/
|
|
11
7
|
declare const MarkedMarkdown: (props: TextData) => import("react/jsx-runtime").JSX.Element;
|
|
12
8
|
export default MarkedMarkdown;
|
|
13
9
|
//# sourceMappingURL=markedMarkdown.d.ts.map
|