Build 545032stable
Module 317084
7,101 characters · in c2ef78f173e5cfba.jsDependencies
Source Raw
function(e,t,n){n.d(t,{A:()=>L}),n(321073);var l=n(627968),r=n(64700),i=n(562708),a=n(17928),s=n(793574),o=n(688810),u=n(139286),d=n(594061),c=n(763827),h=n(935208),A=n(796774),f=n(209932),y=n(813564),m=n(933204),g=n(805143),x=n(735438),p=n.n(x),v=n(939249);function w(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function E(e,t,n,l){return w(e,n,l)!==w(t,n,l)&&w(e,t,n)!==w(e,t,l)}var I=n(375708),_=n(740371);function C(e){let{className:t}=e;return(0,l.jsxs)("svg",{className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",children:[(0,l.jsx)("g",{filter:"url(#a)",children:(0,l.jsx)("path",{d:"M30.4 8 24 14.4 17.6 8 16 9.6l6.4 6.4-6.4 6.4 1.6 1.6 6.4-6.4 6.4 6.4 1.6-1.6-6.4-6.4L32 9.6 30.4 8Z",fill:"currentColor"})}),(0,l.jsx)("defs",{children:(0,l.jsxs)("filter",{id:"a",x:"0",y:"0",width:"48",height:"48",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[(0,l.jsx)("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),(0,l.jsx)("feColorMatrix",{in:"SourceAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),(0,l.jsx)("feOffset",{dy:"8"}),(0,l.jsx)("feGaussianBlur",{stdDeviation:"8"}),(0,l.jsx)("feColorMatrix",{values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.16 0"}),(0,l.jsx)("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_605_72103"}),(0,l.jsx)("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_605_72103",result:"shape"})]})})]})}let O=[{x:.5,y:.05},{x:.95,y:.2},{x:1,y:.5},{x:.95,y:.8},{x:.5,y:.95},{x:.05,y:.8},{x:0,y:.5},{x:.05,y:.2}],N=O.length;function b(e,t,n){let l=e*t;return e>.5?l-n:e<.5?l:l-n/2}let D=r.memo(function(e){let{wheelWidth:t,wheelHeight:n,itemWidth:i,itemHeight:a,showDeadZoneIndicator:s,activeItem:o,onItemSelect:u,onItemAction:d,interactive:c=!0,onClose:h,children:A}=e,f=r.useRef(null),y=r.useRef([]),m=r.useRef(!1),g=r.useRef(null),[w,D]=r.useState(0),[j,T]=r.useState({x:0,y:0}),L=Math.abs(j.x)+Math.abs(j.y)>0,k=r.useMemo(()=>p().chunk(A,N),[A]),M=r.useCallback((e,t)=>{null==y.current[w]?y.current[w]=[]:y.current[w][t]=e},[w]),S=r.useCallback((e,t)=>{g.current=t,u(N*e+t)},[u]),P=r.useCallback(()=>{g.current=null,u(null)},[u]),R=r.useCallback(e=>{P(),m.current=e},[P]),G=r.useCallback((e,t,n)=>{let l,r,i;if(m.current)return void T({x:0,y:0});let a={x:e.x-t.x,y:e.y-t.y},s=a.x<0,o=a.y<0,u=(l=Math.abs(a.x),r=180/Math.PI*Math.atan2(Math.abs(a.y),l),{x:Math.max((i=n/2-28.8)*Math.cos(2*Math.PI*r/360),0),y:Math.max(i*Math.sin(2*Math.PI*r/360),0)});T({x:(s?Math.max(a.x,-u.x):Math.min(a.x,u.x))/2,y:(o?Math.max(a.y,-u.y):Math.min(a.y,u.y))/2})},[]),V=r.useCallback(e=>{null!=g.current&&(e.preventDefault(),e.stopPropagation(),d?.(N*w+g.current))},[d,w]),U=r.useMemo(()=>(0,x.throttle)(e=>{var l;let r;if(null==f.current)return;let i=f.current.getBoundingClientRect(),a={x:i.left+i.width/2,y:i.top+i.height/2},s={x:e.clientX,y:e.clientY};if(G(s,a,Math.max(t,n)),m.current){null!=o&&P();return}let u=(l=Math.max(t,n),r=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2)),{x:s.x+(s.x-a.x)/r*l,y:s.y+(s.y-a.y)/r*l});for(let e=0;e<y.current[w].length;e++){let t=y.current[w][e];if(null!=t&&function(e,t,n){let l={x:n.x,y:n.y},r={x:n.x+n.width,y:n.y},i={x:n.x,y:n.y+n.height},a={x:n.x+n.width,y:n.y+n.height};return E(e,t,l,r)||E(e,t,r,a)||E(e,t,a,i)||E(e,t,i,l)}(a,u,t.getBoundingClientRect()))return void S(w,e)}P()},16),[o,G,P,S,w,n,t]),Y=r.useCallback(e=>{if(!c)return;let t=w+(e.deltaY>0?1:-1);t>=0&&t<k.length&&(null!=g.current&&(k[t].length>g.current?S(t,g.current):P()),D(t))},[c,w,k,S,P]),F=r.useMemo(()=>k[w].map((e,r)=>{let s=O[r];if(null==s)throw Error(`Too many items supplied ${A.length} expected max of ${O.length}`);let o=b(s.x,t,i),u=b(s.y,n,a);return(0,l.jsx)("div",{ref:e=>M(e,r),className:_.Tj,style:{left:o,top:u,width:i,height:a},children:e},r)}),[k,w,t,i,n,a,A.length,M]);return(0,l.jsx)(v.D,{className:_.Pw,onMouseMove:U,onWheel:Y,onClick:V,children:(0,l.jsxs)("div",{ref:f,className:_._$,style:{width:t,height:n},children:[(0,l.jsxs)("svg",{className:_.cA,viewBox:"0 0 288 288",xmlns:"http://www.w3.org/2000/svg",children:[(0,l.jsxs)("filter",{id:"soundboard-wheel-background-shadow",x:"0",y:"0",width:"288",height:"288",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[(0,l.jsx)("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),(0,l.jsx)("feColorMatrix",{in:"SourceAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),(0,l.jsx)("feOffset",{dy:"8"}),(0,l.jsx)("feGaussianBlur",{stdDeviation:"8"}),(0,l.jsx)("feColorMatrix",{values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.16 0"}),(0,l.jsx)("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_489_60382"}),(0,l.jsx)("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_489_60382",result:"shape"})]}),(0,l.jsxs)("g",{filter:"url(#soundboard-wheel-background-shadow)",children:[(0,l.jsx)("circle",{className:_.cA,cx:"144",cy:"144",r:"103.68",strokeWidth:"40.32"}),s&&(0,l.jsx)("circle",{className:_.u1,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),cx:144,cy:144,r:28.8}),L&&(0,l.jsx)("circle",{className:_.JV,cx:144+j.x,cy:144+j.y,r:28.8})]}),s&&(0,l.jsx)("circle",{className:_.u1,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),cx:144,cy:144,r:28.8,stroke:"none"})]}),(0,l.jsxs)("div",{className:_.gx,children:[s&&(0,l.jsx)(v.D,{className:_.$2,onClick:h,children:(0,l.jsx)(C,{className:_.$2})}),c&&k.length>1?(0,l.jsx)("div",{className:_.YB,children:I.intl.string(I.t["Xy+S02"])}):null]}),F]})})});var j=n(805945);n(980504);var T=n(1986);function L(e){let{guildId:t,channel:n,width:x,height:p,keepOpen:v,interactive:w=!0,analyticsSource:E,onClose:I}=e,_=function(e){let[t,n]=(0,a.yK)([f.A],()=>[f.A.getSounds(),f.A.getFavorites()]);return r.useMemo(()=>{let l=[],r=[...e,"0"],i=(e,r)=>{for(let i of t.get(e)?.sort((e,t)=>h.default.compare(e.soundId,t.soundId))??[]){let e=n.has(i.soundId);(e&&r||!e&&!r)&&i.available&&l.push(i)}};return r.forEach(e=>i(e,!0)),r.forEach(e=>i(e,!1)),l},[t,n,e])}((0,g.Y)(n,!0)),C=(0,m.T)(),O=r.useRef(null),[N,b]=r.useState(void 0),L=(0,a.bG)([c.A],()=>c.A.getMediaSessionId()),{analyticsLocations:k}=(0,o.Ay)(s.A.SOUNDBOARD_WHEEL),M=r.useCallback(e=>{(0,y.Ak)(e,n.id,k),I()},[k,n.id,I]);r.useEffect(()=>{A.E7(),d.bW.loadIfNecessary()},[]),r.useEffect(()=>{0===_.length&&0===C.length&&I()},[_.length,C,I]),r.useEffect(()=>()=>{let e=O.current;v||null==e||M(e)},[v,M]),(0,u.A)({type:i.ImpressionTypes.POPOUT,name:i.ImpressionNames.SOUNDBOARD_POPOUT,properties:{source:E,guild_id:t,media_session_id:L}},{disableTrack:!w});let S=r.useCallback(e=>{O.current=e,b(e?.soundId)},[]),P=r.useCallback(e=>{if(null==e)return void S(null);let t=_[e];null!=t&&S(t)},[S,_]),R=r.useCallback(e=>{if(null==e)return;let t=_[e];null!=t&&M(t)},[_,M]),G=r.useMemo(()=>_.map(e=>(0,l.jsx)(j.Ay,{interactive:w,className:T.a,sound:e,focused:N===e.soundId,channel:n},e.soundId)),[N,n,w,_]);return 0===_.length?null:(0,l.jsx)(o.f5,{value:k,children:(0,l.jsx)(D,{wheelWidth:x,wheelHeight:p,itemWidth:96,itemHeight:52,showDeadZoneIndicator:!v,activeItem:N,onItemSelect:P,onItemAction:R,onClose:I,interactive:w,children:G})})}}