PageSourceSearch

https://www.supermercadoero.com.br/_next/static/chunks/2132-8264cb1c4758ba8b.js

js supermercadoero.com.br collected 2026-10-02 01:18:53 UTC 55,212 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="418ca695-2829-4c46-9ec9-8d4914f1f23a",e._sentryDebugIdIdentifier="sentry-dbid-418ca695-2829-4c46-9ec9-8d4914f1f23a")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2132],{9698:(e,t,a)=>{a.d(t,{Z:()=>n});var r=a(12115),s=a(51244),o=a(25093);function n(){var e;let{isAuthenticated:t}=(0,s.A)(),a=(0,o.V)(),n=(0,r.useRef)(!1),i=(0,r.useRef)(null);return(0,r.useEffect)(()=>{var e;let r=null==a||null==(e=a.empresa)?void 0:e.empr_id;if(!t){n.current=!1,i.current=null;return}if(!r)return;let s=null===i.current,o=i.current!==r;if(s){i.current=r,n.current=!0;return}o&&(document.dispatchEvent(new CustomEvent("cartSync",{detail:{companyId:r}})),i.current=r,n.current=!0)},[t,null==a||null==(e=a.empresa)?void 0:e.empr_id]),{}}},14096:(e,t,a)=>{a.d(t,{A:()=>n});var r=a(95155),s=a(27937),o=a(20063);function n(e){let{taxonomia:t}=e,a=(0,o.useRouter)();return(0,r.jsxs)("nav",{className:"flex items-center space-x-2 text-sm text-gray-600 mb-6",children:[(0,r.jsx)("button",{onClick:()=>{let e=new URLSearchParams;e.append("departamento_id",t.departamento.dpto_id.toString()),a.push("/busca?".concat(e.toString()))},className:"hover:text-green-600 cursor-pointer transition-colors focus:outline-none",children:t.departamento.dpto_descricao}),(0,r.jsx)(s.A,{className:"h-4 w-4 text-gray-400"}),(0,r.jsx)("button",{onClick:()=>{let e=new URLSearchParams;e.append("departamento_id",t.departamento.dpto_id.toString()),e.append("grupo_id",t.grupo.grup_id.toString()),a.push("/busca?".concat(e.toString()))},className:"hover:text-green-600 cursor-pointer transition-colors focus:outline-none",children:t.grupo.grup_descricao}),(0,r.jsx)(s.A,{className:"h-4 w-4 text-gray-400"}),(0,r.jsx)("button",{onClick:()=>{let e=new URLSearchParams;e.append("departamento_id",t.departamento.dpto_id.toString()),e.append("grupo_id",t.grupo.grup_id.toString()),e.append("subgrupo_id",t.subgrupo.sgru_id.toString()),a.push("/busca?".concat(e.toString()))},className:"text-gray-900 font-medium hover:text-green-600 cursor-pointer transition-colors focus:outline-none",children:t.subgrupo.sgru_descricao})]})}},19988:(e,t,a)=>{a.d(t,{J:()=>o,y:()=>n});let r=e=>(null==e?void 0:e.valor)==null||""===String(e.valor).trim()?"":"".concat(e.moeda||"R$"," ").concat(e.valor),s=e=>{let t=Number(e);return!Number.isFinite(t)||t<=0?"":"R$ ".concat(t.toFixed(2).replace(".",","))};function o(e){var t,a,r,s,o,n,i,l,d;let c=null==(a=e.parametros)||null==(t=a.prap_tipo_seletor)?void 0:t.toUpperCase(),u="PE"===c||"AM"===c||(null==(s=e.dados)||null==(r=s.embalagem)?void 0:r.toLowerCase().includes("fracionado"))||(null==(n=e.embalagem)||null==(o=n.emb_descricao)?void 0:o.toLowerCase().includes("fracionado"))?(null==(i=e.parametros)?void 0:i.fracao_descricao)||(null==(l=e.dados)?void 0:l.fracao):null==(d=e.embalagem)?void 0:d.emb_abreviacao;return(null==u?void 0:u.trim())||""}function n(e,t,a){var n,i,l,d,c,u,m,p,x;let g=null==(n=e.dados)?void 0:n.preco,h=r(null==g?void 0:g.preco_atual)||s(null==(i=e.preco)?void 0:i.prva_preco_oferta)||s(null==(l=e.preco)?void 0:l.prva_prod_preco),f=r(null==g?void 0:g.preco_anterior),b=(null==(c=e.dados)||null==(d=c.area_inferior_direito_2)?void 0:d.tipo)==="texto"?null==(u=e.dados.area_inferior_direito_2.conteudo)?void 0:u.trim():"",y=o(e),v=r(null==g?void 0:g.preco_do_kg);return[a||(null==(m=e.produto)?void 0:m.prod_descricao)||(null==(p=e.dados)?void 0:p.descricao),(null==(x=e.dados)?void 0:x.qtde_max_por_pedido)?"M\xe1x. ".concat(e.dados.qtde_max_por_pedido," por pedido"):"",f&&b?"".concat(f," — ").concat(b):f||b,h?"".concat(h).concat(y?"/".concat(y.toLowerCase()):""):"",v?"Pre\xe7o por 1kg ".concat(v):"",t].filter(Boolean).join("\n")}},22627:(e,t,a)=>{a.d(t,{A:()=>i});var r=a(95155),s=a(12115),o=a(10512),n=a(85843);function i(e){let{selectorType:t,ctaContent:a,fractionQuestion:i,onChange:l,isInCart:d=!1}
1=e,[c,u]=(0,s.useState)(void 0),m=e=>{e!==c&&(u(e),l(e))},p=null==a?void 0:a.find(e=>e.toLowerCase().includes("unidade")),x=null==a?void 0:a.find(e=>/gr|kg/i.test(e));return p||x?(0,r.jsxs)("div",{className:"absolute z-20 bottom-10 w-40 bg-white rounded-lg shadow-xl flex flex-col py-2 border border-gray-200",children:[(0,r.jsx)("div",{className:"text-xs text-gray-500 px-3 pb-1",children:i}),p&&(0,r.jsxs)("button",{onClick:e=>{e.stopPropagation(),m(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md transition-colors hover:bg-gray-100 ".concat(!1===c?"bg-green-50 text-green-700":"text-gray-700"),children:[(0,r.jsx)(o.A,{className:"w-4 h-4"}),p]}),x&&(0,r.jsxs)("button",{onClick:e=>{e.stopPropagation(),m(!0)},className:"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md transition-colors hover:bg-gray-100 ".concat(p?"mt-1":""," ").concat(!0===c?"bg-green-50 text-green-700":"text-gray-700"),children:[(0,r.jsx)(n.A,{className:"w-4 h-4"}),x]})]}):null}},22746:(e,t,a)=>{a.d(t,{W:()=>o,d:()=>n});var r=a(25959);let s={show:!1,message:"",type:"success"},o=(0,r.v)(e=>({state:s,actions:{show:t=>e(()=>({state:{...t}})),hide:()=>e(e=>({state:{...e.state,show:!1}}))}}));function n(){let e=o(e=>e.state),t=o(e=>e.actions.show);return{toast:e,setToast:e=>{if("function"==typeof e)return void t(e(o.getState().state));t(e)},hide:o(e=>e.actions.hide)}}},22784:(e,t,a)=>{a.d(t,{S:()=>n,c:()=>o});var r=a(25959);let s={intent:null},o=(0,r.v)(e=>({state:s,actions:{setIntent:(t,a)=>e(()=>({state:{intent:{type:t,data:a}}})),clearIntent:()=>e(()=>({state:s}))}}));function n(e){let t=o(e=>e.state.intent);return t&&(Array.isArray(e)?e:[e]).includes(t.type)?t:null}},29133:(e,t,a)=>{a.d(t,{A:()=>y});var r=a(95155),s=a(12115),o=a(47650),n=a(60952),i=a(65229),l=a(86651),d=a(23327),c=a(35299),u=a(6191),m=a(5917),p=a(99776),x=a(53455),g=a(80549),h=a(89950),f=a(96165),b=a(35223);function y(e){var t;let{isOpen:a,onClose:m,product:y,primaryColor:j,onToast:w,onProductAdded:N}=e,k=(0,p.jE)(),[C,_]=(0,s.useState)(!1),[A,S]=(0,s.useState)(""),[E,I]=(0,s.useState)(""),[L,z]=(0,s.useState)(!1),[P,q]=(0,s.useState)(null),{description:T,barcode:F}=function(e){var t,a,r;let s=e.id||e.prod_id||(null==(t=e.dados)?void 0:t.produto_id)||(null==(a=e.produto)?void 0:a.prod_id)||0;return{id:s,description:e.description||e.descricao||e.name||"Produto",barcode:e.codBarras||e.codigoBarras||e.codigo_barras||(null==(r=e.dados)?void 0:r.codigo_barras)||""}}(y),M=null==(t=y.observacao)?void 0:t.trim(),{data:B,isLoading:D}=(0,x.I)({...h.T.lists({codigoBarras:F||void 0}),enabled:a}),R=(0,s.useMemo)(()=>{var e,t;return(null!=(t=null==B||null==(e=B.success)?void 0:e.listas)?t:[]).map(e=>{var t;return{id:e.id,descricao:e.lico_descricao,quantidadeItens:null!=(t=e.lico_qtde_itens)?t:0}})},[B]),Q=(0,s.useMemo)(()=>{var e,t;return null!=(t=null==B||null==(e=B.success)?void 0:e.disponibilidade_produto)?t:[]},[B]);(0,s.useEffect)(()=>{a&&1===Q.length&&null===P&&q(Q[0])},[Q,a,P]);let O=(0,g.n)({...h.V.createList,onSuccess:()=>k.invalidateQueries({queryKey:["shopping-lists"]})});(0,s.useEffect)(()=>(z(!0),a&&(document.body.style.overflow="hidden"),()=>{document.body.style.overflow="unset"}),[a]);let V=(0,s.useMemo)(()=>{if(!E.trim())return R;let e=E.toLowerCase();return R.filter(t=>t.descricao.toLowerCase().includes(e))},[R,E]);if(!a||!L)return null;let K=async()=>{A.trim()&&(await O.mutateAsync({descricao:A}),_(!1),S(""))};return null!==P?(0,r.jsx)(b.A,{isOpen:a,onClose:()=>{q(null),m()},initialListId:P,focusProductBarcode:F,initialObservation:M}):(0,o.createPortal)((0,r.jsxs)("div",{className:"fixed inset-0 z-[1000] flex items-end sm:items-center justify-center sm:p-4",onClick:e=>e.stopPropagation(),style:{isolation:"isolate"},children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:e=>{e.stopPropagation(),m()}}),(0,r.jsxs)("div",{className:"relative w-full max-w-md bg-white rounded-t-2xl sm:rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[80vh] z-[50]",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"px-5 py-4 border-b flex items-center justify-between bg-gray-50 shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"p-2 rounded-lg",style:{backgroundColor:"".concat(j,"15")},children:(0,r.jsx)(n.A,{size:20,style:{color:j}})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"font-bold text-gray-900 leading-tight",children:"Adicionar \xe0 lista"}),(0,r.jsx)("p",{className:"text-xs text-gray-500 truncate max-w-[200px]",children:T})]})]}),(0,r.jsx)("button",{onClick:m,className:"p-2 hover:bg-gray-200 rounded-full text-gray-500",children:(0,r.jsx)(i.A,{size:20})})]}),(0,r.jsxs)("div",{className:"px-5 py-3 bg-white border-b border-gray-100 shrink-0 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 bg-gray-50 border border-gray-200 rounded-xl px-3 py-2 focus-within:ring-2 focus-within:ring-opacity-50 transition-all",style:{"--tw-ring-color":j},children:[(0,r.jsx)(l.A,{className:"w-4 h-4 text-gray-400"}),(0,r.jsx)("input",{value:E,onChange:e=>I(e.target.value),placeholder:"Buscar lista...",className:"flex-1 outline-none text-sm bg-transparent min-w-0",autoFocus:!0}),E&&(0,r.jsx)("button",{onClick:()=>I(""),className:"text-gray-400 hover:text-gray-600",children:(0,r.jsx)(i.A,{size:14})})]}),(0,r.jsxs)("div",{className:"flex items-start gap-2 px-1",children:[(0,r.jsx)(d.A,{className:"w-3.5 h-3.5 text-gray-400 mt-0.5 shrink-0"}),(0,r.jsx)("p",{className:"text-xs text-gray-500 font-medium leading-tight",children:R.length>0?Q.length>0?"Listas marcadas abrem o produto; as demais adicionam o item.":"Clique em uma lista para adicionar este item.":"Crie sua primeira lista para adicionar este item."})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1 scrollbar-thin scrollbar-thumb-gray-300",children:D?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 text-gray-400",children:[(0,r.jsx)(c.A,{className:"animate-spin mb
1-2",size:24}),(0,r.jsx)("span",{className:"text-xs",children:"Carregando listas..."})]}):0===V.length?(0,r.jsxs)("div",{className:"text-center py-8 px-4",children:[(0,r.jsx)("div",{className:"bg-gray-50 p-3 rounded-full inline-block mb-3",children:(0,r.jsx)(l.A,{className:"text-gray-300",size:24})}),(0,r.jsx)("p",{className:"text-gray-500 text-sm mb-4",children:E?'Nenhuma lista encontrada com "'.concat(E,'"'):"Voc\xea n\xe3o tem listas criadas."}),!E&&(0,r.jsx)("button",{onClick:()=>_(!0),className:"text-sm font-bold underline",style:{color:j},children:"Criar minha primeira lista"})]}):V.map(e=>(0,r.jsx)(v,{list:e,barcode:F,primaryColor:j,isChecked:Q.includes(e.id),onToast:w,observation:M,onProductAdded:N,onOpenExistingList:()=>q(e.id)},e.id))}),(0,r.jsx)("div",{className:"p-3 border-t bg-gray-50 shrink-0",children:(0,r.jsxs)("button",{onClick:()=>_(!0),className:"w-full py-3 border-2 border-dashed border-gray-300 rounded-xl flex items-center justify-center gap-2 text-gray-600 font-semibold hover:border-gray-400 hover:bg-gray-100 transition-all active:scale-[0.99]",children:[(0,r.jsx)(u.A,{size:18}),"Criar nova lista"]})})]}),(0,r.jsx)(f.A,{isOpen:C,onClose:()=>_(!1),onConfirm:K,value:A,onChange:S,isLoading:O.isPending,primaryColor:j})]}),document.body)}function v(e){let{list:t,barcode:a,primaryColor:s,isChecked:o,onToast:n,observation:i,onProductAdded:l,onOpenExistingList:d}=e,u=(0,p.jE)(),x=(e,t)=>{u.setQueryData(["shopping-lists",a||null],a=>{var r,s;if(!(null==a||null==(r=a.success)?void 0:r.listas))return a;let o=null!=(s=a.success.disponibilidade_produto)?s:[],n=t>0?Array.from(new Set([...o,e])):o.filter(t=>t!==e);return{...a,success:{...a.success,listas:a.success.listas.map(a=>{var r;return a.id===e?{...a,lico_qtde_itens:Math.max(0,(null!=(r=a.lico_qtde_itens)?r:0)+t)}:a}),disponibilidade_produto:n}}}),u.invalidateQueries({queryKey:["shopping-lists"]}
1),u.invalidateQueries({queryKey:["shopping-list-products",e]})},f=(0,g.n)({...h.V.addProduct,onSuccess:(e,a)=>{x(a.listaId,1),n({show:!0,message:"Produto adicionado a ".concat(t.descricao),type:"success"}),null==l||l()},onError:()=>{n({show:!0,message:"Erro ao adicionar produto \xe0 lista.",type:"error"})}}),b=(0,g.n)({...h.V.deleteProduct,onSuccess:(e,a)=>{x(a.listaId,-1),n({show:!0,message:"Produto removido de ".concat(t.descricao),type:"success"})},onError:()=>{n({show:!0,message:"Erro ao remover produto da lista.",type:"error"})}}),y=f.isPending||b.isPending,v=async e=>{if(e.stopPropagation(),!y&&a)if(o){if(d)return void d();try{var r,s;let e=await u.fetchQuery(h.T.products({listaId:t.id})),o=(null!=(s=null==e||null==(r=e.success)?void 0:r.itens)?s:[]).find(e=>e.codigo_barras===a);if(!(null==o?void 0:o.id))return void n({show:!0,message:"Item n\xe3o encontrado na lista.",type:"warning"});b.mutate({listaId:t.id,produtoId:o.id})}catch(e){n({show:!0,message:"Erro ao localizar item na lista.",type:"error"})}}else f.mutate({listaId:t.id,codigo_barras:a,quantidade:1,observacao:i})};return(0,r.jsxs)("div",{onClick:v,className:"group flex items-center justify-between p-3 rounded-xl border cursor-pointer transition-all select-none ".concat(o?"bg-green-50 border-green-200":"bg-white border-gray-100 hover:border-gray-300 hover:shadow-sm"),children:[(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"font-bold text-sm ".concat(o?"text-green-800":"text-gray-700"),children:t.descricao}),(0,r.jsxs)("span",{className:"text-[10px] text-gray-500",children:[t.quantidadeItens||0," itens"]})]}),(0,r.jsx)("div",{className:"relative flex items-center justify-center h-6 w-6",children:y?(0,r.jsx)(c.A,{className:"animate-spin text-gray-400",size:18}):(0,r.jsx)("div",{className:"w-6 h-6 rounded-md border flex items-center justify-center transition-all ".concat(o?"border-transparent text-white":"border-gray-300 bg-white group-hover:border-gray-400"),style:{backgroundColor:o?s:void 0},children:o&&(0,r.jsx)(m.A,{size:14,strokeWidth:3})})})]})}},35223:(e,t,a)=>{a.d(t,{A:()=>P});var r=a(95155),s=a(12115),o=a(47650),n=a(7125),i=a(6191),l=a(23540),d=a(61194),c=a(59e3),u=a(71360),m=a(90368),p=a(60952),x=a(65229),g=a(86651),h=a(35299),f=a(10512),b=a(99776),y=a(53455),v=a(80549),j=a(89950),w=a(84138),N=a(28412),k=a(27937),C=a(5917),_=a(18514);let A=e=>{let{name:t,itemsCount:a,onClick:o,onRename:n,onDelete:i}
1=e,[l,d]=(0,s.useState)(!1),[c,m]=(0,s.useState)(t),[g,f]=(0,s.useState)(!1),[b,y]=(0,s.useState)(!1),[v,j]=(0,s.useState)(!1),w=null!=a?a:0;(0,s.useEffect)(()=>{m(t)},[t]);let N=e=>{e.stopPropagation()},A=e=>{e&&N(e),m(t),d(!1)},S=async e=>{e&&N(e);let a=c.trim();if(!a||a===t){m(t),d(!1);return}f(!0),d(!1);try{await n(a),m(a)}catch(e){d(!0)}finally{f(!1)}};return(0,r.jsxs)("div",{onClick:()=>{g||o()},role:"button",tabIndex:0,"aria-busy":g,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),onKeyDown:e=>{g||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o())},className:" group relative mb-0 w-full flex flex-row items-center gap-3 rounded-xl border bg-[#f7f8fa] p-3.5 transition-all hover:shadow-md active:scale-[0.99] cursor-pointer aria-busy:cursor-wait md:mb-3 md:flex-col md:items-stretch md:bg-white md:p-4 md:shadow-sm ",style:{borderColor:b?"var(--primary, #16a34a)":"#e5e7eb"},children:[(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3 md:w-full md:items-start",children:[(0,r.jsx)("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-full bg-white transition-colors md:mt-0.5 md:size-10 md:rounded-lg",style:{background:"color-mix(in srgb, var(--primary, #16a34a), white 90%)"},children:(0,r.jsx)(p.A,{className:"size-[22px] md:size-5",style:{color:"var(--primary, #16a34a)"}})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 md:pt-1",children:[l?(0,r.jsx)("input",{autoFocus:!0,value:c,onChange:e=>m(e.target.value),disabled:g,onClick:e=>N(e),onKeyDown:e=>{" "===e.key&&e.stopPropagation(),"Enter"===e.key&&S(),"Escape"!==e.key||g||A()},className:" w-full text-base font-bold text-gray-900 border rounded-md px-2 py-1 -ml-2 focus:outline-none focus:ring-2 ",style:{"--tw-ring-color":"var(--primary, #16a34a)"}}):(0,r.jsx)("h3",{className:"truncate text-[15px] font-bold leading-tight text-gray-900 md:text-base",children:c}),g&&(0,r.jsxs)("span",{className:"mt-1.5 flex items-center gap-1.5 text-xs font-semibold",style:{color:"var(--primary, #16a34a)"},children:[(0,r.jsx)(h.A,{className:"size-3.5 animate-spin"}),"Salvando..."]}),!l&&!g&&(0,r.jsxs)("span",{className:"mt-1.5 inline-flex rounded-full bg-white px-2.5 py-1 text-xs font-medium text-gray-500 md:hidden",children:[w," ",1===w?"item":"itens"]})]}),!l&&(0,r.jsx)(k.A,{className:"hidden h-5 w-5 text-gray-300 transition-transform group-hover:translate-x-0.5 md:block"})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center justify-between md:w-full",children:[(0,r.jsxs)("span",{className:"hidden rounded-full bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-500 md:inline-flex",children:[w," ",1===w?"item":"itens"]}),(0,r.jsx)("div",{className:"flex items-center gap-1",onClick:N,children:g?(0,r.jsx)("span",{className:"flex size-9 items-center justify-center rounded-lg",style:{color:"var(--primary, #16a34a)",backgroundColor:"color-mix(in srgb, var(--primary, #16a34a), white 90%)"},"aria-label":"Salvando nome da lista",children:(0,r.jsx)(h.A,{className:"size-5 animate-spin"})}):l?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:e=>void S(e),className:"rounded-lg p-1.5 transition-colors",title:"Salvar",style:{color:"var(--primary, #16a34a)",backgroundColor:"color-mix(in srgb, var(--primary, #16a34a), white 90%)"},children:(0,r.jsx)(C.A,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:A,className:"p-1.5 rounded-lg bg-red-50 text-red-500 hover:bg-red-100 transition-colors",title:"Cancelar",children:(0,r.jsx)(x.A,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:e=>{N(e),g||d(!0)},onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),className:"p-1.5 rounded-lg text-gray-400 transition-colors hover:bg-gray-100",title:"Renomear",style:{color:v?"var(--primary, #16a34a)":"",backgroundColor:v?"color-mix(in srgb, var(--primary, #16a34a), white 90%)":""},children:(0,r.jsx)(_.A,{className:"size-5 md:size-4"})}),i&&(0,r.jsx)("button",{onClick:e=>{N(e),null==i||i()},className:"p-1.5 rounded-lg text-gray-400 hover:bg-red-50 hover:text-red-500 transition-colors",title:"Excluir",children:(0,r.jsx)(u.A,{className:"size-5 md:size-4"})})]})})]})]})};var S=a(52772),E=a(96165),I=a(46781);let L=e=>
1{let{item:t,primaryColor:a,onUpdate:o,stepKg:l}=e,[d,c]=(0,s.useState)(!1),[u,m]=(0,s.useState)(""),p=(0,s.useRef)(null),x="boolean"==typeof t.item_fracionado?t.item_fracionado:"boolean"==typeof t.fracionado?t.fracionado:void 0,g="boolean"==typeof x?x:"string"==typeof t.quantidade_formatada&&/(kg|gr)/i.test(t.quantidade_formatada),h="number"==typeof l&&l>0?l:parseFloat(t.fracao)||1;return(0,s.useEffect)(()=>{d||(g?m(function(e){let t=Math.round(1e3*e);if(t<1e3)return"".concat(t,"g");let a=Math.floor(t/1e3),r=t%1e3;if(0===r)return"".concat(a,"kg");let s=String(r).padStart(3,"0").replace(/0+$/,"");return"".concat(a,",").concat(s,"kg")}(t.quantidade*h)):m(t.quantidade+"un"))},[t.quantidade,d,g,h]),(0,r.jsxs)("div",{className:"flex items-center border border-gray-200 rounded-lg bg-gray-50 shadow-sm overflow-hidden h-10 w-full max-w-[300px]",children:[(0,r.jsx)("button",{className:"w-10 h-full flex items-center justify-center hover:bg-white text-gray-500 border-r border-gray-100 transition-colors active:bg-gray-100 z-10",onClick:e=>{e.stopPropagation();let a=t.quantidade-1;a>=1&&o(a)},children:(0,r.jsx)(n.A,{size:16,strokeWidth:3})}),(0,r.jsx)("input",{ref:p,type:"text",inputMode:"numeric",className:"flex-1 w-full text-center text-sm font-bold text-gray-800 bg-transparent outline-none px-1",value:u,onChange:e=>m(e.target.value),onFocus:()=>{c(!0);m(g?Math.round(t.quantidade*h*1e3).toString():t.quantidade.toString()),setTimeout(()=>{var e;return null==(e=p.current)?void 0:e.select()},50)},onBlur:()=>{c(!1);let e=parseFloat(u.replace(/[^0-9]/g,""));if(isNaN(e)||e<=0)return;let a=t.quantidade;g?(a=Math.ceil(e/1e3/h))<1&&(a=1):a=Math.ceil(e),a!==t.quantidade&&o(a)},onKeyDown:e=>{var t;"Enter"===e.key&&(null==(t=p.current)||t.blur())},placeholder:g?"Gramas":"Qtd"}),(0,r.jsx)("button",{className:"w-10 h-full flex items-center justify-center hover:bg-white text-gray-500 border-l border-gray-100 transition-colors active:bg-gray-100 z-10",onMouseEnter:e=>e.currentTarget.style.color=a,onMouseLeave:e=>e.currentTarget.style.color="",onClick:e=>{e.stopPropagation(),o(t.quantidade+1)},children:(0,r.jsx)(i.A,{size:16,strokeWidth:3})})]})},z=e=>{let{item:t,isSelected:a,toggleSelect:o,primaryColor:n,onRemove:i,onUpdateQuantity:m,selectedFormat:p,onFormatChange:x,observationValue:g,onObservationChange:h}=e,[f,b]=(0,s.useState)(!1),y=!!t.codigoBarras,v=!1===t.disponivel,j=!y||v,w=Array.isArray(t.cta)?t.cta:[],N=w.length>1&&!!x,k=w.find(e=>/unidade|un\b/i.test(e))||"Unidade",C=w.find(e=>/(kg|gr|peso|grama)/i.test(e)),_=C||"Peso",A=C?function(e){let t=e.toLowerCase().replace(",",".").match(/(\d+(?:\.\d+)?)\s*(kg|gr|grama|g\b)/);if(!t)return null;let a=parseFloat(t[1]);return"kg"===t[2]?a:a/1e3}(C):null,S="number"==typeof A&&A>0?A:parseFloat(t.fracao)||void 0,E="boolean"==typeof p?p:!!(t.item_fracionado||t.fracionado);return v?(0,r.jsxs)("div",{className:"relative bg-white rounded-xl border border-gray-200 p-3 flex items-center gap-3 opacity-60",children:[(0,r.jsx)("div",{className:"h-12 w-12 shrink-0 rounded-lg bg-white border border-gray-100 flex items-center justify-center overflow-hidden p-1 grayscale",children:t.imagem&&!f?(0,r.jsx)("img",{src:t.imagem,alt:t.descricao,className:"h-full w-full object-contain mix-blend-multiply",onError:()=>b(!0)}):(0,r.jsx)(l.A,{size:16,className:"text-gray-300"})}),(0,r.jsx)("p",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-600 line-clamp-2 leading-snug",children:t.descricao}),(0,r.jsx)("span",{className:"shrink-0 text-[10px] bg-red-50 text-red-600 px-2 py-1 rounded font-bold",children:"Indispon\xedvel"})]}):(0,r.jsxs)("div",{className:"\n        relative bg-white rounded-xl border transition-all p-3 flex flex-col gap-3\n        ".concat(v?"border-gray-200 opacity-60":"hover:shadow-md","\n        ").concat(a?"border-green-200 bg-green-50/30":"border-gray-100 hover:border-gray-300","\n      "),children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{onClick:()=>!j&&o(t.codigoBarras),className:"\n            shrink-0 flex justify-center\n            ".concat(j?"opacity-30 curs
1or-not-allowed":"cursor-pointer text-gray-300 hover:text-gray-500","\n          "),children:a?(0,r.jsx)(d.A,{size:24,style:{color:n}}):(0,r.jsx)(c.A,{size:24})}),(0,r.jsx)("div",{className:"h-14 w-14 shrink-0 rounded-lg bg-white border border-gray-100 flex items-center justify-center overflow-hidden p-1",children:t.imagem&&!f?(0,r.jsx)("img",{src:t.imagem,alt:t.descricao,className:"h-full w-full object-contain mix-blend-multiply",onError:()=>b(!0)}):(0,r.jsx)(l.A,{size:16,className:"text-gray-300"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-gray-800 line-clamp-2 leading-snug",children:t.descricao}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[t.codigoBarras?(0,r.jsx)("span",{className:"text-[10px] bg-gray-100 text-gray-500 px-1.5 py-0.5 rounded font-mono truncate",children:t.codigoBarras}):(0,r.jsx)("span",{className:"text-[10px] bg-red-50 text-red-500 px-1.5 py-0.5 rounded font-bold",children:"Sem c\xf3digo"}),(t.item_fracionado||t.fracionado)&&(0,r.jsx)("span",{className:"text-[10px] bg-blue-50 text-blue-500 px-1.5 py-0.5 rounded font-bold",children:"Peso"}),v&&(0,r.jsx)("span",{className:"text-[10px] bg-red-50 text-red-600 px-1.5 py-0.5 rounded font-bold",children:"Indispon\xedvel"})]})]})]}),v&&(0,r.jsx)("div",{className:"text-xs font-medium text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:"Esse produto est\xe1 indispon\xedvel no momento"}),N&&!v&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,r.jsx)("span",{className:"text-[10px] text-gray-500 font-semibold uppercase tracking-wider",children:"Formato:"}),(0,r.jsxs)("div",{className:"inline-flex rounded-lg border border-gray-200 overflow-hidden bg-gray-50",children:[(0,r.jsx)("button",{onClick:()=>null==x?void 0:x(t.id,!1),className:"px-2.5 py-1 text-xs font-bold transition-colors ".concat(E?"text-gray-600 hover:bg-gray-100":"text-white"),style:{backgroundColor:E?void 0:n},children:k}),(0,r.jsx)("button",{onClick:()=>null==x?void 0:x(t.id,!0),className:"px-2.5 py-1 text-xs font-bold transition-colors border-l border-gray-200 ".concat(E?"text-white":"text-gray-600 hover:bg-gray-100"),style:{backgroundColor:E?n:void 0},children:_})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 mt-1",children:[(0,r.jsx)("div",{className:v?"flex-1 max-w-[300px] pointer-events-none opacity-50":"flex-1 max-w-[300px]",children:(0,r.jsx)(L,{item:{...t,item_fracionado:E,fracionado:E},primaryColor:n,onUpdate:e=>!v&&m(t.id,e),stepKg:S})}),(0,r.jsx)("button",{onClick:()=>i(t.id),className:"h-10 w-10 flex items-center justify-center text-gray-300 hover:text-red-500 rounded-lg hover:bg-red-50 transition-colors shrink-0 border border-transparent hover:border-red-100",children:(0,r.jsx)(u.A,{size:20})})]}),t.permite_observacao&&!v&&h&&(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsx)("label",{className:"block text-[10px] font-bold text-gray-500 uppercase tracking-wider mb-1",children:"Observa\xe7\xe3o"}),(0,r.jsx)("input",{type:"text",maxLength:40,value:null!=g?g:"",onChange:e=>h(t.id,e.target.value),placeholder:"Ex: bem maduro",className:"w-full h-10 rounded-lg border border-gray-200 bg-white px-3 text-sm text-gray-800 placeholder:text-gray-400 outline-none transition focus:border-green-500 focus:ring-2 focus:ring-green-500/20"})]})]})},P=e=>{var t,a,n,l,k,C,_;let{isOpen:L,onClose:P,initialListId:q,focusProductBarcode:T,initialObservation:F}=e,M=(0,b.jE)(),{companyParameters:B,selectedCompanyData:D}=(0,N.P)(),{selectedStore:R}=(0,w.U)(),[Q,O]=(0,s.useState)(null),[V,K]=(0,s.useState)(""),[U,W]=(0,s.useState)([]),[G,H]=(0,s.useState)({}),[$,J]=(0,s.useState)({}),[Y,X]=(0,s.useState)({}),Z=(0,s.useRef)(!1),ee=(0,s.useRef)(!1),[et,ea]=(0,s.useState)(!1),[er,es]=(0,s.useState)(null),[eo,en]=(0,s.useState)(!1),[ei,el]=(0,s.useState)(""),[ed,ec]=(0,s.useState)(!1),[eu,em]=(0,s.useState)(!1),ep=(null==D||null==(a=D.empresa)||null==(t=a.empresa)?void 0:t.empr_id)||(null==B||null==(l=B.success)||null==(n=l.empresa)?void 0:n.empr_id),ex=(null==D||null==(C=D.empresa)||null==(k=C.parametros)?void 0:k.empa_main_color)||"#16a34a",{data:eg,isLoading:eh}=(0,y.I)({...j.T.lists(),enabled:L}),ef=(0,s.useMemo)(()=>{var e,t;return(null!=(t=null==eg||null==(e=eg.success)?void 0:e.listas)?t:[]).map(e=>{var t;return{id:e.id,descricao:e.lico_descricao,quantidadeItens:null!=(t=e.lico_qtde_itens)?t:0}})},[eg]);(0,s.useEffect)(()=>
1{if(!L||!q||Z.current||0===ef.length)return;let e=ef.find(e=>e.id===q);e&&(Z.current=!0,O(e))},[q,L,ef]);let{data:eb,isLoading:ey}=(0,y.I)({...j.T.products({listaId:null!=(_=null==Q?void 0:Q.id)?_:0,empresaId:ep?Number(ep):void 0}),enabled:L&&!!(null==Q?void 0:Q.id)}),ev=(0,s.useMemo)(()=>{var e,t;return(null!=(t=null==eb||null==(e=eb.success)?void 0:e.itens)?t:[]).map(e=>{var t,a;return{id:e.id,produto_id:e.produto_id,codigoBarras:e.codigo_barras,descricao:e.descricao,quantidade:e.quantidade,imagem:e.imagem,quantidade_formatada:e.quantidade_formatada,fracao:e.fracao,item_fracionado:e.item_fracionado,fracionado:e.fracionado,cta:Array.isArray(e.cta)?e.cta:void 0,observacao:null!=(a=null!=(t=(0,I.wC)(e.codigo_barras||""))?t:e.observacao)?a:void 0,permite_observacao:!0===e.permite_observacao,disponivel:"boolean"!=typeof e.disponivel||e.disponivel}})},[eb]),ej=e=>["shopping-list-products",null!=e?e:null==Q?void 0:Q.id,ep?Number(ep):null],ew=()=>M.invalidateQueries({queryKey:["shopping-lists"]}),eN=e=>M.invalidateQueries({queryKey:ej(e)}),ek=(0,v.n)({...j.V.createList,onSuccess:()=>ew()}),eC=(0,v.n)({...j.V.deleteList,onSuccess:()=>ew()}),e_=(0,v.n)({...j.V.updateList,onSuccess:()=>ew()}),eA=(0,v.n)({...j.V.deleteProduct,onMutate:async e=>{var t;let{listaId:a,produtoId:r}=e,s=ej(a);await M.cancelQueries({queryKey:s});let o=M.getQueryData(s);(null==o||null==(t=o.success)?void 0:t.itens)&&M.setQueryData(s,{...o,success:{...o.success,itens:o.success.itens.filter(e=>e.id!==r)}});let n=M.getQueriesData({queryKey:["shopping-lists"]}),i=n.map(e=>{let[t,a]=e;return{key:t,value:a}});return n.forEach(e=>{var t;let[r,s]=e;(null==s||null==(t=s.success)?void 0:t.listas)&&M.setQueryData(r,{...s,success:{...s.success,listas:s.success.listas.map(e=>{var t;return e.id===a?{...e,lico_qtde_itens:Math.max(0,(null!=(t=e.lico_qtde_itens)?t:0)-1)}:e})}})}),{previousProducts:o,productsKey:s,previousListsSnapshots:i}},onError:(e,t,a)=>{var r;(null==a?void 0:a.previousProducts)&&M.setQueryData(a.productsKey,a.previousProducts),null==a||null==(r=a.previousListsSnapshots)||r.forEach(e=>{let{key:t,value:a}=e;return M.setQueryData(t,a)}),eN(t.listaId)}}),eS=(0,v.n)({...j.V.updateProductQuantity,onSuccess:(e,t)=>{var a,r;let s=null==e||null==(a=e.success)?void 0:a.item;if(!s)return eN(t.listaId);let o=ej(t.listaId),n=M.getQueryData(o);(null==n||null==(r=n.success)?void 0:r.itens)&&M.setQueryData(o,{...n,success:{...n.success,itens:n.success.itens.map(e=>e.id===s.id?{...e,quantidade:s.quantidade,quantidade_formatada:s.quantidade_formatada,fracao:s.fracao}:e)}})},onError:(e,t)=>eN(t.listaId)}),eE=(0,v.n)({...j.V.sendListToCart,onSettled:(e,t,a)=>{eN(a.lista_id),setTimeout(()=>{document.dispatchEvent(new CustomEvent("cartSync",{detail:{companyId:a.empr_id}}))},300)}}),eI=(0,s.useRef)({});(0,s.useEffect)(()=>()=>{Object.values(eI.current).forEach(clearTimeout),eI.current={}},[]),(0,s.useEffect)(()=>{K(""),W([]),H({}),J({}),X({})},[Q,L]),(0,s.useEffect)(()=>{L||(O(null),Z.current=!1,ee.current=!1)},[L]),(0,s.useEffect)(()=>{if(!L)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[L]),(0,s.useEffect)(()=>L&&Q?(document.body.setAttribute("data-shopping-list-detail-open","true"),()=>{document.body.removeAttribute("data-shopping-list-detail-open")}):void document.body.removeAttribute("data-shopping-list-detail-open"),[L,Q]),(0,s.useEffect)(()=>{if(!L||!T||ee.current||0===ev.length)return;let e=ev.find(e=>e.codigoBarras===T);e&&(ee.current=!0,W(t=>t.includes(e.codigoBarras)?t:[...t,e.codigoBarras]),(null==F?void 0:F.trim())&&X(t=>({...t,[e.id]:F.trim()})),requestAnimationFrame(()=>{var t;null==(t=document.getElementById("shopping-list-item-".concat(e.id)))||t.scrollIntoView({behavior:"smooth",block:"center"})}))},[T,F,L,ev]);let eL=(0,s.useMemo)(()=>{if(!V.trim())return ev;let e=V.toLowerCase();return ev.filter(t=>t.descricao.toLowerCase().includes(e)||t.codigoBarras&&t.codigoBarras.includes(e))},[ev,V]),ez=(0,s.useMemo)(()=>{if(!V.trim())return ef;let e=V.toLowerCase();return ef.filter(t=>t.descricao.toLowerCase().includes(e))},[ef,V]),eP=(0,s.useMemo)(()=>eL.filter(e=>e.codigoBarras&&!1!==e.disponivel),[eL]),eq=eP.length>0&&eP.every(e=>U.includes(e.codigoBarras)),eT=e=>{if(!e)return;let t=ev.find(t=>t.codigoBarras===e);(null==t?void 0:t.disponivel)!==!1&&W(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},eF=()=>{eC.isPending||(ea(!1),es(null))},eM=async()=>{er&&(await eC.mutateAsync({listaId:er.id}),eF())},eB=()=>{el(""),en(!0)},eD=()=>{ek.isPending||en(!1)},eR=async()=>{ei.trim()&&(await ek.mutateAsync({descricao:ei}),eD())},eQ=async()=>
1{if(Q){for(let e of ev.filter(e=>U.includes(e.codigoBarras)).map(e=>e.id))await eA.mutateAsync({listaId:Q.id,produtoId:e});eN(Q.id),ew(),W([]),ec(!1)}},eO=eA.isPending,eV=e=>{Q&&eA.mutate({listaId:Q.id,produtoId:e})};return L&&"undefined"!=typeof document?(0,o.createPortal)((0,r.jsxs)("div",{className:"fixed inset-0 z-[1000]",children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-40 transition-opacity",onClick:P}),(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-0 pointer-events-none md:p-4",children:(0,r.jsxs)("div",{className:"flex h-[100dvh] max-h-none w-full max-w-none flex-col overflow-hidden rounded-none bg-white shadow-none pointer-events-auto transform transition-all md:h-full md:max-h-[85vh] md:max-w-2xl md:rounded-2xl md:bg-gray-50 md:shadow-2xl",style:{"--primary":ex},children:[(0,r.jsxs)("header",{className:"flex shrink-0 items-center gap-3 border-b bg-white px-5 pb-4 pt-[max(1rem,env(safe-area-inset-top))] md:px-6 md:py-4",children:[Q?(0,r.jsx)("button",{onClick:()=>O(null),className:"-ml-2 rounded-full p-2 text-gray-700 transition-colors hover:bg-gray-100 md:text-gray-600","aria-label":"Voltar para minhas listas",children:(0,r.jsx)(m.A,{className:"w-6 h-6"})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:P,className:"-ml-2 rounded-full p-2 text-gray-700 transition-colors hover:bg-gray-100 md:hidden","aria-label":"Voltar para minha conta",children:(0,r.jsx)(m.A,{className:"size-6"})}),(0,r.jsx)("div",{className:"hidden rounded-xl p-2.5 shadow-sm md:block",style:{backgroundColor:"".concat(ex,"20")},children:(0,r.jsx)(p.A,{className:"w-6 h-6",style:{color:ex}})})]}),(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden",children:[(0,r.jsx)("h2",{className:"text-xl font-bold text-gray-900 truncate",children:Q?Q.descricao:"Minhas listas"}),(0,r.jsx)("span",{className:"hidden text-xs font-medium text-gray-500 md:block",children:Q?"".concat(ev.length," itens na lista"):"Gerencie suas compras recorrentes"})]}),(0,r.jsx)("button",{onClick:P,className:"ml-auto hidden rounded-full p-2 text-gray-400 hover:bg-gray-100 hover:text-gray-600 md:block","aria-label":"Fechar minhas listas",children:(0,r.jsx)(x.A,{className:"w-6 h-6"})})]}),(0,r.jsx)("div",{className:"shrink-0 border-b border-gray-200 bg-white px-5 pb-5 pt-6 md:bg-gray-50 md:px-4 md:pb-4 md:pt-4",children:Q?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"flex-1 flex items-center gap-2 bg-white border border-gray-200 rounded-xl px-3 py-2.5 shadow-sm focus-within:ring-2 focus-within:ring-opacity-50 transition-all",style:{"--tw-ring-color":ex},children:[(0,r.jsx)(g.A,{className:"w-4 h-4 text-gray-400"}),(0,r.jsx)("input",{value:V,onChange:e=>K(e.target.value),placeholder:"Buscar item...",className:"flex-1 outline-none text-sm bg-transparent min-w-0"})]}),U.length>0&&(0,r.jsxs)("button",{onClick:()=>{Q&&0!==U.length&&ec(!0)},className:"px-3 md:px-4 rounded-xl bg-red-100 text-red-600 hover:bg-red-200 transition-colors flex items-center gap-2 text-xs font-bold whitespace-nowrap",children:[(0,r.jsx)(u.A,{size:16}),(0,r.jsxs)("span",{className:"hidden sm:inline",children:["Excluir (",U.length,")"]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-1",children:[(0,r.jsxs)("div",{onClick:()=>{eq?W([]):W(eP.map(e=>e.codigoBarras))},className:"flex items-center gap-2 text-xs font-bold text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-800 transition-colors",children:[eq?(0,r.jsx)(d.A,{size:18,style:{color:ex}}):(0,r.jsx)(c.A,{size:18}),(0,r.jsx)("span",{children:"Selecionar Todos"})]}),(0,r.jsx)("span",{className:"text-xs text-gray-400 font-medium",children:U.length>0?"".concat(U.length," selecionados"):""})]})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("button",{onClick:eB,className:"flex w-full items-center justify-center gap-2 rounded-xl py-3.5 text-sm font-bold text-white shadow-sm transition-all hover:brightness-110 hover:shadow-md active:scale-[0.99]",style:{backgroundColor:ex},children:[(0,r.jsx)(i.A,{className:"size-5"}),"Criar nova lista"]}),(0,r.jsxs)("div",{className:"flex h-12 w-full items-center gap-2 rounded-full border border-gray-300 bg-white px-4 shadow-sm transition-all focus-within:ring-2 focus-within:ring-opacity-50 md:h-auto md:rounded-xl md:border-gray-200 md:px-3 md:py-2.5",style:{"--tw-ring-color":ex},children:[(0,r.jsx)(g.A,{className:"w-4 h-4 text-gray-400"}),(0,r.jsx)("input",{value:V,onChange:e=>K(e.target.value),placeholder:"Buscar lista...",className:"flex-1 outline-none text-sm bg-transparent min-w-0"})]})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto bg-white p-5 scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-transparent md:bg-transparent md:p-4 md:pt-3",children:Q?(0,r.jsx)(r.Fragment,{children:ey&&0===ev.length?(0,r.jsx)("div",{className:"flex justify-center py-20",children:(0,r.jsx)(h.A,{className:"h-10 w-10 animate-spin",style:{color:ex}})}):0===eL.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 gap-4 text-gray-400",children:[(0,r.jsx)("div",{className:"bg-gray-100 p-4 rounded-full",children:(0,r.jsx)(g.A,{className:"h-8 w-8"})}),(0,r.jsx)("p",{className:"text-sm font-medium",children:V?"Nenhum item encontrado.":"Lista vazia."})]}):(0,r.jsx)("div",{className:"space-y-3",children:eL.map(e=>{var t,a,s;return(0,r.jsx)("div",{id:"shopping-list-item-".concat(e.id),children:(0,r.jsx)(z,{item:{...e,quantidade:null!=(t=$[e.id])?t:e.quantidade},isSelected:!!e.codigoBarras&&U.includes(e.codigoBarras),toggleSelect:eT,primaryColor:ex,onRemove:eV,onUpdateQuantity:(t,a)=>{if("boolean"==typeof G[t])return void J(e=>({...e,[t]:a}));((e,t)=>
1{var a;if(!Q)return;let r=ej(Q.id),s=M.getQueryData(r);(null==s||null==(a=s.success)?void 0:a.itens)&&M.setQueryData(r,{...s,success:{...s.success,itens:s.success.itens.map(a=>a.id===e?{...a,quantidade:t}:a)}})})(t,a),((e,t,a,r)=>{eI.current[t]&&clearTimeout(eI.current[t]),eI.current[t]=setTimeout(()=>{eS.mutate({listaId:e,produtoId:t,produtoListaId:a,quantidade:r}),delete eI.current[t]},400)})(Q.id,t,e.produto_id,a)},observationValue:null!=(s=null!=(a=Y[e.id])?a:e.observacao)?s:"",onObservationChange:(e,t)=>X(a=>({...a,[e]:t})),selectedFormat:G[e.id],onFormatChange:(e,t)=>{H(a=>({...a,[e]:t})),J(t=>({...t,[e]:1}))}})},e.id)})})}):(0,r.jsx)("div",{className:"space-y-3",children:eh?(0,r.jsx)("div",{className:"flex justify-center py-20",children:(0,r.jsx)(h.A,{className:"h-10 w-10 animate-spin",style:{color:ex}})}):0===ez.length?(0,r.jsxs)("div",{className:"text-center py-16 px-4 border-2 border-dashed border-gray-200 rounded-2xl bg-gray-50/50",children:[(0,r.jsx)("div",{className:"bg-white p-4 rounded-full inline-block shadow-sm mb-4",children:V?(0,r.jsx)(g.A,{className:"h-10 w-10 text-gray-300"}):(0,r.jsx)(p.A,{className:"h-10 w-10 text-gray-300"})}),(0,r.jsx)("h3",{className:"text-gray-900 font-bold text-lg mb-1",children:V?"Nenhuma lista encontrada":"Voc\xea ainda n\xe3o tem listas"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 max-w-xs mx-auto mb-6",children:V?'N\xe3o encontramos nada com "'.concat(V,'"'):"Crie listas para organizar suas compras recorrentes."}),!V&&(0,r.jsx)("button",{onClick:eB,className:"px-6 py-2.5 rounded-xl text-white font-bold text-sm shadow-lg hover:brightness-110 transition-all",style:{backgroundColor:ex},children:"Criar Primeira Lista"})]}):(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:ez.map(e=>{var t;return(0,r.jsx)("div",{children:(0,r.jsx)(A,{name:e.descricao,itemsCount:null!=(t=e.quantidadeItens)?t:0,onClick:()=>O(e),onRename:t=>e_.mutateAsync({listaId:e.id,descricao:t}),onDelete:()=>(e=>{es({id:e.id,descricao:e.descricao}),ea(!0)})(e)})},e.id)})})})}),Q&&ev.length>0&&(0,r.jsx)("footer",{className:"p-4 bg-white border-t z-20 shrink-0",children:(0,r.jsxs)("button",{onClick:()=>{if(!ep)return void em(!0);if(0===U.length||!Q)return;let e=ev.filter(e=>U.includes(e.codigoBarras)&&!1!==e.disponivel).map(e=>{var t,a;let r=G[e.id],s="boolean"==typeof r?r:!!(e.item_fracionado||e.fracionado),o=null!=(t=$[e.id])?t:e.quantidade,n={codigo_barras:e.codigoBarras,quantidade:o,fracionado:s},i=null!=(a=Y[e.id])?a:e.observacao;return void 0!==i&&(n.observacao=i.trim()),n});eE.mutate({lista_id:Q.id,empr_id:Number(ep),itens:e}),P()},disabled:0===U.length,className:"w-full text-white py-4 rounded-xl flex items-center justify-center gap-3 font-bold text-base transition-all hover:brightness-110 active:scale-[0.99] shadow-lg hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed disabled:shadow-none",style:{backgroundColor:U.length>0?ex:"#9ca3af"},children:[(0,r.jsx)(f.A,{size:20}),U.length>0?"Enviar ".concat(U.length," ao carrinho"):"Selecione para enviar"]})})]})}),(0,r.jsx)(S.A,{isOpen:et,onClose:eF,onConfirm:eM,title:"Excluir lista?",message:er?'Excluir "'.concat(er.descricao,'"?'):"Excluir lista?",confirmText:"Sim, excluir",cancelText:"Cancelar",type:"danger",isLoading:eC.isPending,loadingText:"Excluindo..."}),(0,r.jsx)(S.A,{isOpen:ed,onClose:()=>ec(!1),onConfirm:eQ,title:"Remover itens selecionados?",message:"Deseja realmente remover os ".concat(U.length," itens selecionados da sua lista?"),confirmText:"Sim, remover",cancelText:"Cancelar",type:"danger",isLoading:eO,loadingText:"Removendo..."}),(0,r.jsx)(S.A,{isOpen:eu,onClose:()=>em(!1),onConfirm:()=>em(!1),title:"Selecione uma loja",message:"Por favor, selecione uma loja para continuar com o envio dos produtos ao carrinho.",confirmText:"Entendi",type:"warning",singleButton:!0}),(0,r.jsx)(E.A,{isOpen:eo,onClose:eD,onConfirm:eR,value:ei,onChange:el,isLoading:ek.isPending,primaryColor:ex})]}),document.body):null}},63589:(e,t,a)=>{function r(e,t){if(!t)return e.toString();if(!(e<1))return e%1==0?"".concat(Math.floor(e)," kg"):"".concat(e.toFixed(2).replace(".",",")," kg");{let t=Math.round(1e3*e);return"".concat(t," gr")}}function s(e,t){if(!Number.isFinite(e)||e<=0)return 0;if(!Number.isFinite(t)||t<=0)return e;let a=1e3*t;return Math.round(Math.ceil(e/a)*a)}function o(e){if("string"!=typeof e)return NaN;let t=e.toLowerCase().trim();if(!t)return NaN;let a=parseFloat(t.replace(/[^\d.,-]/g,"").replace(",","."));return Number.isFinite(a)?/kg\b/.test(t)||/\bkg/.test(t)?1e3*a:a:NaN}a.d(t,{PI:()=>s,SI:()=>r,Yz:()=>o})},68749:(e,t,a)=>{a.d(t,{I:()=>r});let r=e=>({...e})},69547:(e,t,a)=>{a.d(t,{y:()=>n});var r=a(76363),s=a(26472),o=a(50247);function n(e,t,a,n){if("share"===t){let e={method:n,content_type:"product",item_id:String(a)};s.FV.share(e),o.aO.share(e)}fetch("".concat("https://sicomprasafe.yourintegration.top/api/v1","/aplicativo/empresa/gerenciador-eventos-analytics"),{method:"POST",headers:{"Content-Type":"application/json",...(0,r.c)()},body:JSON.stringify({empresa_id:e,evento:t,codigo_barras:a,origem:"site"})}).catch(()=>{})}},76699:(e,t,a)=>{a.d(t,{F:()=>s});let r={base:a(95125).A.create({baseURL:"https://sicomprasafe.yourintegration.top/api/v1",headers:{"Content-Type":"application/json"}})},s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"base";
1return{GET:async(t,a)=>(await r[e].get(t,a)).data,POST:async(t,a,s)=>(await r[e].post(t,a,s)).data,PUT:async(t,a,s)=>(await r[e].put(t,a,s)).data,PATCH:async(t,a,s)=>(await r[e].patch(t,a,s)).data,DELETE:async(t,a)=>(await r[e].delete(t,a)).data}};(e=>{e.interceptors.request.use(async e=>{let t={...e},a=localStorage.getItem("token"),r=t.headers,s=!!((null==r?void 0:r.Authorization)||(null==r?void 0:r.authorization));return a&&!s&&(t.headers.Authorization="Bearer ".concat(a)),t}),e.interceptors.response.use(e=>e,async e=>{var t;let a=window.location.pathname;return"/acesse-sua-conta"===a||"/sign-up"===a?Promise.reject(e):(401===e.response.status&&(localStorage.removeItem("token"),localStorage.setItem("url",a),window.location.href="/"),403===e.response.status&&(localStorage.clear(),window.location.href="/"),Promise.reject((null==(t=e.response)?void 0:t.data)||e))})})(r.base)},85779:(e,t,a)=>{a.d(t,{A:()=>o});var r=a(95155),s=a(12115);function o(e){let{imageUrl:t,alt:a}=e,[o,n]=(0,s.useState)(!1),[i,l]=(0,s.useState)({x:0,y:0}),[d,c]=(0,s.useState)(!1),[u,m]=(0,s.useState)(!1),p=(0,s.useRef)(null),x=(0,s.useRef)(null);(0,s.useEffect)(()=>{n(!1),m(!1),c(!1);let e=x.current;(null==e?void 0:e.complete)&&(c(!0),m(0===e.naturalWidth))},[t]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&o&&n(!1)};return o&&document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[o]);let g=()=>u||!t?"/placeholder-product.png":t;return(0,r.jsx)("div",{className:"relative bg-white rounded-lg border border-gray-200 overflow-hidden",children:(0,r.jsxs)("div",{ref:p,className:"relative ".concat(o?"cursor-zoom-out":"cursor-zoom-in"),onClick:()=>{t&&!u&&d&&n(!o)},onMouseMove:e=>{if(!o||!p.current)return;let t=p.current.getBoundingClientRect();l({x:Math.max(0,Math.min(100,(e.clientX-t.left)/t.width*100)),y:Math.max(0,Math.min(100,(e.clientY-t.top)/t.height*100))})},onMouseLeave:()=>{o&&n(!1)},children:[(0,r.jsx)("img",{ref:x,src:g(),alt:a,className:"w-full h-[300px] sm:h-[400px] lg:h-[500px] object-contain p-2 sm:p-4 transition-opacity duration-300 ".concat(d?"opacity-100":"opacity-0"),onError:()=>{u||m(!0),c(!0)},onLoad:()=>{c(!0)}}
1),!d&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,r.jsx)("div",{className:"animate-pulse",children:(0,r.jsx)("div",{className:"w-24 h-24 bg-gray-200 rounded-full flex items-center justify-center",children:(0,r.jsx)("svg",{className:"w-12 h-12 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4 3a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V5a2 2 0 00-2-2H4zm12 12H4l4-8 3 6 2-4 3 6z",clipRule:"evenodd"})})})})}),!o&&d&&!u&&(0,r.jsx)("div",{className:"absolute top-2 left-2 bg-black bg-opacity-50 text-white px-2 py-1 rounded text-xs",children:"Clique para zoom"}),o&&t&&!u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black bg-opacity-20 z-20"}),(0,r.jsx)("div",{className:"absolute inset-0 z-30 pointer-events-none",style:{background:"url(".concat(g(),") no-repeat"),backgroundSize:"200%",backgroundPosition:"".concat(i.x,"% ").concat(i.y,"%"),transform:"scale(1.2)",transformOrigin:"center"}}),(0,r.jsx)("div",{className:"absolute bottom-2 left-2 bg-black bg-opacity-70 text-white px-3 py-1 rounded text-sm z-40",children:"Mova o mouse para navegar • Clique ou ESC para sair"})]})]})})}},89950:(e,t,a)=>{a.d(t,{T:()=>n,V:()=>i});var r=a(86560),s=a(68749),o=a(76699);let n={lists:e=>{var t;return(0,r.j)({queryKey:["shopping-lists",null!=(t=null==e?void 0:e.codigoBarras)?t:null],queryFn:()=>(0,o.F)().GET("/aplicativo/usuario/lista-compras",{params:{codigo_barras:null==e?void 0:e.codigoBarras}})})},products:e=>{var t;return(0,r.j)({queryKey:["shopping-list-products",e.listaId,null!=(t=e.empresaId)?t:null],enabled:!!e.listaId,queryFn:()=>(0,o.F)().GET("/aplicativo/usuario/lista-compras/".concat(e.listaId,"/produtos").concat(e.empresaId?"/".concat(e.empresaId):""))})}},i={createList:(0,s.I)({mutationFn:e=>(0,o.F)().POST("/aplicativo/usuario/lista-compras",{descricao:e.descricao})}),updateList:(0,s.I)({mutationFn:e=>(0,o.F)().PUT("/aplicativo/usuario/lista-compras/".concat(e.listaId),{descricao:e.descricao})}),deleteList:(0,s.I)({mutationFn:e=>(0,o.F)().DELETE("/aplicativo/usuario/lista-compras/".concat(e.listaId))}),addProduct:(0,s.I)({mutationFn:e=>(0,o.F)().POST("/aplicativo/usuario/lista-compras/".concat(e.listaId,"/produtos"),{codigo_barras:e.codigo_barras,quantidade:e.quantidade,observacao:e.observacao})}),updateProductQuantity:(0,s.I)({mutationFn:e=>(0,o.F)().PUT("/aplicativo/usuario/lista-compras/".concat(e.listaId,"/produtos/").concat(e.produtoId),{quantidade:e.quantidade,produto_id:e.produtoListaId})}),deleteProduct:(0,s.I)({mutationFn:e=>(0,o.F)().DELETE("/aplicativo/usuario/lista-compras/".concat(e.listaId,"/produtos/").concat(e.produtoId))}),sendListToCart:(0,s.I)({mutationFn:e=>(0,o.F)().POST("/aplicativo/usuario/lista-compras/enviar-carrinho",{lista_id:e.lista_id,empr_id:e.empr_id,itens:e.itens})})}},96165:(e,t,a)=>{a.d(t,{A:()=>n});var r=a(95155),s=a(12115),o=a(6191);function n(e){let{isOpen:t,onClose:a,onConfirm:n,value:i,onChange:l,isLoading:d=!1,primaryColor:c="#16a34a"}=e,u=(0,s.useRef)(null);return((0,s.useEffect)(()=>{t&&setTimeout(()=>{var e;return null==(e=u.current)?void 0:e.focus()},100)},[t]),t)?(0,r.jsx)("div",{className:"fixed inset-0 z-[60] overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 transition-opacity",onClick:a}),(0,r.jsxs)("div",{className:"relative w-full max-w-md transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,r.jsx)("div",{className:"p-2 rounded-full",style:{backgroundColor:"".concat(c,"20"),color:c},children:(0,r.jsx)(o.A,{size:24})}),(0,r.jsx)("h3",{className:"text-lg font-bold text-gray-900",children:"Nova Lista de Compras"})]}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mb-4",children:"D\xea um nome para sua nova lista para come\xe7ar a adicionar produtos."}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-bold text-gray-700 uppercase mb-1",children:"Nome da Lista"}),(0,r.jsx)("input",{ref:u,value:i,onChange:e=>l(e.target.value),onKeyDown:e=>"Enter"===e.key&&i.trim()&&n(),placeholder:"Ex: Churrasco de Domingo",disabled:d,className:"w-full bg-gray-50 border border-gray-200 rounded-lg px-4 py-3 text-sm outline-none focus:ring-2 focus:ring-opacity-50 transition-all",style:{"--tw-ring-color":c}})]}),(0,r.jsxs)("div",{className:"flex gap-3 justify-end pt-2",children:[(0,r.jsx)("button",{onClick:a,disabled:d,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:"Cancelar"}),(0,r.jsxs)("button",{onClick:n,disabled:!i.trim()||d,className:"px-4 py-2 text-sm font-bold text-white rounded-lg hover:brightness-110 transition-all disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 shadow-sm",style:{backgroundColor:c},children:[d&&(0,r.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Criar Lista"]})]})]})]})]})}):null}},96658:(e,t,a)=>{a.d(t,{A:()=>s});var r=a(95155);function s(e){let{isOpen:t,onClose:a,maxQuantity:s,productName:o}=e;return t?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:e=>{e.stopPropagation(),a()},children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black bg-opacity-50"}),(0,r.jsxs)("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6",onClick:e=>{e.stopPropagation()},children:[(0,r.jsx)("button",{onClick:a,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Fechar",children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,r.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,r.jsx)("div",{className:"w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center mb-4",children:(0,r.jsx)("svg",{className:"w-8 h-8 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),(0,r.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Limite m\xe1ximo atingido"}),(0,r.jsx)("p",{className:"text-gray-600 mb-6",children:o?(0,r.jsxs)(r.Fragment,{children:["Limite m\xe1ximo de ",(0,r.jsxs)("strong",{children:[s," ",1===s?"unidade":"unidades"]})," para o produto ",(0,r.jsx)("strong",{children:o})]}):(0,r.jsxs)(r.Fragment,{children:["Limite m\xe1ximo de ",(0,r.jsxs)("strong",{children:[s," ",1===s?"unidade":"unidades"]})," para este produto"]})}),(0,r.jsx)("button",{onClick:a,className:"w-full bg-primary text-white py-3 px-4 roun
1ded-lg font-medium hover:bg-primary-dark transition-colors",children:"Entendi"})]})]})]}):null}},97148:(e,t,a)=>{a.d(t,{A:()=>u});var r=a(95155),s=a(12115),o=a(60952),n=a(28412),i=a(51244),l=a(22746),d=a(22784),c=a(29133);function u(e){var t,a;let{product:u,variant:m="button",className:p="",observation:x,onProductAdded:g,reopenDetailProdId:h}=e,[f,b]=(0,s.useState)(!1),{setToast:y}=(0,l.d)(),{selectedCompanyData:v}=(0,n.P)(),{isAuthenticated:j,openLoginDrawer:w}=(0,i.A)(),N=(0,d.c)(e=>e.actions.setIntent),k=(null==v||null==(a=v.empresa)||null==(t=a.parametros)?void 0:t.empa_main_color)||"#16a34a",C={...u,observacao:void 0!==x?x.trim():u.observacao},_=e=>{if(e.preventDefault(),e.stopPropagation(),!j){"number"==typeof h?N("shopping-list-with-detail",{product:C,detailProdId:h}):N("shopping-list",{product:C}),y({show:!0,message:"Fa\xe7a login na sua conta para acessar suas listas.",type:"warning"}),w();return}b(!0)};return(0,r.jsxs)(r.Fragment,{children:["iconCompact"===m?(0,r.jsx)("button",{onClick:_,title:"Adicionar \xe0 Lista de Compras",className:"rounded-full p-2 bg-gray-100 text-gray-600 transition-colors ".concat(p),children:(0,r.jsx)(o.A,{className:"h-5 w-5"})}):"icon"===m?(0,r.jsx)("button",{onClick:_,title:"Adicionar \xe0 Lista de Compras",className:"h-9 w-9 rounded-full bg-white border border-gray-200 shadow-sm flex items-center justify-center text-gray-600 hover:text-white transition-all hover:scale-105 active:scale-95 z-10 relative ".concat(p),style:{"--hover-bg":k},onMouseEnter:e=>{e.currentTarget.style.backgroundColor=k,e.currentTarget.style.borderColor=k,e.currentTarget.style.color="white"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="white",e.currentTarget.style.borderColor="#e5e7eb",e.currentTarget.style.color="#4b5563"},children:(0,r.jsx)(o.A,{size:16})}):"ghost"===m?(0,r.jsxs)("button",{onClick:_,title:"Adicionar \xe0 Lista de Compras",className:"flex-1 py-3 px-4 rounded-lg font-medium transition-colors flex items-center justify-center gap-2 bg-gray-100 text-gray-700 hover:bg-gray-200 whitespace-nowrap ".concat(p),children:[(0,r.jsx)(o.A,{className:"h-5 w-5 flex-shrink-0"}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:"Adicionar \xe0 Lista"})]}):(0,r.jsxs)("button",{onClick:_,className:"\n            w-full text-white py-1.5 sm:py-2 px-3 sm:px-4 roun
1ded-md font-medium text-xs sm:text-sm flex items-center justify-center gap-2 shadow-md transition-colors duration-200 active:scale-[0.99] ".concat(p,"\n          "),style:{backgroundColor:k},children:[(0,r.jsx)(o.A,{size:18}),"Adicionar \xe0 Lista"]}),f&&(0,r.jsx)(c.A,{isOpen:f,onClose:()=>b(!1),product:C,primaryColor:k,onToast:e=>y(e),onProductAdded:g})]})}}}]);

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.