Module 671897

11,377 characters · in no known chunk
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>J}),n(321073);var i=n(627968),r=n(64700),a=n(503698),s=n.n(a),l=n(580929),o=n(621466),d=n(17928),c=n(661531),u=n(876230),_=n(106236),E=n(717421),A=n(358618),h=n(793920),I=n(983851),f=n(86147),p=n(729475),T=n(261958),m=n(32880),g=n(922016),S=n(980707),N=n(477782),C=n(365199),R=n(268791),O=n(315710),L=n(534514),D=n(775602),y=n(174459),v=n(61491),b=n(990078),M=n(113494),P=n(782134),U=n(417270),w=n(939249),G=n(834730),x=n(375708),k=n(332206);let F="-:--",V={[u.Q6.PLAYING]:{icon:M.E,label:x.intl.string(x.t.ZcgDJX)},[u.Q6.PAUSED]:{icon:P.u,label:x.intl.string(x.t.RscU7I)},[u.Q6.ENDED]:{icon:U.m,label:x.intl.string(x.t.hsvh0i)}},B={[u.oA.MD]:u.n4.MD,[u.oA.LG]:u.n4.LG},H={[u.n4.MD]:"md",[u.n4.LG]:"lg"};function j(e){let{videoRef:t,compact:n=!1}=e,[a,l]=r.useState(null),[o,d]=r.useState(null),[c,u]=r.useState(!1);r.useEffect(()=>{let e=t.current;function n(){null!=e&&(l(e.currentTime),d(e.duration))}if(null!=e)return e.addEventListener("timeupdate",n),e.addEventListener("loadedmetadata",n),e.addEventListener("durationchange",n),()=>{e.removeEventListener("timeupdate",n),e.removeEventListener("loadedmetadata",n),e.removeEventListener("durationchange",n)}},[t]);let _=Number.isFinite(a)&&Number.isFinite(o)?Math.max(0,o-a):null,E=c?null!=_?`-${(0,v.rB)(_)}`:F:Number.isFinite(a)?(0,v.rB)(a):F,A=Number.isFinite(o)?(0,v.rB)(o):F;return(0,i.jsxs)(w.D,{className:s()(k.d$,k.jk),"data-testid":"discord-web-video-player-duration",onClick:()=>u(e=>!e),children:[(0,i.jsx)(G.E,{variant:"text-sm/normal",className:k.Ue,tabularNumbers:!0,children:E}),!n&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(G.E,{variant:"text-sm/normal",className:k.zO,children:"/"}),(0,i.jsx)(G.E,{variant:"text-sm/normal",className:k.Ue,tabularNumbers:!0,children:A})]})]})}let W=r.forwardRef(function(e,t){let{iconComponent:n,animationTime:r,visible:a,ariaLabel:o,active:d,disabled:_,tooltipLabel:E,tooltipDelayMs:A=1500,shortcut:h,onClick:I,buttonSize:f=u.n4.MD,"data-testid":p,clickableProps:T}=e;return(0,i.jsx)(b.m,{text:a?E:void 0,keyboardShortcut:""!==(h??"").trim()?h:void 0,delay:A,children:(0,i.jsx)(w.D,{onClick:!0===_?void 0:I,className:s()(k.K5,{[k.Iy]:_}),"aria-label":o,"aria-disabled":_,"data-testid":p,innerRef:t,...T,children:(0,i.jsx)(l.animated.div,{className:k.K5,style:{opacity:(0,l.to)([r.to({range:[0,1],output:[0,1]})],e=>`${a?e:Math.pow(e,8)}`),height:{[u.n4.LG]:"32px",[u.n4.MD]:"24px"}[f]},children:(0,i.jsx)(n,{size:H[f],color:!0!==_?c.A.colors.WHITE:c.A.colors.TEXT_MUTED,className:s()(k.jk,{[k.x2]:d,[k.Wr]:!_})})})})})});var Y=n(91034),K=n(710434),$=n(634156),z=n(652215),q=n(639790);let Z=[.5,.75,1,1.25,1.5,1.75,2],X=Z[0],Q=Z[Z.length-1];function J(e){let{videoRef:t,playerState:n,animSpring:a,visible:g,seekForwardEnabled:S,hideCaptionBtn:N=!1,hideTranscriptBtn:C=!1,hideSkipButtons:R=!1,hideFullScreenBtn:O=!1,hidePlaybackSpeedBtn:L=!1,size:v,downloadUrl:b,downloadContentType:M,extraButtons:P,autoFocus:U=!1,keyDownHandlerRef:w,volume:G,muted:F,transcriptEnabled:H,captionEnabled:Z,fullScreenEnabled:X,handlePlaybackBtnClick:Q,handleTranscriptBtnClick:J,handleCaptionBtnClick:et,handleFullScreenBtnClick:ei,handleSeekBackBtnClick:er,handleSeekForwardBtnClick:ea,autoHideVolumeSlider:es=!1,compactTimeDisplay:el=!1,handleControlBarPendingInteraction:eo,onVolumeChange:ed,onMutedChange:ec,onVolumeExpandedChange:eu}=e,e_=(0,d.bG)([D.Ay],()=>D.Ay.useReducedMotion),eE=(0,d.bG)([D.Ay],()=>D.Ay.keyboardModeEnabled),[eA,eh]=r.useState(F?0:G),[eI,ef]=r.useState(!1),[ep,eT]=r.useState(!1),[{volumeAnimSpring:em},eg]=(0,E.z)(()=>({from:{volumeAnimSpring:0},config:{tension:100,friction:3,clamp:!0}})),eS=r.useRef(null),[eN,eC]=r.useState(1),eR=r.useCallback(e=>{eC(e),null!=t.current&&(t.current.playbackRate=e)},[t]),eO=r.useCallback(()=>{if(null==b)return;let e=M?.split("/");y.default.track(z.HAw.MEDIA_DOWNLOAD_BUTTON_TAPPED,{attachment_type:e?.[0],attachment_subtype:e?.[1]}),window.open(b,"_blank")},[b,M]),eL=r.useCallback(e=>{null!=t.current&&(e!==t.current.volume&&(t.current.volume=e),e!==eA&&eh(e))},[t,eA]),eD=r.useCallback(()=>{if(null!=t.current)if(0===eA){let e=0===G?.3:G;eL(e),ec(!1),ed(e)}else ed(eA),eL(0),ec(!0)},[t,eA,eL,G,ec,ed]);function ey(){ef(!0),eu(!0)}function ev(){ef(!1),eu(!1)}let eb=r.useCallback(e=>{if(!(e.metaKey||(0,o.vq)(e.target)&&(0,o.Cw)(e.target)))switch(e.key){case u.TJ.PLAYBACK:e.stopPropagation(),Q();break;case u.TJ.SPACE:e.stopPropagation(),eE||(e.preventDefault(),Q());break;case u.TJ.SEEK_BACK:case u.TJ.SEEK_BACK_ALT:e.stopPropagation(),er();break;case u.TJ.SEEK_FORWARD:case u.TJ.SEEK_FORWARD_ALT:e.stopPropagation(),ea();break;case u.TJ.CAPTION:e.stopPropagation(),N||et();break;case u.TJ.FULLSCREEN:e.stopPropagation(),O||ei();break;case u.TJ.MUTE:e.stopPropagation(),eD()}},[et,ei,Q,er,ea,eD,N,O,eE]);r.useEffect(()=>{U&&null!=eS.current&&eS.current.focus()},[U]),r.useEffect(()=>(null!=w&&(w.current=eb),()=>{null!=w&&(w.current=null)}),[eb,w]),r.useEffect(()=>(eg({volumeAnimSpring:!es||ep||eI?1:0,immediate:e_}),()=>{em.stop()}),[es,ep,eI,eg,e_,em]);let eM=0===eA?A._:eA<.5?h.S:I.H,{icon:eP,label:eU}=V[n];return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:k.X3,children:[(0,i.jsx)(W,{iconComponent:eP,animationTime:a,visible:g,ariaLabel:eU,tooltipLabel:eU,shortcut:u.TJ.PLAYBACK,onClick:Q,ref:eS,buttonSize:B[v],"data-testid":"discord-web-video-player-play-pause-btn"}),!R&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(W,{iconComponent:K.q,animationTime:a,visible:g,onClick:er,ariaLabel:x.intl.string(q.default["dRVF+Z"]),tooltipLabel:x.intl.string(q.default["dRVF+Z"]),shortcut:u.TJ.SEEK_BACK,buttonSize:B[v],"data-testid":"discord-web-video-player-seek-backward-btn"}),(0,i.jsx)(W,{iconComponent:$.i,animationTime:a,visible:g,onClick:ea,disabled:!S,ariaLabel:S?x.intl.string(q.default.yV2FLL):x.intl.string(q.default.YWbiPw),tooltipLabel:S?x.intl.string(q.default.yV2FLL):x.intl.string(q.default.YWbiPw),tooltipDelayMs:1500*!!S,shortcut:u.TJ.SEEK_FORWARD,buttonSize:B[v],"data-testid":"discord-web-video-player-seek-forward-btn"})]})]}),(0,i.jsxs)(l.animated.div,{className:s()(k.X3,k.L1),style:{opacity:(0,l.to)([a.to({range:[0,1],output:[0,1]})],e=>`${g?e:Math.pow(e,8)}`)},children:[(0,i.jsxs)("div",{onMouseEnter:ey,onMouseLeave:ev,onFocus:ey,onBlur:ev,className:k.RD,"data-testid":"discord-web-video-player-volume-control",children:[(0,i.jsx)(W,{iconComponent:eM,animationTime:a,visible:g,onClick:eD,ariaLabel:x.intl.string(q.default.XiLvuG),tooltipLabel:x.intl.string(q.default.XiLvuG),shortcut:u.TJ.MUTE,buttonSize:B[v],"data-testid":"discord-web-video-player-volume-btn"}),(0,i.jsx)(l.animated.div,{className:k.MQ,"data-testid":"discord-web-video-player-volume-slider",style:{opacity:(0,l.to)([em.to({range:[0,1],output:[0,1]})],e=>`${g?e:Math.pow(e,8)}`),width:(0,l.to)([em.to({range:[0,1],output:[0,100]})],e=>`${e}px`)},children:(0,i.jsx)(_.A,{mini:!0,value:eA,keyboardStep:.1,minValue:0,maxValue:1,onValueChange:function(e){eL(e),ed(e),ep&&(eT(!1),eo(!1)),F&&e>0?ec(!1):F||0!==e||ec(!0)},asValueChanges:function(e){eL(e),ep||(eT(!0),eo(!0))},fillStyles:{backgroundColor:c.A.colors.WHITE.css},orientation:"horizontal","aria-label":x.intl.string(q.default.XiLvuG),getAriaValueText:e=>x.intl.formatToPlainString(q.default["5L6uDs"],{percent:Math.round(100*e)})})})]}),(0,i.jsx)(j,{videoRef:t,compact:el})]}),(0,i.jsxs)("div",{className:s()(k.X3,k.ST),children:[(0,i.jsx)(ee,{canCollapse:null!=P&&P.length>0,buttons:function(e){let{hideTranscriptBtn:t=!1,hideCaptionBtn:n=!1,transcriptEnabled:i,captionEnabled:r,playerState:a,handleTranscriptBtnClick:s,handleCaptionBtnClick:l,downloadUrl:o,handleDownloadButtonClick:d,extraButtons:c}=e,_=[];return t||_.push({id:"transcript",iconComponent:T.u,label:x.intl.string(q.default["6EjGUv"]),onClick:s,active:i&&a!==u.Q6.ENDED,disabled:a===u.Q6.ENDED,"data-testid":"discord-web-video-player-transcript-btn"}),n||_.push({id:"caption",iconComponent:Y.I,label:x.intl.string(q.default["0DbPcL"]),onClick:l,active:r,shortcut:u.TJ.CAPTION,"data-testid":"discord-web-video-player-captions-btn"}),null!=o&&_.push({id:"download",iconComponent:m.s,label:x.intl.string(x.t["1WjMbC"]),onClick:d,"data-testid":"discord-web-video-player-download-btn"}),null!=c&&_.push(...c),_}({hideTranscriptBtn:C,hideCaptionBtn:N,transcriptEnabled:H,captionEnabled:Z,playerState:n,handleTranscriptBtnClick:J,handleCaptionBtnClick:et,downloadUrl:b,handleDownloadButtonClick:eO,extraButtons:P}),animSpring:a,visible:g,size:v}),!L&&(0,i.jsx)(en,{playbackRate:eN,onPlaybackRateChange:eR,animSpring:a,visible:g,size:v,handleControlBarPendingInteraction:eo}),!O&&(0,i.jsx)(W,{iconComponent:X?f.z:p.T,animationTime:a,visible:g,onClick:ei,ariaLabel:x.intl.string(q.default.z9Cnzv),tooltipLabel:x.intl.string(q.default.z9Cnzv),shortcut:u.TJ.FULLSCREEN,buttonSize:B[v],"data-testid":"discord-web-video-player-fullscreen-btn"})]})]})}function ee(e){let{buttons:t,canCollapse:n,animSpring:r,visible:a,size:s}=e;return 0===t.length?null:!n||t.length<=1?(0,i.jsx)(i.Fragment,{children:t.map(e=>(0,i.jsx)(W,{iconComponent:e.iconComponent,animationTime:r,visible:a,onClick:e.onClick,active:e.active,disabled:e.disabled,ariaLabel:e.label,tooltipLabel:e.label,tooltipDelayMs:e.tooltipDelayMs,shortcut:e.shortcut,buttonSize:B[s],"data-testid":e["data-testid"]},e.id))}):(0,i.jsx)(et,{buttons:t,animSpring:r,visible:a,size:s})}function et(e){let{buttons:t,animSpring:n,visible:a,size:s}=e,l=r.useRef(null),o=x.intl.string(x.t.PdRCRg);return(0,i.jsx)(g.Y,{targetElementRef:l,position:"top",align:"right",renderPopout:e=>{let{closePopout:n}=e;return(0,i.jsx)(S.W,{navId:"video-player-overflow","aria-label":o,onClose:n,onSelect:n,children:t.map(e=>{let t={type:"icon",icon:e.iconComponent};return null!=e.active?(0,i.jsx)(N.sL,{id:e.id,label:e.label,checked:e.active,disabled:e.disabled,leadingAccessory:t,action:e.onClick},e.id):(0,i.jsx)(N.Dr,{id:e.id,label:e.label,disabled:e.disabled,shortcut:e.shortcut,leadingAccessory:t,action:e.onClick},e.id)})})},children:e=>(0,i.jsx)(W,{ref:l,iconComponent:C.j,animationTime:n,visible:a,ariaLabel:o,tooltipLabel:o,buttonSize:B[s],clickableProps:e,"data-testid":"discord-web-video-player-overflow-menu-button"})})}function en(e){let{playbackRate:t,onPlaybackRateChange:n,animSpring:a,visible:s,size:l,handleControlBarPendingInteraction:o}=e,d=r.useRef(null),c=x.intl.string(q.default.ZwPhbB);return(0,i.jsx)(g.Y,{targetElementRef:d,position:"top",align:"right",onRequestOpen:()=>o(!0),onRequestClose:()=>{o(!1),d.current?.focus()},renderPopout:()=>(0,i.jsx)(ei,{playbackRate:t,onPlaybackRateChange:n,label:c}),children:e=>(0,i.jsx)(W,{ref:d,iconComponent:R.$,animationTime:a,visible:s,ariaLabel:c,tooltipLabel:c,buttonSize:B[l],clickableProps:{...e,"aria-haspopup":"dialog"},"data-testid":"discord-web-video-player-playback-speed-btn"})})}function ei(e){let{playbackRate:t,onPlaybackRateChange:n,label:a}=e,s=r.useRef(null);return(0,O.tj)(s),(0,i.jsxs)("div",{ref:s,className:k.qp,role:"dialog","aria-label":a,"data-testid":"discord-web-video-player-playback-speed-popout",children:[(0,i.jsx)(L.D,{variant:"heading-md/semibold",color:"text-default",className:k.xl,children:a}),(0,i.jsx)(_.A,{value:t,initialValue:1,minValue:X,maxValue:Q,markers:Z,stickToMarkers:!0,defaultValue:1,onValueChange:n,asValueChanges:n,onMarkerRender:e=>`${e}x`,orientation:"horizontal","aria-label":a,getAriaValueText:e=>`${e}x`})]})}}