1import{aD as te,dm as H,bJ as a,at as i,cv as n,aq as le,F as N,bX as R,bv as se,as as I,ap as s,dt as j,ay as b,J as ne,cg as d,am as T,bV as w,db as re,d1 as de,cy as ue,d8 as ce,bF as ge,dr as X,di as Z,ba as Y,ds as me,aw as pe,ax as f,bt as ee}from"./DtGgvzh8.js";const be={class:"relative w-full h-full bg-white flex items-center justify-center overflow-hidden select-none"},ve=["src"],ye=["src"],he={class:"absolute bottom-1 left-1/2 -translate-x-1/2 text-[9px] text-gray-400 bg-white/70 px-1.5 py-0.5 rounded capitalize"},xe=te({__name:"ProjectPreviewImage",props:{variantImageUrl:{},positions:{}},setup(z){const P=z,g=T(()=>{const u=new Map;for(const p of P.positions){if(!p.logoUrl)continue;const c=p.viewName||"default";u.has(c)||u.set(c,{viewImageUrl:p.viewImageUrl||P.variantImageUrl||"",zones:[]}),u.get(c).zones.push({name:p.position,logoUrl:p.logoUrl})}return[...u.values()]}),m=w(0);H(g,()=>{m.value=0});const h=T(()=>g.value[m.value]??null),v=T(()=>h.value?.viewImageUrl||P.variantImageUrl||""),$=()=>{m.value=(m.value-1+g.value.length)%g.value.length},_=()=>{m.value=(m.value+1)%g.value.length},y=w(!1),k=T(()=>{if(!y.value)return{};const u={};for(const p of h.value?.zones??[]){const c=h.value.zones.indexOf(p);u[p.name]={position:"absolute",bottom:"6px",right:`${c*36+6}px`,width:"28px",height:"28px",objectFit:"contain"}}return u}),U=()=>{y.value=!0};return H(v,()=>{y.value=!1}),(u,p)=>{const c=ne;return a(),i("div",be,[n(v)?(a(),i("img",{key:0,src:n(v),alt:"Product",class:"w-full h-full object-contain pointer-events-none",onLoad:U},null,40,ve)):(a(),le(c,{key:1,name:"i-heroicons-photo",class:"w-10 h-10 text-gray-300"})),n(y)&&n(h)?(a(!0),i(N,{key:2},R(n(h).zones,D=>(a(),i("img",{key:D.name,src:D.logoUrl,style:se(n(k)[D.name]),alt:"",class:"pointer-events-none"},null,12,ye))),128)):I("",!0),n(g).length>1?(a(),i(N,{key:3},[s("button",{type:"button",class:"absolute left-1 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-white/80 shadow flex items-center justify-center hover:bg-white z-10",onClick:j($,["stop"])},[b(c,{name:"i-heroicons-chevron-left",class:"w-3 h-3 text-gray-600"})]),s("button",{type:"button",class:"absolute right-1 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-white/80 shadow flex items-center justify-center hover:bg-white z-10",onClick:j(_,["stop"])},[b(c,{name:"i-heroicons-chevron-right",class:"w-3 h-3 text-gray-600"})]),s("span",he,d(n(m)+1)+" / "+d(n(g).length),1)],64)):I("",!0)])}}}),fe=Object.assign(xe,{__name:"ProjectsProjectPreviewImage"}),we=()=>{const{user:z}=re(),P=de(),g=ue(),m=ce(),h=w(null),v=w([]),$=w(!0),_=w(""),y=w(1),k=5,U=w(null),u=w(!1),p=w(""),c=w(null),D=w(!1),S=T(()=>z.value?.customerAccount),A=T(()=>z.value?.contactPersonId),J=async()=>{if(S.value){$.value=!0;try{const o=await $fetch("/api/mockup/projects/projects-get",{query:{customerId:S.value}});v.value=o??[]}catch{v.value=[]}finally{$.value=!1}}},M=T(()=>{const o=_.value.toLowerCase().trim();return o?v.value.filter(l=>l.name.toLowerCase().includes(o)||l.variantColour.toLowerCase().includes(o)||l.productCode.toLowerCase().includes(o)):v.value}),O=T(()=>Math.max(1,Math.ceil(M.value.length/k))),V=T(()=>{const o=(y.value-1)*k;return M.value.slice(o,o+k)});H(_,()=>{y.value=1}),H(O,o=>{y.value>o&&(y.value=o)});const F=o=>o.productCode?`/dashboard/shop/products/${o.productCode}?openProject=${o.id}`:null;return{projects:v,loading:$,searchQuery:_,currentPage:y,totalPages:O,paginated:V,filtered:M,confirmDeleteId:U,showNameModal:u,modalProjectName:p,isSaving:D,addingToCartId:h,fetchProjects:J,openProject:o=>{const l=F(o);l&&P.push(l)},addToCart:async o=>{h.value=o.id;try{const l=o.productCode.split("/"),B=await $fetch("/api/productDetails",{method:"POST",body:{product_slug:l[2],category:l[0],sub_category:l[1],last_buy:!1}}),K=B?.product_items?.find(r=>r.stock_id===o.stockId)??B?.product_items?.[0],Q=o.stockHeaderId||B.stock_header_id,oe={stock_header_id:Q,stock_id:o.stockId,quantity:1,colour:o.variantColour,product_item_thumbnail_image:o.variantImageUrl??K.product_item_thumbnail_image,productName:B.name??o.name,price:parseFloat((K.price??0).toFixed(2)),is_external:B.isexternal,sample:0,branding_colour:"",branding_image:"",names_list:[],comment:"",images:[]};let q=o.positions.map(r=>({...oe,branding_type:r.brandingType,branding_position:r.position,branding_size:r.size,colour_count:r.colourCount,branding_config_id:"",branding_charge_id:""}));const ae=q.map(r=>({position:r.branding_position,brandingType:r.branding_type,brandingSize:r.branding_size,brandingCount:r.colour_count,stock_header_id:
1Q})),G=await $fetch("/api/product/branding/branding-charges",{method:"POST",body:{configurations:ae}}),W=new Map;(Array.isArray(G)?G:[]).forEach(r=>{const E=String(r.position||"").trim();E&&W.set(E,{chargeId:String(r.branding_charge_id||""),configId:String(r.brandingconfigid||"")})}),q=q.map(r=>{const E=W.get(r.branding_position);return{...r,branding_charge_id:E?.chargeId??"",branding_config_id:E?.configId??""}});const ie=await $fetch("/api/cart/upsert-cart-branding",{method:"POST",body:{item_data:q}});await g.setCart(ie),g.setCartOpen()}catch{m.add({title:"Could not add to cart. Please try again.",timeout:3e3})}finally{h.value=null}},openDuplicate:o=>{c.value=o,p.value=`${o.name} Copy`,u.value=!0},confirmDuplicate:async()=>{if(!(!p.value.trim()||!c.value||!S.value)){D.value=!0;try{const o=c.value,l=await $fetch("/api/mockup/projects/project-create",{method:"POST",body:{customerId:S.value,name:p.value.trim(),contactPerson:A.value,customerAccount:S.value,productCode:o.productCode,stockId:o.stockId,variantColour:o.variantColour,variantImageUrl:o.variantImageUrl,positions:o.positions}});v.value.unshift(l),u.value=!1,c.value=null}catch{}finally{D.value=!1}}},deleteProject:async o=>{if(S.value)try{await $fetch("/api/mockup/projects/project-delete",{method:"DELETE",query:{customerId:S.value,id:o}}),v.value=v.value.filter(l=>l.id!==o),U.value=null}catch{}},timeAgo:o=>{const l=Math.floor((Date.now()-new Date(o).getTime())/864e5);return l===0?"Today":l===1?"1 day ago":`${l} days ago`},formatDate:o=>new Date(o).toLocaleDateString("en-ZA",{year:"numeric",month:"long",day:"numeric"})}},_e={class:"pb-10"},ke={class:"flex items-center justify-between mb-6"},Ce={key:0,class:"text-sm text-gray-500"},Ie={class:"relative mb-6 max-w-md"},Pe={key:0,class:"space-y-3"},$e={key:1,class:"text-center py-16 bg-white rounded-xl border border-gray-200"},De={class:"text-gray-500 font-medium"},Se={class:"text-sm text-gray-400 mt-1"},Te={key:2,class:"space-y-2.5"},Ue={class:"flex items-stretch"},Ne={class:"w-48 shrink-0 relative bg-[#f5f2ea] self-stretch"},ze={class:"flex-1 min-w-0 px-6 py-5 flex flex-col gap-1"},Ae={class:"flex items-center gap-2 mb-0.5"},Me={class:"font-semibold text-gray-900 text-[15px] leading-snug truncate"},Ve={key:0,class:"shrink-0 inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-0.5 rounded-full bg-green-100 text-green-700"},Le={key:1,class:"shrink-0 inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-0.5 rounded-full bg-blue/10 text-blue"},Be={class:"text-sm text-gray-500 font-medium mb-2"},Ee={class:"text-sm text-gray-500 space-y-0.5"},Oe={key:0},Fe={key:1,class:"flex items-center gap-1.5"},qe={class:"inline-flex items-center gap-1"},Re=["onClick"],He=["onClick"],je={class:"flex items-center gap-4 mt-3"},Je=["disabled","onClick"],Ke={key:0,class:"text-sm"},Qe={class:"font-bold text-gray-900"},Ge={key:1,class:"text-xs text-gray-400"},We={class:"flex flex-col justify-center gap-1 px-6 py-5 shrink-0 min-w-[160px]"},Xe=["onClick"],Ze=["onClick"],Ye=["onClick"],et={type:"button",disabled:"",class:"flex items-center gap-2.5 text-sm text-gray-400 py-1.5 cursor-default w-full mt-1"},tt={key:0,class:"flex items-center gap-3 px-5 py-2 bg-amber-50 border-t border-amber-100 text-xs text-amber-800"},st=["onClick"],nt={key:3,class:"flex items-center justify-center gap-1 mt-8"},ot=["disabled"],at=["onClick"],it=["disabled"],lt={class:"bg-white rounded-xl p-6 w-full max-w-sm mx-4 shadow-xl"},rt={class:"flex gap-3 justify-end"},dt={class:"bg-white rounded-xl p-6 w-full max-w-sm mx-4 shadow-xl"},ut={class:"flex gap-3 justify-end"},ct=["disabled"],bt=te({__name:"index",setup(z){const{loading:P,searchQuery:g,currentPage:m,totalPages:h,paginated:v,filtered:$,confirmDeleteId:_,showNameModal:y,modalProjectName:k,isSaving:U,addingToCartId:u,fetchProjects:p,openProject:c,addToCart:D,openDuplicate:S,confirmDuplicate:A,deleteProject:J,timeAgo:M,formatDate:O}=we();ge(p);const V=w(new Set),F=L=>{const e=new Set(V.value);e.has(L)?e.delete(L):e.add(L),V.value=e};return(L,e)=>{const x=ne;return a(),i("div",_e,[s("div",ke,[e[11]||(e[11]=s("h1",{class:"text-2xl font-bold text-gray-900"},"My Projects",-1)),n(P)?I("",!0):(a(),i("span",Ce,d(n($).length)+" project"+d(n($).length!==1?"s":""),1))]),s("div",Ie,[X(s("input",{"onUpdate:modelValue":e[0]||(e[0]=t=>Y(g)?g.value=t:null),type:"text",placeholder:"Search projects",class:"w-full border border-gray-300 rounded-lg pl-4 pr-10 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue focus:border-transparent"},null,512),[[Z,n(g)]]),b(x,{name:"i-heroicons-magnifying-glass",class:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"})]),n(P)?(a(),i("div",Pe,[(a(),i(N,null,R(5,t=>s("div",{key:t,class:"bg-white rounded-xl border border-gray-200 p-4 flex gap-4"}
1,[...e[12]||(e[12]=[pe('<div class="w-32 h-32 flex-shrink-0 rounded-lg bg-grey-300 animate-pulse"></div><div class="flex-1 space-y-2 py-1"><div class="h-4 bg-grey-300 rounded animate-pulse w-1/2"></div><div class="h-3 bg-grey-300 rounded animate-pulse w-1/4"></div><div class="flex gap-1.5 mt-3"><div class="h-5 w-16 bg-grey-300 rounded-full animate-pulse"></div><div class="h-5 w-20 bg-grey-300 rounded-full animate-pulse"></div><div class="h-5 w-14 bg-grey-300 rounded-full animate-pulse"></div></div><div class="mt-4 pt-3 border-t border-gray-100 flex items-center justify-between"><div class="flex gap-4"><div class="h-3 w-16 bg-grey-300 rounded animate-pulse"></div><div class="h-3 w-16 bg-grey-300 rounded animate-pulse"></div><div class="h-3 w-12 bg-grey-300 rounded animate-pulse"></div></div><div class="h-8 w-28 bg-grey-300 rounded-lg animate-pulse"></div></div></div>',2)])])),64))])):n($).length===0?(a(),i("div",$e,[b(x,{name:"i-heroicons-folder-open",class:"w-12 h-12 text-gray-300 mx-auto mb-3"}),s("p",De,d(n(g)?"No projects match your search":"No projects yet"),1),s("p",Se,d(n(g)?"Try a different search term":"Head to the Shop to start branding a product"),1)])):(a(),i("div",Te,[(a(!0),i(N,null,R(n(v),t=>(a(),i("div",{key:t.id,class:"bg-white rounded-2xl overflow-hidden hover:shadow-sm transition-shadow duration-150",style:{border:"0.8px solid #D3D3D3"}},[s("div",Ue,[s("div",Ne,[b(fe,{"stock-header-id":t.stockHeaderId,"variant-colour":t.variantColour,"variant-image-url":t.variantImageUrl,positions:t.positions??[]},null,8,["stock-header-id","variant-colour","variant-image-url","positions"])]),s("div",ze,[s("div",Ae,[s("h3",Me,d(t.name||"Untitled Design"),1),t.orders?.length?(a(),i("span",Ve,[b(x,{name:"i-heroicons-check-badge",class:"w-3 h-3"}),e[13]||(e[13]=f(" Ordered ",-1))])):t.isInCart?(a(),i("span",Le,[b(x,{name:"i-heroicons-shopping-cart",class:"w-3 h-3"}),e[14]||(e[14]=f(" In Cart ",-1))])):I("",!0)]),s("p",Be,"Edited "+d(n(M)(t.updatedAt)),1),s("div",Ee,[t.productName?(a(),i("p",Oe,[e[15]||(e[15]=s("span",{class:"text-gray-400"},"Product Name: ",-1)),f(d(t.productName),1)])):I("",!0),t.variantColour?(a(),i("p",Fe,[e[16]||(e[16]=s("span",{class:"text-gray-400"},"Colour: ",-1)),s("span",qe,[s("span",{class:"w-2.5 h-2.5 rounded-full border border-black/10 shrink-0",style:se({backgroundColor:t.variantColour})},null,4),f(" "+d(t.variantColour),1)])])):I("",!0),s("p",null,[n(V).has(t.id)?(a(),i(N,{key:1},[e[18]||(e[18]=s("span",{class:"text-gray-400"},"Branding: ",-1)),f(d(t.positions.map(C=>C.position).join(", "))+" ",1),s("button",{type:"button",class:"text-gray-400 hover:text-gray-600 ml-1 text-xs",onClick:C=>F(t.id)},"less",8,He)],64)):(a(),i(N,{key:0},[e[17]||(e[17]=s("span",{class:"text-gray-400"},"Branding: ",-1)),s("button",{type:"button",class:"text-blue hover:underline",onClick:C=>F(t.id)},d(t.positions?.length||0)+" location"+d(t.positions?.length!==1?"s":""),9,Re)],64))]),s("p",null,[e[19]||(e[19]=s("span",{class:"text-gray-400"},"Created on: ",-1)),f(d(n(O)(t.createdAt)),1)])]),s("div",je,[s("button",{type:"button",class:"shrink-0 whitespace-nowrap inline-flex items-center gap-1.5 bg-blue text-white text-sm font-medium px-4 py-2 rounded-lg hover:bg-blue/90 transition-colors disabled:opacity-50",disabled:n(u)===t.id||!t.name||!t.positions?.length,onClick:C=>n(D)(t)},[b(x,{name:n(u)===t.id?"i-heroicons-arrow-path":"i-uil-shopping-cart",class:ee(["w-4 h-4",{"animate-spin":n(u)===t.id}])},null,8,["name","class"]),f(" "+d(n(u)===t.id?"Addingâ¦":"Add to cart"),1)],8,Je),t.pricing?(a(),i("div",Ke,[s("p",Qe,"R"+d(t.pricing.total.toFixed(2)),1),e[20]||(e[20]=s("p",{class:"text-xs text-gray-400"},"Items + Branding + VAT + Delivery",-1))])):(a(),i("p",Ge,"Pricing at checkout"))])]),s("div",We,[s("button",{type:"button",class:"flex items-center gap-2.5 text-sm text-gray-600 hover:text-blue py-1.5 transition-colors w-full",onClick:C=>n(c)(t)},[b(x,{name:"i-uil-edit",class:"w-4 h-4 shrink-0"}),e[21]||(e[21]=f(" Edit ",-1))],8,Xe),s("button",{type:"button",class:"flex items-center gap-2.5 text-sm text-gray-600 hover:text-blue py-1.5 transition-colors w-full",onClick:C=>n(S)(t)},[b(x,{name:"i-uil-copy",class:"w-4 h-4 shrink-0"}),e[22]||(e[22]=f(" Copy ",-1))],8,Ze),s("button",{type:"button",class:"flex items-center gap-2.5 text-sm text-red-500 hover:text-red-600 py-1.5 transition-colors w-full",onClick:C=>_.value=t.id},[b(x,{name:"i-uil-trash-alt",class:"w-4 h-4 shrink-0"}),e[23]||(e[23]=f(" Delete ",-1))],8,Ye),s("button",et,[b(x,{name:"i-uil-brush-alt",class:"w-4 h-4 shrink-0"}),e[24]||(e[24]=f(" Work with a layout artist ",-1))])])]),!t.name||!t.positions?.length?(a(),i("div",tt,[b(x,{name:"i-heroicons-exclamation-triangle",class:"w-3.5 h-3.5 shrink-0 text-amber-500"}),s("span",null,[e[25]||(e[25]=f("This project has a configuration issue. ",-1)),s("button",{type:"button",class:"underline font-semibold hover:text-amber-900",onClick:C=>n(c)(t)},"Edit it",8,st),e[26]||(e[26]=f(" to fix before adding to cart.",-1))])])):I("",!0)]))),128))])),!n(P)&&n(h)>1?(a(),i("div",nt,[s("button",{type:"button",class:"p-2 rounded-lg text-gray-500 hover:bg-gray-100 disabled:opacity-30",disabled:n(m)===1,onClick:e[1]||(e[1]=t=>m.value--)},[b(x,{name:"i-heroicons-chevron-left",class:"w-4 h-4"})],8,ot),(a(!0),i(N,null,R(n(h),t=>(a(),i("button",{key:t,type:"button",class:ee(["w-9 h-9 rounded-lg text-sm font-medium transition-colors",t===n(m)?"bg-blue text-white":"text-gray-600 hover:bg-gray-100"]),onClick:C=>m.value=t},d(t),11,at))),128)),s("button",{type:"button",class:"p-2 rounded-lg text-gray-500 hover:bg-gray-100 disabled:opacity-30",disabled:n(m)===n(h),onClick:e[2]||(e[2]=t=>m.value++)},[b(x,{name:"i-heroicons-chevron-right",class:"w-4 h-4"})],8,it)])):I("",!0),n(_)!==null?(a(),i("div",{key:4,class:"fixed inset-0 bg-black/40 z-50 flex items-center justify-center",onClick:e[5]||(e[5]=j(t=>_.value=null,["self"]))},[s("div",lt,[e[27]||(e[27]=s("h3",{class:"text-base font-semibold text-gray-900 mb-2"},"Delete project?",-1)),e[28]||(e[28]=s("p",{class:"text-sm text-gray-500 mb-5"},"This action cannot be undone.",-1)),s("div",rt,[s("button",{type:"button",class:"px-4 py-2 text-sm rounded-lg border border-gray-200 hover:bg-gray-50",onClick:e[3]||(e[3]=t=>_.value=null)},"Cancel"),s("button",{type:"button",class:"px-4 py-2 text-sm rounded-lg bg-red-500 text-white hover:bg-red-600",onClick:e[4]||(e[4]=t=>n(J)(n(_)))},"Delete")])])])):I("",!0),n(y)?(a(),i("div",{key:5,class:"fixed inset-0 bg-black/40 z-50 flex items-center justify-center",onClick:e[10]||(e[10]=j(t=>y.value=!1,["self"]))},[s("div",dt,[e[29]||(e[29]=s("h3",{class:"text-base font-semibold text-gray-900 mb-1"},"Name your project",-1)),e[30]||(e[30]=s("p",{class:"text-sm text-gray-500 mb-4"},"Give your project a name and we'll save it to My Projects.",-1)),X(s("input",{"onUpdate:modelValue":e[6]||(e[6]=t=>Y(k)?k.value=t:null),type:"text",class:"w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue mb-4",placeholder:"Project name",onKeydown:e[7]||(e[7]=me(t=>n(k).trim()&&n(A)(),["enter"]))},null,544),[[Z,n(k)]]),s("div",ut,[s("button",{type:"button",class:"px-4 py-2 text-sm rounded-lg border border-gray-200 hover:bg-gray-50",onClick:e[8]||(e[8]=t=>y.value=!1)},"Cancel"),s("button",{type:"button",class:"px-4 py-2 text-sm rounded-lg bg-blue text-white hover:bg-blue/90 disabled:opacity-50",disabled:!n(k).trim()||n(U),onClick:e[9]||(e[9]=(...t)=>n(A)&&n(A)(...t))},d(n(U)?"Savingâ¦":"Save"),9,ct)])])])):I("",!0)])}}});
1export{bt as default};
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.