Build 584177stable
Module 833291
5,006 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Ay:()=>K,br:()=>q,l7:()=>z,rL:()=>Y,st:()=>v,tl:()=>j,ts:()=>$}),n(321073);var i=n(492462),r=n(567243),a=n(179771),s=n(919535),l=n(121401);n(380610),n(100392);var o=n(842241);n(346542);var d=n(182490),c=n(123677),u=n(299091),_=n(257120),E=n(167189),A=n(652215),h=n(758836);let I=/^\/([a-zA-Z0-9-]+)$/,f=/^\/channels\/([0-9]+|@me)\/([0-9]+)$/,p=/^\/(invite|template)\/([a-zA-Z0-9-]+)\/?\.?$/,T=RegExp("^/events/(\\d+)(?:/)(\\d+)?((?:/)(\\d+))?"),m=/^\/(application-directory|discovery\/applications)\/([0-9-]+)\/?((about|images|privacy)\/?)?$/,g=/^\/(application-directory|discovery\/applications)\/([0-9-]+)\/store\/?([0-9-]+)?\/?$/,S=/^\/activities\/([0-9-]+)\/?$/,N=/^\/channels\/([0-9]+)\/shop\/([0-9]+)$/,C=/^(?:\/game-shop\/([0-9]+)|\/channels\/([0-9]+)\/game-shop\/(?:[0-9]+))\/([0-9]+)(?:\/([^\/]+))?$/,O=/^\/channels\/([0-9]+)\/shop$/,R=/^\/quests\/([0-9-]+)\/?$/,L=/^\/games\/([0-9]+)(?:\/[A-Za-z0-9-]*)?\/?$/,y=/^\/oauth2\/authorize/,D=/^#itemSkuId=([0-9]+)$/,v=/dev:\/\/[\w-.~:\/?#\[\]@!$&'()*+,;=%]+/i,b=V(window.GLOBAL_ENV.INVITE_HOST),M=V(window.GLOBAL_ENV.GUILD_TEMPLATE_HOST),P=V(window.GLOBAL_ENV.WEBAPP_ENDPOINT??`//canary.${A.U2_}`),U=V(`//canary.${A.U2_}`),w=V(`//ptb.${A.U2_}`),G=V("discordapp.com"),x=V("discord.com"),k=[_.A.escape(b.host??""),_.A.escape(M.host??""),_.A.escape(P.host??""),_.A.escape(G.host??""),_.A.escape(x.host??"")].filter(Boolean),F=RegExp(`((https?://[^ ]*)|^|\\s)(${k.join("|")})`,"g");function V(e){if(null==e)return{host:null,pathPrefix:null};if(e.indexOf("/")>=0){let t=(0,r.parse)(e,void 0,!0);return{host:t.host,pathPrefix:t.pathname}}return{host:e,pathPrefix:null}}function B(e,t){return t.host?.replace(/^www[.]/i,"")===e.host}function H(e,t){if(!B(e,t))return null;let n=t.pathname??"",i=e.pathPrefix??"";if(!n.startsWith(i))return null;let r=n.substring(i.length);return""===r?null:r}function j(e){return H(P,e)??H(U,e)??H(w,e)??H(G,e)??H(x,e)}function W(e){let t=z(e);if(null==t||null==t.pathname)return{url:null,inviteHostRemainingPath:null,templateHostRemainingPath:null,primaryHostRemainingPath:null};let n=H(b,t),i=H(M,t),r=H(P,t)??H(U,t)??H(w,t)??H(G,t)??H(x,t);return{url:t,inviteHostRemainingPath:n,templateHostRemainingPath:i,primaryHostRemainingPath:r}}function Y(e){if(e.includes("\\")){let t=z(e);if(null==t)return!1;if(B(b,t))return!0;if([P,U,w,G,x].some(e=>B(e,t)))return t.pathname?.toUpperCase().includes(E.I.INVITE)??!1}return!1}function K(e){if(null==e)return[];e=e.replace(F,(e,t,n,i)=>null==n?`${t}http://${i}`:e);let t=n(46054).A.parseToAST(e,!0,{allowLinks:!0}),r=[];(0,s.mm)(t,e=>{e.type===d.D.LINK&&"string"==typeof e.target&&e.target.length>0&&r.push(e.target)});let _=e.match(v);return(function(e){if(null==e||0===e.length)return[];let t=new Set,n=[];for(let s of e){let{url:e,inviteHostRemainingPath:d,templateHostRemainingPath:_,primaryHostRemainingPath:A}=W(s);if(null==e||null==e.pathname)continue;function r(e,i){t.has(i)||(t.add(i),n.push({type:e,code:i,url:s}))}if(d?.match(I)!=null&&("https:"===e.protocol||"http:"===e.protocol)){let t=(0,o.fB)(d.substring(1),e.search);if(u.A.getInvite(t),s.includes("\\"))continue;r(E.I.INVITE,t)}_?.match(I)!=null&&r(E.I.TEMPLATE,_.substring(1));let R=A?.match(p);if(null!=R){let t=R[1].toUpperCase();if(t===E.I.INVITE){if(s.includes("\\"))continue;let t=(0,o.fB)(R[2],e.search);r(E.I.INVITE,t)}else r(t,R[2])}A?.match(f)!=null&&r(E.I.CHANNEL_LINK,A.replace("/channels/",""));let v=function(e){if(null==e)return null;let t=e.match(T);return null!=t&&t.length>=4?{guildId:t[1],guildEventId:t[2],recurrenceId:t[4]}:null}(e.pathname);if(null!=v&&r(E.I.EVENT,`${v.guildId}-${v.guildEventId}`+(null!=v.recurrenceId?`-${v.recurrenceId}`:"")),null!=A?.match(y)&&null!=e.query){let t=(0,c._)(e.query),n=t.clientId;null==n||""===n||t.scopes?.some(e=>e!==a.F.APPLICATIONS_COMMANDS)||r(E.I.APP_OAUTH2_LINK,n)}let b=A?.match(m);if(null!=b){let e=b[2];r(E.I.APP_DIRECTORY_PROFILE,e)}let M=A?.match(g);if(null!=M){let e=M[2],t=M[3];if(null!=t){let n=(0,l.L)(e,t);r(E.I.APP_DIRECTORY_STOREFRONT_SKU,n)}else r(E.I.APP_DIRECTORY_STOREFRONT,e)}let P=A?.match(S);if(null!=P){let e=P[1];r(E.I.ACTIVITY_BOOKMARK,e)}let U=A?.match(N);null!=U&&r(E.I.GUILD_PRODUCT,`${U[1]}-${U[2]}`);let w=A?.match(O);null!=w&&r(E.I.SERVER_SHOP,w[1]);let G=A?.match(C);null!=G&&r(E.I.SOCIAL_LAYER_STOREFRONT,`${G[3]}-${G[1]??G[2]}`);let x=$(s);null!=x&&r(E.I.QUESTS_EMBED,x);let k=A?.match(L);if(null!=k&&r(E.I.GAME_PROFILE,k[1]),"/shop"===A){let t=null!=e.query?(0,i.parse)(e.query):null,n=t?.tab;if(n===h.G2.GAME_SHOPS&&t?.applicationId!=null&&t?.skuId!=null){let e=t.applicationId,n=t.skuId;"string"==typeof e&&"string"==typeof n&&r(E.I.SOCIAL_LAYER_STOREFRONT_APP,`${n}-${e}`)}else{let t=e.hash?.match(D);r(E.I.COLLECTIBLES_SHOP,`${n??""}-${t?.[1]??""}`)}}}return n})(r=(r??[]).concat(_??[])).slice(0,10)}function $(e){let t=W(e),n=t?.primaryHostRemainingPath?.match(R);return n?.[1]??null}function z(e){try{return(0,r.parse)(e)}catch(e){return null}}function q(e){return K(e)[0]}}