mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4977],{94977:function(e,t,s){"use strict";s.r(t),s.d(t,{ChatContainer:function(){return eg}});var a,n,r,o,i,l=s(85893),c=s(26246),d=s(67294),h=s(36531),u=s(91951),m=s(59760),g=s.n(m),x=s(94184),p=s.n(x),_=s(29158),C=s(94199),f=s(4480),j=s(5152),v=s.n(j),y=s(27722),N=s(50085),M=s.n(N),b=s(77278);function T(e){let t=new Date(e);if(Number.isNaN(t))return"";let s=(0,b.Xb)(e);if(s>=1){let a=t.toLocaleDateString("en-US",{dateStyle:"medium"});return"".concat(a," at ").concat(t.toLocaleTimeString())}return"".concat(t.toLocaleTimeString())}var S=s(48976),E=s.n(S);let w=e=>{let{badge:t,userColor:s}=e,a="var(--theme-user-colors-".concat(s,")");return(0,l.jsx)("span",{style:{color:a,borderColor:a},className:E().badge,children:t})};var k=s(77466);let O=v()(()=>Promise.all([s.e(5596),s.e(481),s.e(173),s.e(3174),s.e(6386),s.e(3013),s.e(3698),s.e(8213),s.e(6754),s.e(195),s.e(5402),s.e(1834),s.e(8067),s.e(4136),s.e(4860)]).then(s.bind(s,94860)).then(e=>e.ChatModerationActionMenu),{loadableGenerated:{webpack:()=>[94860]},ssr:!1}),D=v()(()=>Promise.resolve().then(s.bind(s,47049)).then(e=>e.Highlight),{loadableGenerated:{webpack:()=>[47049]},ssr:!1}),A=e=>{let{children:t,user:s}=e,{displayName:a,createdAt:n}=s,r="".concat(a," first joined ").concat(T(n));return(0,l.jsx)(C.Z,{title:r,placement:"topLeft",mouseEnterDelay:1,children:t})},B=e=>{let{message:t,highlightString:s,showModeratorMenu:a,sentBySelf:n,sameUserAsLast:r,isAuthorModerator:o,isAuthorAuthenticated:i}=e,{id:c,body:h,user:u,timestamp:m}=t,{id:g,displayName:x,displayColor:j}=u,v=(0,f.sJ)(k.FI),N="var(--theme-color-users-".concat(j,")"),b="Sent ".concat(T(m)),[S,E]=(0,d.useState)(h),B=[];return o&&B.push((0,l.jsx)(w,{badge:"mod",userColor:j},"mod")),i&&B.push((0,l.jsx)(w,{badge:(0,l.jsx)(_.Z,{title:"authenticated"}),userColor:j},"auth")),(0,d.useEffect)(()=>{E((0,y.p1)(h))},[t]),(0,l.jsx)("div",{className:p()(M().messagePadding,r&&M().messagePaddingCollapsed,"chat-message_user"),children:(0,l.jsxs)("div",{className:p()(M().root,{[M().ownMessage]:n}),style:{borderColor:N},children:[!r&&(0,l.jsx)(A,{user:u,children:(0,l.jsxs)("div",{className:M().user,style:{color:N},children:[(0,l.jsx)("span",{className:M().userName,children:x}),(0,l.jsx)("span",{children:B})]})}),(0,l.jsx)(C.Z,{title:b,mouseEnterDelay:1,children:(0,l.jsx)(D,{search:s,children:(0,l.jsx)("div",{className:M().message,dangerouslySetInnerHTML:{__html:S}})})}),a&&(0,l.jsx)("div",{className:M().modMenuWrapper,children:(0,l.jsx)(O,{messageID:c,accessToken:v,userID:g,userDisplayName:x})}),(0,l.jsx)("div",{className:M().background,style:{color:N}})]})})};var U=s(93045),F=s(27496),L=s(55241),R=s(77493),I=s(96391),P=s(26912),H=s.n(P);let W=v()(()=>Promise.all([s.e(7741),s.e(1559)]).then(s.bind(s,51559)).then(e=>e.EmojiPicker),{loadableGenerated:{webpack:()=>[51559]},ssr:!1}),G=e=>{let{attributes:t,element:s,children:a}=e,n=(0,I.vt)(),r=(0,I.UE)();return(0,l.jsxs)("span",{...t,contentEditable:!1,children:[(0,l.jsx)("img",{alt:s.alt,src:s.src,title:s.name,style:{display:"inline",maxWidth:"50px",maxHeight:"20px",boxShadow:"".concat(n&&r?"0 0 0 3px #B4D5FF":"none")}}),a]})},Z=e=>{let{isVoid:t}=e;return e.isVoid=e=>"image"===e.type||t(e),e.isInline=e=>"image"===e.type,e},V=e=>{let t;if(R.xv.isText(e)){let s=e.text;return s}if(0===e.children.length)t=[{text:""}];else{var a;t=null===(a=e.children)||void 0===a?void 0:a.map(e=>V(e)).join("")}switch(e.type){case"paragraph":return"<p>".concat(t,"</p>");case"image":return'<img src="'.concat(e.src,'" alt="').concat(e.alt,'" title="').concat(e.name,'" class="emoji"/>');default:return t}},Y=e=>{if(R.xv.isText(e))return e.text.length;if("image"===e.type)return 5;let t=0;return e.children.forEach(e=>{t+=Y(e)}),t},J=e=>{let{defaultText:t}=e,[s,a]=(0,d.useState)(!1),[n,r]=(0,d.useState)(null==t?void 0:t.length),o=(0,f.sJ)(k.Gt),i=(0,d.useMemo)(()=>(0,I.BU)(Z((0,R.Jh)())),[]),c=()=>{if(!o){console.log("websocketService is not defined");return}let e=V(i);o.send({type:u.C.CHAT,body:e}),R.YR.delete(i,{at:{anchor:R.ML.start(i,[]),focus:R.ML.end(i,[])}}),r(0)},h=(e,t,s)=>({type:"image",alt:e,src:t,name:s,children:[{text:""}]}),m=(e,t)=>{if(!e)return;let{selection:s}=i,a=h(t,e,t);if(R.YR.insertNodes(i,a,{select:!0}),s){var n;let[r,o]=R.ML.parent(i,null===(n=s.focus)||void 0===n?void 0:n.path);i.isVoid(r)||R.NB.string(r).length?R.YR.insertNodes(i,a,{at:R.y$.next(o),select:!0}):(R.YR.insertNodes(i,a,{at:o,select:!0}),R.ML.normalize(i,{force:!0}))}else R.YR.insertNodes(i,a,{select:!0})},g=e=>{I.F3.focus(i),R.YR.insertText(i,e)},x=(e,t)=>{I.F3.focus(i),m(t,e)},_=e=>{let t=Y(i)+1;if("Enter"===e.key){e.preventDefault(),c();return}if("Backspace"===e.key){r(t-1);return}t+1>300&&e.preventDefault(),r(t+1)},C=e=>{let t=e.clipboardData.getData("text/plain"),{length:s}=t;n+s>300&&e.preventDefault()},j=e=>"image"===e.element.type?(0,l.jsx)(G,{...e}):(0,l.jsx)("p",{...e});return(0,l.jsx)("div",{className:H().root,children:(0,l.jsxs)("div",{className:p()(H().inputWrap,n>=300&&H().maxCharacters),children:[(0,l.jsxs)(I.mH,{editor:i,value:[{type:"paragraph",children:[{text:t||""}]}],children:[(0,l.jsx)(I.CX,{className:"chat-text-input",onKeyDown:_,onPaste:C,renderElement:j,placeholder:"Send a message to chat",style:{width:"100%"},role:"textbox","aria-label":"Chat text input",autoFocus:!0}),(0,l.jsx)(L.Z,{content:(0,l.jsx)(W,{onEmojiSelect:g,onCustomEmojiSelect:x}),trigger:"click",placement:"topRight",onOpenChange:e=>a(e),open:s})]}),(0,l.jsxs)("div",{style:{display:"flex",paddingLeft:"5px"},children:[(0,l.jsx)("button",{type:"button",className:H().emojiButton,title:"Emoji picker button",onClick:()=>a(!s),children:(0,l.jsx)(U.Z,{})}),(0,l.jsx)("button",{type:"button",className:H().sendButton,title:"Send message Button",onClick:c,children:(0,l.jsx)(F.Z,{})})]})]})})};var X=s(93107),z=s.n(X);function q(){return(q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e}).apply(this,arguments)}var K=function(e){return d.createElement("svg",q({height:500,viewBox:"0 0 132.292 132.292",width:500,xmlns:"http://www.w3.org/2000/svg"},e),a||(a=d.createElement("linearGradient",{id:"moderator_svg__a",gradientUnits:"userSpaceOnUse",x1:432.851,x2:464.644,y1:49.977,y2:49.977},d.createElement("stop",{offset:0,stopColor:"#2087e2"}),d.createElement("stop",{offset:1,stopColor:"#b63fff"}))),n||(n=d.createElement("path",{d:"M438.672 34.08h20.151a5.82 5.82 45 0 1 5.82 5.821v20.151a5.82 5.82 135 0 1-5.82 5.821h-20.15a5.82 5.82 45 0 1-5.822-5.82V39.9a5.82 5.82 135 0 1 5.821-5.82z",fill:"url(#moderator_svg__a)",transform:"matrix(4.16112 0 0 4.16112 -1801.146 -141.814)"})),r||(r=d.createElement("path",{d:"M121.11 29.551c-6.93 47.444-30.074 104.618-77.642 79.674l25.83 23.067h38.772c13.377 0 24.22-10.845 24.22-24.222V40.864z",fill:"#1d1535",fillOpacity:.335})),o||(o=d.createElement("path",{d:"M66.775 13.257s-7.129 57.999-.63 99.312c6.565 41.724-81.568-74.394-49.619-79.203 31.949-4.809 50.249-20.11 50.249-20.11z",fill:"#e2e8f0",fillOpacity:.306})),i||(i=d.createElement("path",{d:"M435.995 42.072c6.797.447 12.753-4.806 12.753-4.806s5.955 5.253 12.752 4.806c-.581 12.745-7.495 20.586-12.752 20.628-5.188.042-12.172-7.883-12.753-20.628z",fill:"none",stroke:"#fff",strokeLinejoin:"round",strokeWidth:2,transform:"matrix(4.16112 0 0 4.16112 -1801.146 -141.814)"})))};let $=()=>(0,l.jsxs)("div",{className:z().chatModerationNotification,children:[(0,l.jsx)(K,{className:z().icon}),"You are now a moderator."]});var Q=s(47049),ee=s(23421),et=s.n(ee);let es=e=>{let{message:{body:t,user:{displayName:s}},highlightString:a}=e;return(0,l.jsxs)("div",{className:p()([et().chatSystemMessage,"chat-message_system"]),children:[(0,l.jsx)("div",{className:et().user,children:(0,l.jsx)("span",{className:et().userName,children:s})}),(0,l.jsx)(Q.Highlight,{search:a,children:(0,l.jsx)("div",{className:et().message,dangerouslySetInnerHTML:{__html:t}})})]})};var ea=s(55355),en=s(91044),er=s.n(en);let eo=e=>{let{isAuthorModerator:t,userColor:s,displayName:a}=e;return(0,l.jsxs)("div",{className:er().root,children:[(0,l.jsxs)("span",{style:{color:"var(--theme-color-users-".concat(s,")")},children:[(0,l.jsx)("span",{style:{padding:"0 10px"},children:(0,l.jsx)(ea.Z,{})}),(0,l.jsx)("span",{style:{fontWeight:"bold"},children:a}),t&&(0,l.jsx)("span",{children:(0,l.jsx)(w,{badge:"mod",userColor:s})})]})," ","joined the chat."]})};var ei=s(66017),el=s(71577);let ec=e=>{let{chatContainerRef:t,messages:s}=e;return(0,l.jsx)("div",{className:g().toBottomWrap,children:(0,l.jsx)(el.Z,{type:"default",style:{color:"currentColor"},icon:(0,l.jsx)(ei.Z,{}),onClick:()=>t.current.scrollToIndex({index:s.length-1,behavior:"auto"}),children:"Go to last message"})})};var ed=s(65302),eh=s.n(ed);let eu=e=>{let{body:t}=e;return(0,l.jsx)("div",{dangerouslySetInnerHTML:{__html:t},className:eh().chatAction})};function em(e){let{user:{scopes:t}}=e;return!!t&&0!==t.length&&t.includes("MODERATOR")}let eg=e=>{let{messages:t,usernameToHighlight:s,chatUserId:a,isModerator:n,showInput:r,height:o}=e,[i,m]=(0,d.useState)(!1),x=(0,d.useRef)(null),p=e=>{let{oldName:t,user:s}=e,{displayName:a,displayColor:n}=s,r="var(--theme-color-users-".concat(n,")");return(0,l.jsxs)("div",{className:g().nameChangeView,children:[(0,l.jsx)("div",{style:{marginRight:5,height:"max-content",margin:"auto 5px auto 0"},children:(0,l.jsx)(h.Z,{})}),(0,l.jsxs)("div",{className:g().nameChangeText,children:[(0,l.jsx)("span",{style:{color:r},children:t}),(0,l.jsx)("span",{className:g().plain,children:" is now known as "}),(0,l.jsx)("span",{style:{color:r},children:a})]})]})},_=e=>{let{user:{displayName:t,displayColor:s}}=e,a=em(e);return(0,l.jsx)(eo,{displayName:t,userColor:s,isAuthorModerator:a})},C=e=>{let{body:t}=e;return(0,l.jsx)(eu,{body:t})},f=e=>{let t=em(e);return t?(0,l.jsx)($,{}):(0,l.jsx)("div",{style:{width:"1px",height:"1px"}})},j=(e,r)=>{switch(r.type){case u.C.CHAT:var o,i,c;return(0,l.jsx)(B,{message:r,showModeratorMenu:n,highlightString:s,sentBySelf:(null===(o=r.user)||void 0===o?void 0:o.id)===a,sameUserAsLast:function(e,t){if(e.length<2)return!1;let s=e[t];if(!s||!s.user)return!1;let{user:{id:a}}=s,n=e[t-1];if((null==n?void 0:n.type)!==u.C.CHAT||!(null==n?void 0:n.timestamp)||!s.timestamp)return!1;let r=new Date(null==n?void 0:n.timestamp).getTime(),o=new Date(s.timestamp).getTime();return!(o-r>12e4)&&a===(null==n?void 0:n.user.id)}(t,e),isAuthorModerator:null===(i=r.user.scopes)||void 0===i?void 0:i.includes("MODERATOR"),isAuthorAuthenticated:null===(c=r.user)||void 0===c?void 0:c.authenticated},r.id);case u.C.NAME_CHANGE:return p(r);case u.C.CONNECTED_USER_INFO:return f(r);case u.C.USER_JOINED:return _(r);case u.C.CHAT_ACTION:return C(r);case u.C.SYSTEM:return(0,l.jsx)(es,{message:r,highlightString:s},r.id);default:return null}},v=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"smooth";setTimeout(()=>{var a;null===(a=e.current)||void 0===a||a.scrollToIndex({index:t.length-1,behavior:s})},100),m(!0)};(0,d.useEffect)(()=>{setTimeout(()=>{v(x,"auto")},500)},[]);let y=(0,d.useMemo)(()=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.OO,{id:"virtuoso",style:{height:o},className:g().virtuoso,ref:x,data:t,itemContent:(e,t)=>j(e,t),followOutput:e=>(e&&v(x,"smooth"),!1),alignToBottom:!0,atBottomThreshold:70,atBottomStateChange:e=>{m(e)}}),!i&&(0,l.jsx)(ec,{chatContainerRef:x,messages:t})]}),[t,s,a,n,i]);return(0,l.jsxs)("div",{id:"chat-container",className:g().chatContainer,children:[y,r&&(0,l.jsx)("div",{className:g().chatTextField,children:(0,l.jsx)(J,{})})]})};eg.defaultProps={showInput:!0,height:"auto"}},65302:function(e){e.exports={chatAction:"ChatActionMessage_chatAction__x9Xsg"}},59760:function(e){e.exports={toBottomWrap:"ChatContainer_toBottomWrap__3V5wa",nameChangeView:"ChatContainer_nameChangeView__ziyXN",nameChangeText:"ChatContainer_nameChangeText__yXG__",plain:"ChatContainer_plain__IPS19",chatContainer:"ChatContainer_chatContainer__O2lYN",virtuoso:"ChatContainer_virtuoso__OS9Kz",chatTextField:"ChatContainer_chatTextField__OqCGL"}},91044:function(e){e.exports={root:"ChatJoinMessage_root__vuVXa"}},93107:function(e){e.exports={chatModerationNotification:"ChatModeratorNotification_chatModerationNotification__kgFWe",icon:"ChatModeratorNotification_icon__7FdGg"}},23421:function(e){e.exports={chatSystemMessage:"ChatSystemMessage_chatSystemMessage__c6XEN",user:"ChatSystemMessage_user__6yHSJ",message:"ChatSystemMessage_message__ySq5g"}},26912:function(e){e.exports={root:"ChatTextField_root__4oUkJ",inputWrap:"ChatTextField_inputWrap__1mAjD",maxCharacters:"ChatTextField_maxCharacters__yGT4s",emojiButton:"ChatTextField_emojiButton__ON_Cu",sendButton:"ChatTextField_sendButton__MOmD4"}},48976:function(e){e.exports={badge:"ChatUserBadge_badge__1EdUp"}},50085:function(e){e.exports={root:"ChatUserMessage_root__79heB",user:"ChatUserMessage_user__xUEp9",message:"ChatUserMessage_message__MJ9LD",ownMessage:"ChatUserMessage_ownMessage__d28A3",background:"ChatUserMessage_background__Tfghp",modMenuWrapper:"ChatUserMessage_modMenuWrapper__7fblv",messagePadding:"ChatUserMessage_messagePadding__Xp1F6",messagePaddingCollapsed:"ChatUserMessage_messagePaddingCollapsed__qxN0E"}}}]);
|
|
//# sourceMappingURL=4977-c6e33b89f2dd930d.js.map
|