"use strict";(self.webpackChunkchat=self.webpackChunkchat||[]).push([[683],{6683:(e,t,r)=>{r.r(t),r.d(t,{FetchError:()=>z,GiphyFetch:()=>C,gifPaginator:()=>F,request:()=>X,serverUrl:()=>V,setServerUrl:()=>H});const n={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let i;const s=new Uint8Array(16);function o(){if(!i&&(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!i))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(s)}const a=[];for(let e=0;e<256;++e)a.push((e+256).toString(16).slice(1));const c=function(e,t,r){if(n.randomUUID&&!t&&!e)return n.randomUUID();const i=(e=e||{}).random||(e.rng||o)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=i[e];return t}return function(e,t=0){return a[e[t+0]]+a[e[t+1]]+a[e[t+2]]+a[e[t+3]]+"-"+a[e[t+4]]+a[e[t+5]]+"-"+a[e[t+6]]+a[e[t+7]]+"-"+a[e[t+8]]+a[e[t+9]]+"-"+a[e[t+10]]+a[e[t+11]]+a[e[t+12]]+a[e[t+13]]+a[e[t+14]]+a[e[t+15]]}(i)};Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;var p={ENABLED:"undefined"!=typeof window&&"undefined"!=typeof location&&-1!==location.search.indexOf("giphy-debug"),LEVEL:0,PREFIX:"GiphyJS",debug:(...e)=>{p.ENABLED&&p.LEVEL<=0&&console.debug(p.PREFIX,...e)},info:(...e)=>{p.ENABLED&&p.LEVEL<=1&&console.info(p.PREFIX,...e)},warn:(...e)=>{p.ENABLED&&p.LEVEL<=2&&console.warn(p.PREFIX,...e)},error:(...e)=>{p.ENABLED&&p.LEVEL<=3&&console.error(p.PREFIX,...e)}},d="",u=()=>{if(!d){try{d=sessionStorage.getItem("giphyPingbackId")}catch(e){}if(!d){const e=(new Date).getTime().toString(16);try{d=`${e}${c().replace(/-/g,"")}`.substring(0,16)}catch(e){d=(()=>{let e="";for(let t=0;t<16;t++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return e})()}try{sessionStorage.setItem("giphyPingbackId",d)}catch(e){}}}return d},l=(new Promise((e=>{"undefined"==typeof Image&&e(!1);const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src="data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA"})),("undefined"!=typeof window?window:global)||{});l._GIPHY_SDK_HEADERS_=l._GIPHY_SDK_HEADERS_||(l.Headers?new l.Headers({"X-GIPHY-SDK-PLATFORM":"web"}):void 0);var g,h,f,m=()=>l._GIPHY_SDK_HEADERS_,y=(e,t)=>{var r;return null==(r=m())?void 0:r.set(e,t)},b=Object.defineProperty,E=Object.defineProperties,w=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols,I=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,A=(e,t,r)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))I.call(t,r)&&A(e,r,t[r]);if(P)for(var r of P(t))S.call(t,r)&&A(e,r,t[r]);return e},$=(e,t)=>E(e,w(t)),_=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)((function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')})),D=(e,t,r)=>new Promise(((n,i)=>{var s=e=>{try{a(r.next(e))}catch(e){i(e)}},o=e=>{try{a(r.throw(e))}catch(e){i(e)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,o);a((r=r.apply(e,t)).next())})),x=(g={"package.json"(e,t){t.exports={scripts:{lint:"run -T eslint . --ext .ts,.tsx",clean:"rm -rf ./dist",dev:"parcel public/test.html",docs:"typedoc src/index.ts",build:"run -T tsup src/index.ts --format cjs,esm --dts && run -T publint",prepublish:"npm run clean && npm run build",test:"run -T jest --config ./jestconfig.js","test:watch":"run -T jest --config ./jestconfig.js --watchAll"},name:"@giphy/js-fetch-api",version:"5.4.0",description:"Javascript API to fetch gifs and stickers from the GIPHY API.",homepage:"https://github.com/Giphy/giphy-js/tree/master/packages/fetch-api",main:"dist/index.cjs",types:"dist/index.d.ts",module:"dist/index.js",type:"module",sideEffects:!1,exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./package.json":"./package.json"},files:["dist/","src/**/*"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@giphy/js-types":"*","@giphy/js-util":"*"},devDependencies:{"jest-fetch-mock":"^3.0.3","parcel-bundler":"latest",typedoc:"^0.20.37","typedoc-thunder-theme":"^0.0.3",typescript:"^5.0.4"}}}},function(){return h||(0,g[j(g)[0]])((h={exports:{}}).exports,h),h.exports}),O=["is_anonymous","is_community","is_featured","is_hidden","is_indexable","is_preserve_size","is_realtime","is_removed","is_sticker","is_dynamic"],k=["suppress_chrome","is_public","is_verified"],L=e=>t=>e[t]=!!e[t],R=e=>"string"==typeof e?e:e.text,U=e=>{const t=v({},e);t.id=String(t.id),t.tags=(t.tags||[]).map(R),O.forEach(L(t)),Object.keys(t.images||{}).forEach((e=>{const r=t.images[e];r.width=parseInt(r.width),r.height=parseInt(r.height)}));const{user:r}=t;if(r){const e=v({},r);k.forEach(L(e)),t.user=e}return t},Q=e=>(e.data=U(e.data),e),q=e=>(e.data=e.data.map((e=>U(e))),e),V=(("undefined"!=typeof window?window:global)||{}).GIPHY_API_URL||"https://api.giphy.com/v1/",H=e=>{V=e},z=class extends Error{constructor(e,t,r=0,n=""){super(e),this.url=t,this.status=r,this.statusText=n}},G=e=>e,T={},X=function(e,t={}){const{apiVersion:r=1,noCache:n=!1,normalizer:i=G}=t,s=V.replace(/\/v\d+\/$/,`/v${r}/`);if((()=>{const e=Date.now();Object.keys(T).forEach((t=>{const r=T[t].isError?6e3:6e4;e-T[t].ts>=r&&delete T[t]}))})(),!T[e]||n){const t=`${s}${e}`,r=()=>D(this,null,(function*(){var r;let n;try{const s=yield fetch(t,{method:"get"});if(s.ok){const e=yield s.json();if(null==(r=e.meta)?void 0:r.response_id)return i(e);throw{message:"synthetic response"}}{let r="Error fetching";try{const e=yield s.json();e.message&&(r=e.message)}catch(e){}T[e]&&(T[e].isError=!0),n=new z(`@giphy/js-fetch-api: ${r}`,t,s.status,s.statusText)}}catch(r){n=new z(r.message,t),T[e]&&(T[e].isError=!0)}throw n}));T[e]={request:r(),ts:Date.now()}}return T[e].request},Y=e=>e&&e.type?e.type:"gifs",C=class{constructor(e,t={}){this.getQS=(e={})=>new URLSearchParams(v($(v({},e),{api_key:this.apiKey,pingback_id:u()}),this.qsParams)).toString(),this.apiKey=e,this.qsParams=t}categories(e){return X(`gifs/categories?${this.getQS(e)}`)}gif(e,t){const r=(null==t?void 0:t.internal)?"internal/":"";return X(`${r}gifs/${e}?${this.getQS()}`,{normalizer:Q})}gifs(e,t){return Array.isArray(e)?X(`gifs?${this.getQS({ids:e.join(",")})}`,{normalizer:q}):X(`gifs/categories/${e}/${t}?${this.getQS()}`,{normalizer:q})}emoji(e){return X(`emoji?${this.getQS(e)}`,{normalizer:q})}emojiDefaultVariations(e){return X(`emoji?${this.getQS(e)}`,{apiVersion:2,normalizer:q})}emojiVariations(e){return X(`emoji/${e}/variations?${this.getQS()}`,{apiVersion:2,normalizer:q})}animate(e,t={}){const r=this.getQS($(v({},t),{m:e}));return X(`text/animate?${r}`,{normalizer:q})}search(e,t={}){const r=t.channel?`@${t.channel} ${e}`:e;let n;"text"===t.type&&(n=!0);const i=this.getQS($(v({rating:"pg-13"},t),{q:r,excludeDynamicResults:n}));return X(`${Y(t)}/search?${i}`,{normalizer:q})}subcategories(e,t){return X(`gifs/categories/${e}?${this.getQS(t)}`)}trending(e={}){return X(`${Y(e)}/trending?${this.getQS(v({rating:"pg-13"},e))}`,{normalizer:q})}random(e){return X(`${Y(e)}/random?${this.getQS(v({rating:"pg-13"},e))}`,{noCache:!0,normalizer:Q})}related(e,t={}){const{type:r="gifs"}=t;return X(`${r}/related?${this.getQS(v({gif_id:e,rating:"pg-13"},t))}`,{normalizer:q})}channels(e,t={}){return X(`channels/search?${this.getQS(v({q:e,rating:"pg-13"},t))}`)}},F=(e,t=[])=>{const r=[...t],n=t.map((e=>e.id));let i=t.length,s=!1;return()=>D(void 0,null,(function*(){if(s)return r;const t=yield e(i),{pagination:o,data:a}=t;return i=o.count+o.offset,s=i===o.total_count,a.forEach((e=>{const{id:t}=e;n.includes(t)||(r.push(e),n.push(t))})),[...r]}))};if(void 0!==_){const{version:e}=x();(null==(f=m())?void 0:f.get("X-GIPHY-SDK-NAME"))||(y("X-GIPHY-SDK-NAME","FetchAPI"),y("X-GIPHY-SDK-VERSION",e))}}}]);