Build 545032stable
Module 148355
4,898 characters · in f08fed5b39d8e5b5.jsDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>k,h:()=>b});var l=n(627968),i=n(64700),s=n(503698),r=n.n(s),a=n(284009),o=n.n(a),c=n(873174),u=n(17928),d=n(269115),h=n(395899),m=n(834730),p=n(866323),f=n(717421),g=n(775602),x=n(776231),A=n(750506),C=n(218394),E=n(256449),I=n(194004),y=n(68935),S=n(375708),v=n(554896);let N=e=>e.preventDefault(),_={tension:1100,friction:40},T={tension:1600,friction:60};function j(e,t){return i.cloneElement(e,{"data-type":"sticker","data-id":t.id,"data-name":t.name,"data-format-type":t.format_type})}function b(e){let t="description"in e&&null!=e.description?`${e.name}, ${e.description}`:e.name;return S.intl.formatToPlainString(S.t.rk6pOw,{stickerName:t})}let R=e=>{let{children:t,hasError:n,isLoading:i,maskAsset:s,size:a,withLoadingIndicator:o=!0}=e,c=a>=33;return(0,l.jsxs)("div",{className:r()(v.c6,{[v.v2]:n||s}),style:{height:a,width:a},children:[n?(0,l.jsxs)("div",{className:v.z3,children:[(0,l.jsx)(h.d,{size:"custom",width:20,height:20,color:"currentColor",className:v.ik}),c&&(0,l.jsx)(m.E,{className:v.kc,color:"text-default",variant:"text-sm/normal",children:S.intl.string(S.t["tWYWJ+"])})]}):t,o&&i&&(0,l.jsx)("div",{className:v.Mz})]})},O=e=>{let{shouldAnimate:t,size:s,sticker:r,fileUri:a,assetData:c,isFocused:u,className:d,maskAsset:h,positionRef:m,withLoadingIndicator:p,onError:f}=e,g=i.useRef(null),A=i.useRef(null),[C,E]=i.useState(!0),[I,N]=i.useState(!1),_=i.useRef(!1);_.current=t&&u;let T=null==a?(0,y.zg)(r):a;return(o()(null!=T,`Unable to determine sticker asset URL. Sticker ID: ${r.id}`),i.useEffect(()=>{if(null==g.current||null==T)return;let e=Math.min(2,(0,x.mZ)());g.current.width=s*e,g.current.height=s*e;let t=!1;return(async()=>{let{default:e}=await Promise.all([n.e("70716"),n.e("9330")]).then(n.bind(n,140521));null!=g.current&&(A.current=new e({canvas:g.current,animationId:r.id,assetUrl:T,assetData:c,onInitialDraw:()=>{t||E(!1)},onError:()=>{t||(E(!1),N(!0),f?.())}}),_.current&&A.current.setState(!0))})(),()=>{A.current?.drop(),A.current=null,t=!0}},[T,s,r.id,c,f]),i.useEffect(()=>{let e;t||(e=0),A.current?.setState(t&&u,e)},[r,t,u]),null==T)?null:(0,l.jsx)("div",{role:"img",className:d,"aria-label":I?S.intl.string(S.t.yEvsK9):b(r),ref:m,children:(0,l.jsx)(R,{hasError:I,isLoading:C,maskAsset:h,size:s,withLoadingIndicator:p,children:j((0,l.jsx)("canvas",{className:v.ex,ref:g}),r)})})},M=e=>{let{shouldAnimate:t,sticker:n,isFocused:s,size:a,className:o,maskAsset:c,positionRef:u,withLoadingIndicator:h,fileUri:m}=e,[p,f]=i.useState(!1),[g,x]=i.useState(!0),[A,C]=i.useState(!1),E=i.useRef(null),I=i.useRef(null),S=m??(0,y.zg)(n,{isPreview:!t||!p||!s,size:a}),_=i.useCallback(()=>{x(!1)},[]),T=i.useCallback(()=>{C(!0)},[]);return(i.useEffect(()=>{if(null!=E.current){let{isVisible:e}=E.current;f(e)}},[]),i.useLayoutEffect(()=>{I.current?.complete===!0&&x(!1)},[]),null==S)?null:(0,l.jsx)(d.L,{innerRef:u,ref:E,onChange:f,threshold:.7,children:(0,l.jsx)("div",{className:r()(o,v.__invalid_pngImageWrapper),ref:u,children:(0,l.jsx)(R,{hasError:A,isLoading:g,maskAsset:c,size:a,withLoadingIndicator:h,children:j((0,l.jsx)("img",{className:v.r3,alt:b(n),src:S,draggable:!1,onError:T,onLoad:_,onContextMenu:N,ref:I}),n)})})})},L=e=>{let{disableAnimation:t,enlargeScaleFactor:n,enlargeWithName:s,isInteracting:r,positionRef:a,size:o,sticker:d}=e,h=(0,u.bG)([g.A],()=>g.A.useReducedMotion),x=i.useRef(null),C={transform:`scale(${h?1:1/n})`,opacity:0},E=(0,p.p)(r,{ref:x,from:C,enter:{transform:"scale(1)",opacity:1},leave:C,config:_}),I=i.useRef(null),y=(0,f.z)({ref:I,transform:r||h?"translateY(0)":"translateY(-25px)",opacity:+!!r,config:T},"animate-always");return(0,c.useChain)(r?[x,I]:[I,x],r?[0,.0625]:[0,0]),E((e,i)=>i&&(0,l.jsx)(A.nE,{className:v.O2,fixed:!0,align:"center",position:"center",targetRef:a,children:()=>(0,l.jsxs)("div",{className:v._7,children:[(0,l.jsx)(c.animated.div,{className:v.tm,style:e,children:(0,l.jsx)(w,{className:v.__invalid_overlaySticker,disableAnimation:t,enlargeOnInteraction:!1,isInteracting:r,maskAsset:!1,sticker:d,size:Math.round(o*n),withLoadingIndicator:!1})}),s&&(0,l.jsx)(c.animated.div,{className:v.av,style:y,children:(0,l.jsx)(m.E,{variant:"text-sm/medium",className:v.FZ,children:d.name})})]})}))},w=e=>{let{isInteracting:t=!1,disableAnimation:n=!1,enlargeOnInteraction:s=!1,enlargeWithName:r=!0,enlargeScaleFactor:a=1.55,maskAsset:o=!1,size:c,sticker:u,className:d,withLoadingIndicator:h,assetData:m,fileUri:p,onError:f}=e,g=(0,C.j)(),x=(0,E.Th)(t)&&!n,A=i.useRef(null);if(null==u)return null;let y=u.format_type===I.TG.LOTTIE?O:M;return(0,l.jsxs)(i.Fragment,{children:[(0,l.jsx)(y,{shouldAnimate:x,isFocused:g,size:c,sticker:u,className:d,maskAsset:o,positionRef:A,withLoadingIndicator:h,assetData:m,fileUri:p,onError:f}),s&&(0,l.jsx)(L,{disableAnimation:n,enlargeScaleFactor:a,enlargeWithName:r,isInteracting:t,positionRef:A,size:c,sticker:u})]},`${u.id},${c}`)},k=w}