"use strict";exports.id=5278,exports.ids=[5278],exports.modules={35278:(e,t,a)=>{a.d(t,{findOrCreateCustomer:()=>i,updateCustomerMetrics:()=>n});var r=a(8194);async function i(e,t,a,i){if(!t||0===t.trim().length)return null;let n=t.trim(),d=await r._.customer.findFirst({where:{tenantId:e,phone:n}});if(d)return(!d.isActive||a&&a!==d.name)&&(d=await r._.customer.update({where:{id:d.id},data:{isActive:!0,...a?{name:a}:{},...i&&!d.email?{email:i}:{}}})),{id:d.id,name:d.name,phone:d.phone};let s=await r._.customer.create({data:{tenantId:e,name:a||n,phone:n,...i?{email:i}:{}}});return{id:s.id,name:s.name,phone:s.phone}}async function n(e,t){await r._.customer.update({where:{id:e},data:{totalOrders:{increment:1},totalSpent:{increment:t},lastOrderAt:new Date}})}}};