"use strict";(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push([["8739"],{69004:function(e,t,n){n.d(t,{Z:()=>i}),n(388685);class l extends Map{set(e,t){return this.size>=this.maxSize&&this.delete(this.keys().next().value),super.set(e,t)}constructor(e){var t,n;super(),n=void 0,(t="maxSize")in this?Object.defineProperty(this,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[t]=n,this.maxSize=e}}let i=l},970184:function(e,t,n){n.d(t,{CJ:()=>P,Ee:()=>M,Il:()=>y}),n(388685),n(997841);var l=n(255367),i=n(73800),u=n(512722),a=n.n(u),r=n(442837),o=n(570140),d=n(911969),c=n(493773),s=n(71619),E=n(282397),T=n(622449),I=n(188597),p=n(41776),m=n(665906),f=n(592125),S=n(271383),C=n(607744),_=n(594174),g=n(280501),N=n(892902),h=n(359232);let O=e=>{switch(e.type){case d.re.BUTTON:return e.style!==d.ZJ.LINK;case d.re.STRING_SELECT:case d.re.USER_SELECT:case d.re.ROLE_SELECT:case d.re.MENTIONABLE_SELECT:case d.re.CHANNEL_SELECT:return!0;case d.re.ACTION_ROW:case d.re.TEXT_INPUT:default:return!1}},A=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=g.gH.NORMAL;return null!=e&&e.state!==T.F.FAILED&&(e.data.interactionType===d.B8.MESSAGE_COMPONENT&&e.data.componentId===t.id?l=g.gH.LOADING:O(t)&&(l=g.gH.DISABLED)),n&&O(t)&&(l=g.gH.DISABLED),l},v=e=>{let t=f.Z.getChannel(e),n=(0,r.e7)([C.Z],()=>(null==t?void 0:t.guild_id)==null||C.Z.canChatInGuild(t.guild_id),[t]),l=(0,r.e7)([p.Z],()=>(null==t?void 0:t.guild_id)!=null&&p.Z.isLurking(t.guild_id),[t]),i=(0,r.e7)([S.ZP,_.default],()=>{var e,n;let l=_.default.getCurrentUser();return null!=(n=(null==t?void 0:t.guild_id)!=null&&null!=l?null==(e=S.ZP.getMember(null==t?void 0:t.guild_id,l.id))?void 0:e.isPending:null)&&n}),[,u]=(0,s.AB)(null==t?void 0:t.guild_id),a=(0,m.tc)(t);return!!(!n||l||i||(null==t?void 0:t.isLockedThread())||(null==t?void 0:t.isArchivedThread())&&!a)||!!u};function L(e,t){let n=i.useContext(b),[l,u]=i.useState(null),a=i.useCallback(t=>{let n=(0,h.Z)(e,t);return u(n),null==n},[e]);return i.useEffect(()=>{var e;let l=()=>a(t);return null==(e=n.validators)||e.add(l),()=>{var e;null==(e=n.validators)||e.delete(l)}},[n.validators,a,t]),{error:l,validate:a}}function R(e,t,n,l){var u;let a=(0,r.e7)([N.Z],()=>N.Z.getInteractionComponentState(e.id,n.id)),o=(0,r.e7)([E.ZP],()=>E.ZP.getInteraction(e),[e]),d=v(e.channel_id)||t,{error:c,validate:s}=L(n,a),T=null!=(u=e.applicationId)?u:e.author.id;return{state:a,executeStateUpdate:i.useCallback(t=>{if(!s(t))return!1;let l=f.Z.getChannel(e.channel_id);return null!=l&&null!=n.customId&&(0,I.tM)({componentType:n.type,messageId:e.id,messageFlags:e.flags,customId:n.customId,componentId:n.id,applicationId:T,channelId:l.id,guildId:l.guild_id,localState:t}),!0},[e.channel_id,e.flags,e.id,n.customId,n.type,n.id,T,s]),isDisabled:d&&O(n),visualState:A(o,n,d),error:c}}function Z(e,t,n){let l=(0,r.e7)([N.Z],()=>N.Z.getInteractionComponentState(e.customId,t.id)),{error:u,validate:a}=L(t,l),d=i.useCallback(n=>null==n||(o.Z.dispatch({type:"SET_INTERACTION_COMPONENT_STATE",rootContainerId:e.customId,componentId:t.id,state:n}),!!a(n)),[e.customId,t.id,a]);return(0,c.ZP)(()=>{d(n)}),{state:l,executeStateUpdate:d,isDisabled:!1,visualState:g.gH.NORMAL,error:u}}let b=i.createContext(null);function y(e){let{children:t,message:n,modal:u,validators:r,shouldDisableInteractiveComponents:o=!1}=e,d=i.useMemo(()=>null!=n?{useComponentState:R.bind(null,n,o),channelId:n.channel_id,message:n,validators:r}:(a()(null!=u,"modal is present if message is not"),{useComponentState:Z.bind(null,u),channelId:u.channelId,modal:u,validators:r}),[n,u,r,o]);return(0,l.jsx)(b.Provider,{value:d,children:t})}function M(e,t){return i.useContext(b).useComponentState(e,t)}function P(){return i.useContext(b)}},471073:function(e,t,n){let l,i,u,a,r;n.d(t,{Z:()=>N,i:()=>_});var o,d,c,s,E=n(512722),T=n.n(E),I=n(442837),p=n(570140),m=n(904245),f=n(911969),S=n(603721),C=n(70956),_=((o={})[o.IN_FLIGHT=0]="IN_FLIGHT",o[o.ERRORED=1]="ERRORED",o[o.SUCCEEDED=2]="SUCCEEDED",o);class g extends(s=I.ZP.Store){getModalState(e){return e!==l?null:i}}c="InteractionModalStore",(d="displayName")in g?Object.defineProperty(g,d,{value:c,enumerable:!0,configurable:!0,writable:!0}):g[d]=c;let N=new g(p.Z,{LOGOUT:function(){return l=null,i=null,u=null,a=null,r=null,!0},INTERACTION_MODAL_CREATE:function(e){let{nonce:t}=e;return t===r&&(m.Z.deleteMessage(a,u,!0),u=null,a=null,r=null),!1},INTERACTION_IFRAME_MODAL_CREATE:function(e){let{nonce:t}=e;return t===r&&(m.Z.deleteMessage(a,u,!0),u=null,a=null,r=null),!1},INTERACTION_QUEUE:function(e){let{messageId:t,nonce:n,data:o}=e;switch(o.interactionType){case f.B8.APPLICATION_COMMAND:return u=t,a=o.channelId,r=n,!1;case f.B8.MODAL_SUBMIT:return T()(null==l||1===i||2===i,"cannot submit multiple modals at once"),l=n,i=0,setTimeout(()=>{l===n&&0===i&&(0,S.yr)(n)},10*C.Z.Millis.SECOND),!0;default:return!1}},INTERACTION_SUCCESS:function(e){let{nonce:t}=e;return null!=t&&t===l&&(i=2,!0)},INTERACTION_FAILURE:function(e){let{nonce:t}=e;return null!=t&&t===l&&(i=1,!0)}})},293979:function(e,t,n){n.d(t,{X9:()=>Z,b8:()=>b,hz:()=>L}),n(388685),n(190126),n(368063),n(65234),n(111804),n(490233),n(97749);var l=n(73800),i=n(512722),u=n.n(i),a=n(442837),r=n(544891),o=n(570140),d=n(911969),c=n(211266),s=n(81897),E=n(155268),T=n(603721),I=n(314897),p=n(592125),m=n(271383),f=n(914010),S=n(768581),C=n(70956),_=n(709054),g=n(970184),N=n(471073),h=n(892902),O=n(981631),A=n(388032);let v=e=>{let t=!0;return e.forEach(e=>{e()||(t=!1)}),t};function L(e){var t;let n=(0,g.CJ)(),l=null==n||null==(t=n.modal)?void 0:t.components[0];return(null==l?void 0:l.type)===d.re.ACTION_ROW&&l.components[0].id===e}function R(e){return l.useMemo(()=>{let t=f.Z.getGuildId(),n=null!=t&&null!=e.bot?m.ZP.getMember(t,e.bot.id):void 0,l=S.ZP.getApplicationIconURL({id:e.id,icon:e.icon,botIconFirst:!0,bot:null!=n?e.bot:void 0});return{applicationIconURL:l,applicationName:null!=n&&null!=e.bot?e.bot.username:e.name,applicationBaseUrl:(0,E.ZP)(e.id)}},[e.id,e.icon,e.name,e.bot])}function Z(e,t){let{application:n,customId:i,components:E}=e,m=(0,s.Z)(),[f,S]=l.useState(null),[g,h]=l.useState(null),L=(0,a.e7)([N.Z],()=>N.Z.getModalState(g),[g]),Z=(0,c.Z)(()=>new Set),b=l.useCallback(()=>{S(null),h(null),v(Z)&&h(function(e,t){let n=_.default.fromTimestamp(Date.now()),l=e.channelId,i=p.Z.getChannel(l);u()(null!=i,"expected channel");let a=y(e.customId,e.components);(0,T.kz)(n,{data:{interactionType:d.B8.MODAL_SUBMIT,applicationId:e.application.id}});let o=()=>{null!=t&&t.aborted||r.tn.post({url:O.ANM.INTERACTIONS,body:{type:d.B8.MODAL_SUBMIT,application_id:e.application.id,channel_id:i.id,guild_id:i.guild_id,data:{id:e.id,custom_id:e.customId,components:a},session_id:I.default.getSessionId(),nonce:n},signal:t,rejectWithError:!1}).catch(e=>{429===e.status?setTimeout(o,e.body.retry_after*C.Z.Millis.SECOND):(0,T.yr)(n)})};return o(),n}(e,m))},[m,e,Z]);l.useEffect(()=>{L===N.i.SUCCEEDED&&(o.Z.dispatch({type:"CLEAR_INTERACTION_MODAL_STATE",customId:i}),t()),L===N.i.ERRORED&&S(A.intl.string(A.t.uJgdEh))},[g,L,t,i]);let{applicationIconURL:M,applicationName:P}=R(n);return{components:E,applicationIconURL:M,applicationName:P,submissionState:L,error:f,validators:Z,onSubmit:b}}function b(e){let{application:t,customId:n}=e,{applicationIconURL:l,applicationName:i,applicationBaseUrl:a}=R(t),r=p.Z.getChannel(e.channelId);u()(null!=r,"channel should not be null");let o={instance_id:"".concat(e.channelId,":").concat(t.id,":").concat(n),custom_id:n,channel_id:e.channelId};null!=r.guild_id&&""!==r.guild_id&&(o.guild_id=r.guild_id);let d=new URL(null!=a?a:"");return d.pathname=e.iframePath,{applicationIconURL:l,applicationName:i,applicationBaseUrl:a,queryParams:o,iframeUrl:d.toString()}}let y=(e,t)=>t.map(t=>{switch(t.type){case d.re.ACTION_ROW:return{type:t.type,components:y(e,t.components)};case d.re.TEXT_INPUT:{let n=h.Z.getInteractionComponentState(e,t.id);return{type:t.type,custom_id:t.customId,value:(null==n?void 0:n.type)===t.type?n.value:null}}case d.re.STRING_SELECT:{let n=h.Z.getInteractionComponentState(e,t.id);return{type:t.type,custom_id:t.customId,values:(null==n?void 0:n.type)===t.type?n.values:null}}default:u()(!1,"unreachable")}})},892902:function(e,t,n){n.d(t,{Z:()=>m}),n(388685);var l,i,u,a=n(442837),r=n(570140),o=n(69004);let d=new o.Z(196606),c=0,s=new o.Z(196606),E=new o.Z(196606);function T(e,t,n){var l;let i=null!=(l=d.get(e))?l:new Map;i.set(t,n),d.set(e,i),c++}function I(e){let t=s.get(e);null!=t&&E.delete(t),s.delete(e),d.delete(e),c++}class p extends(l=a.ZP.Store){getInteractionComponentStates(){return d}getInteractionComponentStateVersion(){return c}getInteractionComponentState(e,t){var n;let l=d.get(e);return null==l?null:null!=(n=l.get(t))?n:null}}u="LocalInteractionComponentStateStore",(i="displayName")in p?Object.defineProperty(p,i,{value:u,enumerable:!0,configurable:!0,writable:!0}):p[i]=u;let m=new p(r.Z,{LOGOUT:function(){d.clear(),s.clear(),E.clear(),c++},QUEUE_INTERACTION_COMPONENT_STATE:function(e){let{messageId:t,nonce:n,componentId:l,state:i}=e;s.set(t,n),E.set(n,{messageId:t,componentId:l}),T(t,l,i)},SET_INTERACTION_COMPONENT_STATE:function(e){let{rootContainerId:t,componentId:n,state:l}=e;T(t,n,l)},MESSAGE_DELETE:function(e){let{id:t}=e;if(!d.has(t))return!1;I(t)},MESSAGE_UPDATE:function(e){let{message:t}=e;if(null==t.id||!d.has(t.id))return!1;I(t.id)},INTERACTION_SUCCESS:function(e){let{nonce:t}=e;if(null==t)return!1;let n=E.get(t);if(null==n)return!1;s.delete(n.messageId),E.delete(t),c++},INTERACTION_FAILURE:function(e){let{nonce:t}=e;if(null==t)return!1;let n=E.get(t);if(null==n)return!1;!function(e){let{componentId:t,messageId:n}=e,l=d.get(n);if(null!=l&&l.has(t))l.delete(t),0===l.size&&d.delete(n),c++}(n)},CLEAR_INTERACTION_MODAL_STATE:function(e){let{customId:t}=e;d.delete(t),c++}})},359232:function(e,t,n){n.d(t,{Z:()=>d}),n(388685);var l=n(512722),i=n.n(l),u=n(911969),a=n(388032);let r=(e,t)=>{let{minValues:n,maxValues:l}=e;if(null==t)return 0===n?null:a.intl.formatToPlainString(a.t.Jmwzd3,{count:n});if(t.type===u.re.STRING_SELECT){if(t.values.lengthl)return a.intl.formatToPlainString(a.t.LDvfRE,{count:l})}else if(t.selectedOptions.lengthl)return a.intl.formatToPlainString(a.t.LDvfRE,{count:l});return null},o=(e,t)=>{let{minLength:n,maxLength:l,required:i}=e;return null==t||0===t.value.length?i?a.intl.formatToPlainString(a.t.ONSqYW,{min:n,max:l}):null:t.value.lengthl?a.intl.formatToPlainString(a.t.ONSqYW,{min:n,max:l}):null};function d(e,t){switch(null!=t&&i()(t.type===e.type,"component type matches state"),e.type){case u.re.BUTTON:return null;case u.re.STRING_SELECT:case u.re.USER_SELECT:case u.re.ROLE_SELECT:case u.re.MENTIONABLE_SELECT:case u.re.CHANNEL_SELECT:return r(e,t);case u.re.TEXT_INPUT:return o(e,t);default:i()(!1,"missing validator for this component")}}}}]); //# sourceMappingURL=7e962a02edc1a125.js.map