@rustic-ai/ui-components 0.0.27 → 0.0.28

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 (31) hide show
  1. package/dist/components/icon/icon.d.ts +2 -2
  2. package/dist/components/icon/icon.d.ts.map +1 -1
  3. package/dist/components/icon/index.d.ts +1 -0
  4. package/dist/components/icon/index.d.ts.map +1 -1
  5. package/dist/components/icon/index.js +1 -1
  6. package/dist/components/input/emoji/index.js +1 -1
  7. package/dist/components/input/multimodal/multimodalInput/index.js +1 -1
  8. package/dist/components/input/multimodal/uploader/index.js +1 -1
  9. package/dist/components/input/textInput/index.js +1 -1
  10. package/dist/components/map/index.js +1 -1
  11. package/dist/components/media/audio/index.js +1 -1
  12. package/dist/components/media/video/index.js +1 -1
  13. package/dist/components/menu/index.js +1 -1
  14. package/dist/components/messageCanvas/actions/copy/index.js +1 -1
  15. package/dist/components/messageCanvas/actions/textToSpeech/index.js +1 -1
  16. package/dist/components/messageSpace/index.js +1 -1
  17. package/dist/components/multipart/index.js +1 -1
  18. package/dist/components/participantsContainer/index.js +1 -1
  19. package/dist/components/pdfViewer/index.js +1 -1
  20. package/dist/components/promptBuilder/index.js +1 -1
  21. package/dist/components/table/index.js +1 -1
  22. package/dist/components/visualization/chart/index.js +1 -1
  23. package/dist/components/visualization/perspectiveViz/index.js +1 -1
  24. package/dist/components/visualization/perspectiveViz/perspectiveViz.d.ts +3 -3
  25. package/dist/components/visualization/perspectiveViz/perspectiveViz.d.ts.map +1 -1
  26. package/dist/components/visualization/vegaLiteViz/index.js +1 -1
  27. package/dist/components/visualization/vegaLiteViz/vegaLiteViz.d.ts +2 -2
  28. package/dist/components/visualization/vegaLiteViz/vegaLiteViz.d.ts.map +1 -1
  29. package/dist/components/weather/index.js +1 -1
  30. package/dist/index.js +1 -1
  31. package/package.json +23 -23
@@ -1,8 +1,8 @@
1
1
  import './icon.css';
2
- type IconProps = {
2
+ export type IconProps = {
3
3
  name: string;
4
4
  className?: string;
5
+ color?: string;
5
6
  };
6
7
  export default function Icon(props: IconProps): import("react/jsx-runtime").JSX.Element;
7
- export {};
8
8
  //# sourceMappingURL=icon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/components/icon/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA;AAInB,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AACD,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,KAAK,EAAE,SAAS,2CAW5C"}
1
+ {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/components/icon/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA;AAInB,MAAM,MAAM,SAAS,GAAG;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,KAAK,EAAE,SAAS,2CAe5C"}
@@ -1,4 +1,5 @@
1
1
  import './icon.css';
2
2
  import Icon from './icon';
3
3
  export default Icon;
4
+ export type { IconProps } from "./icon";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/icon/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA;AAEnB,OAAO,IAAI,MAAM,QAAQ,CAAA;AAEzB,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/icon/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA;AAEnB,OAAO,IAAI,MAAM,QAAQ,CAAA;AAEzB,eAAe,IAAI,CAAA;AAEnB,YAAY,EAAC,SAAS,EAAC,MAAM,QAAQ,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={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>r});const o=require("react/jsx-runtime");require("react");const r=function(e){return e.name.replaceAll("_","-"),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})};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={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>n});const o=require("react/jsx-runtime");require("react");var r=function(){return r=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},r.apply(this,arguments)};const n=function(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:r({},t),children:e.name})};return t})()));
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={342:e=>{e.exports=require("emoji-picker-element")}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(t,o){if(1&o&&(t=this(t)),8&o)return t;if("object"==typeof t&&t){if(4&o&&t.__esModule)return t;if(16&o&&"function"==typeof t.then)return t}var i=Object.create(null);n.r(i);var c={};e=e||[null,r({}),r([]),r(r)];for(var a=2&o&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>c[e]=()=>t[e]));return c.default=()=>t,n.d(i,c),i},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};n.r(i),n.d(i,{default:()=>j});const c=require("react/jsx-runtime");n(342);const a=require("@mui/material/IconButton");var u=n.n(a);const l=require("@mui/material/Popover");var s=n.n(l);const d=require("@mui/material/styles"),f=require("@mui/material/Tooltip");var p=n.n(f);const m=require("react");function v(e){return e.name.replaceAll("_","-"),(0,c.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}const j=function(e){var r=(0,d.useTheme)(),t=(0,m.useRef)(null),o=(0,m.useRef)(null),i=(0,m.useState)(!1),a=i[0],l=i[1],f={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function j(){l(!1)}function y(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),j()}return(0,m.useEffect)((function(){o.current||"undefined"==typeof window||Promise.resolve().then(n.t.bind(n,342,23)).then((function(e){var t=new(0,e.Picker),n="dark"===r.palette.mode?"dark":"light";t.classList.add(n),Object.keys(f).forEach((function(e){t.style.setProperty(e,f[e])})),o.current=t})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,m.useEffect)((function(){return o.current&&o.current.addEventListener("emoji-click",y),function(){var e;null===(e=o.current)||void 0===e||e.removeEventListener("emoji-click",y)}}),[a,e.onEmojiClick]),(0,c.jsxs)("div",{children:[(0,c.jsx)(p(),{title:"Emoji",children:(0,c.jsx)(u(),{size:"small",ref:t,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,c.jsx)(v,{name:"Mood"})})}),o.current&&(0,c.jsx)(s(),{open:a,anchorEl:t.current,onClose:j,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,c.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&o.current&&!e.contains(o.current)&&e.appendChild(o.current)}})})]})};return i})()));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={342:e=>{e.exports=require("emoji-picker-element")}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(t,o){if(1&o&&(t=this(t)),8&o)return t;if("object"==typeof t&&t){if(4&o&&t.__esModule)return t;if(16&o&&"function"==typeof t.then)return t}var i=Object.create(null);n.r(i);var c={};e=e||[null,r({}),r([]),r(r)];for(var a=2&o&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>c[e]=()=>t[e]));return c.default=()=>t,n.d(i,c),i},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};n.r(i),n.d(i,{default:()=>y});const c=require("react/jsx-runtime");n(342);const a=require("@mui/material/IconButton");var u=n.n(a);const l=require("@mui/material/Popover");var s=n.n(l);const d=require("@mui/material/styles"),f=require("@mui/material/Tooltip");var p=n.n(f);const m=require("react");var v=function(){return v=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},v.apply(this,arguments)};function j(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,c.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:v({},r),children:e.name})}const y=function(e){var r=(0,d.useTheme)(),t=(0,m.useRef)(null),o=(0,m.useRef)(null),i=(0,m.useState)(!1),a=i[0],l=i[1],f={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function v(){l(!1)}function y(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),v()}return(0,m.useEffect)((function(){o.current||"undefined"==typeof window||Promise.resolve().then(n.t.bind(n,342,23)).then((function(e){var t=new(0,e.Picker),n="dark"===r.palette.mode?"dark":"light";t.classList.add(n),Object.keys(f).forEach((function(e){t.style.setProperty(e,f[e])})),o.current=t})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,m.useEffect)((function(){return o.current&&o.current.addEventListener("emoji-click",y),function(){var e;null===(e=o.current)||void 0===e||e.removeEventListener("emoji-click",y)}}),[a,e.onEmojiClick]),(0,c.jsxs)("div",{children:[(0,c.jsx)(p(),{title:"Emoji",children:(0,c.jsx)(u(),{size:"small",ref:t,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,c.jsx)(j,{name:"Mood"})})}),o.current&&(0,c.jsx)(s(),{open:a,anchorEl:t.current,onClose:v,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,c.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&o.current&&!e.contains(o.current)&&e.appendChild(o.current)}})})]})};return i})()));
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,n={342:e=>{e.exports=require("emoji-picker-element")}},t={};function i(e){var r=t[e];if(void 0!==r)return r.exports;var a=t[e]={exports:{}};return n[e](a,a.exports,i),a.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 a=Object.create(null);i.r(a);var o={};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=>o[e]=()=>n[e]));return o.default=()=>n,i.d(a,o),a},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 a={};i.r(a),i.d(a,{default:()=>de});const o=require("react/jsx-runtime"),c=require("@mui/material/Box");var l=i.n(c);const s=require("@mui/material/styles"),u=require("react"),d=require("uuid"),m=require("@mui/material/CircularProgress");var f=i.n(m);const p=require("@mui/material/IconButton");var h=i.n(p);const v=require("@mui/material/InputAdornment");var g=i.n(v);const x=require("@mui/material/MenuItem");var b=i.n(x);const j=require("@mui/material/MenuList");var y=i.n(j);const w=require("@mui/material/Popover");var S=i.n(w);const C=require("@mui/material/TextField");var N=i.n(C);const k=require("@mui/material/Tooltip");var F=i.n(k);const P=require("@mui/material/Typography");var O=i.n(P),E=i(342);function q(e){return e.name.replaceAll("_","-"),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}const T=function(e){var r=(0,s.useTheme)(),n=(0,u.useRef)(null),t=(0,u.useRef)(null),a=(0,u.useState)(!1),c=a[0],l=a[1],d={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function m(){l(!1)}function f(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),m()}return(0,u.useEffect)((function(){t.current||"undefined"==typeof window||Promise.resolve().then(i.t.bind(i,342,23)).then((function(e){var n=new(0,e.Picker),i="dark"===r.palette.mode?"dark":"light";n.classList.add(i),Object.keys(d).forEach((function(e){n.style.setProperty(e,d[e])})),t.current=n})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return t.current&&t.current.addEventListener("emoji-click",f),function(){var e;null===(e=t.current)||void 0===e||e.removeEventListener("emoji-click",f)}}),[c,e.onEmojiClick]),(0,o.jsxs)("div",{children:[(0,o.jsx)(F(),{title:"Emoji",children:(0,o.jsx)(h(),{size:"small",ref:n,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,o.jsx)(q,{name:"Mood"})})}),t.current&&(0,o.jsx)(S(),{open:c,anchorEl:n.current,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,o.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&t.current&&!e.contains(t.current)&&e.appendChild(t.current)}})})]})};var z={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function I(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var R=new E.Database,_=(0,u.forwardRef)((function(e,r){var n=(0,u.useState)(""),t=n[0],i=n[1],a=(0,u.useState)(!1),c=a[0],s=a[1],m=(0,u.useState)(!1),p=m[0],v=m[1],x=(0,u.useState)(!1),j=x[0],w=x[1],C=(0,u.useState)(""),k=C[0],P=C[1],E=(0,u.useState)([]),_=E[0],A=E[1],D=(0,u.useState)(!1),M=D[0],U=D[1],B=(0,u.useRef)(null),L=!t.trim().length&&!e.isSendEnabled,W="".concat(c?"Stop":"Start"," speech to text"),H=p?"primary.main":"primary.light",V=c?"error.main":H,$=c?"stop_circle":"speech_to_text";function G(e,r){if(void 0===r&&(r=!1),B.current){var n=B.current,a=n.selectionStart,o=n.selectionEnd;if("number"==typeof a&&"number"==typeof o){var c,l=t||"",s=l.substring(0,a),u=l.substring(o);c=r?s.replace(/:(\w+)$/,e)+u:s+e+u,i(c);var d=r?s.replace(/:(\w+)$/,e).length:a+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=j?(0,o.jsx)(f(),{size:24}):(0,o.jsx)(F(),{title:W,children:(0,o.jsx)(h(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,c?(e.stop(),w(!0),s(!1)):(e.start(),P(""),s(!0)),e.onstart=function(){s(!0)},e.onresult=function(e){var r,n=e.results[0][0].transcript;t.length>0?i(t+" "+n):i(n),null===(r=B.current)||void 0===r||r.focus(),s(!1)},e.onerror=function(e){var r=z[e.error];P(r),s(!1)},e.onend=function(){w(!1),s(!1)}},size:"small",sx:{color:V,"&:hover":{color:"primary.main"}},children:(0,o.jsx)(q,{name:$})})});function Q(){var r=(new Date).toISOString(),n={id:(0,d.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:t}};e.send(n),i(""),P("")}return(0,o.jsxs)(l(),{className:"rustic-base-input",ref:r,children:[(0,o.jsxs)(l(),{className:"rustic-error-and-input-container",children:[(0,o.jsx)(l(),{className:"rustic-error-container",children:(0,o.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:k})}),(0,o.jsxs)(l(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:p?"secondary.main":"action.disabled"},children:[_.length>0&&(0,o.jsx)(S(),{open:M,anchorEl:B.current,onClose:function(){return U(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,o.jsx)(y(),{children:_.map((function(e,r){return"unicode"in e&&(0,o.jsx)(b(),{onClick:function(){return G(e.unicode,!0)},children:I(e)},r)}))})}),(0,o.jsx)(N(),{className:"rustic-text-field",variant:"outlined",value:t,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!L&&Q())},onChange:function(r){P("");var n=r.target.value;i(n);var t,a=n.match(/:(\w{2,}):/g),o=n.match(/:(\w{2,})/g);if(a){var c=a[0].replace(/:/g,"");R.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=n.replace(a[0],e.unicode);i(r)}else i(n)})).catch((function(){i(n)})),U(!1)}else o?(t=o[0].replace(":",""),R.getEmojiBySearchQuery(t).then((function(r){r.length?(A(r.slice(0,e.maximumEmojiSearchResults)),U(!0)):(A([]),U(!1))})).catch((function(){A([]),U(!1)}))):U(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:B,color:"secondary",size:"small",InputProps:{endAdornment:(0,o.jsxs)(g(),{position:"end",className:"rustic-input-adornment",children:[(0,o.jsx)(T,{onEmojiClick:G,buttonColor:H}),e.enableSpeechToText&&K]})},InputLabelProps:{className:p?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,o.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,o.jsxs)(l(),{className:"rustic-input-actions",children:[e.children,(0,o.jsx)(F(),{title:"Send",children:(0,o.jsx)("span",{className:"rustic-send-button",children:(0,o.jsx)(h(),{"aria-label":"send message",onClick:Q,disabled:L,color:"secondary",children:(0,o.jsx)(q,{name:"send"})})})})]})]})}));_.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const A=_,D=require("@mui/material/LinearProgress");var M=i.n(D);const U=require("axios");var B=i.n(U);const L=require("react-dom"),W=require("@mui/material/Card");var H=i.n(W);const V=require("@mui/material/Modal");var $,G=i.n(V);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}($||($={}));const K=require("@mui/material/useMediaQuery");var Q=i.n(K);const Y=require("@mui/system/Stack");var Z=i.n(Y);const J=require("@mui/system/useTheme");var X=i.n(J);const ee=require("pdfjs-dist"),re=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,o.jsx)(F(),{title:n.label,children:(0,o.jsx)("span",{children:(0,o.jsx)(h(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,o.jsx)(q,{name:n.symbol})})})})};var ne={pdf:function(e){var r,n=(0,u.useRef)(null),t=(0,u.useState)(1),i=t[0],a=t[1],c=(0,u.useState)(1),s=c[0],d=c[1],m=(0,u.useState)(1),f=m[0],p=m[1],h=(0,u.useState)(!1),v=h[0],g=h[1],x=(0,u.useState)(),b=x[0],j=x[1],y=X()(),w=Q()(y.breakpoints.down("sm")),S=Q()(y.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,o.jsx)(H(),{variant:"outlined",className:"rustic-pdf-error",children:(0,o.jsx)(O(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var C=(0,u.useState)((function(){return w?.5:S?1:1.5})),k=C[0],F=C[1];return(0,u.useEffect)((function(){ee.GlobalWorkerOptions.workerSrc||(ee.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(ee.version,"/pdf.worker.mjs")),ee.getDocument({url:"".concat(e.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(i).then((function(e){var r=e.getViewport({scale:k}),t=n.current;if(t){var i=t.getContext("2d");if(i){var a=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*a,t.height=r.height*a;var o={canvasContext:i,viewport:r,transform:[a,0,0,a,0,0]};b&&b.cancel();var c=e.render(o);j(c),c.promise.then((function(){j(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[e.url,i,k]),v?(0,o.jsx)(H(),{variant:"outlined",className:"rustic-pdf-error",children:(0,o.jsx)(O(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,o.jsxs)(H(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,o.jsxs)(l(),{className:"rustic-pdf-viewer-header",children:[(0,o.jsx)(re,{action:"zoomOut",onClick:function(){F((function(e){return Math.max(e-.2,.2)}))}}),(0,o.jsx)(re,{action:"zoomIn",onClick:function(){F((function(e){return e+.2}))}})]}),(0,o.jsx)(l(),{className:"rustic-pdf-viewer-body",children:(0,o.jsx)(l(),{className:"rustic-pdf-viewer-body-inner",children:(0,o.jsx)("canvas",{ref:n})})}),(0,o.jsxs)(Z(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,o.jsx)(re,{action:"previousPage",onClick:function(){i>1&&(a(i-1),p(i-1))},isDisabled:1===i}),(0,o.jsx)(O(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,o.jsx)(N(),{type:"number",value:f,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=s&&a(r)},size:"small",className:"rustic-pdf-page-input"}),(0,o.jsxs)(O(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,o.jsx)(re,{action:"nextPage",onClick:function(){i<s&&(a(i+1),p(i+1))},isDisabled:i===s})]})]})}};function te(e){var r=(0,s.useTheme)(),n=(0,u.useState)(!1),t=n[0],i=n[1];function a(){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,f=!!m,p=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",v=f?" rustic-cursor-pointer":"",g="rustic-file-preview ".concat(p).concat(v),x=e.showFullName?e.file.name:(15,(l=e.file.name).length<=15?l:l.substring(0,12)+"...");return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(H(),{className:g,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){i(!0)},children:[(0,o.jsx)(O(),{variant:"subtitle2",children:x}),(0,o.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),f&&(0,o.jsx)(G(),{open:t,onClose:a,className:"rustic-file-preview-modal",children:(0,o.jsxs)("div",{className:"rustic-modal-content",children:[(0,o.jsx)(F(),{title:"Close",children:(0,o.jsx)(h(),{onClick:a,className:"rustic-close-button",children:(0,o.jsx)(q,{name:"close"})})}),e.file.url&&(0,o.jsx)(m,{url:e.file.url})]})})]})}te.defaultProps={supportedViewers:ne};var ie=function(){return ie=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},ie.apply(this,arguments)},ae=function(e,r,n){if(n||2===arguments.length)for(var t,i=0,a=r.length;i<a;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(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 ce=function(e){var r=(0,u.useState)([]),n=r[0],t=r[1],i=(0,u.useState)([]),a=i[0],c=i[1],s=(0,u.useRef)({}),m=(0,d.v4)();(0,u.useEffect)((function(){t([]),c([]),s.current={}}),[e.messageId]);var f=(0,o.jsx)(l(),{className:"rustic-files rustic-padding-16",children:n.map((function(r,n){return(0,o.jsx)(te,{file:{name:r.name},showFullName:e.showFullName,children:(0,o.jsxs)(l(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,o.jsx)(M(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,o.jsx)(F(),{title:"Delete",children:(0,o.jsx)(h(),{color:"primary",onClick:function(){return function(r,n){var i,a;c([]);var o=r.name;if(s.current=ie(ie({},s.current),((i={})[o]=s.current[o]--,i)),e.onFileUpdate("remove",o),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",o).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);B().delete(l).then((function(){return t((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",o),c((function(e){return ae(ae([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else r.abortController.abort(),t((function(e){return e.filter((function(e,r){return r!==n}))})),s.current=ie(ie({},s.current),((a={})[o]=s.current[o]++,a))}(r,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,o.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),p=(0,o.jsx)(l(),{children:a.map((function(e,r){return(0,o.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function v(e,r){return r?(0,L.createPortal)(e,r):e}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(l(),{className:"rustic-uploader",children:[(0,o.jsx)("label",{htmlFor:m,children:(0,o.jsx)(F(),{title:"Upload",children:(0,o.jsx)(h(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,o.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,o.jsx)("input",{type:"file",id:m,onChange:function(r){c([]);var i=r.target.files&&Array.from(r.target.files),a=n.length+(i?i.length:0);e.maxFileCount&&a>e.maxFileCount&&c((function(r){return ae(ae([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var o=i&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(i,a,e.maxFileCount);o&&o.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,c((function(r){return ae(ae([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&oe(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,i=new AbortController,a=function(e){var r,n,t=e.name,i=s.current[t];if(i){var a=i+1,o=t.lastIndexOf("."),c=t.substring(0,o),l=t.substring(o);t="".concat(c,"(").concat(i,")").concat(l),s.current=ie(ie({},s.current),((r={})[e.name]=a,r))}else s.current=ie(ie({},s.current),((n={})[e.name]=1,n));return t}(r),o=new File([r],a,{type:r.type});if(e.getUploadData){var l=e.getUploadData(a);Object.keys(l).map((function(e){n.append(e,l[e])}))}n.append("file",o);var u=(0,d.v4)(),m={name:a,loadingProgress:0,abortController:i,id:u};t((function(e){return ae(ae([],e,!0),[m],!1)})),e.onFileUpdate("add",a);var f="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);B().post(f,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=m.id,t((function(e){var t=e.map((function(e){return e.id===n?ie(ie({},e),{loadingProgress:r}):e}));return t})))},signal:i.signal}).then((function(e){var r,n;e.data.fileId&&(r=e.data,n=m.id,t((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var i=ae([],e,!0);return i[t]=ie(ie({},i[t]),{id:r.fileId}),i}return e})))})).catch((function(n){var i,o;e.onFileUpdate("remove",a),s.current=ie(ie({},s.current),((i={})[a]=s.current[r.name]--,i)),function(e,r,n){c((function(r){return ae(ae([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),t((function(e){return e.filter((function(e){return e.id!==r}))}))}(r.name,m.id,null===(o=n.response)||void 0===o?void 0:o.data)}))}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),a.length>0&&v(p,e.errorMessagesContainer),n.length>0&&v(f,e.filePreviewsContainer)]})};var le=function(){return le=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},le.apply(this,arguments)},se=function(e,r,n){if(n||2===arguments.length)for(var t,i=0,a=r.length;i<a;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 ue(e){var r=(0,u.useState)([]),n=r[0],t=r[1],i=(0,u.useState)((0,d.v4)()),a=i[0],c=i[1],m=(0,u.useState)(),f=m[0],p=m[1],h=(0,u.useState)(),v=h[0],g=h[1],x=(0,u.useRef)(null),b=(0,s.useTheme)(),j=n.length>0;return(0,u.useEffect)((function(){x.current&&(g(x.current.querySelector(".rustic-error-container")),p(x.current.querySelector(".rustic-input-extras")))})),(0,o.jsx)(l(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(b.palette.action.disabled),borderRadius:"".concat(b.shape.borderRadius,"px"),":focus-within":{borderColor:b.palette.secondary.main},background:b.palette.background.paper},children:(0,o.jsx)(A,le({},e,{send:function(r){j&&(r.id=a,r.format="filesWithText",r.data.files=n),e.ws.send(r),c((0,d.v4)()),t([])},isSendEnabled:j,ref:x,children:(0,o.jsx)(l(),{className:"rustic-bottom-buttons",children:(0,o.jsx)(ce,{acceptedFileTypes:e.acceptedFileTypes,maxFileCount:e.maxFileCount,maxFileSize:e.maxFileSize,uploadFileEndpoint:e.uploadFileEndpoint,deleteFileEndpoint:e.deleteFileEndpoint,onFileUpdate:function(e,r){t("add"===e?function(e){return se(se([],e,!0),[{name:r}],!1)}:function(e){return e.filter((function(e){return e.name!==r}))})},messageId:a,filePreviewsContainer:f,errorMessagesContainer:v,showFullName:e.showFullName,getUploadData:e.getUploadData})})}))})}ue.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const de=ue;return a})()));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={342:e=>{e.exports=require("emoji-picker-element")}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,i),a.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(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 a=Object.create(null);i.r(a);var o={};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=>o[e]=()=>t[e]));return o.default=()=>t,i.d(a,o),a},i.d=(e,r)=>{for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},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 a={};i.r(a),i.d(a,{default:()=>fe});const o=require("react/jsx-runtime"),c=require("@mui/material/Box");var l=i.n(c);const s=require("@mui/material/styles"),u=require("react"),d=require("uuid"),f=require("@mui/material/CircularProgress");var p=i.n(f);const m=require("@mui/material/IconButton");var h=i.n(m);const v=require("@mui/material/InputAdornment");var g=i.n(v);const x=require("@mui/material/MenuItem");var b=i.n(x);const j=require("@mui/material/MenuList");var y=i.n(j);const w=require("@mui/material/Popover");var S=i.n(w);const C=require("@mui/material/TextField");var N=i.n(C);const k=require("@mui/material/Tooltip");var F=i.n(k);const P=require("@mui/material/Typography");var O=i.n(P),E=i(342),q=function(){return q=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},q.apply(this,arguments)};function T(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:q({},r),children:e.name})}const z=function(e){var r=(0,s.useTheme)(),t=(0,u.useRef)(null),n=(0,u.useRef)(null),a=(0,u.useState)(!1),c=a[0],l=a[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 p(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),f()}return(0,u.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(i.t.bind(i,342,23)).then((function(e){var t=new(0,e.Picker),i="dark"===r.palette.mode?"dark":"light";t.classList.add(i),Object.keys(d).forEach((function(e){t.style.setProperty(e,d[e])})),n.current=t})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",p),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[c,e.onEmojiClick]),(0,o.jsxs)("div",{children:[(0,o.jsx)(F(),{title:"Emoji",children:(0,o.jsx)(h(),{size:"small",ref:t,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,o.jsx)(T,{name:"Mood"})})}),n.current&&(0,o.jsx)(S(),{open:c,anchorEl:t.current,onClose:f,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,o.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&n.current&&!e.contains(n.current)&&e.appendChild(n.current)}})})]})};var I={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function R(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var _=new E.Database,A=(0,u.forwardRef)((function(e,r){var t=(0,u.useState)(""),n=t[0],i=t[1],a=(0,u.useState)(!1),c=a[0],s=a[1],f=(0,u.useState)(!1),m=f[0],v=f[1],x=(0,u.useState)(!1),j=x[0],w=x[1],C=(0,u.useState)(""),k=C[0],P=C[1],E=(0,u.useState)([]),q=E[0],A=E[1],D=(0,u.useState)(!1),M=D[0],U=D[1],B=(0,u.useRef)(null),L=!n.trim().length&&!e.isSendEnabled,W="".concat(c?"Stop":"Start"," speech to text"),H=m?"primary.main":"primary.light",V=c?"error.main":H,$=c?"stop_circle":"speech_to_text";function G(e,r){if(void 0===r&&(r=!1),B.current){var t=B.current,a=t.selectionStart,o=t.selectionEnd;if("number"==typeof a&&"number"==typeof o){var c,l=n||"",s=l.substring(0,a),u=l.substring(o);c=r?s.replace(/:(\w+)$/,e)+u:s+e+u,i(c);var d=r?s.replace(/:(\w+)$/,e).length:a+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=j?(0,o.jsx)(p(),{size:24}):(0,o.jsx)(F(),{title:W,children:(0,o.jsx)(h(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,c?(e.stop(),w(!0),s(!1)):(e.start(),P(""),s(!0)),e.onstart=function(){s(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;n.length>0?i(n+" "+t):i(t),null===(r=B.current)||void 0===r||r.focus(),s(!1)},e.onerror=function(e){var r=I[e.error];P(r),s(!1)},e.onend=function(){w(!1),s(!1)}},size:"small",sx:{color:V,"&:hover":{color:"primary.main"}},children:(0,o.jsx)(T,{name:$})})});function Q(){var r=(new Date).toISOString(),t={id:(0,d.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:n}};e.send(t),i(""),P("")}return(0,o.jsxs)(l(),{className:"rustic-base-input",ref:r,children:[(0,o.jsxs)(l(),{className:"rustic-error-and-input-container",children:[(0,o.jsx)(l(),{className:"rustic-error-container",children:(0,o.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:k})}),(0,o.jsxs)(l(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:m?"secondary.main":"action.disabled"},children:[q.length>0&&(0,o.jsx)(S(),{open:M,anchorEl:B.current,onClose:function(){return U(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,o.jsx)(y(),{children:q.map((function(e,r){return"unicode"in e&&(0,o.jsx)(b(),{onClick:function(){return G(e.unicode,!0)},children:R(e)},r)}))})}),(0,o.jsx)(N(),{className:"rustic-text-field",variant:"outlined",value:n,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!L&&Q())},onChange:function(r){P("");var t=r.target.value;i(t);var n,a=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(a){var c=a[0].replace(/:/g,"");_.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=t.replace(a[0],e.unicode);i(r)}else i(t)})).catch((function(){i(t)})),U(!1)}else o?(n=o[0].replace(":",""),_.getEmojiBySearchQuery(n).then((function(r){r.length?(A(r.slice(0,e.maximumEmojiSearchResults)),U(!0)):(A([]),U(!1))})).catch((function(){A([]),U(!1)}))):U(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:B,color:"secondary",size:"small",InputProps:{endAdornment:(0,o.jsxs)(g(),{position:"end",className:"rustic-input-adornment",children:[(0,o.jsx)(z,{onEmojiClick:G,buttonColor:H}),e.enableSpeechToText&&K]})},InputLabelProps:{className:m?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,o.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,o.jsxs)(l(),{className:"rustic-input-actions",children:[e.children,(0,o.jsx)(F(),{title:"Send",children:(0,o.jsx)("span",{className:"rustic-send-button",children:(0,o.jsx)(h(),{"aria-label":"send message",onClick:Q,disabled:L,color:"secondary",children:(0,o.jsx)(T,{name:"send"})})})})]})]})}));A.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const D=A,M=require("@mui/material/LinearProgress");var U=i.n(M);const B=require("axios");var L=i.n(B);const W=require("react-dom"),H=require("@mui/material/Card");var V=i.n(H);const $=require("@mui/material/Modal");var G,K=i.n($);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(G||(G={}));const Q=require("@mui/material/useMediaQuery");var Y=i.n(Q);const Z=require("@mui/system/Stack");var J=i.n(Z);const X=require("@mui/system/useTheme");var ee=i.n(X);const re=require("pdfjs-dist"),te=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,o.jsx)(F(),{title:t.label,children:(0,o.jsx)("span",{children:(0,o.jsx)(h(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,o.jsx)(T,{name:t.symbol})})})})};var ne={pdf:function(e){var r,t=(0,u.useRef)(null),n=(0,u.useState)(1),i=n[0],a=n[1],c=(0,u.useState)(1),s=c[0],d=c[1],f=(0,u.useState)(1),p=f[0],m=f[1],h=(0,u.useState)(!1),v=h[0],g=h[1],x=(0,u.useState)(),b=x[0],j=x[1],y=ee()(),w=Y()(y.breakpoints.down("sm")),S=Y()(y.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,o.jsx)(V(),{variant:"outlined",className:"rustic-pdf-error",children:(0,o.jsx)(O(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var C=(0,u.useState)((function(){return w?.5:S?1:1.5})),k=C[0],F=C[1];return(0,u.useEffect)((function(){re.GlobalWorkerOptions.workerSrc||(re.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(re.version,"/pdf.worker.mjs")),re.getDocument({url:"".concat(e.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(i).then((function(e){var r=e.getViewport({scale:k}),n=t.current;if(n){var i=n.getContext("2d");if(i){var a=window.devicePixelRatio||1;n.style.width="".concat(r.width,"px"),n.style.height="".concat(r.height,"px"),n.width=r.width*a,n.height=r.height*a;var o={canvasContext:i,viewport:r,transform:[a,0,0,a,0,0]};b&&b.cancel();var c=e.render(o);j(c),c.promise.then((function(){j(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[e.url,i,k]),v?(0,o.jsx)(V(),{variant:"outlined",className:"rustic-pdf-error",children:(0,o.jsx)(O(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,o.jsxs)(V(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,o.jsxs)(l(),{className:"rustic-pdf-viewer-header",children:[(0,o.jsx)(te,{action:"zoomOut",onClick:function(){F((function(e){return Math.max(e-.2,.2)}))}}),(0,o.jsx)(te,{action:"zoomIn",onClick:function(){F((function(e){return e+.2}))}})]}),(0,o.jsx)(l(),{className:"rustic-pdf-viewer-body",children:(0,o.jsx)(l(),{className:"rustic-pdf-viewer-body-inner",children:(0,o.jsx)("canvas",{ref:t})})}),(0,o.jsxs)(J(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,o.jsx)(te,{action:"previousPage",onClick:function(){i>1&&(a(i-1),m(i-1))},isDisabled:1===i}),(0,o.jsx)(O(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,o.jsx)(N(),{type:"number",value:p,onChange:function(e){var r=parseInt(e.target.value);m(r),!isNaN(r)&&r>=1&&r<=s&&a(r)},size:"small",className:"rustic-pdf-page-input"}),(0,o.jsxs)(O(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,o.jsx)(te,{action:"nextPage",onClick:function(){i<s&&(a(i+1),m(i+1))},isDisabled:i===s})]})]})}};function ie(e){var r=(0,s.useTheme)(),t=(0,u.useState)(!1),n=t[0],i=t[1];function a(){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,m=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",v=p?" rustic-cursor-pointer":"",g="rustic-file-preview ".concat(m).concat(v),x=e.showFullName?e.file.name:(15,(l=e.file.name).length<=15?l:l.substring(0,12)+"...");return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(V(),{className:g,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){i(!0)},children:[(0,o.jsx)(O(),{variant:"subtitle2",children:x}),(0,o.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,o.jsx)(K(),{open:n,onClose:a,className:"rustic-file-preview-modal",children:(0,o.jsxs)("div",{className:"rustic-modal-content",children:[(0,o.jsx)(F(),{title:"Close",children:(0,o.jsx)(h(),{onClick:a,className:"rustic-close-button",children:(0,o.jsx)(T,{name:"close"})})}),e.file.url&&(0,o.jsx)(f,{url:e.file.url})]})})]})}ie.defaultProps={supportedViewers:ne};var ae=function(){return ae=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},ae.apply(this,arguments)},oe=function(e,r,t){if(t||2===arguments.length)for(var n,i=0,a=r.length;i<a;i++)!n&&i in r||(n||(n=Array.prototype.slice.call(r,0,i)),n[i]=r[i]);return e.concat(n||Array.prototype.slice.call(r))};function ce(e){for(var r=["Bytes","KB","MB","GB"],t=0;e>=1024&&t<r.length-1;)e/=1024,t++;var n=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(n," ").concat(r[t])}const le=function(e){var r=(0,u.useState)([]),t=r[0],n=r[1],i=(0,u.useState)([]),a=i[0],c=i[1],s=(0,u.useRef)({}),f=(0,d.v4)();(0,u.useEffect)((function(){n([]),c([]),s.current={}}),[e.messageId]);var p=(0,o.jsx)(l(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,t){return(0,o.jsx)(ie,{file:{name:r.name},showFullName:e.showFullName,children:(0,o.jsxs)(l(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,o.jsx)(U(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,o.jsx)(F(),{title:"Delete",children:(0,o.jsx)(h(),{color:"primary",onClick:function(){return function(r,t){var i,a;c([]);var o=r.name;if(s.current=ae(ae({},s.current),((i={})[o]=s.current[o]--,i)),e.onFileUpdate("remove",o),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",o).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);L().delete(l).then((function(){return n((function(e){return e.filter((function(e,r){return r!==t}))}))})).catch((function(){return e.onFileUpdate("add",o),c((function(e){return oe(oe([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else r.abortController.abort(),n((function(e){return e.filter((function(e,r){return r!==t}))})),s.current=ae(ae({},s.current),((a={})[o]=s.current[o]++,a))}(r,t)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,o.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},t)}))}),m=(0,o.jsx)(l(),{children:a.map((function(e,r){return(0,o.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function v(e,r){return r?(0,W.createPortal)(e,r):e}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(l(),{className:"rustic-uploader",children:[(0,o.jsx)("label",{htmlFor:f,children:(0,o.jsx)(F(),{title:"Upload",children:(0,o.jsx)(h(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,o.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,o.jsx)("input",{type:"file",id:f,onChange:function(r){c([]);var i=r.target.files&&Array.from(r.target.files),a=t.length+(i?i.length:0);e.maxFileCount&&a>e.maxFileCount&&c((function(r){return oe(oe([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var o=i&&function(e,r,t){return t?r<=t?e:e.slice(0,t-r):e}(i,a,e.maxFileCount);o&&o.forEach((function(r){!function(r){var t;e.maxFileSize&&r.size>e.maxFileSize?(t=r.name,c((function(r){return oe(oe([],r,!0),["Failed to upload ".concat(t,". You cannot upload files larger than ").concat(e.maxFileSize&&ce(e.maxFileSize),".")],!1)}))):function(r){var t=new FormData,i=new AbortController,a=function(e){var r,t,n=e.name,i=s.current[n];if(i){var a=i+1,o=n.lastIndexOf("."),c=n.substring(0,o),l=n.substring(o);n="".concat(c,"(").concat(i,")").concat(l),s.current=ae(ae({},s.current),((r={})[e.name]=a,r))}else s.current=ae(ae({},s.current),((t={})[e.name]=1,t));return n}(r),o=new File([r],a,{type:r.type});if(e.getUploadData){var l=e.getUploadData(a);Object.keys(l).map((function(e){t.append(e,l[e])}))}t.append("file",o);var u=(0,d.v4)(),f={name:a,loadingProgress:0,abortController:i,id:u};n((function(e){return oe(oe([],e,!0),[f],!1)})),e.onFileUpdate("add",a);var p="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);L().post(p,t,{onUploadProgress:function(e){var r,t;e.total&&(r=e.loaded/e.total*100,t=f.id,n((function(e){var n=e.map((function(e){return e.id===t?ae(ae({},e),{loadingProgress:r}):e}));return n})))},signal:i.signal}).then((function(e){var r,t;e.data.fileId&&(r=e.data,t=f.id,n((function(e){var n=e.findIndex((function(e){return e.id===t}));if(-1!==n){var i=oe([],e,!0);return i[n]=ae(ae({},i[n]),{id:r.fileId}),i}return e})))})).catch((function(t){var i,o;e.onFileUpdate("remove",a),s.current=ae(ae({},s.current),((i={})[a]=s.current[r.name]--,i)),function(e,r,t){c((function(r){return oe(oe([],r,!0),["Failed to upload ".concat(e,". ").concat((null==t?void 0:t.message)||"")],!1)})),n((function(e){return e.filter((function(e){return e.id!==r}))}))}(r.name,f.id,null===(o=t.response)||void 0===o?void 0:o.data)}))}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),a.length>0&&v(m,e.errorMessagesContainer),t.length>0&&v(p,e.filePreviewsContainer)]})};var se=function(){return se=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},se.apply(this,arguments)},ue=function(e,r,t){if(t||2===arguments.length)for(var n,i=0,a=r.length;i<a;i++)!n&&i in r||(n||(n=Array.prototype.slice.call(r,0,i)),n[i]=r[i]);return e.concat(n||Array.prototype.slice.call(r))};function de(e){var r=(0,u.useState)([]),t=r[0],n=r[1],i=(0,u.useState)((0,d.v4)()),a=i[0],c=i[1],f=(0,u.useState)(),p=f[0],m=f[1],h=(0,u.useState)(),v=h[0],g=h[1],x=(0,u.useRef)(null),b=(0,s.useTheme)(),j=t.length>0;return(0,u.useEffect)((function(){x.current&&(g(x.current.querySelector(".rustic-error-container")),m(x.current.querySelector(".rustic-input-extras")))})),(0,o.jsx)(l(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(b.palette.action.disabled),borderRadius:"".concat(b.shape.borderRadius,"px"),":focus-within":{borderColor:b.palette.secondary.main},background:b.palette.background.paper},children:(0,o.jsx)(D,se({},e,{send:function(r){j&&(r.id=a,r.format="filesWithText",r.data.files=t),e.ws.send(r),c((0,d.v4)()),n([])},isSendEnabled:j,ref:x,children:(0,o.jsx)(l(),{className:"rustic-bottom-buttons",children:(0,o.jsx)(le,{acceptedFileTypes:e.acceptedFileTypes,maxFileCount:e.maxFileCount,maxFileSize:e.maxFileSize,uploadFileEndpoint:e.uploadFileEndpoint,deleteFileEndpoint:e.deleteFileEndpoint,onFileUpdate:function(e,r){n("add"===e?function(e){return ue(ue([],e,!0),[{name:r}],!1)}:function(e){return e.filter((function(e){return e.name!==r}))})},messageId:a,filePreviewsContainer:p,errorMessagesContainer:v,showFullName:e.showFullName,getUploadData:e.getUploadData})})}))})}de.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const fe=de;return a})()));
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={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 l=require("@mui/material/LinearProgress");var s=e.n(l);const c=require("@mui/material/Tooltip");var u=e.n(c);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"),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 F(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 C=require("@mui/material/TextField");var P=e.n(C);const S=require("@mui/material/useMediaQuery");var k=e.n(S);const q=require("@mui/system/Stack");var O=e.n(q);const I=require("@mui/system/useTheme");var A=e.n(I);const T=require("pdfjs-dist"),z=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)(F,{name:t.symbol})})})})};var D={pdf:function(e){var r,t=(0,v.useRef)(null),i=(0,v.useState)(1),o=i[0],l=i[1],s=(0,v.useState)(1),c=s[0],u=s[1],d=(0,v.useState)(1),m=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=A()(),F=k()(N.breakpoints.down("sm")),C=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)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var S=(0,v.useState)((function(){return F?.5:C?1:1.5})),q=S[0],I=S[1];return(0,v.useEffect)((function(){T.GlobalWorkerOptions.workerSrc||(T.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(T.version,"/pdf.worker.mjs")),T.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 l=e.render(o);w(l),l.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)(f(),{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)(z,{action:"zoomOut",onClick:function(){I((function(e){return Math.max(e-.2,.2)}))}}),(0,n.jsx)(z,{action:"zoomIn",onClick:function(){I((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)(z,{action:"previousPage",onClick:function(){o>1&&(l(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<=c&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,n.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",c]}),(0,n.jsx)(z,{action:"nextPage",onClick:function(){o<c&&(l(o+1),p(o+1))},isDisabled:o===c})]})]})}};function U(e){var r=(0,w.useTheme)(),t=(0,v.useState)(!1),a=t[0],i=t[1];function l(){i(!1)}var s,c,d=e.file.url&&(s=e.file.url.split("."))[s.length-1].toLowerCase(),m=d&&e.supportedViewers?e.supportedViewers[d]:null,p=!!m,h=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",g=p?" rustic-cursor-pointer":"",x="rustic-file-preview ".concat(h).concat(g),j=e.showFullName?e.file.name:(15,(c=e.file.name).length<=15?c:c.substring(0,12)+"...");return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(b(),{className:x,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){i(!0)},children:[(0,n.jsx)(f(),{variant:"subtitle2",children:j}),(0,n.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,n.jsx)(y(),{open:a,onClose:l,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:l,className:"rustic-close-button",children:(0,n.jsx)(F,{name:"close"})})}),e.file.url&&(0,n.jsx)(m,{url:e.file.url})]})})]})}U.defaultProps={supportedViewers:D};var _=function(){return _=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},_.apply(this,arguments)},M=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],l=(0,v.useState)([]),c=l[0],d=l[1],m=(0,v.useRef)({}),x=(0,g.v4)();(0,v.useEffect)((function(){i([]),d([]),m.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)(U,{file:{name:r.name},showFullName:e.showFullName,children:(0,n.jsxs)(a(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,n.jsx)(s(),{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=_(_({},m.current),((t={})[o]=m.current[o]--,t)),e.onFileUpdate("remove",o),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",o).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);p().delete(l).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 M(M([],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=_(_({},m.current),((a={})[o]=m.current[o]++,a))}(r,t)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,n.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},t)}))}),j=(0,n.jsx)(a(),{children:c.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:x,children:(0,n.jsx)(u(),{title:"Upload",children:(0,n.jsx)(o(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},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 M(M([],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 M(M([],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("."),l=t.substring(0,o),s=t.substring(o);t="".concat(l,"(").concat(a,")").concat(s),m.current=_(_({},m.current),((r={})[e.name]=i,r))}else m.current=_(_({},m.current),((n={})[e.name]=1,n));return t}(r),o=new File([r],a,{type:r.type});if(e.getUploadData){var l=e.getUploadData(a);Object.keys(l).map((function(e){n.append(e,l[e])}))}n.append("file",o);var s=(0,g.v4)(),c={name:a,loadingProgress:0,abortController:t,id:s};i((function(e){return M(M([],e,!0),[c],!1)})),e.onFileUpdate("add",a);var u="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);p().post(u,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?_(_({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;e.data.fileId&&(r=e.data,n=c.id,i((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=M([],e,!0);return a[t]=_(_({},a[t]),{id:r.fileId}),a}return e})))})).catch((function(n){var t,o;e.onFileUpdate("remove",a),m.current=_(_({},m.current),((t={})[a]=m.current[r.name]--,t)),function(e,r,n){d((function(r){return M(M([],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})]}),c.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 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:()=>R});const t=require("react/jsx-runtime"),n=require("@mui/material/Box");var a=e.n(n);const i=require("@mui/material/IconButton");var o=e.n(i);const l=require("@mui/material/LinearProgress");var s=e.n(l);const c=require("@mui/material/Tooltip");var u=e.n(c);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"),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(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(N||(N={}));var F=function(){return F=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},F.apply(this,arguments)};function C(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:F({},r),children:e.name})}const P=require("@mui/material/TextField");var S=e.n(P);const O=require("@mui/material/useMediaQuery");var k=e.n(O);const q=require("@mui/system/Stack");var I=e.n(q);const A=require("@mui/system/useTheme");var T=e.n(A);const z=require("pdfjs-dist"),D=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,t.jsx)(u(),{title:n.label,children:(0,t.jsx)("span",{children:(0,t.jsx)(o(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,t.jsx)(C,{name:n.symbol})})})})};var U={pdf:function(e){var r,n=(0,v.useRef)(null),i=(0,v.useState)(1),o=i[0],l=i[1],s=(0,v.useState)(1),c=s[0],u=s[1],d=(0,v.useState)(1),m=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=T()(),F=k()(N.breakpoints.down("sm")),C=k()(N.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,t.jsx)(b(),{variant:"outlined",className:"rustic-pdf-error",children:(0,t.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var P=(0,v.useState)((function(){return F?.5:C?1:1.5})),O=P[0],q=P[1];return(0,v.useEffect)((function(){z.GlobalWorkerOptions.workerSrc||(z.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(z.version,"/pdf.worker.mjs")),z.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:O}),t=n.current;if(t){var a=t.getContext("2d");if(a){var i=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*i,t.height=r.height*i;var o={canvasContext:a,viewport:r,transform:[i,0,0,i,0,0]};y&&y.cancel();var l=e.render(o);w(l),l.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){x(!0)}))}),[e.url,o,O]),g?(0,t.jsx)(b(),{variant:"outlined",className:"rustic-pdf-error",children:(0,t.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,t.jsxs)(b(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,t.jsxs)(a(),{className:"rustic-pdf-viewer-header",children:[(0,t.jsx)(D,{action:"zoomOut",onClick:function(){q((function(e){return Math.max(e-.2,.2)}))}}),(0,t.jsx)(D,{action:"zoomIn",onClick:function(){q((function(e){return e+.2}))}})]}),(0,t.jsx)(a(),{className:"rustic-pdf-viewer-body",children:(0,t.jsx)(a(),{className:"rustic-pdf-viewer-body-inner",children:(0,t.jsx)("canvas",{ref:n})})}),(0,t.jsxs)(I(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,t.jsx)(D,{action:"previousPage",onClick:function(){o>1&&(l(o-1),p(o-1))},isDisabled:1===o}),(0,t.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,t.jsx)(S(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=c&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,t.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",c]}),(0,t.jsx)(D,{action:"nextPage",onClick:function(){o<c&&(l(o+1),p(o+1))},isDisabled:o===c})]})]})}};function _(e){var r=(0,w.useTheme)(),n=(0,v.useState)(!1),a=n[0],i=n[1];function l(){i(!1)}var s,c,d=e.file.url&&(s=e.file.url.split("."))[s.length-1].toLowerCase(),m=d&&e.supportedViewers?e.supportedViewers[d]:null,p=!!m,h=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",g=p?" rustic-cursor-pointer":"",x="rustic-file-preview ".concat(h).concat(g),j=e.showFullName?e.file.name:(15,(c=e.file.name).length<=15?c:c.substring(0,12)+"...");return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(b(),{className:x,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){i(!0)},children:[(0,t.jsx)(f(),{variant:"subtitle2",children:j}),(0,t.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,t.jsx)(y(),{open:a,onClose:l,className:"rustic-file-preview-modal",children:(0,t.jsxs)("div",{className:"rustic-modal-content",children:[(0,t.jsx)(u(),{title:"Close",children:(0,t.jsx)(o(),{onClick:l,className:"rustic-close-button",children:(0,t.jsx)(C,{name:"close"})})}),e.file.url&&(0,t.jsx)(m,{url:e.file.url})]})})]})}_.defaultProps={supportedViewers:U};var M=function(){return M=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},M.apply(this,arguments)},E=function(e,r,t){if(t||2===arguments.length)for(var n,a=0,i=r.length;a<i;a++)!n&&a in r||(n||(n=Array.prototype.slice.call(r,0,a)),n[a]=r[a]);return e.concat(n||Array.prototype.slice.call(r))};function B(e){for(var r=["Bytes","KB","MB","GB"],t=0;e>=1024&&t<r.length-1;)e/=1024,t++;var n=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(n," ").concat(r[t])}const R=function(e){var r=(0,v.useState)([]),n=r[0],i=r[1],l=(0,v.useState)([]),c=l[0],d=l[1],m=(0,v.useRef)({}),x=(0,g.v4)();(0,v.useEffect)((function(){i([]),d([]),m.current={}}),[e.messageId]);var b=(0,t.jsx)(a(),{className:"rustic-files rustic-padding-16",children:n.map((function(r,n){return(0,t.jsx)(_,{file:{name:r.name},showFullName:e.showFullName,children:(0,t.jsxs)(a(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,t.jsx)(s(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,t.jsx)(u(),{title:"Delete",children:(0,t.jsx)(o(),{color:"primary",onClick:function(){return function(r,t){var n,a;d([]);var o=r.name;if(m.current=M(M({},m.current),((n={})[o]=m.current[o]--,n)),e.onFileUpdate("remove",o),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",o).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);p().delete(l).then((function(){return i((function(e){return e.filter((function(e,r){return r!==t}))}))})).catch((function(){return e.onFileUpdate("add",o),d((function(e){return E(E([],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!==t}))})),m.current=M(M({},m.current),((a={})[o]=m.current[o]++,a))}(r,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,t.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),j=(0,t.jsx)(a(),{children:c.map((function(e,r){return(0,t.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,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(a(),{className:"rustic-uploader",children:[(0,t.jsx)("label",{htmlFor:x,children:(0,t.jsx)(u(),{title:"Upload",children:(0,t.jsx)(o(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,t.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,t.jsx)("input",{type:"file",id:x,onChange:function(r){d([]);var t=r.target.files&&Array.from(r.target.files),a=n.length+(t?t.length:0);e.maxFileCount&&a>e.maxFileCount&&d((function(r){return E(E([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var o=t&&function(e,r,t){return t?r<=t?e:e.slice(0,t-r):e}(t,a,e.maxFileCount);o&&o.forEach((function(r){!function(r){var t;e.maxFileSize&&r.size>e.maxFileSize?(t=r.name,d((function(r){return E(E([],r,!0),["Failed to upload ".concat(t,". You cannot upload files larger than ").concat(e.maxFileSize&&B(e.maxFileSize),".")],!1)}))):function(r){var t=new FormData,n=new AbortController,a=function(e){var r,t,n=e.name,a=m.current[n];if(a){var i=a+1,o=n.lastIndexOf("."),l=n.substring(0,o),s=n.substring(o);n="".concat(l,"(").concat(a,")").concat(s),m.current=M(M({},m.current),((r={})[e.name]=i,r))}else m.current=M(M({},m.current),((t={})[e.name]=1,t));return n}(r),o=new File([r],a,{type:r.type});if(e.getUploadData){var l=e.getUploadData(a);Object.keys(l).map((function(e){t.append(e,l[e])}))}t.append("file",o);var s=(0,g.v4)(),c={name:a,loadingProgress:0,abortController:n,id:s};i((function(e){return E(E([],e,!0),[c],!1)})),e.onFileUpdate("add",a);var u="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);p().post(u,t,{onUploadProgress:function(e){var r,t;e.total&&(r=e.loaded/e.total*100,t=c.id,i((function(e){var n=e.map((function(e){return e.id===t?M(M({},e),{loadingProgress:r}):e}));return n})))},signal:n.signal}).then((function(e){var r,t;e.data.fileId&&(r=e.data,t=c.id,i((function(e){var n=e.findIndex((function(e){return e.id===t}));if(-1!==n){var a=E([],e,!0);return a[n]=M(M({},a[n]),{id:r.fileId}),a}return e})))})).catch((function(t){var n,o;e.onFileUpdate("remove",a),m.current=M(M({},m.current),((n={})[a]=m.current[r.name]--,n)),function(e,r,t){d((function(r){return E(E([],r,!0),["Failed to upload ".concat(e,". ").concat((null==t?void 0:t.message)||"")],!1)})),i((function(e){return e.filter((function(e){return e.id!==r}))}))}(r.name,c.id,null===(o=t.response)||void 0===o?void 0:o.data)}))}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),c.length>0&&y(j,e.errorMessagesContainer),n.length>0&&y(b,e.filePreviewsContainer)]})};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,r,t={342:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);o.r(i);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&n&&t;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,o.d(i,a),i},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.r(i),o.d(i,{default:()=>L});const a=require("react/jsx-runtime"),c=require("react"),s=require("@mui/material/Box");var u=o.n(s);const l=require("@mui/material/CircularProgress");var d=o.n(l);const p=require("@mui/material/IconButton");var m=o.n(p);const f=require("@mui/material/InputAdornment");var h=o.n(f);const v=require("@mui/material/MenuItem");var g=o.n(v);const y=require("@mui/material/MenuList");var b=o.n(y);const j=require("@mui/material/Popover");var x=o.n(j);const w=require("@mui/material/TextField");var S=o.n(w);const O=require("@mui/material/Tooltip");var k=o.n(O);const E=require("@mui/material/Typography");var C=o.n(E),P=o(342);const N=require("uuid");function q(e){return e.name.replaceAll("_","-"),(0,a.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}const T=require("@mui/material/styles"),_=function(e){var r=(0,T.useTheme)(),t=(0,c.useRef)(null),n=(0,c.useRef)(null),i=(0,c.useState)(!1),s=i[0],u=i[1],l={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function d(){u(!1)}function p(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),d()}return(0,c.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,342,23)).then((function(e){var t=new(0,e.Picker),o="dark"===r.palette.mode?"dark":"light";t.classList.add(o),Object.keys(l).forEach((function(e){t.style.setProperty(e,l[e])})),n.current=t})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,c.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",p),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[s,e.onEmojiClick]),(0,a.jsxs)("div",{children:[(0,a.jsx)(k(),{title:"Emoji",children:(0,a.jsx)(m(),{size:"small",ref:t,onClick:function(){u((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(q,{name:"Mood"})})}),n.current&&(0,a.jsx)(x(),{open:s,anchorEl:t.current,onClose:d,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,a.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&n.current&&!e.contains(n.current)&&e.appendChild(n.current)}})})]})};var R={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function I(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var z=new P.Database,M=(0,c.forwardRef)((function(e,r){var t=(0,c.useState)(""),n=t[0],o=t[1],i=(0,c.useState)(!1),s=i[0],l=i[1],p=(0,c.useState)(!1),f=p[0],v=p[1],y=(0,c.useState)(!1),j=y[0],w=y[1],O=(0,c.useState)(""),E=O[0],P=O[1],T=(0,c.useState)([]),M=T[0],B=T[1],F=(0,c.useState)(!1),L=F[0],A=F[1],D=(0,c.useRef)(null),W=!n.trim().length&&!e.isSendEnabled,K="".concat(s?"Stop":"Start"," speech to text"),$=f?"primary.main":"primary.light",Q=s?"error.main":$,G=s?"stop_circle":"speech_to_text";function H(e,r){if(void 0===r&&(r=!1),D.current){var t=D.current,i=t.selectionStart,a=t.selectionEnd;if("number"==typeof i&&"number"==typeof a){var c,s=n||"",u=s.substring(0,i),l=s.substring(a);c=r?u.replace(/:(\w+)$/,e)+l:u+e+l,o(c);var d=r?u.replace(/:(\w+)$/,e).length:i+e.length;setTimeout((function(){var e,r;null===(e=D.current)||void 0===e||e.focus(),null===(r=D.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}A(!1)}var J=j?(0,a.jsx)(d(),{size:24}):(0,a.jsx)(k(),{title:K,children:(0,a.jsx)(m(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,s?(e.stop(),w(!0),l(!1)):(e.start(),P(""),l(!0)),e.onstart=function(){l(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;n.length>0?o(n+" "+t):o(t),null===(r=D.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=R[e.error];P(r),l(!1)},e.onend=function(){w(!1),l(!1)}},size:"small",sx:{color:Q,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(q,{name:G})})});function U(){var r=(new Date).toISOString(),t={id:(0,N.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:n}};e.send(t),o(""),P("")}return(0,a.jsxs)(u(),{className:"rustic-base-input",ref:r,children:[(0,a.jsxs)(u(),{className:"rustic-error-and-input-container",children:[(0,a.jsx)(u(),{className:"rustic-error-container",children:(0,a.jsx)(C(),{variant:"caption",color:"error",className:"rustic-error-message",children:E})}),(0,a.jsxs)(u(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[M.length>0&&(0,a.jsx)(x(),{open:L,anchorEl:D.current,onClose:function(){return A(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,a.jsx)(b(),{children:M.map((function(e,r){return"unicode"in e&&(0,a.jsx)(g(),{onClick:function(){return H(e.unicode,!0)},children:I(e)},r)}))})}),(0,a.jsx)(S(),{className:"rustic-text-field",variant:"outlined",value:n,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!W&&U())},onChange:function(r){P("");var t=r.target.value;o(t);var n,i=t.match(/:(\w{2,}):/g),a=t.match(/:(\w{2,})/g);if(i){var c=i[0].replace(/:/g,"");z.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=t.replace(i[0],e.unicode);o(r)}else o(t)})).catch((function(){o(t)})),A(!1)}else a?(n=a[0].replace(":",""),z.getEmojiBySearchQuery(n).then((function(r){r.length?(B(r.slice(0,e.maximumEmojiSearchResults)),A(!0)):(B([]),A(!1))})).catch((function(){B([]),A(!1)}))):A(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:D,color:"secondary",size:"small",InputProps:{endAdornment:(0,a.jsxs)(h(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(_,{onEmojiClick:H,buttonColor:$}),e.enableSpeechToText&&J]})},InputLabelProps:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,a.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,a.jsxs)(u(),{className:"rustic-input-actions",children:[e.children,(0,a.jsx)(k(),{title:"Send",children:(0,a.jsx)("span",{className:"rustic-send-button",children:(0,a.jsx)(m(),{"aria-label":"send message",onClick:U,disabled:W,color:"secondary",children:(0,a.jsx)(q,{name:"send"})})})})]})]})}));M.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const B=M;var F=function(){return F=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},F.apply(this,arguments)};const L=function(e){var r=e.ws,t=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(e,["ws"]);return(0,a.jsx)(B,F({},t,{send:function(e){r.send(e)}}))};return i})()));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={342:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);o.r(i);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&n&&t;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,o.d(i,a),i},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.r(i),o.d(i,{default:()=>A});const a=require("react/jsx-runtime"),c=require("react"),s=require("@mui/material/Box");var u=o.n(s);const l=require("@mui/material/CircularProgress");var d=o.n(l);const p=require("@mui/material/IconButton");var m=o.n(p);const f=require("@mui/material/InputAdornment");var h=o.n(f);const v=require("@mui/material/MenuItem");var y=o.n(v);const g=require("@mui/material/MenuList");var b=o.n(g);const j=require("@mui/material/Popover");var x=o.n(j);const w=require("@mui/material/TextField");var O=o.n(w);const S=require("@mui/material/Tooltip");var k=o.n(S);const E=require("@mui/material/Typography");var P=o.n(E),C=o(342);const N=require("uuid");var q=function(){return q=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},q.apply(this,arguments)};function T(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,a.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:q({},r),children:e.name})}const _=require("@mui/material/styles"),R=function(e){var r=(0,_.useTheme)(),t=(0,c.useRef)(null),n=(0,c.useRef)(null),i=(0,c.useState)(!1),s=i[0],u=i[1],l={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function d(){u(!1)}function p(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),d()}return(0,c.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,342,23)).then((function(e){var t=new(0,e.Picker),o="dark"===r.palette.mode?"dark":"light";t.classList.add(o),Object.keys(l).forEach((function(e){t.style.setProperty(e,l[e])})),n.current=t})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,c.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",p),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[s,e.onEmojiClick]),(0,a.jsxs)("div",{children:[(0,a.jsx)(k(),{title:"Emoji",children:(0,a.jsx)(m(),{size:"small",ref:t,onClick:function(){u((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(T,{name:"Mood"})})}),n.current&&(0,a.jsx)(x(),{open:s,anchorEl:t.current,onClose:d,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,a.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&n.current&&!e.contains(n.current)&&e.appendChild(n.current)}})})]})};var I={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function z(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var M=new C.Database,B=(0,c.forwardRef)((function(e,r){var t=(0,c.useState)(""),n=t[0],o=t[1],i=(0,c.useState)(!1),s=i[0],l=i[1],p=(0,c.useState)(!1),f=p[0],v=p[1],g=(0,c.useState)(!1),j=g[0],w=g[1],S=(0,c.useState)(""),E=S[0],C=S[1],q=(0,c.useState)([]),_=q[0],B=q[1],F=(0,c.useState)(!1),L=F[0],A=F[1],D=(0,c.useRef)(null),W=!n.trim().length&&!e.isSendEnabled,K="".concat(s?"Stop":"Start"," speech to text"),$=f?"primary.main":"primary.light",Q=s?"error.main":$,G=s?"stop_circle":"speech_to_text";function H(e,r){if(void 0===r&&(r=!1),D.current){var t=D.current,i=t.selectionStart,a=t.selectionEnd;if("number"==typeof i&&"number"==typeof a){var c,s=n||"",u=s.substring(0,i),l=s.substring(a);c=r?u.replace(/:(\w+)$/,e)+l:u+e+l,o(c);var d=r?u.replace(/:(\w+)$/,e).length:i+e.length;setTimeout((function(){var e,r;null===(e=D.current)||void 0===e||e.focus(),null===(r=D.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}A(!1)}var J=j?(0,a.jsx)(d(),{size:24}):(0,a.jsx)(k(),{title:K,children:(0,a.jsx)(m(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,s?(e.stop(),w(!0),l(!1)):(e.start(),C(""),l(!0)),e.onstart=function(){l(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;n.length>0?o(n+" "+t):o(t),null===(r=D.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=I[e.error];C(r),l(!1)},e.onend=function(){w(!1),l(!1)}},size:"small",sx:{color:Q,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(T,{name:G})})});function U(){var r=(new Date).toISOString(),t={id:(0,N.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:n}};e.send(t),o(""),C("")}return(0,a.jsxs)(u(),{className:"rustic-base-input",ref:r,children:[(0,a.jsxs)(u(),{className:"rustic-error-and-input-container",children:[(0,a.jsx)(u(),{className:"rustic-error-container",children:(0,a.jsx)(P(),{variant:"caption",color:"error",className:"rustic-error-message",children:E})}),(0,a.jsxs)(u(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[_.length>0&&(0,a.jsx)(x(),{open:L,anchorEl:D.current,onClose:function(){return A(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,a.jsx)(b(),{children:_.map((function(e,r){return"unicode"in e&&(0,a.jsx)(y(),{onClick:function(){return H(e.unicode,!0)},children:z(e)},r)}))})}),(0,a.jsx)(O(),{className:"rustic-text-field",variant:"outlined",value:n,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!W&&U())},onChange:function(r){C("");var t=r.target.value;o(t);var n,i=t.match(/:(\w{2,}):/g),a=t.match(/:(\w{2,})/g);if(i){var c=i[0].replace(/:/g,"");M.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=t.replace(i[0],e.unicode);o(r)}else o(t)})).catch((function(){o(t)})),A(!1)}else a?(n=a[0].replace(":",""),M.getEmojiBySearchQuery(n).then((function(r){r.length?(B(r.slice(0,e.maximumEmojiSearchResults)),A(!0)):(B([]),A(!1))})).catch((function(){B([]),A(!1)}))):A(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:D,color:"secondary",size:"small",InputProps:{endAdornment:(0,a.jsxs)(h(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(R,{onEmojiClick:H,buttonColor:$}),e.enableSpeechToText&&J]})},InputLabelProps:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,a.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,a.jsxs)(u(),{className:"rustic-input-actions",children:[e.children,(0,a.jsx)(k(),{title:"Send",children:(0,a.jsx)("span",{className:"rustic-send-button",children:(0,a.jsx)(m(),{"aria-label":"send message",onClick:U,disabled:W,color:"secondary",children:(0,a.jsx)(T,{name:"send"})})})})]})]})}));B.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const F=B;var L=function(){return L=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},L.apply(this,arguments)};const A=function(e){var r=e.ws,t=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(e,["ws"]);return(0,a.jsx)(F,L({},t,{send:function(e){r.send(e)}}))};return i})()));
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{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
+ !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:()=>h});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 f=e.n(d);const m=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");var b=function(){return b=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},b.apply(this,arguments)};function x(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:b({},r),children:e.name})}const h=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,m.fromLonLat)([e.longitude,e.latitude]),zoom:12}),target:l.current}),t=new(f())({element:u.current,position:(0,m.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)(x,{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 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
+ !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:()=>V});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,g=e.n(h);function N(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(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(E||(E={}));var T=function(){return T=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},T.apply(this,arguments)};function S(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:T({},t),children:e.name})}const _=require("@mui/material/IconButton");var k=e.n(_);function O(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)(g(),{title:n[e.action].label,PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,r.jsx)(k(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(S,{name:n[e.action].symbol,className:"rustic-icon-large"})})})}function P(e){var t="dark"===(0,n.useTheme)().palette.mode,a=N(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 N(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function w(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)(O,{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 B(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)(S,{name:t}),children:(0,r.jsx)(c(),{variant:"overline",children:n})})}function C(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)(O,{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 q(e){var t,n=(0,m.useState)(e.mediaElement.playbackRate),a=n[0],i=n[1];return(0,r.jsx)(g(),{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 M(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)(O,{onClick:n,action:a})}function I(e){var t=N(e.elapsedTimeInSeconds),n=N(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})}I.defaultProps={style:"condensed"};const L=require("@mui/material/Divider");var R=e.n(L);function F(e){var t=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!t&&(0,r.jsx)(R(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(c(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}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,n.useTheme)(),k=(0,m.useRef)(null),L=(0,n.useMediaQuery)(_.breakpoints.down("md"));function R(){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)(O,{action:t,onClick:function(){return f(!d)}})}}function H(){if(k.current)return(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(M,{mediaElement:k.current,movement:"replay"}),(0,r.jsx)(C,{mediaElement:k.current,onError:S}),(0,r.jsx)(M,{mediaElement:k.current,movement:"forward"})]})}function A(){if(e.transcript&&a)return(0,r.jsx)(F,{transcript:e.transcript})}function U(){if(e.transcript)return(0,r.jsx)(B,{isTranscriptVisible:a,setIsTranscriptVisible:function(){return s(!a)}})}function D(){return(0,r.jsx)("video",{src:e.src,ref:k,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){g(e)}null===(e=k.current)||void 0===e||e.addEventListener("timeupdate",(function(){k.current&&j(k.current.currentTime)})),null===(t=k.current)||void 0===t||t.addEventListener("canplay",(function(){g(""),v(!1)})),null===(r=k.current)||void 0===r||r.addEventListener("error",(function(){return a("Failed to load the audio.")})),null===(n=k.current)||void 0===n||n.addEventListener("stalled",(function(){return a("Failed to fetch audio data, but trying.")}))}),[]);var z=L?function(){if(k.current)return(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(I,{elapsedTimeInSeconds:y,durationTimeInSeconds:k.current.duration,style:"wide"}),(0,r.jsx)(P,{mediaElement:k.current}),R(),(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)(w,{mediaElement:k.current}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-right",children:[U(),(0,r.jsxs)(u.Box,{children:[V(),(0,r.jsx)(q,{mediaElement:k.current})]})]})]}),A()]})}:function(){if(k.current)return(0,r.jsxs)(r.Fragment,{children:[R(),(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(P,{mediaElement:k.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)(q,{mediaElement:k.current}),(0,r.jsx)(w,{mediaElement:k.current}),(0,r.jsx)(I,{elapsedTimeInSeconds:y,durationTimeInSeconds:k.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,{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})()));
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:()=>A});const n=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 y=require("@mui/material/Slider");var b=e.n(y);const j=require("@mui/material/Tooltip");var h,g=e.n(j);function N(e){var r=Math.floor(e/3600),n=Math.floor(e%3600/60),t=Math.floor(e%60),i=r>0?"".concat(r,":"):"",a="".concat(r>0?n.toString().padStart(2,"0"):n),o=t.toString().padStart(2,"0");return"".concat(i).concat(a,":").concat(o)}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(h||(h={}));var S=function(){return S=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},S.apply(this,arguments)};function T(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:S({},r),children:e.name})}const k=require("@mui/material/IconButton");var _=e.n(k);function P(e){var r,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,n.jsx)(g(),{title:t[e.action].label,PopperProps:{container:null!==(r=document.fullscreenElement)&&void 0!==r?r:document.body},children:(0,n.jsx)(_(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,n.jsx)(T,{name:t[e.action].symbol,className:"rustic-icon-large"})})})}function C(e){var r="dark"===(0,t.useTheme)().palette.mode,i=N(e.mediaElement.currentTime);return(0,n.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,n.jsx)(E(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:r?"secondary.light":"action.selected"}}})}(),(0,n.jsx)(b(),{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(r,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 r=(0,m.useState)(e.mediaElement.volume),t=r[0],i=r[1],a=(0,m.useState)(e.mediaElement.volume),o=a[0],c=a[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,n.jsxs)(f(),{className:"rustic-volume-settings",children:[(0,n.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,n.jsx)(b(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*t,"%"),value:t,onChange:function(r,n){var t=n;e.mediaElement.muted=0===t,e.mediaElement.volume=t,i(e.mediaElement.volume)}})]})}function B(e){var r=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",t="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,n.jsx)(v(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,n.jsx)(T,{name:r}),children:(0,n.jsx)(s(),{variant:"overline",children:t})})}function O(e){var r=(0,m.useState)(!e.mediaElement.paused),t=r[0],i=r[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,n.jsx)(P,{onClick:function(){t?e.mediaElement.pause():e.mediaElement.play().catch((function(r){e.onError("Failed to play the media. Error: ".concat(r.message))}))},action:a,className:"rustic-pause-play-icon"})}function q(e){var r,t=(0,m.useState)(e.mediaElement.playbackRate),i=t[0],a=t[1];return(0,n.jsx)(g(),{title:"Playback rate",PopperProps:{container:null!==(r=document.fullscreenElement)&&void 0!==r?r:document.body},children:(0,n.jsx)(v(),{onClick:function(){var r=1;e.mediaElement.playbackRate<2&&(r=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=r,a(r)},className:"rustic-playback-rate-button",children:(0,n.jsxs)(s(),{variant:"body1",children:[i,"X"]})})})}function F(e){var r="replay"===e.movement,t=r?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},i=r?"replay":"forward";return(0,n.jsx)(P,{onClick:t,action:i})}function I(e){var r=(0,m.useState)(!!document.pictureInPictureElement),t=r[0],i=r[1],a=e.mediaElement,o=t?"miniPlayerExit":"miniPlayer";return a.onleavepictureinpicture=function(){i(!1)},(0,n.jsx)(P,{onClick:function(){t?document.exitPictureInPicture().then((function(){i(!1)})).catch((function(r){e.onError("Failed to exit mini player. Error: ".concat(r.message))})):a.requestPictureInPicture().then((function(){i(!0)})).catch((function(r){e.onError("Failed to enter mini player. Error: ".concat(r.message))}))},action:o})}function L(e){var r=(0,m.useState)(!!document.fullscreenElement),t=r[0],i=r[1],a=e.element,o=t?"fullscreenExit":"fullscreen";return a.onfullscreenchange=function(){i(!!document.fullscreenElement)},(0,n.jsx)(P,{onClick:function(){t?document.exitFullscreen().then((function(){i(!1)})).catch((function(r){e.onError("Failed to exit fullscreen mode. Error: ".concat(r.message))})):a.requestFullscreen().then((function(){i(!0)})).catch((function(r){e.onError("Failed to enter fullscreen mode. Error: ".concat(r.message))}))},action:o})}function M(e){var r=N(e.elapsedTimeInSeconds),t=N(e.durationTimeInSeconds),i="".concat(r," / ").concat(t);return"wide"===e.style?(0,n.jsxs)(f(),{className:"rustic-time-container",children:[(0,n.jsx)(s(),{variant:"overline",children:r}),(0,n.jsx)(s(),{variant:"overline",children:t})]}):(0,n.jsx)(s(),{variant:"overline",className:"rustic-time-display",children:i})}M.defaultProps={style:"condensed"};const R=require("@mui/material/Divider");var V=e.n(R);function H(e){var r=!!document.fullscreenElement;return(0,n.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!r&&(0,n.jsx)(V(),{orientation:"vertical",flexItem:!0}),(0,n.jsx)(s(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}const A=function(e){var r=(0,m.useState)(!1),i=r[0],o=r[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),y=E[0],b=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)(""),_=k[0],R=k[1],V=(0,m.useState)(0),A=V[0],U=V[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,r,n,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===(r=z.current)||void 0===r||r.addEventListener("canplay",(function(){R(""),x(!1)})),null===(n=z.current)||void 0===n||n.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(){b(!!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,n.jsx)(H,{transcript:e.transcript})}function K(){if(e.captions&&e.captions.length>0){var r=d?"captionsOff":"captionsOn";return(0,n.jsx)(P,{action:r,onClick:function(){return f(!d)}})}}function W(){if(e.transcript)return(0,n.jsx)(B,{isTranscriptVisible:i,setIsTranscriptVisible:function(){return o(!i)}})}var Y=X?function(){return y?(0,n.jsx)(n.Fragment,{children:z.current&&D.current&&(0,n.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,n.jsxs)(u.Box,{className:"rustic-video-top-controls",children:[(0,n.jsx)(O,{mediaElement:z.current,onError:T}),(0,n.jsx)(C,{mediaElement:z.current}),(0,n.jsx)(M,{elapsedTimeInSeconds:A,durationTimeInSeconds:z.current.duration})]}),(0,n.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,n.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,n.jsx)(F,{mediaElement:z.current,movement:"replay"}),(0,n.jsx)(F,{mediaElement:z.current,movement:"forward"}),K(),(0,n.jsx)(q,{mediaElement:z.current})]}),W()]}),J()]})}):(0,n.jsx)(n.Fragment,{children:z.current&&D.current&&(0,n.jsxs)(u.Box,{className:"rustic-video-controls-mobile-preview",children:[(0,n.jsx)(O,{mediaElement:z.current,onError:T}),(0,n.jsxs)(u.Box,{className:"rustic-video-controls-right",children:[W(),(0,n.jsx)(L,{element:D.current,onError:T})]})]})})}:function(){return(0,n.jsx)(n.Fragment,{children:z.current&&D.current&&(0,n.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,n.jsx)(C,{mediaElement:z.current}),(0,n.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,n.jsxs)(u.Box,{className:"rustic-video-bottom-controls-left",children:[(0,n.jsx)(O,{mediaElement:z.current,onError:T}),(0,n.jsx)(F,{mediaElement:z.current,movement:"replay"}),(0,n.jsx)(F,{mediaElement:z.current,movement:"forward"}),K(),(0,n.jsx)(q,{mediaElement:z.current}),(0,n.jsx)(w,{mediaElement:z.current}),(0,n.jsx)(M,{elapsedTimeInSeconds:A,durationTimeInSeconds:z.current.duration,style:"condensed"})]}),(0,n.jsxs)(u.Box,{className:"rustic-video-bottom-controls-right",children:[W(),(0,n.jsx)(I,{mediaElement:z.current,onError:T}),(0,n.jsx)(L,{element:D.current,onError:T})]})]}),y&&J()]})})};return _.length>0?(0,n.jsx)(a(),{severity:"error",children:_}):(0,n.jsxs)(u.Box,{className:"rustic-video",children:[v&&(0,n.jsx)(c(),{className:"rustic-video-loading-spinner"}),(0,n.jsxs)(u.Box,{ref:D,className:"rustic-video-screen",sx:{visibility:v?"hidden":"visible"},children:[S.length>0&&(0,n.jsx)(a(),{severity:"error",className:"rustic-control-error",onClose:function(){return T("")},children:S}),(!X||y)&&function(){if(z.current&&D.current)return(0,n.jsxs)(u.Box,{className:"rustic-video-title",sx:G,children:[(0,n.jsx)(s(),{variant:"body2",children:e.title}),y&&X&&(0,n.jsxs)(u.Box,{children:[(0,n.jsx)(I,{mediaElement:z.current,onError:T}),(0,n.jsx)(L,{element:D.current,onError:T})]})]})}(),(0,n.jsx)("video",{className:"rustic-video-element",ref:z,src:e.src,poster:e.poster,children:d&&(0,n.jsx)("track",{src:e.captions,kind:"captions",default:!0})}),Y()]}),!y&&J()]})};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 o=r&&r.__esModule?()=>r.default:()=>r;return e.d(o,{a:o}),o},d:(r,o)=>{for(var n in o)e.o(o,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:o[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:()=>N});const o=require("react/jsx-runtime"),n=require("@mui/material"),t=require("@mui/material/Button");var a=e.n(t);const i=require("@mui/material/Drawer");var c=e.n(i);const s=require("@mui/material/IconButton");var u=e.n(s);const l=require("@mui/material/ListItemText");var m=e.n(l);const d=require("@mui/material/Menu");var p=e.n(d);const b=require("@mui/material/MenuItem");var f=e.n(b);const x=require("@mui/material/styles"),h=require("@mui/material/Tooltip");var v=e.n(h);const y=require("@mui/material/Typography");var j=e.n(y);const g=require("@mui/system"),q=require("react");function w(e){return e.name.replaceAll("_","-"),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}var k=function(){return k=Object.assign||function(e){for(var r,o=1,n=arguments.length;o<n;o++)for(var t in r=arguments[o])Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e},k.apply(this,arguments)};const N=function(e){var r=(0,q.useState)(!1),t=r[0],i=r[1],s=(0,q.useRef)(null),l=(0,x.useTheme)(),d=(0,n.useMediaQuery)(l.breakpoints.down("md")),b=d?c():p(),h={borderRadius:"".concat(l.shape.borderRadius,"px"),border:"1px solid ".concat(l.palette.divider)};function y(e){return(0,o.jsxs)(o.Fragment,{children:[e.startDecorator&&(0,o.jsx)(g.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,o.jsx)(m(),{children:(0,o.jsx)(j(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,o.jsx)(g.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}d&&(h=k(k({},h),{borderRadius:"".concat(l.shape.borderRadius,"px ").concat(l.shape.borderRadius,"px 0 0"),borderBottom:0}));var N=e.menuItems.map((function(e){return e.href?(0,o.jsx)(f(),{component:"a",onClick:function(){return i(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:y(e)},e.label):(0,o.jsx)(f(),{onClick:function(r){e.onClick&&e.onClick(r),i(!1)},disabled:!e.onClick,children:y(e)},e.label)}));var O,T,C=d?{}:{anchorEl:s.current};return(0,o.jsxs)(o.Fragment,{children:[(O={onClick:function(e){e.stopPropagation(),i(!0)},"aria-label":e.ariaLabel,ref:s,className:"rustic-popover-menu-button"},T=(0,o.jsx)(w,{name:"more_vert"}),e.buttonText?(0,o.jsx)(a(),k({},O,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,o.jsx)(v(),{title:e.ariaLabel,children:(0,o.jsx)(u(),k({},O,{children:e.icon?e.icon:T}))})),(0,o.jsx)(b,k({open:t,onClose:function(){return i(!1)}},C,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":k(k({},h),{backgroundImage:"none",boxShadow:l.shadows[2]})},children:N}))]})};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 o=r&&r.__esModule?()=>r.default:()=>r;return e.d(o,{a:o}),o},d:(r,o)=>{for(var t in o)e.o(o,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:o[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:()=>N});const o=require("react/jsx-runtime"),t=require("@mui/material"),n=require("@mui/material/Button");var a=e.n(n);const i=require("@mui/material/Drawer");var c=e.n(i);const s=require("@mui/material/IconButton");var u=e.n(s);const l=require("@mui/material/ListItemText");var m=e.n(l);const d=require("@mui/material/Menu");var p=e.n(d);const b=require("@mui/material/MenuItem");var f=e.n(b);const h=require("@mui/material/styles"),v=require("@mui/material/Tooltip");var x=e.n(v);const y=require("@mui/material/Typography");var j=e.n(y);const g=require("@mui/system"),q=require("react");var O=function(){return O=Object.assign||function(e){for(var r,o=1,t=arguments.length;o<t;o++)for(var n in r=arguments[o])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},O.apply(this,arguments)};function w(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:O({},r),children:e.name})}var k=function(){return k=Object.assign||function(e){for(var r,o=1,t=arguments.length;o<t;o++)for(var n in r=arguments[o])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},k.apply(this,arguments)};const N=function(e){var r=(0,q.useState)(!1),n=r[0],i=r[1],s=(0,q.useRef)(null),l=(0,h.useTheme)(),d=(0,t.useMediaQuery)(l.breakpoints.down("md")),b=d?c():p(),v={borderRadius:"".concat(l.shape.borderRadius,"px"),border:"1px solid ".concat(l.palette.divider)};function y(e){return(0,o.jsxs)(o.Fragment,{children:[e.startDecorator&&(0,o.jsx)(g.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,o.jsx)(m(),{children:(0,o.jsx)(j(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,o.jsx)(g.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}d&&(v=k(k({},v),{borderRadius:"".concat(l.shape.borderRadius,"px ").concat(l.shape.borderRadius,"px 0 0"),borderBottom:0}));var O=e.menuItems.map((function(e){return e.href?(0,o.jsx)(f(),{component:"a",onClick:function(){return i(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:y(e)},e.label):(0,o.jsx)(f(),{onClick:function(r){e.onClick&&e.onClick(r),i(!1)},disabled:!e.onClick,children:y(e)},e.label)}));var N,P,T=d?{}:{anchorEl:s.current};return(0,o.jsxs)(o.Fragment,{children:[(N={onClick:function(e){e.stopPropagation(),i(!0)},"aria-label":e.ariaLabel,ref:s,className:"rustic-popover-menu-button"},P=(0,o.jsx)(w,{name:"more_vert"}),e.buttonText?(0,o.jsx)(a(),k({},N,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,o.jsx)(x(),{title:e.ariaLabel,children:(0,o.jsx)(u(),k({},N,{children:e.icon?e.icon:P}))})),(0,o.jsx)(b,k({open:n,onClose:function(){return i(!1)}},T,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":k(k({},v),{backgroundImage:"none",boxShadow:l.shadows[2]})},children:O}))]})};return r})()));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={445:(e,t,o)=>{o.d(t,{default:()=>c});var r=o(732),n=o(909),a=o.n(n),i=o(603),s=o.n(i);o(15);const c=function(e){return(0,r.jsx)(s(),{title:e.label,children:(0,r.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},603:e=>{e.exports=require("@mui/material/Tooltip")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};o.r(r),o.d(r,{default:()=>c});var n=o(732),a=o(15);function i(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}var s=o(445);const c=function(e){var t=(0,a.useState)("Copy text"),o=t[0],r=t[1];return(0,n.jsx)(s.default,{message:e.message,icon:(0,n.jsx)(i,{name:"file_copy"}),onClick:function(e){e.data.text&&navigator.clipboard.writeText(e.data.text).then((function(){r("Copied"),setTimeout((function(){r("Copy text")}),2e3)})).catch((function(){r("Failed to copy")}))},label:o})};return r})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={445:(e,t,o)=>{o.d(t,{default:()=>l});var r=o(732),n=o(909),a=o.n(n),i=o(603),c=o.n(i);o(15);const l=function(e){return(0,r.jsx)(c(),{title:e.label,children:(0,r.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},603:e=>{e.exports=require("@mui/material/Tooltip")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};o.r(r),o.d(r,{default:()=>s});var n=o(732),a=o(15),i=function(){return i=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};function c(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:i({},t),children:e.name})}var l=o(445);const s=function(e){var t=(0,a.useState)("Copy text"),o=t[0],r=t[1];return(0,n.jsx)(l.default,{message:e.message,icon:(0,n.jsx)(c,{name:"file_copy"}),onClick:function(e){e.data.text&&navigator.clipboard.writeText(e.data.text).then((function(){r("Copied"),setTimeout((function(){r("Copy text")}),2e3)})).catch((function(){r("Failed to copy")}))},label:o})};return r})()));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={445:(e,t,a)=>{a.d(t,{default:()=>l});var r=a(732),n=a(909),o=a.n(n),s=a(603),i=a.n(s);a(15);const l=function(e){return(0,r.jsx)(i(),{title:e.label,children:(0,r.jsx)(o(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},603:e=>{e.exports=require("@mui/material/Tooltip")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,a),o.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};a.r(r),a.d(r,{default:()=>l});var n=a(732),o=a(15);function s(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}var i=a(445);const l=function(e){var t=(0,o.useState)("Start reading aloud"),a=t[0],r=t[1],l=[e.message.data.title,e.message.data.description,e.message.data.alt,e.message.data.text,e.message.data.transcript].filter(Boolean).join(" "),c=new SpeechSynthesisUtterance(l);return(0,n.jsx)(i.default,{message:e.message,icon:(0,n.jsx)(s,{name:"text_to_speech"}),onClick:function(){window.speechSynthesis.speaking?(window.speechSynthesis.cancel(),r("Start reading aloud")):(c.onend=function(){r("Start reading aloud")},window.speechSynthesis.speak(c),r("Stop reading aloud"))},label:a})};return r})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={445:(e,t,r)=>{r.d(t,{default:()=>l});var a=r(732),o=r(909),n=r.n(o),s=r(603),i=r.n(s);r(15);const l=function(e){return(0,a.jsx)(i(),{title:e.label,children:(0,a.jsx)(n(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},603:e=>{e.exports=require("@mui/material/Tooltip")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function r(a){var o=t[a];if(void 0!==o)return o.exports;var n=t[a]={exports:{}};return e[a](n,n.exports,r),n.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};r.r(a),r.d(a,{default:()=>c});var o=r(732),n=r(15),s=function(){return s=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function i(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:s({},t),children:e.name})}var l=r(445);const c=function(e){var t=(0,n.useState)("Start reading aloud"),r=t[0],a=t[1],s=[e.message.data.title,e.message.data.description,e.message.data.alt,e.message.data.text,e.message.data.transcript].filter(Boolean).join(" "),c=new SpeechSynthesisUtterance(s);return(0,o.jsx)(l.default,{message:e.message,icon:(0,o.jsx)(i,{name:"text_to_speech"}),onClick:function(){window.speechSynthesis.speaking?(window.speechSynthesis.cancel(),a("Start reading aloud")):(c.onend=function(){a("Start reading aloud")},window.speechSynthesis.speak(c),a("Stop reading aloud"))},label:r})};return a})()));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>S});const n=require("react/jsx-runtime"),r=require("@mui/material/Chip");var o=e.n(r);const s=require("@mui/system/Box");var a=e.n(s);const i=require("react");var c=e.n(i);const u=require("@mui/material/Typography");var l=e.n(u),m=function(){return m=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},m.apply(this,arguments)};const d=function(e){var t=e.messages[0],r=e.messages.slice(1),o=e.supportedElements[t.format];return(0,n.jsx)(n.Fragment,{children:o?c().createElement(o,m(m({sender:e.sender,ws:e.ws,messageId:t.id,conversationId:t.conversationId},t.data),r.length>0&&{updatedData:r.map((function(e){return e.data}))})):(0,n.jsxs)(l(),{variant:"body2",children:["Unsupported element format: ",t.format]})})};function f(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}const p=require("@mui/material"),g=require("@mui/material/Card");var v=e.n(g);const h=require("@mui/material/Stack");var y,j=e.n(h);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(y||(y={}));const b=function(e){return(0,n.jsx)(l(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(t=e.timestamp,r=new Date(t),o=navigator.language,s={month:"short",day:"numeric"},a=new Date,i=r.getFullYear()!==a.getFullYear(),c=i?" at ":", ",i&&(s.year="numeric"),r.toLocaleDateString(o,s)+c+r.toLocaleTimeString(o,{hour:"numeric",minute:"2-digit",hour12:!0}))});var t,r,o,s,a,i,c},w=(0,i.forwardRef)((function(e,t){var r=(0,p.useTheme)();return(0,n.jsxs)(j(),{id:e.message.id,className:"rustic-message-canvas",ref:t,children:[(0,n.jsxs)(j(),{direction:"row",alignItems:"center",spacing:1,children:[e.getProfileComponent&&e.getProfileComponent(e.message),(0,n.jsx)(b,{timestamp:e.message.timestamp})]}),e.getActionsComponent&&e.getActionsComponent(e.message)&&(0,n.jsx)(v(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:r.shadows[1]},children:e.getActionsComponent(e.message)}),(0,n.jsx)(v(),{variant:"outlined",className:"rustic-message-container",children:e.children})]})}));var x=function(){return x=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},x.apply(this,arguments)};function O(e,t){var n=t.format.includes("update")?t.threadId:t.id;if(n){var r=x({},e),o=(e[n]||[])[0];return t.format.includes("update")&&o&&o.sender.id!==t.sender.id&&(n=t.id),r[n]||(r[n]=[]),r[n]=r[n].concat(t),r}return e}function E(e){var t,r,s,c=(0,i.useRef)(null),u=(0,i.useRef)(null),l=(0,i.useRef)(),m=(0,i.useState)(!0),p=m[0],g=m[1],v=(0,i.useState)(!0),h=v[0],y=v[1],j=(0,i.useState)(!1),b=j[0],x=j[1],E=(0,i.useState)({}),S=E[0],C=E[1],T=Object.keys(S).length,N=(r=T,s=(0,i.useRef)(0),(0,i.useEffect)((function(){s.current=r})),s.current),P=2e3;function R(){y(!0),l.current&&clearTimeout(l.current),l.current=setTimeout((function(){y(!1)}),P)}function A(){var e=u.current,t=c.current;if(e&&t){var n=e.getBoundingClientRect().bottom,r=t.getBoundingClientRect().bottom;g(r-1<=n)}}function q(){if(function(){var e,t=null===(e=u.current)||void 0===e?void 0:e.querySelectorAll("video");return!t||0===t.length||Array.from(t).every((function(e){return e.readyState>=1}))}()){var e=u.current;x(!0),e&&setTimeout((function(){R(),e.scrollTop=e.scrollHeight}),0)}else setTimeout(q,1)}function D(e){C((function(t){return O(t,e)}))}return(0,i.useEffect)((function(){var e=u.current;if(A(),e)return e.addEventListener("scroll",A),window.addEventListener("resize",A),function(){e.removeEventListener("scroll",A),window.removeEventListener("resize",A)}}),[p]),(0,i.useEffect)((function(){q()}),[b]),(0,i.useEffect)((function(){p&&0!==N&&T>N&&(R(),q())}),[p,Object.keys(S).length]),(0,i.useEffect)((function(){var t,n={};null===(t=e.receivedMessages)||void 0===t||t.forEach((function(e){var t=O(n,e);n=t})),C(n)}),[null===(t=e.receivedMessages)||void 0===t?void 0:t.length]),(0,i.useEffect)((function(){e.ws.onReceive&&e.ws.onReceive(D)}),[]),(0,n.jsxs)(a(),{ref:u,className:"rustic-message-space",children:[Object.keys(S).map((function(t,r){var o=S[t],s=o[o.length-1];return(0,n.jsx)(w,{message:s,getActionsComponent:e.getActionsComponent,getProfileComponent:e.getProfileComponent,ref:r===T-1?c:null,children:(0,n.jsx)(d,{ws:e.ws,sender:e.sender,messages:o,supportedElements:e.supportedElements})},t)})),!p&&!h&&(0,n.jsx)(o(),{variant:"rusticSecondary",className:"rustic-scroll-down-button",size:"medium",onClick:q,label:(0,n.jsxs)(n.Fragment,{children:[e.scrollDownLabel,(0,n.jsx)(f,{name:"arrow_downward"})]})})]})}E.defaultProps={scrollDownLabel:"Scroll down"};const S=E;return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>C});const n=require("react/jsx-runtime"),r=require("@mui/material/Chip");var o=e.n(r);const s=require("@mui/system/Box");var a=e.n(s);const i=require("react");var c=e.n(i);const u=require("@mui/material/Typography");var l=e.n(u),m=function(){return m=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},m.apply(this,arguments)};const d=function(e){var t=e.messages[0],r=e.messages.slice(1),o=e.supportedElements[t.format];return(0,n.jsx)(n.Fragment,{children:o?c().createElement(o,m(m({sender:e.sender,ws:e.ws,messageId:t.id,conversationId:t.conversationId},t.data),r.length>0&&{updatedData:r.map((function(e){return e.data}))})):(0,n.jsxs)(l(),{variant:"body2",children:["Unsupported element format: ",t.format]})})};var f=function(){return f=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},f.apply(this,arguments)};function p(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:f({},t),children:e.name})}const g=require("@mui/material"),v=require("@mui/material/Card");var h=e.n(v);const y=require("@mui/material/Stack");var j,b=e.n(y);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(j||(j={}));const w=function(e){return(0,n.jsx)(l(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(t=e.timestamp,r=new Date(t),o=navigator.language,s={month:"short",day:"numeric"},a=new Date,i=r.getFullYear()!==a.getFullYear(),c=i?" at ":", ",i&&(s.year="numeric"),r.toLocaleDateString(o,s)+c+r.toLocaleTimeString(o,{hour:"numeric",minute:"2-digit",hour12:!0}))});var t,r,o,s,a,i,c},x=(0,i.forwardRef)((function(e,t){var r=(0,g.useTheme)();return(0,n.jsxs)(b(),{id:e.message.id,className:"rustic-message-canvas",ref:t,children:[(0,n.jsxs)(b(),{direction:"row",alignItems:"center",spacing:1,children:[e.getProfileComponent&&e.getProfileComponent(e.message),(0,n.jsx)(w,{timestamp:e.message.timestamp})]}),e.getActionsComponent&&e.getActionsComponent(e.message)&&(0,n.jsx)(h(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:r.shadows[1]},children:e.getActionsComponent(e.message)}),(0,n.jsx)(h(),{variant:"outlined",className:"rustic-message-container",children:e.children})]})}));var O=function(){return O=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},O.apply(this,arguments)};function E(e,t){var n=t.format.includes("update")?t.threadId:t.id;if(n){var r=O({},e),o=(e[n]||[])[0];return t.format.includes("update")&&o&&o.sender.id!==t.sender.id&&(n=t.id),r[n]||(r[n]=[]),r[n]=r[n].concat(t),r}return e}function S(e){var t,r,s,c=(0,i.useRef)(null),u=(0,i.useRef)(null),l=(0,i.useRef)(),m=(0,i.useState)(!0),f=m[0],g=m[1],v=(0,i.useState)(!0),h=v[0],y=v[1],j=(0,i.useState)(!1),b=j[0],w=j[1],O=(0,i.useState)({}),S=O[0],C=O[1],T=Object.keys(S).length,P=(r=T,s=(0,i.useRef)(0),(0,i.useEffect)((function(){s.current=r})),s.current),N=2e3;function R(){y(!0),l.current&&clearTimeout(l.current),l.current=setTimeout((function(){y(!1)}),N)}function A(){var e=u.current,t=c.current;if(e&&t){var n=e.getBoundingClientRect().bottom,r=t.getBoundingClientRect().bottom;g(r-1<=n)}}function q(){if(function(){var e,t=null===(e=u.current)||void 0===e?void 0:e.querySelectorAll("video");return!t||0===t.length||Array.from(t).every((function(e){return e.readyState>=1}))}()){var e=u.current;w(!0),e&&setTimeout((function(){R(),e.scrollTop=e.scrollHeight}),0)}else setTimeout(q,1)}function D(e){C((function(t){return E(t,e)}))}return(0,i.useEffect)((function(){var e=u.current;if(A(),e)return e.addEventListener("scroll",A),window.addEventListener("resize",A),function(){e.removeEventListener("scroll",A),window.removeEventListener("resize",A)}}),[f]),(0,i.useEffect)((function(){q()}),[b]),(0,i.useEffect)((function(){f&&0!==P&&T>P&&(R(),q())}),[f,Object.keys(S).length]),(0,i.useEffect)((function(){var t,n={};null===(t=e.receivedMessages)||void 0===t||t.forEach((function(e){var t=E(n,e);n=t})),C(n)}),[null===(t=e.receivedMessages)||void 0===t?void 0:t.length]),(0,i.useEffect)((function(){e.ws.onReceive&&e.ws.onReceive(D)}),[]),(0,n.jsxs)(a(),{ref:u,className:"rustic-message-space",children:[Object.keys(S).map((function(t,r){var o=S[t],s=o[o.length-1];return(0,n.jsx)(x,{message:s,getActionsComponent:e.getActionsComponent,getProfileComponent:e.getProfileComponent,ref:r===T-1?c:null,children:(0,n.jsx)(d,{ws:e.ws,sender:e.sender,messages:o,supportedElements:e.supportedElements})},t)})),!f&&!h&&(0,n.jsx)(o(),{variant:"rusticSecondary",className:"rustic-scroll-down-button",size:"medium",onClick:q,label:(0,n.jsxs)(n.Fragment,{children:[e.scrollDownLabel,(0,n.jsx)(p,{name:"arrow_downward"})]})})]})}S.defaultProps={scrollDownLabel:"Scroll down"};const C=S;return t})()));