1 line
9.5 KiB
JavaScript
Vendored
1 line
9.5 KiB
JavaScript
Vendored
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5707],{75707:function(e,n,t){"use strict";t.r(n),t.d(n,{UserDropdown:function(){return UserDropdown}});var o=t(85893),r=t(82891),a=t(65400),i=t(94184),l=t.n(i),s=t(4480),u=t(67294),c=t(46977),d=t(5152),p=t.n(d),y=t(4511),f=t(42843),h=t(1931),b=t.n(h),v=t(86658);let m=p()(()=>t.e(8244).then(t.t.bind(t,18244,23)),{loadableGenerated:{webpack:()=>[18244]},ssr:!1}),k=p()(()=>t.e(775).then(t.t.bind(t,10775,23)),{loadableGenerated:{webpack:()=>[10775]},ssr:!1}),g=p()(()=>t.e(6275).then(t.t.bind(t,6275,23)),{loadableGenerated:{webpack:()=>[6275]},ssr:!1}),w=p()(()=>t.e(531).then(t.t.bind(t,40531,23)),{loadableGenerated:{webpack:()=>[40531]},ssr:!1}),C=p()(()=>t.e(4504).then(t.t.bind(t,4504,23)),{loadableGenerated:{webpack:()=>[4504]},ssr:!1}),E=p()(()=>t.e(5672).then(t.t.bind(t,65672,23)),{loadableGenerated:{webpack:()=>[65672]},ssr:!1}),K=p()(()=>t.e(5412).then(t.t.bind(t,95412,23)),{loadableGenerated:{webpack:()=>[95412]},ssr:!1}),L=p()(()=>Promise.all([t.e(1130),t.e(6697),t.e(3946)]).then(t.bind(t,33946)).then(e=>e.Modal),{loadableGenerated:{webpack:()=>[33946]},ssr:!1}),P=p()(()=>Promise.all([t.e(5596),t.e(1130),t.e(4104),t.e(1024),t.e(1749),t.e(7752),t.e(4749),t.e(7513)]).then(t.bind(t,45439)).then(e=>e.NameChangeModal),{loadableGenerated:{webpack:()=>[45439]},ssr:!1}),_=p()(()=>Promise.all([t.e(5596),t.e(1130),t.e(4104),t.e(1024),t.e(1700),t.e(3068),t.e(8469),t.e(489)]).then(t.bind(t,45167)).then(e=>e.AuthModal),{loadableGenerated:{webpack:()=>[45167]},ssr:!1}),UserDropdown=e=>{let{id:n,username:t,hideTitleOnMobile:i=!1,showToggleChatOption:d=!0}=e,[p,h]=(0,u.useState)(!1),[x,j]=(0,u.useState)(!1),[D,I]=(0,s.FV)(f.vZ),[A,G]=(0,u.useState)(null),O=(0,s.sJ)(f.Q),toggleChatVisibility=()=>{d&&I(D===f.gG.VISIBLE?f.gG.HIDDEN:f.gG.VISIBLE)},closeChangeNameModal=()=>{h(!1)},closeChatPopup=()=>{A&&A.close(),G(null),I(f.gG.VISIBLE)},S=d&&O.chatAvailable&&(D===f.gG.HIDDEN||D===f.gG.VISIBLE),H=d&&O.chatAvailable&&(D===f.gG.HIDDEN||D===f.gG.VISIBLE||D===f.gG.POPPED_OUT);(0,c.y1)("c",toggleChatVisibility,{enableOnContentEditable:!1},[D===f.gG.VISIBLE]);let N=(0,s.sJ)(f.db);if(!N)return null;let{displayName:T}=N,M=[{key:0,icon:(0,o.jsx)(k,{}),label:"Change name",onClick:()=>{h(!0)}},{key:1,icon:(0,o.jsx)(g,{}),label:"Authenticate",onClick:()=>j(!0)}];return S&&M.push({key:3,"aria-expanded":D===f.gG.VISIBLE,className:b().chatToggle,icon:(0,o.jsx)(E,{}),label:D===f.gG.VISIBLE?"Hide Chat":"Show Chat",onClick:toggleChatVisibility}),H&&M.push({key:4,icon:A?(0,o.jsx)(w,{}):(0,o.jsx)(C,{}),label:A?"Put chat back":"Pop out chat",onClick:A?closeChatPopup:()=>{closeChatPopup();let e=window.open("/embed/chat/readwrite","_blank","popup");e.addEventListener("beforeunload",closeChatPopup),G(e),I(f.gG.POPPED_OUT)}}),(0,o.jsx)(y.SV,{fallbackRender:e=>{let{error:n,resetErrorBoundary:t}=e;return(0,o.jsx)(v.A,{componentName:"UserDropdown",message:n.message,retryFunction:t})},children:(0,o.jsxs)("div",{className:b().root,children:[(0,o.jsx)(r.default,{menu:{items:M},trigger:["click"],children:(0,o.jsxs)(a.default,{id:n,type:"primary",icon:(0,o.jsx)(K,{className:b().userIcon}),children:[(0,o.jsx)("span",{className:l()([b().username,i&&b().hideTitleOnMobile]),children:t||T}),(0,o.jsx)(m,{})]})}),(0,o.jsx)(L,{title:"Change Chat Display Name",open:p,handleCancel:closeChangeNameModal,children:(0,o.jsx)(P,{closeModal:closeChangeNameModal})}),(0,o.jsx)(L,{title:"Authenticate",open:x,handleCancel:()=>j(!1),children:(0,o.jsx)(_,{})})]})})}},1931:function(e){e.exports={root:"UserDropdown_root__XCKtE","ant-space":"UserDropdown_ant-space__NT8a9","ant-space-item":"UserDropdown_ant-space-item__D6AUQ",username:"UserDropdown_username__1vJf_",hideTitleOnMobile:"UserDropdown_hideTitleOnMobile__Nd7fp",chatToggle:"UserDropdown_chatToggle__MEP4e"}},46977:function(e,n,t){"use strict";t.d(n,{y1:function(){return useHotkeys}});var o=t(67294);function _extends(){return(_extends=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}t(85893);var r=["shift","alt","meta","mod","ctrl"],a={esc:"escape",return:"enter",".":"period",",":"comma","-":"slash"," ":"space","`":"backquote","#":"backslash","+":"bracketright",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function mapKey(e){return(a[e]||e).trim().toLowerCase().replace(/key|digit|numpad|arrow/,"")}function parseKeysHookInput(e,n){return void 0===n&&(n=","),e.split(n)}function parseHotkey(e,n,t){void 0===n&&(n="+");var o=e.toLocaleLowerCase().split(n).map(function(e){return mapKey(e)}),a={alt:o.includes("alt"),ctrl:o.includes("ctrl")||o.includes("control"),shift:o.includes("shift"),meta:o.includes("meta"),mod:o.includes("mod")},i=o.filter(function(e){return!r.includes(e)});return _extends({},a,{keys:i,description:t})}"undefined"!=typeof document&&(document.addEventListener("keydown",function(e){void 0!==e.key&&pushToCurrentlyPressedKeys([mapKey(e.key),mapKey(e.code)])}),document.addEventListener("keyup",function(e){void 0!==e.key&&removeFromCurrentlyPressedKeys([mapKey(e.key),mapKey(e.code)])})),"undefined"!=typeof window&&window.addEventListener("blur",function(){i.clear()});var i=new Set;function isReadonlyArray(e){return Array.isArray(e)}function pushToCurrentlyPressedKeys(e){var n=Array.isArray(e)?e:[e];i.has("meta")&&i.forEach(function(e){return!r.includes(e)&&i.delete(e.toLowerCase())}),n.forEach(function(e){return i.add(e.toLowerCase())})}function removeFromCurrentlyPressedKeys(e){var n=Array.isArray(e)?e:[e];"meta"===e?i.clear():n.forEach(function(e){return i.delete(e.toLowerCase())})}function isHotkeyEnabledOnTag(e,n){var t=e.target;void 0===n&&(n=!1);var o=t&&t.tagName;return isReadonlyArray(n)?!!(o&&n&&n.some(function(e){return e.toLowerCase()===o.toLowerCase()})):!!(o&&n&&!0===n)}var isHotkeyMatchingKeyboardEvent=function(e,n,t){void 0===t&&(t=!1);var o,r=n.alt,a=n.meta,l=n.mod,s=n.shift,u=n.ctrl,c=n.keys,d=e.key,p=e.code,y=e.ctrlKey,f=e.metaKey,h=e.shiftKey,b=e.altKey,v=mapKey(p),m=d.toLowerCase();if(!t){if(!b===r&&"alt"!==m||!h===s&&"shift"!==m)return!1;if(l){if(!f&&!y)return!1}else if(!f===a&&"meta"!==m&&"os"!==m||!y===u&&"ctrl"!==m&&"control"!==m)return!1}return!!(c&&1===c.length&&(c.includes(m)||c.includes(v)))||(c?(void 0===o&&(o=","),(isReadonlyArray(c)?c:c.split(o)).every(function(e){return i.has(e.trim().toLowerCase())})):!c)},l=(0,o.createContext)(void 0),s=(0,o.createContext)({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),stopPropagation=function(e){e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},u="undefined"!=typeof window?o.useLayoutEffect:o.useEffect;function useHotkeys(e,n,t,r){var a,i=(0,o.useRef)(null),c=(0,o.useRef)(!1),d=t instanceof Array?r instanceof Array?void 0:r:t,p=isReadonlyArray(e)?e.join(null==d?void 0:d.splitKey):e,y=t instanceof Array?t:r instanceof Array?r:void 0,f=(0,o.useCallback)(n,null!=y?y:[]),h=(0,o.useRef)(f);y?h.current=f:h.current=n;var b=(!function deepEqual(e,n){return e&&n&&"object"==typeof e&&"object"==typeof n?Object.keys(e).length===Object.keys(n).length&&Object.keys(e).reduce(function(t,o){return t&&deepEqual(e[o],n[o])},!0):e===n}((a=(0,o.useRef)(void 0)).current,d)&&(a.current=d),a.current),v=(0,o.useContext)(s).enabledScopes,m=(0,o.useContext)(l);return u(function(){if((null==b?void 0:b.enabled)!==!1&&(e=null==b?void 0:b.scopes,0===v.length&&e?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):!!(!e||v.some(function(n){return e.includes(n)})||v.includes("*")))){var e,listener=function(e,n){var t;if(void 0===n&&(n=!1),!(isHotkeyEnabledOnTag(e,["input","textarea","select"])&&!isHotkeyEnabledOnTag(e,null==b?void 0:b.enableOnFormTags)||null!=b&&null!=b.ignoreEventWhen&&b.ignoreEventWhen(e))){if(null!==i.current&&document.activeElement!==i.current&&!i.current.contains(document.activeElement)){stopPropagation(e);return}(null==(t=e.target)||!t.isContentEditable||null!=b&&b.enableOnContentEditable)&&parseKeysHookInput(p,null==b?void 0:b.splitKey).forEach(function(t){var o,r,a,i=parseHotkey(t,null==b?void 0:b.combinationKey);if(isHotkeyMatchingKeyboardEvent(e,i,null==b?void 0:b.ignoreModifiers)||null!=(a=i.keys)&&a.includes("*")){if(n&&c.current)return;if(("function"==typeof(o=null==b?void 0:b.preventDefault)&&o(e,i)||!0===o)&&e.preventDefault(),"function"==typeof(r=null==b?void 0:b.enabled)?!r(e,i):!0!==r&&void 0!==r){stopPropagation(e);return}h.current(e,i),n||(c.current=!0)}})}},handleKeyDown=function(e){void 0!==e.key&&(pushToCurrentlyPressedKeys(mapKey(e.code)),((null==b?void 0:b.keydown)===void 0&&(null==b?void 0:b.keyup)!==!0||null!=b&&b.keydown)&&listener(e))},handleKeyUp=function(e){void 0!==e.key&&(removeFromCurrentlyPressedKeys(mapKey(e.code)),c.current=!1,null!=b&&b.keyup&&listener(e,!0))},n=i.current||(null==d?void 0:d.document)||document;return n.addEventListener("keyup",handleKeyUp),n.addEventListener("keydown",handleKeyDown),m&&parseKeysHookInput(p,null==b?void 0:b.splitKey).forEach(function(e){return m.addHotkey(parseHotkey(e,null==b?void 0:b.combinationKey,null==b?void 0:b.description))}),function(){n.removeEventListener("keyup",handleKeyUp),n.removeEventListener("keydown",handleKeyDown),m&&parseKeysHookInput(p,null==b?void 0:b.splitKey).forEach(function(e){return m.removeHotkey(parseHotkey(e,null==b?void 0:b.combinationKey,null==b?void 0:b.description))})}}},[p,b,v]),i}}}]); |