Build 542549stable
Module 527214
4,008 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Ay:()=>v,W1:()=>C}),n(323874),n(14289),n(35956);var i,r=n(735438),s=n.n(r),a=n(635377),o=n.n(a);n(228785);var l=n(791332),u=n.n(l),c=n(833291),d=n(403362),_=n(998218),f=((i={}).TEXT="text",i.STRIKETHROUGH="s",i.UNDERLINE="u",i.STRONG="strong",i.ITALICS="em",i.IMAGE="image",i.EMOJI="emoji",i.CUSTOM_EMOJI="customEmoji",i.LINK="link",i.URL="url",i.AUTOLINK="autolink",i.HIGHLIGHT="highlight",i.PARAGRAPH="paragraph",i.LINE_BREAK="br",i.NEWLINE="newline",i.ESCAPE="escape",i.SPOILER="spoiler",i.BLOCK_QUOTE="blockQuote",i.INLINE_CODE="inlineCode",i.CODE_BLOCK="codeBlock",i.MENTION="mention",i.CHANNEL_MENTION="channelMention",i.CHANNEL="channel",i.GUILD="guild",i.ATTACHMENT_LINK="attachmentLink",i.SOUNDBOARD="soundboard",i.STATIC_ROUTE_LINK="staticRouteLink",i.ROLE_MENTION="roleMention",i.COMMAND_MENTION="commandMention",i.TIMESTAMP="timestamp",i.LIST="list",i.HEADING="heading",i.SUBTEXT="subtext",i.SILENT_PREFIX="silentPrefix",i),h=n(417964);let p=new(o())({max:50});function E(e){let t=p.get(e);if(null!=t)return t;let n=(0,h.Fd)(e),i=(0,h.El)(n),r={whitespaceSanitized:n,fullySanitized:i};return p.set(e,r),r}let m=["http:","https:","discord:","tel:","sms:","mailto:"],g=[f.TEXT,f.UNDERLINE,f.STRONG,f.ITALICS,f.STRIKETHROUGH,f.INLINE_CODE,f.SPOILER,f.LINE_BREAK,f.TIMESTAMP],A=[...g,f.EMOJI,f.CUSTOM_EMOJI],I=[f.LIST,f.HEADING,f.BLOCK_QUOTE,f.SUBTEXT],T=[f.TEXT],S=[f.UNDERLINE,f.STRONG,f.ITALICS,f.STRIKETHROUGH,f.INLINE_CODE,f.SPOILER,f.LINE_BREAK,f.TIMESTAMP,f.EMOJI,f.CUSTOM_EMOJI,f.LIST,f.HEADING,f.BLOCK_QUOTE,f.SUBTEXT];function N(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];for(let i of(Array.isArray(e)||(e=[e]),e)){if(void 0===i||!t.includes(i.type))return null;if(i.type===f.INLINE_CODE){let e=[...t,...n];if(null==N(i.validationChildContent,e))return null}if(Array.isArray(i.content)&&null==N(i.content,t))return null}return e}function y(e){if((0,c.rL)(e)||E(e).whitespaceSanitized!==e)return!0;let t=_.A.toURLSafe(e);if(null==t)return!0;if("http:"!==t.protocol&&"https:"!==t.protocol)return!1;let n=e.split("/");return n.length<3||""!==n[1]||_.A.safeDecodeURIComponent(n[2])!==n[2]}function C(e){try{if(y(e))throw Error("Rejected due to suspicious characters in URL: "+JSON.stringify(e));let t=new URL(e),n=t.protocol??"";if(!m.includes(n.toLowerCase()))throw Error("Provided protocol is not allowed: "+n);if(("http:"===n||"https:"===n)&&(null==t.hostname||0===t.hostname.length))throw Error("no hostname");let i=(0,h.nK)(t);t.username="",t.password="";let r=(0,h.nK)(t);return{target:i,displayTarget:r}}catch(e){return null}}let v={...u().defaultRules.link,match(e,t,n){if(!t.allowLinks||-1===e.indexOf("]("))return null;let i=0;for(let t=0;t<e.length;t++){let n=e[t];if("["===n){if(++i>10)return null}else"]"===n&&i>0&&i--}return u().defaultRules.link.match(e,t,n)},parse(e,t,n){let[i,r,a,o]=e,l=()=>({type:f.TEXT,content:i});if(y(a))return l();let _=E(a),h=E(r),p=E(null!=o?o:""),m=_.whitespaceSanitized,v=h.fullySanitized,O=p.fullySanitized,R=v.trim();if(0===m.trim().length||0===R.length)return l();let b=C(u().unescapeUrl(a)),D=(0,c.Ay)(r).length>0||(0,c.Ay)(o).length>0;if(null==b||D)return l();let L={...n,allowEscape:!1,parseInlineCodeChildContent:!0},w=n.allowEmojiLinks?A:g,M=[...w,...I],P=[...T,...S],x=N(t(v,L),M,[f.EMOJI]),U=N(t(O,L),P);if(null==x||null==U||0===(function e(t){let n="";for(let i of t)switch(i.type){case f.TEXT:case f.INLINE_CODE:n+=i.content;break;case f.CUSTOM_EMOJI:n+=i.name;break;case f.EMOJI:n+=i.surrogate;break;case f.LINE_BREAK:n+="\n";break;case f.STRONG:case f.ITALICS:case f.UNDERLINE:case f.STRIKETHROUGH:case f.SPOILER:n+=e(i.content);break;case f.TIMESTAMP:n+="<timestamp>";break;case f.BLOCK_QUOTE:case f.LIST:case f.HEADING:case f.SUBTEXT:n+=`<${i.type}Content>`;break;default:(0,d.xb)(i.type)}return n})(x).trim().length)return l();let k=s().pick(t.rules,w),G=u().parserFor(k)(h.whitespaceSanitized,L),F=p.whitespaceSanitized,{target:V}=b;return{content:G,target:V,title:F}}}}