Module 655098

14,170 characters · in abe64d994b0c71cc.js
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>ep});var l=n(627968),i=n(64700),s=n(503698),r=n.n(s),a=n(670482),o=n(442433),c=n(267102),u=n(723702),d=n(38405),h=n(408018),m=n(186306),p=n(654821),f=n(35277),g=n(820066),x=n(112107),A=n(17928),E=n(990078),C=n(778712),I=n(939249),y=n(545442),S=n(922016),v=n(565645),N=n(730134),_=n(775602),T=n(47167),j=n(545868),b=n(376943),R=n(465365),O=n(78390),M=n(785562),w=n(973664),L=n(332173),k=n(37632),P=n(679621),D=n(593284),U=n(967144);n(209932);var V=n(734057),G=n(317525),F=n(994500),H=n(351906),B=n(287809),W=n(871237),K=n(562153),z=n(427262),Z=n(375708),Y=n(178259);function q(e){let{emoji:t}=e;return(0,l.jsx)(E.m,{text:t.name,delay:750,position:"top",children:(0,l.jsx)(v.A,{src:t.src,emojiName:t.name,animated:!1,surrogate:t.surrogate})})}function J(e){let{emoji:t}=e;return(0,l.jsx)(E.m,{text:t.name,delay:750,position:"top",children:(0,l.jsx)(v.A,{emojiId:t.emojiId,emojiName:t.name,animated:t.animated})})}function $(e){let{text:t}=e;return(0,l.jsx)(L.A,{children:t})}function X(e){let{id:t,guildId:n,channelId:i}=e,s=(0,A.bG)([B.default],()=>B.default.getUser(t)),r=(0,A.bG)([H.A],()=>H.A.hidePersonalInformation),a=K.Ay.useName(n,i,s),o=(0,l.jsx)(L.A,{children:null==a?`<@${t}>`:`@${a}`});if(null!=s){let e=r||s.hasUniqueUsername()?null:`#${s.discriminator}`;return(0,l.jsx)(E.m,{__unsupportedReactNodeAsText:(0,l.jsxs)("div",{className:Y.fX,children:[(0,l.jsx)(N.A,{user:s,animate:!0,size:C._3.SIZE_16,className:Y.my}),z.Ay.getUserTag(s,{mode:"username",identifiable:r?"never":"always"}),(0,l.jsx)("span",{className:Y.D2,children:e})]}),delay:750,position:"top","aria-label":z.Ay.getUserTag(s,{decoration:"never"}),asContainer:!0,children:(0,l.jsx)(I.D,{tag:"span",children:o})})}return o}function Q(e){let{id:t,guildId:n,channelId:s}=e,r=(0,A.bG)([G.A],()=>null!=n?G.A.getRole(n,t):void 0),a=(0,A.bG)([_.A],()=>_.A.roleStyle),o=(0,U.X_)(n,r,r?.colorStrings),c=i.useRef(null);if(null==r)return(0,l.jsxs)("span",{children:["@",Z.intl.string(Z.t["YV4F/n"])]});let u=null!=r.color&&0!==r.color,d="dot"===a,h="username"===a&&u,m=e=>(0,l.jsxs)(L.A,{ref:c,color:h?r.color:null,roleColors:h?o:null,...e,children:[d&&(0,l.jsx)(y.W,{color:r.colorString,colors:o,background:!1,tooltip:!1}),"@",r.name]});return null==n||null==s?m():(0,l.jsx)(S.Y,{targetElementRef:c,preload:async()=>{await (0,j.a)(n,t)},renderPopout:e=>(0,l.jsx)(D.Y,{guildId:n,channelId:s,roleId:t,popoutProps:e}),position:"top",children:m})}function ee(e){let{id:t}=e,n=(0,A.bG)([V.A],()=>V.A.getChannel(t)),i=Z.intl.string(Z.t.zLZPmk).toLowerCase(),s="text",r=!0;return(null!=n&&(i=(0,b.nc)(n)?(0,T.m1)(n,B.default,F.A):Z.intl.string(Z.t["/YzI63"]),s=(0,b.nc)(n)?(0,W.QG)(n)??"text":"locked",r=(0,R.Y)(n.type)),r)?(0,l.jsx)(L.A,{iconType:s,children:i}):(0,l.jsx)("span",{children:"#"+i})}function et(e){let{id:t,itemId:n,guildId:i}=e,s=(0,O.Q)(t),r=(0,O.f)(t,n,i);return(0,l.jsxs)(L.A,{iconType:t,children:[s,null!=r&&(0,l.jsx)(k.A,{}),r]})}function en(e){let{text:t,id:n}=e;return(0,l.jsxs)(L.A,{children:[t,"(",n,")"]})}function el(e){let{timestamp:t}=e;return(0,l.jsx)(M.A,{node:t,className:"R"===t.format?Y.gS:null})}function ei(e){let{id:t,gameName:n,gameIconHash:i}=e,{name:s,hasName:r}=(0,P.V)({gameName:n,gameId:t});return r?(0,l.jsxs)(L.A,{children:[(0,l.jsx)(w.A,{gameId:t,gameIconHash:i,iconClassName:Y.Kk}),s]}):(0,l.jsxs)("span",{children:["@",Z.intl.string(Z.t["11pdXZ"])]})}var es=n(571898),er=n(494715),ea=n(766184);let eo={strong:es.bold,em:es.italics,u:es.underline,s:es.strikethrough,inlineCode:es.inlineCode,link:es.fakeLink,url:es.fakeLink,autolink:es.fakeLink,silentPrefix:es.fakeLink,spoiler:r()(ea.ur,ea.F0,ea.kx,es.spoiler),staticRouteLink:es.fakeLink,syntaxBefore:es.syntaxBefore,syntaxAfter:es.syntaxAfter,codeBlockText:es.codeBlockText,codeBlockSyntax:es.codeBlockSyntax,codeBlockLang:es.codeBlockLang,subtext:es.subtext};var ec=n(992595);let eu=e=>{let{className:t,attributes:n,children:i}=e,s=r()(er.S0,er.Cj,t);return(0,l.jsx)("span",{...n,className:s,contentEditable:!1,children:i})};var ed=n(652215),eh=n(422404);class em extends i.PureComponent{containerRef=i.createRef();state;constructor(e){super(e),this.renderElement=this.renderElement.bind(this),this.renderLeaf=this.renderLeaf.bind(this),this.handleOnChange=this.handleOnChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this),this.handleBeforeInput=this.handleBeforeInput.bind(this),this.handleCompositionStart=this.handleCompositionStart.bind(this),this.handleCompositionEnd=this.handleCompositionEnd.bind(this),this.handleFocusCapture=this.handleFocusCapture.bind(this),this.handleBlurCapture=this.handleBlurCapture.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handlePasteCapture=this.handlePasteCapture.bind(this),g.VW.isEditorEmpty(e.editor)?this.state={initialValue:(0,h.N3)().richValue,showPlaceholder:!0}:this.state={initialValue:g.VW.richValue(e.editor),showPlaceholder:!1}}componentDidMount(){this.props.editor.events.addListener("onChange",this.handleOnChange)}componentDidUpdate(e,t,n){e.editor!==this.props.editor&&(e.editor.events.removeListener("onChange",this.handleOnChange),this.props.editor.events.addListener("onChange",this.handleOnChange))}componentWillUnmount(){this.props.editor.events.removeListener("onChange",this.handleOnChange)}componentDidCatch(e,t){d.A.captureException(e,{extra:t}),this.setState({initialValue:[...this.props.editor.children]})}renderElement(e){let{guildId:t,channelId:n,renderExtraElement:i}=this.props,{attributes:s,children:a}=e;"rtl"===s.dir&&(s.style={...s.style,textAlign:"right"});let o=i?.(e)??function(e,t,n){let{attributes:i,children:s,element:a,decorations:o}=e,c=Object.entries(o?.[0]??{}).filter(e=>{let[t]=e;return"anchor"!==t&&"focus"!==t}).map(e=>{let[t,n]=e;return!0===n&&t in eo?eo[t]:null}).filter(e=>null!=e).join(" ");switch(a.type){case"line":if(a.codeBlockState?.isInCodeBlock)return(0,l.jsx)("div",{className:es.codeLine,spellCheck:null==a.codeBlockState||null==a.codeBlockState.lang,...i,children:s});return(0,l.jsx)("div",{...i,children:s});case"blockQuote":{let e=r()(ec.h,ec.MN);return(0,l.jsxs)("div",{...i,className:e,children:[(0,l.jsx)("span",{contentEditable:!1,className:ec.r}),(0,l.jsx)("blockquote",{children:s})]})}case"emoji":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(q,{emoji:a.emoji}),s]});case"customEmoji":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(J,{emoji:a.emoji}),s]});case"textMention":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)($,{text:a.name}),s]});case"userMention":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(X,{id:a.userId,channelId:n,guildId:t}),s]});case"roleMention":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(Q,{id:a.roleId,guildId:t,channelId:n}),s]});case"channelMention":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(ee,{id:a.channelId}),s]});case"staticRouteLink":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(et,{id:a.id,itemId:a.itemId,guildId:t}),s]});case"soundboard":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(x.LF,{soundId:a.soundId}),s]});case"commandMention":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(en,{text:a.commandName,id:a.commandId}),s]});case"timestamp":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(el,{timestamp:a.parsed}),s]});case"gameMention":return(0,l.jsxs)(eu,{attributes:i,className:c,children:[(0,l.jsx)(ei,{id:a.gameId,gameName:a.gameName,gameIconHash:a.gameIconHash}),s]});default:return null}}(e,t,n);return null!=o?o:(0,l.jsx)("div",{...s,children:a})}renderLeaf(e){let{editor:t,renderExtraLeaf:n}=this.props,{attributes:i,children:s}=e,a=n?.(e)??function(e,t){let n,{attributes:i,children:s,leaf:a,text:o}=t,c=!1,[u]=g.VW.node(e,g.PW.parent(g.VW.findPath(e,o)));switch(g.VW.isEditor(u)?"editor":u.type){case"line":case"blockQuote":{c=void 0;let e=Object.entries(a).filter(e=>{let[t]=e;return"text"!==t}).flatMap(e=>{let[t,n]=e;if("hljsTypes"===t)return n;if(!0===n){if(("codeBlockLang"===t||"codeBlockSyntax"===t)&&(c=!1),t.startsWith("before_")||t.startsWith("after_"))return[es[t]];if(t in eo)return[eo[t]];throw Error(`Slate: Unknown decoration attribute: ${t}`)}}).filter(e=>null!=e).join(" ");n=r()(e,{[es.syntaxOverride]:"||"===a.text||"\\"===a.text})}}return n=r()(n,{[er.BI]:""===o.text}),(0,l.jsx)("span",{...i,className:n,spellCheck:c,children:s})}(t,e);return null!=a?a:(0,l.jsx)("span",{...i,children:s})}handleOnChange(){let{editor:e}=this.props,t=g.VW.isEditorEmpty(e)&&null==e.composition;if(t!==this.state.showPlaceholder&&this.setState({showPlaceholder:t}),this.props.onChange?.(g.VW.richValue(e)),!1===this.props.canFocus){let t=a.rL.findDocumentOrShadowRoot(e).getSelection();null!=t&&this.isSelectionPartiallyInside(t)&&t?.removeAllRanges()}}handleKeyDown(e){if(null!=this.props.editor.composition){e.preventDefault(),e.stopPropagation();return}this.props.onKeyDown?.(e)}handleKeyUp(e){if(null!=this.props.editor.composition){e.preventDefault(),e.stopPropagation();return}this.props.onKeyUp?.(e)}handleBeforeInput(e){let{editor:t}=this.props,n=a.rL.findDocumentOrShadowRoot(t).getSelection(),l=null!=n&&n.rangeCount>0?n.getRangeAt(0):null,i=e.getTargetRanges()[0]??null;if(null==t.composition){if(("insertText"===e.inputType||"insertReplacementText"===e.inputType)&&(null==i&&(i=l),null!=i)){let n=g.VW.toSlateRange(t,i,{exactMatch:!1,suppressThrow:!0});null!=n&&null!=e.data&&(g.ZF.isExpanded(n)?m.o.withSingleEntry(t,()=>{t.selection=n,t.deleteFragment(),t.insertText(e.data),e.preventDefault()}):(t.insertText(e.data),e.preventDefault()))}if(e.inputType.startsWith("deleteContent")&&null!=l&&!l.collapsed){let n=g.VW.toSlateRange(t,l,{exactMatch:!0,suppressThrow:!0});null!=n&&g.ZF.isExpanded(n)&&(t.selection=n,t.deleteFragment(e.inputType.endsWith("Backward")?"backward":"forward"),e.preventDefault())}}}handleCompositionStart(){let{editor:e}=this.props,t={insertedPrefix:!1,startedInsideInline:!1};this.state.showPlaceholder&&this.setState({showPlaceholder:!1});let n=null!=e.selection&&g.ZF.isCollapsed(e.selection)?g.VW.leaf(e,e.selection.anchor.path):null;if(null==n){e.composition=t;return}if(null!=(null!=e.selection&&g.ZF.isCollapsed(e.selection)?g.VW.above(e,{at:n[1],match:t=>g.VW.isInline(e,t),mode:"lowest"}):null)&&(t.startedInsideInline=!0),g.VW.isEditorEmpty(e)){f.b.insertNodes(e,{text:"\uFEFF"},{select:!0}),t.insertedPrefix=!0,e.composition=t;return}let l=a.rL.findDocumentOrShadowRoot(this.props.editor).getSelection(),i=(l?.rangeCount??0)>0?l?.getRangeAt(0):null;if(null==(null!=i?g.VW.toSlateRange(e,i,{exactMatch:!0,suppressThrow:!0}):null)&&null!=i){let t=g.VW.toSlateRange(e,i,{exactMatch:!1,suppressThrow:!0});e.selection=null,null!=t?f.b.select(e,t):f.b.select(e,g.VW.end(e,[]))}e.composition=t}handleCompositionEnd(e){let{editor:t}=this.props;if(null==t.composition)return;let{insertedPrefix:n}=t.composition;if(n&&null!=t.selection&&g.ZF.isCollapsed(t.selection)){let e=t.selection.anchor.path,n=g.AS.leaf(t,e);g.VW.withoutNormalizing(t,()=>{let e=n.text.replace(/^\uFEFF/,"");f.b.delete(t,{unit:"offset",distance:n.text.length,reverse:!0}),g.VW.insertText(t,e)})}t.composition=null}handleFocusCapture(e){let{onFocus:t}=this.props;t?.(e)}handleBlurCapture(e){let{editor:t,onBlur:n}=this.props,l=e.relatedTarget,i=a.rL.findDocumentOrShadowRoot(this.props.editor),s=i.getElementById("textarea-context"),r=i.getElementById("slate-toolbar");if(null!=l&&!(0,p.hasDomParent)(l,s)&&!(0,p.hasDomParent)(l,r)){let e=a.rL.findDocumentOrShadowRoot(t).getSelection();null!=e&&this.isSelectionEscaping(e)&&e.removeAllRanges()}n?.(e)}isSelectionPartiallyInside(e){let t=this.containerRef.current;if(null!=e&&null!=t)for(let n=e.rangeCount-1;n>=0;n--){let l=e.getRangeAt(n),i=l.startContainer,s=l.endContainer,r=l.startOffset,a=l.endOffset;if((0,p.hasDomParent)(i,t)||!(0,p.isDOMRangeCollapsed)(i,r,s,a)&&(0,p.hasDomParent)(s,t))return!0}return!1}isSelectionEscaping(e){let t=this.containerRef.current,n=!1,l=!1;if(null!=e&&null!=t)for(let i=e.rangeCount-1;i>=0;i--){let s=e.getRangeAt(i),r=s.startContainer,a=s.endContainer,o=s.startOffset,c=s.endOffset;if((0,p.hasDomParent)(r,t)){if(l)return!0;n=!0}else{if(n)return!0;l=!0}if(!(0,p.isDOMRangeCollapsed)(r,o,a,c))if((0,p.hasDomParent)(r,t)){if(l)return!0;n=!0}else{if(n)return!0;l=!0}}return!1}handleContextMenu(e){let{editor:t}=this.props,i=e.pageY,s=window.innerHeight;if(u.isPlatformEmbedded){let r=(0,c.zd)();(0,o.L3)(e,async()=>{let{default:e}=await Promise.all([n.e("10310"),n.e("58273"),n.e("14591"),n.e("96804"),n.e("30803"),n.e("22401")]).then(n.bind(n,258360));return n=>(0,l.jsx)(e,{...n,editor:t,text:g.VW.getSelectedText(t,!0)})},{align:null!=i&&null!=s&&i<s/2?"top":"bottom",enableSpellCheck:r===ed.BRT.APP,repositionOnContentChange:!0})}else blur()}handlePasteCapture(e){let{editor:t,onPaste:n,readOnly:l}=this.props;n?.(e),e.isDefaultPrevented()||e.isPropagationStopped()||l||(t.insertData(e.clipboardData),e.preventDefault(),e.stopPropagation())}render(){let{editor:e,className:t,containerClassName:n,canFocus:i,autoFocus:s,placeholder:o,decorate:c,channelId:u,guildId:d,onChange:h,onFocus:m,onBlur:p,onKeyDown:f,onKeyUp:g,renderExtraElement:x,renderExtraLeaf:A,...E}=this.props;return(0,l.jsxs)("div",{ref:this.containerRef,className:n,children:[this.state.showPlaceholder?(0,l.jsx)("div",{className:r()(eh.q,t),"aria-hidden":!0,"data-slate-placeholder":"true",children:o}):null,(0,l.jsx)(a.A,{editor:e,value:[...this.state.initialValue],children:(0,l.jsx)(a.Fo,{...E,className:r()(ec.PT,eh.E,t),decorate:c,renderElement:this.renderElement,renderLeaf:this.renderLeaf,onFocusCapture:this.handleFocusCapture,onBlurCapture:this.handleBlurCapture,onContextMenu:this.handleContextMenu,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onDOMBeforeInput:this.handleBeforeInput,onCompositionStart:this.handleCompositionStart,onCompositionEnd:this.handleCompositionEnd,onPasteCapture:this.handlePasteCapture,autoFocus:s&&!1!==i,autoCorrect:"off","data-can-focus":!1!==i,"aria-label":o,"aria-multiline":!0})})]})}}let ep=em}