1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[896],{88833:function(e,t,a){"use strict";var i=a(83252);t.DF={prefix:i.prefix,iconName:i.iconName,icon:[i.width,i.height,i.aliases,i.unicode,i.svgPathData]},t.bk=t.DF,i.prefix,i.iconName,i.width,i.height,i.aliases,i.unicode,i.svgPathData,i.aliases},83252:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a="lock-keyhole",i=["lock-alt"],r="f30d",n="M224 32c53 0 96 43 96 96l0 64-192 0 0-64c0-53 43-96 96-96zM96 128l0 64-16 0c-44.2 0-80 35.8-80 80L0 432c0 44.2 35.8 80 80 80l288 0c44.2 0 80-35.8 80-80l0-160c0-44.2-35.8-80-80-80l-16 0 0-64C352 57.3 294.7 0 224 0S96 57.3 96 128zM80 224l288 0c26.5 0 48 21.5 48 48l0 160c0 26.5-21.5 48-48 48L80 480c-26.5 0-48-21.5-48-48l0-160c0-26.5 21.5-48 48-48zm160 88c0-8.8-7.2-16-16-16s-16 7.2-16 16l0 80c0 8.8 7.2 16 16 16s16-7.2 16-16l0-80z";t.definition={prefix:"fal",iconName:a,icon:[448,512,i,r,n]},t.faLockKeyhole=t.definition,t.prefix="fal",t.iconName=a,t.width=448,t.height=512,t.ligatures=i,t.unicode=r,t.svgPathData=n,t.aliases=i},67363:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a="cart-shopping",i=[128722,"shopping-cart"],r="f07a",n="M24 0C10.7 0 0 10.7 0 24S10.7 48 24 48l45.5 0c3.8 0 7.1 2.7 7.9 6.5l51.6 271c6.5 34 36.2 58.5 70.7 58.5L488 384c13.3 0 24-10.7 24-24s-10.7-24-24-24l-288.3 0c-11.5 0-21.4-8.2-23.6-19.5L170.7 288l288.5 0c32.6 0 61.1-21.8 69.5-53.3l41-152.3C576.6 57 557.4 32 531.1 32l-411 0C111 12.8 91.6 0 69.5 0L24 0zM131.1 80l389.6 0L482.4 222.2c-2.8 10.5-12.3 17.8-23.2 17.8l-297.6 0L131.1 80zM176 512a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm336-48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0z";t.definition={prefix:"far",iconName:a,icon:[576,512,i,r,n]},t.faCartShopping=t.definition,t.prefix="far",t.iconName=a,t.width=576,t.height=512,t.ligatures=i,t.unicode=r,t.svgPathData=n,t.aliases=i},82059:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a="credit-card",i=[128179,62083,"credit-card-alt"],r="f09d",n="M512 80c8.8 0 16 7.2 16 16l0 32L48 128l0-32c0-8.8 7.2-16 16-16l448 0zm16 144l0 192c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16l0-192 480 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l448 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm56 304c-13.3 0-24 10.7-24 24s10.7 24 24 24l48 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-48 0zm128 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l112 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-112 0z";t.definition={prefix:"far",iconName:a,icon:[576,512,i,r,n]},t.faCreditCard=t.definition,t.prefix="far",t.iconName=a,t.width=576,t.height=512,t.ligatures=i,t.unicode=r,t.svgPathData=n,t.aliases=i},53350:function(e,t,a){"use strict";var i=a(67363);t.DF={prefix:i.prefix,iconName:i.iconName,icon:[i.width,i.height,i.aliases,i.unicode,i.svgPathData]},t.sq=t.DF,i.prefix,i.iconName,i.width,i.height,i.aliases,i.unicode,i.svgPathData,i.aliases},56073:function(e,t){"use strict";t.DF={prefix:"far",iconName:"truck",icon:[640,512,[128666,9951],"f0d1","M352 48c8.8 0 16 7.2 16 16l0 288c0 8.8-7.2 16-16 16l-32 0-76.8 0c-16.6-28.7-47.6-48-83.2-48s-66.6 19.3-83.2 48L64 368c-8.8 0-16-7.2-16-16L48 64c0-8.8 7.2-16 16-16l288 0zm32 368c0 53 43 96 96 96s96-43 96-96l40 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-8 0 0-122.7c0-14.9-5.9-29.1-16.4-39.6l-93.3-93.3C487.8 101.9 473.6 96 458.7 96L416 96l0-32c0-35.3-28.7-64-64-64L64 0C28.7 0 0 28.7 0 64L0 352c0 35.3 28.7 64 64 64c0 53 43 96 96 96s96-43 96-96l64 0 32 0 24 0 8 0zM557.7 239.6c.1 .1 .3 .3 .4 .4l-142 0 0-96 42.7 0c2.1 0 4.2 .8 5.7 2.3l93.3 93.3zM112 416a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zm368-48a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"]},t.$K=t.DF},310:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/cart/import",function(){return a(163)}])},34044:function(e,t,a){"use strict";a.d(t,{Jg:function(){return buildCheckoutDataFromCart},Y8:function(){return buildCheckoutDataFromPayment},YZ:function(){return getPaymentText},rh:function(){return n}});var i=a(72578),r=a(67596);let n={customer:{fullName:"",cards:[]},summary:{totalProducts:0,totalProductsInCash:0,totalProductsInCashDiscount:0,totalItems:0,totalInCash:0,totalFreight:0,totalExtendedWarranty:0,totalMountingServices:0,totalDiscount:0,cashback:null,credit:null,isEmpty:!0,isGuideShop:!1,paymentMethodsConfig:null,totalServices:0,totalServicesByType:{}},metadata:{cartId:null,zipcode:null,couponAssigned:null,salesTeamCode:null},items:[],shippingAddress:null,paymentMethods:null,affiliate:null,posTerminals:[],errors:[]},getMappedServices=e=>e?.map(e=>r.hh[e.id]?{...e,id:r.hh[e.id]}:e),buildCheckoutDataFromCart=e=>{var t;let a=Object.fromEntries(e?.totalItemTypes?.map(e=>[e.itemType,e.total])||[]),i=e?.totalItemTypes?.find(e=>"services"===e.itemType),r=Object.fromEntries(i?.values.map(e=>[e.itemSubType,{name:e.itemSubTypeName,total:e.total,quantity:e.quantity}])||[]);return{summary:{totalProducts:a?.products??0,totalProductsInCash:a?.products_in_cash??0,totalProductsInCashDiscount:a?.products_in_cash_discount??0,totalItems:e?.total??0,totalInCash:a?.in_cash??0,totalFreight:a?.freight??0,totalExtendedWarranty:a?.extended_warranty??0,totalMountingServices:0,totalServices:a?.services??0,totalServicesByType:r,totalDiscount:a?.discount??0,cashback:null,credit:null,isEmpty:0===e.cartItems.length,isGuideShop:e?.affiliate?.guideshop===1,paymentMethodsConfig:e.paymentMethodsConfig},items:e.cartItems.map(e=>({itemType:e.itemType,productId:e?.itemId?e?.itemId:e?.productId,quantity:e.quantity,quantityByFractionalUnit:e.quantityByFractionalUnit,sellerId:e.sellerId,name:e.name,images:e.images||[],seller:e.seller,category:e.category,commercialCategory:e.commercialCategory,sku:e.sku,brand:e.brand,extendedWarrantyId:e.extendedWarrantyId,mountingServiceId:e.mountingServiceId,extendedWarranties:e.extendedWarranties||[],mountingService:e.mountingService,eligibleItems:getMappedServices(e?.eligibleItems||[])||[],price:e.price,promotional:e.promotional,unit:e.unit,fractionalUnit:e.fractionalUnit,stock:e.stock?.total,shipping:e?.shipping||[],installments:e.installments,installmentsInfo:e.installmentsInfo,parentItems:e.parentItems||[],urgencySignals:e?.urgencySignals||null,..."service"===e.itemType&&{itemSubType:e.itemSubType,serviceRefId:e.serviceRefId,serviceRefName:e.serviceRefName}})),metadata:{cartId:e.cartMetadata.cartId,zipcode:e.cartMetadata?.zipcode||"",couponAssigned:e.cartMetadata.couponAssigned,salesTeamCode:e.cartMetadata.salesTeamCode},shippingAddress:null,paymentMethods:[],affiliate:(t=e?.affiliate||null,t?.codigo_vendedor?{affiliateCode:t.codigo_vendedor,guideshopCode:t.codigo_guideshop,guideshop:t.guideshop}:null),errors:e.errors}},buildCheckoutDataFromPayment=(e,t=!1)=>{var a,r;let n=(0,i.HS)(),s=e.summary?.totalMountingServices||0,o=(a=e.summary.items,t?a.map(e=>{let t=Number(e.product.main.id);return{productId:t,quantity:e.quantity,quantityByFractionalUnit:e.quantityByFractionalUnit}}):a.map(t=>{let a=Number(t.product.main.id),i=t.warrantyId?[e.summary.extendedWarranty[t.warrantyId]]:[],r=Object.values(e.summary.freight.quotations).find(([e])=>e.skus.includes(`${a}`));return{productId:a,quantity:t.quantity,quantityByFractionalUnit:t.quantityByFractionalUnit,sellerId:t.selectedSeller.id,name:t.product.main.name,images:t.product.images.map(e=>e.zoom),seller:{id:t.selectedSeller.id,name:t.selectedSeller.name},commercialCategory:t.commercialCategory??"Sem categoria",category:{id:`${t.product.main.category.id}`,name:t.product.main.category.name,url:t.product.main.category.url},sku:t.product.buyBox[0]?.sku??null,brand:t.product.main.brand,extendedWarrantyId:t.warrantyId,mountingServiceId:t.mountingServiceId,extendedWarranties:i,mountingService:t.mountingServiceId?{serviceSku:t.mountingServiceId,sku:a}:null,price:t.price,promotional:t.incashPrice,unit:t.product.buyBox[0].unit,fractionalUnit:t.product.buyBox[0].fractionalUnit,stock:t.product.buyBox[0].stock.total,shipping:r,installments:t.product.buyBox[0].installments??[],installmentsInfo:t.product.buyBox[0].installmentsInfo??null,itemType:t.itemType,parentItems:t.parentItems||[],eligibleItems:getMappedServices(t?.eligibleItems||[])||[],itemSubType:t.itemSubType,serviceRefId:t.serviceRefId,serviceRefName:t.serviceRefName,urgencySignals:null}})),c=e?.summary?.totalItemTypes?.find?.(e=>"services"===e.itemType),d=Object.fromEntries(c?.values?.reduce((e,t)=>
1(e.push([t.itemSubType,{name:t.itemSubTypeName,total:t.total,quantity:t.quantity}]),e),[])||[]);return{customer:e.customer,summary:{totalProducts:e.summary.totalProducts-s,totalProductsInCash:e.summary.totalProductsInCash-s,totalProductsInCashDiscount:e.summary.totalProductsInCashDiscount,totalItems:e.summary.total,totalInCash:e.summary.totalInCash,totalFreight:e.summary.totalFreight,totalExtendedWarranty:e.summary.totalExtendedWarranty,totalMountingServices:s,totalDiscount:e.summary.totalDiscount,cashback:{...e.summary.cashback,assigned:e.summary?.cashbackAssigned||0},credit:{...e.summary.credit,assigned:e.summary?.creditAssigned||0},isEmpty:0===e.summary.items.length,isGuideShop:n,paymentMethodsConfig:e.paymentMethodsConfig,totalServices:0,totalServicesByType:d},items:o,metadata:{cartId:e.summary.cbid,zipcode:e.summary?.freight?.zipcode||"",couponAssigned:e.summary?.coupon?.code||"",salesTeamCode:e.summary?.affiliate?.code||"",paymentSlipExpirationDate:e.settings?.paymentSlipExpirationDate||""},shippingAddress:e.shippingAddress,paymentMethods:e.paymentMethods.map(e=>({...e,methods:e?.methods||[]})),affiliate:(r=e.summary?.affiliate||null,r?.code?{affiliateCode:r.code,guideshopCode:r.codeGuideshop,guideshop:r.guideshop}:null),posTerminals:e.posTerminals,errors:[]}},getPaymentText=(e,t)=>
10===t?"":e?e.name:null},46973:function(e,t,a){"use strict";a.d(t,{$T:function(){return trackIndividualServicePurchase},OS:function(){return trackIndividualServicePageView},ub:function(){return trackIndividualServiceSteps}});var i=a(59016),r=a(35113);function trackIndividualServiceSteps(e){(0,i.Z)(r.V.IndividualServicesStep,e)}function trackIndividualServicePageView(e){(0,i.Z)(r.V.IndividualServicesPageView,e)}function trackIndividualServicePurchase(e){(0,i.Z)(r.V.IndividualServicesPurchase,e)}},65305:function(e,t,a){"use strict";var i=a(21860),r=a(2582);t.Z=function(e=new Date){return(0,r.b)((0,i.E)(e,2))}},163:function(e,t,a){"use strict";a.r(t),a.d(t,{__N_SSP:function(){return M},default:function(){return CartImport}});var i=a(85893),r=a(84107),n=a(32805),s=a(33299),o=a(67294),c=a(34356),d=a(65109),l=a(44118),u=a(34044),m=a(24388),p=a(5677),f=a(46973),h=a(16909),y=a(34325),g=a(44930);let I={WHATSAPP_AGENT:"Whatsapp Agent",CHATGPT_MCP:"MCP - ChatGPT"};function trackCartImportOrigin({source:e,zipcode:t,serviceItems:a,productItems:i}){if(a.length>0){let e=a.map(e=>e.serviceRefName||e.name),i=[...new Set(e)],r=a.reduce((e,t)=>e+(t?.price??0),0);(0,f.ub)({interaction_step:"schedule_completed",interaction_service_type:(0,h.w5)(i[0]),interaction_zipcode:t,interaction_furniture_count:`${a.length}`,interaction_service_sku:a.map(e=>e.productId).join("|"),interaction_furniture_type:e.join("|"),interaction_furniture_condition:Array(a.length).fill("new").join("|"),...r>0&&{interaction_service_subtotal:(0,g.Z)(r)}})}i.forEach(t=>{(0,y.jC)({pageType:"",source:e,productId:t.productId})}),a.forEach(t=>{(0,y._8)({pageType:"",source:e,itemId:t.productId,productId:t.parentItems?.[0]?.itemId||null})});let r=(0,h.N4)(i)||[],n=(0,h.cQ)(a)||[],s=[...r,...n].map(t=>({...t,product_origin:e}));s.length>0&&(0,p.ch)({source:e,products:s})}var v=a(29625),_=a(72578),S=a(95646),C=a(49315),b=a(50462),P=a(2582),T=a(65305),platServ_validateImportedSchedule=function({schedule:e,now:t=new Date}){if("string"!=typeof e?.when_date||!e.when_date)return{isValid:!1,reason:"invalid-date"};let a=(0,P.b)((0,b.D)(e.when_date));return Number.isNaN(a.getTime())?{isValid:!1,reason:"invalid-date"}:(0,C.A)(a,(0,T.Z)(t))?{isValid:!0}:{isValid:!1,reason:"min-lead-time"}},N=a(55812);async function fetchCartImportServerless(e){let t=await fetch("/api/cart/cart-import",{method:"POST",body:JSON.stringify(e)});return t.json()}var w=a(46413),x=a(1209),k=a(67066);let firstParam=e=>Array.isArray(e)?e[0]:e;var CartImportPage_CartImportPage=function({queryParams:e}){let[t,a]=(0,o.useState)(!0),[r,n]=(0,o.useState)("Importando carrinho, aguarde..."),{sessionId:p}=(0,m.cm)(),{executeSessionRequest:f}=(0,N.I)(),{data:h,status:y}=(0,s.useSession)(),handleDestroyZipCodeCookie=()=>{(0,_.qj)(v.ff),(0,_.qj)(v.K3)};return(0,o.useEffect)(()=>{let loadBudgetHandler=async()=>{if("loading"!==y&&p){let t;let i=Number(h?.customer_id||0);handleDestroyZipCodeCookie();let r=await f(()=>fetchCartImportServerless({customerId:i,...e}));if(!r)return;if((0,S.oi)(r)){a(!1),n(r.message||"Houve um erro ao importar o seu carrinho.");return}let s=!1,o="",c=!1,d=await f(()=>(0,w.VV)());if((0,S.q_)(d)&&d.data){let a=d.data.cartMetadata?.salesTeamCode,i=(0,u.Jg)(d.data),r=i.items.filter(e=>"service"===e.itemType),n=i.items.filter(e=>"product"===e.itemType),l=firstParam(e.productDescription),m=firstParam(e.scheduleDate),p=firstParam(e.scheduleStart),h=firstParam(e.scheduleEnd),y=firstParam(e.mainOrderId),g=firstParam(e.mainOrderItemId),_=m&&p&&h?{when_date:m,when_time_start:p,when_time_end:h}:null,C=d.data.cartMetadata?.zipcode||"";t=r[0]?.serviceRefId;let b=r.filter(e=>e.serviceRefId===r[0]?.serviceRefId),P=b.map(e=>Number(e.productId)),shouldWriteSchedule=e=>!c||P.includes(e);o=b.map(e=>e.productId).join(",");let T=_;if(_&&r.length>0){c=!0;let e=platServ_validateImportedSchedule({schedule:_});T=e.isValid?_:null,s=!e.isValid}if(r.length>0)try{let e=await f(()=>(0,x.r)());if((0,S.q_)(e)&&e.data?.metadata){let t=e.data.metadata,a=r.map(e=>Number(e.productId)),i=(t.items||[]).map(e=>e.sellerId===v.G5&&a.includes(e.itemId)?{...e,...l&&{extra_info:l},..._&&shouldWriteSchedule(e.itemId)&&{schedule:T},...y&&{main_order_id:y},...g&&{main_order_item_id:g}}:e),n=(t.items||[]).map(e=>e.itemId),s=r.filter(e=>!n.includes(Number(e.productId))).map(e=>({itemId:Number(e.productId),sellerId:v.G5,...shouldWriteSchedule(Number(e.productId))&&{schedule:T},extra_info:l||"",...y&&{main_order_id:y},...g&&{main_order_item_id:g}}));await (0,k.HP)({metadata:{items:[...i,...s]}})}else if(r.length>0){let e=r.map(e=>({itemId:Number(e.productId),sellerId:v.G5,...shouldWriteSchedule(Number(e.productId))&&{schedule:T},extra_info:l||"",...y&&{main_order_id:y},...g&&{main_order_item_id:g}}));await (0,k.HP)({metadata:{items:e}})}}catch(e){console.error("Erro ao atualizar metadados dos servi\xe7os:",e)}"PME02"===a&&trackCartImportOrigin({source:I.WHATSAPP_AGENT,zipcode:C,serviceItems:r,productItems:n}),"chatgpt"===e.utm_source&&trackCartImportOrigin({source:I.CHATGPT_MCP,zipcode:C,serviceItems:r,productItems:n})}if(s&&t&&o){window.location.href=`/carrinho/agendar?itens=${o}&servico=${t}`;return}r.data?.redirectUrl&&(window.location.href=r.data.redirectUrl)}};loadBudgetHandler()},[y,p]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l.Z,{align:"center",asBlock:"true",children:r}),t&&(0,i.jsx)(c.Z,{justifyContent:"center",css:{mt:"$medium1"},children:(0,i.jsx)(d.default,{})})]})},M=!0;function CartImport({seo:e,canonical:t,queryParams:a}){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.Z,{title:e.title,de
1scription:e.description,canonical:t}),(0,i.jsx)(CartImportPage_CartImportPage,{queryParams:a})]})}CartImport.Layout=n.Z,CartImport.displayName="CartImport"},46413:function(e,t,a){"use strict";a.d(t,{EN:function(){return fetchGetCartToFinancing},VV:function(){return fetchGetCartServerless}});var i=a(95646);async function fetchGetCartServerless(){let e=await fetch("/api/cart",{method:"GET"});return e.json()}async function fetchGetCartToFinancing(){let e=await fetchGetCartServerless();if(!(0,i.q_)(e))return null;let t=[];0!==e.data.cartItems.length&&e.data.cartItems.forEach(e=>{let a={amount:e.quantity,id:e.itemId.toString(),name:e.name,value:e.price,discount:0,sellerId:e.sellerId,brand:e.brand};t.push(a)});let a=Object.fromEntries(e.data?.totalItemTypes?.map(e=>[e.itemType,e.total])||[]),r=a?.extended_warranty??0;return r>0&&t.push({amount:1,id:"ges",name:"Garantia estendida",value:r,discount:0}),{products:t,discount:a?.discount??0,shipping:a?.freight??0,salesTeamCode:e.data.cartMetadata.salesTeamCode}}},1209:function(e,t,a){"use strict";async function fetchGetSessionServerless(){let e=await fetch("/api/session",{method:"GET"});return e.json()}a.d(t,{r:function(){return fetchGetSessionServerless}})},67066:function(e,t,a){"use strict";async function fetchUpdateMetadataServerless(e){let t=await fetch("/api/session/metadata",{method:"PUT",body:JSON.stringify(e)});return t.json()}a.d(t,{HP:function(){return fetchUpdateMetadataServerless}})},35113:function(e,t,a){"use strict";var i,r;a.d(t,{V:function(){return i}}),(r=i||(i={})).IndividualServicesStep="individual_services_step",r.ServicesSelection="services_selection",r.IndividualServicesPageView="individual_services_page_view",r.IndividualServicesPurchase="individual_services_purchase"},90274:function(e){e.exports={style:{fontFamily:"'__Inter_0d3b9f', '__Inter_Fallback_0d3b9f', sans-serif",fontStyle:"normal"},className:"__className_0d3b9f"}},49315:function(e,t,a){"use strict";a.d(t,{A:function(){return isAfter}});var i=a(32612);function isAfter(e,t){return+(0,i.Q)(e)>+(0,i.Q)(t)}}},function(e){e.O(0,[4904,431,1038,1852,5254,2962,6799,3751,2758,8207,2663,6701,2007,5677,5631,9625,1902,4640,9774,2888,179],function(){return e(e.s=310)}),_N_E=e.O()}]); 2//# sourceMappingURL=import-82193279ae817353.js.map
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.