Build 576754stable
Module 464651
8,586 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Ff:()=>m,JZ:()=>S,Fk:()=>T,FV:()=>p,oV:()=>f,se:()=>g}),n(321073);var i=n(64700),r=n(735438),a=n.n(r),s=n(741918),l=n(788413),o=n(602034);let d=[s.D$.TAB];function c(e,t,n){return null!=t&&null!=n?`#${(0,o.Aq)(e,t,n)}`:`[data-ref-id=${e}]`}function u(e){return document.querySelector(e)}var _=n(23339),E=n(319060),A=n(60587),h=n(652215);let I=(0,_.xI)(E.A.EMOJI_PICKER_CONSTANTS_EMOJI_LIST_PADDING_LEFT),f=e=>{let{gridWrapperRef:t,containerWidth:n,showingEmptyState:r,listPaddingLeft:s=I,listScrollbarWidth:l=8}=e,[o,d]=i.useState(void 0),c=i.useCallback(()=>{if(null==t.current)return null;d(t.current.offsetWidth-s-l)},[t,s,l]);return i.useLayoutEffect(()=>{c()},[n,c,r]),i.useEffect(()=>{let e=a().debounce(c,250);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[c]),o};function p(e){let{activeCategoryIndex:t,listRef:n,searchQuery:r}=e,a=i.useRef(r),s=i.useRef(!0);i.useLayoutEffect(()=>{""===r&&""!==a.current&&n.current?.scrollToSectionTop(t),a.current=r},[r,t,n]),i.useLayoutEffect(()=>{s.current&&(n.current?.scrollToSectionTop(t),s.current=!1)},[t,n]),i.useEffect(()=>{a.current=r},[r])}let T=e=>{let{activeCategoryIndex:t,listRef:n,isScrolling:r,searchQuery:s,scrollOffset:l=0,onActiveCategoryIndexChange:o,disableForSearch:d=!0}=e,c=i.useRef(h.An1),u=i.useRef(t);u.current=t;let _=i.useMemo(()=>a().debounce(()=>{r.current=!1},250),[r]),E=i.useMemo(()=>a().debounce(e=>{""!==s&&d||(window.cancelAnimationFrame(c.current),c.current=window.requestAnimationFrame(()=>{let t=n.current?.getSectionDescriptors();if(null==t)return;let i=t.findIndex((n,i)=>{let r=t[i+1],a=e+l>=n.offset.top,s=null!=r&&e+l<r.offset.top;return null!=r&&!a&&!s||a&&s||a&&null==r}),r=-1===i?0:i;u.current!==r&&o(r)}))},0),[s,n,l,o,d]);return i.useCallback(e=>{r.current=!0,_(),E(e)},[r,_,E])};function m(e){let{columnCounts:t,gridNavigatorId:n,itemGrid:r,itemList:a,onGridNavigatorItemSelect:_,onGridNavigatorPositionChange:E}=e,A=i.useRef(!1),h=i.useCallback((e,t)=>{let n=r[t];if(null!=n)return n[e]},[r]),I=i.useCallback(e=>{let{focusedX:t,focusedY:n}=e;A.current=!0;let i=h(t,n);if(null==i)return;let{visibleRowIndex:r,columnIndex:s}=i;E(s,r),null!=a.current&&a.current.scrollRowIntoView(n)},[h,a,E]),{dispatch:f,getItemProps:p,getRowProps:T,getContainerProps:m}=function(e){let{navId:t,columnCounts:n,focusedX:r=0,focusedY:a=0,onSelect:_,prepareFocus:E,getNewFocusPosition:A,maintainFocusPosition:h=!0,enabled:I=!0,onDispatch:f,autoFocusElement:p=!0,useVirtualFocus:T=!1}=e,m=i.useCallback((e,t)=>{let n=(0,l.A)(e,t);return null!=f&&f(e,n,t),n},[f]),[g,S]=i.useReducer(m,{focusedX:r,focusedY:a,columnCounts:n}),{columnCounts:N,focusedX:C,focusedY:R}=g,[O]=i.useState(()=>(0,o.nF)(S,16));return i.useEffect(()=>{S({type:l.n.UPDATE_COLUMN_COUNTS,columnCounts:n})},[n]),function(e){let{navId:t,columnCounts:n,focusedX:r,focusedY:a,onSelect:_,prepareFocus:E,getNewFocusPosition:A,dispatch:h,maintainFocusPosition:I,enabled:f,autoFocusElement:p,useVirtualFocus:T}=e,m=i.useRef(f),g=u(c(t,r,a)),[S,N]=i.useState(!1),[C,R]=i.useState(!1),[O,L]=i.useState(!1),[D]=i.useState(()=>new o.Lp(e=>{let[t,n]=e.split(",").map(Number);return()=>{N(!0),h({type:l.n.SET_FOCUSED_POSITION,x:t,y:n})}}));i.useEffect(()=>()=>D.clean(),[D]);let y=i.useCallback(e=>{if(!m.current||!p)return!1;e.focus()},[p]),v=i.useCallback((e,n)=>{let i=c(t,e,n);(null!=E?E(e,n,i):Promise.resolve()).then(()=>{let e=u(i);null!=e?(y(e),R(!1)):requestAnimationFrame(()=>R(!0))})},[t,E,y]),b=i.useCallback(function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],[n,i]=null!=A?A(r,a):[r,a];if((n!==r||i!==a)&&(h({type:l.n.SET_FOCUSED_POSITION,x:n,y:i}),!e))return void L(!0);let s=u(c(t,n,i));null!=s&&(L(!0),y(s))},[h,r,a,A,t,y]),[M,P]=i.useState(!1);i.useEffect(()=>{if(!M||!S)return;P(!1);let e=u(c(t,r,a));if(null!=e)return void y(e);N(!1);let n=u(c(t));null!=n&&y(n)},[t,M,S,y,r,a]);let U=i.useCallback(e=>{m.current&&null==e&&P(!0)},[]);i.useEffect(()=>{S&&C&&null!=g&&(y(g),R(!1))},[C,g]),i.useEffect(()=>{S&&(O||v(r,a),L(!1))},[r,a]);let w=i.useCallback(e=>{if(!m.current)return;if(!T&&d.includes(e.key)&&!(e.shiftKey||e.altKey||e.metaKey||e.ctrlKey)&&e.currentTarget===e.target){e.preventDefault(),e.stopPropagation(),b();return}let t=function(e){switch(e.key){case s.D$.ENTER:return s.X2.SELECT_FOCUSED_ITEM;case s.D$.UP:return s.X2.NAVIGATE_UP;case s.D$.DOWN:return s.X2.NAVIGATE_DOWN;case s.D$.RIGHT:return s.X2.NAVIGATE_RIGHT;case s.D$.LEFT:return s.X2.NAVIGATE_LEFT;case s.D$.HOME:if(e.ctrlKey)return s.X2.NAVIGATE_START;return s.X2.NAVIGATE_INLINE_START;case s.D$.END:if(e.ctrlKey)return s.X2.NAVIGATE_END;return s.X2.NAVIGATE_INLINE_END}}(e);switch(t){case s.X2.NAVIGATE_UP:case s.X2.NAVIGATE_DOWN:case s.X2.NAVIGATE_RIGHT:case s.X2.NAVIGATE_LEFT:case s.X2.NAVIGATE_INLINE_START:case s.X2.NAVIGATE_INLINE_END:case s.X2.NAVIGATE_START:case s.X2.NAVIGATE_END:0!==n.length&&(0!==r||0!==a||t!==s.X2.NAVIGATE_LEFT)&&(e.preventDefault(),e.stopPropagation()),h({type:t});return;case s.X2.SELECT_FOCUSED_ITEM:if(p&&g?.ownerDocument.activeElement!==g||e.repeat)return;e.preventDefault(),e.stopPropagation(),h({type:t}),null!=_?_(r,a,e):null!=g&&g.click()}},[b,h,p,g,_,r,a]),G=i.useCallback(e=>e.currentTarget!==e.target?(S||(N(!0),L(!0)),!1):S?(b(!1),!1):void(I&&null!=g?v(r,a):b(!0)),[S,I,g,b,v,r,a]),x=i.useCallback(e=>{if(e.target!==e.currentTarget){if(e.currentTarget.contains(e.relatedTarget))return!1;N(!1)}},[]),k=i.useMemo(()=>Math.max(...n),[n]),F=i.useCallback(()=>({role:"grid","aria-rowcount":n.length,"aria-colcount":k,tabIndex:S&&I?-1:0,"data-ref-id":t,onKeyDown:w,onFocus:G,onBlur:x}),[n.length,k,S,I,t,w,G,x]),V=i.useCallback((e,n)=>{let i={role:"gridcell","aria-rowindex":n+1,"aria-colindex":e+1,id:(0,o.Aq)(t,e,n),tabIndex:I&&e===r&&n===a?0:-1,onFocus:D.get(`${e},${n}`)};return e===r&&n===a&&(i.ref=U),i},[t,I,r,a,D,U]),B=i.useCallback(e=>({role:"row","aria-rowindex":e+1}),[]);return i.useMemo(()=>({dispatch:h,getContainerProps:F,getItemProps:V,getRowProps:B}),[h,F,V,B])}({navId:t,columnCounts:N,focusedX:C,focusedY:R,dispatch:O,onSelect:_,prepareFocus:E,getNewFocusPosition:A,maintainFocusPosition:h,enabled:I,autoFocusElement:p,useVirtualFocus:T})}({navId:n,columnCounts:t,onDispatch:i.useCallback((e,t,n)=>{switch(n.type){case s.X2.NAVIGATE_UP:case s.X2.NAVIGATE_DOWN:case s.X2.NAVIGATE_RIGHT:case s.X2.NAVIGATE_LEFT:case s.X2.NAVIGATE_INLINE_START:case s.X2.NAVIGATE_INLINE_END:case s.X2.NAVIGATE_START:case s.X2.NAVIGATE_END:case s.X2.NAVIGATE_CROSSLINE_START:case s.X2.NAVIGATE_CROSSLINE_END:I(t)}},[I]),onSelect:i.useCallback((e,t,n)=>{let i=h(e,t);null!=i&&_(i,n)},[h,_]),autoFocusElement:!1,useVirtualFocus:!0}),{gridContainerProps:g,handleGridContainerKeyDown:S}=i.useMemo(()=>{let e=m();return{gridContainerProps:e,handleGridContainerKeyDown:e.onKeyDown}},[m]);return i.useEffect(()=>{function e(){A.current=!1}return window.addEventListener("mousemove",e),()=>window.removeEventListener("mousemove",e)},[]),{gridDispatch:f,getItemProps:p,getRowProps:T,gridContainerProps:g,handleGridContainerKeyDown:S,isUsingKeyboardNavigation:A}}function g(e){let{categories:t,collapsedCategories:n,gridWidth:r=0,listPaddingRight:a=0,itemNodeWidth:s,itemNodeMargin:l=0}=e;return i.useMemo(()=>{let e=Math.max(1,Math.floor((r-a+l)/(s+l))),i=Math.floor(Math.max(l,(r-a-s*e)/(e-1))),o=[],d=[],c=[],u=0,_=0,E=0;if(0!==r)for(let i of t)i.items.length>0&&function(t,n){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=Math.ceil(t.length/e);d[_]=i?0:r;for(let a=0;a<r;a++){let r=a*e,s=r+e,l=t.slice(r,s).map((e,t)=>({item:e,gridSectionIndex:_,rowIndex:u,columnIndex:t,visibleRowIndex:E,category:n}));i||(E++,c.push(l),o.push(l.length)),u++}_++}(i.items,i.categoryInfo.type,n?.has(`${i.key}`)??!1);return{expressionsGrid:c,rowCount:u,rowCountBySection:d,columnCounts:o,gutterWidth:i}},[t,n,r,l,s,a])}function S(e){let{columnCounts:t,expressionsGrid:n,expressionsListRef:r,store:a,gridNavigatorId:s,onSelectItem:o}=e,{gridDispatch:d,getItemProps:c,getRowProps:u,gridContainerProps:_,handleGridContainerKeyDown:E,isUsingKeyboardNavigation:h}=m({columnCounts:t,gridNavigatorId:s,itemGrid:n,itemList:r,onGridNavigatorItemSelect:o,onGridNavigatorPositionChange:a.setInspectedExpressionPosition});return i.useEffect(()=>a.subscribe(e=>e.inspectedExpressionPosition,e=>{if(null==e)return;let{columnIndex:t,rowIndex:n,source:i}=e;i!==A.t.GRID_NAVIGATOR_EVENT&&d({type:l.n.SET_FOCUSED_POSITION,x:t,y:n})}),[d,a]),{getItemProps:c,getRowProps:u,gridContainerProps:_,handleGridContainerKeyDown:E,isUsingKeyboardNavigation:h}}}