Loading
function(e,t,n){n.d(t,{A:()=>tv});var l=n(477900),i=n(582128),r=n(503698),s=n.n(r),a=n(305866),o=n(289873),u=n(793574),c=n(688810),d=n(151271),h=n(665252),m=n(702841),f=n(594061),p=n(796774),g=n(209932);n(30146);var x=n(675816),E=n(562708),S=n(17928),y=n(27232),A=n(406810),C=n(111159),b=n(7689),I=n(369606),v=n(939249),N=n(297264),T=n(358618),j=n(983851),_=n(442433),k=n(537652),R=n(212245),w=n(139286),O=n(915089),M=n(724511),L=n(850992),P=n(887695),D=n(435558),U=n(962125),V=n(927578),W=n(240864),F=n(212633);let B=(0,D.throttle)(function(e){let{listRef:t,searchQuery:n,nitroLockedSectionStates:l,scrollTop:i,sectionHeaderHeight:r,sectionFooterHeight:s}=e;if(null==t.current)return;let a=(0,W.s)({listRef:t,searchQuery:n,nitroLockedSectionStates:l,scrollTop:i,sectionHeaderHeight:r,sectionFooterHeight:s});d.RQ.setState({isNitroLockedSectionVisible:a.isNitroLockedSectionVisible,areOnlyNitroLockedSectionsVisible:a.areOnlyNitroLockedSectionsVisible})},300,{leading:!1,trailing:!0}),K=function(e){let{categories:t,store:n,hasSearchResults:r,listPadding:s,renderRow:a,renderSection:o,renderSectionHeader:u,renderSectionFooter:c,renderInspector:h,renderEmptySearchState:m,rowCount:f,rowCountBySection:p,rowHeight:g,sectionHeaderHeight:x,sectionFooterHeight:E,renderUpsell:S,onScroll:y,ref:A}=e,C=i.useRef(!1),b=i.useRef(null),I=(0,d.RQ)(e=>e.searchQuery),v=n.useStore(e=>e.activeCategoryIndex),N=i.useMemo(()=>t.map(e=>(0,V.Em)(e.categoryInfo)?{isNitroLocked:e.categoryInfo.isNitroLocked}:{isNitroLocked:!1}),[t]),T=(0,P.Fk)({activeCategoryIndex:v,isScrolling:C,listRef:b,onActiveCategoryIndexChange:n.setActiveCategoryIndex,scrollOffset:20,searchQuery:I}),j=i.useCallback(e=>{T(e),B({listRef:b,searchQuery:I,nitroLockedSectionStates:N,scrollTop:e,sectionHeaderHeight:x,sectionFooterHeight:E}),y?.(e)},[T,I,N,x,E,y]);return i.useEffect(()=>{null!=b.current&&j(b.current.getScrollerNode()?.scrollTop??0)},[j,b]),(0,P.FV)({searchQuery:I,activeCategoryIndex:v,listRef:b}),i.useImperativeHandle(A,()=>({scrollTo:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.current?.scrollTo(...t)},getRowDescriptors:()=>b.current?.getRowDescriptors()??[],getSectionDescriptors:()=>b.current?.getSectionDescriptors()??[],scrollToSectionTop:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.current?.scrollToSectionTop(...t)},scrollRowIntoView:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.current?.scrollRowIntoView(...t)},getScrollerNode:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.current?.getScrollerNode(...t)},scrollIntoViewNode:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.current?.scrollIntoViewNode(...t)},getListDimensions:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.current?.getListDimensions(...t)??{height:-1,totalHeight:-1}}}),[]),(0,l.jsxs)("div",{className:F.i,children:[I.length>0&&!r&&null!=m?m():(0,l.jsx)(U.A,{role:"none presentation",listPadding:s,onScroll:j,renderRow:a,renderSection:o,renderSectionHeader:u,renderSectionFooter:c,rowCount:f,rowCountBySection:p,rowHeight:g,sectionHeaderHeight:x,sectionFooterHeight:E,stickyHeaders:!0,ref:b}),S?.(),h?.()]})};var G=n(462180),H=n(602034),z=n(683438),q=n(642232);let $=function(e){let{store:t,hasSendableExpressions:n,onKeyDown:r,gridNavigatorId:s,expressionsListRef:a,defaultSearchPlaceholder:o,emptySearchPlaceholder:u,ref:c}=e,h=i.useRef(null),[m,f]=(0,d.RQ)(e=>[e.searchQuery,e.isSearchSuggestion],G.x),p=t.useStore(e=>e.searchPlaceholder),[g,x]=t.useStore(e=>[e.inspectedExpressionPosition,e.hasInteracted],G.x),E=i.useCallback(e=>{t.setActiveCategoryIndex(""===e?0:L.Uk),t.setInspectedExpressionPosition(0,0),t.setSearchPlaceholder(null),(0,d.Ri)(e),a.current?.scrollTo(0)},[a,t]),S=i.useCallback(()=>{E("")},[E]);return i.useImperativeHandle(c,()=>({focus:()=>h.current?.focus()})),i.useLayoutEffect(()=>{f&&h.current?.focus()},[f]),(0,l.jsx)("div",{className:q.i,children:(0,l.jsx)(z.I,{autoFocus:n,disabled:!n,query:m,ref:h,placeholder:null!=p?p:n||null==u?o:u,onClear:S,onKeyDown:r,onChange:E,inputProps:{"aria-haspopup":"grid","aria-controls":s,"aria-expanded":!0,...x?{"aria-activedescendant":(0,H.Aq)(s,g.columnIndex,g.rowIndex)}:void 0}})})};var Q=n(904289);function Z(e){let{categories:t,collapsedCategories:n,containerWidth:r,store:s,onSelectItem:a,onSearchExpressions:o,onScroll:u,hasSearchResults:c,defaultSearchPlaceholder:h,emptySearchPlaceholder:m,renderEmptyState:f,renderRow:p,renderSection:g,renderSectionHeader:x,renderSectionFooter:E,renderInspector:S,renderEmptySearchState:y,renderCategoryList:A,renderHeaderAccessories:C,rowHeight:b,sectionHeaderHeight:I,sectionFooterHeight:v,itemNodeWidth:N,listPaddingRight:T,itemNodeMargin:j,listPadding:_,gridNavigatorId:k,gridNotice:R,renderHeader:w,renderUpsell:O}=e,M=i.useRef(null),L=i.useRef(null),D=i.useRef(null),U=0===t.length,V=(0,d.RQ)(e=>e.searchQuery),W=s.useStore(e=>e.inspectedExpressionPosition),F=(0,P.oV)({gridWrapperRef:M,containerWidth:r,showingEmptyState:U}),{expressionsGrid:B,rowCount:G,rowCountBySection:H,columnCounts:z,gutterWidth:q}=(0,P.se)({categories:t,collapsedCategories:n,gridWidth:F,listPaddingRight:T,itemNodeWidth:N,itemNodeMargin:j}),{getItemProps:Z,getRowProps:X,gridContainerProps:J,handleGridContainerKeyDown:Y,isUsingKeyboardNavigation:ee}=(0,P.JZ)({columnCounts:z,expressionsListRef:L,expressionsGrid:B,onSelectItem:a,store:s,gridNavigatorId:k}),et=i.useCallback((e,t)=>p(B[e],X(e),{isUsingKeyboardNavigation:ee.current,gutterWidth:q,rowIndex:e,totalRowCount:G,sectionIndex:t.sectionIndex},t=>Z(e,t),t=>s.setInspectedExpressionPosition(t,e)),[B,Z,X,q,ee,p,s,G]),en=i.useCallback(e=>x?.(t[e],e),[t,x]),el=i.useCallback(e=>E?.(t[e],e),[t,E]),ei=i.useCallback(()=>S?.(B?.[W.rowIndex]?.[W.columnIndex]),[B,W.columnIndex,W.rowIndex,S]);i.useEffect(()=>{o(V)},[o,V]),i.useEffect(()=>{s.setBottomPosition(M.current?.getBoundingClientRect().bottom??null)}),i.useEffect(()=>s.resetStoreState,[s.resetStoreState]),i.useLayoutEffect(()=>{D.current?.focus()},[]);let er=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)($,{ref:D,store:s,hasSendableExpressions:!0,onKeyDown:Y,expressionsListRef:L,gridNavigatorId:k,defaultSearchPlaceholder:h,emptySearchPlaceholder:m}),C?.()]});return(0,l.jsxs)(l.Fragment,{children:[null!=w?w(er):(0,l.jsxs)("div",{className:Q.wx,children:[" ",er," "]}),U&&null!=f?f(Q.p$):(0,l.jsxs)(l.Fragment,{children:[A(L),null!=R&&(0,l.jsx)("div",{className:Q.Eb,children:R}),(0,l.jsx)("div",{ref:M,className:Q.AD,id:k,...J,children:null!=F?(0,l.jsx)(K,{categories:t,ref:L,store:s,hasSearchResults:c,listPadding:_,renderRow:et,renderSection:g,renderSectionHeader:null!=x?en:void 0,renderSectionFooter:null!=E?el:void 0,renderInspector:null!=S?ei:void 0,renderEmptySearchState:y,rowCount:G,rowCountBySection:H,rowHeight:b,sectionHeaderHeight:I,sectionFooterHeight:v,renderUpsell:O,onScroll:u}):null})]})]})}var X=n(89366),J=n(319993),Y=n(202639),ee=n(414872),et=n(285373),en=n(609178),el=n(253932),ei=n(763827),er=n(287809),es=n(977997),ea=n(147925),eo=n(174459),eu=n(807348),ec=n(813564),ed=n(699840),eh=n(147472);n(321073);var em=n(964486),ef=n(931991),ep=n(734057),eg=n(71393),ex=n(576705),eE=n(309010),eS=n(473145),ey=n(636537),eA=n(73153),eC=n(463347),eb=n(125831),eI=n(652215),ev=n(805143),eN=n(194567),eT=n(980504),ej=n(202541);function e_(e,t){return null!=t&&(e=t(e)),e.map((e,t)=>({type:eu.uq.SOUND,sound:e,index:t}))}function ek(e){let{sections:t,guildIds:n,allSounds:l,potentialSoundIdsForSection:i,sectionType:r,sortSoundsFn:s}=e,a={};for(let e of[...n,"0"])for(let t of l.get(e)??[])null!=i.find(e=>e===t.soundId)&&(a[t.soundId]=t);let o=[];for(let e of i){let t=a[e];null!=t&&o.push(t)}let u=e_(o,s);u.length>0&&t.push({key:r,categoryInfo:{type:r},items:u})}function eR(e,t){let n=t.get("0")??eT.pD;e.push({key:eu.Cx.DEFAULTS,categoryInfo:{type:eu.Cx.DEFAULTS},items:e_(n,eN.U9)})}var ew=n(554146),eO=n(43105),eM=n(131607),eL=n(49999),eP=n(105292);function eD(e){let{targetElementRef:t}=e,{allowReordering:n}=ed.q.useConfig({location:"SoundboardFavoritesCoachmark"}),[i,r]=(0,eM.kn)(n?[ew.M.SOUNDBOARD_FAVORITES_ORDERING_COACHMARK]:[],{bypassAutoDismiss:!0});return i!==ew.M.SOUNDBOARD_FAVORITES_ORDERING_COACHMARK?null:(0,l.jsx)(eO.A,{targetElementRef:t,onRequestClose:function(e){("user:escape"===e||"user:explicit"===e)&&r(eL.i.DISMISS),r(eL.i.AUTO_DISMISS)},title:eP.intl.string(eP.t.KFcQy8),body:eP.intl.string(eP.t["P/1x7s"]),badge:"beta"})}var eU=n(340368),eV=n(837381),eW=n(866665),eF=n(713517),eB=n(88218),eK=n(407698),eG=n(941971),eH=n(698279),ez=n(120052);let eq=[8,8,8,8],e$="soundboard_guild_",{itemIdForIndex:eQ}=(0,eB.J)(e$);function eZ(e){let{children:t,className:n,isSelected:r,listItemProps:s,onClick:a}=e,o=i.useRef(null),{isHoveringOrFocusing:u}=(0,eF.A)(o);return(0,l.jsxs)(v.D,{innerRef:o,...s,className:n,onClick:a,children:[(0,l.jsx)("div",{className:ez.a$,children:(0,l.jsx)(eG.A,{hovered:u,selected:r,size:"small"})}),t]})}function eX(e){let{icon:t,isSelected:n,onClick:i,listItemProps:r}=e;return(0,l.jsx)(eZ,{className:s()(ez.Yl,{[ez.wH]:n}),isSelected:n,listItemProps:r,onClick:i,children:(0,l.jsx)(t,{className:ez.xi,color:"currentColor"})})}function eJ(e,t,n,i,r){switch(e.categoryInfo.type){case eu.Cx.FAVORITES:return(0,l.jsx)(eX,{icon:y.StarIcon,onClick:t,isSelected:n,listItemProps:i},e.key);case eu.Cx.FREQUENTLY_USED:return(0,l.jsx)(eX,{icon:A.ClockIcon,onClick:t,isSelected:n,listItemProps:i},e.key);case eu.Cx.GUILD:return(0,l.jsx)(eZ,{className:ez.L1,isSelected:n,listItemProps:i,onClick:t,children:(0,l.jsx)(M.A,{guild:e.categoryInfo.guild,isSelected:n,isLocked:r})},e.key);case eu.Cx.DEFAULTS:return(0,l.jsx)(eX,{icon:C.p,onClick:t,isSelected:n,listItemProps:i},e.key);case eu.Cx.TOP_SOUNDS:return(0,l.jsx)(eX,{icon:I.TrophyIcon,onClick:t,isSelected:n,listItemProps:i},e.key);default:return null}}function eY(e){let{category:t,categoryIndex:n,onClick:i,isSelected:r,isNitroLocked:s}=e,a=(0,eV.rm)(eQ(n));return t.categoryInfo.type===eu.Cx.GUILD?(0,l.jsx)(eK.Q,{guild:t.categoryInfo.guild,children:eJ(t,i,r,a,s)}):(0,l.jsx)(eW.m,{text:function(e){switch(e.categoryInfo.type){case eu.Cx.FAVORITES:return eP.intl.string(eP.t.k8fFjp);case eu.Cx.FREQUENTLY_USED:return eP.intl.string(eP.t["+cGVV6"]);case eu.Cx.GUILD:return e.categoryInfo.guild.name;case eu.Cx.DEFAULTS:return eP.intl.string(eP.t.Rtvk9X);case eu.Cx.TOP_SOUNDS:return eP.intl.formatToPlainString(eP.t.GXs41w,{guildName:e.categoryInfo.guild.name})}}(t),position:"right",align:"center",children:eJ(t,i,r,a,s)})}function e0(e){let{soundboardListRef:t,categories:n,shouldUpsellLockedCategories:r,listPadding:a=eq,guildId:o,inExpressionPicker:u}=e,c=i.useRef(null),d=(0,S.bG)([er.default],()=>er.default.getCurrentUser()),h=(0,V.TW)(d,ej.PremiumTypes.TIER_2),m=i.useCallback((e,t,n,i)=>{let s=r&&e1(e.categoryInfo,h,o);return(0,l.jsx)(eY,{category:e,categoryIndex:t,onClick:function(){eo.default.track(eI.HAw.EXPRESSION_PICKER_CATEGORY_SELECTED,{location:{page:eI.liQ.SOUNDBOARD_POPOUT},guild_id:o??null,num_expressions:e.items.length,tab:eH.kx.SOUNDBOARD,sticker_pack_id:null,pack_id:null}),n()},isSelected:i,isNitroLocked:s})},[o,r,h]);return(0,l.jsx)(eB.A,{className:s()(u?ez.HZ:ez.jv),categoryListRef:c,expressionsListRef:t,store:L.LW,categories:n,listPadding:a,renderCategoryListItem:m,rowCount:n.length,categoryHeight:40,navId:"soundboard-picker-categories",itemIdPrefix:e$})}function e1(e,t,n){return null==n&&e.type===eu.Cx.GUILD&&!t||e.type===eu.Cx.GUILD&&e.guild.id!==n&&!t}var e2=n(191023),e5=n(192308),e3=n(28863),e6=n(695366),e8=n(834730),e7=n(789645),e4=n(565645),e9=n(775602),te=n(826673),tt=n(182922),tn=n(532624),tl=n(531685),ti=n(723702),tr=n(350535),ts=n(115023);function ta(e){let{soundboardSound:t,closePicker:i}=e,r=(0,d.RQ)(e=>e.searchQuery),s=(0,m.bG)([g.A],()=>null!=t&&g.A.isFavoriteSound(t.soundId)),a=(0,m.bG)([eg.A],()=>eg.A.getGuild(t?.guildId)),o=(0,m.bG)([e9.Ay],()=>e9.Ay.useReducedMotion,[]),u=(0,m.bG)([tl.A],()=>tl.A.isFocused()),c=(0,m.bG)([tn.Ay],()=>tn.Ay.getKeybindForAction(eI.hCu.SOUNDBOARD_HOLD));if(null!=t&&r.length>0)return(0,l.jsx)(tt.A,{graphicPrimary:null!=t.emojiId||null!=t.emojiName?(0,l.jsx)(e4.A,{emojiId:t.emojiId,emojiName:t.emojiName,className:ts.Zg}):(0,l.jsx)(e2.ImageIcon,{size:"md",color:"currentColor",className:ts.Zg}),graphicSecondary:null!=a?(0,l.jsx)(M.A,{guild:a,shouldAnimate:!o&&u}):null,titlePrimary:t.name,titleSecondary:a?.name,isFavorite:s});function h(){i(),(0,e5.openModalLazy)(async()=>{let{default:e}=await Promise.all([n.e("161411"),n.e("498640"),n.e("846327"),n.e("912618")]).then(n.bind(n,29681));return t=>(0,l.jsx)(e,{...t})})}let f=(0,te.k8)(ew.M.SOUNDBOARD_KEYBIND_TIP),p=null!=c&&(0,ti.isWindows)()&&!f?eP.intl.format(eP.t.udMTth,{keybind:(0,tr.dI)(c.shortcut,!0),openSettingsHook:(e,t)=>(0,l.jsx)(e3.Anchor,{onClick:h,children:e},t)}):null;return null==p?null:(0,l.jsxs)("div",{className:ts.g,children:[(0,l.jsx)(e6.E,{size:"custom",width:20,height:20,color:"currentColor",className:ts.QW}),(0,l.jsx)(e8.E,{variant:"text-sm/medium",color:"text-default",className:ts.L5,children:p}),(0,l.jsx)(v.D,{className:ts.b,onClick:function(){return(0,te.Dr)(ew.M.SOUNDBOARD_KEYBIND_TIP)},children:(0,l.jsx)(e7.P,{size:"xs",color:"currentColor"})})]})}var to=n(817232),tu=n(890856),tc=n(307301),td=n(468689);function th(e){td.A.open(e,eI.BEX.SOUNDBOARD),(0,e5.openModalLazy)(async()=>{let{default:t}=await Promise.all([n.e("860350"),n.e("207998"),n.e("699733"),n.e("401295"),n.e("775417"),n.e("67491"),n.e("308555"),n.e("883952"),n.e("220287"),n.e("66580"),n.e("808979"),n.e("420643"),n.e("974049"),n.e("280559"),n.e("669006"),n.e("98913"),n.e("612811")]).then(n.bind(n,191110));return n=>(0,l.jsx)(t,{...n,guildId:e})})}var tm=n(948611),tf=n(308078);function tp(e){let{guild:t,focused:n,onSelectItem:i,...r}=e,{canCreateExpressions:a}=(0,ef.nr)(t);return(0,l.jsx)(eW.m,{text:eP.intl.string(eP.t["fHo+z1"]),shouldShow:!a,children:(0,l.jsx)("li",{className:tm.H,children:(0,l.jsxs)(tu.s,{...r,"aria-label":eP.intl.formatToPlainString(eP.t.c1qVYh,{guildName:t.name}),className:s()(tf.n4,{[tf.in]:n,[tf.r9]:!a}),onClick:()=>null!=i?i():th(t.id),children:[(0,l.jsx)(tc.j,{size:"sm",color:"currentColor"}),(0,l.jsx)(e8.E,{variant:"text-xs/semibold",color:a?"currentColor":"text-muted",children:eP.intl.string(eP.t["8Fu/S7"])})]})})})}function tg(e){let{descriptor:t,soundButtonProps:n,rowIndex:l,columnIndex:r,isUsingKeyboardNavigation:s,suppressPlaySound:a,getItemProps:o,onSelectItem:u,onItemMouseEnter:c,buttonOverlay:d,isNitroLocked:h,showLockForDisabledSound:m,inExpressionPicker:f}=e,p=L.LW.useStore(e=>e.inspectedExpressionPosition),g=`${l}-${r}`,x=s&&p.rowIndex===l&&p.columnIndex===r;switch(t.item.type){case eu.uq.SOUND:return(0,i.createElement)(to.Ay,{...o(r),...n,key:g,sound:t.item.sound,suppressPlaySound:a,focused:x,onMouseEnter:()=>c(r),onSelectItem:e=>u(t,e),enableSecondaryActions:!0,buttonOverlay:d,inNitroLockedSection:h,showLockForDisabledSound:m,isSoundmoji:!0===f});case eu.uq.ADD_SOUND:return(0,i.createElement)(tp,{...o(r),key:g,guild:t.item.guild,focused:x,onSelectItem:()=>u(t)})}}var tx=n(635799);let tE=32+ee.kg-8,tS={[eu.Cx.SEARCH]:u.A.SOUNDBOARD_SEARCH_RESULTS_SECTION,[eu.Cx.DEFAULTS]:u.A.SOUNDBOARD_DEFAULT_SOUNDS_SECTION,[eu.Cx.GUILD]:u.A.SOUNDBOARD_GUILD_SOUNDS_SECTION,[eu.Cx.FAVORITES]:u.A.SOUNDBOARD_FAVORITES_SECTION,[eu.Cx.FREQUENTLY_USED]:u.A.SOUNDBOARD_FREQUENTLY_USED_SECTION,[eu.Cx.TOP_SOUNDS]:u.A.SOUNDBOARD_TOP_SOUNDS_SECTION};function ty(e){let{categoryInfo:t,collapsed:n,toggleCollapsed:r,isSectionNitroLocked:a,showNitroDivider:o,canRenderFavoritesUpsell:u}=e,c=i.useRef(null);return(0,l.jsxs)(l.Fragment,{children:[o&&(0,l.jsx)(ee.Ay,{className:tx.yH}),(0,l.jsx)("div",{className:s()(tx.hd,{[tx.Jb]:a,[tx.VD]:a}),children:(0,l.jsx)(v.D,{className:tx.bV,onClick:r,onKeyDown:e=>e.stopPropagation(),"aria-expanded":!n,children:(0,l.jsxs)("div",{className:tx.M2,ref:u?c:void 0,children:[function(){switch(t.type){case eu.Cx.FAVORITES:return(0,l.jsx)(y.StarIcon,{size:"xs",color:"currentColor",className:tx.nr});case eu.Cx.FREQUENTLY_USED:return(0,l.jsx)(A.ClockIcon,{size:"xs",color:"currentColor",className:tx.nr});case eu.Cx.GUILD:return(0,l.jsx)(M.A,{guild:t.guild,height:16,width:16});case eu.Cx.DEFAULTS:return(0,l.jsx)(C.p,{size:"custom",width:28,height:28,color:"currentColor",className:tx.nr});case eu.Cx.SEARCH:return(0,l.jsx)(b.MagnifyingGlassIcon,{size:"md",color:"currentColor",className:tx.nr});case eu.Cx.TOP_SOUNDS:return(0,l.jsx)(I.TrophyIcon,{size:"xs",color:"currentColor",className:tx.nr})}}(),(0,l.jsx)(N.D,{variant:"text-sm/semibold",color:"none",className:tx.Gf,children:function(){switch(t.type){case eu.Cx.FAVORITES:return eP.intl.string(eP.t.k8fFjp);case eu.Cx.FREQUENTLY_USED:return eP.intl.string(eP.t["+cGVV6"]);case eu.Cx.GUILD:return t.guild.name;case eu.Cx.DEFAULTS:return eP.intl.string(eP.t.Rtvk9X);case eu.Cx.SEARCH:return eP.intl.string(eP.t["zkoeq/"]);case eu.Cx.TOP_SOUNDS:return eP.intl.formatToPlainString(eP.t.GXs41w,{guildName:t.guild.name})}}()}),(0,l.jsx)(ea.A,{className:tx.nr,direction:n?ea.A.Directions.RIGHT:ea.A.Directions.DOWN})]})})}),u&&(0,l.jsx)(eD,{targetElementRef:c})]})}function tA(){return(0,l.jsx)(k.A,{message:eP.intl.string(eP.t.bgDdNK)})}function tC(e){let{className:t}=e,n=(0,S.bG)([g.A],()=>g.A.isSoundboardVolumeMuted())?T._:j.H;return(0,l.jsx)(n,{size:"md",color:"currentColor",className:t})}function tb(e){let{guildId:t,channel:r,containerWidth:a,onClose:o,onSelect:h,shouldValidateSelectedSound:m=!1,suppressPlaySound:f=!1,shouldShowLockedSounds:p=!0,gridNotice:y,soundButtonOverlay:A,listPadding:C,renderHeader:b,defaultSoundsOnly:I=!1,inExpressionPicker:N,analyticsSource:T}=e,{analyticsLocations:k}=(0,c.Ay)(),{analyticsLocations:M}=(0,c.Ay)(u.A.PREMIUM_UPSELL),{location:P}=(0,R.p)(),D=i.useMemo(()=>({...P,section:eI.JJy.SOUNDBOARD_SOUND_PICKER}),[P]),[U,W]=i.useState(null),F=(0,S.bG)([er.default],()=>er.default.getCurrentUser()),B=(0,V.TW)(F,ej.PremiumTypes.TIER_2),K=(0,S.bG)([es.A],()=>es.A.getVoiceState(t,F?.id??eI.dJq)),G=K?.selfDeaf||K?.mute||K?.suppress,H=(0,d.RQ)(e=>e.searchQuery),z=null!=H&&""!==H,q=(0,O.GV)(),{allowReordering:$}=ed.q.useConfig({location:"SoundboardSoundGrid"}),[Q,ee]=i.useState(!1),{isDraggingFavoriteSound:ea}=(0,x.V)(e=>({isDraggingFavoriteSound:e.isDragging()&&e.getItemType()===eT.Tj})),ew=i.useCallback(()=>{ee(!0)},[]);i.useEffect(()=>{if(Q)return window.addEventListener("mousemove",e),()=>{window.removeEventListener("mousemove",e)};function e(){ee(!1)}},[Q]);let{categories:eO,availableSounds:eM,soundCounts:eL}=function(e){let{filterOutEmptyCurrentGuild:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=(0,S.bG)([er.default],()=>er.default.getCurrentUser()),r=V.Ay.isPremium(l,ej.PremiumTypes.TIER_2),[s,a,o,u]=(0,S.yK)([g.A],()=>[g.A.getSounds(),g.A.getFavorites(),g.A.getFrequentlyUsedSoundIds(),g.A.isFetching()]),c=(0,eN.IJ)(),{sortOrder:d}=ed.q.useConfig({location:"useSoundGrid"}),h=(0,ev.Y)(e,!1),m=(0,S.yK)([eg.A],()=>{let e=[];return h.forEach(t=>{let n=eg.A.getGuild(t);null!=n&&e.push(n)}),e}),f=V.Ay.canUseSoundboardEverywhere(l),p=(0,S.bG)([eg.A],()=>eg.A.getGuild(e?.guild_id)),x=(0,S.bG)([ex.A],()=>{let{canCreateExpressions:e}=(0,ef.ie)(p);return e},[p]),E=i.useMemo(()=>o.filter(e=>!a.has(e)).slice(0,3),[o,a]),y=(0,S.bG)([eE.Ay,ep.A,eg.A],()=>{let e=eE.Ay.getVoiceChannelId(),t=null!=e?ep.A.getChannel(e):null;return t?.guild_id!=null?eg.A.getGuild(t.guild_id):void 0});(0,em.Ay)(()=>{!function(e){var t;if(null==e||null==er.default.getCurrentUser())return;let n=g.A.getTopSoundboardSoundsMetadata(e);if(null!=n){let{topSoundsTTL:e}=n;if(null==e||Date.now()<e)return}eb.A.getIsFetching(e)||(t=e,(0,eC.tZ)(t)||(eA.h.dispatch({type:"TOP_SOUNDBOARD_SOUNDS_FETCH",guildId:t}),ey.Bo.get({url:eI.Rsh.TOP_SOUNDBOARD_SOUNDS_FOR_GUILD(t),oldFormErrors:!0,rejectWithError:!0}).then(e=>eA.h.dispatch({type:"TOP_SOUNDBOARD_SOUNDS_FETCH_SUCCESS",guildId:t,topSoundsMetadata:e.body.items.map(e=>({soundId:e.sound_id,rank:e.sound_rank})).sort((e,t)=>e.rank-t.rank)}),()=>eA.h.dispatch({type:"TOP_SOUNDBOARD_SOUNDS_FETCH_FAILURE",guildId:t}))))}(y?.id)});let A=(0,S.yK)([g.A],()=>g.A.getTopSoundboardSoundIds(y?.id)),C=i.useMemo(()=>A.slice(0,3),[A]);return i.useMemo(()=>{let e=0,l=0,i=[];if(n)return eR(i,s),{categories:i,availableSounds:s.get("0")??eT.pD,isFetching:u,soundCounts:{favoriteSoundCount:0,unlockedCustomSoundCount:0,lockedCustomSoundCount:0}};null!=y&&function(e,t,n){let{allSounds:l,topSoundIds:i}=n,r={};for(let e of l.get(t.id)??[])r[e.soundId]=e;let s=[];for(let e of i){let t=r[e];null!=t&&s.push(t)}0!==s.length&&e.push({key:eu.Cx.TOP_SOUNDS,categoryInfo:{type:eu.Cx.TOP_SOUNDS,guild:t},items:e_(s)})}(i,y,{allSounds:s,topSoundIds:C});let o="favorite-date"===d?eN.XP:eN.U9;return ek({sections:i,guildIds:h,allSounds:s,potentialSoundIdsForSection:Array.from(a),sectionType:eu.Cx.FAVORITES,sortSoundsFn:o}),E.length>0&&ek({sections:i,guildIds:h,allSounds:s,potentialSoundIdsForSection:E,sectionType:eu.Cx.FREQUENTLY_USED}),void 0!==p&&function(e,t,n){let{currentGuildHasAddPermissions:l,allSounds:i,filterOutEmptyCurrentGuild:r,sortSoundsFn:s}=n,a=i.get(t.id)??[],o=e_(a,s),u=a.length<(0,eS.fA)(t)&&l,c=0===o.length;(u||c)&&!r&&o.push({type:eu.uq.ADD_SOUND,guild:t}),r&&c||e.push({categoryInfo:{type:eu.Cx.GUILD,guild:t,isNitroLocked:!1},key:t.id,items:o})}(i,p,{currentGuildHasAddPermissions:x,allSounds:s,filterOutEmptyCurrentGuild:t,sortSoundsFn:c}),f||eR(i,s),!function(e){let{sections:t,guilds:n,currentGuildId:l,allSounds:i,hasNitro:r,sortSoundsFn:s}=e;for(let e of n){if(e.id===l)continue;let n=e_(i.get(e.id)??[],s);n.length>0&&t.push({categoryInfo:{type:eu.Cx.GUILD,guild:e,isNitroLocked:!r},key:e.id,items:n})}}({sections:i,guilds:m,currentGuildId:p?.id,allSounds:s,hasNitro:r,sortSoundsFn:c}),f&&eR(i,s),i.forEach(t=>{t.categoryInfo.type===eu.Cx.GUILD&&(t.categoryInfo.isNitroLocked?l+=t.items.length:e+=t.items.length)}),{categories:i,availableSounds:Array.from(s.values()).flat(),isFetching:u,soundCounts:{favoriteSoundCount:a.size,unlockedCustomSoundCount:e,lockedCustomSoundCount:l}}},[h,s,a,!0,p,x,t,f,m,n,u,r,c,E,y,C,d])}(r,void 0,I),[eD,eV]=i.useState([]),eW=i.useMemo(()=>H.length>0?[{key:eu.Cx.SEARCH,categoryInfo:{type:eu.Cx.SEARCH},items:e_(eD)}]:eO,[eO,H.length,eD]),eF=(0,d.RQ)(e=>e.isNitroLockedSectionVisible),eB=i.useMemo(()=>eW.filter(e=>e.items.length>0),[eW]),eK=i.useMemo(()=>eB.findLastIndex(e=>!!(0,V.Em)(e.categoryInfo)&&e.categoryInfo.isNitroLocked),[eB]),eG=!B&&p&&-1!==eK,ez=!B&&p&&-1!==eK,eq=el.b0.useSetting(),e$=i.useMemo(()=>new Set(eq),[eq]),eQ=null==r,eZ=V.Ay.canUseCustomCallSounds(F),eX=i.useCallback(e=>{e$.has(e)?e$.delete(e):e$.add(e),el.b0.updateSetting(Array.from(e$))},[e$]),eJ=i.useCallback((e,t,n,l)=>{if(null!=h&&!m)return h(e,n);let i=(0,ec.Ir)(F,e,r,!1);if(null!=h&&m&&i)h(e,n);else if(!f&&i&&(0,ec.Au)(r))(0,ec.Ak)(e,r?.id??eI.dJq,t,l),z&&eo.default.track(eI.HAw.SEARCH_RESULT_SELECTED,{search_type:eI.I4_.SOUNDBOARD,channel_id:r?.id,query:H,location_stack:t});else{if((0,ec.Ir)(F,e,r))return;p&&W(e)}},[f,F,r,p,z,H,h,m]),eY=i.useCallback((e,t)=>{switch(e.item.type){case eu.uq.SOUND:let n=tS[e?.category]??null,l=e?.item.index;return eJ(e.item.sound,null==n?k:[...k,n],t?.shiftKey!==!0,l);case eu.uq.ADD_SOUND:return o(),th(e.item.guild.id)}},[k,eJ,o]),e2=i.useCallback((e,n,i,a,o)=>{let u=eB[i.sectionIndex],c=p&&e1(u.categoryInfo,B,t)&&eG,d=$&&u.categoryInfo.type===eu.Cx.FAVORITES;return(0,l.jsx)("ul",{...n,className:s()(tx.a,{[tx.uL]:c}),children:e.map((e,t)=>{let n=e.item.type===eu.uq.SOUND&&e.category===eu.Cx.FAVORITES&&e.item.index===u.items.length-1,s=e.item.type===eu.uq.SOUND?`sound-${e.item.sound.soundId}`:`add-sound-${e.item.guild.id}`;return(0,l.jsx)(tg,{descriptor:e,soundButtonProps:{channel:r,interactive:eQ?eZ:!G,forceSecondaryActions:!0,analyticsLocations:k,enableFavoritesDragAndDrop:d,isLastFavoriteSound:n,onFavoriteSoundDrop:ew,disableActiveStyles:d&&Q},rowIndex:i.rowIndex,columnIndex:t,isUsingKeyboardNavigation:i.isUsingKeyboardNavigation,suppressPlaySound:f,getItemProps:a,onSelectItem:eY,onItemMouseEnter:o,buttonOverlay:A,isNitroLocked:c,showLockForDisabledSound:p,inExpressionPicker:N},s)})},`row-${n["aria-rowindex"]}`)},[eB,p,B,t,f,eY,r,eQ,eZ,G,k,A,eG,N,$,ew,Q]),e5=i.useCallback((e,t)=>{if(e<=0||!p)return!1;let n=eB[e],l=eB[e-1],i=e1(n.categoryInfo,B,t),r=e1(l.categoryInfo,B,t);return i&&!r},[eB,p,B]),e3=i.useCallback(()=>{let e=g.A.getSoundById("3");null!=e&&W(e)},[]),e6=i.useCallback(()=>{let e=(0,V.Dd)(ej.PremiumTypes.TIER_2);return eP.intl.format(eP.t["tw/SSq"],{nitroTierName:e,onClick:e3})},[e3]),e8=i.useCallback(e=>e5(e,t)?tE:32,[t,e5]),e7=i.useCallback(e=>{let t=e===eB.length-1;return ez&&t?70:eG&&e===eK?20:0},[eB.length,eG,ez,eK]),e4=i.useCallback((e,t)=>{let n=ea&&eB[e]?.categoryInfo.type!==eu.Cx.FAVORITES;return(0,l.jsx)("div",{className:s()({[tx.YJ]:n}),children:t},e)},[eB,ea]),e9=i.useCallback((e,n)=>{let i=`${e.key}`,r=p&&e1(e.categoryInfo,B,t),s=e5(n,t),a=e$.has(i);return(0,l.jsx)(ty,{categoryInfo:e.categoryInfo,toggleCollapsed:function(){eo.default.track(eI.HAw.EXPRESSION_PICKER_CATEGORY_COLLAPSE_TOGGLED,{location:{page:eI.liQ.SOUNDBOARD_POPOUT},tab:eH.kx.SOUNDBOARD,guild_id:t??null,collapsed:!a,sticker_pack_id:null,num_expressions:e.items.length}),eX(i)},collapsed:a,isSectionNitroLocked:r&&eG,showNitroDivider:s&&eG,canRenderFavoritesUpsell:$&&e.items.length>1&&e.categoryInfo.type===eu.Cx.FAVORITES},`header-${i}`)},[e$,eX,t,e5,p,B,eG,$]),te=i.useCallback((e,t)=>{let n=t===eB.length-1,i=t===eK;return ez&&n?(0,l.jsx)("div",{className:s()(tx.Lk,{[tx.Ns]:i})}):eG&&t===eK?(0,l.jsx)("div",{className:s()(tx.a3,{[tx.Ns]:i})}):null},[eK,eG,ez,eB.length]),tt=i.useCallback(e=>eV((0,eh.lG)(e,eM,F,r,k)),[r,F,eM,k]),tn=i.useCallback(e=>{(0,_.L3)(e,async()=>{let{default:e}=await n.e("811562").then(n.bind(n,666801));return t=>(0,l.jsx)(e,{sourceAnalyticsLocations:k,...t})})},[k]),tl=(0,eU._)("SoundboardSoundGrid"),ti=i.useCallback(()=>N?(0,l.jsx)(J.Gq,{renderPopout:()=>(0,l.jsx)(J.qn,{}),tooltipText:eP.intl.string(eP.t["19lt24"]),position:"top",clickableClassName:s()(tx.Jm,tx.Zz),children:(0,l.jsx)(j.H,{size:"md",color:"currentColor",className:tx.By})}):(0,l.jsx)(v.D,{tabIndex:0,className:tx.Jm,onClick:tn,"aria-label":tl?eP.intl.string(eP.t.wQKOBb):eP.intl.string(eP.t.kbFsAD),children:(0,l.jsx)(tC,{className:tx.By})}),[N,tn,tl]),tr=i.useCallback(e=>(0,l.jsx)(e0,{soundboardListRef:e,categories:eO,shouldUpsellLockedCategories:eG,listPadding:C,guildId:t,inExpressionPicker:N}),[eO,C,eG,t,N]),ts=i.useCallback(()=>{let e=(0,X.qD)();return(0,V.LE)(e,ej.pe.TIER_2)??eP.intl.string(eP.t.pj0XBN)},[]);i.useEffect(()=>{ez&&eF&&eo.default.track(eI.HAw.PREMIUM_UPSELL_VIEWED,{type:ej.e.SOUNDBOARD_PICKER_FLOATING_UPSELL,location:D,location_stack:M,sku_id:V.Ay.getSkuIdForPremiumType(ej.PremiumTypes.TIER_2),voice_guild_id:ei.A.getGuildId()??null})},[D,M,ez,eF]);let to=i.useCallback(()=>ez?(0,l.jsx)(Y.d,{showUpsell:eF,text:e6(),button:ts(),buttonAnalyticsObject:{section:eI.JJy.SOUND_PICKER_FLOATING_UPSELL},leadingAction:(0,l.jsx)(et.l,{size:"sm",className:tx.ij,location:u.A.PREMIUM_WISHLIST_SOUNDBOARD_UPSELL,forceDarkTheme:!0})}):null,[e6,ts,ez,eF]),tu=i.useCallback(e=>e?.item.type===eu.uq.SOUND?(0,l.jsx)(ta,{closePicker:o,soundboardSound:e?.item.sound??null}):null,[o]),tc=(0,S.bG)([ei.A],()=>ei.A.getMediaSessionId());return(0,w.A)({type:E.ImpressionTypes.POPOUT,name:E.ImpressionNames.SOUNDBOARD_POPOUT,properties:{source:T,guild_id:t,media_session_id:tc,available_custom_sounds_count:eL.unlockedCustomSoundCount,unavailable_custom_sounds_count:eL.lockedCustomSoundCount,favorite_sounds_count:eL.favoriteSoundCount,type:eT.c4.FULL_PICKER}}),(0,l.jsxs)(l.Fragment,{children:[null!=U?(0,l.jsx)(en.A,{title:eP.intl.string(N?eP.t.rZEEvU:eP.t.jGDYF0),description:eP.intl.string(N?eP.t.ZPNG5A:eP.t["grL/hg"]),analyticsLocationSection:eI.JJy.SOUNDBOARD_SOUND_PICKER_UPSELL,upsellViewedTrackingData:{type:ej.e.SOUND_PICKER_SOUND_CLICKED,is_external:!0,location:{...D,object:eI.ZSU.SOUNDBOARD_SOUND},location_stack:M,sku_id:V.Ay.getSkuIdForPremiumType(ej.PremiumTypes.TIER_2),voice_guild_id:ei.A.getGuildId()},onClose:()=>W(null),onUpsellClicked:o}):void 0,(0,l.jsx)(Z,{categories:eB,collapsedCategories:e$,containerWidth:a,store:L.LW,onSelectItem:eY,onSearchExpressions:tt,hasSearchResults:eD.length>0,defaultSearchPlaceholder:eP.intl.string(eP.t.sKt3xS),renderRow:e2,renderSectionHeader:e9,renderSectionFooter:te,renderSection:e4,renderCategoryList:tr,renderHeaderAccessories:ti,rowHeight:48,sectionHeaderHeight:e8,sectionFooterHeight:e7,itemNodeWidth:150,gridNavigatorId:q,renderEmptySearchState:tA,renderInspector:tu,gridNotice:y,renderHeader:b,renderUpsell:to})]})}var tI=n(70317);function tv(e){let{guildId:t,channel:n,containerWidth:r,onClose:x,onSelect:E,analyticsSource:S,suppressPlaySound:y,shouldValidateSelectedSound:A,shouldShowLockedSounds:C=!0,gridNotice:b,inExpressionPicker:I,soundButtonOverlay:v,listPadding:N,renderHeader:T,defaultSoundsOnly:j,showEchoes:_=!1}=e,{fetching:k,maybeFetchData:R}={fetching:(0,m.bG)([g.A],()=>g.A.isFetchingAnySounds()),maybeFetchData:i.useCallback(()=>{p.E7(),f.bW.loadIfNecessary()},[])},{analyticsLocations:w}=(0,c.Ay)(u.A.SOUNDBOARD_POPOUT),O=I?void 0:{height:520};return i.useEffect(()=>{R()},[R]),i.useEffect(()=>{I||(0,d.Ri)("")},[I]),(0,l.jsx)(c.f5,{value:w,children:(0,l.jsxs)(a.l,{style:O,className:s()(tI.Nz,{[tI.Bg]:k,[tI.yV]:I}),children:[_&&null!=t&&n?.id!=null?(0,l.jsx)(h.A,{guildId:t,channelId:n.id}):null,k?(0,l.jsx)(o.y,{}):(0,l.jsx)(tb,{guildId:t,channel:n,onClose:x,onSelect:E,shouldValidateSelectedSound:A,containerWidth:r,suppressPlaySound:y,shouldShowLockedSounds:C,gridNotice:b,soundButtonOverlay:v,listPadding:N,renderHeader:T,defaultSoundsOnly:j,inExpressionPicker:I,analyticsSource:S})]})})}}