Module 870748

8,693 characters · in abe64d994b0c71cc.js
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>_,t:()=>T}),n(321073),n(667532);var l=n(485845),i=n(155718),s=n(721768),r=n(459016),a=n(842209),o=n(861382),c=n(392054),u=n(168186),d=n(203779),h=n(664929),m=n(734057),p=n(317525),f=n(287809),g=n(317681),x=n(186306),A=n(323350),E=n(35277),C=n(820066),I=n(551483),y=n(652215);n(827669);let S=new Set(["applicationCommandOption"]),v=new Set([i.n4.ATTACHMENT]),N=new Set(["line","applicationCommand"]);function _(e,t,n,d){let{insertData:m,isInline:p,isVoid:f,onChange:y,deleteBackward:_,deleteForward:w,deleteFragment:L}=e;e.insertData=n=>{if(null!=t&&C.VW.isEditorEmpty(e)&&n.types.includes("application/x-discord-interaction-data")){let e=JSON.parse(n.getData("application/x-discord-interaction-data")),{commandKey:l,interactionOptions:i}=(0,u.Ez)(e),{application:o,command:d}=a.EW({channel:t,type:"channel"},l);if(null!=d){let e=null!=o?{type:c.Hf.APPLICATION,id:o.id,icon:o.icon,name:o.bot?.username??o.name,application:o}:null;return s.Gf({channelId:t.id,command:d,section:e,location:c.Oh.PASTE,initialValues:(0,r.getInitialValuesFromInteractionOptions)(d,i??[])}),null}}return m(n)},e.isInline=e=>!!S.has(e.type)||p(e),e.isVoid=e=>!!("applicationCommandOption"===e.type&&v.has(e.optionType))||f(e),e.deleteBackward=t=>{O(e,()=>_(t))},e.deleteForward=t=>{O(e,()=>w(t))},e.deleteFragment=t=>{O(e,()=>L(t))};let k=null,P=null,D=null,U=null,V=null;return e.onChange=()=>{if(null!=t){let r=o.A.getState(t.id),u=a.j8({channel:t,type:"channel"});if(C.VW.richValue(e)!==k||!C.Ot.equals(e.selection,P)||r.activeCommand!==D||null==V||u.some((e,t)=>V[t]!==e)){let o=x.o.withMergedEntry(e,()=>(function(e){let{editor:t,storeCommandState:n,channel:r,canUseCommands:o,canOnlyUseTextCommands:u,commandChanged:d,previousOptionValues:m}=e,{command:p,commandText:f}=R(t),x=n.activeCommand;if(!o&&x?.integration_types?.includes(l.b.GUILD_INSTALL)||u&&x?.inputType!==c.y$.BUILT_IN_TEXT&&x?.inputType!==c.y$.BUILT_IN_INTEGRATION)return null!=p&&T(t,r.id,x,!0),null;if(null!=p){if(C.VW.isEditorEmpty(t)||null==x)return T(t,r.id,x,!1),null;let e=`/${p.displayName}`;if(null==f||!f.startsWith(e)||0===g.O7(t).length&&(f.length<e.length+1||" "!==f[e.length]))return T(t,r.id,x,!0),null}else{if(null!=x&&d){let e=function(e,t,n){let l,{initialValues:i,activeCommand:s}=n;if(null==s)return null;let r=(s.options?.length??0)>0?g.pY(e,s):null,a=(0,A.WO)(C.VW.richValue(e),{mode:"raw",range:{anchor:C.VW.start(e,[]),focus:r?.[0]?.keyRange.anchor??C.VW.end(e,[])}}),o="",c=a.toLocaleLowerCase(),u=`/${s.displayName} `.toLocaleLowerCase(),d=`/${s.untranslatedName} `.toLocaleLowerCase();c.startsWith(u)?o=a.substring(u.length).trim():c.startsWith(d)&&(o=a.substring(d.length).trim());let h=[],m=null,p=null;if(null!=s.options){let e=new Set;if(null!=r)for(let l of r){e.add(l.name);let i=M(n,t,l.name)??l.text,s={type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:i}]};h.push(s),0===l.text.length&&null==m&&(m=s)}for(let l of s.options)if(!e.has(l.name)&&(l.required||null!=i[l.name])){let e,i;o.length>0&&!v.has(l.type)?(e=o,o=""):e=(i=M(n,t,l.name))??"";let s={type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:e}]};h.push(s),0===e.length&&null==m&&(m=s),null==i&&(p=s)}}l=o.length>0?`/${s.displayName} ${o.replace(/\r|\n/g," ")}`:0===h.length?`/${s.displayName} `:`/${s.displayName}`,h.unshift({text:l});let f={type:"applicationCommand",children:h,command:{id:s.id,name:s.untranslatedName,displayName:s.displayName}};C.VW.withoutNormalizing(e,()=>{for(let[,t]of(E.b.insertNodes(e,[f],{at:I.Xg}),C.VW.blocks(e).reverse()))C.PW.isAfter(t,I.Xg)&&E.b.removeNodes(e,{at:t,voids:!0})});let x=null;return null!=m?(E.b.selectCommandOption(e,m.optionName),x=m.optionName):null!=p?(E.b.selectCommandOption(e,p.optionName,!1),x=p.optionName):E.b.resetSelectionToEditorEnd(e),null==p&&j(e,s),x}(t,r,n),l=g.SQ(t,x,r.id);return b({guildId:r.guild_id,channelId:r.id,command:x,activeOption:e,currentOptionValues:l,previousOptionValues:null,validateAll:!0,allowEmpty:!0}),{commandId:x.id,optionValues:l}}if(null!=x&&!d)return s.Gf({channelId:r.id,command:null,section:null}),null;let e=C.VW.richValue(t)[0],l=e.children[0];if(N.has(e.type)&&C.l5.isText(l)){let e=function(e,t){if(!e.startsWith("/"))return null;let n=(0,h.Yn)(t,e.substring(1));if(!n.hasSpaceTerminator)return null;let{commands:l,sections:s}=a.v7({channel:t,type:"channel"},i.kc.CHAT,n.text);if(0===l.length)return null;let r=n.text.trim(),o=r+" ",u=l.filter(e=>e.inputType!==c.y$.PLACEHOLDER&&(e.displayName===r||e.displayName.startsWith(o)));if(1===u.length&&u[0].displayName===r){let e=u[0],t=s.find(t=>t.application?.id===e.applicationId);return{command:e,section:t}}return null}(l.text,r);if(null!=e)return s.Gf({channelId:r.id,command:e.command,section:e.section}),null}}if(null!=x&&null!=p){!function(e,t){if(null==t.options||0===t.options.length)return!1;let n=g.pY(e,t);return 0!==n.length&&(C.VW.withoutNormalizing(e,()=>{for(let t=n.length-1;t>=0;t--){let l=n[t];E.b.textToInline(e,{type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:l.text}]},{anchor:l.keyRange.anchor,focus:l.valueRange.focus})}let t=C.VW.getFirstText(e);if(null==t)return!1;let l=t.text.trim();t.text!==l&&E.b.textToText(e,l,{anchor:{path:I.fP,offset:0},focus:{path:I.fP,offset:t.text.length}})}),!0)}(t,x)&&j(t,x);let e=g.SQ(t,x,r.id),n=C.VW.above(t,{match:e=>C.VW.isInline(t,e)&&"applicationCommandOption"===e.type,mode:"lowest"}),l=n?.[0].optionName??null;return b({guildId:r.guild_id,channelId:r.id,command:x,activeOption:l,currentOptionValues:e,previousOptionValues:m,validateAll:!1,allowEmpty:!1}),{commandId:p.id,optionValues:e}}return null})({editor:e,storeCommandState:r,channel:t,canUseCommands:n,canOnlyUseTextCommands:d,commandChanged:r.activeCommand?.id!==D?.id,previousOptionValues:U}));if(null!=o){let t=x.o.currentEntry(e);null!=t&&(t.commandId=o.commandId),U=o.optionValues}else U=null;k=C.VW.richValue(e),P=e.selection,D=r.activeCommand,V=u}}y()},e}function T(e,t,n,l){let[i]=C.VW.blocks(e)[0],r=(l?(0,A.IQ)(i,{mode:"plain"}).trimEnd():"").split("\n").map(e=>({type:"line",children:[{text:e}]})),a=[r.length-1];for(let[,t]of(E.b.insertNodes(e,r,{at:I.Xg}),C.VW.blocks(e).reverse()))C.PW.isAfter(t,a)&&E.b.removeNodes(e,{at:t,voids:!0});null!=n&&s.Gf({channelId:t,command:null,section:null})}function j(e,t){if(null==t.options||1!==t.options.length||!0===t.options[0].required||v.has(t.options[0].type)||g.O7(e).length>0||null==g.n$(e))return!1;let n=C.VW.getFirstText(e);if(null==n)return!1;let l=t.options[0],i={path:I.fP,offset:t.displayName.length+2},s={path:I.fP,offset:n.text.length};return!(!n.text.startsWith(`/${t.displayName} `.toLocaleLowerCase())||C.Kh.equals(i,s))&&(E.b.textToInline(e,{type:"applicationCommandOption",optionName:l.name,optionDisplayName:l.displayName,optionType:l.type,children:[{text:n.text.substring(t.displayName.length+2)}]},{anchor:i,focus:s}),!0)}function b(e){let{guildId:t,channelId:n,command:l,activeOption:i,currentOptionValues:r,previousOptionValues:a,validateAll:c,allowEmpty:u}=e;if(null==l.options)return!1;let h=c?null:o.A.getActiveOptionName(n),m={},p=o.A.getOptionStates(n),f=!1;for(let e of l.options){let l=p[e.name],s=c||e.name===h&&h!==i||l?.lastValidationResult?.success===!1&&r?.[e.name]!==a?.[e.name],o={hasValue:null!=r&&e.name in r,isActive:e.name===i,lastValidationResult:s?(0,d.J)({option:e,content:r?.[e.name]??null,guildId:t,channelId:n,allowEmptyValues:u}):l?.lastValidationResult};(null==l||l.hasValue!==o.hasValue||l.isActive!==o.isActive||s&&l.lastValidationResult?.success===!1)&&(m[e.name]=o,f=!0)}f&&s.H2(n,m)}function R(e){let t=g.n$(e);if(null==t)return{command:null,commandText:null};let[n]=t,l=n.children[0];return C.l5.isText(l)?{command:n.command,commandText:l.text}:{command:n.command,commandText:null}}function O(e,t){let n=g.O7(e)[0];t();let l=C.ZF.toPoint(e.selection);if(null==l||n===g.O7(e)[0])return;let{command:i,commandText:s}=R(e);!(null==i||null==s||s.endsWith(" "))&&C.Kh.equals(l,{path:I.fP,offset:i.displayName.length+1})&&E.b.insertText(e," ")}function M(e,t,n){let l=e.activeCommand?.options?.find(e=>e.name===n),s=e.initialValues[n];if(null==l||null==s)return null;if(null!=l.choices)return l.choices.find(e=>e.value===s.value)?.displayName;let r=s.value?.toString();return l.type===i.n4.CHANNEL||l.type===i.n4.MENTIONABLE&&null!=m.A.getChannel(r)?`<#${r}>	`:l.type===i.n4.USER||l.type===i.n4.MENTIONABLE&&null!=f.default.getUser(r)?`<@${r}>`:l.type===i.n4.ROLE||l.type===i.n4.MENTIONABLE&&null!=p.A.getRole(t.guild_id,r??y.dJq)?`<@&${r}>`:r}}