1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CIhbGVJX.js","assets/index-Bjgpq81W.css","assets/index-D9B0wFfc.js","assets/synapse-akrKn89j.js"])))=>i.map(i=>d[i]); 2import{u as j,h as H,v as K,K as Y,aZ as J,a as l,c1 as Z,_ as U,c2 as q,c3 as F,c4 as Q,c5 as X,j as e,Y as ee,q as k,c6 as te,c7 as ae,c8 as se,c9 as ne,ca as re,cb as le,cc as ie,l as $,cd as oe,b0 as _,bT as de,ce,cf as xe,cg as W,ch as me,ci as ge,cj as pe,ck as ue,cl as fe,cm as be,cn as he}from"./index-CIhbGVJX.js";const D={regular:{labelKey:"sticker.legends.colRegular",fallback:"Regular",chip:"bg-purple-100 text-purple-700"},bronze:{labelKey:"sticker.legends.colBronze",fallback:"Bronze",chip:"bg-amber-100 text-amber-700"},silver:{labelKey:"sticker.legends.colSilver",fallback:"Prata",chip:"bg-slate-100 text-slate-600"},gold:{labelKey:"sticker.legends.colGold",fallback:"Ouro",chip:"bg-yellow-100 text-yellow-800"}},ye=[0,5,10,25,50,100];function je(s){return _[s]?.name??`#${s}`}function ve(s){return _[s]?.flag??"â"}const ke=new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"});function M(s){return s===null||Number.isNaN(s)?null:ke.format(s)}function B(s){const t=s.replace(/[^\d,.-]/g,"").replace(/\.(?=\d{3}(\D|$))/g,"").replace(",",".");if(!t)return null;const a=Number(t);return Number.isFinite(a)&&a>=0?a:null}function Ne(s,t){const r=(t.lat-s.lat)*Math.PI/180,n=(t.lng-s.lng)*Math.PI/180,o=s.lat*Math.PI/180,d=t.lat*Math.PI/180,c=Math.sin(r/2)**2+Math.cos(o)*Math.cos(d)*Math.sin(n/2)**2;return 2*6371*Math.asin(Math.sqrt(c))}function z(s,t){return!t||s.sellerLat===null||s.sellerLng===null?null:Ne(t,{lat:s.sellerLat,lng:s.sellerLng})}function E(){window.dispatchEvent(new CustomEvent("open-premium-modal"))}function Fe(){const{t:s}=j(),{user:t,profile:a}=H(),{isPremiumPro:r}=K(),{getSlot:n}=Y(),o=n("legends_affiliate_top"),d=!!a?.birthdate,c=d&&!J(a?.birthdate),[b,m]=l.useState(null);l.useEffect(()=>{if(!t?.id)return;let y=!1;return(async()=>{try{const N=await Z(t.id);if(N&&!y){m(N);return}}catch{}if(!y){try{const{Capacitor:N}=await U(async()=>{const{Capacitor:S}=await import("./index-CIhbGVJX.js").then(L=>L.dx);return{Capacitor:S}},__vite__mapDeps([0,1]));if(N.isNativePlatform()){const{Geolocation:S}=await U(async()=>{const{Geolocation:G}=await import("./index-D9B0wFfc.js");return{Geolocation:G}},__vite__mapDeps([2,0,1,3])),L=await S.getCurrentPosition({enableHighAccuracy:!1,timeout:8e3});if(y)return;const R={lat:L.coords.latitude,lng:L.coords.longitude};m(R),q(t.id,R.lat,R.lng).catch(()=>{});return}}catch{}y||!navigator.geolocation||navigator.geolocation.getCurrentPosition(N=>{if(y)return;const S={lat:N.coords.latitude,lng:N.coords.longitude};m(S),q(t.id,S.lat,S.lng).catch(()=>{})},()=>{},{enableHighAccuracy:!1,timeout:8e3})}})(),()=>{y=!0}},[t?.id]);const[f,g]=l.useState(null),[x,h]=l.useState(!0);l.useEffect(()=>{if(!t?.id||!c){h(!1);return}let y=!1;return(async()=>{try{const N=await F(t.id);y||g(N.accepted)}catch{y||g(!1)}finally{y||h(!1)}})(),()=>{y=!0}},[t?.id,c]);const p=l.useCallback(async()=>{if(t?.id){await Q(t.id);try{const y=await F(t.id);g(y.accepted)}catch{g(!0)}}},[t?.id]),w=l.useMemo(()=>Math.max(0,new Date(X).getTime()-Date.now()),[]),u=!r&&w>0&&f===!0,v=r||u;let i;return c?x||f===null?i=e.jsx(P,{}):f?i=e.jsx(Se,{userId:t.id,fullAccess:v,isPremiumPro:r,trialMsRemaining:u?w:0,userLocation:b}):i=e.jsx(Me,{onAccept:p}):i=e.jsx(we,{hasBirthdate:d}),e.jsxs("div",{className:"flex h-full flex-col bg-slate-50",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-gradient-to-r from-yellow-500 via-amber-500 to-yellow-600 px-4 py-3 text-white shadow",children:[e.jsx("span",{className:"text-xl",children:"â"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base leading-tight font-black",children:s("trades.legendsMarket.title","Vitrine Legends")}),e.jsx("p",{className:"text-[11px] font-medium text-white/85",children:s("trades.legendsMarket.headerSubtitle","Mural de colecionadores")})]})]}),e.jsx("div",{className:"px-3 pt-2",children:e.jsx(ee,{slotId:"legends_affiliate_top",fallbackSlot:o,position:"legends"})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:i})]})}function P(){return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"animate-spin text-4xl",children:"â½"})})}function we({hasBirthdate:s}){const{t}=j();return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 p-8 text-center",children:[e.jsx("span",{className:"text-5xl",children:"ð"}),e.jsx("h3",{className:"text-lg font-black text-gray-800",children:t("trades.legendsMarket.adultTitle","Ãrea exclusiva para maiores de 18 anos")}),e.jsx("p",{className:"max-w-sm text-sm text-gray-500",children:s?t("trades.legendsMarket.adultBlocked","Esta área envolve negociação com valores e está disponÃvel apenas para usuários maiores de idade."):t("trades.legendsMarket.adultNoBirthdate","Esta área envolve negociação com valores e está temporariamente indisponÃvel para contas sem verificação de maioridade.")})]})}function Me({onAccept:s}){const{t}=j(),[a,r]=l.useState(!1),[n,o]=l.useState(!1),d=async()=>{r(!0);try{await s()}catch{r(!1)}};return e.jsx("div",{className:"h-full overflow-y-auto px-4 py-5",style:{paddingBottom:"var(--app-bottom-inset, 1.25rem)"},children:e.jsxs("div",{className:"mx-auto max-w-xl space-y-5",children:[e.jsxs("section",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-4",children:[e.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-black text-amber-900",children:[e.jsx("i",{className:"fa-solid fa-circle-info"})," ",t("trades.legendsMarket.howTitle","Como funciona")]}),e.jsxs("ul",{className:"space-y-2 text-[13px] leading-relaxed text-amber-900/90",children:[e.jsxs("li",{children:["ð"," ",t("trades.legendsMarket.how1","Você expõe na vitrine uma figurinha Legend que possui, com um preço de referência (opcional).")]}),e.jsxs("li",{children:["ð¤"," ",t("trades.legendsMarket.how2","Outros colecionadores demonstram interesse. A negociação acontece diretamente entre vocês.")]}),e.jsxs("li",{children:["ð"," ",t("trades.legendsMarket.how3","Ao concluir, vocês informam o valor combinado. Isso alimenta cotações anônimas e agregadas.")]}),e.jsxs("li",{children:["ð«"," ",t("trades.legendsMarket.how4","O app NÃO processa pagamentos e NÃO cobra comissão. à apenas um mural informativo entre colecionadores.")]})]})]}),e.jsxs("section",{className:"rounded-2xl border border-blue-200 bg-blue-50 p-4",children:[e.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-black text-blue-900",children:[e.jsx("i",{className:"fa-solid fa-shield-halved"})," ",t("trades.legendsMarket.safetyTitle","Dica de segurança")]}),e.jsxs("p",{className:"text-[13px] leading-relaxed text-blue-900/90",children:["ð"," ",t("trades.legendsMarket.safetyTip","Combine encontros e entregas sempre em locais públicos e movimentados (shoppings, lojas, etc.). Evite lugares isolados.")]})]}),e.jsxs("section",{className:"rounded-2xl border border-gray-200 bg-white p-4",children:[e.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-black text-gray-800",children:[e.jsx("i",{className:"fa-solid fa-scale-balanced"})," ",t("trades.legendsMarket.legalTitle","Aviso importante")]}),e.jsxs("ul",{className:"space-y-2 text-[13px] leading-relaxed text-gray-600",children:[e.jsxs("li",{children:["⢠",t("trades.legendsMarket.legal1","Esta área é restrita a maiores de 18 anos.")]}),e.jsxs("li",{children:["â¢"," ",t("trades.legendsMarket.legal2","O app atua apenas como mural informativo. Não é parte das negociações, não intermedia pagamentos e não garante valores, autenticidade ou a conclusão de qualquer negócio.")]}),e.jsxs("li",{children:["â¢"," ",t("trades.legendsMarket.legal3","Toda negociação e pagamento ocorrem por sua conta e risco, diretamente entre os usuários.")]}),e.jsxs("li",{children:["â¢"," ",t("trades.legendsMarket.legal4","Você declara expor apenas itens genuÃnos e de sua propriedade. à proibido expor itens ilÃcitos ou falsificados.")]}),e.jsxs("li",{children:["â¢"," ",t("trades.legendsMarket.legal5","Itens podem ser denunciados e removidos. As cotações são apenas informativas e referenciais.")]})]})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl bg-white p-3 shadow-sm",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:c=>o(c.target.checked),className:"mt-0.5 h-5 w-5 shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-gray-700",children:t("trades.legendsMarket.acceptLabel","Li e concordo com as condições acima e confirmo ser maior de 18 anos.")})]}),e.jsx("div",{className:"pb-4",children:e.jsx("button",{onClick:()=>void d(),disabled:!n||a,className:k("w-full rounded-xl py-3 text-sm font-black text-white transition",!n||a?"cursor-not-allowed bg-gray-300":"bg-amber-500 hover:bg-amber-400"),children:a?e.jsx("i",{className:"fa-solid fa-spinner fa-spin"}):t("trades.legendsMarket.acceptButton","Aceitar e entrar")})})]})})}function Ce(s){const t=Math.floor(s/6e4),a=Math.floor(t/60),r=t%60;return a>0?`${a}h${r>0?` ${r}min`:""}`:`${r}min`}function Se({userId:s,fullAccess:t,isPremiumPro:a,trialMsRemaining:r,userLocation:n}){const{t:o}=j(),[d,c]=l.useState("browse"),[b,m]=l.useState(null),[f,g]=l.useState(!t),x=l.useCallback(p=>{m(p),setTimeout(()=>m(null),2800)},[]),h=t?[{key:"browse",icon:"fa-store",label:o("trades.legendsMarket.tabBrowse","Vitrine")},{key:"mine",icon:"fa-tag",label:o("trades.legendsMarket.tabMine","Minhas vitrines")},{key:"offers",icon:"fa-handshake",label:o("trades.legendsMarket.tabOffers","Propostas")},{key:"index",icon:"fa-chart-line",label:o("trades.legendsMarket.tabIndex","Cotações")}]:[{key:"browse",icon:"fa-store",label:o("trades.legendsMarket.tabBrowse","Vitrine")},{key:"index",icon:"fa-chart-line",label:o("trades.legendsMarket.tabIndex","Cotações")}];return e.jsxs("div",{className:"flex h-full flex-col",children:[r>0&&e.jsx("div",{className:"bg-amber-50 px-3 py-1 text-center text-[10px] font-medium text-amber-700/80",children:o("trades.legendsMarket.trialNotice","Acesso de teste · expira em {{time}}",{time:Ce(r)})}),e.jsx("div",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-gray-200 bg-white px-2 py-2",children:h.map(p=>e.jsxs("button",{onClick:()=>c(p.key),className:k("flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-bold transition",d===p.key?"bg-amber-500 text-white shadow":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:[e.jsx("i",{className:k("fa-solid",p.icon)}),p.label]},p.key))}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",style:{paddingBottom:"var(--app-bottom-inset, 1rem)"},children:[d==="browse"&&e.jsx(Oe,{userId:s,fullAccess:t,userLocation:n,showToast:x}),d==="mine"&&t&&e.jsx(Re,{userId:s,userLocation:n,showToast:x}),d==="offers"&&t&&e.jsx(Ie,{userId:s,showToast:x}),d==="index"&&(t?e.jsx(De,{}):e.jsx(Ee,{onUnlock:E,kind:"index"}))]}),!t&&d==="browse"&&e.jsx("div",{style:{paddingBottom:"var(--app-bottom-inset, 0px)"},children:e.jsx(Le,{isPremiumPro:a,onUnlock:E})}),f&&e.jsx(Pe,{onClose:()=>g(!1),onSubscribe:()=>{g(!1),E()}}),b&&e.jsx("div",{className:"pointer-events-none fixed left-1/2 z-[980] -translate-x-1/2 roun
2ded-xl bg-gray-900 px-4 py-2 text-sm font-bold text-white shadow-lg",style:{bottom:"calc(1.5rem + var(--app-bottom-inset, 0px))"},children:b})]})}function Pe({onClose:s,onSubscribe:t}){const{t:a}=j(),r=[a("trades.legendsMarket.proUpsellBenefit1","â Exponha suas figurinhas Legends na vitrine"),a("trades.legendsMarket.proUpsellBenefit2","ð Filtre compradores pela sua região"),a("trades.legendsMarket.proUpsellBenefit3","ð¬ Combine via WhatsApp com segurança"),a("trades.legendsMarket.proUpsellBenefit4","ð Acesse as cotações de mercado")];return $.createPortal(e.jsx("div",{className:"fixed inset-0 z-[985] flex items-end justify-center bg-black/55 p-0 sm:items-center sm:p-4",onClick:s,children:e.jsxs("div",{className:"w-full max-w-md overflow-hidden rounded-t-2xl bg-white shadow-2xl sm:rounded-2xl",onClick:n=>n.stopPropagation(),style:{paddingBottom:"var(--app-bottom-inset, env(safe-area-inset-bottom, 0px))"},children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-yellow-500 via-amber-500 to-orange-500 px-6 py-5 text-center text-white",children:[e.jsx("div",{className:"absolute -top-6 -left-6 h-24 w-24 rounded-full bg-white/10"}),e.jsx("div",{className:"absolute -right-4 -bottom-4 h-20 w-20 rounded-full bg-white/10"}),e.jsx("button",{onClick:s,className:"absolute top-3 right-3 flex h-7 w-7 items-center justify-center rounded-full bg-black/20 text-white/80",children:e.jsx("i",{className:"fa-solid fa-xmark text-xs"})}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"text-4xl",children:"ðâ"}),e.jsx("h3",{className:"mt-2 text-lg font-black drop-shadow",children:a("trades.legendsMarket.proUpsellTitle","Assine o Premium Pro")}),e.jsx("p",{className:"mt-1 text-sm font-medium text-white/90",children:a("trades.legendsMarket.proUpsellSubtitle","Divulgue suas Legends e acesse todos os recursos!")})]})]}),e.jsxs("div",{className:"px-5 pt-4 pb-2",children:[e.jsx("p",{className:"mb-3 text-center text-[11px] font-black tracking-wide text-gray-400 uppercase",children:"O que você desbloqueia"}),e.jsx("div",{className:"space-y-2",children:r.map(n=>e.jsx("div",{className:"flex items-center gap-2 rounded-lg bg-amber-50 px-3 py-2 text-sm text-gray-700",children:n},n))})]}),e.jsxs("div",{className:"px-5 pb-5 pt-3",children:[e.jsx("button",{onClick:t,className:"w-full rounded-xl bg-gradient-to-r from-amber-500 to-yellow-400 py-3 text-sm font-black text-white shadow-lg shadow-amber-300/30 transition active:scale-[0.98]",children:a("trades.legendsMarket.proUpsellCta","Assinar Premium Pro")}),e.jsx("button",{onClick:s,className:"mt-2 w-full py-2 text-xs font-medium text-gray-400 transition hover:text-gray-600",children:a("trades.legendsMarket.proUpsellDismiss","Agora não")})]})]})}),document.body)}function C({playerId:s,type:t,size:a="md"}){const{t:r}=j(),n=D[t];return e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:a==="sm"?"text-base":"text-xl",children:ve(s)}),e.jsx("span",{className:k("truncate font-black text-gray-800",a==="sm"?"text-xs":"text-sm"),children:je(s)}),e.jsx("span",{className:k("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-black",n.chip),children:r(n.labelKey,n.fallback)})]})}function A({icon:s,text:t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 rounded-2xl bg-white py-12 text-center shadow-sm",children:[e.jsx("span",{className:"text-4xl opacity-60",children:s}),e.jsx("p",{className:"px-6 text-sm font-semibold text-gray-400",children:t})]})}function Le({isPremiumPro:s,onUnlock:t}){const{t:a}=j();return e.jsxs("div",{className:"flex items-center gap-3 border-t border-amber-200 bg-amber-50 px-4 py-2.5",children:[e.jsx("i",{className:"fa-solid fa-lock text-amber-500"}),e.jsx("p",{className:"flex-1 text-[12px] leading-snug font-semibold text-amber-900",children:a("trades.legendsMarket.blurHint","Preços, contatos e cotações ficam visÃveis no Premium Pro.")}),e.jsx("button",{onClick:t,className:"shrink-0 rounded-lg bg-amber-500 px-3 py-1.5 text-xs font-black text-white transition hover:bg-amber-400",children:a("trades.legendsMarket.unlock","Desbloquear")})]})}function Ee({onUnlock:s,kind:t}){const{t:a}=j();return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 rounded-2xl bg-white py-12 text-center shadow-sm",children:[e.jsx("span",{className:"text-4xl",children:"ð"}),e.jsx("p",{className:"px-6 text-sm font-semibold text-gray-500",children:t==="index"?a("trades.legendsMarket.indexLocked","As cotações estão disponÃveis no Premium Pro."):""}),e.jsx("button",{onClick:s,className:"rounded-xl bg-amber-500 px-5 py-2.5 text-sm font-black text-white transition hover:bg-amber-400",children:a("trades.legendsMarket.unlock","Desbloquear")})]})}function Ae({value:s,onChange:t,disabled:a,premiumLocked:r}){const{t:n}=j();return e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-bold text-gray-500",children:[e.jsx("i",{className:"fa-solid fa-location-dot mr-1"}),n("trades.legendsMarket.distanceLabel","Distância"),":"]}),e.jsx("select",{value:s,onChange:o=>t(Number(o.target.value)),disabled:a,className:"rounded-lg border border-gray-200 bg-white px-2 py-1 text-xs font-bold text-gray-700 disabled:opacity-50",children:ye.map(o=>e.jsx("option",{value:o,children:o===0?n("trades.legendsMarket.distanceAll","Sem limite"):`${o} km`},o))}),r?e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-amber-600",children:[e.jsx("i",{className:"fa-solid fa-lock"}),n("trades.legendsMarket.distancePremiumLocked","Premium Pro")]}):a?e.jsx("span",{className:"text-[10px] text-gray-400",children:n("trades.legendsMarket.distanceNoLoc","Ative a localização")}):null]})}function Oe({userId:s,fullAccess:t,userLocation:a,showToast:r}){const{t:n}=j(),[o,d]=l.useState([]),[c,b]=l.useState(!0),[m,f]=l.useState(0),[g,x]=l.useState(null),[h,p]=l.useState(null),w=l.useCallback(async()=>{b(!0);try{d(t?await te():await ae())}catch{r(n("trades.legendsMarket.loadError","Erro ao carregar a vitrine"))}finally{b(!1)}},[t,r,n]);l.useEffect(()=>{w()},[w]);const u=l.useMemo(()=>m===0||!a?o:o.filter(v=>{const i=z(v,a);return i!==null&&i<=m}),[o,m,a]);return c?e.jsx(P,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{value:m,onChange:f,disabled:!a||!t,premiumLocked:!t}),u.length===0?e.jsx(A,{icon:"ð",text:n("trades.legendsMarket.noListings","Nenhum item na vitrine no momento.")}):e.jsx("div",{className:"space-y-3",children:u.map(v=>{const i=v.sellerId===s,y=z(v,a);return e.jsxs("div",{className:"rounded-2xl bg-white p-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(C,{playerId:v.playerId,type:v.legendType}),t?e.jsx("span",{className:"shrink-0 text-sm font-black text-emerald-600",children:M(v.askingPrice)??n("trades.legendsMarket.negotiable","A combinar")}):e.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-2 py-0.5 text-sm font-black text-transparent blur-sm select-none",children:"R$ 00,00"})]}),t&&v.notes&&e.jsx("p",{className:"mt-2 text-[13px] leading-snug text-gray-600",children:v.notes}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-[11px] text-gray-400",children:[t?e.jsxs("span",{className:"truncate",children:[e.jsx("i",{className:"fa-solid fa-user mr-1"}),v.seller?.nickname||n("trades.someone","Alguém")]}):e.jsxs("span",{className:"truncate text-transparent blur-sm select-none",children:[e.jsx("i",{className:"fa-solid fa-user mr-1"}),"colecionador"]}),t&&y!==null&&e.jsxs("span",{className:"shrink-0 text-gray-400",children:["· ",y<1?"<1":Math.round(y)," km"]})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[t&&e.jsx("button",{onClick:()=>p(v),className:"rounded-lg px-2 py-1 text-[11px] font-bold text-gray-400 transition hover:text-red-500",title:n("trades.legendsMarket.report","Denunciar"),children:e.jsx("i",{className:"fa-solid fa-flag"})}),t?i?e.jsx("span",{className:"rounded-lg bg-gray-100 px-3 py-1.5 text-xs font-bold text-gray-400",children:n("trades.legendsMarket.yourListing","Sua vitrine")}):e.jsx("button",{onClick:()=>x(v),className:"rounded-lg bg-amber-500 px-3 py-1.5 text-xs font-bold text-white transition hover:bg-amber-400",children:n("trades.legendsMarket.makeOffer","Tenho interesse")}):e.jsxs("button",{onClick:()=>E(),className:"rounded-lg bg-gray-200 px-3 py-1.5 text-xs font-bold text-gray-500 transition hover:bg-gray-300",children:[e.jsx("i",{className:"fa-solid fa-lock mr-1"})," ",n("trades.legendsMarket.makeOffer","Tenho interesse")]})]})]})]},v.id)})}),g&&e.jsx(_e,{listing:g,buyerId:s,onClose:()=>x(null),onDone:()=>{x(null),r(n("trades.legendsMarket.offerSent","Proposta enviada!"))}}),h&&e.jsx(Ue,{listing:h,reporterId:s,onClose:()=>p(null),onDone:()=>{p(null),r(n("trades.legendsMarket.reportSent","Denúncia enviada. Obrigado!"))}})]})}function Re({userId:s,userLocation:t,showToast:a}){const{t:r}=j(),[n,o]=l.useState([]),[d,c]=l.useState(!0),[b,m]=l.useState(!1),f=l.useCallback(async()=>{c(!0);try{o(await se(s))}catch{a(r("trades.legendsMarket.loadError","Erro ao carregar a vitrine"))}finally{c(!1)}},[s,a,r]);l.useEffect(()=>{f()},[f]);const g=async x=>{if(window.confirm(r("trades.legendsMarket.cancelConfirm","Remover este item da vitrine?")))try{await oe(x),a(r("trades.legendsMarket.listingCancelled","Item removido")),await f()}catch{a(r("trades.legendsMarket.actionError","Não foi possÃvel concluir a ação"))}};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>m(!0),className:"mb-4 flex w-full items-center justify-center gap-2 rounded-xl bg-amber-500 py-3 text-sm font-black text-white shadow transition hover:bg-amber-400",children:[e.jsx("i",{className:"fa-solid fa-plus"})," ",r("trades.legendsMarket.newListing","Expor uma Legend")]}),d?e.jsx(P,{}):n.length===0?e.jsx(A,{icon:"ð·ï¸",text:r("trades.legendsMarket.noMyListings","Você ainda não expôs nada.")}):e.jsx("div",{className:"space-y-3",children:n.map(x=>e.jsxs("div",{className:"rounded-2xl bg-white p-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(C,{playerId:x.playerId,type:x.legendT
2ype}),e.jsx("span",{className:"shrink-0 text-sm font-black text-emerald-600",children:M(x.askingPrice)??r("trades.legendsMarket.negotiable","A combinar")})]}),x.notes&&e.jsx("p",{className:"mt-2 text-[13px] leading-snug text-gray-600",children:x.notes}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx(T,{status:x.status}),x.status==="active"&&e.jsxs("button",{onClick:()=>void g(x.id),className:"rounded-lg px-3 py-1.5 text-xs font-bold text-red-500 transition hover:bg-red-50",children:[e.jsx("i",{className:"fa-solid fa-trash mr-1"})," ",r("trades.legendsMarket.removeListing","Remover")]})]})]},x.id))}),b&&e.jsx(Te,{sellerId:s,userLocation:t,onClose:()=>m(!1),onDone:()=>{m(!1),a(r("trades.legendsMarket.listingCreated","Item publicado na vitrine!")),f()}})]})}function T({status:s}){const{t}=j(),r={active:{label:t("trades.legendsMarket.statusActive","Ativo"),cls:"bg-emerald-100 text-emerald-700"},sold:{label:t("trades.legendsMarket.statusSold","ConcluÃdo"),cls:"bg-blue-100 text-blue-700"},cancelled:{label:t("trades.legendsMarket.statusCancelled","Removido"),cls:"bg-gray-100 text-gray-500"},pending:{label:t("trades.legendsMarket.statusPending","Pendente"),cls:"bg-amber-100 text-amber-700"},accepted:{label:t("trades.legendsMarket.statusAccepted","Aceita"),cls:"bg-emerald-100 text-emerald-700"},rejected:{label:t("trades.legendsMarket.statusRejected","Recusada"),cls:"bg-red-100 text-red-600"}}[s]??{label:s,cls:"bg-gray-100 text-gray-500"};return e.jsx("span",{className:k("rounded-full px-2 py-0.5 text-[10px] font-black",r.cls),children:r.label})}function Ie({userId:s,showToast:t}){const{t:a}=j(),[r,n]=l.useState([]),[o,d]=l.useState([]),[c,b]=l.useState([]),[m,f]=l.useState(!0),[g,x]=l.useState(null),h=l.useCallback(async()=>{f(!0);try{const[i,y,N]=await Promise.all([ne(s),re(s),le(s)]);n(i),d(y),b(N)}catch{t(a("trades.legendsMarket.loadError","Erro ao carregar propostas"))}finally{f(!1)}},[s,t,a]);l.useEffect(()=>{h()},[h]);const p=async i=>{try{await W(i.id,"rejected"),t(a("trades.legendsMarket.offerRejected","Proposta recusada")),await h()}catch{t(a("trades.legendsMarket.actionError","Não foi possÃvel concluir a ação"))}},w=async i=>{try{await W(i.id,"cancelled"),t(a("trades.legendsMarket.offerCancelled","Proposta cancelada")),await h()}catch{t(a("trades.legendsMarket.actionError","Não foi possÃvel concluir a ação"))}},u=async i=>{try{await ce(i.id),t(a("trades.legendsMarket.saleConfirmed","Negociação confirmada! Obrigado por contribuir com as cotações.")),await h()}catch{t(a("trades.legendsMarket.actionError","Não foi possÃvel concluir a ação"))}};return m?e.jsx(P,{}):r.length===0&&o.length===0&&c.length===0?e.jsx(A,{icon:"ð¤",text:a("trades.legendsMarket.noOffers","Nenhuma proposta ou negociação ainda.")}):e.jsxs("div",{className:"space-y-5",children:[c.length>0&&e.jsxs("section",{children:[e.jsx(I,{icon:"fa-clipboard-check",text:a("trades.legendsMarket.confirmSection","Confirme o valor da negociação")}),e.jsx("div",{className:"space-y-3",children:c.map(i=>e.jsxs("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-3",children:[e.jsx(C,{playerId:i.playerId,type:i.legendType,size:"sm"}),e.jsxs("p",{className:"mt-2 text-[13px] text-amber-900",children:[a("trades.legendsMarket.confirmPrompt","O vendedor informou o valor de")," ",e.jsx("strong",{children:M(i.finalPrice)}),"."," ",a("trades.legendsMarket.confirmHint","Confirma que esse foi o valor combinado?")]}),e.jsxs("button",{onClick:()=>void u(i),className:"mt-2 rounded-lg bg-emerald-600 px-3 py-1.5 text-xs font-bold text-white transition hover:bg-emerald-500",children:[e.jsx("i",{className:"fa-solid fa-check mr-1"})," ",a("trades.legendsMarket.confirmValue","Confirmar valor")]})]},i.id))})]}),r.length>0&&e.jsxs("section",{children:[e.jsx(I,{icon:"fa-inbox",text:a("trades.legendsMarket.incomingSection","Propostas recebidas")}),e.jsx("div",{className:"space-y-3",children:r.map(i=>e.jsxs("div",{className:"rounded-2xl bg-white p-3 shadow-sm",children:[i.listing&&e.jsx(C,{playerId:i.listing.playerId,type:i.listing.legendType,size:"sm"}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-black text-emerald-600",children:M(i.offerPrice)}),e.jsx(T,{status:i.status})]}),i.message&&e.jsxs("p",{className:"mt-1 text-[13px] text-gray-600",children:["â",i.message,"â"]}),e.jsxs("p",{className:"mt-1 text-[11px] text-gray-400",children:[e.jsx("i",{className:"fa-solid fa-user mr-1"}),i.buyer?.nickname||a("trades.someone","Alguém")]}),(i.status==="pending"||i.status==="accepted")&&e.jsx(V,{offerId:i.id}),i.status==="pending"&&e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsxs("button",{onClick:()=>x(i),className:"flex-1 rounded-lg bg-emerald-600 py-2 text-xs font-bold text-white transition hover:bg-emerald-500",children:[e.jsx("i",{className:"fa-solid fa-check mr-1"})," ",a("trades.legendsMarket.acceptAndConclude","Aceitar e concluir")]}),e.jsx("button",{onClick:()=>void p(i),className:"flex-1 rounded-lg border border-gray-200 py-2 text-xs font-bold text-gray-600 transition hover:bg-gray-50",children:a("trades.reject","Recusar")})]})]},i.id))})]}),o.length>0&&e.jsxs("section",{children:[e.jsx(I,{icon:"fa-paper-plane",text:a("trades.legendsMarket.outgoingSection","Propostas enviadas")}),e.jsx("div",{className:"space-y-3",children:o.map(i=>e.jsxs("div",{className:"rounded-2xl bg-white p-3 shadow-sm",children:[i.listing&&e.jsx(C,{playerId:i.listing.playerId,type:i.listing.legendType,size:"sm"}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-black text-emerald-600",children:M(i.offerPrice)}),e.jsx(T,{status:i.status})]}),(i.status==="pending"||i.status==="accepted")&&e.jsx(V,{offerId:i.id}),i.status==="pending"&&e.jsx("button",{onClick:()=>void w(i),className:"mt-2 rounded-lg px-3 py-1.5 text-xs font-bold text-red-500 transition hover:bg-red-50",children:a("trades.legendsMarket.cancelOffer","Cancelar proposta")})]},i.id))})]}),g&&e.jsx(Be,{offer:g,onClose:()=>x(null),onDone:()=>{x(null),t(a("trades.legendsMarket.saleRecorded","Negociação registrada! Aguardando confirmação do comprador.")),h()}})]})}function I({icon:s,text:t}){return e.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-xs font-black tracking-wide text-gray-500 uppercase",children:[e.jsx("i",{className:k("fa-solid",s)})," ",t]})}function V({offerId:s}){const{t}=j(),[a,r]=l.useState(null),[n,o]=l.useState(!1),d=l.useCallback(async()=>{try{r(await xe(s))}catch{r({available:!1})}},[s]);if(l.useEffect(()=>{d()},[d]),!a||!a.available)return null;const c=async b=>{o(!0);try{r(await b())}catch{}finally{o(!1)}};return e.jsxs("div",{className:"mt-2 rounded-lg border border-green-100 bg-green-50 p-2.5",children:[e.jsxs("p",{className:"mb-1.5 flex items-center gap-1.5 text-[11px] font-bold text-green-800",children:[e.jsx("i",{className:"fa-brands fa-whatsapp text-green-600"}),t("trades.legendsMarket.waTitle","Contato por WhatsApp")]}),a.canOpenWhatsapp&&a.whatsappUrl?e.jsxs("a",{href:a.whatsappUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-1.5 rounded-lg bg-green-600 px-3 py-1.5 text-xs font-bold text-white transition hover:bg-green-500",children:[e.jsx("i",{className:"fa-brands fa-whatsapp"})," ",t("trades.legendsMarket.waOpen","Abrir conversa")]}):e.jsx("p",{className:"mb-1.5 text-[11px] text-gray-500",children:a.otherRequested?t("trades.legendsMarket.waOtherRequested","A outra pessoa quer combinar pelo WhatsApp."):t("trades.legendsMarket.waNotShared","Compartilhe seu WhatsApp para combinar a entrega.")}),a.myHasPhone?a.myShared?e.jsx("button",{onClick:()=>void c(()=>fe(s)),disabled:n,className:"mt-1.5 w-full rounded-lg px-3 py-1.5 text-[11px] font-bold text-gray-500 transition hover:bg-gray-100 disabled:opacity-50",children:t("trades.legendsMarket.waStopSharing","Parar de compartilhar meu número")}):e.jsx("button",{onClick:()=>void c(()=>be(s)),disabled:n,className:"mt-1.5 w-full rounded-lg bg-green-600 px-3 py-1.5 text-[11px] font-bold text-white transition hover:bg-green-500 disabled:opacity-50",children:t("trades.legendsMarket.waShare","Compartilhar meu WhatsApp")}):e.jsx("button",{onClick:()=>window.dispatchEvent(new CustomEvent("tf:open-settings-whatsapp")),className:"mt-1.5 w-full rounded-lg bg-white px-3 py-1.5 text-[11px] font-bold text-green-700 ring-1 ring-green-200 transition hover:bg-green-100",children:t("trades.legendsMarket.waAddNumber","Adicionar meu WhatsApp")}),a.myHasPhone&&!a.canOpenWhatsapp&&!a.myRequested&&e.jsx("button",{onClick:()=>void c(()=>he(s)),disabled:n,className:"mt-1.5 w-full rounded-lg px-3 py-1.5 text-[11px] font-bold text-green-700 transition hover:bg-green-100 disabled:opacity-50",children:t("trades.legendsMarket.waRequest","Pedir o WhatsApp da outra pessoa")})]})}function De(){const{t:s}=j(),[t,a]=l.useState([]),[r,n]=l.useState(!0);l.useEffect(()=>{let d=!1;return(async()=>{try{const c=await ie();d||a(c)}catch{}finally{d||n(!1)}})(),()=>{d=!0}},[]);const o=l.useMemo(()=>[...t].sort((d,c)=>c.avgPrice-d.avgPrice),[t]);return r?e.jsx(P,{}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 p-3 text-[12px] leading-snug text-blue-800",children:[e.jsx("i",{className:"fa-solid fa-circle-info mr-1"}),s("trades.legendsMarket.indexDisclaimer","Cotações meramente informativas e referenciais, baseadas em negociações concluÃdas e confirmadas pelos usuários (dados anônimos e agregados). Não representam cotação oficial.")]}),o.length===0?e.jsx(A,{icon:"ð",text:s("trades.legendsMarket.noIndex","Ainda não há negociações suficientes para gerar as cotações.")}):e.jsx("div",{className:"space-y-2",children:o.map(d=>e.jsxs("div",{className:"rounded-2xl bg-white p-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(C,{playerId:d.playerId,type:d.legendT
2ype,size:"sm"}),e.jsx("span",{className:"shrink-0 text-base font-black text-emerald-600",children:M(d.avgPrice)})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-[11px] text-gray-400",children:[e.jsxs("span",{children:[s("trades.legendsMarket.indexRange","Faixa"),": ",M(d.minPrice)," â ",M(d.maxPrice)]}),e.jsx("span",{children:s("trades.legendsMarket.indexSamples","{{count}} negociações",{count:d.sampleCount})})]})]},`${d.playerId}_${d.legendType}`))})]})}function O({title:s,onClose:t,children:a}){return $.createPortal(e.jsx("div",{className:"fixed inset-0 z-[985] flex items-end justify-center bg-black/50 p-0 sm:items-center sm:p-4",onClick:t,children:e.jsxs("div",{className:"max-h-[90dvh] w-full max-w-md overflow-y-auto rounded-t-2xl bg-white px-5 pt-5 shadow-2xl sm:rounded-2xl",onClick:r=>r.stopPropagation(),style:{paddingBottom:"calc(1.25rem + var(--app-bottom-inset, env(safe-area-inset-bottom, 0px)))"},children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-black text-gray-800",children:s}),e.jsx("button",{onClick:t,className:"flex h-8 w-8 items-center justify-center rounded-full bg-gray-100 text-gray-500",children:e.jsx("i",{className:"fa-solid fa-xmark"})})]}),a]})}),document.body)}function Te({sellerId:s,userLocation:t,onClose:a,onDone:r}){const{t:n}=j(),[o,d]=l.useState(0),[c,b]=l.useState("gold"),[m,f]=l.useState(""),[g,x]=l.useState(""),[h,p]=l.useState(!1),w=async()=>{p(!0);try{await pe({sellerId:s,playerId:o,legendType:c,askingPrice:B(m),notes:g,sellerLat:t?.lat??null,sellerLng:t?.lng??null}),r()}catch{p(!1)}};return e.jsx(O,{title:n("trades.legendsMarket.newListing","Expor uma Legend"),onClose:a,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-bold text-gray-500",children:n("album.player","Jogador")}),e.jsx("select",{value:o,onChange:u=>d(Number(u.target.value)),className:"w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm",children:_.map(u=>e.jsxs("option",{value:u.id,children:[u.flag," ",u.name]},u.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-bold text-gray-500",children:n("trades.legendsMarket.type","Tipo")}),e.jsx("select",{value:c,onChange:u=>b(u.target.value),className:"w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm",children:de.map(u=>e.jsx("option",{value:u,children:n(D[u].labelKey,D[u].fallback)},u))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-bold text-gray-500",children:n("trades.legendsMarket.priceOptional","Preço de referência (opcional)")}),e.jsx("input",{value:m,onChange:u=>f(u.target.value),inputMode:"decimal",placeholder:n("trades.legendsMarket.pricePlaceholder","Ex: 49,90 â deixe vazio para 'a combinar'"),className:"w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-bold text-gray-500",children:n("trades.legendsMarket.notes","Observações (opcional)")}),e.jsx("textarea",{value:g,onChange:u=>x(u.target.value.slice(0,280)),rows:2,placeholder:n("trades.legendsMarket.notesPlaceholder","Estado, detalhes da negociação, sua cidade..."),className:"w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm"})]}),e.jsx("button",{onClick:()=>void w(),disabled:h,className:k("w-full rounded-xl py-3 text-sm font-black text-white transition",h?"cursor-not-allowed bg-gray-300":"bg-amber-500 hover:bg-amber-400"),children:h?e.jsx("i",{className:"fa-solid fa-spinner fa-spin"}):n("trades.legendsMarket.publish","Publicar na vitrine")})]})})}function _e({listing:s,buyerId:t,onClose:a,onDone:r}){const{t:n}=j(),[o,d]=l.useState(s.askingPrice!==null?String(s.askingPrice).replace(".",","):""),[c,b]=l.useState(""),[m,f]=l.useState(!1),[g,x]=l.useState(!1),h=async()=>{const p=B(o);if(p===null){x(!0);return}f(!0);try{await me({listingId:s.id,buyerId:t,offerPrice:p,message:c}),r()}catch{f(!1)}};return e.jsxs(O,{title:n("trades.legendsMarket.makeOfferTitle","Demonstrar interesse"),onClose:a,children:[e.jsx("div",{className:"mb-3 rounded-xl bg-gray-50 p-3",children:e.jsx(C,{playerId:s.playerId,type:s.legendT
2ype,size:"sm"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-bold text-gray-500",children:n("trades.legendsMarket.yourOffer","Sua proposta")}),e.jsx("input",{value:o,onChange:p=>{d(p.target.value),x(!1)},inputMode:"decimal",placeholder:"Ex: 45,00",className:k("w-full rounded-lg border bg-white px-3 py-2 text-sm",g?"border-red-400":"border-gray-200")}),g&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:n("trades.legendsMarket.invalidPrice","Informe um valor válido")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-bold text-gray-500",children:n("trades.legendsMarket.message","Mensagem (opcional)")}),e.jsx("textarea",{value:c,onChange:p=>b(p.target.value.slice(0,280)),rows:2,className:"w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm"})]}),e.jsx("button",{onClick:()=>void h(),disabled:m,className:k("w-full rounded-xl py-3 text-sm font-black text-white transition",m?"cursor-not-allowed bg-gray-300":"bg-amber-500 hover:bg-amber-400"),children:m?e.jsx("i",{className:"fa-solid fa-spinner fa-spin"}):n("trades.legendsMarket.sendOffer","Enviar proposta")})]})]})}function Be({offer:s,onClose:t,onDone:a}){const{t:r}=j(),[n,o]=l.useState(String(s.offerPrice).replace(".",",")),[d,c]=l.useState(!1),[b,m]=l.useState(!1),f=async()=>{const g=B(n);if(g===null){m(!0);return}c(!0);try{await ue(s,g),a()}catch{c(!1)}};return e.jsxs(O,{title:r("trades.legendsMarket.concludeTitle","Concluir negociação"),onClose:t,children:[s.listing&&e.jsx("div",{className:"mb-3 rounded-xl bg-gray-50 p-3",children:e.jsx(C,{playerId:s.listing.playerId,type:s.listing.legendType,size:"sm"})}),e.jsx("p",{className:"mb-3 text-[13px] leading-snug text-gray-600",children:r("trades.legendsMarket.concludeHint","Informe o valor final combinado. O comprador precisará confirmar. Isso alimenta as cotações (anônimas).")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-bold text-gray-500",children:r("trades.legendsMarket.finalValue","Valor final")}),e.jsx("input",{value:n,onChange:g=>{o(g.target.value),m(!1)},inputMode:"decimal",className:k("w-full rounded-lg border bg-white px-3 py-2 text-sm",b?"border-red-400":"border-gray-200")}),b&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:r("trades.legendsMarket.invalidPrice","Informe um valor válido")})]}),e.jsx("button",{onClick:()=>void f(),disabled:d,className:k("w-full rounded-xl py-3 text-sm font-black text-white transition",d?"cursor-not-allowed bg-gray-300":"bg-emerald-600 hover:bg-emerald-500"),children:d?e.jsx("i",{className:"fa-solid fa-spinner fa-spin"}):r("trades.legendsMarket.confirmConclude","Confirmar conclusão")})]})]})}function Ue({listing:s,reporterId:t,onClose:a,onDone:r}){const{t:n}=j(),[o,d]=l.useState(""),[c,b]=l.useState(!1),m=async()=>{b(!0);try{await ge(s.id,t,o),r()}catch{b(!1)}};return e.jsxs(O,{title:n("trades.legendsMarket.reportTitle","Denunciar item"),onClose:a,children:[e.jsx("p",{className:"mb-3 text-[13px] leading-snug text-gray-600",children:n("trades.legendsMarket.reportHint","Conte o motivo (item falsificado, golpe, conteúdo impróprio, etc.). Nossa equipe irá analisar.")}),e.jsx("textarea",{value:o,onChange:f=>d(f.target.value.slice(0,500)),rows:3,placeholder:n("trades.legendsMarket.reportPlaceholder","Descreva o problema..."),className:"mb-3 w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm"}),e.jsx("button",{onClick:()=>void m(),disabled:c||!o.trim(),className:k("w-full rounded-xl py-3 text-sm font-black text-white transition",c||!o.trim()?"cursor-not-allowed bg-gray-300":"bg-red-500 hover:bg-red-400"),children:c?e.jsx("i",{className:"fa-solid fa-spinner fa-spin"}):n("trades.legendsMarket.sendReport","Enviar denúncia")})]})}export{Fe 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.