"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4732],{44401:function(e,t,s){s.d(t,{Z:function(){return r}});var a=s(57437),n=s(20392);function r(e){let{locale:t,namespace:s,textCode:r,...l}=e,{t:o}=(0,n.$)(t,s);return(0,a.jsx)("p",{...l,children:o(r)})}s(2265)},54732:function(e,t,s){s.d(t,{Z:function(){return E},h:function(){return R}});var a=s(57437),n=s(33145),r=s(44401),l=s(74291),o=s(40279),i=s(15863),d=s(80670),c=s(12381),u=s(2265),m=s(29827),f=s(21770),x=s(10709),h=s(76350),p=s(14438),A=s(20392),g=s(31229),b=s(29501),j=s(13590),w=s(93448),N=s(55765),C=s(67281),y=s(99376),v=s(33651),F=s(17946);function E(e){let{locale:t,open:s,onOpenChange:E,moveToShortlistAfterCreate:I}=e,V=(0,u.useRef)(null),{t:B}=(0,A.$)(t,"home"),{t:D}=(0,A.$)(t,"shortlist"),[k,z]=(0,u.useState)(),[L,S]=(0,u.useState)(),Z=(0,m.NL)(),M=(0,y.useRouter)(),_=g.z.object({name:g.z.string(),description:g.z.string().optional()}),G=(0,b.cI)({resolver:(0,j.F)(_),mode:"all",defaultValues:{name:"",description:""}}),O=(0,f.D)({mutationFn:async e=>(0,x._y)(await fetch(h.MF.BRAND_ANALYTICS_SHORTLIST,{method:h.w$.POST,body:JSON.stringify(e)})),onSuccess:async e=>{(0,N.k)(new C.YR),E(!1),await Promise.all([Z.refetchQueries({queryKey:["home"]}),Z.refetchQueries({queryKey:["shortlists"]})]),I&&(p.Am.success(B("create-shortlist-success")),M.push("/shortlist/".concat(e.id)))},onError:e=>{(0,N.k)(new C.eD),p.Am.error(B("create-shortlist-failed")),console.log(e)}}),U=(0,f.D)({mutationFn:async e=>(0,x._y)(await fetch(h.MF.FILE_UPLOAD,{method:h.w$.POST,body:e})),onSuccess:async e=>{z(e.id)},onError:()=>{p.Am.error(B("upload-image-failed"))}});return(0,a.jsx)(l.Vq,{open:s,onOpenChange:E,children:(0,a.jsxs)(l.cZ,{onOpenAutoFocus:function(){S(void 0),z(void 0),G.reset({name:"",description:""})},className:(0,w.cn)("w-[36rem] max-w-none rounded-[8px] border-none *:px-4 gap-4 p-0 flex flex-col items-start justify-start max-sm:w-bit-shorter-than-screen overflow-clip"),rel:"noCloseIcon",children:[(0,a.jsxs)("div",{className:"h-28 w-full flex-none flex relative pb-3 items-end",children:[(0,a.jsxs)("div",{onClick:()=>{var e;return null===(e=V.current)||void 0===e?void 0:e.click()},className:"flex items-center justify-start p-1 gap-1 bg-[#4D3DF0] z-20 rounded-sm cursor-pointer",children:[(0,a.jsx)(R,{}),(0,a.jsx)(r.Z,{locale:t,namespace:"shortlist",textCode:"change-cover",className:"text-sm text-[#FFFFFF] font-semibold leading-none"})]}),L?(0,a.jsx)(n.default,{className:"w-full h-full object-cover absolute object-center top-0 right-0",src:L,alt:"",quality:100,width:500,height:500}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.default,{className:"w-full absolute h-full top-0 right-0 object-cover object-right-top z-10",src:v.Z,alt:"",quality:100,width:500,height:500}),(0,a.jsx)(n.default,{className:"w-full absolute h-full top-0 right-0 object-cover object-left-bottom z-0",src:F.Z,alt:"",quality:100,width:500,height:500})]})]}),O.isPending&&(0,a.jsx)("div",{className:"absolute flex items-center justify-center w-full h-full z-30 bg-slate-200 rounded-[8px] animate-pulse left-0 top-0",children:(0,a.jsxs)("div",{className:"flex items-center justify-center space-x-2 animate-bounce",children:[(0,a.jsx)("div",{className:"w-4 h-4 bg-zinc-400 rounded-full"}),(0,a.jsx)("div",{className:"w-4 h-4 bg-zinc-400 rounded-full"}),(0,a.jsx)("div",{className:"w-4 h-4 bg-zinc-400 rounded-full"})]})}),(0,a.jsx)(o.I,{className:"absolute invisible",type:"file",accept:"image/*",ref:V,onChange:e=>{var t,s;let a=null==e?void 0:null===(s=e.target)||void 0===s?void 0:null===(t=s.files)||void 0===t?void 0:t[0];if(a){let e=new FormData;e.set("file",a),U.mutate(e);let t=new FileReader;t.onload=()=>{S(t.result)},t.readAsDataURL(a)}}}),(0,a.jsx)(r.Z,{locale:t,namespace:"home",textCode:"create-shortlist",className:"text-lg/[1.375rem] font-semibold text-[#3F484A] w-full"}),(0,a.jsx)(d.l0,{...G,children:(0,a.jsxs)("form",{onSubmit:G.handleSubmit(()=>O.mutate({...G.getValues(),image:k})),className:"w-full flex flex-col gap-4 pb-6",children:[(0,a.jsx)(d.Wi,{control:G.control,name:"name",render:e=>{let{field:t}=e;return(0,a.jsxs)(d.xJ,{className:"w-full",children:[(0,a.jsx)(d.lX,{className:"text-xs/[0.875rem] text-[#3F484A] font-normal",children:D("shortlist-name")}),(0,a.jsx)(d.NI,{children:(0,a.jsx)(o.I,{className:"h-12 rounded-[3px] border-[#ECEEEF] shadow-[#B7CFF426]",placeholder:"",...t})})]})}}),(0,a.jsx)(d.Wi,{control:G.control,name:"description",render:e=>{let{field:t}=e;return(0,a.jsxs)(d.xJ,{children:[(0,a.jsxs)(d.lX,{className:"text-xs/[0.875rem] text-[#3F484A] font-normal flex gap-1 items-center",children:[D("description"),(0,a.jsx)("p",{className:"text-[#BFC8CA]",children:"(".concat(D("optional"),")")})]}),(0,a.jsx)(d.NI,{children:(0,a.jsx)(o.I,{className:"h-12 rounded-[3px] border-[#ECEEEF] shadow-[#B7CFF426]",placeholder:"",...t})})]})}}),(0,a.jsxs)("div",{className:"w-full flex justify-end items-center gap-2",children:[(0,a.jsx)(l.GG,{className:"flex items-center justify-center rounded-sm py-1 px-3 border border-[#BFC8CA] h-7",children:(0,a.jsx)(r.Z,{locale:t,namespace:"home",textCode:"go-back",className:"text-xs/[0.875rem] text-[#3F484A] font-normal"})}),(0,a.jsx)(c.z,{disabled:!G.getValues("name"),type:"submit",className:"h-7 bg-[#4D3DF0] text-white py-1 px-3 rounded-sm text-xs/[0.875rem] font-normal disabled:bg-[#ECEEEF] disabled:text-[#BFC8CA] border-none",onClick:()=>{(0,N.k)(new C.d0)},children:O.isPending?(0,a.jsx)(i.Z,{width:12,height:12,className:"text-white animate-spin"}):(0,a.jsx)(r.Z,{locale:t,namespace:"home",textCode:"save-shortlist"})})]})]})})]})})}function R(){return(0,a.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,a.jsx)("path",{d:"M16.875 3.125H3.125C2.79348 3.125 2.47554 3.2567 2.24112 3.49112C2.0067 3.72554 1.875 4.04348 1.875 4.375V15.625C1.875 15.9565 2.0067 16.2745 2.24112 16.5089C2.47554 16.7433 2.79348 16.875 3.125 16.875H16.875C17.2065 16.875 17.5245 16.7433 17.7589 16.5089C17.9933 16.2745 18.125 15.9565 18.125 15.625V4.375C18.125 4.04348 17.9933 3.72554 17.7589 3.49112C17.5245 3.2567 17.2065 3.125 16.875 3.125ZM12.1875 6.875C12.3729 6.875 12.5542 6.92998 12.7083 7.033C12.8625 7.13601 12.9827 7.28243 13.0536 7.45373C13.1246 7.62504 13.1432 7.81354 13.107 7.9954C13.0708 8.17725 12.9815 8.3443 12.8504 8.47541C12.7193 8.60652 12.5523 8.69581 12.3704 8.73199C12.1885 8.76816 12 8.74959 11.8287 8.67864C11.6574 8.60768 11.511 8.48752 11.408 8.33335C11.305 8.17918 11.25 7.99792 11.25 7.8125C11.25 7.56386 11.3488 7.3254 11.5246 7.14959C11.7004 6.97377 11.9389 6.875 12.1875 6.875ZM16.875 15.625H3.125V12.5539L6.74531 8.93281C6.80336 8.8747 6.87229 8.8286 6.94816 8.79715C7.02404 8.7657 7.10537 8.74951 7.1875 8.74951C7.26963 8.74951 7.35096 8.7657 7.42684 8.79715C7.50271 8.8286 7.57164 8.8747 7.62969 8.93281L12.8906 14.1922C13.0079 14.3095 13.167 14.3753 13.3328 14.3753C13.4987 14.3753 13.6577 14.3095 13.775 14.1922C13.8923 14.0749 13.9582 13.9159 13.9582 13.75C13.9582 13.5841 13.8923 13.4251 13.775 13.3078L12.3953 11.9289L13.5156 10.8078C13.6328 10.6907 13.7917 10.6249 13.9574 10.6249C14.1231 10.6249 14.282 10.6907 14.3992 10.8078L16.875 13.2867V15.625Z",fill:"white"})})}},74291:function(e,t,s){s.d(t,{$N:function(){return p},Be:function(){return A},GG:function(){return u},Vq:function(){return i},cN:function(){return h},cZ:function(){return f},fK:function(){return x},hg:function(){return d}});var a=s(57437),n=s(2265),r=s(49027),l=s(20653),o=s(93448);let i=r.fC,d=r.xz,c=r.h_,u=r.x8,m=n.forwardRef((e,t)=>{let{className:s,showOverlay:n=!0,...l}=e;return(0,a.jsx)(r.aV,{ref:t,className:(0,o.cn)("fixed inset-0 z-50  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n&&"bg-black/80",s),...l})});m.displayName=r.aV.displayName;let f=n.forwardRef((e,t)=>{let{className:s,children:n,rel:i,showOverlay:d,closeIconProps:u,...f}=e;return(0,a.jsxs)(c,{children:[(0,a.jsx)(m,{showOverlay:d}),(0,a.jsxs)(r.VY,{ref:t,className:(0,o.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...f,children:[n,(0,a.jsxs)(r.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:["noCloseIcon"!=i?(0,a.jsx)(l.Pxu,{...u,className:(null==u?void 0:u.height)&&(null==u?void 0:u.width)?"":"h-4 w-4"}):null,(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});f.displayName=r.VY.displayName;let x=e=>{let{className:t,...s}=e;return(0,a.jsx)("div",{className:(0,o.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...s})};x.displayName="DialogHeader";let h=e=>{let{className:t,...s}=e;return(0,a.jsx)("div",{className:(0,o.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s})};h.displayName="DialogFooter";let p=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)(r.Dx,{ref:t,className:(0,o.cn)("text-lg font-semibold leading-none tracking-tight",s),...n})});p.displayName=r.Dx.displayName;let A=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)(r.dk,{ref:t,className:(0,o.cn)("text-sm text-muted-foreground",s),...n})});A.displayName=r.dk.displayName},80670:function(e,t,s){s.d(t,{NI:function(){return p},Wi:function(){return u},l0:function(){return d},lX:function(){return h},xJ:function(){return x},zG:function(){return A}});var a=s(57437),n=s(2265),r=s(37053),l=s(29501),o=s(93448),i=s(75060);let d=l.RV,c=n.createContext({}),u=e=>{let{...t}=e;return(0,a.jsx)(c.Provider,{value:{name:t.name},children:(0,a.jsx)(l.Qr,{...t})})},m=()=>{let e=n.useContext(c),t=n.useContext(f),{getFieldState:s,formState:a}=(0,l.Gc)(),r=s(e.name,a);if(!e)throw Error("useFormField should be used within <FormField>");let{id:o}=t;return{id:o,name:e.name,formItemId:"".concat(o,"-form-item"),formDescriptionId:"".concat(o,"-form-item-description"),formMessageId:"".concat(o,"-form-item-message"),...r}},f=n.createContext({}),x=n.forwardRef((e,t)=>{let{className:s,...r}=e,l=n.useId();return(0,a.jsx)(f.Provider,{value:{id:l},children:(0,a.jsx)("div",{ref:t,className:(0,o.cn)("space-y-2",s),...r})})});x.displayName="FormItem";let h=n.forwardRef((e,t)=>{let{className:s,...n}=e,{error:r,formItemId:l}=m();return(0,a.jsx)(i._,{ref:t,className:(0,o.cn)(r&&"text-red-600",s),htmlFor:l,...n})});h.displayName="FormLabel";let p=n.forwardRef((e,t)=>{let{...s}=e,{error:n,formItemId:l,formDescriptionId:o,formMessageId:i}=m();return(0,a.jsx)(r.g7,{ref:t,id:l,"aria-describedby":n?"".concat(o," ").concat(i):"".concat(o),"aria-invalid":!!n,...s})});p.displayName="FormControl",n.forwardRef((e,t)=>{let{className:s,...n}=e,{formDescriptionId:r}=m();return(0,a.jsx)("p",{ref:t,id:r,className:(0,o.cn)("text-[0.8rem] text-muted-foreground",s),...n})}).displayName="FormDescription";let A=n.forwardRef((e,t)=>{let{className:s,children:n,...r}=e,{error:l,formMessageId:i}=m(),d=l?String(null==l?void 0:l.message):n;return d?(0,a.jsx)("p",{ref:t,id:i,className:(0,o.cn)("text-[0.8rem] text-red-600",s),...r,children:d}):null});A.displayName="FormMessage"},40279:function(e,t,s){s.d(t,{I:function(){return l}});var a=s(57437),n=s(2265),r=s(93448);let l=n.forwardRef((e,t)=>{let{className:s,type:n,...l}=e;return(0,a.jsx)("input",{type:n,className:(0,r.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...l})});l.displayName="Input"},75060:function(e,t,s){s.d(t,{_:function(){return d}});var a=s(57437),n=s(2265),r=s(6394),l=s(77712),o=s(93448);let i=(0,l.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)(r.f,{ref:t,className:(0,o.cn)(i(),s),...n})});d.displayName=r.f.displayName},17946:function(e,t){t.Z={src:"/_next/static/media/shortlist-default-cover-bg.5060c232.png",height:210,width:1440,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAABCAMAAADU3h9xAAAABlBMVEWEg4OEhIR66pW8AAAACXBIWXMAAAsTAAALEwEAmpwYAAAADklEQVR4nGNgYGBkBGEAABcABVAQLkcAAAAASUVORK5CYII=",blurWidth:8,blurHeight:1}},33651:function(e,t){t.Z={src:"/_next/static/media/shortlist-default-cover.41151e91.png",height:210,width:1440,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAABCAMAAADU3h9xAAAACVBMVEVMaXH////////OZTV/AAAAA3RSTlMACRrW1obtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAADUlEQVR4nGNgAANGJgAADQAEpBAsBgAAAABJRU5ErkJggg==",blurWidth:8,blurHeight:1}}}]);