owncast/static/web/_next/static/chunks/8731-f9eede65b9b99f99.js
2023-06-30 03:41:14 +00:00

1 line
17 KiB
JavaScript
Vendored

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8731],{92093:function(e,t,a){"use strict";a.r(t),a.d(t,{ChatContainer:function(){return eO}});var s,n,r,o,l,i=a(85893),c=a(26246),d=a(67294),u=a(4511),h=a(28997),m=a(45761),g=a.n(m),_=a(94184),p=a.n(_),C=a(94199),x=a(4480),f=a(5152),j=a.n(f),b=a(63108),E=a(41366),N=a(4693);class v extends N.M{match(e){let{highlightString:t}=this.options;if(!t)return null;let a=e.match(t);return a?{index:a.index,length:a[0].length,match:a[0],valid:!0}:null}replaceWith(e,t){let{key:a}=t;return d.createElement("mark",{key:a},e)}asTag(){return"mark"}}var M=a(75774),w=a.n(M),y=a(63516);function S(e){let t=new Date(e);if(Number.isNaN(t))return"";let a=(0,y.Xb)(e);if(a>=1){let e=t.toLocaleDateString("en-US",{dateStyle:"medium"});return"".concat(e," at ").concat(t.toLocaleTimeString())}return"".concat(t.toLocaleTimeString())}var T=a(44974),k=a(73295),A=a.n(k);let G=e=>{let{badge:t,userColor:a,title:s}=e;return(0,i.jsx)("span",{style:{color:"var(--theme-color-users-".concat(a,")")},className:A().badge,title:s,children:t})},B=j()(()=>Promise.all([a.e(2074),a.e(7719)]).then(a.t.bind(a,27719,23)),{loadableGenerated:{webpack:()=>[27719]},ssr:!1}),O=e=>{let{userColor:t}=e;return(0,i.jsx)(G,{badge:(0,i.jsx)(B,{}),userColor:t,title:"Authenticated"})},D=j()(()=>Promise.all([a.e(2074),a.e(710)]).then(a.t.bind(a,20710,23)),{loadableGenerated:{webpack:()=>[20710]},ssr:!1}),F=e=>{let{userColor:t}=e;return(0,i.jsx)(G,{badge:(0,i.jsx)(D,{}),userColor:t,title:"Moderator"})},P=j()(()=>Promise.all([a.e(2074),a.e(6133)]).then(a.t.bind(a,56133,23)),{loadableGenerated:{webpack:()=>[56133]},ssr:!1}),U=e=>{let{userColor:t}=e;return(0,i.jsx)(G,{badge:(0,i.jsx)(P,{}),userColor:t,title:"Bot"})},I=j()(()=>Promise.all([a.e(173),a.e(5874),a.e(4931),a.e(5402),a.e(1382),a.e(4041),a.e(3698),a.e(3013),a.e(4398),a.e(8091),a.e(2659),a.e(9991)]).then(a.bind(a,39991)).then(e=>e.ChatModerationActionMenu),{loadableGenerated:{webpack:()=>[39991]},ssr:!1}),L=e=>{let{children:t,user:a}=e,{displayName:s,createdAt:n}=a,r="".concat(s," first joined ").concat(S(n));return(0,i.jsx)(C.Z,{title:r,placement:"topLeft",mouseEnterDelay:1,children:t})},R=e=>{let{message:t,highlightString:a,showModeratorMenu:s,sentBySelf:n,sameUserAsLast:r,isAuthorModerator:o,isAuthorAuthenticated:l,isAuthorBot:c}=e,{id:d,body:u,user:h,timestamp:m}=t,{id:g,displayName:_,displayColor:f}=h,j=(0,x.sJ)(T.FI),N="var(--theme-color-users-".concat(f,")"),M="Sent ".concat(S(m)),y=[];return o&&y.push((0,i.jsx)(F,{userColor:f},"mod")),l&&y.push((0,i.jsx)(O,{userColor:f},"auth")),c&&y.push((0,i.jsx)(U,{userColor:f},"bot")),(0,i.jsx)("div",{className:p()(w().messagePadding,r&&w().messagePaddingCollapsed,"chat-message_user"),children:(0,i.jsxs)("div",{className:p()(w().root,{[w().ownMessage]:n}),style:{borderColor:N},children:[(0,i.jsx)("div",{className:w().background,style:{color:N}}),(0,i.jsx)(L,{user:h,children:(0,i.jsxs)("div",{className:r?w().repeatUser:w().user,style:{color:N},children:[(0,i.jsx)("span",{className:w().userName,children:_}),(0,i.jsx)("span",{className:w().userBadges,children:y})]})}),(0,i.jsx)(C.Z,{title:M,mouseEnterDelay:1,children:(0,i.jsx)(b.wZ,{className:w().message,content:u,matchers:[new E.xc("url",{customTLDs:["online"]}),new v("highlight",{highlightString:a})]})}),s&&(0,i.jsx)("div",{className:w().modMenuWrapper,children:(0,i.jsx)(I,{messageID:d,accessToken:j,userID:g,userDisplayName:_})})]})})};var W=a(55241),V=a(61512),H=a.n(V),Z=a(91036),J=a.n(Z),z=a(14866),K=a.n(z);let q=j()(()=>Promise.all([a.e(7741),a.e(344)]).then(a.bind(a,20344)).then(e=>e.EmojiPicker),{loadableGenerated:{webpack:()=>[20344]},ssr:!1}),X=j()(()=>Promise.all([a.e(2074),a.e(3366)]).then(a.t.bind(a,73366,23)),{loadableGenerated:{webpack:()=>[73366]},ssr:!1}),Y=j()(()=>Promise.all([a.e(2074),a.e(2348)]).then(a.t.bind(a,92348,23)),{loadableGenerated:{webpack:()=>[92348]},ssr:!1});function Q(e){let t=window.getSelection();if(0===t.rangeCount)return 0;let a=t.getRangeAt(0),s=a.cloneRange(),n=document.createElement("div");return s.selectNodeContents(e),s.setEnd(a.endContainer,a.endOffset),n.appendChild(s.cloneContents()),n.innerHTML.length}let $=e=>{let{defaultText:t,enabled:a,focusInput:s}=e,[n,r]=(0,d.useState)(null==t?void 0:t.length),o=(0,x.sJ)(T.Gt),l=(0,d.useRef)(t||""),[c,u]=(0,d.useState)(0),[m,g]=(0,d.useState)([]),[,_]=(0,d.useReducer)(e=>e+1,0),C=()=>l.current.length,f=()=>{if(!o){console.log("websocketService is not defined");return}let e=l.current;e=e.replace(/^<p>|<\/p>$/g,""),o.send({type:h.C.CHAT,body:e}),l.current="",r(0),_()},j=e=>{let t=l.current+e;l.current=t,_()};(0,d.useEffect)(()=>{s&&document.getElementById("chat-input-content-editable").focus()},[]);let b=async()=>{try{let e=await fetch("/api/emoji"),t=await e.json();g(t),t.forEach(e=>{let t=document.createElement("link");t.href=e.url,t.rel="preload",t.as="image",document.head.appendChild(t)})}catch(e){console.error("cannot fetch custom emoji",e)}};return(0,d.useEffect)(()=>{b()},[]),(0,i.jsx)("div",{id:"chat-input",className:K().root,children:(0,i.jsxs)("div",{className:p()(K().inputWrap,n>=300&&K().maxCharacters),children:[(0,i.jsx)(H(),{id:"chat-input-content-editable",html:l.current,placeholder:a?"Send a message to chat":"Chat is disabled",disabled:!a,onKeyDown:e=>{if("Enter"===e.key&&e.shiftKey)return;let t=C()+1;if("Backspace"!==e.key&&"Delete"!==e.key&&("a"!==e.key||!e.ctrlKey)){if(t+1>300){e.preventDefault();return}if("Enter"===e.key){e.preventDefault(),f();return}r(t+1)}},onChange:e=>{let t=J()(e.target.value,{allowedTags:["b","i","em","strong","a","br","p","img"],allowedAttributes:{img:["class","alt","title","src"]},allowedClasses:{img:["emoji"]},transformTags:{h1:"p",h2:"p",h3:"p"}});l.current=t;let a=t.replace(/<\/?[^>]+(>|$)/g,"");r(a.length),u(Q(document.getElementById("chat-input-content-editable")))},onBlur:()=>{u(Q(document.getElementById("chat-input-content-editable")))},onFocus:()=>{c&&(function(e,t){try{let a=document.createRange(),s=window.getSelection();a.selectNode(e),a.setStart(e.childNodes[0],t),a.collapse(!0),s.removeAllRanges(),s.addRange(a)}catch(e){console.debug(e)}}(document.getElementById("chat-input-content-editable"),c),u(0))},style:{width:"100%"},role:"textbox","aria-label":"Chat text input"}),a&&(0,i.jsxs)("div",{style:{display:"flex",paddingLeft:"5px"},children:[(0,i.jsx)(W.Z,{content:(0,i.jsx)(q,{customEmoji:m,onEmojiSelect:e=>{j(e)},onCustomEmojiSelect:(e,t)=>{let a='<img src="'.concat(t,'" alt="').concat(e,'" title="').concat(e,'" class="emoji" />');j(a)}}),trigger:"click",placement:"topRight",children:(0,i.jsx)("button",{type:"button",className:K().emojiButton,title:"Emoji picker button",children:(0,i.jsx)(Y,{})})}),(0,i.jsx)("button",{type:"button",className:K().sendButton,title:"Send message Button",onClick:f,children:(0,i.jsx)(X,{})})]})]})})};var ee=a(71368),et=a.n(ee);function ea(){return(ea=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e}).apply(this,arguments)}var es=function(e){return d.createElement("svg",ea({xmlns:"http://www.w3.org/2000/svg",width:500,height:500,viewBox:"0 0 132.292 132.292"},e),s||(s=d.createElement("linearGradient",{id:"moderator_svg__a",x1:432.851,x2:464.644,y1:49.977,y2:49.977,gradientUnits:"userSpaceOnUse"},d.createElement("stop",{offset:0,stopColor:"#2087e2"}),d.createElement("stop",{offset:1,stopColor:"#b63fff"}))),n||(n=d.createElement("path",{fill:"url(#moderator_svg__a)",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",transform:"matrix(4.16112 0 0 4.16112 -1801.146 -141.814)"})),r||(r=d.createElement("path",{fill:"#1d1535",fillOpacity:.335,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"})),o||(o=d.createElement("path",{fill:"#e2e8f0",fillOpacity:.306,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"})),l||(l=d.createElement("path",{fill:"none",stroke:"#fff",strokeLinejoin:"round",strokeWidth:2,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",transform:"matrix(4.16112 0 0 4.16112 -1801.146 -141.814)"})))};let en=()=>(0,i.jsxs)("div",{className:et().chatModerationNotification,children:[(0,i.jsx)(es,{className:et().icon}),"You are now a moderator."]});var er=a(61120),eo=a.n(er);let el=e=>{let{message:{body:t,user:{displayName:a}},highlightString:s}=e;return(0,i.jsxs)("div",{className:p()([eo().chatSystemMessage,"chat-message_system"]),children:[(0,i.jsx)("div",{className:eo().user,children:(0,i.jsx)("span",{className:eo().userName,children:a})}),(0,i.jsx)(b.wZ,{className:eo().message,content:t,matchers:[new E.xc("url",{customTLDs:["online"]}),new v("highlight",{highlightString:s})]})]})};var ei=a(56654),ec=a.n(ei);let ed=j()(()=>Promise.all([a.e(2074),a.e(8725)]).then(a.t.bind(a,8725,23)),{loadableGenerated:{webpack:()=>[8725]},ssr:!1}),eu=e=>{let{isAuthorModerator:t,userColor:a,displayName:s}=e;return(0,i.jsxs)("div",{className:ec().root,children:[(0,i.jsxs)("span",{style:{color:"var(--theme-color-users-".concat(a,")")},children:[(0,i.jsx)("span",{className:ec().icon,children:(0,i.jsx)(ed,{})}),(0,i.jsx)("span",{className:ec().user,children:s}),t&&(0,i.jsx)("span",{className:ec().moderatorBadge,children:(0,i.jsx)(F,{userColor:a})})]}),"joined the chat."]})};var eh=a(71577);let em=j()(()=>Promise.all([a.e(2074),a.e(437)]).then(a.t.bind(a,20437,23)),{loadableGenerated:{webpack:()=>[20437]},ssr:!1}),eg=e=>{let{onClick:t}=e;return(0,i.jsx)("div",{className:g().toBottomWrap,id:"scroll-to-chat-bottom",children:(0,i.jsx)(eh.Z,{type:"default",style:{color:"currentColor"},icon:(0,i.jsx)(em,{}),onClick:t,children:"Go to last message"})})};var e_=a(88881),ep=a.n(e_);let eC=e=>{let{body:t}=e;return(0,i.jsx)("div",{dangerouslySetInnerHTML:{__html:t},className:ep().chatAction})};var ex=a(71230),ef=a(15746),ej=a(24093),eb=a(31654),eE=a.n(eb);let eN=j()(()=>a.e(9069).then(a.bind(a,49069)),{loadableGenerated:{webpack:()=>[49069]},ssr:!1}),ev=j()(()=>a.e(5584).then(a.bind(a,15584)),{loadableGenerated:{webpack:()=>[15584]},ssr:!1}),eM=j()(()=>a.e(7268).then(a.bind(a,97268)),{loadableGenerated:{webpack:()=>[97268]},ssr:!1}),ew=e=>{let t,{message:a}=e,{body:s,title:n,image:r,link:o,type:l}=a;switch(l.toString()){case"FEDIVERSE_ENGAGEMENT_FOLLOW":t=eN;break;case"FEDIVERSE_ENGAGEMENT_LIKE":t=ev;break;case"FEDIVERSE_ENGAGEMENT_REPOST":t=eM}return(0,i.jsx)("div",{className:p()([eE().follower,"chat-message_social"]),children:(0,i.jsx)("a",{href:o,target:"_blank",rel:"noreferrer",children:(0,i.jsxs)(ex.Z,{wrap:!1,children:[(0,i.jsxs)(ef.Z,{span:6,className:eE().avatarColumn,children:[(0,i.jsx)(ej.C,{src:r,alt:"Avatar",className:eE().avatar,size:"large",children:n.charAt(0).toUpperCase()}),(0,i.jsx)(t,{className:eE().icon})]}),(0,i.jsxs)(ef.Z,{children:[(0,i.jsx)(ex.Z,{className:eE().account,children:n}),(0,i.jsx)(ex.Z,{className:eE().body,dangerouslySetInnerHTML:{__html:s}})]})]})})})};var ey=a(44964),eS=a.n(ey);let eT=j()(()=>Promise.all([a.e(2074),a.e(1668)]).then(a.t.bind(a,51668,23)),{loadableGenerated:{webpack:()=>[51668]},ssr:!1}),ek=e=>{let{message:t}=e,{oldName:a,user:s}=t,{displayName:n,displayColor:r}=s,o="var(--theme-color-users-".concat(r,")");return(0,i.jsxs)("div",{className:eS().nameChangeView,children:[(0,i.jsx)("div",{className:eS().icon,children:(0,i.jsx)(eT,{})}),(0,i.jsxs)("div",{className:eS().nameChangeText,children:[(0,i.jsx)("span",{style:{color:o},children:a}),(0,i.jsx)("span",{className:eS().plain,children:" is now known as "}),(0,i.jsx)("span",{style:{color:o},children:n})]})]})};var eA=a(25449),eG=a(69183);function eB(e){let{user:t}=e,a=new eA.n(t);return a.isModerator}let eO=e=>{let{messages:t,usernameToHighlight:a,chatUserId:s,isModerator:n,showInput:r,height:o,chatAvailable:l,focusInput:m=!0}=e,[_,p]=(0,d.useState)(!1),[C,x]=(0,d.useState)(!1),f=(0,d.useRef)(null),j=(0,d.useRef)(null),b=new Set;(0,d.useEffect)(()=>()=>{clearTimeout(j.current)},[]);let E=e=>(0,i.jsx)(ew,{message:e}),N=e=>{let{user:{displayName:t,displayColor:a}}=e,s=eB(e);return(0,i.jsx)(eu,{displayName:t,userColor:a,isAuthorModerator:s})},v=e=>{let{body:t}=e;return(0,i.jsx)(eC,{body:t})},M=e=>{let t=eB(e);return t?(0,i.jsx)(en,{}):(0,i.jsx)("div",{style:{width:"1px",height:"1px"}})},w=(e,r)=>{var o,l,c;let d=function(e,t,a){if(e.length<2)return!1;let s=e[t];if(!s||!s.user)return!1;let{user:{id:n}}=s,r=e[t-1];if((null==r?void 0:r.type)!==h.C.CHAT||!(null==r?void 0:r.timestamp)||!s.timestamp)return!1;let o=new Date(null==r?void 0:r.timestamp).getTime(),l=new Date(s.timestamp).getTime();return!(l-o>4e4)&&n===(null==r?void 0:r.user.id)&&!(a.size>=5)}(t,e,b);d?b.add(r.id):b.clear();let u=eB(r);return(0,i.jsx)(R,{message:r,showModeratorMenu:n,highlightString:a,sentBySelf:(null===(o=r.user)||void 0===o?void 0:o.id)===s,sameUserAsLast:d,isAuthorModerator:u,isAuthorBot:null===(l=r.user)||void 0===l?void 0:l.isBot,isAuthorAuthenticated:null===(c=r.user)||void 0===c?void 0:c.authenticated},r.id)},y=(e,t)=>{switch(t.type){case h.C.CHAT:return w(e,t);case h.C.NAME_CHANGE:return(0,i.jsx)(ek,{message:t});case h.C.CONNECTED_USER_INFO:return M(t);case h.C.USER_JOINED:return N(t);case h.C.CHAT_ACTION:return v(t);case h.C.SYSTEM:return(0,i.jsx)(el,{message:t,highlightString:a},t.id);case h.C.FEDIVERSE_ENGAGEMENT_FOLLOW:case h.C.FEDIVERSE_ENGAGEMENT_LIKE:case h.C.FEDIVERSE_ENGAGEMENT_REPOST:return E(t);default:return null}},S=e=>{clearTimeout(j.current),j.current=setTimeout(()=>{var t;null===(t=e.current)||void 0===t||t.scrollTo({top:1/0,left:0,behavior:"auto"}),x(!0)},150),p(!1)};(0,d.useEffect)(()=>{setTimeout(()=>{S(f)},500)},[]);let T=(0,d.useMemo)(()=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.OO,{id:"virtuoso",style:{height:o},className:g().virtuoso,ref:f,data:t,itemContent:(e,t)=>y(e,t),initialTopMostItemIndex:t.length-1,followOutput:()=>!!C&&(p(!1),S(f),"smooth"),alignToBottom:!0,atBottomThreshold:70,atBottomStateChange:e=>{x(e),e?p(!1):p(!0)}}),_&&(0,i.jsx)(eg,{onClick:()=>{S(f)}})]}),[t,a,s,n,_,C]);return(0,i.jsx)(u.SV,{fallbackRender:e=>{let{error:t,resetErrorBoundary:a}=e;return(0,i.jsx)(eG.A,{componentName:"ChatContainer",message:t.message,retryFunction:a})},children:(0,i.jsxs)("div",{id:"chat-container",className:g().chatContainer,children:[T,r&&(0,i.jsx)("div",{className:g().chatTextField,children:(0,i.jsx)($,{enabled:l,focusInput:m})})]})})};eO.defaultProps={showInput:!0,height:"auto"}},88881:function(e){e.exports={chatAction:"ChatActionMessage_chatAction__x9Xsg"}},45761:function(e){e.exports={toBottomWrap:"ChatContainer_toBottomWrap__3V5wa",show:"ChatContainer_show__OBPqg",chatContainer:"ChatContainer_chatContainer__O2lYN",virtuoso:"ChatContainer_virtuoso__OS9Kz",chatTextField:"ChatContainer_chatTextField__OqCGL"}},56654:function(e){e.exports={root:"ChatJoinMessage_root__vuVXa",moderatorBadge:"ChatJoinMessage_moderatorBadge__HF66k",user:"ChatJoinMessage_user__kYpU9",icon:"ChatJoinMessage_icon__TzTHn"}},71368:function(e){e.exports={chatModerationNotification:"ChatModeratorNotification_chatModerationNotification__kgFWe",icon:"ChatModeratorNotification_icon__7FdGg"}},44964:function(e){e.exports={nameChangeView:"ChatNameChangeMessage_nameChangeView__z4WoO",nameChangeText:"ChatNameChangeMessage_nameChangeText__PTEQP",plain:"ChatNameChangeMessage_plain__heTPn",icon:"ChatNameChangeMessage_icon__TWCil"}},31654:function(e){e.exports={follower:"ChatSocialMessage_follower__TyNGH",avatar:"ChatSocialMessage_avatar__QbcNk",avatarColumn:"ChatSocialMessage_avatarColumn__inCWq",body:"ChatSocialMessage_body__aY2Oa",account:"ChatSocialMessage_account__uGSKr",icon:"ChatSocialMessage_icon__fiCk6"}},61120:function(e){e.exports={chatSystemMessage:"ChatSystemMessage_chatSystemMessage__c6XEN",user:"ChatSystemMessage_user__6yHSJ",message:"ChatSystemMessage_message__ySq5g"}},14866: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"}},73295:function(e){e.exports={badge:"ChatUserBadge_badge__1EdUp"}},75774:function(e){e.exports={root:"ChatUserMessage_root__79heB",user:"ChatUserMessage_user__xUEp9",repeatUser:"ChatUserMessage_repeatUser__HnoyL",userBadges:"ChatUserMessage_userBadges__L6wat",message:"ChatUserMessage_message__MJ9LD",ownMessage:"ChatUserMessage_ownMessage__d28A3",background:"ChatUserMessage_background__Tfghp",modMenuWrapper:"ChatUserMessage_modMenuWrapper__7fblv",messagePadding:"ChatUserMessage_messagePadding__Xp1F6",messagePaddingCollapsed:"ChatUserMessage_messagePaddingCollapsed__qxN0E"}},22868:function(){},14777:function(){},99830:function(){},70209:function(){}}]);