"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[6236],{81376(e,t,a){a.r(t),a.d(t,{default:()=>F}),a(43617),a(81975);var i=a(36418),n=a(84402),l=a(37270),c=a(53442),r=a(67091),s=a(26614),o=a(69657);const g=(0,r.Mz)("getGiphyFetchInstance",e=>(0,s.zj)(e).GiphySdkKey,e=>e?new c.uK(e):null),m=(0,r.Mz)("getGiphyLanguageCode",e=>(0,o.k)(e),e=>e?.split("-")?.[0]??"en");var u=a(60853),f=a(92243);const p="gifs";function h(e){const t=(0,l.useSelector)(g),a=(0,l.useSelector)(m),c=(0,i.useCallback)(async i=>t?e.filter.length>0?await t.search(e.filter,{offset:i,lang:a,sort:"relevant",limit:10,rating:"g",type:p}):await t.trending({offset:i,limit:10,rating:"g",type:p}):{},[e.filter,a,t]);return i.createElement("div",{className:"emoji-picker__items gif-picker__items","data-testid":"gif-picker-items"},i.createElement(n.xA,{key:0===e.filter.length?"trending":e.filter,columns:2,gutter:8,hideAttribution:!0,width:e.width,noResultsMessage:i.createElement(u.A,{variant:f.L.Search,titleValues:{channelName:`${e.filter}`}}),fetchGifs:c,onGifClick:e.onClick}))}const d=(0,i.memo)(h);var k=a(14778),C=a(11038),_=a(77440);const b=a.p+"files/baa860e68242972b21ae.png",v=a.p+"files/619b38f85175109c83db.png";function w(e){const t=(0,l.useSelector)(_.O4),{formatMessage:a}=(0,k.useIntl)(),n=(0,i.useCallback)(t=>{t.preventDefault();const a=t.target?.value?.replace(/^:|:$/g,"")??"";e.onChange(a)},[e.onChange]),c=(0,i.useMemo)(()=>!!C.A.mostReadable(t.centerChannelBg,["#FFFFFF","#000000"],{includeFallbackColors:!1}).isLight(),[t.centerChannelBg]);return i.createElement("div",{className:"emoji-picker__search-container"},i.createElement("div",{className:"emoji-picker__text-container gif-picker__text-container"},i.createElement("span",{className:"icon-magnify icon emoji-picker__search-icon"}),i.createElement("input",{id:"emojiPickerSearch",className:"emoji-picker__search","aria-label":a({id:"gif_picker.input.label",defaultMessage:"Search for GIFs"}),placeholder:a({id:"gif_picker.input.placeholder",defaultMessage:"Search GIPHY"}),type:"text",autoFocus:!0,autoComplete:"off",onChange:n,value:e.value})),i.createElement("div",{className:"gif-attribution"},i.createElement("img",{src:c?v:b,alt:a({id:"gif_picker.attribution.alt",defaultMessage:"Powered by GIPHY"})})))}const E=(0,i.memo)(w),F=e=>{const t=(0,i.useCallback)((t,a)=>{if(e.onGifClick){a.preventDefault();const i=`![${t.title}](${t.images.fixed_height.url})`;e.onGifClick(i)}},[e.onGifClick]),a=(0,i.useMemo)(()=>(e.getRootPickerNode?.()?.getBoundingClientRect()?.width??350)-24,[e.getRootPickerNode]);return i.createElement(i.Fragment,null,i.createElement(E,{value:e.filter,onChange:e.handleFilterChange}),i.createElement(d,{width:a,filter:e.filter,onClick:t}))}}}]);
//# sourceMappingURL=6236.35c8689d5cc2559fdf6a.js.map