1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B29x19vy.js","assets/index-8EMmiI2f.css"])))=>i.map(i=>d[i]); 2import{u as us,D as Je,ea as hs,ed as fs,aL as gs,r as l,as as me,ae as E,j as e,dj as bs,c_ as ke,bf as Ze,dk as Qe,cz as ys,F as Xe,cw as Ce,aM as js,V as K,n as vs,ec as Ns,bd as ne,be as ie,bg as oe,bw as ws,cW as _s,aq as ks,ad as H,a1 as Cs,a0 as Ss,cL as Is,a3 as Ms,p as Ps,al as es,am as ss,an as rs,ao as ts,ee as Ls,ap as as,W as h,x as Es,ef as Rs,dd as ze,af as qs,aK as Ts,I as As,T as Bs,eg as Fs}from"./index-B29x19vy.js";import{I as Y}from"./input-DlI5hdWK.js";import{T as Os}from"./textarea-DCvB6Rhz.js";import{P as $s}from"./PromoNotice-CgMEuEIW.js";import{L as I}from"./label-CwfDO0Ee.js";import{B as Se}from"./badge-DY9NB_ci.js";import{S as Ke,a as Ve,b as Ue,c as We,e as le,f as ce,d as Ge}from"./select-DRUuYEII.js";import{C as Ds}from"./CategorySidebar-C93mORAH.js";import{M as Qs}from"./MobileCategoryFlyout-BSEoP2q9.js";import{g as He}from"./serviceLinks-CLQrAwD3.js";import{U as Xs}from"./UnifiedOrderCard-BbFDJBlK.js";import{P as L,d as Ie}from"./smmPlatform-34tCK8Z5.js";import{g as de,u as zs,a as Ye}from"./smmUnitBasis-DdJ4eBp1.js";import{C as Ks}from"./credit-card-Dacs2Zal.js";import{o as Vs,s as Us,n as Ws}from"./types-CeNoQn1N.js";import"./index-9BqJAWWA.js";import"./chevron-up-CDA9uoHs.js";import"./categoryIcons-C0gqmBE7.js";import"./ClaudeIcon-ChfFkQMx.js";import"./tag-BJ6GvW45.js";import"./filter-BgMTjCWL.js";import"./chevrons-right-YSUJ5mRv.js";import"./circle-check-big-Bf3_DD3q.js";import"./truck-BZ7qSGvF.js";import"./createReactComponent-CIt0eOV3.js";const Gs=Vs({link:Us().trim().url({message:"Link inválido (precisa começar com http/https)"}).max(500),quantity:Ws().int().min(1,"Quantidade inválida")});function Hs(x){return new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(x)}function Ys(x){const D=Math.abs(x);let _=2;if(D>0&&D<1){const R=D.toFixed(6).replace(/0+$/,""),q=R.indexOf(".");_=q===-1?2:Math.min(6,Math.max(2,R.length-q-1))}return new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:_,maximumFractionDigits:_}).format(x)}function Js(){const{user:x,session:D,loading:_}=us(),v=Je(),{data:R=0,isError:q,isPending:J}=hs(),V=q?"Saldo indisponÃvel":J?"â":fs(R),{data:Q=!1}=gs(),T=Ys,[u,N]=l.useState("all"),[A,Z]=l.useState(""),[pe,xe]=l.useState(""),[ue,he]=l.useState(""),[B,ee]=l.useState(0),[fe,ge]=l.useState(""),[M,be]=l.useState("balance"),[Me,Pe]=l.useState(!1),[F,ye]=l.useState(null),[ns,je]=l.useState(!1),[is,ve]=l.useState(!1),[se,re]=l.useState("services");l.useState(!1);const[U,Le]=l.useState(()=>typeof window>"u"?"":new URLSearchParams(window.location.search).get("q")||""),{data:f=[],isLoading:Ee,refetch:Re,isFetching:qe}=me({queryKey:["smm-public-services"],queryFn:async()=>{const{data:r,error:t}=await E.functions.invoke("smm-services-public",{method:"GET"});if(t)throw t;if(r!=null&&r.error)throw new Error(r.error);return(r==null?void 0:r.services)||[]},staleTime:5*6e4,retry:3,retryDelay:r=>Math.min(1e3*2**r,8e3)}),{data:Ne=[]}=me({queryKey:["smm-bestsellers"],queryFn:async()=>{const{data:r,error:t}=await E.rpc("get_smm_bestseller_services",{_limit:50});if(t)throw t;return(r||[]).map(c=>c.provider_service_id)},staleTime:5*6e4}),{data:W=[],isLoading:os,isFetching:ls,refetch:Te}=me({queryKey:["smm-orders",x==null?void 0:x.id],queryFn:async()=>{if(!(x!=null&&x.id))return[];await E.auth.getSession();const{data:r,error:t}=await E.from("smm_orders").select("id, global_order_no, product_title_snapshot, link, quantity, price_paid, price_paid_millicents, payment_method, payment_status, status, created_at, pix_qr_code, pix_copy_paste, provider_service_id, provider_order_id, refill_id, refill_status, refill_requested_at, start_count, remains").eq("user_id",x.id).order("created_at",{ascending:!1}).limit(200);if(t)throw t;return r||[]},enabled:!_&&!!(x!=null&&x.id),staleTime:0,refetchInterval:15e3,refetchOnWindowFocus:!0,refetchOnMount:"always"}),cs=l.useMemo(()=>{const r=new Set;return f.forEach(t=>{t.refill&&r.add(Number(t.service))}),r},[f]),[Ae,Be]=l.useState(null),ds=async r=>{Be(r);try{const{data:t,error:c}=await E.functions.invoke("smm-order-refill",{body:{order_id:r}});if(c)throw new Error(await ze(c,"Não foi possÃvel solicitar o refil agora."));if(t!=null&&t.error)throw new Error((t==null?void 0:t.reason)||t.error);h.success("Refil solicitado! O provedor vai reprocessar em breve."),v.invali
2dateQueries({queryKey:["smm-orders"]})}catch(t){h.error((t==null?void 0:t.message)||"Não foi possÃvel solicitar o refil agora.")}finally{Be(null)}},k=r=>{const t=Ie(r.category);return t.key!=="outros"?t:Ie(r.name)},we=l.useMemo(()=>{const r=new Map;return f.forEach(t=>{const c=k(t),d=r.get(c.key);d?d.services.push(t):r.set(c.key,{meta:c,services:[t]})}),Array.from(r.values()).sort((t,c)=>L.findIndex(d=>d.key===t.meta.key)-L.findIndex(d=>d.key===c.meta.key))},[f]),te=l.useMemo(()=>{if(!Ne.length)return[];const r=new Map(Ne.map((t,c)=>[t,c]));return f.filter(t=>r.has(t.service)).sort((t,c)=>r.get(t.service)-r.get(c.service))},[f,Ne]),G=l.useMemo(()=>{const r=U.trim().toLowerCase();if(!r)return[];const t=/^\d+$/.test(r);return f.map(d=>{const i=String(d.service),P=d.name.toLowerCase().includes(r),z=d.category.toLowerCase().includes(r);let s=-1;if(t&&(i===r?s=0:i.startsWith(r)?s=1:i.includes(r)&&(s=2)),!P&&!z&&s<0)return null;const p=t&&s>=0?s:P?3:4;return{s:d,rank:p,id:Number(d.service)||0}}).filter(d=>d!==null).sort((d,i)=>d.rank-i.rank||d.id-i.id).slice(0,60).map(d=>d.s)},[f,U]),O=l.useMemo(()=>u==="all"?f:u==="bestsellers"?te:f.filter(r=>k(r).key===u),[f,u,te]),_e=l.useMemo(()=>{const r=new Set;return O.forEach(t=>r.add(t.category)),Array.from(r).sort()},[O]),X=l.useMemo(()=>A?O.filter(r=>r.category===A):[],[O,A]),a=l.useMemo(()=>X.find(r=>String(r.service)===pe)||null,[X,pe]);l.useEffect(()=>{if(u==="all"||u==="bestsellers")Z("");else{const r=new Set;f.filter(c=>k(c).key===u).forEach(c=>r.add(c.category));const t=Array.from(r).sort()[0]||"";Z(t)}xe("")},[u,f]);const C=!!a&&["Custom Comments","Custom Comments Package"].includes(a.type),Fe=l.useMemo(()=>fe.split(` 3`).map(r=>r.trim()).filter(r=>r.length>0),[fe]),w=Fe.length;l.useEffect(()=>{if(a){const r=parseInt(a.min,10);ee(t=>t&&t>=r&&t<=parseInt(a.max,10)?t:r),ge("")}else ee(0),ge("")},[a]),l.useEffect(()=>{if(!a||!C||a.type!=="Custom Comments")return;const r=parseInt(a.min,10),t=parseInt(a.max,10),c=Math.min(Math.max(w,r),t);ee(c)},[w,a,C]);const ae=l.useMemo(()=>{if(!a)return 0;const r=a.unit_basis??de(a.type),t=a.price_brl??a.price_brl_per_1000;return B/r*t},[a,B]),ms=Math.max(1,Math.ceil(ae*100)),$=ae>0&&ae<10,Oe=!!a&&M==="balance"&&ms>R;l.useEffect(()=>{$&&M==="pix"&&be("balance")},[$,M]);const ps=async()=>{if(!a)return;const r=parseInt(a.min,10),t=parseInt(a.max,10),c=Gs.safeParse({link:ue,quantity:B});if(!c.success){h.error(c.error.errors[0].message);return}if(B<r||B>t){h.error(`Quantidade entre ${r} e ${t}`);return}if(C){if(w===0){h.error("Adicione pelo menos 1 comentário (1 por linha).");return}if(a.type==="Custom Comments"&&(w<r||w>t)){h.error(`Envie entre ${r} e ${t} comentários (1 por linha).`);return}if(a.type==="Custom Comments Package"){const d=a.name.match(/\[\s*(\d+)\s*Coment/i),i=d?parseInt(d[1],10):null;if(i&&w!==i){h.error(`Esse pacote requer exatamente ${i} comentários (você enviou ${w}).`);return}}}Pe(!0);try{const{checkRateLimit:d}=await qs(async()=>{const{checkRateLimit:z}=await import("./index-B29x19vy.js").then(s=>s.gg);return{checkRateLimit:z}},__vite__mapDeps([0,1]));await d("create_order");const{data:i,error:P}=await E.functions.invoke("smm-user-create-order",{body:{service_id:a.service,link:c.data.link,quantity:c.data.quantity,payment_method:M,comments:C?Fe.join(` 4`):void 0}});if(P)throw new Error(await ze(P,"Erro ao criar pedido"));if(i!=null&&i.error){if(i.error==="insufficient_balance")h.error("Saldo insuficiente. Recarregue ou pague via PIX.");else if(i.error==="duplicate_active_order")h.error(i.message||"Você já tem um pedido ativo desse serviço pra esse link. Aguarde concluir ou cancele.");else if(i.error==="payment_create_failed")h.error(i.message?`Não deu pra gerar o PIX: ${i.message}`:"Não deu pra gerar o PIX agora. Tente de novo em instantes.");else throw new Error(i.error);return}v.invalidateQueries({queryKey:["smm-orders"]}),v.invalidateQueries({queryKey:["my-smm-orders"]}),v.invalidateQueries({queryKey:["user-balance"]}),re("orders"),Te(),M==="pix"&&(i!=null&&i.pix_qr_code||i!=null&&i.pix_copy_paste)?(ye({qr:i.pix_qr_code,copy:i.pix_copy_paste,total:i.total}),h.success("PIX gerado! Pague para liberar a entrega.")):(h.success('Pedido envi
4ado! Acompanhe em "Meus pedidos".'),he(""))}catch(d){h.error(d.message||"Erro ao criar pedido")}finally{Pe(!1)}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"max-w-[100rem] mx-auto px-4 md:px-8 pt-6",children:e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(bs,{className:"h-6 w-6 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-foreground flex items-center gap-2 flex-wrap",children:"Painel SMM"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Impulsione suas redes sociais com entregas automáticas e seguras."})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:()=>Re(),disabled:qe,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary text-secondary-foreground text-sm font-medium hover:bg-secondary/80 transition-colors disabled:opacity-50",title:"Atualizar catálogo",children:[e.jsx(ke,{className:`h-3.5 w-3.5 ${qe?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Atualizar"})]}),Q&&e.jsxs("button",{type:"button",onClick:()=>je(!0),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary text-secondary-foreground text-sm font-medium hover:bg-secondary/80 transition-colors",children:[e.jsx(Ze,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs("button",{type:"button",onClick:()=>ve(!0),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary text-secondary-foreground text-sm font-medium hover:bg-secondary/80 transition-colors",title:"Abrir carteira",children:[e.jsx(Qe,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:V})]})]})]})}),e.jsxs("div",{className:"max-w-[100rem] mx-auto px-4 md:px-8 py-6 md:py-8",children:[e.jsx($s,{className:"mb-4"}),e.jsx(ys,{service:"smm"}),e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"space-y-5",children:(()=>{var z;const r="Mais vendidos",t=we.map(({meta:s,services:p})=>({label:s.label,count:p.length,icon:s.icon,accentClass:s.colorClass})),c=te.length>0?[{label:r,count:te.length,icon:Xe,accentClass:"text-amber-500 dark:text-amber-300"},...t]:t,d=u==="all"?void 0:u==="bestsellers"?r:(z=we.find(({meta:s})=>s.key===u))==null?void 0:z.meta.label,i=s=>{if(re("services"),!s)return N("all");if(s===r)return N("bestsellers");const p=we.find(({meta:b})=>b.label===s);p&&N(p.meta.key)},P=e.jsxs("button",{type:"button",onClick:()=>{re(se==="orders"?"services":"orders"),se!=="orders"&&(x!=null&&x.id)&&Te()},className:`w-full flex items-center justify-between gap-2 px-4 py-3 rounded-2xl border text-sm font-semibold transition-all ${se==="orders"?"border-emerald-500/50 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"border-border bg-card/60 backdrop-blur-sm hover:bg-accent text-foreground"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"}),"Meus pedidos"]}),W.length>0&&e.jsx(Se,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:W.length})]});return e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[240px_minmax(0,1fr)] gap-6",children:[c.length>0&&e.jsx("div",{className:"hidden lg:block",children:e.jsx("div",{className:"sticky top-20",children:e.jsx(Ds,{items:c,selected:d,onSelect:i,allLabel:"Todos",extraItems:He("smm"),topAction:P})})}),e.jsxs("div",{className:"min-w-0 flex flex-col gap-5",children:[c.length>0&&e.jsx(Qs,{items:c,selected:d,onSelect:i,allLabel:"Todos",extraItems:He("smm"),topAction:P}),se==="orders"?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>re("services"),className:"lg:hidden mb-2 inline-flex items-center gap-2 px-4 py-2.5 rounded-xl border border-border bg-card/60 backdrop-blur-sm text-sm font-semibold text-foreground hover:bg-accent transition-colors",children:[e.jsx(js,{className:"h-4 w-4"}),"Voltar para o catálogo"]}),(_||os||ls)&&W.length===0?e.jsxs("div",{className:"text-center py-16 rounded-2xl border border-dashed border-border/50",children:[e.jsx(K,{className:"h-10 w-10 mx-auto text-primary mb-3 animate-spin"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando seus pedidos..."})]}):W.length===0?e.jsxs("div",{className:"text-center py-16 rounded-2xl border border-dashed border-border/50",children:[e.jsx(Ce,{className:"h-10 w-10 mx-auto text-muted-foreground
4/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum pedido ainda."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:W.map(s=>{const p={pending:"pending",processing:"info",in_progress:"info",completed:"success",partial:"pending",canceled:"muted",failed:"danger"},b={pending:"Pendente",processing:"Processando",in_progress:"Em andamento",completed:"ConcluÃdo",partial:"Parcial",canceled:"Cancelado",failed:"Falhou"},y=p[s.status]||"pending",n=s.status==="processing"||s.status==="in_progress",m=T(s.price_paid_millicents?s.price_paid_millicents/1e5:s.price_paid/100),o=Ie(s.product_title_snapshot),j=o.icon;return e.jsx(Xs,{title:s.product_title_snapshot,shortId:s.global_order_no??void 0,createdAtLabel:vs(new Date(s.created_at),{addSuffix:!0,locale:Ts}),status:{label:b[s.status]||s.status,tone:y,icon:n?e.jsx(K,{className:"h-4 w-4"}):void 0,spin:n},thumbnail:e.jsx("div",{className:`w-12 h-12 rounded-lg bg-gradient-to-br ${o.gradient} flex items-center justify-center shrink-0 text-white shadow-sm`,children:e.jsx(j,{className:"h-6 w-6"})}),badges:s.payment_status==="pending"&&s.payment_method==="pix"&&e.jsx(Se,{variant:"outline",className:"text-[10px] h-5",children:"PIX pendente"}),meta:(()=>{const g=s.start_count!=null&&s.remains!=null?Math.max(0,s.quantity-Number(s.remains)):null,S=g!=null&&s.quantity>0?Math.min(100,Math.round(g/s.quantity*100)):null;return e.jsx(Ns,{delayDuration:150,children:e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs(ne,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs("span",{className:"inline-flex items-center gap-1 cursor-help",children:[e.jsx(Ce,{className:"h-3 w-3"}),s.quantity.toLocaleString("pt-BR")]})}),e.jsx(oe,{children:"Quantidade contratada"})]}),s.start_count!=null&&e.jsxs(ne,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs("span",{className:"inline-flex items-center gap-1 cursor-help",children:[e.jsx(ws,{className:"h-3 w-3"}),"InÃcio: ",Number(s.start_count).toLocaleString("pt-BR")]})}),e.jsx(oe,{children:"Contagem registrada antes do envio começar"})]}),g!=null&&e.jsxs(ne,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500 cursor-help",children:[e.jsx(_s,{className:"h-3 w-3"}),g.toLocaleString("pt-BR")," entregue",S!=null?` · ${S}%`:"",Number(s.remains)>0&&e.jsxs("span",{className:"text-muted-foreground",children:["· ",Number(s.remains).toLocaleString("pt-BR")," restante"]})]})}),e.jsx(oe,{children:Number(s.remains)>0?`Faltam ${Number(s.remains).toLocaleString("pt-BR")} para concluir a entrega`:"Entrega concluÃda"})]}),e.jsxs(ne,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs("a",{href:s.link,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1 hover:text-primary truncate max-w-[140px] sm:max-w-[200px]",children:[e.jsx(ks,{className:"h-3 w-3"}),s.link.replace(/^https?:\/\//,"")]})}),e.jsx(oe,{className:"max-w-xs break-all",children:s.link})]})]})})})(),price:{value:m,sub:s.payment_method==="balance"?"Saldo":"PIX"},footer:(()=>{if(!(!((s.status==="completed"||s.status==="partial")&&s.provider_order_id&&s.provider_service_id!=null&&cs.has(Number(s.provider_service_id)))&&!s.refill_id)){if(s.refill_id){const S=(s.refill_status||"Pending").toLowerCase(),$e=S==="completed",De=S==="error"||S==="not found",xs=$e?"text-emerald-500":De?"text-destructive":"text-blue-500";return e.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${xs}`,children:[e.jsx(ke,{className:`h-3.5 w-3.5 ${!$e&&!De?"animate-spin":""}`}),e.jsx("span",{className:"font-medium",children:"Refil:"}),e.jsx("span",{children:s.refill_status||"Pendente"})]})}return e.jsxs(H,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1.5",disabled:Ae===s.id,onClick:S=>{S.preventDefault(),S.stopPropagation(),ds(s.id)},children:[Ae===s.id?e.jsx(K,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ke,{className:"h-3.5 w-3.5"}),"Pedir refil"]})}})(),adminInfo:Q&&(s.provider_service_id!=null||s.provider_order_id)&&e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono text-muted-foreground
4/80 flex-wrap",children:[s.provider_service_id!=null&&e.jsxs("span",{title:"Controle interno (admin)",className:"px-1.5 py-0.5 rounded bg-muted/40",children:["ID serviço: ",s.provider_service_id]}),s.provider_order_id&&e.jsxs("span",{title:"Controle interno (admin)",className:"px-1.5 py-0.5 rounded bg-muted/40",children:["ID pedido: ",s.provider_order_id]})]})},s.id)})})]}):e.jsxs(e.Fragment,{children:[!Ee&&f.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Cs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Y,{placeholder:"Buscar serviço por nome, categoria ou ID (#1234)...",value:U,onChange:s=>Le(s.target.value),className:"pl-9 h-11 bg-background/60"})]}),U.trim()&&e.jsxs("div",{className:"rounded-2xl border border-border/50 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-border/30 bg-muted/30 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium",children:G.length===0?`Nenhum serviço encontrado para "${U}"`:`${G.length} resultado${G.length===1?"":"s"}`}),e.jsx("button",{type:"button",onClick:()=>Le(""),className:"text-[11px] text-muted-foreground hover:text-foreground",children:"Limpar"})]}),G.length>0&&e.jsx("div",{className:"max-h-[360px] overflow-y-auto divide-y divide-border/30",children:G.map(s=>e.jsxs("button",{type:"button",onClick:()=>{const p=k(s).key;N(p),Z(s.category),xe(String(s.service)),requestAnimationFrame(()=>{var b;(b=document.getElementById("smm-order-form"))==null||b.scrollIntoView({behavior:"smooth",block:"start"})})},className:"w-full text-left px-4 py-3 hover:bg-accent/40 transition-colors flex items-start gap-2",children:[e.jsxs(Se,{variant:"outline",className:"text-[10px] h-4 px-1 font-mono shrink-0 mt-0.5",children:["#",s.service]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-medium whitespace-normal break-words leading-snug",children:s.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground whitespace-normal break-words mt-0.5",children:s.category})]}),e.jsxs("span",{className:"text-[11px] font-semibold text-primary tabular-nums shrink-0 mt-0.5",children:[T(s.price_brl??s.price_brl_per_1000),zs(s.unit_basis??de(s.type))]})]},s.service))})]})]}),e.jsxs("div",{id:"smm-order-form",className:"rounded-2xl border border-border/50 overflow-hidden bg-card/30 backdrop-blur-2xl",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border/30 bg-gradient-to-r from-primary/5 to-transparent flex items-center gap-2",children:[e.jsx("div",{className:"size-8 rounded-lg bg-primary/15 flex items-center justify-center",children:e.jsx(Ss,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-sm",children:"Crie uma nova ordem abaixo"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Selecione a categoria e o serviço desejado."})]})]}),e.jsx("div",{className:"p-5 space-y-4",children:Ee?e.jsx("div",{className:"space-y-3",children:Array.from({length:4}).map((s,p)=>e.jsx("div",{className:"h-11 rounded-lg bg-muted/40 animate-pulse"},p))}):f.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"Não foi possÃvel carregar o catálogo no momento."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs(I,{className:"text-xs flex items-center gap-1.5 mb-1.5",children:[e.jsx("span",{className:"inline-flex size-5 items-center justify-center rounded bg-primary/15 text-primary text-[10px] font-bold",children:"1"}),"Selecione a Categoria"]}),e.jsxs(Ke,{value:A,onValueChange:Z,children:[e.jsx(Ve,{className:"min-h-11 h-auto bg-background/60",children:e.jsx(Ue,{placeholder:_e.length?"Escolha uma categoria...":"Nenhuma categoria disponÃvel"})}),e.jsx(We,{className:"max-h-[min(20rem,60vh)] w-[var(--radix-select-trigger-width)] max-w-[calc(100vw-1rem)] [&>[data-radix-select-scroll-up-button]]:hidden",position:"popper",sideOffset:4,collisionPadding:{top:72,bottom:16,left:8,right:8},children:(()=>{const s=/promo|promoç|recomend|destaque|oferta|best ?seller|featured|exclusiv/i,p={};_e.forEach(n=>{const m=O.find(j=>j.category===n),o=m?k(m):L[L.length-1];p[o.key]||(p[o.key]={meta:o,cats:[]}),p[o.key].cats.push(n)});const b=_e.filter(n=>s.test(n));
4Object.values(p).forEach(n=>{n.cats.sort((m,o)=>{const j=s.test(m)?0:1,g=s.test(o)?0:1;return j!==g?j-g:m.localeCompare(o)})});const y=n=>{const m=O.filter(g=>g.category===n).length,o=k(O.find(g=>g.category===n)??{category:n,name:n}),j=o.icon;return e.jsx(Ge,{value:n,className:"pl-3 pr-2 [&>span:first-child]:hidden",children:e.jsxs("span",{className:"flex items-start gap-2 whitespace-normal break-words text-left w-full",children:[e.jsx(j,{className:`h-4 w-4 shrink-0 mt-0.5 ${o.colorClass}`}),e.jsx("span",{className:"flex-1",children:n}),e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0 mt-0.5",children:["(",m,")"]})]})},n)};return e.jsxs(e.Fragment,{children:[b.length>0&&e.jsxs(le,{children:[e.jsxs(ce,{className:"sticky-header-elevated sticky -top-1 z-10 flex items-center gap-2 text-[11px] font-semibold text-amber-600 dark:text-amber-300 uppercase tracking-wider w-full pl-3 pr-2 py-1.5 -mt-1",children:[e.jsx("span",{className:"shrink-0",children:"Promoções & Recomendados"}),e.jsx(Xe,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 h-px bg-gradient-to-r from-transparent via-amber-500/60 to-transparent min-w-[40px]"})]}),b.map(y)]}),Object.values(p).sort((n,m)=>L.findIndex(o=>o.key===n.meta.key)-L.findIndex(o=>o.key===m.meta.key)).map(({meta:n,cats:m})=>{const o=n.icon;return e.jsxs(le,{children:[e.jsxs(ce,{className:"sticky-header-elevated sticky -top-1 z-10 flex items-center gap-2 text-[11px] font-semibold text-foreground uppercase tracking-wider w-full pl-3 pr-2 py-1.5",children:[e.jsx("span",{className:"shrink-0",children:n.label}),e.jsx(o,{className:`h-3.5 w-3.5 shrink-0 ${n.colorClass}`}),e.jsx("span",{className:"flex-1 h-px bg-gradient-to-r from-transparent via-primary to-transparent min-w-[40px]"})]}),m.filter(j=>!s.test(j)).map(y)]},n.key)})]})})()})]})]}),e.jsxs("div",{children:[e.jsxs(I,{className:"text-xs flex items-center gap-1.5 mb-1.5",children:[e.jsx("span",{className:"inline-flex size-5 items-center justify-center rounded bg-primary/15 text-primary text-[10px] font-bold",children:"2"}),"Selecione o Serviço"]}),e.jsxs(Ke,{value:pe,onValueChange:xe,disabled:!A,children:[e.jsx(Ve,{className:"min-h-11 h-auto bg-background/60 [&>span]:line-clamp-none [&>span]:whitespace-normal [&>span]:break-words",children:e.jsx(Ue,{placeholder:A?"Escolha um serviço...":"Selecione uma categoria primeiro"})}),e.jsx(We,{className:"max-h-[min(20rem,60vh)] w-[var(--radix-select-trigger-width)] max-w-[calc(100vw-1rem)] [&>[data-radix-select-scroll-up-button]]:hidden",position:"popper",sideOffset:4,collisionPadding:{top:72,bottom:16,left:8,right:8},children:(()=>{const s=/promo|promoç|recomend|destaque|oferta|best ?seller|featured|exclusiv/i,p=n=>[...n].sort((m,o)=>{const j=s.test(m.name)?0:1,g=s.test(o.name)?0:1;return j!==g?j-g:m.price_brl_per_1000-o.price_brl_per_1000}),b=n=>{const m=k(n),o=m.icon;return e.jsx(Ge,{value:String(n.service),className:"pl-3 pr-2 py-2 [&>span:first-child]:hidden",children:e.jsxs("span",{className:"flex items-start gap-2 whitespace-normal break-words text-left w-full",children:[e.jsx(o,{className:`h-4 w-4 shrink-0 mt-0.5 ${m.colorClass}`}),e.jsxs("span",{className:"flex-1 min-w-0 text-[12px] leading-snug",children:[e.jsxs("span",{className:"text-[9px] font-mono text-muted-foreground/70 mr-1 tabular-nums",children:["#",n.service]}),n.name]}),e.jsxs("span",{className:"shrink-0 flex flex-col items-end leading-tight",children:[e.jsx("span",{className:"text-[11px] text-primary font-semibold tabular-nums",children:T(n.price_brl??n.price_brl_per_1000)}),e.jsx("span",{className:"text-[9px] text-muted-foreground uppercase tracking-wider",children:Ye(n.unit_basis??de(n.type))})]})]})},n.service)},y=new Map;return X.forEach(n=>{const m=k(n),o=y.get(m.key);o?o.list.push(n):y.set(m.key,{meta:m,list:[n]})}),y.size<=1?e.jsxs(le,{children:[e.jsxs(ce,{className:"sticky-header-elevated sticky -top-1 z-10 flex items-center gap-2 text-[11px] font-semibold text-foreground uppercase tracking-wider w-full pl-3 pr-2 py-1.5 -mt-1",children:[e.jsx("span",{className:"shrink-0",children:A}),X[0]&&(()=>{const n=k(X[0]),m=n.icon;return e.jsx(m,{className:`h-3.5 w-3.5 shrink-0 ${n.colorClass}`})})(),e.jsx("span",{className:"flex-1 h-px bg-gradient-to-r from-transparent via-primary to-transparent min-w-[40px]"})]}),p(X).map(b)]}):Array.from(y.values()).sort((n,m)=>L.findIndex(o=>o.key===n.meta.key)-L.findIndex(o=>o.key===m.meta.key)).map(({meta:n,list:m})=>{const o=n.icon;return e.jsxs(le,{children:[e.jsxs(ce,{className:"sticky-header-elevated sticky -top-1 z-10 flex items-center gap-2 text-[11px] font-semibold text-foreground uppercase tracking-wider w-full pl-3 pr-2 py-1.5",children:[e.jsx("span",{className:"shrink-0",children:n.label}),e.jsx(o,{className:`h-3.5 w-3.5 shrink-0 ${n.colorClass}`}),e.jsx("span",{className:"flex-1 h-px bg-gradient-to-r from-transparent via-primary to-transparent min-w-[40px]"})]}),p(m).map(b)]},n.key)})})()})]})]}),a&&(()=>{const s=Array.from(a.name.matchAll(/\[([^\]]+)\]/g)).flatMap(y=>y[1].split("|").map(n=>
4n.trim()).filter(Boolean)),p=parseInt(a.min,10),b=parseInt(a.max,10);return e.jsxs("details",{className:"group rounded-xl border border-border/60 bg-background/40 overflow-hidden",children:[e.jsxs("summary",{className:"flex items-center gap-2 px-3 py-2.5 cursor-pointer select-none hover:bg-background/70 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx(Is,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-xs font-medium flex-1",children:"Detalhes do serviço"}),e.jsx(Ms,{className:"h-4 w-4 text-muted-foreground transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"px-3 pb-3 pt-2 border-t border-border/40 space-y-2.5",children:[s.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((y,n)=>e.jsx("span",{className:"text-[10.5px] px-2 py-0.5 rounded-full bg-primary/10 text-primary border border-primary/20",children:y},n))}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 text-[11.5px]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"MÃnimo"}),e.jsx("span",{className:"tabular-nums font-medium",children:p.toLocaleString("pt-BR")})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Máximo"}),e.jsx("span",{className:"tabular-nums font-medium",children:b.toLocaleString("pt-BR")})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Recarga"}),e.jsx("span",{className:a.refill?"text-emerald-500 font-medium":"text-muted-foreground",children:a.refill?"DisponÃvel":"Não"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cancelar"}),e.jsx("span",{className:a.cancel?"text-emerald-500 font-medium":"text-muted-foreground",children:a.cancel?"Permitido":"Não"})]}),e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Categoria"}),e.jsx("span",{className:"font-medium text-right truncate ml-2",children:a.category})]})]}),a.description&&e.jsx("div",{className:"whitespace-pre-wrap border-t border-border/30 pt-2 text-[11.5px] leading-relaxed text-foreground",children:a.description}),e.jsxs("p",{className:"text-[10.5px] text-muted-foreground/80 leading-relaxed pt-1 border-t border-border/30",children:["â ï¸ O perfil/post deve estar ",e.jsx("strong",{children:"público"})," durante a entrega. Velocidade e disponibilidade podem variar conforme o provedor."]})]})]})})(),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"link",className:"text-xs",children:"Link"}),e.jsx(Y,{id:"link",placeholder:"https://instagram.com/seuusuario",value:ue,onChange:s=>he(s.target.value),className:"mt-1.5 h-11 bg-background/60",disabled:!a})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"qty",className:"text-xs",children:"Quantidade"}),e.jsx(Y,{id:"qty",type:"number",min:a?parseInt(a.min,10):void 0,max:a?parseInt(a.max,10):void 0,value:B||"",onChange:s=>ee(parseInt(s.target.value||"0",10)),className:"mt-1.5 h-11 bg-background/60 tabular-nums",disabled:!a||C,readOnly:C}),a&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:["MÃn.: ",parseInt(a.min,10).toLocaleString("pt-BR")," â Máx.: ",parseInt(a.max,10).toLocaleString("pt-BR"),C&&a.type==="Custom Comments"&&" ⢠Definido pelo nº de linhas abaixo",C&&a.type==="Custom Comments Package"&&" ⢠Pacote com quantidade fixa"]})]}),C&&e.jsxs("div",{children:[e.jsxs(I,{htmlFor:"comments",className:"text-xs flex items-center gap-2",children:["Comentários",e.jsx("span",{className:"text-[10px] text-muted-foreground font-normal",children:"(1 por linha)"})]}),e.jsx(Os,{id:"comments",placeholder:`Muito bom! 5Amei o conteúdo ð¥ 6Parabéns pelo trabalho`,value:fe,onChange:s=>ge(s.target.value),className:"mt-1.5 min-h-[120px] bg-background/60 font-mono text-xs",disabled:!a}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:[w," comentário",
6w===1?"":"s"," detectado",w===1?"":"s"]}),(a==null?void 0:a.type)==="Custom Comments Package"&&(()=>{const s=a.name.match(/\[\s*(\d+)\s*Coment/i);return s?e.jsxs("span",{className:"text-primary",children:["Esperado: ",s[1]]}):null})()]})]}),e.jsxs("div",{children:[e.jsx(I,{className:"text-xs mb-1.5 block",children:"Forma de pagamento"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>be("balance"),className:`relative rounded-xl border p-3 flex items-center gap-2 text-left transition-all overflow-hidden ${M==="balance"?"border-primary bg-primary/10 ring-1 ring-primary/40 shadow-[0_0_12px_-4px_hsl(var(--primary)/0.35)]":"border-primary/40 bg-primary/[0.03] hover:border-primary/60 hover:bg-primary/[0.06]"}`,children:[e.jsx("span",{className:"absolute top-1.5 right-1.5 text-[9px] font-semibold uppercase tracking-wider text-primary bg-primary/10 rounded-full px-1.5 py-0.5",children:"Recomendado"}),e.jsx(Qe,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Saldo"}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:V})]})]}),e.jsxs("button",{type:"button",onClick:()=>!$&&be("pix"),disabled:$,title:$?"PIX disponÃvel somente para pedidos a partir de R$ 10,00":void 0,className:`rounded-xl border p-3 flex items-center gap-2 text-left transition-all ${$?"border-border/30 bg-muted/30 opacity-50 cursor-not-allowed":M==="pix"?"border-primary bg-primary/5 ring-1 ring-primary/30":"border-border/50 hover:border-border"}`,children:[e.jsx(Ks,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"PIX"}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:$?"MÃn. R$ 10,00":"Aprovação na hora"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(I,{className:"text-xs",children:"Valor"}),e.jsxs("div",{className:"mt-1.5 rounded-xl bg-gradient-to-br from-primary/10 to-accent/10 border border-primary/20 px-4 py-3 flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:a?`${T(a.price_brl??a.price_brl_per_1000)} ${Ye(a.unit_basis??de(a.type))}`:"â"}),e.jsx("span",{className:"text-2xl font-bold text-primary tabular-nums",children:T(ae)})]})]}),Oe&&e.jsxs("div",{className:"rounded-lg bg-destructive/10 border border-destructive/20 p-3 text-xs text-destructive",children:["Saldo insuficiente."," ",e.jsx("button",{type:"button",onClick:()=>ve(!0),className:"underline font-medium",children:"Recarregar"})," ","ou escolha PIX."]}),e.jsx(H,{onClick:ps,disabled:Me||!a||!ue.trim()||!B||Oe,className:"w-full h-12 text-base font-semibold",size:"lg",children:Me?e.jsx(K,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[M==="pix"?"Gerar PIX":"Enviar",e.jsx(Ps,{className:"h-4 w-4"})]})})]})})]})]})]})]})})()})})]}),F&&e.jsx(es,{open:!0,onOpenChange:()=>ye(null),children:e.jsxs(ss,{className:"max-w-md",children:[e.jsxs(rs,{children:[e.jsxs(ts,{className:"flex items-center gap-2",children:[e.jsx(Ls,{className:"h-5 w-5"})," Pague o PIX"]}),e.jsxs(as,{children:["Total ",e.jsx("span",{className:"font-bold text-foreground",children:Hs(F.total/100)})," â assim que o pagamento for confirmado o pedido é enviado automaticamente."]})]}),F.qr&&e.jsx("div",{className:"flex justify-center bg-white p-4 rounded-xl",children:e.jsx("img",{src:`data:image/png;base64,${F.qr}`,alt:"QR Code PIX",className:"w-56 h-56"})}),F.copy&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"text-xs",children:"PIX Copia e Cola"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{readOnly:!0,value:F.copy,className:"font-mono text-xs"}),e.jsx(H,{variant:"outline",size:"icon",onClick:()=>{navigator.clipboard.writeText(F.copy),h.success("Copiado!")},children:e.jsx(Es,{className:"h-4 w-4"})})]})]}),e.jsx(H,{onClick:()=>{ye(null),he(""),v.invalidateQueries({queryKey:["smm-orders"]}),v.invalidateQueries({queryKey:["user-balance"]})},className:"w-full",children:"Acompanhar pedido"})]})}),ns&&Q&&e.jsx(Zs,{onClose:()=>je(!1),onSaved:()=>{je(!1),Re()}}),e.jsx(Rs,{open:is,onOpenChange:ve})]})}function Zs({onClose:x,onSaved:D}){const _=Je(),{data:v,isLoading:R}=me({queryKey:["smm-settings"],queryFn:async()=>{const{data:u,error:N}=await E.from("smm_settings").select("markup_pct").eq("id",!0).single();if(N)throw N;return u},staleTime:0,refetchOnMount:"always"}),[q,J]=l.useState(""),[V,Q]=l.useState(!1);l.useEffect(()=>{v&&J(String(Number(v.markup_pct)))},[v]);const T=async()=>{const u=parseFloat(q);if(isNaN(u)||u<0){h.error("Informe um markup válido.");return}Q(!0);const{error:N}=await E.from("smm_settings").update({markup_pct:u,updated_at:new Date().toISOString()}).eq("id",!0);if(Q(!1),N){h.error(N.message);return}
6await _.invalidateQueries({queryKey:["smm-settings"]}),await _.invalidateQueries({queryKey:["smm-services-public"]}),h.success("Configurações salvas."),D()};return e.jsx(es,{open:!0,onOpenChange:x,children:e.jsxs(ss,{className:"max-w-md",children:[e.jsxs(rs,{children:[e.jsxs(ts,{className:"flex items-center gap-2",children:[e.jsx(Ze,{className:"h-4 w-4"})," Configurações (Admin)"]}),e.jsx(as,{children:"VisÃveis somente para administradores. Aplicam-se ao catálogo de todos os usuários."})]}),R?e.jsx(K,{className:"h-5 w-5 animate-spin mx-auto"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{className:"text-xs",children:"Markup (%)"}),e.jsx(Y,{type:"number",step:1,min:0,value:q,onChange:u=>J(u.target.value),className:"mt-1.5"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Os preços do provedor já vêm em R$ â apenas o markup é aplicado."})]}),e.jsx(H,{onClick:T,disabled:V,className:"w-full",children:V?e.jsx(K,{className:"h-4 w-4 animate-spin"}):"Salvar"})]})]})})}function Sr(){return e.jsxs(e.Fragment,{children:[e.jsx(As,{title:"Painel SMM â axye",description:"Impulsione Instagram, TikTok, YouTube e mais. Entregas automáticas, rastreamento em tempo real e pagamento pela sua carteira."}),e.jsx(Bs,{}),e.jsx(Fs,{children:e.jsx(Js,{})})]})}export{Sr 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.