@rustic-ai/ui-components 0.0.33 → 0.0.35

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.
Files changed (51) hide show
  1. package/dist/components/dynamicForm/index.js +1 -1
  2. package/dist/components/filePreview/filePreview.d.ts +1 -0
  3. package/dist/components/filePreview/filePreview.d.ts.map +1 -1
  4. package/dist/components/helper.d.ts +6 -1
  5. package/dist/components/helper.d.ts.map +1 -1
  6. package/dist/components/icon/index.js +1 -1
  7. package/dist/components/index.d.ts +7 -6
  8. package/dist/components/index.d.ts.map +1 -1
  9. package/dist/components/input/baseInput/baseInput.d.ts.map +1 -1
  10. package/dist/components/input/emoji/index.js +1 -1
  11. package/dist/components/input/multimodal/multimodalInput/index.css +5 -1
  12. package/dist/components/input/multimodal/multimodalInput/index.js +1 -1
  13. package/dist/components/input/multimodal/multimodalInput/multimodalInput.d.ts.map +1 -1
  14. package/dist/components/input/multimodal/uploader/index.css +4 -0
  15. package/dist/components/input/multimodal/uploader/index.js +1 -1
  16. package/dist/components/input/multimodal/uploader/uploader.d.ts.map +1 -1
  17. package/dist/components/input/textInput/index.css +1 -1
  18. package/dist/components/input/textInput/index.js +1 -1
  19. package/dist/components/messageCanvas/actions/copy/index.js +1 -1
  20. package/dist/components/messageCanvas/actions/index.js +1 -1
  21. package/dist/components/messageCanvas/actions/textToSpeech/index.js +1 -1
  22. package/dist/components/messageSpace/index.js +1 -1
  23. package/dist/components/multipart/chatCompletion/chatCompletion.d.ts +11 -0
  24. package/dist/components/multipart/chatCompletion/chatCompletion.d.ts.map +1 -0
  25. package/dist/components/multipart/{index.css → chatCompletion/index.css} +4 -0
  26. package/dist/components/multipart/chatCompletion/index.d.ts +4 -0
  27. package/dist/components/multipart/chatCompletion/index.d.ts.map +1 -0
  28. package/dist/components/multipart/chatCompletion/index.js +1 -0
  29. package/dist/components/multipart/multipart/index.css +149 -0
  30. package/dist/components/multipart/{index.d.ts → multipart/index.d.ts} +1 -1
  31. package/dist/components/multipart/multipart/index.d.ts.map +1 -0
  32. package/dist/components/multipart/{index.js → multipart/index.js} +1 -1
  33. package/dist/components/multipart/{multipart.d.ts → multipart/multipart.d.ts} +2 -2
  34. package/dist/components/multipart/multipart/multipart.d.ts.map +1 -0
  35. package/dist/components/promptBuilder/index.js +1 -1
  36. package/dist/components/promptBuilder/promptBuilder.d.ts.map +1 -1
  37. package/dist/components/prompts/index.js +1 -1
  38. package/dist/components/prompts/prompts.d.ts.map +1 -1
  39. package/dist/components/question/index.js +1 -1
  40. package/dist/components/text/index.js +1 -1
  41. package/dist/components/types.d.ts +62 -3
  42. package/dist/components/types.d.ts.map +1 -1
  43. package/dist/components/weather/index.js +1 -1
  44. package/dist/index.css +5 -1
  45. package/dist/index.js +1 -1
  46. package/dist/rusticTheme.d.ts +3 -11
  47. package/dist/rusticTheme.d.ts.map +1 -1
  48. package/dist/rusticTheme.js +1 -1
  49. package/package.json +15 -13
  50. package/dist/components/multipart/index.d.ts.map +0 -1
  51. package/dist/components/multipart/multipart.d.ts.map +0 -1
@@ -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={989:e=>{e.exports=require("@mui/material/Box")},785:e=>{e.exports=require("@mui/material/Typography")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")},903:e=>{e.exports=require("uuid")}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o](i,i.exports,t),i.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 o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},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 o={};t.r(o),t.d(o,{UniformsForm:()=>v});var n=t(732),i=t(989),a=t.n(i),s=t(785),u=t.n(s);const d=require("ajv");var c=t.n(d),l=t(15);const m=require("uniforms-bridge-json-schema"),p=require("uniforms-mui");var f=t(903);function v(e){var r=(0,l.useState)(e.data),t=r[0],o=r[1];(0,l.useEffect)((function(){e.data&&o(e.data)}),[e.data]);var i,s,d=new(c())({allErrors:!0,useDefaults:!0,keywords:["uniforms"]}),v=(i=e.schema,s=d.compile(i),function(e){var r;return s(e),(null===(r=s.errors)||void 0===r?void 0:r.length)?{details:s.errors}:null}),x=new m.JSONSchemaBridge({schema:e.schema,validator:v});return(0,n.jsxs)(a(),{className:"rustic-form",children:[e.title&&(0,n.jsx)(u(),{variant:"h6",children:e.title}),e.description&&(0,n.jsx)(u(),{variant:"body1",children:e.description}),(0,n.jsx)(p.AutoForm,{schema:x,onSubmit:function(r){return function(r){var t=(new Date).toISOString(),n={id:(0,f.v4)(),timestamp:t,sender:e.sender,conversationId:e.conversationId,format:"formResponse",data:r,inReplyTo:e.messageId};o(r),e.ws.send(n)}(r)},model:t,disabled:!!t})]})}return o})()));
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={6989:e=>{e.exports=require("@mui/material/Box")},785:e=>{e.exports=require("@mui/material/Typography")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")},3903:e=>{e.exports=require("uuid")}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o](i,i.exports,t),i.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 o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},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 o={};t.r(o),t.d(o,{UniformsForm:()=>v});var n=t(8732),i=t(6989),a=t.n(i),s=t(785),u=t.n(s);const d=require("ajv");var c=t.n(d),l=t(2015);const m=require("uniforms-bridge-json-schema"),p=require("uniforms-mui");var f=t(3903);function v(e){var r=(0,l.useState)(e.data),t=r[0],o=r[1];(0,l.useEffect)((function(){e.data&&o(e.data)}),[e.data]);var i,s,d=new(c())({allErrors:!0,useDefaults:!0,keywords:["uniforms"]}),v=(i=e.schema,s=d.compile(i),function(e){var r;return s(e),(null===(r=s.errors)||void 0===r?void 0:r.length)?{details:s.errors}:null}),x=new m.JSONSchemaBridge({schema:e.schema,validator:v});return(0,n.jsxs)(a(),{className:"rustic-form",children:[e.title&&(0,n.jsx)(u(),{variant:"h6",children:e.title}),e.description&&(0,n.jsx)(u(),{variant:"body1",children:e.description}),(0,n.jsx)(p.AutoForm,{schema:x,onSubmit:function(r){return function(r){var t=(new Date).toISOString(),n={id:(0,f.v4)(),timestamp:t,sender:e.sender,conversationId:e.conversationId,format:"formResponse",data:r,inReplyTo:e.messageId};o(r),e.ws.send(n)}(r)},model:t,disabled:!!t})]})}return o})()));
@@ -19,6 +19,7 @@ declare namespace FilePreview {
19
19
  url: string;
20
20
  }>;
21
21
  };
22
+ showFullName: boolean;
22
23
  };
23
24
  }
24
25
  export default FilePreview;
@@ -1 +1 @@
1
- {"version":3,"file":"filePreview.d.ts","sourceRoot":"","sources":["../../../src/components/filePreview/filePreview.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAA;AAC1B,OAAO,iBAAiB,CAAA;AAQxB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,CAAA;IACd,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAA;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AASD,iBAAwB,WAAW,CACjC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,2CAwEjD;kBAzEuB,WAAW;;;;;;;;;eAAX,WAAW"}
1
+ {"version":3,"file":"filePreview.d.ts","sourceRoot":"","sources":["../../../src/components/filePreview/filePreview.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAA;AAC1B,OAAO,iBAAiB,CAAA;AAQxB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,CAAA;IACd,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAA;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AASD,iBAAwB,WAAW,CACjC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,2CA4EjD;kBA7EuB,WAAW;;;;;;;;;;eAAX,WAAW"}
@@ -1,3 +1,4 @@
1
+ import type { ChatCompletionRequest } from './types';
1
2
  export declare function calculateTimeDiffInSeconds(isoDate: string): number;
2
3
  export declare function formatDateAndTime(isoDateTimeInUtc: string): string;
3
4
  export declare const capitalizeFirstLetter: (str: string) => string;
@@ -15,8 +16,12 @@ export declare function getSizeStyles(maybeWidth: number | undefined, maybeHeigh
15
16
  className?: string;
16
17
  };
17
18
  export declare function shortenString(str: string, maxLength: number): string;
18
- export declare const getDayFromUnixTime: (unixTime: number) => {
19
+ export declare function getDayFromUnixTime(unixTime: number): {
19
20
  shortName: string;
20
21
  fullName: string;
21
22
  };
23
+ export declare function toChatRequest(msg?: string, files?: {
24
+ url: string;
25
+ name?: string;
26
+ }[]): ChatCompletionRequest;
22
27
  //# sourceMappingURL=helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/components/helper.ts"],"names":[],"mappings":"AAEA,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CA6BlE;AAED,eAAO,MAAM,qBAAqB,QAAS,MAAM,KAAG,MAEnD,CAAA;AAED,oBAAY,UAAU;IACpB,IAAI,IAAA;IACJ,UAAU,IAAA;CACX;AAED,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,MAAM,EACzB,MAAM,EAAE,UAAU,GACjB,MAAM,CAsBR;AAED,wBAAgB,uBAAuB,CACrC,sBAAsB,EAAE,MAAM,EAC9B,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CASR;AAED,wBAAgB,oBAAoB,CAClC,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,MAAM,UAOvB;AAED,wBAAgB,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAapE;AAED,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAqBzD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAK3D;AAED,eAAO,MAAM,kBAAkB,aACnB,MAAM,KACf;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAoBvC,CAAA"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/components/helper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAW,MAAM,SAAS,CAAA;AAE7D,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CA6BlE;AAED,eAAO,MAAM,qBAAqB,QAAS,MAAM,KAAG,MAEnD,CAAA;AAED,oBAAY,UAAU;IACpB,IAAI,IAAA;IACJ,UAAU,IAAA;CACX;AAED,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,MAAM,EACzB,MAAM,EAAE,UAAU,GACjB,MAAM,CAsBR;AAED,wBAAgB,uBAAuB,CACrC,sBAAsB,EAAE,MAAM,EAC9B,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CASR;AAED,wBAAgB,oBAAoB,CAClC,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,MAAM,UAOvB;AAED,wBAAgB,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAapE;AAED,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAqBzD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAK3D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACpD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAoBA;AAED,wBAAgB,aAAa,CAC3B,GAAG,CAAC,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GACvC,qBAAqB,CAsBvB"}
@@ -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={767:(e,r,t)=>{t.d(r,{A:()=>a});var o=t(732),n=(t(15),function(){return n=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},n.apply(this,arguments)});function a(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:n({},r),children:e.name})}},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var a=r[o]={exports:{}};return e[o](a,a.exports,t),a.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 o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},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 o={};t.r(o),t.d(o,{default:()=>n});const n=t(767).A;return o})()));
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,t)=>{t.d(r,{A:()=>a});var o=t(8732),n=(t(2015),function(){return n=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},n.apply(this,arguments)});function a(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:n({},r),children:e.name})}},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var a=r[o]={exports:{}};return e[o](a,a.exports,t),a.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 o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},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 o={};t.r(o),t.d(o,{default:()=>n});const n=t(9767).A;return o})()));
@@ -18,7 +18,8 @@ import Action from './messageCanvas/actions/index';
18
18
  import TextToSpeech from './messageCanvas/actions/textToSpeech/textToSpeech';
19
19
  import MessageCanvas from './messageCanvas/messageCanvas';
20
20
  import MessageSpace from './messageSpace/messageSpace';
21
- import Multipart from './multipart/multipart';
21
+ import ChatCompletion from './multipart/chatCompletion/chatCompletion';
22
+ import Multipart from './multipart/multipart/multipart';
22
23
  import ParticipantsContainer from './participantsContainer/participantsContainer';
23
24
  import PDFViewer from './pdfViewer/pdfViewer';
24
25
  import PromptBuilder from './promptBuilder/promptBuilder';
@@ -35,10 +36,10 @@ import PerspectiveViz from './visualization/perspectiveViz/perspectiveViz';
35
36
  import PlotlyGraph from './visualization/plotlyGraph/plotlyGraph';
36
37
  import VegaLiteViz from './visualization/vegaLiteViz/vegaLiteViz';
37
38
  import Weather from './weather/weather';
38
- export { Action, CodeSnippet, CopyText, ElementRenderer, FCCalendar, Icon, Image, MarkedMarkdown, MarkedStreamingMarkdown, MermaidViz, MessageCanvas, MessageSpace, MultimodalInput, Multipart, OpenLayersMap, ParticipantsContainer, PDFViewer, PerspectiveViz, PlotlyGraph, PopoverMenu, PromptBuilder, Prompts, Question, RechartsTimeSeries, Sound, StreamingText, Table, Text, TextInput, TextToSpeech, Timestamp, UniformsForm, Uploader, VegaLiteViz, Video, Weather, YoutubeVideo, };
39
+ export { Action, ChatCompletion, CodeSnippet, CopyText, ElementRenderer, FCCalendar, Icon, Image, MarkedMarkdown, MarkedStreamingMarkdown, MermaidViz, MessageCanvas, MessageSpace, MultimodalInput, Multipart, OpenLayersMap, ParticipantsContainer, PDFViewer, PerspectiveViz, PlotlyGraph, PopoverMenu, PromptBuilder, Prompts, Question, RechartsTimeSeries, Sound, StreamingText, Table, Text, TextInput, TextToSpeech, Timestamp, UniformsForm, Uploader, VegaLiteViz, Video, Weather, YoutubeVideo, };
39
40
  export * from '../rusticTheme';
40
- export * from './types';
41
- export * from './visualization/mermaidViz/mermaidViz.types';
42
- export * from './visualization/plotlyGraph/plotlyGraph.types';
43
- export * from './visualization/vegaLiteViz/vegaLiteViz.types';
41
+ export type * from './types';
42
+ export type * from './visualization/mermaidViz/mermaidViz.types';
43
+ export type * from './visualization/plotlyGraph/plotlyGraph.types';
44
+ export type * from './visualization/vegaLiteViz/vegaLiteViz.types';
44
45
  //# sourceMappingURL=index.d.ts.map
@@ -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,uBAAuB,MAAM,oCAAoC,CAAA;AACxE,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAC5C,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,SAAS,MAAM,uBAAuB,CAAA;AAC7C,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,aAAa,MAAM,sBAAsB,CAAA;AAChD,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,YAAY,MAAM,sBAAsB,CAAA;AAC/C,OAAO,kBAAkB,MAAM,0CAA0C,CAAA;AACzE,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,WAAW,EACX,QAAQ,EACR,eAAe,EACf,UAAU,EACV,IAAI,EACJ,KAAK,EACL,cAAc,EACd,uBAAuB,EACvB,UAAU,EACV,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,kBAAkB,EAClB,KAAK,EACL,aAAa,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,OAAO,EACP,YAAY,GACb,CAAA;AAED,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,6CAA6C,CAAA;AAC3D,cAAc,+CAA+C,CAAA;AAC7D,cAAc,+CAA+C,CAAA"}
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,uBAAuB,MAAM,oCAAoC,CAAA;AACxE,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAC5C,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,aAAa,MAAM,sBAAsB,CAAA;AAChD,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,YAAY,MAAM,sBAAsB,CAAA;AAC/C,OAAO,kBAAkB,MAAM,0CAA0C,CAAA;AACzE,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,uBAAuB,EACvB,UAAU,EACV,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,kBAAkB,EAClB,KAAK,EACL,aAAa,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,OAAO,EACP,YAAY,GACb,CAAA;AAED,cAAc,gBAAgB,CAAA;AAC9B,mBAAmB,SAAS,CAAA;AAC5B,mBAAmB,6CAA6C,CAAA;AAChE,mBAAmB,+CAA+C,CAAA;AAClE,mBAAmB,+CAA+C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"baseInput.d.ts","sourceRoot":"","sources":["../../../../src/components/input/baseInput/baseInput.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAA;AAexB,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,cAAc,EAAW,MAAM,aAAa,CAAA;AAqW1D,QAAA,MAAM,SAAS;;wCAA+B,CAAA;AAU9C,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"baseInput.d.ts","sourceRoot":"","sources":["../../../../src/components/input/baseInput/baseInput.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAA;AAexB,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,cAAc,EAAW,MAAM,aAAa,CAAA;AAyW1D,QAAA,MAAM,SAAS;;wCAA+B,CAAA;AAU9C,eAAe,SAAS,CAAA"}
@@ -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,r,t={342:e=>{e.exports=require("emoji-picker-element")}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(t,o){if(1&o&&(t=this(t)),8&o)return t;if("object"==typeof t&&t){if(4&o&&t.__esModule)return t;if(16&o&&"function"==typeof t.then)return t}var i=Object.create(null);n.r(i);var c={};e=e||[null,r({}),r([]),r(r)];for(var a=2&o&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>c[e]=()=>t[e]));return c.default=()=>t,n.d(i,c),i},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 i={};n.r(i),n.d(i,{default:()=>y});const c=require("react/jsx-runtime");n(342);const a=require("@mui/material/IconButton");var u=n.n(a);const l=require("@mui/material/Popover");var s=n.n(l);const d=require("@mui/material/styles"),f=require("@mui/material/Tooltip");var p=n.n(f);const m=require("react");var v=function(){return v=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},v.apply(this,arguments)};function j(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,c.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:v({},r),children:e.name})}const y=function(e){var r=(0,d.useTheme)(),t=(0,m.useRef)(null),o=(0,m.useRef)(null),i=(0,m.useState)(!1),a=i[0],l=i[1],f={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function v(){l(!1)}function y(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),v()}return(0,m.useEffect)((function(){o.current||"undefined"==typeof window||Promise.resolve().then(n.t.bind(n,342,23)).then((function(t){var n=new(0,t.Picker)({dataSource:e.dataSource}),i="dark"===r.palette.mode?"dark":"light";n.classList.add(i),Object.keys(f).forEach((function(e){n.style.setProperty(e,f[e])})),o.current=n})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,m.useEffect)((function(){return o.current&&o.current.addEventListener("emoji-click",y),function(){var e;null===(e=o.current)||void 0===e||e.removeEventListener("emoji-click",y)}}),[a,e.onEmojiClick]),(0,c.jsxs)("div",{children:[(0,c.jsx)(p(),{title:"Emoji",children:(0,c.jsx)(u(),{size:"small",ref:t,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,c.jsx)(j,{name:"Mood"})})}),o.current&&(0,c.jsx)(s(),{open:a,anchorEl:t.current,onClose:v,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,c.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&o.current&&!e.contains(o.current)&&e.appendChild(o.current)}})})]})};return i})()));
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,r,t={8342:e=>{e.exports=require("emoji-picker-element")}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(t,o){if(1&o&&(t=this(t)),8&o)return t;if("object"==typeof t&&t){if(4&o&&t.__esModule)return t;if(16&o&&"function"==typeof t.then)return t}var i=Object.create(null);n.r(i);var c={};e=e||[null,r({}),r([]),r(r)];for(var a=2&o&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>c[e]=()=>t[e]));return c.default=()=>t,n.d(i,c),i},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 i={};n.r(i),n.d(i,{default:()=>y});const c=require("react/jsx-runtime");n(8342);const a=require("@mui/material/IconButton");var u=n.n(a);const l=require("@mui/material/Popover");var s=n.n(l);const d=require("@mui/material/styles"),f=require("@mui/material/Tooltip");var p=n.n(f);const m=require("react");var v=function(){return v=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},v.apply(this,arguments)};function j(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,c.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:v({},r),children:e.name})}const y=function(e){var r=(0,d.useTheme)(),t=(0,m.useRef)(null),o=(0,m.useRef)(null),i=(0,m.useState)(!1),a=i[0],l=i[1],f={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function v(){l(!1)}function y(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),v()}return(0,m.useEffect)((function(){o.current||"undefined"==typeof window||Promise.resolve().then(n.t.bind(n,8342,23)).then((function(t){var n=new(0,t.Picker)({dataSource:e.dataSource}),i="dark"===r.palette.mode?"dark":"light";n.classList.add(i),Object.keys(f).forEach((function(e){n.style.setProperty(e,f[e])})),o.current=n})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,m.useEffect)((function(){return o.current&&o.current.addEventListener("emoji-click",y),function(){var e;null===(e=o.current)||void 0===e||e.removeEventListener("emoji-click",y)}}),[a,e.onEmojiClick]),(0,c.jsxs)("div",{children:[(0,c.jsx)(p(),{title:"Emoji",children:(0,c.jsx)(u(),{size:"small",ref:t,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,c.jsx)(j,{name:"Mood"})})}),o.current&&(0,c.jsx)(s(),{open:a,anchorEl:t.current,onClose:v,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,c.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&o.current&&!e.contains(o.current)&&e.appendChild(o.current)}})})]})};return i})()));
@@ -99,7 +99,7 @@ code {
99
99
  }
100
100
 
101
101
  .rustic-base-input .rustic-input-label {
102
- padding-top: 8px;
102
+ padding-top: 10px;
103
103
  }
104
104
 
105
105
  .rustic-base-input .rustic-text-field .MuiOutlinedInput-input {
@@ -177,6 +177,10 @@ emoji-picker {
177
177
  min-width: 220px;
178
178
  }
179
179
 
180
+ .rustic-file-preview-name {
181
+ margin-right: 8px;
182
+ }
183
+
180
184
  .rustic-file-preview-modal {
181
185
  width: 90vw;
182
186
  height: 90vh;
@@ -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,r,n={767:(e,r,n)=>{n.d(r,{A:()=>o});var t=n(732),a=(n(15),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})}},110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(767).A},342:e=>{e.exports=require("emoji-picker-element")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function a(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return n[e](o,o.exports,a),o.exports}a.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return a.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(n,t){if(1&t&&(n=this(n)),8&t)return n;if("object"==typeof n&&n){if(4&t&&n.__esModule)return n;if(16&t&&"function"==typeof n.then)return n}var o=Object.create(null);a.r(o);var i={};e=e||[null,r({}),r([]),r(r)];for(var c=2&t&&n;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>i[e]=()=>n[e]));return i.default=()=>n,a.d(o,i),o},a.d=(e,r)=>{for(var n in r)a.o(r,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},a.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};a.r(o),a.d(o,{default:()=>Se});var i=a(732);const c=require("@mui/material/Box");var s=a.n(c);const l=require("@mui/material/styles");var u=a(15);const d=require("uuid"),m=require("@mui/material/CircularProgress");var p=a.n(m);const f=require("@mui/material/IconButton");var h=a.n(f);const v=require("@mui/material/InputAdornment");var x=a.n(v);const g=require("@mui/material/MenuItem");var b=a.n(g);const j=require("@mui/material/MenuList");var y=a.n(j);const w=require("@mui/material/Popover");var S=a.n(w);const F=require("@mui/material/TextField");var C=a.n(F);const N=require("@mui/material/Tooltip");var k=a.n(N);const P=require("@mui/material/Typography");var O=a.n(P),E=a(342),q=a(767);const T=function(e){var r=(0,l.useTheme)(),n=(0,u.useRef)(null),t=(0,u.useRef)(null),o=(0,u.useState)(!1),c=o[0],s=o[1],d={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function m(){s(!1)}function p(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),m()}return(0,u.useEffect)((function(){t.current||"undefined"==typeof window||Promise.resolve().then(a.t.bind(a,342,23)).then((function(n){var a=new(0,n.Picker)({dataSource:e.dataSource}),o="dark"===r.palette.mode?"dark":"light";a.classList.add(o),Object.keys(d).forEach((function(e){a.style.setProperty(e,d[e])})),t.current=a})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return t.current&&t.current.addEventListener("emoji-click",p),function(){var e;null===(e=t.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[c,e.onEmojiClick]),(0,i.jsxs)("div",{children:[(0,i.jsx)(k(),{title:"Emoji",children:(0,i.jsx)(h(),{size:"small",ref:n,onClick:function(){s((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(q.A,{name:"Mood"})})}),t.current&&(0,i.jsx)(S(),{open:c,anchorEl:n.current,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,i.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&t.current&&!e.contains(t.current)&&e.appendChild(t.current)}})})]})};var I={"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 R(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var D=(0,u.forwardRef)((function(e,r){var n=(0,u.useState)(""),t=n[0],a=n[1],o=(0,u.useState)(!1),c=o[0],l=o[1],m=(0,u.useState)(!1),f=m[0],v=m[1],g=(0,u.useState)(!1),j=g[0],w=g[1],F=(0,u.useState)(""),N=F[0],P=F[1],D=(0,u.useState)([]),A=D[0],z=D[1],_=(0,u.useState)(!1),M=_[0],U=_[1],B=(0,u.useRef)(null),L=new E.Database({dataSource:e.emojiDataSource}),W=!t.trim().length&&!e.isSendEnabled,$="".concat(c?"Stop":"Start"," speech to text"),H=f?"primary.main":"primary.light",V=c?"error.main":H,G=c?"stop_circle":"speech_to_text";function K(e,r){if(void 0===r&&(r=!1),B.current){var n=B.current,o=n.selectionStart,i=n.selectionEnd;if("number"==typeof o&&"number"==typeof i){var c,s=t||"",l=s.substring(0,o),u=s.substring(i);c=r?l.replace(/:(\w+)$/,e)+u:l+e+u,a(c);var d=r?l.replace(/:(\w+)$/,e).length:o+e.length;setTimeout((function(){var e,r;null===(e=B.current)||void 0===e||e.focus(),null===(r=B.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}U(!1)}var Q=j?(0,i.jsx)(p(),{size:24}):(0,i.jsx)(k(),{title:$,children:(0,i.jsx)(h(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,c?(e.stop(),w(!0),l(!1)):(e.start(),P(""),l(!0)),e.onstart=function(){l(!0)},e.onresult=function(e){var r,n=e.results[0][0].transcript;t.length>0?a(t+" "+n):a(n),null===(r=B.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=I[e.error];P(r),l(!1)},e.onend=function(){w(!1),l(!1)}},size:"small",sx:{color:V,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(q.A,{name:G})})});function Y(){var r=(new Date).toISOString(),n={id:(0,d.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:t}};e.send(n),a(""),P("")}return(0,i.jsxs)(s(),{className:"rustic-base-input",ref:r,children:[(0,i.jsxs)(s(),{className:"rustic-error-and-input-container",children:[(0,i.jsx)(s(),{className:"rustic-error-container",children:(0,i.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:N})}),(0,i.jsxs)(s(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[A.length>0&&(0,i.jsx)(S(),{open:M,anchorEl:B.current,onClose:function(){return U(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,i.jsx)(y(),{children:A.map((function(e,r){return"unicode"in e&&(0,i.jsx)(b(),{onClick:function(){return K(e.unicode,!0)},children:R(e)},r)}))})}),(0,i.jsx)(C(),{className:"rustic-text-field",variant:"outlined",value:t,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!W&&Y())},onChange:function(r){P("");var n=r.target.value;a(n);var t,o=n.match(/:(\w{2,}):/g),i=n.match(/:(\w{2,})/g);if(o){var c=o[0].replace(/:/g,"");L.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=n.replace(o[0],e.unicode);a(r)}else a(n)})).catch((function(){a(n)})),U(!1)}else i?(t=i[0].replace(":",""),L.getEmojiBySearchQuery(t).then((function(r){r.length?(z(r.slice(0,e.maximumEmojiSearchResults)),U(!0)):(z([]),U(!1))})).catch((function(){z([]),U(!1)}))):U(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:B,color:"secondary",size:"small",InputProps:{endAdornment:(0,i.jsxs)(x(),{position:"end",className:"rustic-input-adornment",children:[(0,i.jsx)(T,{dataSource:e.emojiDataSource,onEmojiClick:K,buttonColor:H}),e.enableSpeechToText&&Q]})},InputLabelProps:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,i.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,i.jsxs)(s(),{className:"rustic-input-actions",children:[e.children,(0,i.jsx)(k(),{title:"Send",children:(0,i.jsx)("span",{className:"rustic-send-button",children:(0,i.jsx)(h(),{"aria-label":"send message",onClick:Y,disabled:W,color:"secondary",children:(0,i.jsx)(q.A,{name:"send"})})})})]})]})}));D.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const A=D,z=require("@mui/material/LinearProgress");var _=a.n(z);const M=require("axios");var U=a.n(M);const B=require("react-dom"),L=require("@mui/material/Card");var W=a.n(L);const $=require("@mui/material/Modal");var H,V=a.n($);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(H||(H={}));const G=require("@mui/material/useMediaQuery");var K=a.n(G);const Q=require("@mui/system/Stack");var Y=a.n(Q);const Z=require("@mui/system/useTheme");var J=a.n(Z);const X=require("pdfjs-dist"),ee=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,i.jsx)(k(),{title:n.label,children:(0,i.jsx)("span",{children:(0,i.jsx)(h(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,i.jsx)(q.A,{name:n.symbol})})})})};var re={pdf:function(e){var r,n=(0,u.useRef)(null),t=(0,u.useState)(1),a=t[0],o=t[1],c=(0,u.useState)(1),l=c[0],d=c[1],m=(0,u.useState)(1),p=m[0],f=m[1],h=(0,u.useState)(!1),v=h[0],x=h[1],g=(0,u.useState)(),b=g[0],j=g[1],y=J()(),w=K()(y.breakpoints.down("sm")),S=K()(y.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,i.jsx)(W(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(O(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var F=(0,u.useState)((function(){return w?.5:S?1:1.5})),N=F[0],k=F[1];return(0,u.useEffect)((function(){X.GlobalWorkerOptions.workerSrc||(X.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(X.version,"/pdf.worker.mjs")),X.getDocument({url:"".concat(e.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(a).then((function(e){var r=e.getViewport({scale:N}),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]};b&&b.cancel();var c=e.render(i);j(c),c.promise.then((function(){j(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){x(!0)}))}),[e.url,a,N]),v?(0,i.jsx)(W(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(O(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,i.jsxs)(W(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,i.jsxs)(s(),{className:"rustic-pdf-viewer-header",children:[(0,i.jsx)(ee,{action:"zoomOut",onClick:function(){k((function(e){return Math.max(e-.2,.2)}))}}),(0,i.jsx)(ee,{action:"zoomIn",onClick:function(){k((function(e){return e+.2}))}})]}),(0,i.jsx)(s(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(s(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:n})})}),(0,i.jsxs)(Y(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(ee,{action:"previousPage",onClick:function(){a>1&&(o(a-1),f(a-1))},isDisabled:1===a}),(0,i.jsx)(O(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,i.jsx)(C(),{type:"number",value:p,onChange:function(e){var r=parseInt(e.target.value);f(r),!isNaN(r)&&r>=1&&r<=l&&o(r)},size:"small",className:"rustic-pdf-page-input"}),(0,i.jsxs)(O(),{variant:"body1",className:"rustic-page-indicator",children:["of ",l]}),(0,i.jsx)(ee,{action:"nextPage",onClick:function(){a<l&&(o(a+1),f(a+1))},isDisabled:a===l})]})]})}};function ne(e){var r=(0,l.useTheme)(),n=(0,u.useState)(!1),t=n[0],a=n[1];function o(){a(!1)}var c,s,d=e.file.url&&(c=e.file.url.split("."))[c.length-1].toLowerCase(),m=d&&e.supportedViewers?e.supportedViewers[d]:null,p=!!m,f=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",v=p?" rustic-cursor-pointer":"",x="rustic-file-preview ".concat(f).concat(v),g=e.showFullName?e.file.name:(15,(s=e.file.name).length<=15?s:s.substring(0,12)+"...");return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(W(),{className:x,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){a(!0)},children:[(0,i.jsx)(O(),{variant:"subtitle2",children:g}),(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,i.jsx)(V(),{open:t,onClose:o,className:"rustic-file-preview-modal",children:(0,i.jsxs)("div",{className:"rustic-modal-content",children:[(0,i.jsx)(k(),{title:"Close",children:(0,i.jsx)(h(),{onClick:o,className:"rustic-close-button",children:(0,i.jsx)(q.A,{name:"close"})})}),e.file.url&&(0,i.jsx)(m,{url:e.file.url})]})})]})}ne.defaultProps={supportedViewers:re};var te=a(110);const ae=require("@mui/material"),oe=require("@mui/material/Button");var ie=a.n(oe);const ce=require("@mui/material/Drawer");var se=a.n(ce);const le=require("@mui/material/ListItemText");var ue=a.n(le);const de=require("@mui/material/Menu");var me=a.n(de);const pe=require("@mui/system");var fe=function(){return fe=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},fe.apply(this,arguments)};function he(e){var r=(0,u.useState)(!1),n=r[0],t=r[1],a=(0,u.useRef)(null),o=(0,l.useTheme)(),c=(0,ae.useMediaQuery)(o.breakpoints.down("md")),s=c?se():me(),d={borderRadius:"".concat(o.shape.borderRadius,"px"),border:"1px solid ".concat(o.palette.divider)};function m(e){return(0,i.jsxs)(i.Fragment,{children:[e.startDecorator&&(0,i.jsx)(pe.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,i.jsx)(ue(),{children:(0,i.jsx)(O(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,i.jsx)(pe.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}c&&(d=fe(fe({},d),{borderRadius:"".concat(o.shape.borderRadius,"px ").concat(o.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=e.menuItems.map((function(e){return e.href?(0,i.jsx)(b(),{component:"a",onClick:function(){return t(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:m(e)},e.label):(0,i.jsx)(b(),{onClick:function(r){e.onClick&&e.onClick(r),t(!1)},disabled:!e.onClick,children:m(e)},e.label)}));var f,v,x=c?{}:{anchorEl:a.current};return(0,i.jsxs)(i.Fragment,{children:[(f={onClick:function(e){e.stopPropagation(),t(!0)},"aria-label":e.ariaLabel,ref:a,className:"rustic-popover-menu-button"},v=(0,i.jsx)(q.A,{name:"more_vert"}),e.buttonText?(0,i.jsx)(ie(),fe({},f,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,i.jsx)(k(),{title:e.ariaLabel,children:(0,i.jsx)(h(),fe({},f,{children:e.icon?e.icon:v}))})),(0,i.jsx)(s,fe({open:n,onClose:function(){return t(!1)}},x,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":fe(fe({},d),{backgroundImage:"none",boxShadow:o.shadows[2]})},children:p}))]})}var ve=function(){return ve=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},ve.apply(this,arguments)},xe=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 ge(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])}const be=function(e){var r,n=(0,u.useState)([]),t=n[0],a=n[1],o=(0,u.useState)([]),c=o[0],l=o[1],m=(0,u.useState)({}),p=m[0],f=m[1],v=(0,u.useRef)({}),x=(0,d.v4)();function g(e,r,n){var t;v.current=ve(ve({},v.current),((t={})[e]=v.current[e]--,t)),function(e,r,n){l((function(r){return xe(xe([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),a((function(e){return e.filter((function(e){return e.id!==r}))}))}(e,r,n)}(0,u.useEffect)((function(){a([]),l([]),v.current={}}),[e.messageId]);var b=(0,i.jsx)(s(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,n){return(0,i.jsx)(ne,{file:{name:r.name},showFullName:e.showFullName,children:(0,i.jsxs)(s(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,i.jsx)(_(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,i.jsx)(k(),{title:"Delete",children:(0,i.jsx)(h(),{color:"primary",onClick:function(){return function(r,n){var t,o;l([]);var i=r.name;if(v.current=ve(ve({},v.current),((t={})[i]=v.current[i]--,t)),e.onFileUpdate("remove",i),100===r.loadingProgress){var c="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);U().delete(c).then((function(){return a((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",i),l((function(e){return xe(xe([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}else r.abortController.abort(),a((function(e){return e.filter((function(e,r){return r!==n}))})),v.current=ve(ve({},v.current),((o={})[i]=v.current[i]++,o))}(r,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)(s(),{children:c.map((function(e,r){return(0,i.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function y(e,r){return r?(0,B.createPortal)(e,r):e}var w=null===(r=e.uploadOptions)||void 0===r?void 0:r.map((function(r){return{label:r.label,onClick:function(){return function(r){f(r.metadata);var n=document.getElementById(x);n&&(n.accept=r.acceptedFileTypes||e.acceptedFileTypes),n.click()}(r)},startDecorator:r.iconName&&(0,i.jsx)(te.default,{name:r.iconName})}}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(s(),{className:"rustic-uploader",children:[(0,i.jsx)("label",{htmlFor:x,children:(null==w?void 0:w.length)?(0,i.jsx)(he,{ariaLabel:"Upload",icon:(0,i.jsx)(te.default,{name:"upload_2"}),menuItems:w}):(0,i.jsx)(k(),{title:"Upload",children:(0,i.jsx)(h(),{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:x,onChange:function(r){l([]);var n=r.target.files&&Array.from(r.target.files),o=t.length+(n?n.length:0);e.maxFileCount&&o>e.maxFileCount&&l((function(r){return xe(xe([],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,o,e.maxFileCount);i&&i.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,l((function(r){return xe(xe([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&ge(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,o=function(e){var r,n,t=e.name,a=v.current[t];if(a){var o=a+1,i=t.lastIndexOf("."),c=t.substring(0,i),s=t.substring(i);t="".concat(c,"(").concat(a,")").concat(s),v.current=ve(ve({},v.current),((r={})[e.name]=o,r))}else v.current=ve(ve({},v.current),((n={})[e.name]=1,n));return t}(r),i=new File([r],o,{type:r.type});if(e.getUploadData||p){var c=e.getUploadData?e.getUploadData(o):{},s=ve(ve({},c),p);Object.keys(s).forEach((function(e){var r=s[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)}))}n.append("file",i);var l=(0,d.v4)(),u={name:o,loadingProgress:0,abortController:t,id:l};function m(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=u.id,a((function(e){var t=e.map((function(e){return e.id===n?ve(ve({},e),{loadingProgress:r}):e}));return t})))}a((function(e){return xe(xe([],e,!0),[u],!1)})),e.onFileUpdate("add",o);var f="".concat(e.uploadFileEndpoint).replaceAll("fileName",o).replaceAll("messageId",e.messageId);!function i(){return U().post(f,n,{onUploadProgress:m,signal:t.signal}).then((function(e){var r,n;e.data.fileId&&(r=e.data,n=u.id,a((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=xe([],e,!0);return a[t]=ve(ve({},a[t]),{id:r.fileId}),a}return e})))})).catch((function(t){var c,s,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var m,p,f,h;409===(null===(c=t.response)||void 0===c?void 0:c.status)&&e.listFiles?(m=o.lastIndexOf("."),p=o.substring(0,m),f=o.substring(m),h=new RegExp("^".concat(p.replace(".","\\."),"(\\(\\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(h.test(a.name)){var o=a.name.match(h),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(o)).then((function(t){e.onFileUpdate("add",t);var o=new File([r],t,{type:r.type});n.set("file",o),a((function(e){return e.map((function(e){return e.id===l?ve(ve({},e),{name:t,loadingProgress:0}):e}))})),i()})).catch((function(){var e;g(r.name,u.id,null===(e=t.response)||void 0===e?void 0:e.data)})):g(r.name,u.id,null===(s=t.response)||void 0===s?void 0:s.data)}))}()}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),c.length>0&&y(j,e.errorMessagesContainer),t.length>0&&y(b,e.filePreviewsContainer)]})};var je=function(){return je=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},je.apply(this,arguments)},ye=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 we(e){var r=(0,u.useState)([]),n=r[0],t=r[1],a=(0,u.useState)((0,d.v4)()),o=a[0],c=a[1],m=(0,u.useState)(),p=m[0],f=m[1],h=(0,u.useState)(),v=h[0],x=h[1],g=(0,u.useRef)(null),b=(0,l.useTheme)(),j=n.length>0;return(0,u.useEffect)((function(){g.current&&(x(g.current.querySelector(".rustic-error-container")),f(g.current.querySelector(".rustic-input-extras")))})),(0,i.jsx)(s(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(b.palette.action.disabled),borderRadius:"".concat(b.shape.borderRadius,"px"),":focus-within":{borderColor:b.palette.secondary.main},background:b.palette.background.paper},children:(0,i.jsx)(A,je({},e,{send:function(r){j&&(r.id=o,r.format="filesWithText",r.data.files=n),e.ws.send(r),c((0,d.v4)()),t([])},isSendEnabled:j,ref:g,children:(0,i.jsx)(s(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(be,{acceptedFileTypes:e.acceptedFileTypes,maxFileCount:e.maxFileCount,maxFileSize:e.maxFileSize,uploadFileEndpoint:e.uploadFileEndpoint,deleteFileEndpoint:e.deleteFileEndpoint,onFileUpdate:function(e,r){t("add"===e?function(e){return ye(ye([],e,!0),[{name:r}],!1)}:function(e){return e.filter((function(e){return e.name!==r}))})},messageId:o,filePreviewsContainer:p,errorMessagesContainer:v,showFullName:e.showFullName,getUploadData:e.getUploadData,uploadOptions:e.uploadOptions,listFiles:e.listFiles})})}))})}we.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const Se=we;return o})()));
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,r,t={9767:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(8732),a=(t(2015),function(){return a=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},a.apply(this,arguments)});function o(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:a({},r),children:e.name})}},3110:(e,r,t)=>{t.d(r,{default:()=>n});const n=t(9767).A},8342:e=>{e.exports=require("emoji-picker-element")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},n={};function a(e){var r=n[e];if(void 0!==r)return r.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,a),o.exports}a.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return a.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var o=Object.create(null);a.r(o);var i={};e=e||[null,r({}),r([]),r(r)];for(var l=2&n&&t;"object"==typeof l&&!~e.indexOf(l);l=r(l))Object.getOwnPropertyNames(l).forEach((e=>i[e]=()=>t[e]));return i.default=()=>t,a.d(o,i),o},a.d=(e,r)=>{for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};a.r(o),a.d(o,{default:()=>Se});var i=a(8732);const l=require("@mui/material/Box");var c=a.n(l);const s=require("@mui/material/styles");var u=a(2015);const d=require("uuid");var p;function m(e,r){var t=[];if(e&&(null==e?void 0:e.trim().length)&&t.push({type:"text",text:e}),r&&r.length>0)for(var n=0;n<(null==r?void 0:r.length);n++)t.push({type:"file_url",file_url:{url:r[n].url,name:r[n].name}});return{messages:[{content:t,role:"user"}]}}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(p||(p={}));const f=require("@mui/material/CircularProgress");var h=a.n(f);const v=require("@mui/material/IconButton");var g=a.n(v);const x=require("@mui/material/InputAdornment");var b=a.n(x);const j=require("@mui/material/MenuItem");var y=a.n(j);const w=require("@mui/material/MenuList");var F=a.n(w);const S=require("@mui/material/Popover");var C=a.n(S);const N=require("@mui/material/TextField");var k=a.n(N);const P=require("@mui/material/Tooltip");var O=a.n(P);const E=require("@mui/material/Typography");var q=a.n(E),R=a(8342),T=a(9767);const I=function(e){var r=(0,s.useTheme)(),t=(0,u.useRef)(null),n=(0,u.useRef)(null),o=(0,u.useState)(!1),l=o[0],c=o[1],d={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function p(){c(!1)}function m(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),p()}return(0,u.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(a.t.bind(a,8342,23)).then((function(t){var a=new(0,t.Picker)({dataSource:e.dataSource}),o="dark"===r.palette.mode?"dark":"light";a.classList.add(o),Object.keys(d).forEach((function(e){a.style.setProperty(e,d[e])})),n.current=a})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",m),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",m)}}),[l,e.onEmojiClick]),(0,i.jsxs)("div",{children:[(0,i.jsx)(O(),{title:"Emoji",children:(0,i.jsx)(g(),{size:"small",ref:t,onClick:function(){c((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(T.A,{name:"Mood"})})}),n.current&&(0,i.jsx)(C(),{open:l,anchorEl:t.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&&n.current&&!e.contains(n.current)&&e.appendChild(n.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 A(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var _=(0,u.forwardRef)((function(e,r){var t=(0,u.useState)(""),n=t[0],a=t[1],o=(0,u.useState)(!1),l=o[0],s=o[1],p=(0,u.useState)(!1),f=p[0],v=p[1],x=(0,u.useState)(!1),j=x[0],w=x[1],S=(0,u.useState)(""),N=S[0],P=S[1],E=(0,u.useState)([]),_=E[0],U=E[1],z=(0,u.useState)(!1),L=z[0],M=z[1],B=(0,u.useRef)(null),H=new R.Database({dataSource:e.emojiDataSource}),$=!n.trim().length&&!e.isSendEnabled,W="".concat(l?"Stop":"Start"," speech to text"),V=f?"primary.main":"primary.light",G=l?"error.main":V,K=l?"stop_circle":"speech_to_text";function Q(e,r){if(void 0===r&&(r=!1),B.current){var t=B.current,o=t.selectionStart,i=t.selectionEnd;if("number"==typeof o&&"number"==typeof i){var l,c=n||"",s=c.substring(0,o),u=c.substring(i);l=r?s.replace(/:(\w+)$/,e)+u:s+e+u,a(l);var d=r?s.replace(/:(\w+)$/,e).length:o+e.length;setTimeout((function(){var e,r;null===(e=B.current)||void 0===e||e.focus(),null===(r=B.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}M(!1)}var Y=j?(0,i.jsx)(h(),{size:24}):(0,i.jsx)(O(),{title:W,children:(0,i.jsx)(g(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,l?(e.stop(),w(!0),s(!1)):(e.start(),P(""),s(!0)),e.onstart=function(){s(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;n.length>0?a(n+" "+t):a(t),null===(r=B.current)||void 0===r||r.focus(),s(!1)},e.onerror=function(e){var r=D[e.error];P(r),s(!1)},e.onend=function(){w(!1),s(!1)}},size:"small",sx:{color:G,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(T.A,{name:K})})});function Z(){var r=(new Date).toISOString(),t={id:(0,d.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"chatCompletionRequest",data:m(n)};e.send(t),a(""),P("")}return(0,i.jsxs)(c(),{className:"rustic-base-input",ref:r,children:[(0,i.jsxs)(c(),{className:"rustic-error-and-input-container",children:[(0,i.jsx)(c(),{className:"rustic-error-container",children:(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:N})}),(0,i.jsxs)(c(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[_.length>0&&(0,i.jsx)(C(),{open:L,anchorEl:B.current,onClose:function(){return M(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,i.jsx)(F(),{children:_.map((function(e,r){return"unicode"in e&&(0,i.jsx)(y(),{onClick:function(){return Q(e.unicode,!0)},children:A(e)},r)}))})}),(0,i.jsx)(k(),{className:"rustic-text-field",variant:"outlined",value:n,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),$||Z())},onChange:function(r){P("");var t=r.target.value;a(t);var n,o=t.match(/:(\w{2,}):/g),i=t.match(/:(\w{2,})/g);if(o){var l=o[0].replace(/:/g,"");H.getEmojiByShortcode(l).then((function(e){if(e&&"unicode"in e){var r=t.replace(o[0],e.unicode);a(r)}else a(t)})).catch((function(){a(t)})),M(!1)}else i?(n=i[0].replace(":",""),H.getEmojiBySearchQuery(n).then((function(r){r.length?(U(r.slice(0,e.maximumEmojiSearchResults)),M(!0)):(U([]),M(!1))})).catch((function(){U([]),M(!1)}))):M(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:B,color:"secondary",size:"small",slotProps:{input:{endAdornment:(0,i.jsxs)(b(),{position:"end",className:"rustic-input-adornment",children:[(0,i.jsx)(I,{dataSource:e.emojiDataSource,onEmojiClick:Q,buttonColor:V}),e.enableSpeechToText&&Y]})},inputLabel:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,i.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,i.jsxs)(c(),{className:"rustic-input-actions",children:[e.children,(0,i.jsx)(O(),{title:"Send",children:(0,i.jsx)("span",{className:"rustic-send-button",children:(0,i.jsx)(g(),{"aria-label":"send message",onClick:Z,disabled:$,color:"secondary",children:(0,i.jsx)(T.A,{name:"send"})})})})]})]})}));_.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const U=_,z=require("@mui/material/LinearProgress");var L=a.n(z);const M=require("axios");var B=a.n(M);const H=require("react-dom"),$=require("@mui/material/Card");var W=a.n($);const V=require("@mui/material/Modal");var G=a.n(V);const K=require("@mui/material/useMediaQuery");var Q=a.n(K);const Y=require("@mui/system/Stack");var Z=a.n(Y);const J=require("@mui/system/useTheme");var X=a.n(J);const ee=require("pdfjs-dist"),re=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"}},t=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,i.jsx)(O(),{title:t.label,children:(0,i.jsx)("span",{children:(0,i.jsx)(g(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,i.jsx)(T.A,{name:t.symbol})})})})};var te={pdf:function(e){var r,t=(0,u.useRef)(null),n=(0,u.useState)(1),a=n[0],o=n[1],l=(0,u.useState)(1),s=l[0],d=l[1],p=(0,u.useState)(1),m=p[0],f=p[1],h=(0,u.useState)(!1),v=h[0],g=h[1],x=(0,u.useState)(),b=x[0],j=x[1],y=X()(),w=Q()(y.breakpoints.down("sm")),F=Q()(y.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,i.jsx)(W(),{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 S=(0,u.useState)((function(){return w?.5:F?1:1.5})),C=S[0],N=S[1];return(0,u.useEffect)((function(){ee.GlobalWorkerOptions.workerSrc||(ee.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(ee.version,"/pdf.worker.mjs")),ee.getDocument({url:"".concat(e.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(a).then((function(e){var r=e.getViewport({scale:C}),n=t.current;if(n){var a=n.getContext("2d");if(a){var o=window.devicePixelRatio||1;n.style.width="".concat(r.width,"px"),n.style.height="".concat(r.height,"px"),n.width=r.width*o,n.height=r.height*o;var i={canvasContext:a,viewport:r,transform:[o,0,0,o,0,0]};b&&b.cancel();var l=e.render(i);j(l),l.promise.then((function(){j(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[e.url,a,C]),v?(0,i.jsx)(W(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(q(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,i.jsxs)(W(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,i.jsxs)(c(),{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)(c(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(c(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:t})})}),(0,i.jsxs)(Z(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(re,{action:"previousPage",onClick:function(){a>1&&(o(a-1),f(a-1))},isDisabled:1===a}),(0,i.jsx)(q(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,i.jsx)(k(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);f(r),!isNaN(r)&&r>=1&&r<=s&&o(r)},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(){a<s&&(o(a+1),f(a+1))},isDisabled:a===s})]})]})}};function ne(e){var r=(0,s.useTheme)(),t=(0,u.useState)(!1),n=t[0],a=t[1];function o(){a(!1)}var l,c,d=e.file.url&&(l=e.file.url.split("."))[l.length-1].toLowerCase(),p=d&&e.supportedViewers?e.supportedViewers[d]:null,m=!!p,f=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",h=m?" rustic-cursor-pointer":"",v="rustic-file-preview ".concat(f).concat(h),x=e.showFullName?e.file.name:(c=e.file.name).length<=15?c:c.substring(0,12)+"...";return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(W(),{className:v,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){a(!0)},children:[(0,i.jsx)(q(),{variant:"subtitle2",className:"rustic-file-preview-name",children:x}),(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),m&&(0,i.jsx)(G(),{open:n,onClose:o,className:"rustic-file-preview-modal",children:(0,i.jsxs)("div",{className:"rustic-modal-content",children:[(0,i.jsx)(O(),{title:"Close",children:(0,i.jsx)(g(),{onClick:o,className:"rustic-close-button",children:(0,i.jsx)(T.A,{name:"close"})})}),e.file.url&&(0,i.jsx)(p,{url:e.file.url})]})})]})}ne.defaultProps={supportedViewers:te,showFullName:!0};var ae=a(3110);const oe=require("@mui/material"),ie=require("@mui/material/Button");var le=a.n(ie);const ce=require("@mui/material/Drawer");var se=a.n(ce);const ue=require("@mui/material/ListItemText");var de=a.n(ue);const pe=require("@mui/material/Menu");var me=a.n(pe);const fe=require("@mui/system");var he=function(){return he=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},he.apply(this,arguments)};function ve(e){var r=(0,u.useState)(!1),t=r[0],n=r[1],a=(0,u.useRef)(null),o=(0,s.useTheme)(),l=(0,oe.useMediaQuery)(o.breakpoints.down("md")),c=l?se():me(),d={borderRadius:"".concat(o.shape.borderRadius,"px"),border:"1px solid ".concat(o.palette.divider)};function p(e){return(0,i.jsxs)(i.Fragment,{children:[e.startDecorator&&(0,i.jsx)(fe.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,i.jsx)(de(),{children:(0,i.jsx)(q(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,i.jsx)(fe.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}l&&(d=he(he({},d),{borderRadius:"".concat(o.shape.borderRadius,"px ").concat(o.shape.borderRadius,"px 0 0"),borderBottom:0}));var m=e.menuItems.map((function(e){return e.href?(0,i.jsx)(y(),{component:"a",onClick:function(){return n(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:p(e)},e.label):(0,i.jsx)(y(),{onClick:function(r){e.onClick&&e.onClick(r),n(!1)},disabled:!e.onClick,children:p(e)},e.label)}));var f,h,v=l?{}:{anchorEl:a.current};return(0,i.jsxs)(i.Fragment,{children:[(f={onClick:function(e){e.stopPropagation(),n(!0)},"aria-label":e.ariaLabel,ref:a,className:"rustic-popover-menu-button"},h=(0,i.jsx)(T.A,{name:"more_vert"}),e.buttonText?(0,i.jsx)(le(),he({},f,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,i.jsx)(O(),{title:e.ariaLabel,children:(0,i.jsx)(g(),he({},f,{children:e.icon?e.icon:h}))})),(0,i.jsx)(c,he({open:t,onClose:function(){return n(!1)}},v,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":he(he({},d),{backgroundImage:"none",boxShadow:o.shadows[2]})},children:m}))]})}var ge=function(){return ge=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},ge.apply(this,arguments)},xe=function(e,r,t){if(t||2===arguments.length)for(var n,a=0,o=r.length;a<o;a++)!n&&a in r||(n||(n=Array.prototype.slice.call(r,0,a)),n[a]=r[a]);return e.concat(n||Array.prototype.slice.call(r))};function be(e){for(var r=["Bytes","KB","MB","GB"],t=0;e>=1024&&t<r.length-1;)e/=1024,t++;var n=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(n," ").concat(r[t])}const je=function(e){var r,t=(0,u.useState)([]),n=t[0],a=t[1],o=(0,u.useState)([]),l=o[0],s=o[1],p=(0,u.useState)({}),m=p[0],f=p[1],h=(0,u.useRef)({}),v=(0,d.v4)();(0,u.useEffect)((function(){a([]),s([]),h.current={}}),[e.messageId]);var x=e.getUploadHeaders?e.getUploadHeaders():Promise.resolve({headers:{}});function b(e,r,t){var n;h.current=ge(ge({},h.current),((n={})[e]=h.current[e]--,n)),function(e,r,t){s((function(r){return xe(xe([],r,!0),["Failed to upload ".concat(e,". ").concat((null==t?void 0:t.message)||"")],!1)})),a((function(e){return e.filter((function(e){return e.id!==r}))}))}(e,r,t)}var j=(0,i.jsx)(c(),{className:"rustic-files rustic-padding-16",children:n.map((function(r,t){return(0,i.jsx)(ne,{file:{name:r.name},showFullName:e.showFullName,children:(0,i.jsxs)(c(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,i.jsx)(L(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,i.jsx)(O(),{title:"Delete",children:(0,i.jsx)(g(),{color:"primary",onClick:function(){return function(r,t){var n,o;s([]);var i=r.name;if(h.current=ge(ge({},h.current),((n={})[i]=h.current[i]--,n)),e.onFileUpdate("remove",i),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);x.then((function(r){B().delete(l,ge({},r)).then((function(){return a((function(e){return e.filter((function(e,r){return r!==t}))}))})).catch((function(){return e.onFileUpdate("add",i),s((function(e){return xe(xe([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}))}else r.abortController.abort(),a((function(e){return e.filter((function(e,r){return r!==t}))})),h.current=ge(ge({},h.current),((o={})[i]=h.current[i]++,o))}(r,t)},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"})})})]})},t)}))}),y=(0,i.jsx)(c(),{children:l.map((function(e,r){return(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function w(e,r){return r?(0,H.createPortal)(e,r):e}var F=null===(r=e.uploadOptions)||void 0===r?void 0:r.map((function(r){return{label:r.label,onClick:function(){return function(r){f(r.metadata);var t=document.getElementById(v);t&&(t.accept=r.acceptedFileTypes||e.acceptedFileTypes),t.click()}(r)},startDecorator:r.iconName&&(0,i.jsx)(ae.default,{name:r.iconName})}}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(c(),{className:"rustic-uploader",children:[(0,i.jsx)("label",{htmlFor:v,children:(null==F?void 0:F.length)?(0,i.jsx)(ve,{ariaLabel:"Upload",icon:(0,i.jsx)(ae.default,{name:"upload_2"}),menuItems:F}):(0,i.jsx)(O(),{title:"Upload",children:(0,i.jsx)(g(),{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(r){s([]);var t=r.target.files&&Array.from(r.target.files),o=n.length+(t?t.length:0);e.maxFileCount&&o>e.maxFileCount&&s((function(r){return xe(xe([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=t&&function(e,r,t){return t?r<=t?e:e.slice(0,t-r):e}(t,o,e.maxFileCount);i&&i.forEach((function(r){!function(r){var t;e.maxFileSize&&r.size>e.maxFileSize?(t=r.name,s((function(r){return xe(xe([],r,!0),["Failed to upload ".concat(t,". You cannot upload files larger than ").concat(e.maxFileSize&&be(e.maxFileSize),".")],!1)}))):function(r){var t=new FormData,n=new AbortController,o=function(e){var r,t,n=e.name,a=h.current[n];if(a){var o=a+1,i=n.lastIndexOf("."),l=n.substring(0,i),c=n.substring(i);n="".concat(l,"(").concat(a,")").concat(c),h.current=ge(ge({},h.current),((r={})[e.name]=o,r))}else h.current=ge(ge({},h.current),((t={})[e.name]=1,t));return n}(r),i=new File([r],o,{type:r.type});if(e.getUploadData||m){var l=e.getUploadData?e.getUploadData(o):{},c=ge(ge({},l),m);Object.keys(c).forEach((function(e){var r=c[e];t.append(e,"object"==typeof r?JSON.stringify(r):r)}))}t.append("file",i);var s=(0,d.v4)(),u={name:o,loadingProgress:0,abortController:n,id:s};function p(e){var r,t;e.total&&(r=e.loaded/e.total*100,t=u.id,a((function(e){var n=e.map((function(e){return e.id===t?ge(ge({},e),{loadingProgress:r}):e}));return n})))}a((function(e){return xe(xe([],e,!0),[u],!1)})),e.onFileUpdate("add",o);var f="".concat(e.uploadFileEndpoint).replaceAll("fileName",o).replaceAll("messageId",e.messageId);!function i(){return x.then((function(l){return B().post(f,t,ge(ge({},l),{onUploadProgress:p,signal:n.signal})).then((function(r){var n,o,i=t.get("file");r.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,r.data.url),r.data.fileId&&(n=r.data,o=u.id,a((function(e){var r=e.findIndex((function(e){return e.id===o}));if(-1!==r){var t=xe([],e,!0);return t[r]=ge(ge({},t[r]),{id:n.fileId}),t}return e})))})).catch((function(n){var l,c,d=t.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var p,m,f,h;409===(null===(l=n.response)||void 0===l?void 0:l.status)&&e.listFiles?(p=o.lastIndexOf("."),m=o.substring(0,p),f=o.substring(p),h=new RegExp("^".concat(m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(f,"$"),"i"),e.listFiles?e.listFiles().then((function(e){for(var r=0,t=0,n=e;t<n.length;t++){var a=n[t];if(h.test(a.name)){var o=a.name.match(h),i=o&&o[1]?parseInt(o[1].slice(1,-1),10):0;r=Math.max(r,i)}}return"".concat(m,"(").concat(r+1,")").concat(f)})):Promise.resolve(o)).then((function(n){e.onFileUpdate("add",n);var o=new File([r],n,{type:r.type});t.set("file",o),a((function(e){return e.map((function(e){return e.id===s?ge(ge({},e),{name:n,loadingProgress:0}):e}))})),i()})).catch((function(){var e;b(r.name,u.id,null===(e=n.response)||void 0===e?void 0:e.data)})):b(r.name,u.id,null===(c=n.response)||void 0===c?void 0:c.data)}))}))}()}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),l.length>0&&w(y,e.errorMessagesContainer),n.length>0&&w(j,e.filePreviewsContainer)]})};var ye=function(){return ye=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},ye.apply(this,arguments)},we=function(e,r,t){if(t||2===arguments.length)for(var n,a=0,o=r.length;a<o;a++)!n&&a in r||(n||(n=Array.prototype.slice.call(r,0,a)),n[a]=r[a]);return e.concat(n||Array.prototype.slice.call(r))};function Fe(e){var r=(0,u.useState)({uploaded:[],fileList:[]}),t=r[0],n=r[1],a=(0,u.useState)((0,d.v4)()),o=a[0],l=a[1],p=(0,u.useState)(),f=p[0],h=p[1],v=(0,u.useState)(),g=v[0],x=v[1],b=(0,u.useRef)(null),j=(0,s.useTheme)(),y=t.uploaded.length===t.fileList.length&&t.uploaded.length>0;return(0,u.useEffect)((function(){b.current&&(x(b.current.querySelector(".rustic-error-container")),h(b.current.querySelector(".rustic-input-extras")))})),(0,i.jsx)(c(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(j.palette.action.disabled),borderRadius:"".concat(j.shape.borderRadius,"px"),":focus-within":{borderColor:j.palette.secondary.main},background:j.palette.background.paper},children:(0,i.jsx)(U,ye({},e,{send:function(r){y&&(r.id=o,r.format="chatCompletionRequest",r.data=m(r.data.text,t.uploaded.map((function(e){return{url:e.url,name:e.name}})))),e.ws.send(r),l((0,d.v4)()),n({uploaded:[],fileList:[]})},isSendEnabled:y,ref:b,children:(0,i.jsx)(c(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(je,{acceptedFileTypes:e.acceptedFileTypes,maxFileCount:e.maxFileCount,maxFileSize:e.maxFileSize,uploadFileEndpoint:e.uploadFileEndpoint,deleteFileEndpoint:e.deleteFileEndpoint,onFileUpdate:function(e,r,t){if("add"===e)n((function(e){return ye(ye({},e),{fileList:we(we([],e.fileList,!0),[{name:r}],!1)})}));else if("update"===e){if(!t)return void console.error("URL is required for the 'update' action");n((function(e){var n=e.fileList.findIndex((function(e){return e.name===r})),a=we(we(we([],e.uploaded.slice(0,n),!0),[{name:r,url:t}],!1),e.uploaded.slice(n),!0);return ye(ye({},e),{uploaded:a})}))}else n((function(e){return{uploaded:e.uploaded.filter((function(e){return e.name!==r})),fileList:e.fileList.filter((function(e){return e.name!==r}))}}))},messageId:o,filePreviewsContainer:f,errorMessagesContainer:g,showFullName:e.showFullName,getUploadData:e.getUploadData,uploadOptions:e.uploadOptions,listFiles:e.listFiles,getUploadHeaders:e.getUploadHeaders})})}))})}Fe.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const Se=Fe;return o})()));
@@ -1 +1 @@
1
- {"version":3,"file":"multimodalInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/multimodalInput/multimodalInput.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAC9B,OAAO,uBAAuB,CAAA;AAQ9B,OAAO,KAAK,EAAqB,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAI7E;;;;;;;;;;;;;;;EAeE;AACF,iBAAwB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAoFlE;kBApFuB,eAAe;;;;;;;;;eAAf,eAAe"}
1
+ {"version":3,"file":"multimodalInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/multimodalInput/multimodalInput.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAC9B,OAAO,uBAAuB,CAAA;AAS9B,OAAO,KAAK,EAAqB,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAI7E;;;;;;;;;;;;;;;EAeE;AACF,iBAAwB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAgIlE;kBAhIuB,eAAe;;;;;;;;;eAAf,eAAe"}
@@ -37,6 +37,10 @@
37
37
  min-width: 220px;
38
38
  }
39
39
 
40
+ .rustic-file-preview-name {
41
+ margin-right: 8px;
42
+ }
43
+
40
44
  .rustic-file-preview-modal {
41
45
  width: 90vw;
42
46
  height: 90vh;
@@ -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={767:(e,r,n)=>{n.d(r,{A:()=>o});var t=n(732),a=(n(15),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})}},110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(767).A},15:e=>{e.exports=require("react")},732: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,{default:()=>te});var a=n(732);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(15);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 N=n.n(w);const F=require("@mui/material/styles");var C;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(C||(C={}));var P=n(767);const k=require("@mui/material/TextField");var O=n.n(k);const S=require("@mui/material/useMediaQuery");var q=n.n(S);const I=require("@mui/system/Stack");var D=n.n(I);const T=require("@mui/system/useTheme");var A=n.n(T);const M=require("pdfjs-dist"),U=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)(P.A,{name:n.symbol})})})})};var _={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],N=A()(),F=q()(N.breakpoints.down("sm")),C=q()(N.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 P=(0,x.useState)((function(){return F?.5:C?1:1.5})),k=P[0],S=P[1];return(0,x.useEffect)((function(){M.GlobalWorkerOptions.workerSrc||(M.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(M.version,"/pdf.worker.mjs")),M.getDocument({url:"".concat(e.url)}).promise.then((function(e){u(e.numPages),function(e){e.getPage(o).then((function(e){var r=e.getViewport({scale:k}),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)}))}),[e.url,o,k]),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)(U,{action:"zoomOut",onClick:function(){S((function(e){return Math.max(e-.2,.2)}))}}),(0,a.jsx)(U,{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)(D(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,a.jsx)(U,{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)(O(),{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)(U,{action:"nextPage",onClick:function(){o<s&&(l(o+1),p(o+1))},isDisabled:o===s})]})]})}};function R(e){var r=(0,F.useTheme)(),n=(0,x.useState)(!1),t=n[0],o=n[1];function i(){o(!1)}var l,s,u=e.file.url&&(l=e.file.url.split("."))[l.length-1].toLowerCase(),d=u&&e.supportedViewers?e.supportedViewers[u]:null,p=!!d,v=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",h=p?" rustic-cursor-pointer":"",g="rustic-file-preview ".concat(v).concat(h),b=e.showFullName?e.file.name:(15,(s=e.file.name).length<=15?s:s.substring(0,12)+"...");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y(),{className:g,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){o(!0)},children:[(0,a.jsx)(f(),{variant:"subtitle2",children:b}),(0,a.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,a.jsx)(N(),{open:t,onClose:i,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:i,className:"rustic-close-button",children:(0,a.jsx)(P.A,{name:"close"})})}),e.file.url&&(0,a.jsx)(d,{url:e.file.url})]})})]})}R.defaultProps={supportedViewers:_};var z=n(110);const B=require("@mui/material"),E=require("@mui/material/Button");var L=n.n(E);const H=require("@mui/material/Drawer");var V=n.n(H);const G=require("@mui/material/ListItemText");var $=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,F.useTheme)(),l=(0,B.useMediaQuery)(i.breakpoints.down("md")),s=l?V():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)($(),{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)(P.A,{name:"more_vert"}),e.buttonText?(0,a.jsx)(L(),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])}const te=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)();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)}(0,x.useEffect)((function(){o([]),d([]),y.current={}}),[e.messageId]);var F=(0,a.jsx)(i(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,n){return(0,a.jsx)(R,{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);h().delete(l).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 P(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)(z.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)(z.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 h().post(m,n,{onUploadProgress:d,signal:t.signal}).then((function(e){var r,n;e.data.fileId&&(r=e.data,n=u.id,o((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=re([],e,!0);return a[t]=ee(ee({},a[t]),{id:r.fileId}),a}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(".","\\."),"(\\(\\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&&P(C,e.errorMessagesContainer),t.length>0&&P(F,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,{default:()=>te});var a=n(8732);const o=require("@mui/material/Box");var i=n.n(o);const l=require("@mui/material/IconButton");var s=n.n(l);const c=require("@mui/material/LinearProgress");var u=n.n(c);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 C;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(C||(C={}));var P=n(9767);const k=require("@mui/material/TextField");var O=n.n(k);const S=require("@mui/material/useMediaQuery");var q=n.n(S);const I=require("@mui/system/Stack");var D=n.n(I);const T=require("@mui/system/useTheme");var A=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)(s(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,a.jsx)(P.A,{name:n.symbol})})})})};var _={pdf:function(e){var r,n=(0,x.useRef)(null),t=(0,x.useState)(1),o=t[0],l=t[1],s=(0,x.useState)(1),c=s[0],u=s[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=A()(),N=q()(F.breakpoints.down("sm")),C=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 P=(0,x.useState)((function(){return N?.5:C?1:1.5})),k=P[0],S=P[1];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")),U.getDocument({url:"".concat(e.url)}).promise.then((function(e){u(e.numPages),function(e){e.getPage(o).then((function(e){var r=e.getViewport({scale:k}),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)}))}),[e.url,o,k]),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)(D(),{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)(O(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=c&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,a.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",c]}),(0,a.jsx)(M,{action:"nextPage",onClick:function(){o<c&&(l(o+1),p(o+1))},isDisabled:o===c})]})]})}};function R(e){var r=(0,N.useTheme)(),n=(0,x.useState)(!1),t=n[0],o=n[1];function i(){o(!1)}var l,c,u=e.file.url&&(l=e.file.url.split("."))[l.length-1].toLowerCase(),d=u&&e.supportedViewers?e.supportedViewers[u]:null,p=!!d,v=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",h=p?" rustic-cursor-pointer":"",g="rustic-file-preview ".concat(v).concat(h),b=e.showFullName?e.file.name:(c=e.file.name).length<=15?c:c.substring(0,12)+"...";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y(),{className:g,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){o(!0)},children:[(0,a.jsx)(f(),{variant:"subtitle2",className:"rustic-file-preview-name",children:b}),(0,a.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,a.jsx)(F(),{open:t,onClose:i,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)(s(),{onClick:i,className:"rustic-close-button",children:(0,a.jsx)(P.A,{name:"close"})})}),e.file.url&&(0,a.jsx)(d,{url:e.file.url})]})})]})}R.defaultProps={supportedViewers:_,showFullName:!0};var z=n(3110);const B=require("@mui/material"),E=require("@mui/material/Button");var L=n.n(E);const H=require("@mui/material/Drawer");var $=n.n(H);const V=require("@mui/material/ListItemText");var G=n.n(V);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,B.useMediaQuery)(i.breakpoints.down("md")),c=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)(G(),{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)(P.A,{name:"more_vert"}),e.buttonText?(0,a.jsx)(L(),K({},v,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,a.jsx)(m(),{title:e.ariaLabel,children:(0,a.jsx)(s(),K({},v,{children:e.icon?e.icon:h}))})),(0,a.jsx)(c,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])}const te=function(e){var r,n=(0,x.useState)([]),t=n[0],o=n[1],l=(0,x.useState)([]),c=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 C=(0,a.jsx)(i(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,n){return(0,a.jsx)(R,{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)(s(),{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)}))}),P=(0,a.jsx)(i(),{children:c.map((function(e,r){return(0,a.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function k(e,r){return r?(0,g.createPortal)(e,r):e}var O=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)(z.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==O?void 0:O.length)?(0,a.jsx)(X,{ariaLabel:"Upload",icon:(0,a.jsx)(z.default,{name:"upload_2"}),menuItems:O}):(0,a.jsx)(m(),{title:"Upload",children:(0,a.jsx)(s(),{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),s=t.substring(i);t="".concat(l,"(").concat(a,")").concat(s),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):{},s=ee(ee({},l),v);Object.keys(s).forEach((function(e){var r=s[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)}))}n.append("file",i);var c=(0,b.v4)(),u={name:a,loadingProgress:0,abortController:t,id:c};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,s,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===c?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===(s=t.response)||void 0===s?void 0:s.data)}))}))}()}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),c.length>0&&k(P,e.errorMessagesContainer),t.length>0&&k(C,e.filePreviewsContainer)]})};return t})()));
@@ -1 +1 @@
1
- {"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/uploader/uploader.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AAgBvB,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,gBAAgB,CAAA;AAWjE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,EAAE,EACb,cAAc,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,EAAE,GAAG,SAAS,CAUpB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYvD;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAgbrC;AACD,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/uploader/uploader.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AAgBvB,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,gBAAgB,CAAA;AAWjE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,EAAE,EACb,cAAc,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,EAAE,GAAG,SAAS,CAUpB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYvD;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAicrC;AACD,eAAe,QAAQ,CAAA"}
@@ -24,7 +24,7 @@
24
24
  }
25
25
 
26
26
  .rustic-base-input .rustic-input-label {
27
- padding-top: 8px;
27
+ padding-top: 10px;
28
28
  }
29
29
 
30
30
  .rustic-base-input .rustic-text-field .MuiOutlinedInput-input {
@@ -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,r,t={342:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);o.r(i);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&n&&t;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,o.d(i,a),i},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),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,{default:()=>F});const a=require("react/jsx-runtime"),c=require("react"),s=require("@mui/material/Box");var u=o.n(s);const l=require("@mui/material/CircularProgress");var d=o.n(l);const p=require("@mui/material/IconButton");var m=o.n(p);const f=require("@mui/material/InputAdornment");var h=o.n(f);const v=require("@mui/material/MenuItem");var y=o.n(v);const g=require("@mui/material/MenuList");var b=o.n(g);const j=require("@mui/material/Popover");var x=o.n(j);const S=require("@mui/material/TextField");var w=o.n(S);const O=require("@mui/material/Tooltip");var k=o.n(O);const E=require("@mui/material/Typography");var P=o.n(E),C=o(342);const N=require("uuid");var q=function(){return q=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},q.apply(this,arguments)};function T(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,a.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:q({},r),children:e.name})}const _=require("@mui/material/styles"),R=function(e){var r=(0,_.useTheme)(),t=(0,c.useRef)(null),n=(0,c.useRef)(null),i=(0,c.useState)(!1),s=i[0],u=i[1],l={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function d(){u(!1)}function p(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),d()}return(0,c.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,342,23)).then((function(t){var o=new(0,t.Picker)({dataSource:e.dataSource}),i="dark"===r.palette.mode?"dark":"light";o.classList.add(i),Object.keys(l).forEach((function(e){o.style.setProperty(e,l[e])})),n.current=o})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,c.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",p),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[s,e.onEmojiClick]),(0,a.jsxs)("div",{children:[(0,a.jsx)(k(),{title:"Emoji",children:(0,a.jsx)(m(),{size:"small",ref:t,onClick:function(){u((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(T,{name:"Mood"})})}),n.current&&(0,a.jsx)(x(),{open:s,anchorEl:t.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&&n.current&&!e.contains(n.current)&&e.appendChild(n.current)}})})]})};var I={"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)}var M=(0,c.forwardRef)((function(e,r){var t=(0,c.useState)(""),n=t[0],o=t[1],i=(0,c.useState)(!1),s=i[0],l=i[1],p=(0,c.useState)(!1),f=p[0],v=p[1],g=(0,c.useState)(!1),j=g[0],S=g[1],O=(0,c.useState)(""),E=O[0],q=O[1],_=(0,c.useState)([]),M=_[0],D=_[1],B=(0,c.useState)(!1),F=B[0],L=B[1],A=(0,c.useRef)(null),W=new C.Database({dataSource:e.emojiDataSource}),K=!n.trim().length&&!e.isSendEnabled,$="".concat(s?"Stop":"Start"," speech to text"),Q=f?"primary.main":"primary.light",G=s?"error.main":Q,H=s?"stop_circle":"speech_to_text";function J(e,r){if(void 0===r&&(r=!1),A.current){var t=A.current,i=t.selectionStart,a=t.selectionEnd;if("number"==typeof i&&"number"==typeof a){var c,s=n||"",u=s.substring(0,i),l=s.substring(a);c=r?u.replace(/:(\w+)$/,e)+l:u+e+l,o(c);var d=r?u.replace(/:(\w+)$/,e).length:i+e.length;setTimeout((function(){var e,r;null===(e=A.current)||void 0===e||e.focus(),null===(r=A.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}L(!1)}var U=j?(0,a.jsx)(d(),{size:24}):(0,a.jsx)(k(),{title:$,children:(0,a.jsx)(m(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,s?(e.stop(),S(!0),l(!1)):(e.start(),q(""),l(!0)),e.onstart=function(){l(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;n.length>0?o(n+" "+t):o(t),null===(r=A.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=I[e.error];q(r),l(!1)},e.onend=function(){S(!1),l(!1)}},size:"small",sx:{color:G,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(T,{name:H})})});function V(){var r=(new Date).toISOString(),t={id:(0,N.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:n}};e.send(t),o(""),q("")}return(0,a.jsxs)(u(),{className:"rustic-base-input",ref:r,children:[(0,a.jsxs)(u(),{className:"rustic-error-and-input-container",children:[(0,a.jsx)(u(),{className:"rustic-error-container",children:(0,a.jsx)(P(),{variant:"caption",color:"error",className:"rustic-error-message",children:E})}),(0,a.jsxs)(u(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[M.length>0&&(0,a.jsx)(x(),{open:F,anchorEl:A.current,onClose:function(){return L(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,a.jsx)(b(),{children:M.map((function(e,r){return"unicode"in e&&(0,a.jsx)(y(),{onClick:function(){return J(e.unicode,!0)},children:z(e)},r)}))})}),(0,a.jsx)(w(),{className:"rustic-text-field",variant:"outlined",value:n,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!K&&V())},onChange:function(r){q("");var t=r.target.value;o(t);var n,i=t.match(/:(\w{2,}):/g),a=t.match(/:(\w{2,})/g);if(i){var c=i[0].replace(/:/g,"");W.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=t.replace(i[0],e.unicode);o(r)}else o(t)})).catch((function(){o(t)})),L(!1)}else a?(n=a[0].replace(":",""),W.getEmojiBySearchQuery(n).then((function(r){r.length?(D(r.slice(0,e.maximumEmojiSearchResults)),L(!0)):(D([]),L(!1))})).catch((function(){D([]),L(!1)}))):L(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:A,color:"secondary",size:"small",InputProps:{endAdornment:(0,a.jsxs)(h(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(R,{dataSource:e.emojiDataSource,onEmojiClick:J,buttonColor:Q}),e.enableSpeechToText&&U]})},InputLabelProps:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,a.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,a.jsxs)(u(),{className:"rustic-input-actions",children:[e.children,(0,a.jsx)(k(),{title:"Send",children:(0,a.jsx)("span",{className:"rustic-send-button",children:(0,a.jsx)(m(),{"aria-label":"send message",onClick:V,disabled:K,color:"secondary",children:(0,a.jsx)(T,{name:"send"})})})})]})]})}));M.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const D=M;var B=function(){return B=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},B.apply(this,arguments)};const F=function(e){var r=e.ws,t=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(e,["ws"]);return(0,a.jsx)(D,B({},t,{send:function(e){r.send(e)}}))};return i})()));
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,r,t={8342:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);o.r(i);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&n&&t;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,o.d(i,a),i},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),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,{default:()=>L});const a=require("react/jsx-runtime"),c=require("react"),s=require("@mui/material/Box");var u=o.n(s);const l=require("@mui/material/CircularProgress");var d=o.n(l);const p=require("@mui/material/IconButton");var m=o.n(p);const f=require("@mui/material/InputAdornment");var h=o.n(f);const v=require("@mui/material/MenuItem");var g=o.n(v);const y=require("@mui/material/MenuList");var b=o.n(y);const j=require("@mui/material/Popover");var x=o.n(j);const O=require("@mui/material/TextField");var S=o.n(O);const w=require("@mui/material/Tooltip");var k=o.n(w);const E=require("@mui/material/Typography");var C=o.n(E),P=o(8342);const N=require("uuid");var T;function _(e,r){var t=[];if(e&&(null==e?void 0:e.trim().length)&&t.push({type:"text",text:e}),r&&r.length>0)for(var n=0;n<(null==r?void 0:r.length);n++)t.push({type:"file_url",file_url:{url:r[n].url,name:r[n].name}});return{messages:[{content:t,role:"user"}]}}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(T||(T={}));var q=function(){return q=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},q.apply(this,arguments)};function R(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,a.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:q({},r),children:e.name})}const M=require("@mui/material/styles"),z=function(e){var r=(0,M.useTheme)(),t=(0,c.useRef)(null),n=(0,c.useRef)(null),i=(0,c.useState)(!1),s=i[0],u=i[1],l={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function d(){u(!1)}function p(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),d()}return(0,c.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then((function(t){var o=new(0,t.Picker)({dataSource:e.dataSource}),i="dark"===r.palette.mode?"dark":"light";o.classList.add(i),Object.keys(l).forEach((function(e){o.style.setProperty(e,l[e])})),n.current=o})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,c.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",p),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[s,e.onEmojiClick]),(0,a.jsxs)("div",{children:[(0,a.jsx)(k(),{title:"Emoji",children:(0,a.jsx)(m(),{size:"small",ref:t,onClick:function(){u((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(R,{name:"Mood"})})}),n.current&&(0,a.jsx)(x(),{open:s,anchorEl:t.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&&n.current&&!e.contains(n.current)&&e.appendChild(n.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 I(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var A=(0,c.forwardRef)((function(e,r){var t=(0,c.useState)(""),n=t[0],o=t[1],i=(0,c.useState)(!1),s=i[0],l=i[1],p=(0,c.useState)(!1),f=p[0],v=p[1],y=(0,c.useState)(!1),j=y[0],O=y[1],w=(0,c.useState)(""),E=w[0],T=w[1],q=(0,c.useState)([]),M=q[0],A=q[1],B=(0,c.useState)(!1),F=B[0],L=B[1],H=(0,c.useRef)(null),W=new P.Database({dataSource:e.emojiDataSource}),K=!n.trim().length&&!e.isSendEnabled,U="".concat(s?"Stop":"Start"," speech to text"),$=f?"primary.main":"primary.light",Q=s?"error.main":$,G=s?"stop_circle":"speech_to_text";function J(e,r){if(void 0===r&&(r=!1),H.current){var t=H.current,i=t.selectionStart,a=t.selectionEnd;if("number"==typeof i&&"number"==typeof a){var c,s=n||"",u=s.substring(0,i),l=s.substring(a);c=r?u.replace(/:(\w+)$/,e)+l:u+e+l,o(c);var d=r?u.replace(/:(\w+)$/,e).length:i+e.length;setTimeout((function(){var e,r;null===(e=H.current)||void 0===e||e.focus(),null===(r=H.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}L(!1)}var V=j?(0,a.jsx)(d(),{size:24}):(0,a.jsx)(k(),{title:U,children:(0,a.jsx)(m(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,s?(e.stop(),O(!0),l(!1)):(e.start(),T(""),l(!0)),e.onstart=function(){l(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;n.length>0?o(n+" "+t):o(t),null===(r=H.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=D[e.error];T(r),l(!1)},e.onend=function(){O(!1),l(!1)}},size:"small",sx:{color:Q,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(R,{name:G})})});function X(){var r=(new Date).toISOString(),t={id:(0,N.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"chatCompletionRequest",data:_(n)};e.send(t),o(""),T("")}return(0,a.jsxs)(u(),{className:"rustic-base-input",ref:r,children:[(0,a.jsxs)(u(),{className:"rustic-error-and-input-container",children:[(0,a.jsx)(u(),{className:"rustic-error-container",children:(0,a.jsx)(C(),{variant:"caption",color:"error",className:"rustic-error-message",children:E})}),(0,a.jsxs)(u(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[M.length>0&&(0,a.jsx)(x(),{open:F,anchorEl:H.current,onClose:function(){return L(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,a.jsx)(b(),{children:M.map((function(e,r){return"unicode"in e&&(0,a.jsx)(g(),{onClick:function(){return J(e.unicode,!0)},children:I(e)},r)}))})}),(0,a.jsx)(S(),{className:"rustic-text-field",variant:"outlined",value:n,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),K||X())},onChange:function(r){T("");var t=r.target.value;o(t);var n,i=t.match(/:(\w{2,}):/g),a=t.match(/:(\w{2,})/g);if(i){var c=i[0].replace(/:/g,"");W.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=t.replace(i[0],e.unicode);o(r)}else o(t)})).catch((function(){o(t)})),L(!1)}else a?(n=a[0].replace(":",""),W.getEmojiBySearchQuery(n).then((function(r){r.length?(A(r.slice(0,e.maximumEmojiSearchResults)),L(!0)):(A([]),L(!1))})).catch((function(){A([]),L(!1)}))):L(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:H,color:"secondary",size:"small",slotProps:{input:{endAdornment:(0,a.jsxs)(h(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(z,{dataSource:e.emojiDataSource,onEmojiClick:J,buttonColor:$}),e.enableSpeechToText&&V]})},inputLabel:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,a.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,a.jsxs)(u(),{className:"rustic-input-actions",children:[e.children,(0,a.jsx)(k(),{title:"Send",children:(0,a.jsx)("span",{className:"rustic-send-button",children:(0,a.jsx)(m(),{"aria-label":"send message",onClick:X,disabled:K,color:"secondary",children:(0,a.jsx)(R,{name:"send"})})})})]})]})}));A.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const B=A;var F=function(){return F=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},F.apply(this,arguments)};const L=function(e){var r=e.ws,t=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(e,["ws"]);return(0,a.jsx)(B,F({},t,{send:function(e){r.send(e)}}))};return i})()));
@@ -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={445:(e,t,o)=>{o.d(t,{default:()=>l});var r=o(732),n=o(909),a=o.n(n),i=o(603),c=o.n(i);o(15);const l=function(e){return(0,r.jsx)(c(),{title:e.label,children:(0,r.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},603:e=>{e.exports=require("@mui/material/Tooltip")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},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 r={};o.r(r),o.d(r,{default:()=>s});var n=o(732),a=o(15),i=function(){return i=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};function c(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:i({},t),children:e.name})}var l=o(445);const s=function(e){var t=(0,a.useState)("Copy text"),o=t[0],r=t[1];return(0,n.jsx)(l.default,{message:e.message,icon:(0,n.jsx)(c,{name:"file_copy"}),onClick:function(e){e.data.text&&navigator.clipboard.writeText(e.data.text).then((function(){r("Copied"),setTimeout((function(){r("Copy text")}),2e3)})).catch((function(){r("Failed to copy")}))},label:o})};return r})()));
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={4445:(e,t,o)=>{o.d(t,{default:()=>l});var r=o(8732),n=o(909),a=o.n(n),i=o(4603),c=o.n(i);o(2015);const l=function(e){return(0,r.jsx)(c(),{title:e.label,children:(0,r.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},4603:e=>{e.exports=require("@mui/material/Tooltip")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},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 r={};o.r(r),o.d(r,{default:()=>s});var n=o(8732),a=o(2015),i=function(){return i=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};function c(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:i({},t),children:e.name})}var l=o(4445);const s=function(e){var t=(0,a.useState)("Copy text"),o=t[0],r=t[1];return(0,n.jsx)(l.default,{message:e.message,icon:(0,n.jsx)(c,{name:"file_copy"}),onClick:function(e){e.data.text&&navigator.clipboard.writeText(e.data.text).then((function(){r("Copied"),setTimeout((function(){r("Copy text")}),2e3)})).catch((function(){r("Failed to copy")}))},label:o})};return r})()));
@@ -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={909:e=>{e.exports=require("@mui/material/IconButton")},603:e=>{e.exports=require("@mui/material/Tooltip")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,r),i.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 o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},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 o={};r.r(o),r.d(o,{default:()=>s});var n=r(732),i=r(909),a=r.n(i),u=r(603),l=r.n(u);r(15);const s=function(e){return(0,n.jsx)(l(),{title:e.label,children:(0,n.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})};return o})()));
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={909:e=>{e.exports=require("@mui/material/IconButton")},4603:e=>{e.exports=require("@mui/material/Tooltip")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,r),i.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 o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},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 o={};r.r(o),r.d(o,{default:()=>s});var n=r(8732),i=r(909),a=r.n(i),u=r(4603),l=r.n(u);r(2015);const s=function(e){return(0,n.jsx)(l(),{title:e.label,children:(0,n.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})};return o})()));
@@ -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={445:(e,t,r)=>{r.d(t,{default:()=>l});var a=r(732),o=r(909),n=r.n(o),s=r(603),i=r.n(s);r(15);const l=function(e){return(0,a.jsx)(i(),{title:e.label,children:(0,a.jsx)(n(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},603:e=>{e.exports=require("@mui/material/Tooltip")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function r(a){var o=t[a];if(void 0!==o)return o.exports;var n=t[a]={exports:{}};return e[a](n,n.exports,r),n.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 a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},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 a={};r.r(a),r.d(a,{default:()=>c});var o=r(732),n=r(15),s=function(){return s=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function i(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:s({},t),children:e.name})}var l=r(445);const c=function(e){var t=(0,n.useState)("Start reading aloud"),r=t[0],a=t[1],s=[e.message.data.title,e.message.data.description,e.message.data.alt,e.message.data.text,e.message.data.transcript].filter(Boolean).join(" "),c=new SpeechSynthesisUtterance(s);return(0,o.jsx)(l.default,{message:e.message,icon:(0,o.jsx)(i,{name:"text_to_speech"}),onClick:function(){window.speechSynthesis.speaking?(window.speechSynthesis.cancel(),a("Start reading aloud")):(c.onend=function(){a("Start reading aloud")},window.speechSynthesis.speak(c),a("Stop reading aloud"))},label:r})};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={4445:(e,t,r)=>{r.d(t,{default:()=>l});var a=r(8732),o=r(909),n=r.n(o),s=r(4603),i=r.n(s);r(2015);const l=function(e){return(0,a.jsx)(i(),{title:e.label,children:(0,a.jsx)(n(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},4603:e=>{e.exports=require("@mui/material/Tooltip")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},t={};function r(a){var o=t[a];if(void 0!==o)return o.exports;var n=t[a]={exports:{}};return e[a](n,n.exports,r),n.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 a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},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 a={};r.r(a),r.d(a,{default:()=>c});var o=r(8732),n=r(2015),s=function(){return s=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function i(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:s({},t),children:e.name})}var l=r(4445);const c=function(e){var t=(0,n.useState)("Start reading aloud"),r=t[0],a=t[1],s=[e.message.data.title,e.message.data.description,e.message.data.alt,e.message.data.text,e.message.data.transcript].filter(Boolean).join(" "),c=new SpeechSynthesisUtterance(s);return(0,o.jsx)(l.default,{message:e.message,icon:(0,o.jsx)(i,{name:"text_to_speech"}),onClick:function(){window.speechSynthesis.speaking?(window.speechSynthesis.cancel(),a("Start reading aloud")):(c.onend=function(){a("Start reading aloud")},window.speechSynthesis.speak(c),a("Stop reading aloud"))},label:r})};return a})()));
@@ -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 n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},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:()=>S});const n=require("react/jsx-runtime"),r=require("@mui/material/Chip");var s=e.n(r);const o=require("@mui/system/Box");var a=e.n(o);const i=require("react");var c=e.n(i);const u=require("@mui/material/Typography");var l=e.n(u),d=function(){return d=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},d.apply(this,arguments)};const m=function(e){var t=e.messages[0],r=e.messages.slice(1),s=e.supportedElements[t.format];return(0,n.jsx)(n.Fragment,{children:s?c().createElement(s,d(d({sender:e.sender,ws:e.ws,messageId:t.id,conversationId:t.conversationId},t.data),r.length>0&&{updatedData:r.map((function(e){return e.data}))})):(0,n.jsxs)(l(),{variant:"body2",children:["Unsupported element format: ",t.format]})})};var f=function(){return f=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},f.apply(this,arguments)};function p(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:f({},t),children:e.name})}const v=require("@mui/material"),g=require("@mui/material/Card");var y=e.n(g);const h=require("@mui/material/Stack");var j,b=e.n(h);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(j||(j={}));const w=function(e){return(0,n.jsx)(l(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(t=e.timestamp,r=new Date(t),s=navigator.language,o={month:"short",day:"numeric"},a=new Date,i=r.getFullYear()!==a.getFullYear(),c=i?" at ":", ",i&&(o.year="numeric"),r.toLocaleDateString(s,o)+c+r.toLocaleTimeString(s,{hour:"numeric",minute:"2-digit",hour12:!0}))});var t,r,s,o,a,i,c},x=(0,i.forwardRef)((function(e,t){var r=(0,v.useTheme)(),s=e.inReplyTo?e.inReplyTo:e.message;return(0,n.jsxs)(b(),{id:s.id,className:"rustic-message-canvas",ref:t,children:[(0,n.jsxs)(b(),{direction:"row",alignItems:"center",spacing:1,className:"rustic-header",children:[e.getProfileComponent&&e.getProfileComponent(s),(0,n.jsx)(w,{timestamp:s.timestamp})]}),e.getActionsComponent&&e.getActionsComponent(e.message)&&(0,n.jsx)(y(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:r.shadows[1]},children:e.getActionsComponent(s)}),(0,n.jsxs)(y(),{variant:"outlined",className:"rustic-message-container",children:[e.children,e.inReplyTo&&(0,n.jsxs)(l(),{variant:"caption",color:"text.secondary",className:"rustic-footer",children:["Submitted by ",e.message.sender.name," at ",(0,n.jsx)(w,{timestamp:e.message.timestamp})]})]})]})}));var O=function(){return O=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},O.apply(this,arguments)},E=function(e,t,n){if(n||2===arguments.length)for(var r,s=0,o=t.length;s<o;s++)!r&&s in t||(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))};function R(e,t){var n;if(!(n=t.format.includes("update")?t.threadId:t.format.includes("Response")?t.inReplyTo:t.id))return e;var r=O({},e),s=(r[n]||[])[0];return t.format.includes("update")&&s&&s.sender.id!==t.sender.id&&(n=t.id),r[n]||(r[n]=[]),t.format.includes("Response")&&s?r[n]=[O(O({},s),{data:O(O({},s.data),t.data)}),t]:r[n]=E(E([],r[n],!0),[t],!1),r}function T(e){var t,r,o,c=(0,i.useRef)(null),u=(0,i.useRef)(null),l=(0,i.useRef)(),d=(0,i.useState)(!0),f=d[0],v=d[1],g=(0,i.useState)(!0),y=g[0],h=g[1],j=(0,i.useState)(!1),b=j[0],w=j[1],E=(0,i.useState)({}),T=E[0],S=E[1],C=Object.keys(T).length,N=(r=C,o=(0,i.useRef)(0),(0,i.useEffect)((function(){o.current=r})),o.current),A=2e3;function P(){h(!0),l.current&&clearTimeout(l.current),l.current=setTimeout((function(){h(!1)}),A)}function q(){var e=u.current,t=c.current;if(e&&t){var n=e.getBoundingClientRect().bottom,r=t.getBoundingClientRect().bottom;v(r-1<=n)}}function D(){if(function(){var e,t=null===(e=u.current)||void 0===e?void 0:e.querySelectorAll("video");return!t||0===t.length||Array.from(t).every((function(e){return e.readyState>=1}))}()){var e=u.current;w(!0),e&&setTimeout((function(){P(),e.scrollTop=e.scrollHeight}),0)}else setTimeout(D,1)}function L(e){S((function(t){return R(t,e)}))}return(0,i.useEffect)((function(){var e=u.current;if(q(),e)return e.addEventListener("scroll",q),window.addEventListener("resize",q),function(){e.removeEventListener("scroll",q),window.removeEventListener("resize",q)}}),[f]),(0,i.useEffect)((function(){D()}),[b]),(0,i.useEffect)((function(){f&&0!==N&&C>N&&(P(),D())}),[f,Object.keys(T).length]),(0,i.useEffect)((function(){var t,n={};null===(t=e.receivedMessages)||void 0===t||t.forEach((function(e){var t=R(n,e);n=t})),S(n)}),[null===(t=e.receivedMessages)||void 0===t?void 0:t.length]),(0,i.useEffect)((function(){e.ws.onReceive&&e.ws.onReceive(L)}),[]),(0,n.jsxs)(a(),{className:"rustic-message-space",children:[(0,n.jsxs)(a(),{ref:u,className:"rustic-message-container",children:[Object.keys(T).map((function(t,r){var s,o=T[t],a=o[o.length-1],i=a.format.includes("Response"),u=i&&{inReplyTo:o[0]};return"prompts"!==a.format?(0,n.jsx)(x,O({message:a},u,{getActionsComponent:e.getActionsComponent,getProfileComponent:e.getProfileComponent,ref:r===C-1?c:null,children:(0,n.jsx)(m,{ws:e.ws,sender:e.sender,messages:i?[o[0]]:o,supportedElements:e.supportedElements})}),t):"inConversation"===(null===(s=a.data)||void 0===s?void 0:s.position)?(0,n.jsx)("div",{ref:r===C-1?c:null,children:(0,n.jsx)(m,{ws:e.ws,sender:e.sender,messages:i?[o[0]]:o,supportedElements:e.supportedElements})},t):void 0})),!f&&!y&&(0,n.jsx)(s(),{variant:"rusticSecondary",className:"rustic-scroll-down-button",size:"medium",onClick:D,label:(0,n.jsxs)(n.Fragment,{children:[e.scrollDownLabel,(0,n.jsx)(p,{name:"arrow_downward"})]})})]}),function(t){var r,s=Object.values(t).flat(),o=s[s.length-1];return"prompts"===(null==o?void 0:o.format)&&"inConversation"!==(null===(r=null==o?void 0:o.data)||void 0===r?void 0:r.position)?(0,n.jsx)(m,{ws:e.ws,sender:e.sender,messages:[o],supportedElements:e.supportedElements}):null}(T)]})}T.defaultProps={scrollDownLabel:"Scroll down"};const S=T;return t})()));
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 n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},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:()=>S});const n=require("react/jsx-runtime"),r=require("@mui/material/Chip");var o=e.n(r);const s=require("@mui/system/Box");var a=e.n(s);const i=require("react");var c=e.n(i);const l=require("@mui/material/Typography");var u=e.n(l),d=function(){return d=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},d.apply(this,arguments)};const m=function(e){var t=e.messages[0],r=e.messages.slice(1),o=e.supportedElements[t.format];return(0,n.jsx)(n.Fragment,{children:o?c().createElement(o,d(d({sender:e.sender,ws:e.ws,messageId:t.id,conversationId:t.conversationId},t.data),r.length>0&&{updatedData:r.map((function(e){return e.data}))})):(0,n.jsxs)(u(),{variant:"body2",children:["Unsupported element format: ",t.format]})})};var f=function(){return f=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},f.apply(this,arguments)};function p(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:f({},t),children:e.name})}const v=require("@mui/material"),g=require("@mui/material/Card");var y=e.n(g);const h=require("@mui/material/Stack");var j,b=e.n(h);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(j||(j={}));const w=function(e){return(0,n.jsx)(u(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(t=e.timestamp,r=new Date(t),o=navigator.language,s={month:"short",day:"numeric"},a=new Date,i=r.getFullYear()!==a.getFullYear(),c=i?" at ":", ",i&&(s.year="numeric"),r.toLocaleDateString(o,s)+c+r.toLocaleTimeString(o,{hour:"numeric",minute:"2-digit",hour12:!0}))});var t,r,o,s,a,i,c},x=(0,i.forwardRef)((function(e,t){var r=(0,v.useTheme)(),o=e.inReplyTo?e.inReplyTo:e.message;return(0,n.jsxs)(b(),{id:o.id,className:"rustic-message-canvas",ref:t,children:[(0,n.jsxs)(b(),{direction:"row",alignItems:"center",spacing:1,className:"rustic-header",children:[e.getProfileComponent&&e.getProfileComponent(o),(0,n.jsx)(w,{timestamp:o.timestamp})]}),e.getActionsComponent&&e.getActionsComponent(e.message)&&(0,n.jsx)(y(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:r.shadows[1]},children:e.getActionsComponent(o)}),(0,n.jsxs)(y(),{variant:"outlined",className:"rustic-message-container",children:[e.children,e.inReplyTo&&(0,n.jsxs)(u(),{variant:"caption",color:"text.secondary",className:"rustic-footer",children:["Submitted by ",e.message.sender.name," at ",(0,n.jsx)(w,{timestamp:e.message.timestamp})]})]})]})}));var O=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)},E=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;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 R(e,t){var n;if(!(n=t.format.includes("update")?t.threadId:t.format.includes("Response")?t.inReplyTo:t.id))return e;var r=O({},e),o=(r[n]||[])[0];return t.format.includes("update")&&o&&o.sender.id!==t.sender.id&&(n=t.id),r[n]||(r[n]=[]),t.format.includes("Response")&&o?r[n]=[O(O({},o),{data:O(O({},o.data),t.data)}),t]:r[n]=E(E([],r[n],!0),[t],!1),r}function T(e){var t,r,s,c=(0,i.useRef)(null),l=(0,i.useRef)(null),u=(0,i.useRef)(),d=(0,i.useState)(!0),f=d[0],v=d[1],g=(0,i.useState)(!0),y=g[0],h=g[1],j=(0,i.useState)(!1),b=j[0],w=j[1],E=(0,i.useState)({}),T=E[0],S=E[1],C=Object.keys(T).length,N=(r=C,s=(0,i.useRef)(0),(0,i.useEffect)((function(){s.current=r})),s.current);function A(){h(!0),u.current&&clearTimeout(u.current),u.current=setTimeout((function(){h(!1)}),2e3)}function P(){var e=l.current,t=c.current;if(e&&t){var n=e.getBoundingClientRect().bottom,r=t.getBoundingClientRect().bottom;v(r-1<=n)}}function q(){if(function(){var e,t=null===(e=l.current)||void 0===e?void 0:e.querySelectorAll("video");return!t||0===t.length||Array.from(t).every((function(e){return e.readyState>=1}))}()){var e=l.current;w(!0),e&&setTimeout((function(){A(),e.scrollTop=e.scrollHeight}),0)}else setTimeout(q,1)}function D(e){S((function(t){return R(t,e)}))}return(0,i.useEffect)((function(){var e=l.current;if(P(),e)return e.addEventListener("scroll",P),window.addEventListener("resize",P),function(){e.removeEventListener("scroll",P),window.removeEventListener("resize",P)}}),[f]),(0,i.useEffect)((function(){q()}),[b]),(0,i.useEffect)((function(){f&&0!==N&&C>N&&(A(),q())}),[f,Object.keys(T).length]),(0,i.useEffect)((function(){var t,n={};null===(t=e.receivedMessages)||void 0===t||t.forEach((function(e){var t=R(n,e);n=t})),S(n)}),[null===(t=e.receivedMessages)||void 0===t?void 0:t.length]),(0,i.useEffect)((function(){e.ws.onReceive&&e.ws.onReceive(D)}),[]),(0,n.jsxs)(a(),{className:"rustic-message-space",children:[(0,n.jsxs)(a(),{ref:l,className:"rustic-message-container",children:[Object.keys(T).map((function(t,r){var o,s=T[t],a=s[s.length-1],i=a.format.includes("Response"),l=i&&{inReplyTo:s[0]};return"prompts"!==a.format?(0,n.jsx)(x,O({message:a},l,{getActionsComponent:e.getActionsComponent,getProfileComponent:e.getProfileComponent,ref:r===C-1?c:null,children:(0,n.jsx)(m,{ws:e.ws,sender:e.sender,messages:i?[s[0]]:s,supportedElements:e.supportedElements})}),t):"inConversation"===(null===(o=a.data)||void 0===o?void 0:o.position)?(0,n.jsx)("div",{ref:r===C-1?c:null,children:(0,n.jsx)(m,{ws:e.ws,sender:e.sender,messages:i?[s[0]]:s,supportedElements:e.supportedElements})},t):void 0})),!f&&!y&&(0,n.jsx)(o(),{color:"secondary",className:"rustic-scroll-down-button",size:"medium",onClick:q,label:(0,n.jsxs)(n.Fragment,{children:[e.scrollDownLabel,(0,n.jsx)(p,{name:"arrow_downward"})]})})]}),function(t){var r,o=Object.values(t).flat(),s=o[o.length-1];return"prompts"===(null==s?void 0:s.format)&&"inConversation"!==(null===(r=null==s?void 0:s.data)||void 0===r?void 0:r.position)?(0,n.jsx)(m,{ws:e.ws,sender:e.sender,messages:[s],supportedElements:e.supportedElements}):null}(T)]})}T.defaultProps={scrollDownLabel:"Scroll down"};const S=T;return t})()));
@@ -0,0 +1,11 @@
1
+ import '../../../index.css';
2
+ import '../multipart/multipart.css';
3
+ import type { ChatCompletionProps } from '../../types';
4
+ /**
5
+ * The `ChatCompletion` component provides a flexible message interface
6
+ * that supports both textual content and file attachments within a single message.
7
+ * Its data structure closely mirrors OpenAI's [ChatCompletionRequest](https://platform.openai.com/docs/api-reference/chat),
8
+ * eliminating the need for data conversion to the Chat Completion format.
9
+ */
10
+ export default function ChatCompletion(props: ChatCompletionProps): import("react/jsx-runtime").JSX.Element;
11
+ //# sourceMappingURL=chatCompletion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatCompletion.d.ts","sourceRoot":"","sources":["../../../../src/components/multipart/chatCompletion/chatCompletion.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,4BAA4B,CAAA;AAUnC,OAAO,KAAK,EAAE,mBAAmB,EAAW,MAAM,aAAa,CAAA;AAS/D;;;;;GAKG;AAEH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CAwDhE"}