@rustic-ai/ui-components 0.0.20 → 0.0.22

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 (62) hide show
  1. package/dist/components/calendar/fCCalendar.d.ts.map +1 -1
  2. package/dist/components/calendar/index.css +24 -10
  3. package/dist/components/calendar/index.js +1 -1
  4. package/dist/components/codeSnippet/index.js +1 -1
  5. package/dist/components/elementRenderer/elementRenderer.d.ts +2 -2
  6. package/dist/components/elementRenderer/elementRenderer.d.ts.map +1 -1
  7. package/dist/components/elementRenderer/index.js +1 -1
  8. package/dist/components/helper.d.ts +0 -2
  9. package/dist/components/helper.d.ts.map +1 -1
  10. package/dist/components/image/index.js +1 -1
  11. package/dist/components/input/multimodal/multimodalInput/index.css +4 -0
  12. package/dist/components/input/multimodal/multimodalInput/index.js +1 -1
  13. package/dist/components/input/multimodal/uploader/index.js +1 -1
  14. package/dist/components/input/textInput/index.css +4 -0
  15. package/dist/components/input/textInput/index.js +1 -1
  16. package/dist/components/map/index.js +1 -1
  17. package/dist/components/markdown/index.js +1 -1
  18. package/dist/components/media/audio/index.js +1 -1
  19. package/dist/components/media/video/index.js +1 -1
  20. package/dist/components/messageCanvas/actions/action.d.ts +3 -3
  21. package/dist/components/messageCanvas/actions/action.d.ts.map +1 -1
  22. package/dist/components/messageCanvas/actions/copy/copyText.d.ts +2 -2
  23. package/dist/components/messageCanvas/actions/copy/copyText.d.ts.map +1 -1
  24. package/dist/components/messageCanvas/actions/copy/index.js +1 -1
  25. package/dist/components/messageCanvas/actions/index.js +1 -1
  26. package/dist/components/messageCanvas/actions/textToSpeech/index.js +1 -1
  27. package/dist/components/messageCanvas/actions/textToSpeech/textToSpeech.d.ts +2 -2
  28. package/dist/components/messageCanvas/actions/textToSpeech/textToSpeech.d.ts.map +1 -1
  29. package/dist/components/messageCanvas/index.js +1 -1
  30. package/dist/components/messageCanvas/messageCanvas.d.ts +5 -5
  31. package/dist/components/messageCanvas/messageCanvas.d.ts.map +1 -1
  32. package/dist/components/messageSpace/index.js +1 -1
  33. package/dist/components/messageSpace/messageSpace.d.ts +6 -3
  34. package/dist/components/messageSpace/messageSpace.d.ts.map +1 -1
  35. package/dist/components/{promptBuilder/mockWebSocket.d.ts → mockWebSocket.d.ts} +1 -1
  36. package/dist/components/mockWebSocket.d.ts.map +1 -0
  37. package/dist/components/multipart/index.js +1 -1
  38. package/dist/components/multipart/multipart.d.ts +2 -2
  39. package/dist/components/multipart/multipart.d.ts.map +1 -1
  40. package/dist/components/participantsContainer/index.d.ts +2 -1
  41. package/dist/components/participantsContainer/index.d.ts.map +1 -1
  42. package/dist/components/participantsContainer/index.js +1 -1
  43. package/dist/components/participantsContainer/participantsContainer.d.ts +14 -1
  44. package/dist/components/participantsContainer/participantsContainer.d.ts.map +1 -1
  45. package/dist/components/pdfViewer/index.js +1 -1
  46. package/dist/components/promptBuilder/index.js +1 -1
  47. package/dist/components/promptBuilder/promptBuilder.d.ts.map +1 -1
  48. package/dist/components/question/index.js +1 -1
  49. package/dist/components/table/index.js +1 -1
  50. package/dist/components/text/index.js +1 -1
  51. package/dist/components/timestamp/index.d.ts.map +1 -1
  52. package/dist/components/timestamp/index.js +1 -0
  53. package/dist/components/types.d.ts +4 -20
  54. package/dist/components/types.d.ts.map +1 -1
  55. package/dist/components/video/index.js +1 -1
  56. package/dist/components/visualization/chart/index.js +1 -1
  57. package/dist/components/visualization/perspectiveViz/index.js +1 -1
  58. package/dist/components/weather/index.js +1 -1
  59. package/dist/index.css +28 -10
  60. package/dist/index.js +1 -1
  61. package/package.json +8 -4
  62. package/dist/components/promptBuilder/mockWebSocket.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fCCalendar.d.ts","sourceRoot":"","sources":["../../../src/components/calendar/fCCalendar.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AASzB,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,UAAU,CAAA;AAa3D;;;;;;;;iUAQiU;AACjU,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,YAAY,2CAwCrD"}
1
+ {"version":3,"file":"fCCalendar.d.ts","sourceRoot":"","sources":["../../../src/components/calendar/fCCalendar.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAUzB,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,UAAU,CAAA;AAa3D;;;;;;;;iUAQiU;AACjU,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,YAAY,2CA6ErD"}
@@ -1,21 +1,35 @@
1
- .rustic-fc-calendar .fc-event {
2
- overflow: hidden;
1
+ .rustic-fc-calendar {
2
+ padding: 16px;
3
+ }
4
+
5
+ .rustic-fc-calendar .fc-event-title {
6
+ text-overflow: ellipsis;
3
7
  }
4
8
 
5
9
  .rustic-fc-calendar .fc-button {
6
- font-size: 12px;
7
- padding: 2px 4px;
10
+ padding: 4px 8px;
8
11
  }
9
12
 
10
- .rustic-fc-calendar .fc-toolbar-title {
11
- font-size: 16px;
12
- padding-inline: 8px;
13
- text-align: center;
13
+ .rustic-fc-calendar
14
+ .fc
15
+ .fc-button-primary:not(:disabled).fc-button-active:focus,
16
+ .rustic-fc-calendar .fc .fc-button-primary:focus,
17
+ .rustic-fc-calendar .fc .fc-button-primary:not(:disabled):active:focus {
18
+ box-shadow: none;
14
19
  }
15
20
 
16
21
  @media (max-width: 900px) {
17
- .rustic-fc-calendar {
18
- font-size: 12px;
22
+ .rustic-fc-calendar .fc-toolbar {
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: 4px;
26
+ align-items: flex-start;
27
+ }
28
+
29
+ .rustic-fc-calendar .fc-toolbar .fc-toolbar-chunk:last-child {
30
+ display: flex;
31
+ justify-content: space-between;
32
+ width: 100%;
19
33
  }
20
34
  }
21
35
 
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},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,{ParticipantRole:()=>s,ParticipantType:()=>m,default:()=>p});const r=require("react/jsx-runtime"),i=require("@fullcalendar/daygrid");var a=e.n(i);const n=require("@fullcalendar/react");var o=e.n(n);const u=require("@mui/material/Box");var d=e.n(u);const l=require("@mui/material/styles"),c=require("@mui/material/useMediaQuery");var s,m,y=e.n(c);function f(e){return{title:e.title?e.title:"",start:e.start,end:e.end,allDay:e.isAllDay}}require("react"),function(e){e.Owner="owner",e.Member="member"}(s||(s={})),function(e){e.Human="human",e.Agent="agent"}(m||(m={}));const p=function(e){var t=(0,l.useTheme)(),i=y()(t.breakpoints.up("md"));return(0,r.jsx)(d(),{className:"rustic-fc-calendar",children:(0,r.jsx)(o(),{plugins:[a()],initialView:i?"dayGridMonth":"dayGridDay",headerToolbar:{left:"prev,next",center:"title",right:"dayGridMonth,dayGridWeek,dayGridDay"},eventTimeFormat:{hour:"2-digit",minute:"2-digit"},initialDate:e.events[0].start,events:e.events.map(f),views:{dayGridMonth:{titleFormat:{year:"numeric",month:"short"}},dayGridWeek:{},dayGridDay:{titleFormat:{year:"numeric",month:"short",day:"numeric"}}}})})};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={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var a in t)e.o(t,a)&&!e.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:t[a]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{default:()=>m});const t=require("react/jsx-runtime"),a=require("@fullcalendar/daygrid");var o=e.n(a);const i=require("@fullcalendar/react");var n=e.n(i);const d=require("@fullcalendar/timegrid");var c=e.n(d);const l=require("@mui/material/Box");var s=e.n(l);const u=require("@mui/material/styles"),p=require("@mui/material/useMediaQuery");var f=e.n(p);require("react");var y=function(){return y=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},y.apply(this,arguments)};function b(e){return{title:e.title?e.title:"",start:e.start,end:e.end,allDay:e.isAllDay}}const m=function(e){var r=(0,u.useTheme)(),a=f()(r.breakpoints.up("md"));return(0,t.jsx)(s(),{className:"rustic-fc-calendar",sx:{border:"1px solid ".concat(r.palette.divider),borderRadius:"".concat(r.shape.borderRadius,"px"),".fc .fc-toolbar-title":y({},r.typography.h6),".fc .fc-scrollgrid-liquid":{borderRadius:"".concat(r.shape.borderRadius,"px")},".fc td":{borderRadius:"0 0 ".concat(r.shape.borderRadius,"px ").concat(r.shape.borderRadius,"px")},".fc .fc-scrollgrid-section-header > th":{borderRadius:"".concat(r.shape.borderRadius,"px ").concat(r.shape.borderRadius,"px 0 0")},".fc .fc-button, .fc .fc-button:active":{color:r.palette.primary.main,backgroundColor:r.palette.background.paper,border:"1px solid ".concat(r.palette.divider),borderRadius:"".concat(r.shape.borderRadius,"px"),"&:hover":{backgroundColor:r.palette.secondary.light,border:"1px solid ".concat(r.palette.divider)}},".fc .fc-button-group .fc-button.fc-button-active":{backgroundColor:r.palette.secondary.main,border:"1px solid ".concat(r.palette.divider)},".fc a, .fc .fc-event-title, .fc .fc-button, .fc .fc-timegrid-slot":y({},r.typography.caption)},children:(0,t.jsx)(n(),{plugins:[c(),o()],initialView:a?"dayGridMonth":"timeGridDay",headerToolbar:{left:"title",right:"prev,next dayGridMonth,timeGridWeek,timeGridDay"},eventColor:r.palette.secondary.main,displayEventTime:!1,titleFormat:{year:"numeric",month:"long"},views:{dayGridMonth:{dayHeaderFormat:{weekday:a?"long":"narrow"}},timeGridWeek:{dayHeaderFormat:{weekday:"short",day:"numeric"}},timeGridDay:{dayHeaderFormat:{weekday:"long",day:"numeric"}}},allDaySlot:!1,initialDate:e.events[0].start,events:e.events.map(b)})})};return r})()));
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{ParticipantRole:()=>s,ParticipantType:()=>f,default:()=>g});const t=require("react/jsx-runtime"),n=require("@codemirror/language"),o=require("@codemirror/language-data"),a=require("@codemirror/state"),i=require("@codemirror/view"),u=require("@mui/material/Typography");var c=e.n(u);const l=require("@mui/system"),d=require("react");var s,f;!function(e){e.Owner="owner",e.Member="member"}(s||(s={})),function(e){e.Human="human",e.Agent="agent"}(f||(f={}));const g=function(e){var r=(0,d.useRef)(null),u=(0,d.useRef)(),s=new a.Compartment,f=[a.EditorState.readOnly.of(!0),(0,i.highlightSpecialChars)(),(0,n.syntaxHighlighting)(n.defaultHighlightStyle,{fallback:!0}),s.of([])],g=o.languages.find((function(r){return r.name.toLowerCase()===e.language.toLowerCase()}));return(0,d.useEffect)((function(){if(r.current&&!u.current){var t=r.current,n=a.EditorState.create({doc:e.code,extensions:f});u.current=new i.EditorView({state:n,parent:t}),g&&u.current&&g.load().then((function(e){var r;null===(r=u.current)||void 0===r||r.dispatch({effects:s.reconfigure(e.extension)})}))}}),[]),(0,t.jsx)(l.Box,{sx:{backgroundColor:"background.default"},className:"rustic-code-snippet",children:(0,t.jsx)("div",{"aria-label":"code snippet",ref:r,children:(0,t.jsx)(c(),{variant:"body2","aria-label":"language type",children:e.language})})})};return r})()));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var o in t)e.o(t,o)&&!e.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:t[o]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{default:()=>s});const t=require("react/jsx-runtime"),o=require("@codemirror/language"),n=require("@codemirror/language-data"),a=require("@codemirror/state"),i=require("@codemirror/view"),u=require("@mui/material/Typography");var c=e.n(u);const l=require("@mui/system"),d=require("react"),s=function(e){var r=(0,d.useRef)(null),u=(0,d.useRef)(),s=new a.Compartment,f=[a.EditorState.readOnly.of(!0),(0,i.highlightSpecialChars)(),(0,o.syntaxHighlighting)(o.defaultHighlightStyle,{fallback:!0}),s.of([])],g=n.languages.find((function(r){return r.name.toLowerCase()===e.language.toLowerCase()}));return(0,d.useEffect)((function(){if(r.current&&!u.current){var t=r.current,o=a.EditorState.create({doc:e.code,extensions:f});u.current=new i.EditorView({state:o,parent:t}),g&&u.current&&g.load().then((function(e){var r;null===(r=u.current)||void 0===r||r.dispatch({effects:s.reconfigure(e.extension)})}))}}),[]),(0,t.jsx)(l.Box,{sx:{backgroundColor:"background.default"},className:"rustic-code-snippet",children:(0,t.jsx)("div",{"aria-label":"code snippet",ref:r,children:(0,t.jsx)(c(),{variant:"body2","aria-label":"language type",children:e.language})})})};return r})()));
@@ -1,8 +1,8 @@
1
- import type { ComponentMap, Sender, ThreadableMessage, WebSocketClient } from '../types';
1
+ import type { ComponentMap, Message, Sender, WebSocketClient } from '../types';
2
2
  interface ElementRendererProps {
3
3
  sender: Sender;
4
4
  ws: WebSocketClient;
5
- message: ThreadableMessage;
5
+ messages: Message[];
6
6
  supportedElements: ComponentMap;
7
7
  }
8
8
  declare const ElementRenderer: (props: ElementRendererProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"elementRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/elementRenderer/elementRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,iBAAiB,EACjB,eAAe,EAChB,MAAM,UAAU,CAAA;AAEjB,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,eAAe,CAAA;IACnB,OAAO,EAAE,iBAAiB,CAAA;IAC1B,iBAAiB,EAAE,YAAY,CAAA;CAChC;AAED,QAAA,MAAM,eAAe,UAAW,oBAAoB,4CAuBnD,CAAA;AAED,eAAe,eAAe,CAAA"}
1
+ {"version":3,"file":"elementRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/elementRenderer/elementRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE9E,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,eAAe,CAAA;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,iBAAiB,EAAE,YAAY,CAAA;CAChC;AAED,QAAA,MAAM,eAAe,UAAW,oBAAoB,4CAyBnD,CAAA;AAED,eAAe,eAAe,CAAA"}
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>d});const r=require("react/jsx-runtime"),a=require("@mui/material/Typography");var o=e.n(a);const n=require("react");var s=e.n(n),i=function(){return i=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},i.apply(this,arguments)};const d=function(e){var t=e.supportedElements[e.message.format];return(0,r.jsx)(r.Fragment,{children:t?s().createElement(t,i(i({sender:e.sender,ws:e.ws,messageId:e.message.id,conversationId:e.message.conversationId},e.message.data),e.message.threadMessagesData&&{updatedData:e.message.threadMessagesData})):(0,r.jsxs)(o(),{variant:"body2",children:["Unsupported element format: ",e.message.format]})})};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 r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>u});const r=require("react/jsx-runtime"),o=require("@mui/material/Typography");var n=e.n(o);const a=require("react");var s=e.n(a),i=function(){return i=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};const u=function(e){var t=e.messages[0],o=e.messages.slice(1),a=e.supportedElements[t.format];return(0,r.jsx)(r.Fragment,{children:a?s().createElement(a,i(i({sender:e.sender,ws:e.ws,messageId:t.id,conversationId:t.conversationId},t.data),o.length>0&&{updatedData:o.map((function(e){return e.data}))})):(0,r.jsxs)(n(),{variant:"body2",children:["Unsupported element format: ",t.format]})})};return t})()));
@@ -1,7 +1,5 @@
1
1
  export declare function calculateTimeDiffInSeconds(isoDate: string): number;
2
- export declare function calculateTimeAgo(isoDate: string): string;
3
2
  export declare function formatDateAndTime(isoDateTimeInUtc: string): string;
4
- export declare function formatMessageTimestamp(isoDate: string): string;
5
3
  export declare const capitalizeFirstLetter: (str: string) => string;
6
4
  export declare enum TimeFormat {
7
5
  HOUR = 0,
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/components/helper.ts"],"names":[],"mappings":"AAGA,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYxD;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CA6BlE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAM9D;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,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 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ParticipantRole:()=>l,ParticipantType:()=>p,default:()=>y});const r=require("react/jsx-runtime"),n=require("@mui/material/CircularProgress");var o=e.n(n);const i=require("@mui/material/Typography");var a=e.n(i);const c=require("react");require("pluralize");var u,s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(u||(u={}));var l,p,f=function(){return f=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},f.apply(this,arguments)};function d(e){var t,n,i,u=(0,c.useState)(!0),l=u[0],p=u[1],d=(0,c.useState)(""),y=d[0],m=d[1];return y.length>0?(0,r.jsx)(a(),{variant:"body2",children:y}):(0,r.jsxs)("figure",{children:[l&&(0,r.jsx)(o(),{}),(0,r.jsx)("img",f({},(t=e.width,n=e.height,i={},t&&(i={width:t}),n&&(i=s(s({},i),{height:n})),t||n||(i={className:"rustic-fit-container"}),i),{src:e.src,alt:e.alt,onError:function(){m("Image failed to load"),p(!1)},onLoad:function(){p(!1)}})),e.description&&(0,r.jsx)("figcaption",{children:(0,r.jsx)(a(),{variant:"body2",children:e.description})})]})}d.defaultProps={alt:"An image is displayed"},function(e){e.Owner="owner",e.Member="member"}(l||(l={})),function(e){e.Human="human",e.Agent="agent"}(p||(p={}));const y=d;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 r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},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:()=>f});const r=require("react/jsx-runtime"),o=require("@mui/material/CircularProgress");var n=e.n(o);const i=require("@mui/material/Typography");var a=e.n(i);const c=require("react");var s,u=function(){return u=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},u.apply(this,arguments)};!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(s||(s={}));var l=function(){return l=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},l.apply(this,arguments)};function d(e){var t,o,i,s=(0,c.useState)(!0),d=s[0],f=s[1],p=(0,c.useState)(""),y=p[0],g=p[1];return y.length>0?(0,r.jsx)(a(),{variant:"body2",children:y}):(0,r.jsxs)("figure",{children:[d&&(0,r.jsx)(n(),{}),(0,r.jsx)("img",l({},(t=e.width,o=e.height,i={},t&&(i={width:t}),o&&(i=u(u({},i),{height:o})),t||o||(i={className:"rustic-fit-container"}),i),{src:e.src,alt:e.alt,onError:function(){g("Image failed to load"),f(!1)},onLoad:function(){f(!1)}})),e.description&&(0,r.jsx)("figcaption",{children:(0,r.jsx)(a(),{variant:"body2",children:e.description})})]})}d.defaultProps={alt:"An image is displayed"};const f=d;return t})()));
@@ -102,6 +102,10 @@ code {
102
102
  margin: 10px 8px;
103
103
  }
104
104
 
105
+ .rustic-base-input .rustic-input-actions {
106
+ display: flex;
107
+ }
108
+
105
109
  span.rustic-icon-large {
106
110
  font-size: 32px;
107
111
  }
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["@rustic-ai/ui-components"]=n():e["@rustic-ai/ui-components"]=n()}(global,(()=>(()=>{"use strict";var e,n,r={13:e=>{e.exports=require("emoji-picker-element")}},t={};function i(e){var n=t[e];if(void 0!==n)return n.exports;var o=t[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return i.d(n,{a:n}),n},n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,t){if(1&t&&(r=this(r)),8&t)return r;if("object"==typeof r&&r){if(4&t&&r.__esModule)return r;if(16&t&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var a={};e=e||[null,n({}),n([]),n(n)];for(var c=2&t&&r;"object"==typeof c&&!~e.indexOf(c);c=n(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>r[e]));return a.default=()=>r,i.d(o,a),o},i.d=(e,n)=>{for(var r in n)i.o(n,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},i.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{ParticipantRole:()=>te,ParticipantType:()=>ie,default:()=>se});const e=require("react/jsx-runtime"),n=require("@mui/material/Box");var r=i.n(n);const t=require("react"),a=require("uuid"),c=require("@mui/material/CircularProgress");var s=i.n(c);const l=require("@mui/material/IconButton");var u=i.n(l);const d=require("@mui/material/InputAdornment");var f=i.n(d);const m=require("@mui/material/MenuItem");var p=i.n(m);const h=require("@mui/material/MenuList");var v=i.n(h);const g=require("@mui/material/Popover");var x=i.n(g);const j=require("@mui/material/TextField");var b=i.n(j);const y=require("@mui/material/Tooltip");var w=i.n(y);const S=require("@mui/material/Typography");var C=i.n(S),k=i(13);function N(n){return n.name.replaceAll("_","-"),(0,e.jsx)("span",{className:"".concat(n.className?n.className+" ":"","material-symbols-rounded"),children:n.name})}const F=require("@mui/material/styles"),P=function(n){var r=(0,F.useTheme)(),o=(0,t.useRef)(null),a=(0,t.useRef)(null),c=(0,t.useState)(!1),s=c[0],l=c[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 f(){l(!1)}function m(e){e.detail.unicode&&n.onEmojiClick(e.detail.unicode),f()}return(0,t.useEffect)((function(){a.current||"undefined"==typeof window||Promise.resolve().then(i.t.bind(i,13,23)).then((function(e){var n=new(0,e.Picker),t="dark"===r.palette.mode?"dark":"light";n.classList.add(t),Object.keys(d).forEach((function(e){n.style.setProperty(e,d[e])})),a.current=n})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,t.useEffect)((function(){return a.current&&a.current.addEventListener("emoji-click",m),function(){var e;null===(e=a.current)||void 0===e||e.removeEventListener("emoji-click",m)}}),[s,n.onEmojiClick]),(0,e.jsxs)("div",{children:[(0,e.jsx)(w(),{title:"Emoji",children:(0,e.jsx)(u(),{size:"small",ref:o,onClick:function(){l((function(e){return!e}))},sx:{color:n.buttonColor},children:(0,e.jsx)(N,{name:"Mood"})})}),a.current&&(0,e.jsx)(x(),{open:s,anchorEl:o.current,onClose:f,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,e.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&a.current&&!e.contains(a.current)&&e.appendChild(a.current)}})})]})};var O={"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 E(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var q=(0,t.forwardRef)((function(n,i){var o=(0,t.useState)(""),c=o[0],l=o[1],d=(0,t.useState)(!1),m=d[0],h=d[1],g=(0,t.useState)(!1),j=g[0],y=g[1],S=(0,t.useState)(!1),F=S[0],q=S[1],T=(0,t.useState)(""),z=T[0],R=T[1],_=(0,t.useState)([]),I=_[0],M=_[1],A=(0,t.useState)(!1),D=A[0],U=A[1],B=(0,t.useRef)(null),L=!c.trim().length&&!n.isSendEnabled,W="".concat(m?"Stop":"Start"," speech to text"),H=j?"primary.main":"primary.light",V=m?"error.main":H,$=m?"stop_circle":"speech_to_text";function G(e,n){if(void 0===n&&(n=!1),B.current){var r=B.current,t=r.selectionStart,i=r.selectionEnd;if("number"==typeof t&&"number"==typeof i){var o,a=c||"",s=a.substring(0,t),u=a.substring(i);o=n?s.replace(/:(\w+)$/,e)+u:s+e+u,l(o);var d=n?s.replace(/:(\w+)$/,e).length:t+e.length;setTimeout((function(){var e,n;null===(e=B.current)||void 0===e||e.focus(),null===(n=B.current)||void 0===n||n.setSelectionRange(d,d)}),0)}}U(!1)}var K=new k.Database,Q=F?(0,e.jsx)(s(),{size:24}):(0,e.jsx)(w(),{title:W,children:(0,e.jsx)(u(),{onClick:function(){var e=new window.webkitSpeechRecognition,n=navigator.language;e.lang=n,m?(e.stop(),q(!0),h(!1)):(e.start(),R(""),h(!0)),e.onstart=function(){h(!0)},e.onresult=function(e){var n,r=e.results[0][0].transcript;c.length>0?l(c+" "+r):l(r),null===(n=B.current)||void 0===n||n.focus(),h(!1)},e.onerror=function(e){var n=O[e.error];R(n),h(!1)},e.onend=function(){q(!1),h(!1)}},size:"small",sx:{color:V},children:(0,e.jsx)(N,{name:$})})});function Y(){var e=(new Date).toISOString(),r={id:(0,a.v4)(),timestamp:e,sender:n.sender,conversationId:n.conversationId,format:"text",data:{text:c}};n.send(r),l(""),R("")}return(0,e.jsxs)(r(),{className:"rustic-base-input",ref:i,children:[(0,e.jsxs)(r(),{className:"rustic-error-and-input-container",children:[(0,e.jsx)(r(),{className:"rustic-error-container",children:(0,e.jsx)(C(),{variant:"caption",color:"error",className:"rustic-error-message",children:z})}),(0,e.jsxs)(r(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:j?"secondary.main":"action.disabled"},children:[I.length>0&&(0,e.jsx)(x(),{open:D,anchorEl:B.current,onClose:function(){return U(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,e.jsx)(v(),{children:I.map((function(n,r){return"unicode"in n&&(0,e.jsx)(p(),{onClick:function(){return G(n.unicode,!0)},children:E(n)},r)}))})}),(0,e.jsx)(b(),{className:"rustic-text-field",variant:"outlined",value:c,label:n.label,placeholder:n.placeholder,maxRows:n.maxRows,multiline:n.multiline,fullWidth:n.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!L&&Y())},onChange:function(e){R("");var r=e.target.value;l(r);var t,i=r.match(/:(\w{2,}):/g),o=r.match(/:(\w{2,})/g);if(i){var a=i[0].replace(/:/g,"");K.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var n=r.replace(i[0],e.unicode);l(n)}else l(r)})).catch((function(){l(r)})),U(!1)}else o?(t=o[0].replace(":",""),K.getEmojiBySearchQuery(t).then((function(e){e.length?(M(e.slice(0,n.maximumEmojiSearchResults)),U(!0)):(M([]),U(!1))})).catch((function(){M([]),U(!1)}))):U(!1)},onFocus:function(){return y(!0)},onBlur:function(){return y(!1)},inputRef:B,color:"secondary",size:"small",InputProps:{endAdornment:(0,e.jsxs)(f(),{position:"end",children:[(0,e.jsx)(P,{onEmojiClick:G,buttonColor:H}),n.enableSpeechToText&&Q]})},InputLabelProps:{className:j?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,e.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,e.jsxs)(r(),{className:"rustic-input-actions",children:[n.children,(0,e.jsx)(w(),{title:"Send",children:(0,e.jsx)("span",{className:"rustic-send-button",children:(0,e.jsx)(u(),{"aria-label":"send message",onClick:Y,disabled:L,color:"primary",children:(0,e.jsx)(N,{name:"send"})})})})]})]})}));q.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const T=q,z=require("@mui/material/LinearProgress");var R=i.n(z);const _=require("axios");var I=i.n(_);const M=require("react-dom"),A=require("@mui/material/Card");var D=i.n(A);const U=require("@mui/material/Modal");var B,L=i.n(U);require("pluralize"),function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(B||(B={}));const W=require("@mui/material/useMediaQuery");var H=i.n(W);const V=require("@mui/system/Stack");var $=i.n(V);const G=require("@mui/system/useTheme");var K=i.n(G);const Q=require("pdfjs-dist"),Y=function(n){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[n.action].label.replaceAll(" ","-").toLowerCase(),r[n.action]);return(0,e.jsx)(w(),{title:t.label,children:(0,e.jsx)("span",{children:(0,e.jsx)(u(),{onClick:n.onClick,className:n.className,disabled:n.isDisabled,children:(0,e.jsx)(N,{name:t.symbol})})})})};var Z={pdf:function(n){var i,o=(0,t.useRef)(null),a=(0,t.useState)(1),c=a[0],s=a[1],l=(0,t.useState)(1),u=l[0],d=l[1],f=(0,t.useState)(1),m=f[0],p=f[1],h=(0,t.useState)(!1),v=h[0],g=h[1],x=(0,t.useState)(),j=x[0],y=x[1],w=K()(),S=H()(w.breakpoints.down("sm")),k=H()(w.breakpoints.between("sm","md"));if(i=n.url,!/\/[^/]+\.pdf$/.test(i))return(0,e.jsx)(D(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(C(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var N=(0,t.useState)((function(){return S?.5:k?1:1.5})),F=N[0],P=N[1];return(0,t.useEffect)((function(){Q.GlobalWorkerOptions.workerSrc||(Q.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(Q.version,"/pdf.worker.mjs")),Q.getDocument({url:"".concat(n.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(c).then((function(e){var n=e.getViewport({scale:F}),r=o.current;if(r){var t=r.getContext("2d");if(t){var i=window.devicePixelRatio||1;r.style.width="".concat(n.width,"px"),r.style.height="".concat(n.height,"px"),r.width=n.width*i,r.height=n.height*i;var a={canvasContext:t,viewport:n,transform:[i,0,0,i,0,0]};j&&j.cancel();var c=e.render(a);y(c),c.promise.then((function(){y(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[n.url,c,F]),v?(0,e.jsx)(D(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(C(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,e.jsxs)(D(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,e.jsxs)(r(),{className:"rustic-pdf-viewer-header",children:[(0,e.jsx)(Y,{action:"zoomOut",onClick:function(){P((function(e){return Math.max(e-.2,.2)}))}}),(0,e.jsx)(Y,{action:"zoomIn",onClick:function(){P((function(e){return e+.2}))}})]}),(0,e.jsx)(r(),{className:"rustic-pdf-viewer-body",children:(0,e.jsx)(r(),{className:"rustic-pdf-viewer-body-inner",children:(0,e.jsx)("canvas",{ref:o})})}),(0,e.jsxs)($(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,e.jsx)(Y,{action:"previousPage",onClick:function(){c>1&&(s(c-1),p(c-1))},isDisabled:1===c}),(0,e.jsx)(C(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,e.jsx)(b(),{type:"number",value:m,onChange:function(e){var n=parseInt(e.target.value);p(n),!isNaN(n)&&n>=1&&n<=u&&s(n)},size:"small",className:"rustic-pdf-page-input"}),(0,e.jsxs)(C(),{variant:"body1",className:"rustic-page-indicator",children:["of ",u]}),(0,e.jsx)(Y,{action:"nextPage",onClick:function(){c<u&&(s(c+1),p(c+1))},isDisabled:c===u})]})]})}};function J(n){var r=(0,F.useTheme)(),i=(0,t.useState)(!1),o=i[0],a=i[1];function c(){a(!1)}var s,l,d=n.file.url&&(s=n.file.url.split("."))[s.length-1].toLowerCase(),f=d&&n.supportedViewers?n.supportedViewers[d]:null,m=!!f;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(D(),{className:"rustic-file-preview".concat(m?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){a(!0)},children:[(0,e.jsx)(C(),{variant:"subtitle2",children:(l=n.file.name,15,l.length<=15?l:l.substring(0,12)+"...")}),(0,e.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:n.children})]}),m&&(0,e.jsx)(L(),{open:o,onClose:c,className:"rustic-file-preview-modal",children:(0,e.jsxs)("div",{className:"rustic-modal-content",children:[(0,e.jsx)(w(),{title:"Close",children:(0,e.jsx)(u(),{onClick:c,className:"rustic-close-button",children:(0,e.jsx)(N,{name:"close"})})}),n.file.url&&(0,e.jsx)(f,{url:n.file.url})]})})]})}J.defaultProps={supportedViewers:Z};var X=function(){return X=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var i in n=arguments[r])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},X.apply(this,arguments)},ee=function(e,n,r){if(r||2===arguments.length)for(var t,i=0,o=n.length;i<o;i++)!t&&i in n||(t||(t=Array.prototype.slice.call(n,0,i)),t[i]=n[i]);return e.concat(t||Array.prototype.slice.call(n))};function ne(e){for(var n=["Bytes","KB","MB","GB"],r=0;e>=1024&&r<n.length-1;)e/=1024,r++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(n[r])}const re=function(n){var i=(0,t.useState)([]),o=i[0],c=i[1],s=(0,t.useState)([]),l=s[0],d=s[1],f=(0,t.useRef)({}),m=(0,a.v4)();(0,t.useEffect)((function(){c([]),d([]),f.current={}}),[n.messageId]);var p=(0,e.jsx)(r(),{className:"rustic-files rustic-padding-16",children:o.map((function(t,i){return(0,e.jsx)(J,{file:{name:t.name},children:(0,e.jsxs)(r(),{className:"rustic-flex-center",children:[t.loadingProgress<100&&(0,e.jsx)(R(),{variant:"determinate",color:"secondary",value:t.loadingProgress,className:"rustic-upload-progress"}),(0,e.jsx)(w(),{title:"Delete",children:(0,e.jsx)(u(),{color:"primary",onClick:function(){return function(e,r){var t,i;d([]);var o=e.name;if(f.current=X(X({},f.current),((t={})[o]=f.current[o]--,t)),n.onFileUpdate("remove",o),100===e.loadingProgress){var a="".concat(n.deleteFileEndpoint,"?message-id=").concat(n.messageId,"&file-id=").concat(e.id);I().delete(a).then((function(){return c((function(e){return e.filter((function(e,n){return n!==r}))}))})).catch((function(){return n.onFileUpdate("add",o),d((function(e){return ee(ee([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else e.abortController.abort(),c((function(e){return e.filter((function(e,n){return n!==r}))})),f.current=X(X({},f.current),((i={})[o]=f.current[o]++,i))}(t,i)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},i)}))}),h=(0,e.jsx)(r(),{children:l.map((function(n,r){return(0,e.jsx)(C(),{variant:"caption",color:"error",className:"rustic-error-message",children:n},r)}))});function v(e,n){return n?(0,M.createPortal)(e,n):e}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(r(),{className:"rustic-uploader",children:[(0,e.jsx)("label",{htmlFor:m,children:(0,e.jsx)(w(),{title:"Upload",children:(0,e.jsx)(u(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,e.jsx)("input",{type:"file",id:m,onChange:function(e){d([]);var r=e.target.files&&Array.from(e.target.files),t=o.length+(r?r.length:0);n.maxFileCount&&t>n.maxFileCount&&d((function(e){return ee(ee([],e,!0),["You can only upload ".concat(n.maxFileCount," files.")],!1)}));var i=r&&function(e,n,r){return r?n<=r?e:e.slice(0,r-n):e}(r,t,n.maxFileCount);i&&i.forEach((function(e){!function(e){var r;n.maxFileSize&&e.size>n.maxFileSize?(r=e.name,d((function(e){return ee(ee([],e,!0),["Failed to upload ".concat(r,". You cannot upload files larger than ").concat(n.maxFileSize&&ne(n.maxFileSize),".")],!1)}))):function(e){var r=new FormData,t=new AbortController,i=function(e){var n,r,t=e.name,i=f.current[t];if(i){var o=i+1,a=t.lastIndexOf("."),c=t.substring(0,a),s=t.substring(a);t="".concat(c,"(").concat(i,")").concat(s),f.current=X(X({},f.current),((n={})[e.name]=o,n))}else f.current=X(X({},f.current),((r={})[e.name]=1,r));return t}(e),o=new File([e],i,{type:e.type});r.append("file",o);var s=(0,a.v4)(),l={name:i,loadingProgress:0,abortController:t,id:s};c((function(e){return ee(ee([],e,!0),[l],!1)})),n.onFileUpdate("add",i);var u="".concat(n.uploadFileEndpoint,"?message-id=").concat(n.messageId);I().post(u,r,{onUploadProgress:function(e){var n,r;e.total&&(n=e.loaded/e.total*100,r=l.id,c((function(e){var t=e.map((function(e){return e.id===r?X(X({},e),{loadingProgress:n}):e}));return t})))},signal:t.signal}).then((function(e){var n,r;n=e.data,r=l.id,c((function(e){var t=e.findIndex((function(e){return e.id===r}));if(-1!==t){var i=ee([],e,!0);return i[t]=X(X({},i[t]),{id:n.fileId}),i}return e}))})).catch((function(r){var t,o;n.onFileUpdate("remove",i),f.current=X(X({},f.current),((t={})[i]=f.current[e.name]--,t)),function(e,n,r){d((function(n){return ee(ee([],n,!0),["Failed to upload ".concat(e,". ").concat((null==r?void 0:r.message)||"")],!1)})),c((function(e){return e.filter((function(e){return e.id!==n}))}))}(e.name,l.id,null===(o=r.response)||void 0===o?void 0:o.data)}))}(e)}(e)})),e.target.value=""},multiple:!0,accept:n.acceptedFileTypes})]}),l.length>0&&v(h,n.errorMessagesContainer),o.length>0&&v(p,n.filePreviewsContainer)]})};var te,ie,oe=function(){return oe=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var i in n=arguments[r])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},oe.apply(this,arguments)},ae=function(e,n,r){if(r||2===arguments.length)for(var t,i=0,o=n.length;i<o;i++)!t&&i in n||(t||(t=Array.prototype.slice.call(n,0,i)),t[i]=n[i]);return e.concat(t||Array.prototype.slice.call(n))};function ce(n){var i=(0,t.useState)([]),o=i[0],c=i[1],s=(0,t.useState)((0,a.v4)()),l=s[0],u=s[1],d=(0,t.useState)(),f=d[0],m=d[1],p=(0,t.useState)(),h=p[0],v=p[1],g=(0,t.useRef)(null),x=o.length>0;return(0,t.useEffect)((function(){g.current&&(v(g.current.querySelector(".rustic-error-container")),m(g.current.querySelector(".rustic-input-extras")))})),(0,e.jsx)(r(),{className:"rustic-multimodal-input",children:(0,e.jsx)(T,oe({},n,{send:function(e){x&&(e.id=l,e.format="multipart",e.data.files=o),n.ws.send(e),u((0,a.v4)()),c([])},isSendEnabled:x,ref:g,children:(0,e.jsx)(r(),{className:"rustic-bottom-buttons",children:(0,e.jsx)(re,{acceptedFileTypes:n.acceptedFileTypes,maxFileCount:n.maxFileCount,maxFileSize:n.maxFileSize,uploadFileEndpoint:n.uploadFileEndpoint,deleteFileEndpoint:n.deleteFileEndpoint,onFileUpdate:function(e,n){c("add"===e?function(e){return ae(ae([],e,!0),[{name:n}],!1)}:function(e){return e.filter((function(e){return e.name!==n}))})},messageId:l,filePreviewsContainer:f,errorMessagesContainer:h})})}))})}ce.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1},function(e){e.Owner="owner",e.Member="member"}(te||(te={})),function(e){e.Human="human",e.Agent="agent"}(ie||(ie={}));const se=ce})(),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,n={13:e=>{e.exports=require("emoji-picker-element")}},t={};function i(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return n[e](o,o.exports,i),o.exports}i.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return i.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.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);i.r(o);var a={};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=>a[e]=()=>n[e]));return a.default=()=>n,i.d(o,a),o},i.d=(e,r)=>{for(var n in r)i.o(r,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{default:()=>ae});const e=require("react/jsx-runtime"),r=require("@mui/material/Box");var n=i.n(r);const t=require("react"),a=require("uuid"),c=require("@mui/material/CircularProgress");var s=i.n(c);const l=require("@mui/material/IconButton");var u=i.n(l);const d=require("@mui/material/InputAdornment");var f=i.n(d);const m=require("@mui/material/MenuItem");var p=i.n(m);const h=require("@mui/material/MenuList");var v=i.n(h);const g=require("@mui/material/Popover");var x=i.n(g);const j=require("@mui/material/TextField");var b=i.n(j);const y=require("@mui/material/Tooltip");var w=i.n(y);const S=require("@mui/material/Typography");var C=i.n(S),k=i(13);function N(r){return r.name.replaceAll("_","-"),(0,e.jsx)("span",{className:"".concat(r.className?r.className+" ":"","material-symbols-rounded"),children:r.name})}const F=require("@mui/material/styles"),P=function(r){var n=(0,F.useTheme)(),o=(0,t.useRef)(null),a=(0,t.useRef)(null),c=(0,t.useState)(!1),s=c[0],l=c[1],d={"--indicator-color":n.palette.divider,"--background":n.palette.background.paper,"--input-border-color":n.palette.divider,"--outline-color":n.palette.secondary.main};function f(){l(!1)}function m(e){e.detail.unicode&&r.onEmojiClick(e.detail.unicode),f()}return(0,t.useEffect)((function(){a.current||"undefined"==typeof window||Promise.resolve().then(i.t.bind(i,13,23)).then((function(e){var r=new(0,e.Picker),t="dark"===n.palette.mode?"dark":"light";r.classList.add(t),Object.keys(d).forEach((function(e){r.style.setProperty(e,d[e])})),a.current=r})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,t.useEffect)((function(){return a.current&&a.current.addEventListener("emoji-click",m),function(){var e;null===(e=a.current)||void 0===e||e.removeEventListener("emoji-click",m)}}),[s,r.onEmojiClick]),(0,e.jsxs)("div",{children:[(0,e.jsx)(w(),{title:"Emoji",children:(0,e.jsx)(u(),{size:"small",ref:o,onClick:function(){l((function(e){return!e}))},sx:{color:r.buttonColor},children:(0,e.jsx)(N,{name:"Mood"})})}),a.current&&(0,e.jsx)(x(),{open:s,anchorEl:o.current,onClose:f,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,e.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&a.current&&!e.contains(a.current)&&e.appendChild(a.current)}})})]})};var O={"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 E(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var q=(0,t.forwardRef)((function(r,i){var o=(0,t.useState)(""),c=o[0],l=o[1],d=(0,t.useState)(!1),m=d[0],h=d[1],g=(0,t.useState)(!1),j=g[0],y=g[1],S=(0,t.useState)(!1),F=S[0],q=S[1],T=(0,t.useState)(""),z=T[0],_=T[1],R=(0,t.useState)([]),I=R[0],M=R[1],D=(0,t.useState)(!1),A=D[0],U=D[1],B=(0,t.useRef)(null),L=!c.trim().length&&!r.isSendEnabled,W="".concat(m?"Stop":"Start"," speech to text"),H=j?"primary.main":"primary.light",V=m?"error.main":H,$=m?"stop_circle":"speech_to_text";function G(e,r){if(void 0===r&&(r=!1),B.current){var n=B.current,t=n.selectionStart,i=n.selectionEnd;if("number"==typeof t&&"number"==typeof i){var o,a=c||"",s=a.substring(0,t),u=a.substring(i);o=r?s.replace(/:(\w+)$/,e)+u:s+e+u,l(o);var d=r?s.replace(/:(\w+)$/,e).length:t+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 K=new k.Database,Q=F?(0,e.jsx)(s(),{size:24}):(0,e.jsx)(w(),{title:W,children:(0,e.jsx)(u(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,m?(e.stop(),q(!0),h(!1)):(e.start(),_(""),h(!0)),e.onstart=function(){h(!0)},e.onresult=function(e){var r,n=e.results[0][0].transcript;c.length>0?l(c+" "+n):l(n),null===(r=B.current)||void 0===r||r.focus(),h(!1)},e.onerror=function(e){var r=O[e.error];_(r),h(!1)},e.onend=function(){q(!1),h(!1)}},size:"small",sx:{color:V},children:(0,e.jsx)(N,{name:$})})});function Y(){var e=(new Date).toISOString(),n={id:(0,a.v4)(),timestamp:e,sender:r.sender,conversationId:r.conversationId,format:"text",data:{text:c}};r.send(n),l(""),_("")}return(0,e.jsxs)(n(),{className:"rustic-base-input",ref:i,children:[(0,e.jsxs)(n(),{className:"rustic-error-and-input-container",children:[(0,e.jsx)(n(),{className:"rustic-error-container",children:(0,e.jsx)(C(),{variant:"caption",color:"error",className:"rustic-error-message",children:z})}),(0,e.jsxs)(n(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:j?"secondary.main":"action.disabled"},children:[I.length>0&&(0,e.jsx)(x(),{open:A,anchorEl:B.current,onClose:function(){return U(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,e.jsx)(v(),{children:I.map((function(r,n){return"unicode"in r&&(0,e.jsx)(p(),{onClick:function(){return G(r.unicode,!0)},children:E(r)},n)}))})}),(0,e.jsx)(b(),{className:"rustic-text-field",variant:"outlined",value:c,label:r.label,placeholder:r.placeholder,maxRows:r.maxRows,multiline:r.multiline,fullWidth:r.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!L&&Y())},onChange:function(e){_("");var n=e.target.value;l(n);var t,i=n.match(/:(\w{2,}):/g),o=n.match(/:(\w{2,})/g);if(i){var a=i[0].replace(/:/g,"");K.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var r=n.replace(i[0],e.unicode);l(r)}else l(n)})).catch((function(){l(n)})),U(!1)}else o?(t=o[0].replace(":",""),K.getEmojiBySearchQuery(t).then((function(e){e.length?(M(e.slice(0,r.maximumEmojiSearchResults)),U(!0)):(M([]),U(!1))})).catch((function(){M([]),U(!1)}))):U(!1)},onFocus:function(){return y(!0)},onBlur:function(){return y(!1)},inputRef:B,color:"secondary",size:"small",InputProps:{endAdornment:(0,e.jsxs)(f(),{position:"end",children:[(0,e.jsx)(P,{onEmojiClick:G,buttonColor:H}),r.enableSpeechToText&&Q]})},InputLabelProps:{className:j?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,e.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,e.jsxs)(n(),{className:"rustic-input-actions",children:[r.children,(0,e.jsx)(w(),{title:"Send",children:(0,e.jsx)("span",{className:"rustic-send-button",children:(0,e.jsx)(u(),{"aria-label":"send message",onClick:Y,disabled:L,color:"primary",children:(0,e.jsx)(N,{name:"send"})})})})]})]})}));q.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const T=q,z=require("@mui/material/LinearProgress");var _=i.n(z);const R=require("axios");var I=i.n(R);const M=require("react-dom"),D=require("@mui/material/Card");var A=i.n(D);const U=require("@mui/material/Modal");var B,L=i.n(U);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(B||(B={}));const W=require("@mui/material/useMediaQuery");var H=i.n(W);const V=require("@mui/system/Stack");var $=i.n(V);const G=require("@mui/system/useTheme");var K=i.n(G);const Q=require("pdfjs-dist"),Y=function(r){var n={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=(n[r.action].label.replaceAll(" ","-").toLowerCase(),n[r.action]);return(0,e.jsx)(w(),{title:t.label,children:(0,e.jsx)("span",{children:(0,e.jsx)(u(),{onClick:r.onClick,className:r.className,disabled:r.isDisabled,children:(0,e.jsx)(N,{name:t.symbol})})})})};var Z={pdf:function(r){var i,o=(0,t.useRef)(null),a=(0,t.useState)(1),c=a[0],s=a[1],l=(0,t.useState)(1),u=l[0],d=l[1],f=(0,t.useState)(1),m=f[0],p=f[1],h=(0,t.useState)(!1),v=h[0],g=h[1],x=(0,t.useState)(),j=x[0],y=x[1],w=K()(),S=H()(w.breakpoints.down("sm")),k=H()(w.breakpoints.between("sm","md"));if(i=r.url,!/\/[^/]+\.pdf$/.test(i))return(0,e.jsx)(A(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(C(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var N=(0,t.useState)((function(){return S?.5:k?1:1.5})),F=N[0],P=N[1];return(0,t.useEffect)((function(){Q.GlobalWorkerOptions.workerSrc||(Q.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(Q.version,"/pdf.worker.mjs")),Q.getDocument({url:"".concat(r.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(c).then((function(e){var r=e.getViewport({scale:F}),n=o.current;if(n){var t=n.getContext("2d");if(t){var i=window.devicePixelRatio||1;n.style.width="".concat(r.width,"px"),n.style.height="".concat(r.height,"px"),n.width=r.width*i,n.height=r.height*i;var a={canvasContext:t,viewport:r,transform:[i,0,0,i,0,0]};j&&j.cancel();var c=e.render(a);y(c),c.promise.then((function(){y(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[r.url,c,F]),v?(0,e.jsx)(A(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(C(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,e.jsxs)(A(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,e.jsxs)(n(),{className:"rustic-pdf-viewer-header",children:[(0,e.jsx)(Y,{action:"zoomOut",onClick:function(){P((function(e){return Math.max(e-.2,.2)}))}}),(0,e.jsx)(Y,{action:"zoomIn",onClick:function(){P((function(e){return e+.2}))}})]}),(0,e.jsx)(n(),{className:"rustic-pdf-viewer-body",children:(0,e.jsx)(n(),{className:"rustic-pdf-viewer-body-inner",children:(0,e.jsx)("canvas",{ref:o})})}),(0,e.jsxs)($(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,e.jsx)(Y,{action:"previousPage",onClick:function(){c>1&&(s(c-1),p(c-1))},isDisabled:1===c}),(0,e.jsx)(C(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,e.jsx)(b(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=u&&s(r)},size:"small",className:"rustic-pdf-page-input"}),(0,e.jsxs)(C(),{variant:"body1",className:"rustic-page-indicator",children:["of ",u]}),(0,e.jsx)(Y,{action:"nextPage",onClick:function(){c<u&&(s(c+1),p(c+1))},isDisabled:c===u})]})]})}};function J(r){var n=(0,F.useTheme)(),i=(0,t.useState)(!1),o=i[0],a=i[1];function c(){a(!1)}var s,l,d=r.file.url&&(s=r.file.url.split("."))[s.length-1].toLowerCase(),f=d&&r.supportedViewers?r.supportedViewers[d]:null,m=!!f;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(A(),{className:"rustic-file-preview".concat(m?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:n.shadows[1]},onClick:function(){a(!0)},children:[(0,e.jsx)(C(),{variant:"subtitle2",children:(l=r.file.name,15,l.length<=15?l:l.substring(0,12)+"...")}),(0,e.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:r.children})]}),m&&(0,e.jsx)(L(),{open:o,onClose:c,className:"rustic-file-preview-modal",children:(0,e.jsxs)("div",{className:"rustic-modal-content",children:[(0,e.jsx)(w(),{title:"Close",children:(0,e.jsx)(u(),{onClick:c,className:"rustic-close-button",children:(0,e.jsx)(N,{name:"close"})})}),r.file.url&&(0,e.jsx)(f,{url:r.file.url})]})})]})}J.defaultProps={supportedViewers:Z};var X=function(){return X=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},X.apply(this,arguments)},ee=function(e,r,n){if(n||2===arguments.length)for(var t,i=0,o=r.length;i<o;i++)!t&&i in r||(t||(t=Array.prototype.slice.call(r,0,i)),t[i]=r[i]);return e.concat(t||Array.prototype.slice.call(r))};function re(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 ne=function(r){var i=(0,t.useState)([]),o=i[0],c=i[1],s=(0,t.useState)([]),l=s[0],d=s[1],f=(0,t.useRef)({}),m=(0,a.v4)();(0,t.useEffect)((function(){c([]),d([]),f.current={}}),[r.messageId]);var p=(0,e.jsx)(n(),{className:"rustic-files rustic-padding-16",children:o.map((function(t,i){return(0,e.jsx)(J,{file:{name:t.name},children:(0,e.jsxs)(n(),{className:"rustic-flex-center",children:[t.loadingProgress<100&&(0,e.jsx)(_(),{variant:"determinate",color:"secondary",value:t.loadingProgress,className:"rustic-upload-progress"}),(0,e.jsx)(w(),{title:"Delete",children:(0,e.jsx)(u(),{color:"primary",onClick:function(){return function(e,n){var t,i;d([]);var o=e.name;if(f.current=X(X({},f.current),((t={})[o]=f.current[o]--,t)),r.onFileUpdate("remove",o),100===e.loadingProgress){var a="".concat(r.deleteFileEndpoint,"?message-id=").concat(r.messageId,"&file-id=").concat(e.id);I().delete(a).then((function(){return c((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return r.onFileUpdate("add",o),d((function(e){return ee(ee([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else e.abortController.abort(),c((function(e){return e.filter((function(e,r){return r!==n}))})),f.current=X(X({},f.current),((i={})[o]=f.current[o]++,i))}(t,i)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},i)}))}),h=(0,e.jsx)(n(),{children:l.map((function(r,n){return(0,e.jsx)(C(),{variant:"caption",color:"error",className:"rustic-error-message",children:r},n)}))});function v(e,r){return r?(0,M.createPortal)(e,r):e}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(n(),{className:"rustic-uploader",children:[(0,e.jsx)("label",{htmlFor:m,children:(0,e.jsx)(w(),{title:"Upload",children:(0,e.jsx)(u(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,e.jsx)("input",{type:"file",id:m,onChange:function(e){d([]);var n=e.target.files&&Array.from(e.target.files),t=o.length+(n?n.length:0);r.maxFileCount&&t>r.maxFileCount&&d((function(e){return ee(ee([],e,!0),["You can only upload ".concat(r.maxFileCount," files.")],!1)}));var i=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,t,r.maxFileCount);i&&i.forEach((function(e){!function(e){var n;r.maxFileSize&&e.size>r.maxFileSize?(n=e.name,d((function(e){return ee(ee([],e,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(r.maxFileSize&&re(r.maxFileSize),".")],!1)}))):function(e){var n=new FormData,t=new AbortController,i=function(e){var r,n,t=e.name,i=f.current[t];if(i){var o=i+1,a=t.lastIndexOf("."),c=t.substring(0,a),s=t.substring(a);t="".concat(c,"(").concat(i,")").concat(s),f.current=X(X({},f.current),((r={})[e.name]=o,r))}else f.current=X(X({},f.current),((n={})[e.name]=1,n));return t}(e),o=new File([e],i,{type:e.type});n.append("file",o);var s=(0,a.v4)(),l={name:i,loadingProgress:0,abortController:t,id:s};c((function(e){return ee(ee([],e,!0),[l],!1)})),r.onFileUpdate("add",i);var u="".concat(r.uploadFileEndpoint,"?message-id=").concat(r.messageId);I().post(u,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=l.id,c((function(e){var t=e.map((function(e){return e.id===n?X(X({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;r=e.data,n=l.id,c((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var i=ee([],e,!0);return i[t]=X(X({},i[t]),{id:r.fileId}),i}return e}))})).catch((function(n){var t,o;r.onFileUpdate("remove",i),f.current=X(X({},f.current),((t={})[i]=f.current[e.name]--,t)),function(e,r,n){d((function(r){return ee(ee([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),c((function(e){return e.filter((function(e){return e.id!==r}))}))}(e.name,l.id,null===(o=n.response)||void 0===o?void 0:o.data)}))}(e)}(e)})),e.target.value=""},multiple:!0,accept:r.acceptedFileTypes})]}),l.length>0&&v(h,r.errorMessagesContainer),o.length>0&&v(p,r.filePreviewsContainer)]})};var te=function(){return te=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},te.apply(this,arguments)},ie=function(e,r,n){if(n||2===arguments.length)for(var t,i=0,o=r.length;i<o;i++)!t&&i in r||(t||(t=Array.prototype.slice.call(r,0,i)),t[i]=r[i]);return e.concat(t||Array.prototype.slice.call(r))};function oe(r){var i=(0,t.useState)([]),o=i[0],c=i[1],s=(0,t.useState)((0,a.v4)()),l=s[0],u=s[1],d=(0,t.useState)(),f=d[0],m=d[1],p=(0,t.useState)(),h=p[0],v=p[1],g=(0,t.useRef)(null),x=o.length>0;return(0,t.useEffect)((function(){g.current&&(v(g.current.querySelector(".rustic-error-container")),m(g.current.querySelector(".rustic-input-extras")))})),(0,e.jsx)(n(),{className:"rustic-multimodal-input",children:(0,e.jsx)(T,te({},r,{send:function(e){x&&(e.id=l,e.format="filesWithText",e.data.files=o),r.ws.send(e),u((0,a.v4)()),c([])},isSendEnabled:x,ref:g,children:(0,e.jsx)(n(),{className:"rustic-bottom-buttons",children:(0,e.jsx)(ne,{acceptedFileTypes:r.acceptedFileTypes,maxFileCount:r.maxFileCount,maxFileSize:r.maxFileSize,uploadFileEndpoint:r.uploadFileEndpoint,deleteFileEndpoint:r.deleteFileEndpoint,onFileUpdate:function(e,r){c("add"===e?function(e){return ie(ie([],e,!0),[{name:r}],!1)}:function(e){return e.filter((function(e){return e.name!==r}))})},messageId:l,filePreviewsContainer:f,errorMessagesContainer:h})})}))})}oe.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const ae=oe})(),o})()));
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var n=r&&r.__esModule?()=>r.default:()=>r;return e.d(n,{a:n}),n},d:(r,n)=>{for(var t in n)e.o(n,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:n[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{ParticipantRole:()=>R,ParticipantType:()=>B,default:()=>H});const n=require("react/jsx-runtime"),t=require("@mui/material/Box");var a=e.n(t);const i=require("@mui/material/IconButton");var o=e.n(i);const s=require("@mui/material/LinearProgress");var c=e.n(s);const l=require("@mui/material/Tooltip");var u=e.n(l);const d=require("@mui/material/Typography");var m=e.n(d);const f=require("axios");var p=e.n(f);const v=require("react"),h=require("react-dom"),g=require("uuid"),x=require("@mui/material/Card");var b=e.n(x);const j=require("@mui/material/Modal");var y=e.n(j);const w=require("@mui/material/styles");var N;function C(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}require("pluralize"),function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(N||(N={}));const P=require("@mui/material/TextField");var F=e.n(P);const S=require("@mui/material/useMediaQuery");var k=e.n(S);const q=require("@mui/system/Stack");var O=e.n(q);const T=require("@mui/system/useTheme");var z=e.n(T);const _=require("pdfjs-dist"),I=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,n.jsx)(u(),{title:t.label,children:(0,n.jsx)("span",{children:(0,n.jsx)(o(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,n.jsx)(C,{name:t.symbol})})})})};var M={pdf:function(e){var r,t=(0,v.useRef)(null),i=(0,v.useState)(1),o=i[0],s=i[1],c=(0,v.useState)(1),l=c[0],u=c[1],d=(0,v.useState)(1),f=d[0],p=d[1],h=(0,v.useState)(!1),g=h[0],x=h[1],j=(0,v.useState)(),y=j[0],w=j[1],N=z()(),C=k()(N.breakpoints.down("sm")),P=k()(N.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,n.jsx)(b(),{variant:"outlined",className:"rustic-pdf-error",children:(0,n.jsx)(m(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var S=(0,v.useState)((function(){return C?.5:P?1:1.5})),q=S[0],T=S[1];return(0,v.useEffect)((function(){_.GlobalWorkerOptions.workerSrc||(_.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(_.version,"/pdf.worker.mjs")),_.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:q}),n=t.current;if(n){var a=n.getContext("2d");if(a){var i=window.devicePixelRatio||1;n.style.width="".concat(r.width,"px"),n.style.height="".concat(r.height,"px"),n.width=r.width*i,n.height=r.height*i;var o={canvasContext:a,viewport:r,transform:[i,0,0,i,0,0]};y&&y.cancel();var s=e.render(o);w(s),s.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){x(!0)}))}),[e.url,o,q]),g?(0,n.jsx)(b(),{variant:"outlined",className:"rustic-pdf-error",children:(0,n.jsx)(m(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,n.jsxs)(b(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,n.jsxs)(a(),{className:"rustic-pdf-viewer-header",children:[(0,n.jsx)(I,{action:"zoomOut",onClick:function(){T((function(e){return Math.max(e-.2,.2)}))}}),(0,n.jsx)(I,{action:"zoomIn",onClick:function(){T((function(e){return e+.2}))}})]}),(0,n.jsx)(a(),{className:"rustic-pdf-viewer-body",children:(0,n.jsx)(a(),{className:"rustic-pdf-viewer-body-inner",children:(0,n.jsx)("canvas",{ref:t})})}),(0,n.jsxs)(O(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,n.jsx)(I,{action:"previousPage",onClick:function(){o>1&&(s(o-1),p(o-1))},isDisabled:1===o}),(0,n.jsx)(m(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,n.jsx)(F(),{type:"number",value:f,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=l&&s(r)},size:"small",className:"rustic-pdf-page-input"}),(0,n.jsxs)(m(),{variant:"body1",className:"rustic-page-indicator",children:["of ",l]}),(0,n.jsx)(I,{action:"nextPage",onClick:function(){o<l&&(s(o+1),p(o+1))},isDisabled:o===l})]})]})}};function D(e){var r=(0,w.useTheme)(),t=(0,v.useState)(!1),a=t[0],i=t[1];function s(){i(!1)}var c,l,d=e.file.url&&(c=e.file.url.split("."))[c.length-1].toLowerCase(),f=d&&e.supportedViewers?e.supportedViewers[d]:null,p=!!f;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(b(),{className:"rustic-file-preview".concat(p?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){i(!0)},children:[(0,n.jsx)(m(),{variant:"subtitle2",children:(l=e.file.name,15,l.length<=15?l:l.substring(0,12)+"...")}),(0,n.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,n.jsx)(y(),{open:a,onClose:s,className:"rustic-file-preview-modal",children:(0,n.jsxs)("div",{className:"rustic-modal-content",children:[(0,n.jsx)(u(),{title:"Close",children:(0,n.jsx)(o(),{onClick:s,className:"rustic-close-button",children:(0,n.jsx)(C,{name:"close"})})}),e.file.url&&(0,n.jsx)(f,{url:e.file.url})]})})]})}D.defaultProps={supportedViewers:M};var U=function(){return U=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},U.apply(this,arguments)},A=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,i=r.length;a<i;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 E(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}var R,B;!function(e){e.Owner="owner",e.Member="member"}(R||(R={})),function(e){e.Human="human",e.Agent="agent"}(B||(B={}));const H=function(e){var r=(0,v.useState)([]),t=r[0],i=r[1],s=(0,v.useState)([]),l=s[0],d=s[1],f=(0,v.useRef)({}),x=(0,g.v4)();(0,v.useEffect)((function(){i([]),d([]),f.current={}}),[e.messageId]);var b=(0,n.jsx)(a(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,t){return(0,n.jsx)(D,{file:{name:r.name},children:(0,n.jsxs)(a(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,n.jsx)(c(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,n.jsx)(u(),{title:"Delete",children:(0,n.jsx)(o(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var o=r.name;if(f.current=U(U({},f.current),((t={})[o]=f.current[o]--,t)),e.onFileUpdate("remove",o),100===r.loadingProgress){var s="".concat(e.deleteFileEndpoint,"?message-id=").concat(e.messageId,"&file-id=").concat(r.id);p().delete(s).then((function(){return i((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",o),d((function(e){return A(A([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else r.abortController.abort(),i((function(e){return e.filter((function(e,r){return r!==n}))})),f.current=U(U({},f.current),((a={})[o]=f.current[o]++,a))}(r,t)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,n.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},t)}))}),j=(0,n.jsx)(a(),{children:l.map((function(e,r){return(0,n.jsx)(m(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function y(e,r){return r?(0,h.createPortal)(e,r):e}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(a(),{className:"rustic-uploader",children:[(0,n.jsx)("label",{htmlFor:x,children:(0,n.jsx)(u(),{title:"Upload",children:(0,n.jsx)(o(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,n.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,n.jsx)("input",{type:"file",id:x,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 A(A([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var o=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);o&&o.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,d((function(r){return A(A([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&E(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,a=f.current[t];if(a){var i=a+1,o=t.lastIndexOf("."),s=t.substring(0,o),c=t.substring(o);t="".concat(s,"(").concat(a,")").concat(c),f.current=U(U({},f.current),((r={})[e.name]=i,r))}else f.current=U(U({},f.current),((n={})[e.name]=1,n));return t}(r),o=new File([r],a,{type:r.type});n.append("file",o);var s=(0,g.v4)(),c={name:a,loadingProgress:0,abortController:t,id:s};i((function(e){return A(A([],e,!0),[c],!1)})),e.onFileUpdate("add",a);var l="".concat(e.uploadFileEndpoint,"?message-id=").concat(e.messageId);p().post(l,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=c.id,i((function(e){var t=e.map((function(e){return e.id===n?U(U({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;r=e.data,n=c.id,i((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=A([],e,!0);return a[t]=U(U({},a[t]),{id:r.fileId}),a}return e}))})).catch((function(n){var t,o;e.onFileUpdate("remove",a),f.current=U(U({},f.current),((t={})[a]=f.current[r.name]--,t)),function(e,r,n){d((function(r){return A(A([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),i((function(e){return e.filter((function(e){return e.id!==r}))}))}(r.name,c.id,null===(o=n.response)||void 0===o?void 0:o.data)}))}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),l.length>0&&y(j,e.errorMessagesContainer),t.length>0&&y(b,e.filePreviewsContainer)]})};return r})()));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var n=r&&r.__esModule?()=>r.default:()=>r;return e.d(n,{a:n}),n},d:(r,n)=>{for(var t in n)e.o(n,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:n[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{default:()=>B});const n=require("react/jsx-runtime"),t=require("@mui/material/Box");var a=e.n(t);const i=require("@mui/material/IconButton");var o=e.n(i);const s=require("@mui/material/LinearProgress");var c=e.n(s);const l=require("@mui/material/Tooltip");var u=e.n(l);const d=require("@mui/material/Typography");var f=e.n(d);const m=require("axios");var p=e.n(m);const v=require("react"),h=require("react-dom"),x=require("uuid"),g=require("@mui/material/Card");var j=e.n(g);const b=require("@mui/material/Modal");var y=e.n(b);const w=require("@mui/material/styles");var N;function C(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(N||(N={}));const F=require("@mui/material/TextField");var P=e.n(F);const S=require("@mui/material/useMediaQuery");var k=e.n(S);const q=require("@mui/system/Stack");var O=e.n(q);const T=require("@mui/system/useTheme");var z=e.n(T);const _=require("pdfjs-dist"),I=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,n.jsx)(u(),{title:t.label,children:(0,n.jsx)("span",{children:(0,n.jsx)(o(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,n.jsx)(C,{name:t.symbol})})})})};var D={pdf:function(e){var r,t=(0,v.useRef)(null),i=(0,v.useState)(1),o=i[0],s=i[1],c=(0,v.useState)(1),l=c[0],u=c[1],d=(0,v.useState)(1),m=d[0],p=d[1],h=(0,v.useState)(!1),x=h[0],g=h[1],b=(0,v.useState)(),y=b[0],w=b[1],N=z()(),C=k()(N.breakpoints.down("sm")),F=k()(N.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,n.jsx)(j(),{variant:"outlined",className:"rustic-pdf-error",children:(0,n.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var S=(0,v.useState)((function(){return C?.5:F?1:1.5})),q=S[0],T=S[1];return(0,v.useEffect)((function(){_.GlobalWorkerOptions.workerSrc||(_.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(_.version,"/pdf.worker.mjs")),_.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:q}),n=t.current;if(n){var a=n.getContext("2d");if(a){var i=window.devicePixelRatio||1;n.style.width="".concat(r.width,"px"),n.style.height="".concat(r.height,"px"),n.width=r.width*i,n.height=r.height*i;var o={canvasContext:a,viewport:r,transform:[i,0,0,i,0,0]};y&&y.cancel();var s=e.render(o);w(s),s.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[e.url,o,q]),x?(0,n.jsx)(j(),{variant:"outlined",className:"rustic-pdf-error",children:(0,n.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,n.jsxs)(j(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,n.jsxs)(a(),{className:"rustic-pdf-viewer-header",children:[(0,n.jsx)(I,{action:"zoomOut",onClick:function(){T((function(e){return Math.max(e-.2,.2)}))}}),(0,n.jsx)(I,{action:"zoomIn",onClick:function(){T((function(e){return e+.2}))}})]}),(0,n.jsx)(a(),{className:"rustic-pdf-viewer-body",children:(0,n.jsx)(a(),{className:"rustic-pdf-viewer-body-inner",children:(0,n.jsx)("canvas",{ref:t})})}),(0,n.jsxs)(O(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,n.jsx)(I,{action:"previousPage",onClick:function(){o>1&&(s(o-1),p(o-1))},isDisabled:1===o}),(0,n.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,n.jsx)(P(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=l&&s(r)},size:"small",className:"rustic-pdf-page-input"}),(0,n.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",l]}),(0,n.jsx)(I,{action:"nextPage",onClick:function(){o<l&&(s(o+1),p(o+1))},isDisabled:o===l})]})]})}};function M(e){var r=(0,w.useTheme)(),t=(0,v.useState)(!1),a=t[0],i=t[1];function s(){i(!1)}var c,l,d=e.file.url&&(c=e.file.url.split("."))[c.length-1].toLowerCase(),m=d&&e.supportedViewers?e.supportedViewers[d]:null,p=!!m;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(j(),{className:"rustic-file-preview".concat(p?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){i(!0)},children:[(0,n.jsx)(f(),{variant:"subtitle2",children:(l=e.file.name,15,l.length<=15?l:l.substring(0,12)+"...")}),(0,n.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,n.jsx)(y(),{open:a,onClose:s,className:"rustic-file-preview-modal",children:(0,n.jsxs)("div",{className:"rustic-modal-content",children:[(0,n.jsx)(u(),{title:"Close",children:(0,n.jsx)(o(),{onClick:s,className:"rustic-close-button",children:(0,n.jsx)(C,{name:"close"})})}),e.file.url&&(0,n.jsx)(m,{url:e.file.url})]})})]})}M.defaultProps={supportedViewers:D};var U=function(){return U=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},U.apply(this,arguments)},A=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,i=r.length;a<i;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 E(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 B=function(e){var r=(0,v.useState)([]),t=r[0],i=r[1],s=(0,v.useState)([]),l=s[0],d=s[1],m=(0,v.useRef)({}),g=(0,x.v4)();(0,v.useEffect)((function(){i([]),d([]),m.current={}}),[e.messageId]);var j=(0,n.jsx)(a(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,t){return(0,n.jsx)(M,{file:{name:r.name},children:(0,n.jsxs)(a(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,n.jsx)(c(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,n.jsx)(u(),{title:"Delete",children:(0,n.jsx)(o(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var o=r.name;if(m.current=U(U({},m.current),((t={})[o]=m.current[o]--,t)),e.onFileUpdate("remove",o),100===r.loadingProgress){var s="".concat(e.deleteFileEndpoint,"?message-id=").concat(e.messageId,"&file-id=").concat(r.id);p().delete(s).then((function(){return i((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",o),d((function(e){return A(A([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else r.abortController.abort(),i((function(e){return e.filter((function(e,r){return r!==n}))})),m.current=U(U({},m.current),((a={})[o]=m.current[o]++,a))}(r,t)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,n.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},t)}))}),b=(0,n.jsx)(a(),{children:l.map((function(e,r){return(0,n.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function y(e,r){return r?(0,h.createPortal)(e,r):e}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(a(),{className:"rustic-uploader",children:[(0,n.jsx)("label",{htmlFor:g,children:(0,n.jsx)(u(),{title:"Upload",children:(0,n.jsx)(o(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,n.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,n.jsx)("input",{type:"file",id:g,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 A(A([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var o=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);o&&o.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,d((function(r){return A(A([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&E(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,a=m.current[t];if(a){var i=a+1,o=t.lastIndexOf("."),s=t.substring(0,o),c=t.substring(o);t="".concat(s,"(").concat(a,")").concat(c),m.current=U(U({},m.current),((r={})[e.name]=i,r))}else m.current=U(U({},m.current),((n={})[e.name]=1,n));return t}(r),o=new File([r],a,{type:r.type});n.append("file",o);var s=(0,x.v4)(),c={name:a,loadingProgress:0,abortController:t,id:s};i((function(e){return A(A([],e,!0),[c],!1)})),e.onFileUpdate("add",a);var l="".concat(e.uploadFileEndpoint,"?message-id=").concat(e.messageId);p().post(l,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=c.id,i((function(e){var t=e.map((function(e){return e.id===n?U(U({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;r=e.data,n=c.id,i((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=A([],e,!0);return a[t]=U(U({},a[t]),{id:r.fileId}),a}return e}))})).catch((function(n){var t,o;e.onFileUpdate("remove",a),m.current=U(U({},m.current),((t={})[a]=m.current[r.name]--,t)),function(e,r,n){d((function(r){return A(A([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),i((function(e){return e.filter((function(e){return e.id!==r}))}))}(r.name,c.id,null===(o=n.response)||void 0===o?void 0:o.data)}))}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),l.length>0&&y(b,e.errorMessagesContainer),t.length>0&&y(j,e.filePreviewsContainer)]})};return r})()));
@@ -39,6 +39,10 @@
39
39
  margin: 10px 8px;
40
40
  }
41
41
 
42
+ .rustic-base-input .rustic-input-actions {
43
+ display: flex;
44
+ }
45
+
42
46
  span.rustic-icon-large {
43
47
  font-size: 32px;
44
48
  }
@@ -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={13: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={};return(()=>{o.r(i),o.d(i,{ParticipantRole:()=>R,ParticipantType:()=>I,default:()=>M});const e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Box");var n=o.n(t);const a=require("@mui/material/CircularProgress");var c=o.n(a);const s=require("@mui/material/IconButton");var u=o.n(s);const l=require("@mui/material/InputAdornment");var d=o.n(l);const p=require("@mui/material/MenuItem");var m=o.n(p);const f=require("@mui/material/MenuList");var h=o.n(f);const v=require("@mui/material/Popover");var g=o.n(v);const y=require("@mui/material/TextField");var b=o.n(y);const j=require("@mui/material/Tooltip");var x=o.n(j);const w=require("@mui/material/Typography");var O=o.n(w),S=o(13);const k=require("uuid");function P(r){return r.name.replaceAll("_","-"),(0,e.jsx)("span",{className:"".concat(r.className?r.className+" ":"","material-symbols-rounded"),children:r.name})}const C=require("@mui/material/styles"),E=function(t){var n=(0,C.useTheme)(),i=(0,r.useRef)(null),a=(0,r.useRef)(null),c=(0,r.useState)(!1),s=c[0],l=c[1],d={"--indicator-color":n.palette.divider,"--background":n.palette.background.paper,"--input-border-color":n.palette.divider,"--outline-color":n.palette.secondary.main};function p(){l(!1)}function m(e){e.detail.unicode&&t.onEmojiClick(e.detail.unicode),p()}return(0,r.useEffect)((function(){a.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,13,23)).then((function(e){var r=new(0,e.Picker),t="dark"===n.palette.mode?"dark":"light";r.classList.add(t),Object.keys(d).forEach((function(e){r.style.setProperty(e,d[e])})),a.current=r})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,r.useEffect)((function(){return a.current&&a.current.addEventListener("emoji-click",m),function(){var e;null===(e=a.current)||void 0===e||e.removeEventListener("emoji-click",m)}}),[s,t.onEmojiClick]),(0,e.jsxs)("div",{children:[(0,e.jsx)(x(),{title:"Emoji",children:(0,e.jsx)(u(),{size:"small",ref:i,onClick:function(){l((function(e){return!e}))},sx:{color:t.buttonColor},children:(0,e.jsx)(P,{name:"Mood"})})}),a.current&&(0,e.jsx)(g(),{open:s,anchorEl:i.current,onClose:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,e.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&a.current&&!e.contains(a.current)&&e.appendChild(a.current)}})})]})};var q={"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 N(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var T=(0,r.forwardRef)((function(t,o){var i=(0,r.useState)(""),a=i[0],s=i[1],l=(0,r.useState)(!1),p=l[0],f=l[1],v=(0,r.useState)(!1),y=v[0],j=v[1],w=(0,r.useState)(!1),C=w[0],T=w[1],_=(0,r.useState)(""),R=_[0],I=_[1],z=(0,r.useState)([]),M=z[0],A=z[1],B=(0,r.useState)(!1),F=B[0],L=B[1],D=(0,r.useRef)(null),W=!a.trim().length&&!t.isSendEnabled,K="".concat(p?"Stop":"Start"," speech to text"),$=y?"primary.main":"primary.light",H=p?"error.main":$,Q=p?"stop_circle":"speech_to_text";function G(e,r){if(void 0===r&&(r=!1),D.current){var t=D.current,n=t.selectionStart,o=t.selectionEnd;if("number"==typeof n&&"number"==typeof o){var i,c=a||"",u=c.substring(0,n),l=c.substring(o);i=r?u.replace(/:(\w+)$/,e)+l:u+e+l,s(i);var d=r?u.replace(/:(\w+)$/,e).length:n+e.length;setTimeout((function(){var e,r;null===(e=D.current)||void 0===e||e.focus(),null===(r=D.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}L(!1)}var J=new S.Database,U=C?(0,e.jsx)(c(),{size:24}):(0,e.jsx)(x(),{title:K,children:(0,e.jsx)(u(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,p?(e.stop(),T(!0),f(!1)):(e.start(),I(""),f(!0)),e.onstart=function(){f(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;a.length>0?s(a+" "+t):s(t),null===(r=D.current)||void 0===r||r.focus(),f(!1)},e.onerror=function(e){var r=q[e.error];I(r),f(!1)},e.onend=function(){T(!1),f(!1)}},size:"small",sx:{color:H},children:(0,e.jsx)(P,{name:Q})})});function V(){var e=(new Date).toISOString(),r={id:(0,k.v4)(),timestamp:e,sender:t.sender,conversationId:t.conversationId,format:"text",data:{text:a}};t.send(r),s(""),I("")}return(0,e.jsxs)(n(),{className:"rustic-base-input",ref:o,children:[(0,e.jsxs)(n(),{className:"rustic-error-and-input-container",children:[(0,e.jsx)(n(),{className:"rustic-error-container",children:(0,e.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:R})}),(0,e.jsxs)(n(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:y?"secondary.main":"action.disabled"},children:[M.length>0&&(0,e.jsx)(g(),{open:F,anchorEl:D.current,onClose:function(){return L(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,e.jsx)(h(),{children:M.map((function(r,t){return"unicode"in r&&(0,e.jsx)(m(),{onClick:function(){return G(r.unicode,!0)},children:N(r)},t)}))})}),(0,e.jsx)(b(),{className:"rustic-text-field",variant:"outlined",value:a,label:t.label,placeholder:t.placeholder,maxRows:t.maxRows,multiline:t.multiline,fullWidth:t.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!W&&V())},onChange:function(e){I("");var r=e.target.value;s(r);var n,o=r.match(/:(\w{2,}):/g),i=r.match(/:(\w{2,})/g);if(o){var a=o[0].replace(/:/g,"");J.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var t=r.replace(o[0],e.unicode);s(t)}else s(r)})).catch((function(){s(r)})),L(!1)}else i?(n=i[0].replace(":",""),J.getEmojiBySearchQuery(n).then((function(e){e.length?(A(e.slice(0,t.maximumEmojiSearchResults)),L(!0)):(A([]),L(!1))})).catch((function(){A([]),L(!1)}))):L(!1)},onFocus:function(){return j(!0)},onBlur:function(){return j(!1)},inputRef:D,color:"secondary",size:"small",InputProps:{endAdornment:(0,e.jsxs)(d(),{position:"end",children:[(0,e.jsx)(E,{onEmojiClick:G,buttonColor:$}),t.enableSpeechToText&&U]})},InputLabelProps:{className:y?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,e.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,e.jsxs)(n(),{className:"rustic-input-actions",children:[t.children,(0,e.jsx)(x(),{title:"Send",children:(0,e.jsx)("span",{className:"rustic-send-button",children:(0,e.jsx)(u(),{"aria-label":"send message",onClick:V,disabled:W,color:"primary",children:(0,e.jsx)(P,{name:"send"})})})})]})]})}));T.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const _=T;var R,I,z=function(){return z=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},z.apply(this,arguments)};!function(e){e.Owner="owner",e.Member="member"}(R||(R={})),function(e){e.Human="human",e.Agent="agent"}(I||(I={}));const M=function(r){var t=r.ws,n=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}(r,["ws"]);return(0,e.jsx)(_,z({},n,{send:function(e){t.send(e)}}))}})(),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={13: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={};return(()=>{o.r(i),o.d(i,{default:()=>I});const e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Box");var n=o.n(t);const a=require("@mui/material/CircularProgress");var c=o.n(a);const s=require("@mui/material/IconButton");var u=o.n(s);const l=require("@mui/material/InputAdornment");var d=o.n(l);const p=require("@mui/material/MenuItem");var m=o.n(p);const f=require("@mui/material/MenuList");var h=o.n(f);const v=require("@mui/material/Popover");var g=o.n(v);const y=require("@mui/material/TextField");var b=o.n(y);const j=require("@mui/material/Tooltip");var x=o.n(j);const w=require("@mui/material/Typography");var S=o.n(w),O=o(13);const k=require("uuid");function C(r){return r.name.replaceAll("_","-"),(0,e.jsx)("span",{className:"".concat(r.className?r.className+" ":"","material-symbols-rounded"),children:r.name})}const E=require("@mui/material/styles"),P=function(t){var n=(0,E.useTheme)(),i=(0,r.useRef)(null),a=(0,r.useRef)(null),c=(0,r.useState)(!1),s=c[0],l=c[1],d={"--indicator-color":n.palette.divider,"--background":n.palette.background.paper,"--input-border-color":n.palette.divider,"--outline-color":n.palette.secondary.main};function p(){l(!1)}function m(e){e.detail.unicode&&t.onEmojiClick(e.detail.unicode),p()}return(0,r.useEffect)((function(){a.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,13,23)).then((function(e){var r=new(0,e.Picker),t="dark"===n.palette.mode?"dark":"light";r.classList.add(t),Object.keys(d).forEach((function(e){r.style.setProperty(e,d[e])})),a.current=r})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,r.useEffect)((function(){return a.current&&a.current.addEventListener("emoji-click",m),function(){var e;null===(e=a.current)||void 0===e||e.removeEventListener("emoji-click",m)}}),[s,t.onEmojiClick]),(0,e.jsxs)("div",{children:[(0,e.jsx)(x(),{title:"Emoji",children:(0,e.jsx)(u(),{size:"small",ref:i,onClick:function(){l((function(e){return!e}))},sx:{color:t.buttonColor},children:(0,e.jsx)(C,{name:"Mood"})})}),a.current&&(0,e.jsx)(g(),{open:s,anchorEl:i.current,onClose:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,e.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&a.current&&!e.contains(a.current)&&e.appendChild(a.current)}})})]})};var q={"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 N(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var T=(0,r.forwardRef)((function(t,o){var i=(0,r.useState)(""),a=i[0],s=i[1],l=(0,r.useState)(!1),p=l[0],f=l[1],v=(0,r.useState)(!1),y=v[0],j=v[1],w=(0,r.useState)(!1),E=w[0],T=w[1],_=(0,r.useState)(""),R=_[0],I=_[1],z=(0,r.useState)([]),M=z[0],B=z[1],F=(0,r.useState)(!1),L=F[0],A=F[1],D=(0,r.useRef)(null),W=!a.trim().length&&!t.isSendEnabled,K="".concat(p?"Stop":"Start"," speech to text"),$=y?"primary.main":"primary.light",Q=p?"error.main":$,G=p?"stop_circle":"speech_to_text";function H(e,r){if(void 0===r&&(r=!1),D.current){var t=D.current,n=t.selectionStart,o=t.selectionEnd;if("number"==typeof n&&"number"==typeof o){var i,c=a||"",u=c.substring(0,n),l=c.substring(o);i=r?u.replace(/:(\w+)$/,e)+l:u+e+l,s(i);var d=r?u.replace(/:(\w+)$/,e).length:n+e.length;setTimeout((function(){var e,r;null===(e=D.current)||void 0===e||e.focus(),null===(r=D.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}A(!1)}var J=new O.Database,U=E?(0,e.jsx)(c(),{size:24}):(0,e.jsx)(x(),{title:K,children:(0,e.jsx)(u(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,p?(e.stop(),T(!0),f(!1)):(e.start(),I(""),f(!0)),e.onstart=function(){f(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;a.length>0?s(a+" "+t):s(t),null===(r=D.current)||void 0===r||r.focus(),f(!1)},e.onerror=function(e){var r=q[e.error];I(r),f(!1)},e.onend=function(){T(!1),f(!1)}},size:"small",sx:{color:Q},children:(0,e.jsx)(C,{name:G})})});function V(){var e=(new Date).toISOString(),r={id:(0,k.v4)(),timestamp:e,sender:t.sender,conversationId:t.conversationId,format:"text",data:{text:a}};t.send(r),s(""),I("")}return(0,e.jsxs)(n(),{className:"rustic-base-input",ref:o,children:[(0,e.jsxs)(n(),{className:"rustic-error-and-input-container",children:[(0,e.jsx)(n(),{className:"rustic-error-container",children:(0,e.jsx)(S(),{variant:"caption",color:"error",className:"rustic-error-message",children:R})}),(0,e.jsxs)(n(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:y?"secondary.main":"action.disabled"},children:[M.length>0&&(0,e.jsx)(g(),{open:L,anchorEl:D.current,onClose:function(){return A(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,e.jsx)(h(),{children:M.map((function(r,t){return"unicode"in r&&(0,e.jsx)(m(),{onClick:function(){return H(r.unicode,!0)},children:N(r)},t)}))})}),(0,e.jsx)(b(),{className:"rustic-text-field",variant:"outlined",value:a,label:t.label,placeholder:t.placeholder,maxRows:t.maxRows,multiline:t.multiline,fullWidth:t.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!W&&V())},onChange:function(e){I("");var r=e.target.value;s(r);var n,o=r.match(/:(\w{2,}):/g),i=r.match(/:(\w{2,})/g);if(o){var a=o[0].replace(/:/g,"");J.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var t=r.replace(o[0],e.unicode);s(t)}else s(r)})).catch((function(){s(r)})),A(!1)}else i?(n=i[0].replace(":",""),J.getEmojiBySearchQuery(n).then((function(e){e.length?(B(e.slice(0,t.maximumEmojiSearchResults)),A(!0)):(B([]),A(!1))})).catch((function(){B([]),A(!1)}))):A(!1)},onFocus:function(){return j(!0)},onBlur:function(){return j(!1)},inputRef:D,color:"secondary",size:"small",InputProps:{endAdornment:(0,e.jsxs)(d(),{position:"end",children:[(0,e.jsx)(P,{onEmojiClick:H,buttonColor:$}),t.enableSpeechToText&&U]})},InputLabelProps:{className:y?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,e.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,e.jsxs)(n(),{className:"rustic-input-actions",children:[t.children,(0,e.jsx)(x(),{title:"Send",children:(0,e.jsx)("span",{className:"rustic-send-button",children:(0,e.jsx)(u(),{"aria-label":"send message",onClick:V,disabled:W,color:"primary",children:(0,e.jsx)(C,{name:"send"})})})})]})]})}));T.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const _=T;var R=function(){return R=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},R.apply(this,arguments)};const I=function(r){var t=r.ws,n=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}(r,["ws"]);return(0,e.jsx)(_,R({},n,{send:function(e){t.send(e)}}))}})(),i})()));
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var n=r&&r.__esModule?()=>r.default:()=>r;return e.d(n,{a:n}),n},d:(r,n)=>{for(var t in n)e.o(n,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:n[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{ParticipantRole:()=>x,ParticipantType:()=>q,default:()=>w});const n=require("react/jsx-runtime"),t=(require("ol/ol.css"),require("@mui/material/Alert"));var o=e.n(t);const a=require("@mui/material/Box");var i=e.n(a);const u=require("ol/layer/Tile.js");var l=e.n(u);const s=require("ol/Map.js");var c=e.n(s);const d=require("ol/Overlay.js");var m=e.n(d);const f=require("ol/proj.js"),p=require("ol/source/OSM.js");var v=e.n(p);const y=require("ol/View.js");var j=e.n(y);const g=require("react");function b(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}var x,q;!function(e){e.Owner="owner",e.Member="member"}(x||(x={})),function(e){e.Human="human",e.Agent="agent"}(q||(q={}));const w=function(e){var r=(0,g.useState)(""),t=r[0],a=r[1],u=(0,g.useRef)(null),s=(0,g.useRef)(null);return(0,g.useEffect)((function(){if(a(""),e.latitude<-90||e.latitude>90||e.longitude<-180||e.longitude>180)return a("Invalid coordinates");if(u.current&&s.current){var r=new(c())({layers:[new(l())({source:new(v())})],view:new(j())({center:(0,f.fromLonLat)([e.longitude,e.latitude]),zoom:12}),target:u.current}),n=new(m())({element:s.current,position:(0,f.fromLonLat)([e.longitude,e.latitude]),positioning:"bottom-center",stopEvent:!1});return r.addOverlay(n),r.once("postrender",(function(){var e;if(!(null===(e=u.current)||void 0===e?void 0:e.querySelector("canvas")))return a("An error occurred while loading the map")})),function(){r.setTarget(""),r.removeOverlay(n)}}}),[]),(0,n.jsx)(n.Fragment,{children:t.length>0?(0,n.jsx)(o(),{severity:"error",children:t}):(0,n.jsxs)(i(),{children:[(0,n.jsx)(i(),{ref:s,children:(0,n.jsx)(b,{className:"rustic-open-layers-map-marker",name:"location_on"})}),(0,n.jsx)("div",{ref:u,className:"rustic-open-layers-map-canvas"})]})})};return r})()));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{default:()=>x});const t=require("react/jsx-runtime"),n=(require("ol/ol.css"),require("@mui/material/Alert"));var o=e.n(n);const a=require("@mui/material/Box");var i=e.n(a);const l=require("ol/layer/Tile.js");var s=e.n(l);const u=require("ol/Map.js");var c=e.n(u);const d=require("ol/Overlay.js");var m=e.n(d);const f=require("ol/proj.js"),p=require("ol/source/OSM.js");var v=e.n(p);const y=require("ol/View.js");var j=e.n(y);const g=require("react");function b(e){return e.name.replaceAll("_","-"),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}const x=function(e){var r=(0,g.useState)(""),n=r[0],a=r[1],l=(0,g.useRef)(null),u=(0,g.useRef)(null);return(0,g.useEffect)((function(){if(a(""),e.latitude<-90||e.latitude>90||e.longitude<-180||e.longitude>180)return a("Invalid coordinates");if(l.current&&u.current){var r=new(c())({layers:[new(s())({source:new(v())})],view:new(j())({center:(0,f.fromLonLat)([e.longitude,e.latitude]),zoom:12}),target:l.current}),t=new(m())({element:u.current,position:(0,f.fromLonLat)([e.longitude,e.latitude]),positioning:"bottom-center",stopEvent:!1});return r.addOverlay(t),r.once("postrender",(function(){var e;if(!(null===(e=l.current)||void 0===e?void 0:e.querySelector("canvas")))return a("An error occurred while loading the map")})),function(){r.setTarget(""),r.removeOverlay(t)}}}),[]),(0,t.jsx)(t.Fragment,{children:n.length>0?(0,t.jsx)(o(),{severity:"error",children:n}):(0,t.jsxs)(i(),{children:[(0,t.jsx)(i(),{ref:u,children:(0,t.jsx)(b,{className:"rustic-open-layers-map-marker",name:"location_on"})}),(0,t.jsx)("div",{ref:l,className:"rustic-open-layers-map-canvas"})]})})};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={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MarkedMarkdown:()=>s,MarkedStreamingMarkdown:()=>l,ParticipantRole:()=>m,ParticipantType:()=>y,default:()=>g});const r=require("react/jsx-runtime"),a=require("@mui/material/Typography");var n=e.n(a);const o=require("dompurify");var u=e.n(o);const i=require("marked"),d=require("react");function c(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=i.marked.parse(t);return u().sanitize(r)}const s=function(e){var t=(0,d.useState)(c(e.text)),a=t[0],o=t[1];return(0,d.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var t=e.updatedData[e.updatedData.length-1].text;o(c(t))}}),[e.text,e.updatedData]),(0,r.jsx)(n(),{variant:"body2",dangerouslySetInnerHTML:{__html:a}})},f=require("@mui/material/Alert");var p=e.n(f);const l=function(e){var t=(0,d.useState)(c(e.text)),a=t[0],o=t[1],u=(0,d.useState)(""),i=u[0],s=u[1];return(0,d.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){for(var t=e.text,r=0,a=e.updatedData;r<a.length;r++){var n=a[r];"string"!=typeof n.text?(t+=" [MISSING TEXT]",s("Some of the incoming text was not correctly formatted. Some data may be missing.")):t+=n.text}o(c(t))}}),[e.text,e.updatedData]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n(),{variant:"body2",dangerouslySetInnerHTML:{__html:a}}),i&&(0,r.jsx)(p(),{severity:"error",children:i})]})};var m,y;!function(e){e.Owner="owner",e.Member="member"}(m||(m={})),function(e){e.Human="human",e.Agent="agent"}(y||(y={}));const g=s;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 r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MarkedMarkdown:()=>c,MarkedStreamingMarkdown:()=>p,default:()=>m});const r=require("react/jsx-runtime"),a=require("@mui/material/Typography");var n=e.n(a);const o=require("dompurify");var u=e.n(o);const d=require("marked"),i=require("react");function s(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=d.marked.parse(t);return u().sanitize(r)}const c=function(e){var t=(0,i.useState)(s(e.text)),a=t[0],o=t[1];return(0,i.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var t=e.updatedData[e.updatedData.length-1].text;o(s(t))}}),[e.text,e.updatedData]),(0,r.jsx)(n(),{variant:"body2",dangerouslySetInnerHTML:{__html:a}})},f=require("@mui/material/Alert");var l=e.n(f);const p=function(e){var t=(0,i.useState)(s(e.text)),a=t[0],o=t[1],u=(0,i.useState)(""),d=u[0],c=u[1];return(0,i.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){for(var t=e.text,r=0,a=e.updatedData;r<a.length;r++){var n=a[r];"string"!=typeof n.text?(t+=" [MISSING TEXT]",c("Some of the incoming text was not correctly formatted. Some data may be missing.")):t+=n.text}o(s(t))}}),[e.text,e.updatedData]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n(),{variant:"body2",dangerouslySetInnerHTML:{__html:a}}),d&&(0,r.jsx)(l(),{severity:"error",children:d})]})},m=c;return t})()));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var 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,{ParticipantRole:()=>L,ParticipantType:()=>R,default:()=>V});const n=require("react/jsx-runtime"),r=require("@mui/material"),a=require("@mui/material/Alert");var i=e.n(a);const s=require("@mui/material/CircularProgress");var o=e.n(s);const l=require("@mui/material/Typography");var c=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("@mui/material/Box");var f=e.n(d);const p=require("@mui/material/Button");var x=e.n(p);const v=require("@mui/material/LinearProgress");var b=e.n(v);const y=require("@mui/material/Slider");var j=e.n(y);const h=require("@mui/material/Tooltip");var E,g=e.n(h);function N(e){var t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60),a=t>0?"".concat(t,":"):"",i="".concat(t>0?n.toString().padStart(2,"0"):n),s=r.toString().padStart(2,"0");return"".concat(a).concat(i,":").concat(s)}function T(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}require("pluralize"),function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(E||(E={}));const S=require("@mui/material/IconButton");var _=e.n(S);function k(e){var t,r={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return r[e.action].label.replaceAll(" ","-").toLowerCase(),(0,n.jsx)(g(),{title:r[e.action].label,PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,n.jsx)(_(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,n.jsx)(T,{name:r[e.action].symbol,className:"rustic-icon-large"})})})}function P(e){var t="dark"===(0,r.useTheme)().palette.mode,a=N(e.mediaElement.currentTime);return(0,n.jsxs)(f(),{className:"rustic-progress",children:[function(){for(var r=e.mediaElement.buffered,a=0,i=r.length-1;i>=0;--i){var s=r.start(i),o=r.end(i);if(s<e.mediaElement.currentTime){a=o;break}}var l=a/e.mediaElement.duration*100;return(0,n.jsx)(b(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:t?"secondary.light":"action.selected"}}})}(),(0,n.jsx)(j(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(a),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(t,n){e.mediaElement.currentTime=n},valueLabelDisplay:"auto",valueLabelFormat:function(e){return N(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function w(e){var t=(0,m.useState)(e.mediaElement.volume),r=t[0],a=t[1],i=(0,m.useState)(e.mediaElement.volume),s=i[0],o=i[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,n.jsxs)(f(),{className:"rustic-volume-settings",children:[(0,n.jsx)(k,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(o(e.mediaElement.volume),a(0)):a(s)},className:"rustic-mute-button",action:l}),(0,n.jsx)(j(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*r,"%"),value:r,onChange:function(t,n){var r=n;e.mediaElement.muted=0===r,e.mediaElement.volume=r,a(e.mediaElement.volume)}})]})}function B(e){var t=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",r="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,n.jsx)(x(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,n.jsx)(T,{name:t}),children:(0,n.jsx)(c(),{variant:"overline",children:r})})}function C(e){var t=(0,m.useState)(!e.mediaElement.paused),r=t[0],a=t[1],i=r?"pause":"play";return e.mediaElement.onended=function(){a(!1)},e.mediaElement.onpause=function(){a(!1)},e.mediaElement.onplay=function(){a(!0)},(0,n.jsx)(k,{onClick:function(){r?e.mediaElement.pause():e.mediaElement.play().catch((function(t){e.onError("Failed to play the media. Error: ".concat(t.message))}))},action:i,className:"rustic-pause-play-icon"})}function O(e){var t,r=(0,m.useState)(e.mediaElement.playbackRate),a=r[0],i=r[1];return(0,n.jsx)(g(),{title:"Playback rate",PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,n.jsx)(x(),{onClick:function(){var t=1;e.mediaElement.playbackRate<2&&(t=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=t,i(t)},className:"rustic-playback-rate-button",children:(0,n.jsxs)(c(),{variant:"body1",children:[a,"X"]})})})}function q(e){var t="replay"===e.movement,r=t?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},a=t?"replay":"forward";return(0,n.jsx)(k,{onClick:r,action:a})}function M(e){var t=N(e.elapsedTimeInSeconds),r=N(e.durationTimeInSeconds),a="".concat(t," / ").concat(r);return"wide"===e.style?(0,n.jsxs)(f(),{className:"rustic-time-container",children:[(0,n.jsx)(c(),{variant:"overline",children:t}),(0,n.jsx)(c(),{variant:"overline",children:r})]}):(0,n.jsx)(c(),{variant:"overline",className:"rustic-time-display",children:a})}M.defaultProps={style:"condensed"};const I=require("@mui/material/Divider");var L,R,F=e.n(I);function H(e){var t=!!document.fullscreenElement;return(0,n.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!t&&(0,n.jsx)(F(),{orientation:"vertical",flexItem:!0}),(0,n.jsx)(c(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}!function(e){e.Owner="owner",e.Member="member"}(L||(L={})),function(e){e.Human="human",e.Agent="agent"}(R||(R={}));const V=function(e){var t=(0,m.useState)(!1),a=t[0],s=t[1],l=(0,m.useState)(!1),d=l[0],f=l[1],p=(0,m.useState)(!0),x=p[0],v=p[1],b=(0,m.useState)(0),y=b[0],j=b[1],h=(0,m.useState)(""),E=h[0],g=h[1],N=(0,m.useState)(""),T=N[0],S=N[1],_=(0,r.useTheme)(),I=(0,m.useRef)(null),L=(0,r.useMediaQuery)(_.breakpoints.down("md"));function R(){return(0,n.jsx)(c(),{variant:"h6",className:"rustic-sound-title",children:e.title})}function F(){if(e.captions&&e.captions.length>0){var t=d?"captionsOff":"captionsOn";return(0,n.jsx)(k,{action:t,onClick:function(){return f(!d)}})}}function V(){if(I.current)return(0,n.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,n.jsx)(q,{mediaElement:I.current,movement:"replay"}),(0,n.jsx)(C,{mediaElement:I.current,onError:S}),(0,n.jsx)(q,{mediaElement:I.current,movement:"forward"})]})}function A(){if(e.transcript&&a)return(0,n.jsx)(H,{transcript:e.transcript})}function U(){if(e.transcript)return(0,n.jsx)(B,{isTranscriptVisible:a,setIsTranscriptVisible:function(){return s(!a)}})}function D(){return(0,n.jsx)("video",{src:e.src,ref:I,className:d?"rustic-has-captions":"",children:d&&(0,n.jsx)("track",{src:e.captions,kind:"captions",default:!0})})}(0,m.useEffect)((function(){var e,t,n,r;function a(e){g(e)}null===(e=I.current)||void 0===e||e.addEventListener("timeupdate",(function(){I.current&&j(I.current.currentTime)})),null===(t=I.current)||void 0===t||t.addEventListener("canplay",(function(){g(""),v(!1)})),null===(n=I.current)||void 0===n||n.addEventListener("error",(function(){return a("Failed to load the audio.")})),null===(r=I.current)||void 0===r||r.addEventListener("stalled",(function(){return a("Failed to fetch audio data, but trying.")}))}),[]);var z=L?function(){if(I.current)return(0,n.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,n.jsx)(M,{elapsedTimeInSeconds:y,durationTimeInSeconds:I.current.duration,style:"wide"}),(0,n.jsx)(P,{mediaElement:I.current}),R(),(0,n.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,n.jsx)(u.Box,{className:"rustic-sound-bottom-controls-left",children:V()}),(0,n.jsx)(w,{mediaElement:I.current}),(0,n.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-right",children:[U(),(0,n.jsxs)(u.Box,{children:[F(),(0,n.jsx)(O,{mediaElement:I.current})]})]})]}),A()]})}:function(){if(I.current)return(0,n.jsxs)(n.Fragment,{children:[R(),(0,n.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,n.jsx)(P,{mediaElement:I.current}),(0,n.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,n.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-left",children:[V(),F(),(0,n.jsx)(O,{mediaElement:I.current}),(0,n.jsx)(w,{mediaElement:I.current}),(0,n.jsx)(M,{elapsedTimeInSeconds:y,durationTimeInSeconds:I.current.duration,style:"condensed"})]}),(0,n.jsx)(u.Box,{className:"rustic-sound-bottom-controls-right",children:U()})]}),A()]})]})};return E.length>0?(0,n.jsx)(i(),{severity:"error",children:E}):x?(0,n.jsxs)(u.Box,{className:"rustic-sound",children:[D(),(0,n.jsx)(o(),{})]}):(0,n.jsxs)(u.Box,{className:"rustic-sound",children:[D(),z(),T.length>0&&(0,n.jsx)(i(),{severity:"error",className:"rustic-control-error",onClose:function(){return S("")},children: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 r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>F});const r=require("react/jsx-runtime"),n=require("@mui/material"),a=require("@mui/material/Alert");var i=e.n(a);const s=require("@mui/material/CircularProgress");var o=e.n(s);const l=require("@mui/material/Typography");var c=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("@mui/material/Box");var f=e.n(d);const p=require("@mui/material/Button");var x=e.n(p);const v=require("@mui/material/LinearProgress");var b=e.n(v);const y=require("@mui/material/Slider");var j=e.n(y);const h=require("@mui/material/Tooltip");var E,N=e.n(h);function g(e){var t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),a=t>0?"".concat(t,":"):"",i="".concat(t>0?r.toString().padStart(2,"0"):r),s=n.toString().padStart(2,"0");return"".concat(a).concat(i,":").concat(s)}function T(e){return e.name.replaceAll("_","-"),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(E||(E={}));const S=require("@mui/material/IconButton");var _=e.n(S);function k(e){var t,n={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return n[e.action].label.replaceAll(" ","-").toLowerCase(),(0,r.jsx)(N(),{title:n[e.action].label,PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,r.jsx)(_(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(T,{name:n[e.action].symbol,className:"rustic-icon-large"})})})}function P(e){var t="dark"===(0,n.useTheme)().palette.mode,a=g(e.mediaElement.currentTime);return(0,r.jsxs)(f(),{className:"rustic-progress",children:[function(){for(var n=e.mediaElement.buffered,a=0,i=n.length-1;i>=0;--i){var s=n.start(i),o=n.end(i);if(s<e.mediaElement.currentTime){a=o;break}}var l=a/e.mediaElement.duration*100;return(0,r.jsx)(b(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:t?"secondary.light":"action.selected"}}})}(),(0,r.jsx)(j(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(a),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(t,r){e.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return g(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function B(e){var t=(0,m.useState)(e.mediaElement.volume),n=t[0],a=t[1],i=(0,m.useState)(e.mediaElement.volume),s=i[0],o=i[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,r.jsxs)(f(),{className:"rustic-volume-settings",children:[(0,r.jsx)(k,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(o(e.mediaElement.volume),a(0)):a(s)},className:"rustic-mute-button",action:l}),(0,r.jsx)(j(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*n,"%"),value:n,onChange:function(t,r){var n=r;e.mediaElement.muted=0===n,e.mediaElement.volume=n,a(e.mediaElement.volume)}})]})}function C(e){var t=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",n="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,r.jsx)(x(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,r.jsx)(T,{name:t}),children:(0,r.jsx)(c(),{variant:"overline",children:n})})}function w(e){var t=(0,m.useState)(!e.mediaElement.paused),n=t[0],a=t[1],i=n?"pause":"play";return e.mediaElement.onended=function(){a(!1)},e.mediaElement.onpause=function(){a(!1)},e.mediaElement.onplay=function(){a(!0)},(0,r.jsx)(k,{onClick:function(){n?e.mediaElement.pause():e.mediaElement.play().catch((function(t){e.onError("Failed to play the media. Error: ".concat(t.message))}))},action:i,className:"rustic-pause-play-icon"})}function O(e){var t,n=(0,m.useState)(e.mediaElement.playbackRate),a=n[0],i=n[1];return(0,r.jsx)(N(),{title:"Playback rate",PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,r.jsx)(x(),{onClick:function(){var t=1;e.mediaElement.playbackRate<2&&(t=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=t,i(t)},className:"rustic-playback-rate-button",children:(0,r.jsxs)(c(),{variant:"body1",children:[a,"X"]})})})}function q(e){var t="replay"===e.movement,n=t?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},a=t?"replay":"forward";return(0,r.jsx)(k,{onClick:n,action:a})}function M(e){var t=g(e.elapsedTimeInSeconds),n=g(e.durationTimeInSeconds),a="".concat(t," / ").concat(n);return"wide"===e.style?(0,r.jsxs)(f(),{className:"rustic-time-container",children:[(0,r.jsx)(c(),{variant:"overline",children:t}),(0,r.jsx)(c(),{variant:"overline",children:n})]}):(0,r.jsx)(c(),{variant:"overline",className:"rustic-time-display",children:a})}M.defaultProps={style:"condensed"};const I=require("@mui/material/Divider");var L=e.n(I);function R(e){var t=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!t&&(0,r.jsx)(L(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(c(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}const F=function(e){var t=(0,m.useState)(!1),a=t[0],s=t[1],l=(0,m.useState)(!1),d=l[0],f=l[1],p=(0,m.useState)(!0),x=p[0],v=p[1],b=(0,m.useState)(0),y=b[0],j=b[1],h=(0,m.useState)(""),E=h[0],N=h[1],g=(0,m.useState)(""),T=g[0],S=g[1],_=(0,n.useTheme)(),I=(0,m.useRef)(null),L=(0,n.useMediaQuery)(_.breakpoints.down("md"));function F(){return(0,r.jsx)(c(),{variant:"h6",className:"rustic-sound-title",children:e.title})}function V(){if(e.captions&&e.captions.length>0){var t=d?"captionsOff":"captionsOn";return(0,r.jsx)(k,{action:t,onClick:function(){return f(!d)}})}}function H(){if(I.current)return(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(q,{mediaElement:I.current,movement:"replay"}),(0,r.jsx)(w,{mediaElement:I.current,onError:S}),(0,r.jsx)(q,{mediaElement:I.current,movement:"forward"})]})}function A(){if(e.transcript&&a)return(0,r.jsx)(R,{transcript:e.transcript})}function U(){if(e.transcript)return(0,r.jsx)(C,{isTranscriptVisible:a,setIsTranscriptVisible:function(){return s(!a)}})}function D(){return(0,r.jsx)("video",{src:e.src,ref:I,className:d?"rustic-has-captions":"",children:d&&(0,r.jsx)("track",{src:e.captions,kind:"captions",default:!0})})}(0,m.useEffect)((function(){var e,t,r,n;function a(e){N(e)}null===(e=I.current)||void 0===e||e.addEventListener("timeupdate",(function(){I.current&&j(I.current.currentTime)})),null===(t=I.current)||void 0===t||t.addEventListener("canplay",(function(){N(""),v(!1)})),null===(r=I.current)||void 0===r||r.addEventListener("error",(function(){return a("Failed to load the audio.")})),null===(n=I.current)||void 0===n||n.addEventListener("stalled",(function(){return a("Failed to fetch audio data, but trying.")}))}),[]);var z=L?function(){if(I.current)return(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(M,{elapsedTimeInSeconds:y,durationTimeInSeconds:I.current.duration,style:"wide"}),(0,r.jsx)(P,{mediaElement:I.current}),F(),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,r.jsx)(u.Box,{className:"rustic-sound-bottom-controls-left",children:H()}),(0,r.jsx)(B,{mediaElement:I.current}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-right",children:[U(),(0,r.jsxs)(u.Box,{children:[V(),(0,r.jsx)(O,{mediaElement:I.current})]})]})]}),A()]})}:function(){if(I.current)return(0,r.jsxs)(r.Fragment,{children:[F(),(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(P,{mediaElement:I.current}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-left",children:[H(),V(),(0,r.jsx)(O,{mediaElement:I.current}),(0,r.jsx)(B,{mediaElement:I.current}),(0,r.jsx)(M,{elapsedTimeInSeconds:y,durationTimeInSeconds:I.current.duration,style:"condensed"})]}),(0,r.jsx)(u.Box,{className:"rustic-sound-bottom-controls-right",children:U()})]}),A()]})]})};return E.length>0?(0,r.jsx)(i(),{severity:"error",children:E}):x?(0,r.jsxs)(u.Box,{className:"rustic-sound",children:[D(),(0,r.jsx)(o(),{})]}):(0,r.jsxs)(u.Box,{className:"rustic-sound",children:[D(),z(),T.length>0&&(0,r.jsx)(i(),{severity:"error",className:"rustic-control-error",onClose:function(){return S("")},children:T})]})};return t})()));
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["@rustic-ai/ui-components"]=n():e["@rustic-ai/ui-components"]=n()}(global,(()=>(()=>{"use strict";var e={n:n=>{var r=n&&n.__esModule?()=>n.default:()=>n;return e.d(r,{a:r}),r},d:(n,r)=>{for(var t in r)e.o(r,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:r[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{ParticipantRole:()=>R,ParticipantType:()=>H,default:()=>U});const r=require("react/jsx-runtime"),t=require("@mui/material"),i=require("@mui/material/Alert");var a=e.n(i);const o=require("@mui/material/CircularProgress");var c=e.n(o);const l=require("@mui/material/Typography");var s=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("@mui/material/Box");var f=e.n(d);const p=require("@mui/material/Button");var v=e.n(p);const x=require("@mui/material/LinearProgress");var E=e.n(x);const b=require("@mui/material/Slider");var y=e.n(b);const j=require("@mui/material/Tooltip");var h,g=e.n(j);function N(e){var n=Math.floor(e/3600),r=Math.floor(e%3600/60),t=Math.floor(e%60),i=n>0?"".concat(n,":"):"",a="".concat(n>0?r.toString().padStart(2,"0"):r),o=t.toString().padStart(2,"0");return"".concat(i).concat(a,":").concat(o)}function S(e){return e.name.replaceAll("_","-"),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}require("pluralize"),function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(h||(h={}));const T=require("@mui/material/IconButton");var k=e.n(T);function P(e){var n,t={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return t[e.action].label.replaceAll(" ","-").toLowerCase(),(0,r.jsx)(g(),{title:t[e.action].label,PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(k(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(S,{name:t[e.action].symbol,className:"rustic-icon-large"})})})}function _(e){var n="dark"===(0,t.useTheme)().palette.mode,i=N(e.mediaElement.currentTime);return(0,r.jsxs)(f(),{className:"rustic-progress",children:[function(){for(var t=e.mediaElement.buffered,i=0,a=t.length-1;a>=0;--a){var o=t.start(a),c=t.end(a);if(o<e.mediaElement.currentTime){i=c;break}}var l=i/e.mediaElement.duration*100;return(0,r.jsx)(E(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:n?"secondary.light":"action.selected"}}})}(),(0,r.jsx)(y(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(i),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(n,r){e.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return N(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function w(e){var n=(0,m.useState)(e.mediaElement.volume),t=n[0],i=n[1],a=(0,m.useState)(e.mediaElement.volume),o=a[0],c=a[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,r.jsxs)(f(),{className:"rustic-volume-settings",children:[(0,r.jsx)(P,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(c(e.mediaElement.volume),i(0)):i(o)},className:"rustic-mute-button",action:l}),(0,r.jsx)(y(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*t,"%"),value:t,onChange:function(n,r){var t=r;e.mediaElement.muted=0===t,e.mediaElement.volume=t,i(e.mediaElement.volume)}})]})}function C(e){var n=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",t="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,r.jsx)(v(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,r.jsx)(S,{name:n}),children:(0,r.jsx)(s(),{variant:"overline",children:t})})}function B(e){var n=(0,m.useState)(!e.mediaElement.paused),t=n[0],i=n[1],a=t?"pause":"play";return e.mediaElement.onended=function(){i(!1)},e.mediaElement.onpause=function(){i(!1)},e.mediaElement.onplay=function(){i(!0)},(0,r.jsx)(P,{onClick:function(){t?e.mediaElement.pause():e.mediaElement.play().catch((function(n){e.onError("Failed to play the media. Error: ".concat(n.message))}))},action:a,className:"rustic-pause-play-icon"})}function q(e){var n,t=(0,m.useState)(e.mediaElement.playbackRate),i=t[0],a=t[1];return(0,r.jsx)(g(),{title:"Playback rate",PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(v(),{onClick:function(){var n=1;e.mediaElement.playbackRate<2&&(n=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=n,a(n)},className:"rustic-playback-rate-button",children:(0,r.jsxs)(s(),{variant:"body1",children:[i,"X"]})})})}function O(e){var n="replay"===e.movement,t=n?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},i=n?"replay":"forward";return(0,r.jsx)(P,{onClick:t,action:i})}function F(e){var n=(0,m.useState)(!!document.pictureInPictureElement),t=n[0],i=n[1],a=e.mediaElement,o=t?"miniPlayerExit":"miniPlayer";return a.onleavepictureinpicture=function(){i(!1)},(0,r.jsx)(P,{onClick:function(){t?document.exitPictureInPicture().then((function(){i(!1)})).catch((function(n){e.onError("Failed to exit mini player. Error: ".concat(n.message))})):a.requestPictureInPicture().then((function(){i(!0)})).catch((function(n){e.onError("Failed to enter mini player. Error: ".concat(n.message))}))},action:o})}function I(e){var n=(0,m.useState)(!!document.fullscreenElement),t=n[0],i=n[1],a=e.element,o=t?"fullscreenExit":"fullscreen";return a.onfullscreenchange=function(){i(!!document.fullscreenElement)},(0,r.jsx)(P,{onClick:function(){t?document.exitFullscreen().then((function(){i(!1)})).catch((function(n){e.onError("Failed to exit fullscreen mode. Error: ".concat(n.message))})):a.requestFullscreen().then((function(){i(!0)})).catch((function(n){e.onError("Failed to enter fullscreen mode. Error: ".concat(n.message))}))},action:o})}function M(e){var n=N(e.elapsedTimeInSeconds),t=N(e.durationTimeInSeconds),i="".concat(n," / ").concat(t);return"wide"===e.style?(0,r.jsxs)(f(),{className:"rustic-time-container",children:[(0,r.jsx)(s(),{variant:"overline",children:n}),(0,r.jsx)(s(),{variant:"overline",children:t})]}):(0,r.jsx)(s(),{variant:"overline",className:"rustic-time-display",children:i})}M.defaultProps={style:"condensed"};const L=require("@mui/material/Divider");var R,H,V=e.n(L);function A(e){var n=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!n&&(0,r.jsx)(V(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(s(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}!function(e){e.Owner="owner",e.Member="member"}(R||(R={})),function(e){e.Human="human",e.Agent="agent"}(H||(H={}));const U=function(e){var n=(0,m.useState)(!1),i=n[0],o=n[1],l=(0,m.useState)(!1),d=l[0],f=l[1],p=(0,m.useState)(!0),v=p[0],x=p[1],E=(0,m.useState)(!!document.fullscreenElement),b=E[0],y=E[1],j=(0,m.useState)(!1),h=j[0],g=j[1],N=(0,m.useState)(""),S=N[0],T=N[1],k=(0,m.useState)(""),L=k[0],R=k[1],H=(0,m.useState)(0),V=H[0],U=H[1],D=(0,m.useRef)(null),z=(0,m.useRef)(null),Q=(0,t.useTheme)(),X=(0,t.useMediaQuery)(Q.breakpoints.down("md"));(0,m.useEffect)((function(){var e,n,r,t,i,a,o,c;function l(e){R(e),x(!1)}function s(){clearTimeout(c),c=setTimeout((function(){return g(!1)}),3e3)}null===(e=z.current)||void 0===e||e.addEventListener("timeupdate",(function(){z.current&&U(z.current.currentTime)})),null===(n=z.current)||void 0===n||n.addEventListener("canplay",(function(){R(""),x(!1)})),null===(r=z.current)||void 0===r||r.addEventListener("error",(function(){return l("Failed to load the video.")})),null===(t=z.current)||void 0===t||t.addEventListener("stalled",(function(){return l("Failed to fetch video data, but trying.")})),document.addEventListener("fullscreenchange",(function(){y(!!document.fullscreenElement)})),null===(i=D.current)||void 0===i||i.addEventListener("mousemove",(function(){g(!0),s()})),null===(a=D.current)||void 0===a||a.addEventListener("mouseleave",(function(){g(!1)})),null===(o=D.current)||void 0===o||o.addEventListener("keydown",(function(){g(!0),s()}))}),[]);var G={backgroundColor:Q.palette.background.paper,opacity:h?1:0};function J(){if(e.transcript&&i)return(0,r.jsx)(A,{transcript:e.transcript})}function K(){if(e.captions&&e.captions.length>0){var n=d?"captionsOff":"captionsOn";return(0,r.jsx)(P,{action:n,onClick:function(){return f(!d)}})}}function W(){if(e.transcript)return(0,r.jsx)(C,{isTranscriptVisible:i,setIsTranscriptVisible:function(){return o(!i)}})}var Y=X?function(){return b?(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsxs)(u.Box,{className:"rustic-video-top-controls",children:[(0,r.jsx)(B,{mediaElement:z.current,onError:T}),(0,r.jsx)(_,{mediaElement:z.current}),(0,r.jsx)(M,{elapsedTimeInSeconds:V,durationTimeInSeconds:z.current.duration})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(O,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(O,{mediaElement:z.current,movement:"forward"}),K(),(0,r.jsx)(q,{mediaElement:z.current})]}),W()]}),J()]})}):(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls-mobile-preview",children:[(0,r.jsx)(B,{mediaElement:z.current,onError:T}),(0,r.jsxs)(u.Box,{className:"rustic-video-controls-right",children:[W(),(0,r.jsx)(I,{element:D.current,onError:T})]})]})})}:function(){return(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsx)(_,{mediaElement:z.current}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-left",children:[(0,r.jsx)(B,{mediaElement:z.current,onError:T}),(0,r.jsx)(O,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(O,{mediaElement:z.current,movement:"forward"}),K(),(0,r.jsx)(q,{mediaElement:z.current}),(0,r.jsx)(w,{mediaElement:z.current}),(0,r.jsx)(M,{elapsedTimeInSeconds:V,durationTimeInSeconds:z.current.duration,style:"condensed"})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-right",children:[W(),(0,r.jsx)(F,{mediaElement:z.current,onError:T}),(0,r.jsx)(I,{element:D.current,onError:T})]})]}),b&&J()]})})};return L.length>0?(0,r.jsx)(a(),{severity:"error",children:L}):(0,r.jsxs)(u.Box,{className:"rustic-video",children:[v&&(0,r.jsx)(c(),{className:"rustic-video-loading-spinner"}),(0,r.jsxs)(u.Box,{ref:D,className:"rustic-video-screen",sx:{visibility:v?"hidden":"visible"},children:[S.length>0&&(0,r.jsx)(a(),{severity:"error",className:"rustic-control-error",onClose:function(){return T("")},children:S}),(!X||b)&&function(){if(z.current&&D.current)return(0,r.jsxs)(u.Box,{className:"rustic-video-title",sx:G,children:[(0,r.jsx)(s(),{variant:"body2",children:e.title}),b&&X&&(0,r.jsxs)(u.Box,{children:[(0,r.jsx)(F,{mediaElement:z.current,onError:T}),(0,r.jsx)(I,{element:D.current,onError:T})]})]})}(),(0,r.jsx)("video",{className:"rustic-video-element",ref:z,src:e.src,poster:e.poster,children:d&&(0,r.jsx)("track",{src:e.captions,kind:"captions",default:!0})}),Y()]}),!b&&J()]})};return n})()));
1
+ !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["@rustic-ai/ui-components"]=n():e["@rustic-ai/ui-components"]=n()}(global,(()=>(()=>{"use strict";var e={n:n=>{var r=n&&n.__esModule?()=>n.default:()=>n;return e.d(r,{a:r}),r},d:(n,r)=>{for(var t in r)e.o(r,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:r[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{default:()=>H});const r=require("react/jsx-runtime"),t=require("@mui/material"),i=require("@mui/material/Alert");var a=e.n(i);const o=require("@mui/material/CircularProgress");var c=e.n(o);const l=require("@mui/material/Typography");var s=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("@mui/material/Box");var f=e.n(d);const p=require("@mui/material/Button");var v=e.n(p);const x=require("@mui/material/LinearProgress");var E=e.n(x);const b=require("@mui/material/Slider");var y=e.n(b);const j=require("@mui/material/Tooltip");var h,g=e.n(j);function N(e){var n=Math.floor(e/3600),r=Math.floor(e%3600/60),t=Math.floor(e%60),i=n>0?"".concat(n,":"):"",a="".concat(n>0?r.toString().padStart(2,"0"):r),o=t.toString().padStart(2,"0");return"".concat(i).concat(a,":").concat(o)}function S(e){return e.name.replaceAll("_","-"),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(h||(h={}));const T=require("@mui/material/IconButton");var k=e.n(T);function _(e){var n,t={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return t[e.action].label.replaceAll(" ","-").toLowerCase(),(0,r.jsx)(g(),{title:t[e.action].label,PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(k(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(S,{name:t[e.action].symbol,className:"rustic-icon-large"})})})}function P(e){var n="dark"===(0,t.useTheme)().palette.mode,i=N(e.mediaElement.currentTime);return(0,r.jsxs)(f(),{className:"rustic-progress",children:[function(){for(var t=e.mediaElement.buffered,i=0,a=t.length-1;a>=0;--a){var o=t.start(a),c=t.end(a);if(o<e.mediaElement.currentTime){i=c;break}}var l=i/e.mediaElement.duration*100;return(0,r.jsx)(E(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:n?"secondary.light":"action.selected"}}})}(),(0,r.jsx)(y(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(i),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(n,r){e.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return N(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function C(e){var n=(0,m.useState)(e.mediaElement.volume),t=n[0],i=n[1],a=(0,m.useState)(e.mediaElement.volume),o=a[0],c=a[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,r.jsxs)(f(),{className:"rustic-volume-settings",children:[(0,r.jsx)(_,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(c(e.mediaElement.volume),i(0)):i(o)},className:"rustic-mute-button",action:l}),(0,r.jsx)(y(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*t,"%"),value:t,onChange:function(n,r){var t=r;e.mediaElement.muted=0===t,e.mediaElement.volume=t,i(e.mediaElement.volume)}})]})}function B(e){var n=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",t="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,r.jsx)(v(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,r.jsx)(S,{name:n}),children:(0,r.jsx)(s(),{variant:"overline",children:t})})}function w(e){var n=(0,m.useState)(!e.mediaElement.paused),t=n[0],i=n[1],a=t?"pause":"play";return e.mediaElement.onended=function(){i(!1)},e.mediaElement.onpause=function(){i(!1)},e.mediaElement.onplay=function(){i(!0)},(0,r.jsx)(_,{onClick:function(){t?e.mediaElement.pause():e.mediaElement.play().catch((function(n){e.onError("Failed to play the media. Error: ".concat(n.message))}))},action:a,className:"rustic-pause-play-icon"})}function q(e){var n,t=(0,m.useState)(e.mediaElement.playbackRate),i=t[0],a=t[1];return(0,r.jsx)(g(),{title:"Playback rate",PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(v(),{onClick:function(){var n=1;e.mediaElement.playbackRate<2&&(n=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=n,a(n)},className:"rustic-playback-rate-button",children:(0,r.jsxs)(s(),{variant:"body1",children:[i,"X"]})})})}function F(e){var n="replay"===e.movement,t=n?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},i=n?"replay":"forward";return(0,r.jsx)(_,{onClick:t,action:i})}function O(e){var n=(0,m.useState)(!!document.pictureInPictureElement),t=n[0],i=n[1],a=e.mediaElement,o=t?"miniPlayerExit":"miniPlayer";return a.onleavepictureinpicture=function(){i(!1)},(0,r.jsx)(_,{onClick:function(){t?document.exitPictureInPicture().then((function(){i(!1)})).catch((function(n){e.onError("Failed to exit mini player. Error: ".concat(n.message))})):a.requestPictureInPicture().then((function(){i(!0)})).catch((function(n){e.onError("Failed to enter mini player. Error: ".concat(n.message))}))},action:o})}function I(e){var n=(0,m.useState)(!!document.fullscreenElement),t=n[0],i=n[1],a=e.element,o=t?"fullscreenExit":"fullscreen";return a.onfullscreenchange=function(){i(!!document.fullscreenElement)},(0,r.jsx)(_,{onClick:function(){t?document.exitFullscreen().then((function(){i(!1)})).catch((function(n){e.onError("Failed to exit fullscreen mode. Error: ".concat(n.message))})):a.requestFullscreen().then((function(){i(!0)})).catch((function(n){e.onError("Failed to enter fullscreen mode. Error: ".concat(n.message))}))},action:o})}function L(e){var n=N(e.elapsedTimeInSeconds),t=N(e.durationTimeInSeconds),i="".concat(n," / ").concat(t);return"wide"===e.style?(0,r.jsxs)(f(),{className:"rustic-time-container",children:[(0,r.jsx)(s(),{variant:"overline",children:n}),(0,r.jsx)(s(),{variant:"overline",children:t})]}):(0,r.jsx)(s(),{variant:"overline",className:"rustic-time-display",children:i})}L.defaultProps={style:"condensed"};const M=require("@mui/material/Divider");var R=e.n(M);function V(e){var n=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!n&&(0,r.jsx)(R(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(s(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}const H=function(e){var n=(0,m.useState)(!1),i=n[0],o=n[1],l=(0,m.useState)(!1),d=l[0],f=l[1],p=(0,m.useState)(!0),v=p[0],x=p[1],E=(0,m.useState)(!!document.fullscreenElement),b=E[0],y=E[1],j=(0,m.useState)(!1),h=j[0],g=j[1],N=(0,m.useState)(""),S=N[0],T=N[1],k=(0,m.useState)(""),M=k[0],R=k[1],H=(0,m.useState)(0),A=H[0],U=H[1],D=(0,m.useRef)(null),z=(0,m.useRef)(null),Q=(0,t.useTheme)(),X=(0,t.useMediaQuery)(Q.breakpoints.down("md"));(0,m.useEffect)((function(){var e,n,r,t,i,a,o,c;function l(e){R(e),x(!1)}function s(){clearTimeout(c),c=setTimeout((function(){return g(!1)}),3e3)}null===(e=z.current)||void 0===e||e.addEventListener("timeupdate",(function(){z.current&&U(z.current.currentTime)})),null===(n=z.current)||void 0===n||n.addEventListener("canplay",(function(){R(""),x(!1)})),null===(r=z.current)||void 0===r||r.addEventListener("error",(function(){return l("Failed to load the video.")})),null===(t=z.current)||void 0===t||t.addEventListener("stalled",(function(){return l("Failed to fetch video data, but trying.")})),document.addEventListener("fullscreenchange",(function(){y(!!document.fullscreenElement)})),null===(i=D.current)||void 0===i||i.addEventListener("mousemove",(function(){g(!0),s()})),null===(a=D.current)||void 0===a||a.addEventListener("mouseleave",(function(){g(!1)})),null===(o=D.current)||void 0===o||o.addEventListener("keydown",(function(){g(!0),s()}))}),[]);var G={backgroundColor:Q.palette.background.paper,opacity:h?1:0};function J(){if(e.transcript&&i)return(0,r.jsx)(V,{transcript:e.transcript})}function K(){if(e.captions&&e.captions.length>0){var n=d?"captionsOff":"captionsOn";return(0,r.jsx)(_,{action:n,onClick:function(){return f(!d)}})}}function W(){if(e.transcript)return(0,r.jsx)(B,{isTranscriptVisible:i,setIsTranscriptVisible:function(){return o(!i)}})}var Y=X?function(){return b?(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsxs)(u.Box,{className:"rustic-video-top-controls",children:[(0,r.jsx)(w,{mediaElement:z.current,onError:T}),(0,r.jsx)(P,{mediaElement:z.current}),(0,r.jsx)(L,{elapsedTimeInSeconds:A,durationTimeInSeconds:z.current.duration})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(F,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(F,{mediaElement:z.current,movement:"forward"}),K(),(0,r.jsx)(q,{mediaElement:z.current})]}),W()]}),J()]})}):(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls-mobile-preview",children:[(0,r.jsx)(w,{mediaElement:z.current,onError:T}),(0,r.jsxs)(u.Box,{className:"rustic-video-controls-right",children:[W(),(0,r.jsx)(I,{element:D.current,onError:T})]})]})})}:function(){return(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsx)(P,{mediaElement:z.current}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-left",children:[(0,r.jsx)(w,{mediaElement:z.current,onError:T}),(0,r.jsx)(F,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(F,{mediaElement:z.current,movement:"forward"}),K(),(0,r.jsx)(q,{mediaElement:z.current}),(0,r.jsx)(C,{mediaElement:z.current}),(0,r.jsx)(L,{elapsedTimeInSeconds:A,durationTimeInSeconds:z.current.duration,style:"condensed"})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-right",children:[W(),(0,r.jsx)(O,{mediaElement:z.current,onError:T}),(0,r.jsx)(I,{element:D.current,onError:T})]})]}),b&&J()]})})};return M.length>0?(0,r.jsx)(a(),{severity:"error",children:M}):(0,r.jsxs)(u.Box,{className:"rustic-video",children:[v&&(0,r.jsx)(c(),{className:"rustic-video-loading-spinner"}),(0,r.jsxs)(u.Box,{ref:D,className:"rustic-video-screen",sx:{visibility:v?"hidden":"visible"},children:[S.length>0&&(0,r.jsx)(a(),{severity:"error",className:"rustic-control-error",onClose:function(){return T("")},children:S}),(!X||b)&&function(){if(z.current&&D.current)return(0,r.jsxs)(u.Box,{className:"rustic-video-title",sx:G,children:[(0,r.jsx)(s(),{variant:"body2",children:e.title}),b&&X&&(0,r.jsxs)(u.Box,{children:[(0,r.jsx)(O,{mediaElement:z.current,onError:T}),(0,r.jsx)(I,{element:D.current,onError:T})]})]})}(),(0,r.jsx)("video",{className:"rustic-video-element",ref:z,src:e.src,poster:e.poster,children:d&&(0,r.jsx)("track",{src:e.captions,kind:"captions",default:!0})}),Y()]}),!b&&J()]})};return n})()));