import{r as t,j as s,h as W,f as Q}from"./index-2SI3TtYZ.js";import{a as S,r as m,I as $,m as c,V as q,aA as z,Z as J,G as K}from"./LoginPage-yYkKaUvX.js";import{S as X,a as Y,b as A,E as e1}from"./discord_desktop-9WkRDieH.js";import{h as s1,i as t1,j as w,k as n1,l as a1}from"./arrowLeftAdornment-jpxA6Zr3.js";import{S as r1,a as i1,b as l1,P as d1,o as o1}from"./busHandlers-qQRaWD8D.js";import{a as c1,V as C1,S as u1}from"./share-P1KryU6L.js";import{e as m1,b as f1}from"./moreIcon-hyogBtJh.js";import"./Popup-prQjvaC2.js";import"./share_icon_red-7uXoZm4i.js";const h1=e=>t.createElement("svg",{width:56,height:56,viewBox:"0 0 56 56",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("path",{opacity:.5,fillRule:"evenodd",clipRule:"evenodd",d:"M28 56C43.464 56 56 43.464 56 28C56 12.536 43.464 0 28 0C12.536 0 0 12.536 0 28C0 43.464 12.536 56 28 56ZM36.6132 26.203C36.022 24.8916 34.2603 23.8871 30.7368 21.8781C27.2134 19.8691 25.4517 18.8646 24.0061 19.0147C22.7451 19.1456 21.5996 19.7987 20.8544 20.8117C20 21.973 20 23.982 20 28C20 32.018 20 34.027 20.8544 35.1883C21.5996 36.2013 22.7451 36.8545 24.0061 36.9853C25.4517 37.1354 27.2134 36.1309 30.7368 34.1219C34.2603 32.1129 36.022 31.1084 36.6132 29.797C37.1289 28.6531 37.1289 27.3469 36.6132 26.203Z",fill:"white"})),g1=e=>t.createElement("svg",{width:127,height:23,viewBox:"0 0 127 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M62.5118 16.2737C62.5118 19.7923 66.0767 22.655 70.4584 22.655C74.8401 22.655 78.4051 19.7923 78.4051 16.2737V12.2647C78.4051 10.9565 77.3155 9.89238 75.9759 9.89238H70.4584C69.5806 9.89238 68.8691 10.5873 68.8691 11.4446C68.8691 12.3019 69.5806 12.9968 70.4584 12.9968H75.2264V16.2737C75.2264 18.0499 73.0428 19.5506 70.4584 19.5506C67.874 19.5506 65.6904 18.0499 65.6904 16.2737V6.96042C65.6904 5.4451 67.7733 3.68353 70.4584 3.68353C73.1435 3.68353 75.2264 5.4451 75.2264 6.96042V7.6503C75.2264 8.50758 75.9379 9.20251 76.8157 9.20251C77.6935 9.20251 78.4051 8.50758 78.4051 7.6503V6.96042C78.4051 3.50146 74.766 0.579102 70.4584 0.579102C66.1509 0.579102 62.5118 3.50146 62.5118 6.96042V16.2737ZM50.9307 22.6551H44.6772C43.7994 22.6551 43.0878 21.9601 43.0878 21.1028C43.0878 20.8637 43.1434 20.637 43.2424 20.4347C43.0351 20.5314 42.8029 20.5854 42.5581 20.5854C41.6803 20.5854 40.9687 19.8905 40.9687 19.0332V2.95142C40.9687 1.64325 42.0583 0.579138 43.3979 0.579138H51.0345C54.7739 0.579138 57.5684 4.6766 57.5684 8.34021V15.2389C57.5684 18.7964 55.1309 21.7506 51.5032 22.5904C51.3159 22.6333 51.1241 22.6551 50.9307 22.6551ZM44.1474 3.68356V19.0332C44.1474 19.2724 44.0919 19.4991 43.9929 19.7014C44.2002 19.6047 44.4323 19.5506 44.6772 19.5506H50.8493C53.0022 19.0203 54.3897 17.3357 54.3897 15.2389V8.34021C54.3897 6.12069 52.6338 3.68356 51.0345 3.68356H44.1474ZM22.0867 10.4266C21.5567 10.1749 21.1915 9.64406 21.1915 9.02983V3.29611C21.1915 1.98794 22.281 0.923828 23.6207 0.923828H35.1422C36.02 0.923828 36.7316 1.61875 36.7316 2.47604C36.7316 3.33333 36.02 4.02825 35.1422 4.02825H24.3701V9.02983C24.3701 9.3491 24.2714 9.64585 24.1022 9.89258H35.1422C36.02 9.89258 36.7316 10.5875 36.7316 11.4448C36.7316 12.3021 36.02 12.997 35.1422 12.997H24.3701V19.5508H35.1422C36.02 19.5508 36.7316 20.2457 36.7316 21.103C36.7316 21.9603 36.02 22.6552 35.1422 22.6552H23.6207C22.281 22.6552 21.1915 21.5911 21.1915 20.2829V12.2649C21.1915 11.5243 21.5407 10.862 22.0867 10.4266ZM15.0117 22.6551C14.4864 22.6551 13.9725 22.401 13.6693 21.9361L9.19347 15.0664H5.60782C4.26821 15.0664 3.17865 14.0023 3.17865 12.6941V21.1028C3.17865 21.96 2.46711 22.655 1.58933 22.655C0.711541 22.655 0 21.96 0 21.1028V3.29626C0 1.9881 1.08956 0.923983 2.42917 0.923983H10.7721C13.6089 0.923983 15.8933 4.0375 15.8933 6.61543C15.8933 9.01685 13.9901 11.8328 11.3826 12.7168C11.4826 12.8219 11.5733 12.9366 11.654 13.0602L16.3513 20.2694C16.8224 20.9926 16.6041 21.9521 15.8636 22.4123C15.5991 22.5766 15.3038 22.6551 15.0117 22.6551ZM3.17865 4.02841V12.2646C3.17865 10.9564 4.26821 9.89232 5.60782 9.89232H9.71255C11.2605 9.89232 12.7146 7.84814 12.7146 6.61543C12.7146 5.59393 11.6726 4.02841 10.7721 4.02841H3.17865ZM85.2925 22.655C84.4147 22.655 83.7032 21.9601 83.7032 21.1028V2.13132C83.7032 1.27403 84.4147 0.579102 85.2925 0.579102C86.1703 0.579102 86.8818 1.27403 86.8818 2.13132V21.1028C86.8818 21.9601 86.1703 22.655 85.2925 22.655ZM91.4727 9.03004C91.4727 9.6442 91.8379 10.175 92.3678 10.4267C91.8218 10.8621 91.4727 11.5244 91.4727 12.2649V21.4479C91.4727 22.3052 92.1843 23.0002 93.062 23.0002C93.9398 23.0002 94.6514 22.3052 94.6514 21.4479V12.997H105.07C105.948 12.997 106.66 12.3021 106.66 11.4448C106.66 10.5875 105.948 9.89258 105.07 9.89258H94.3836C94.5527 9.6459 94.6514 9.34922 94.6514 9.03004V3.68353H105.07C105.948 3.68353 106.66 2.9886 106.66 2.13131C106.66 1.27403 105.948 0.579102 105.07 0.579102H93.9019C92.5623 0.579102 91.4727 1.64322 91.4727 2.95138V9.03004ZM111.774 18.6926C113.215 21.507 115.366 22.655 119.199 22.655C122.682 22.655 126.44 20.3471 126.44 16.6186C126.44 12.727 122.812 11.242 120.411 10.2594L120.411 10.2594C120.213 10.1782 120.017 10.098 119.825 10.0179C119.613 9.92898 119.396 9.84025 119.176 9.75031L119.153 9.74097C116.728 8.75045 115.138 7.99776 115.138 6.61549V5.58068C115.138 4.49905 116.884 3.68353 119.199 3.68353C121.365 3.68353 122.555 4.59033 122.555 4.89081C122.555 5.74809 123.266 6.44302 124.144 6.44302C125.022 6.44302 125.733 5.74809 125.733 4.89081C125.733 2.4328 122.924 0.579102 119.199 0.579102C114.936 0.579102 111.959 2.63575 111.959 5.58068V6.61549C111.959 10.1678 115.408 11.5764 117.927 12.605L117.927 12.6051L117.934 12.6079C118.15 12.6964 118.365 12.7839 118.573 12.8713C118.758 12.9485 118.946 13.0256 119.136 13.1035L119.182 13.1225C121.72 14.1611 123.261 14.9148 123.261 16.6186C123.261 18.3725 121.161 19.5506 119.199 19.5506C116.013 19.5506 115.29 18.6195 114.617 17.3041C114.224 16.5378 113.271 16.2264 112.484 16.6101C111.699 16.9934 111.381 17.9258 111.774 18.6926Z",fill:"url(#paint0_linear_3865_190369)"}),t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M42.2031 2.95121C42.2031 2.30776 42.7372 1.78613 43.3961 1.78613H51.0327C52.5533 1.78613 53.8829 2.71456 54.815 3.95944C55.7499 5.20811 56.3305 6.83065 56.3305 8.33992V15.2386C56.3305 18.0319 54.4969 20.656 51.2162 21.4153C51.1204 21.4375 51.0231 21.4475 50.929 21.4475H44.6754V20.7576H50.929C50.9726 20.7576 51.015 20.7529 51.0533 20.744C54.0014 20.0617 55.6241 17.7264 55.6241 15.2386V8.33992C55.6241 6.98932 55.0989 5.50744 54.2448 4.36665C53.3878 3.22206 52.2451 2.47601 51.0327 2.47601H43.3961C43.1273 2.47601 42.9095 2.68876 42.9095 2.95121V19.0329H42.2031V2.95121ZM22.4258 3.29594C22.4258 2.65248 22.9599 2.13086 23.6187 2.13086H35.1404V2.82073H23.6187C23.35 2.82073 23.1321 3.03349 23.1321 3.29594V9.02958H22.4258V3.29594ZM1.23438 3.29605C1.23438 2.6526 1.76847 2.13098 2.42731 2.13098H10.7703C11.8998 2.13098 12.875 2.82518 13.5493 3.68976C14.2254 4.55669 14.6553 5.66309 14.6553 6.61515C14.6553 7.75252 14.0802 9.03684 13.2009 10.0313C12.3205 11.0268 11.0831 11.7892 9.71078 11.7892H5.60596C5.33724 11.7892 5.11939 12.0019 5.11939 12.2644V12.6937C5.11939 12.9562 5.33724 13.1689 5.60596 13.1689H9.60299C10.0108 13.1689 10.3904 13.3724 10.6094 13.7085L15.3065 20.9173L14.7106 21.2877L10.0135 14.0789C9.92417 13.9418 9.76934 13.8588 9.60299 13.8588H5.60596C4.94712 13.8588 4.41303 13.3372 4.41303 12.6937V12.2644C4.41303 11.6209 4.94712 11.0993 5.60596 11.0993H9.71078C10.8108 11.0993 11.869 10.4819 12.6663 9.58035C13.4645 8.67763 13.949 7.54739 13.949 6.61515C13.949 5.84252 13.5891 4.87931 12.9874 4.10779C12.3838 3.33393 11.593 2.82085 10.7703 2.82085H2.42731C2.15858 2.82085 1.94074 3.03361 1.94074 3.29605V21.1025H1.23438V3.29605ZM23.1321 12.2647C23.1321 12.0022 23.35 11.7895 23.6187 11.7895H35.1404V11.0996H23.6187C22.9599 11.0996 22.4258 11.6212 22.4258 12.2647V20.2826C22.4258 20.9261 22.9599 21.4477 23.6187 21.4477H35.1404V20.7578H23.6187C23.35 20.7578 23.1321 20.5451 23.1321 20.2826V12.2647ZM70.4566 1.78613C68.6203 1.78613 66.953 2.39992 65.7398 3.34668C64.5299 4.29075 63.7461 5.58916 63.7461 6.96018V16.2735C63.7461 19.2088 66.8354 21.4475 70.4566 21.4475C74.0778 21.4475 77.1671 19.2088 77.1671 16.2735V12.2645C77.1671 11.621 76.633 11.0994 75.9741 11.0994H70.4566V11.7893H75.9741C76.2429 11.7893 76.4607 12.002 76.4607 12.2645V16.2735C76.4607 18.6765 73.8632 20.7576 70.4566 20.7576C67.05 20.7576 64.4525 18.6765 64.4525 16.2735V6.96018C64.4525 5.85264 65.0903 4.7365 66.1807 3.88565C67.2676 3.0375 68.779 2.47601 70.4566 2.47601C72.1342 2.47601 73.6456 3.0375 74.7325 3.88565C75.8229 4.7365 76.4607 5.85264 76.4607 6.96018V7.65005H77.1671V6.96018C77.1671 5.58916 76.3832 4.29075 75.1734 3.34668C73.9601 2.39992 72.2929 1.78613 70.4566 1.78613ZM84.9375 21.1024V2.13086H85.6439V21.1024H84.9375ZM93.4134 2.95121C93.4134 2.68876 93.6312 2.47601 93.9 2.47601H105.068V1.78613H93.9C93.2411 1.78613 92.707 2.30776 92.707 2.95121V9.02979H93.4134V2.95121ZM92.707 12.2647C92.707 11.6212 93.2411 11.0996 93.9 11.0996H105.068V11.7895H93.9C93.6312 11.7895 93.4134 12.0022 93.4134 12.2647V21.4477H92.707V12.2647ZM113.901 5.58043C113.901 4.69158 114.396 3.929 115.315 3.37289C116.241 2.81245 117.584 2.47601 119.199 2.47601C120.515 2.47601 121.689 2.77401 122.521 3.23833C123.363 3.70814 123.79 4.30495 123.79 4.89056H124.497C124.497 3.9509 123.819 3.16797 122.871 2.63935C121.914 2.10524 120.615 1.78613 119.199 1.78613C117.495 1.78613 116.012 2.13956 114.943 2.7864C113.867 3.43756 113.195 4.39966 113.195 5.58043V6.61523C113.195 8.15357 114.092 9.19438 115.248 9.96179C116.192 10.5887 117.355 11.0634 118.415 11.4959L118.415 11.496C118.635 11.586 118.851 11.6741 119.06 11.7614C119.261 11.8456 119.465 11.929 119.669 12.0128C120.748 12.4546 121.852 12.9069 122.745 13.5352C123.787 14.2675 124.497 15.2088 124.497 16.6184C124.497 17.8665 123.84 18.8926 122.839 19.6183C121.833 20.3473 120.495 20.7576 119.199 20.7576C117.473 20.7576 116.306 20.5026 115.451 20.0268C114.603 19.5547 114.022 18.8426 113.511 17.8439L112.879 18.1524C113.427 19.2233 114.091 20.0634 115.102 20.6261C116.106 21.1851 117.411 21.4475 119.199 21.4475C120.636 21.4475 122.124 20.9955 123.26 20.1723C124.4 19.3458 125.203 18.1298 125.203 16.6184C125.203 14.9235 124.324 13.7952 123.158 12.9753C122.193 12.2966 121 11.8087 119.923 11.3684L119.923 11.3683C119.723 11.2866 119.528 11.2066 119.338 11.1273C119.116 11.0343 118.891 10.9423 118.664 10.8498L118.664 10.8496C117.605 10.4169 116.524 9.97504 115.645 9.39131C114.593 8.69274 113.901 7.83627 113.901 6.61511V5.58043Z",fill:"white"}),t.createElement("defs",null,t.createElement("linearGradient",{id:"paint0_linear_3865_190369",x1:123.967,y1:14.5491,x2:972134e-12,y2:14.5492,gradientUnits:"userSpaceOnUse"},t.createElement("stop",{stopColor:"#8C18F1"}),t.createElement("stop",{offset:1,stopColor:"#E5194D"})))),S1=e=>{const a=r=>()=>{e.onClick(r)},C=()=>{e.onClose()};return s.jsxs("div",{className:S({popupMenu:!0,[e.className??""]:!0}),children:[s.jsx("div",{className:"backdrop",onClick:C}),s.jsxs("div",{className:"canvas",children:[s.jsx("div",{className:"grip"}),e.groups.map((r,u)=>s.jsxs("div",{className:S({group:!0,[r.className??""]:!0}),children:[r.text&&s.jsx("div",{className:"groupName",children:r.text}),s.jsx("div",{className:"items",children:r.items.map((d,o)=>s.jsxs("div",{className:S({item:!0,[d.className??""]:!0}),onClick:a(d),children:[d.icon,s.jsx("span",{className:"label",children:d.label})]},o))})]},u)),s.jsx("div",{className:"items"})]})]})},x1=e=>t.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("path",{d:"M5.73324 12.0837C6.14745 12.0837 6.48324 11.7479 6.48324 11.3337C6.48324 10.9194 6.14745 10.5837 5.73324 10.5837V12.0837ZM11.0666 10.5837C10.6524 10.5837 10.3166 10.9194 10.3166 11.3337C10.3166 11.7479 10.6524 12.0837 11.0666 12.0837V10.5837ZM11.0666 3.91699C10.6524 3.91699 10.3166 4.25278 10.3166 4.66699C10.3166 5.08121 10.6524 5.41699 11.0666 5.41699V3.91699ZM5.73324 5.41699C6.14745 5.41699 6.48324 5.08121 6.48324 4.66699C6.48324 4.25278 6.14745 3.91699 5.73324 3.91699V5.41699ZM5.73324 7.25033C5.31902 7.25033 4.98324 7.58611 4.98324 8.00033C4.98324 8.41454 5.31902 8.75033 5.73324 8.75033V7.25033ZM11.0666 8.75033C11.4808 8.75033 11.8166 8.41454 11.8166 8.00033C11.8166 7.58611 11.4808 7.25033 11.0666 7.25033V8.75033ZM5.73324 10.5837C4.3065 10.5837 3.1499 9.42706 3.1499 8.00033H1.6499C1.6499 10.2555 3.47807 12.0837 5.73324 12.0837V10.5837ZM13.6499 8.00033C13.6499 9.42706 12.4933 10.5837 11.0666 10.5837V12.0837C13.3217 12.0837 15.1499 10.2555 15.1499 8.00033H13.6499ZM11.0666 5.41699C12.4933 5.41699 13.6499 6.57359 13.6499 8.00033H15.1499C15.1499 5.74516 13.3217 3.91699 11.0666 3.91699V5.41699ZM5.73324 3.91699C3.47807 3.91699 1.6499 5.74516 1.6499 8.00033H3.1499C3.1499 6.57359 4.3065 5.41699 5.73324 5.41699V3.91699ZM5.73324 8.75033H11.0666V7.25033H5.73324V8.75033Z",fill:"currentColor"})),V1=e=>t.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("path",{d:"M5.99992 11.3337L4.82461 10.1688C3.88732 9.23982 3.41867 8.77534 3.34651 8.20921C3.32883 8.07051 3.32883 7.93014 3.34651 7.79144C3.41867 7.22531 3.88732 6.76083 4.82461 5.83186L5.99992 4.66699",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"}),t.createElement("path",{d:"M9.99984 4.66732L11.1751 5.83219C12.1124 6.76115 12.5811 7.22563 12.6532 7.79176C12.6709 7.93047 12.6709 8.07083 12.6532 8.20954C12.5811 8.77567 12.1124 9.24015 11.1752 10.1691L9.99984 11.334",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"})),v1=[{text:void 0,items:[{icon:s.jsx(x1,{className:"link"}),label:"Copy link",id:"link"},{icon:s.jsx(V1,{className:"embed"}),label:"Embed",id:"embed"}]},{text:"Social share:",items:[{icon:s.jsx(X,{}),label:"Reddit",className:"reddit",id:"reddit"},{icon:s.jsx(Y,{}),label:"Twitter",className:"twitter",id:"twitter"},{icon:s.jsx(A,{}),label:"Discord",className:"discord",id:"discord"}]}],b1=e=>s.jsx(S1,{className:"shareGifMenu",onClick:e.onClick,onClose:e.onClose,groups:v1}),j1=e=>{if(!e.name)return s.jsx(s.Fragment,{});const a=`${m.watch(e.gifId)}?from=embed`;return s.jsxs("div",{className:"userInfo",children:[s.jsx("a",{href:m.user(e.name),title:"Open user profile page",target:"_blank",rel:"noreferrer",children:s.jsx($,{className:"userpic",src:e.userpic})}),s.jsxs("div",{className:"text",children:[s.jsx("div",{className:"date",children:s.jsx("a",{href:a,target:"_blank",title:"Open gif page",rel:"noreferrer",children:c1(e.createDate)})}),s.jsxs("div",{className:"author",children:[s.jsx("a",{href:m.user(e.name),target:"_blank",title:"Open user profile page",rel:"noreferrer",children:e.name}),e.verified&&s.jsx(C1,{hint:"Video from a verified user"})]})]})]})},k1=e=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("path",{d:"M22 15.6364L19.2727 15.6364C17.2644 15.6364 15.6364 17.2644 15.6364 19.2727L15.6364 22",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M2 8.36364L4.72727 8.36364C6.73555 8.36364 8.36364 6.73558 8.36364 4.72727L8.36364 2",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M8.36364 22L8.36364 19.2727C8.36364 17.2644 6.73558 15.6364 4.72727 15.6364L2 15.6364",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M15.6364 2L15.6364 4.72727C15.6364 6.73555 17.2644 8.36364 19.2727 8.36364L22 8.36364",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}));var l=(e=>(e[e.Share=0]="Share",e[e.Mute=1]="Mute",e[e.UnMute=2]="UnMute",e[e.FullScreen=3]="FullScreen",e[e.ExitFullScreen=4]="ExitFullScreen",e[e.HD=5]="HD",e[e.SD=6]="SD",e))(l||{});const H1=e=>{const a=C=>()=>{e.onClick(C)};return s.jsxs("div",{className:"buttons",children:[e.hasSound&&e.muted&&s.jsxs("div",{className:"button",children:[s.jsx(W,{className:"soundOff",onClick:a(l.UnMute)}),s.jsx("span",{children:"Off"})]}),e.hasSound&&!e.muted&&s.jsxs("div",{className:"button",children:[s.jsx(Q,{className:"soundOn",onClick:a(l.Mute)}),s.jsx("span",{children:"On"})]}),e.haveFullScreen&&s.jsxs("div",{className:"button",children:[e.fullScreen&&s.jsx(k1,{className:"exitFullScreen",onClick:a(l.FullScreen)}),!e.fullScreen&&s.jsx(r1,{className:"fullScreen",onClick:a(l.FullScreen)})]}),e.hd&&s.jsx("div",{onClick:a(l.SD),className:"button",children:s.jsx(i1,{className:"gifQuality"})}),!e.hd&&s.jsx("div",{onClick:a(l.HD),className:"button",children:s.jsx(l1,{className:"gifQuality"})}),s.jsx("div",{className:"button",id:"shareButton",children:s.jsx(u1,{onClick:a(l.Share)})})]})},x=1e3,w1=e=>{const{isFullScreen:a}=m1(n=>n.application),[C,r]=t.useState(!0),[u,d]=t.useState(!0),[o,V]=t.useState(!0),[M,f]=t.useState(!1),[N,v]=t.useState(!1),[L,b]=t.useState(0),[E,Z]=t.useState(0),i=t.useRef(null),y=t.useRef(null),j=t.useRef(0),h=t.useRef(0),D=n=>{Number.isFinite(n)&&i.current&&(i.current.currentTime=n/x),b(n)},P=()=>{},p=()=>{i.current&&Z(i.current.duration*x)},R=()=>{i.current&&b(i.current.currentTime*x)},k=()=>{if(i.current)if(i.current.paused){const n=i.current.play();n!==void 0?n.then(()=>{r(!0)}).catch(g=>{console.warn("failed to play video",g)}):r(!0)}else i.current.pause(),r(!1)},H=()=>{i.current&&i.current.load()},F=n=>{n===l.Mute?(d(!0),console.debug("Sound disabled.")):n===l.UnMute?(d(!1),console.debug("Sound enabled.")):n===l.FullScreen?o1({id:e.id}):n===l.HD?(V(!0),console.debug("Switch to HD."),H()):n===l.SD?(V(!1),console.debug("Switch to SD."),H()):n===l.Share?(f(!0),i.current&&i.current.pause(),r(!1),c.sendShareClick(),console.debug("Open share dialog.")):console.debug(`Unhandled action: ${n}`)},I=n=>{f(!1),n.id==="link"?(console.debug("Copy gif link."),w(e.gif),c.sendShareCopy()):n.id==="discord"?(console.debug("Copy gif link."),w(e.gif),c.sendShareDiscord()):n.id==="embed"?(console.debug("Embed link."),v(!0),c.sendShareEmbed()):n.id==="reddit"?(console.debug("Send to Reddit."),n1(e.gif),c.sendShareReddit()):n.id==="twitter"?(console.debug("Send to Twitter."),a1(e.id),c.sendShareTwitter()):console.debug("Share menu item clicked.",n)},T=()=>{console.debug("Closing the share menu."),f(!1)},U=()=>{v(!1)},O=t.useCallback(async()=>{const n=await c.getUserName();await c.sendGifView({gifId:e.id,tags:[],source:q.Embed,position:1,boosted:!!e.gif.cta,userName:n})},[e.id,e.gif]),G=()=>{O()},_=t.useCallback(()=>{j.current=performance.now()},[]),B=t.useCallback(()=>{if(h.current===0){h.current=performance.now();const n=Math.ceil(h.current-j.current),g=o?e.hdVideo:e.sdVideo;console.debug("loaded time(ms):",n,new URL(g??"").pathname,"isHls:",!1),f1.sendVideoLoaded({duration:n,isHLS:!1})}},[o,e.hdVideo,e.sdVideo]);return s.jsxs("div",{className:"embeddedPlayer",ref:y,children:[s.jsx("a",{href:m.watch(e.id),target:"_blank",rel:"noreferrer",className:"videoLink",children:s.jsx("video",{ref:i,controls:!1,autoPlay:!0,loop:!0,playsInline:!0,poster:e.poster,muted:u,onLoadedMetadata:p,disablePictureInPicture:!0,onClick:k,onTimeUpdate:R,onPlay:G,onLoadStart:_,onCanPlay:B,src:o?e.hdVideo:e.sdVideo})}),s.jsx("a",{href:"https://www.redgifs.com/",target:"_blank",title:"Open RedGIFs home page",className:"logo",rel:"noreferrer",children:s.jsx(g1,{})}),s.jsx(j1,{gifId:e.id,createDate:e.createDate,name:e.userName,userpic:e.userPic,verified:e.verified}),s.jsx(H1,{hasSound:e.sound,muted:u,hd:o,haveFullScreen:z.fullscreenEnabled,fullScreen:a,onClick:F}),!C&&s.jsx(h1,{className:"playIcon",onClick:k}),M&&s.jsx(b1,{onClick:I,onClose:T}),s.jsx(e1,{isOpen:N,fixedEmbedCode:s1(e.gif),responsiveEmbedCode:t1(e.gif),onClose:U}),s.jsx("div",{className:"ProgressBar",children:s.jsx(d1,{max:E,currentTime:L,onChange:D,onChangeEnd:P,fullScreen:a})})]})},M1=e=>{var u,d,o;const[a,C]=t.useState(void 0),r=J(e.id);return t.useEffect(()=>{r.isSuccess&&r.data&&C(r.data)},[r.isSuccess,r.data]),a?s.jsx(w1,{gif:a.gif,id:a.gif.id,createDate:a.gif.createDate,userName:(u=a.user)==null?void 0:u.username,userPic:(d=a.user)==null?void 0:d.profileImageUrl,sdVideo:a.gif.urls.sd,hdVideo:a.gif.urls.hd,poster:a.gif.urls.thumbnail,sound:!!a.gif.hasAudio,verified:!!((o=a.user)!=null&&o.verified)}):r.isLoading?s.jsx("div",{className:"embedPage",children:s.jsx("p",{className:"message",children:"Loading..."})}):r.isError?s.jsx("div",{className:"embedPage",children:s.jsx("p",{className:"error message",children:"Error loading this gif."})}):s.jsx(s.Fragment,{})},F1=()=>{const{id:e}=K();return e?s.jsx(M1,{id:e}):s.jsx("div",{className:"embedPage",children:s.jsx("p",{className:"error message",children:"Gif id not specified."})})};export{F1 as EmbedPage,F1 as default}; //# sourceMappingURL=EmbedPage-UMhTpcCe.js.map