1import{bt as e,yt as t}from"./BJbnTo5H.js";import{p as n}from"./C9wB_tNB.js";import{t as r}from"./C5vNCuz1.js";import{v as i}from"./CPX5SEXC.js";import{O as a,c as o,j as s,m as c,x as l}from"./By2EVj0a.js";import{n as u,t as d}from"./MB0euNS4.js";import{n as f,t as p}from"./GwzUzc_A.js";function m(m){let{collectionType:h,useLocalSignup:g=!1}=m,_=i(),v=o(),y=n(),b=f(),x=p(),S=e(!1),C=e(null),w=new Set,T=new Map,E=g?r(`signup`):null;async function D(e){if(!_.value?.uid||!e?.id)return;let t=_.value.uid,n=e.id,r=h===`gradients`?`likedGradients`:`likedPalettes`,i=T.get(n);if(S.value||w.has(n)||i&&Date.now()-i<250)return;S.value=!0,C.value=null,w.add(n);let o=e.isLiked,f=e.likeCount||0;try{e.isLiked=!o,e.likeCount=Math.max(0,f+(e.isLiked?1:-1)),b.set(t,r,n,!!e.isLiked),x.record(t,r,n,f,e.isLiked?1:-1);let i=u(d(),`updateLikesCountV2`),p=a(v,`users`,t,r,n);if(o){await c(p);try{await i({colorId:n,action:`unlike`,collectionType:h})}catch(e){throw await l(p,{likedAt:s()}),e}}else{let e={likedAt:s()};await l(p,e);try{await i({colorId:n,action:`like`,collectionType:h})}catch(e){throw await c(p),e}}}catch(i){e.isLiked=o,e.likeCount=f,b.set(t,r,n,!!o),x.record(t,r,n,f,o?1:-1),C.value=i?.code===`permission-denied`?`You don't have permission to perform this action.`:i?.code===`unavailable`?`Service temporarily unavailable. Please try again.`:i?.message||`Failed to update like status. Please try again.`}finally{w.delete(n),T.set(n,Date.now()),S.value=!1}}function O(e,t){if(e)if(g&&E)E.value=!0;else{let n=t||(h===`gradients`?`gradient`:`palette`);y.push({name:`signup`,query:{[n]:e}})}}return{isLoading:t(S),error:t(C),onLikeItem:D,onLikeSignedOut:O}}export{m as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.