1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="13c30caf-b6a1-5f5c-9021-b5a593d6be9d")}catch(e){}}(); 3import{e as I,f as w,g as T,h as C,i as A,n as he,R as e,Y as E,s as ye,bi as Z,bm as Ne,I as de,d2 as Se,C as U,a6 as Ie,aN as J,aS as we,bw as Te,k as ee,X as Ce,aE as Ae,aU as Pe,ai as ze,gb as Re,W as Me,aj as _e,aY as te,aG as ke}from"./index-Cs-In7Vx.js";import{u as qe}from"./useWhatsAppIntegrationPageState-B17qVVk9.js";import{H as Le}from"./HelpOutlineRounded-BdKAN6Cs.js";import"./cacheKeys-Px_UUtmK.js";import{g as Oe}from"./errors-BL8YlbI8.js";import{T as je,a as De,b as Q,u as Ve,c as We}from"./useTemplateMutations-Bd5usizi.js";import{C as K}from"./Check-D80HhUso.js";import{L as Fe}from"./Lock-C5j5Mq5n.js";import{A as Ue}from"./AutorenewRounded-BzryKyaY.js";import{C as He}from"./ContactPhoneRounded-B3ob7BpZ.js";import{f as $e}from"./formatWhatsAppPhone-DJG7KN8s.js";import{T as X,p as Ge,q as D,r as Be,u as Ye,i as Je}from"./useIntegrationTemplates-C7sVRBPz.js";import"./useIntegrationOverview-Dol5EBAf.js";import"./ArrowBackRounded-d_5Kt6BO.js";import"./ViewHeadlineRounded-CNvGi08T.js";import"./useGetCoupons-D015gTvi.js";import"./FiberManualRecord-B1d1Mzjb.js";var M={},ae;function Qe(){if(ae)return M;ae=1;var t=I(),a=w();Object.defineProperty(M,"__esModule",{value:!0}),M.default=void 0;var r=a(T()),l=t(C()),o=(0,l.default)(r.createElement("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 6h-4c0 1.62-1.38 3-3 3s-3-1.38-3-3H5V5h14v4zm-4 7h6v3c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-3h6c0 1.66 1.34 3 3 3s3-1.34 3-3z"}),"AllInbox");return M.default=o,M}var Xe=Qe();const ue=A(Xe);function Ke(){const t=he();return e.createElement("div",{className:"flex flex-1 flex-col items-center justify-center px-24 py-24 text-center"},e.createElement("div",{className:"flex h-64 w-64 items-center justify-center rounded-full bg-purple-lightest"},e.createElement(ue,{style:{fontSize:32},className:"text-purple"})),e.createElement("div",{className:"mt-20 max-w-sm text-20 font-semibold text-gray-800"},"Configure pelo menos um número na Gestão de números na API oficial da Meta"),e.createElement("div",{className:"mt-8 max-w-sm text-16 text-gray-500"},"Acesse o menu de navegação e clique em Gestão de número ou use o atalho a seguir:"),e.createElement(E,{variant:"outlined",color:"primary",className:"mt-24 w-full max-w-xs",onClick:()=>t.push("/whatsapp/conexao")},"Atalho para Gestão de números"))}var _={},re;function Ze(){if(re)return _;re=1;var t=I(),a=w();Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var r=a(T()),l=t(C()),o=(0,l.default)(r.createElement("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"}),"Create");return _.default=o,_}var et=Ze();const tt=A(et);var k={},le;function at(){if(le)return k;le=1;var t=I(),a=w();Object.defineProperty(k,"__esModule",{value:!0}),k.default=void 0;var r=a(T()),l=t(C()),o=(0,l.default)(r.createElement("path",{d:"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"}),"Send");return k.default=o,k}var rt=at();const lt=A(rt);var q={},ne;function nt(){if(ne)return q;ne=1;var t=I(),a=w();Object.defineProperty(q,"__esModule",{value:!0}),q.default=void 0;var r=a(T()),l=t(C()),o=(0,l.default)(r.createElement("path",{d:"M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2z"}),"ThumbUp");return q.default=o,q}var st=nt();const ot=A(st);function H({children:t}){return e.createElement("div",{className:"mb-16 text-16 font-semibold text-gray-800"},t)}const se=[{icon:tt,label:"Você cria modelo"},{icon:ot,label:"Meta revisa"},{icon:K,label:"Pós aprovação"},{icon:lt,label:"Você envia"}];function ct(){return e.createElement("div",null,e.createElement(H,null,"Como funciona a aprovação: apenas para modelos Meta"),e.createElement("div",{className:"flex items-center gap-8"},se.map((t,a)=>{const r=t.icon;return e.createElement(e.Fragment,{key:t.label},e.createElement("div",{className:"flex flex-col items-center gap-8 text-center"},e.createElement("div",{className:"flex h-36 w-36 items-center justify-center rounded-full bg-purple-lightest"},e.createElement(r,{style:{fontSize:16},className:"text-purple"})),e.createElement("span",{className:"text-16 text-gray-600"},a+1,". ",t.label)),a<se.length-1&&e.createElement("div",{className:"mb-16 h-
3px flex-1 bg-gray-200"}))})),e.createElement("p",{className:"mt-16 text-16 text-gray-500"},"A revisão da Meta pode levar de alguns minutos a 24 horas. Se reprovado, você vê o motivo e pode editar e reenviar."))}const it=["Linguagem natural, como você falaria","Categoria correta (marketing vs utilidade)","Use variáveis para personalizar"],mt=["Caixa alta e excesso de pontuação",'"URGENTE", "TEMPO LIMITADO"',"Promessas vagas ou irrealistas"];function dt(){return e.createElement("div",null,e.createElement(H,null,"Dicas para aprovar de primeira"),e.createElement("div",{className:"grid grid-cols-2 gap-16"},e.createElement("div",null,e.createElement("div",{className:"mb-8 text-16 font-semibold text-gray-700"},"Faça"),e.createElement("div",{className:"space-y-8"},it.map(t=>e.createElement("div",{key:t,className:"flex items-start gap-8 text-16 text-gray-600"},e.createElement(K,{style:{fontSize:14},className:"text-green-600 mt-8 shrink-0"}),e.createElement("span",null,t))))),e.createElement("div",null,e.createElement("div",{className:"mb-8 text-16 font-semibold text-gray-700"},"Evite"),e.createElement("div",{className:"space-y-8"},mt.map(t=>e.createElement("div",{key:t,className:"flex items-start gap-8 text-16 text-gray-600"},e.createElement(ye,{style:{fontSize:14},className:"text-red-500 mt-8 shrink-0"}),e.createElement("span",null,t)))))))}var L={},oe;function ut(){if(oe)return L;oe=1;var t=I(),a=w();Object.defineProperty(L,"__esModule",{value:!0}),L.default=void 0;var r=a(T()),l=t(C()),o=(0,l.default)(r.createElement("path",{d:"M18.6 6.62c-1.44 0-2.8.56-3.77 1.53L12 10.66 10.48 12h.01L7.8 14.39c-.64.64-1.49.99-2.4.99-1.87 0-3.39-1.51-3.39-3.38S3.53 8.62 5.4 8.62c.91 0 1.76.35 2.44 1.03l1.13 1 1.51-1.34L9.22 8.2C8.2 7.18 6.84 6.62 5.4 6.62 2.42 6.62 0 9.04 0 12s2.42 5.38 5.4 5.38c1.44 0 2.8-.56 3.77-1.53l2.83-2.5.01.01L13.52 12h-.01l2.69-2.39c.64-.64 1.49-.99 2.4-.99 1.87 0 3.39 1.51 3.39 3.38s-1.52 3.38-3.39 3.38c-.9 0-1.76-.35-2.44-1.03l-1.14-1.01-1.51 1.34 1.27 1.12c1.02 1.01 2.37 1.57 3.82 1.57 2.98 0 5.4-2.41 5.4-5.38s-2.42-5.37-5.4-5.37z"}),"AllInclusive");return L.default=o,L}var pt=ut();const ft=A(pt);var O={},ce;function vt(){if(ce)return O;ce=1;var t=I(),a=w();
3Object.defineProperty(O,"__esModule",{value:!0}),O.default=void 0;var r=a(T()),l=t(C()),o=(0,l.default)(r.createElement("path",{d:"M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"}),"Apps");return O.default=o,O}var gt=vt();const Et=A(gt),xt=["Notificações dentro da janela aberta â ex: 'pedido em preparo' logo após a confirmação, quando o cliente acabou de pedir.","Respostas rápidas em atendimento humano ativo.","Qualquer envio via número conectado pela API alternativa (QR code): ali tudo é livre."];function bt(){return e.createElement("div",null,e.createElement(H,null,"Os tipos de modelo:"),e.createElement("div",{className:"mb-16 rounded-12 border border-solid border-gray-200 bg-white p-16"},e.createElement("div",{className:"mb-8 flex items-center justify-between"},e.createElement("div",{className:"flex items-center gap-8"},e.createElement(ft,{style:{fontSize:16},className:"text-purple"}),e.createElement("span",{className:"text-16 font-semibold text-gray-800"},"Modelo Meta (oficial)")),e.createElement(Z,{color:"orange"},"Exige aprovação")),e.createElement("p",{className:"mb-16 text-16 text-gray-600"},"Ãnico formato capaz de iniciar conversa com cliente fora da janela 24h. Passa pela revisão da Meta antes de poder ser usado."),e.createElement("div",{className:"grid grid-cols-2 gap-8"},e.createElement("div",{className:"rounded-8 border border-solid border-gray-100 p-16"},e.createElement("div",{className:"text-16 font-semibold text-gray-700"},"Marketing"),e.createElement("div",{className:"mt-8 text-16 text-gray-500"},"Promoções, ofertas, lançamentos")),e.createElement("div",{className:"rounded-8 border border-solid border-gray-100 p-16"},e.createElement("div",{className:"text-16 font-semibold text-gray-700"},"Utilidade"),e.createElement("div",{className:"mt-8 text-16 text-gray-500"},"Confirmações, status, lembretes")))),e.createElement("div",{className:"rounded-12 border border-solid border-gray-200 bg-white p-16"},e.createElement("div",{className:"mb-8 flex items-center justify-between"},e.createElement("div",{className:"flex items-center gap-8"},e.createElement(Et,{style:{fontSize:16},className:"text-purple"}),e.createElement("span",{className:"text-16 font-semibold text-gray-800"},"Modelo livre")),e.createElement(Z,{color:"green"},"Sem aprovação")),e.createElement("p",{className:"mb-16 text-16 text-gray-600"},"Mensagem reutilizável que não passa pela Meta. DisponÃvel apenas em contextos onde a janela já está aberta ou onde não há restrição da Meta."),e.createElement("div",{className:"space-y-8"},xt.map(t=>e.createElement("div",{key:t,className:"flex items-start gap-8 text-16 text-gray-600"},e.createElement(K,{style:{fontSize:14},className:"text-green-600 mt-8 shrink-0"}),e.createElement("span",null,t)))),e.createElement("div",{className:"mt-16 rounded-8 border border-solid border-gray-100 p-16"},e.createElement("div",{className:"text-16 text-gray-500"},"Sem custo Meta"),e.createElement("div",{className:"mt-8 text-16 text-gray-600"},"Cobrança só pelo plano Cardápio Web. Para alto volume, sai mais barato."),e.createElement("div",{className:"mt-8 text-20 font-bold text-gray-800"},"R$ 0,00"),e.createElement("div",{className:"text-16 text-gray-400"},"por mensagem"))))}var j={},ie;function ht(){if(ie)return j;ie=1;var t=I(),a=w();Object.defineProperty(j,"__esModule",{value:!0}),j.default=void 0;var r=a(T()),l=t(C()),o=(0,l.default)(r.createElement("path",{d:"M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10z"}),"LockOpen");return j.default=o,j}var yt=ht();const Nt=A(yt);function me({icon:t,title:a,description:r,locked:l}){return e.createElement("div",{className:"flex flex-1 flex-col gap-8 rounded-12 border border-solid border-gray-200 bg-white p-16"},e.createElement("div",{className:"flex items-center gap-8"},e.createElement(t,{style:{fontSize:16},className:l?"text-gray-500":"text-green-600"}),e.createElement("span",{className:"text-16 font-semibold text-gray-700"},a)),e.createElement("p",{className:"text-16 text-gray-500"},r))}function St(){return e.createElement("div",null,e.createElement(H,null,"A janela de 24 horas"),e.createElement("p",{className:"mb-16 text-16 text-gray-600"},"Você só pode mandar mensagem livre quando o cliente falou com você nas últimas 24 horas. Fora disso, só um modelo aprovado pode iniciar conversa."),e.createElement("div",{className:"flex gap-16"},e.createElement(me,{icon:Fe,title:"Janela fechada",description:"Sem mensagem do cliente nas últimas 24h. Só modelo aprovado pode iniciar.",locked:!0}),e.createElement(me,{icon:Nt,title:"Janela aberta",description:"Cliente respondeu. Você pode mandar texto,
3áudio e mÃdia livremente.",locked:!1})))}function It({open:t,onClose:a,onCreateTemplate:r}){return e.createElement(Ne,{anchor:"right",open:t,onClose:a},e.createElement("div",{className:"flex h-full max-w-full flex-col bg-gray-50",style:{width:560}},e.createElement("div",{className:"flex items-center justify-between border-0 border-b border-solid border-gray-200 bg-white px-20 py-16"},e.createElement("div",{className:"text-20 font-semibold text-gray-800"},"Como funcionam os modelos"),e.createElement(de,{onClick:a},e.createElement(Se,null))),e.createElement("div",{className:"flex-1 space-y-20 overflow-auto p-20"},e.createElement(St,null),e.createElement(bt,null),e.createElement(ct,null),e.createElement(dt,null)),e.createElement("div",{className:"flex items-center justify-end gap-16 border-0 border-t border-solid border-gray-200 bg-white px-20 py-16"},e.createElement(E,{variant:"outlined",color:"primary",onClick:a},"Entendi"),e.createElement(E,{variant:"contained",color:"primary",disableElevation:!0,onClick:()=>{a(),r?.()}},"Criar meu primeiro modelo"))))}function wt({template:t,isDeleting:a,onDelete:r}){const[l,o]=e.useState(!1);return e.createElement(e.Fragment,null,e.createElement(je,{template:t,headerActions:e.createElement(e.Fragment,null,e.createElement(E,{variant:"outlined",size:"small",className:"whitespace-nowrap",onClick:()=>r(t),disabled:a,startIcon:a?e.createElement(U,{size:14,color:"inherit"}):null},"Excluir"),e.createElement(E,{variant:"outlined",color:"primary",size:"small",className:"whitespace-nowrap",onClick:()=>o(!0)},"Ver mensagem"))}),e.createElement(De,{open:l,template:t,onClose:()=>o(!1)}))}function Tt(t){return $e(t?.phoneNumberIdentification)||t?.phoneNumberIdentification||t?.integrationId||"Número não identificado"}function Ct({integrations:t,selectedIntegrationId:a,onSelectIntegration:r,onSync:l,isSyncing:o}){return!Array.isArray(t)||t.length===0?null:e.createElement("div",{className:"flex flex-wrap items-center gap-8"},t.map(c=>{const u=String(c.integrationId)===String(a),f=c?.displayVerifiedName;return e.createElement("div",{key:c.integrationId,className:Ie("flex items-center overflow-hidden rounded-8 border border-solid bg-gray-50 px-8 py-4 transition-colors",u?"border-gray-300":"border-gray-200 hover:border-gray-300")},e.createElement("button",{type:"button","aria-pressed":u,onClick:()=>r?.(c.integrationId),className:"flex cursor-pointer items-center gap-12 border-0 bg-transparent px-12 py-8 text-left"},e.createElement(He,{style:{fontSize:18},className:"shrink-0 text-gray-400"}),e.createElement("span",{className:"flex min-w-0 flex-wrap items-baseline gap-x-8"},f&&e.createElement("span",{className:"truncate text-16 font-semibold text-gray-800"},f),e.createElement("span",{className:"whitespace-nowrap text-16 text-gray-500"},Tt(c)))),u&&e.createElement(E,{type:"button",size:"small",color:"primary",disabled:o,onClick:l,className:"mr-8 min-w-0 rounded-full bg-purple-lightest px-12 text-12 font-semibold",startIcon:o?e.createElement(U,{size:12,color:"inherit"}):e.createElement(Ue,{style:{fontSize:14}})},o?"Sincronizando...":"Sincronizar"))}))}function At({onCreateTemplate:t}){return e.createElement("div",{className:"flex flex-col items-center justify-center px-24 py-24 text-center"},e.createElement("div",{className:"flex h-64 w-64 items-center justify-center rounded-full bg-purple-lightest"},e.createElement(ue,{style:{fontSize:32},className:"text-purple"})),e.createElement("div",{className:"mt-20 max-w-sm text-20 font-semibold text-gray-800"},"Crie seu primeiro modelo de mensagem e envie para aprovação da Meta"),e.createElement("div",{className:"mt-8 max-w-sm text-16 text-gray-500"},"Acesse clicando no botão principal na barra superior ou use o atalho a seguir:"),e.createElement(E,{variant:"outlined",color:"primary",className:"mt-24 w-full max-w-xs",onClick:t},"Atalho para criar modelo"))}function Pt({search:t,onSearchChange:a,statusFilter:r,onStatusFilterChange:l,sort:o,onSortChange:c,onCreateTemplate:u}){const f=e.useMemo(()=>X.reduce((n,i)=>(n[i.value]=i.label,n),{}),[]);return e.createElement("div",{className:"flex flex-col gap-16 lg:flex-row lg:flex-wrap lg:items-center"},e.createElement(J,{variant:"outlined",placeholder:"Pesquisar pelo nome",value:t,size:"small",onChange:n=>a(n.target.value),className:"w-full min-w-0 lg:flex-1",InputProps:{startAdornment:e.createElement(we,{position:"start"},e.createElement(Te,{fontSize:"small",className:"text-gray-400"}))}}),e.createElement("div",{className:"flex flex-wrap items-center gap-16"},e.createElement(J,{select:!0,variant:"outlined",size:"small",value:r,onChange:n=>l(n.target.value),className:"min-w-0 flex-1 sm:flex-none",style:{minWidth:160},SelectProps:{multiple:!0,renderValue:n=>{const i=Array.isArray(n)?n:[];return i.length===X.length?"Todos":i.map(m=>f[m]||m).join(", ")}}},X.map(n=>e.createElement(ee,{key:n.value,value:n.value}
3,e.createElement(Ce,{checked:r.includes(n.value),color:"primary",size:"small"}),e.createElement(Ae,{primary:n.label})))),e.createElement(J,{select:!0,variant:"outlined",value:o,size:"small",onChange:n=>c(n.target.value),className:"min-w-0 flex-1 sm:flex-none",style:{minWidth:200}},Ge.map(n=>e.createElement(ee,{key:n.value,value:n.value},n.label))),e.createElement(E,{variant:"contained",color:"primary",disableElevation:!0,className:"w-full whitespace-nowrap sm:w-auto",onClick:u,startIcon:e.createElement(Pe,null)},"Criar modelo")))}function zt(t){const[a,r]=e.useState(""),[l,o]=e.useState(""),[c,u]=e.useState(D),[f,n]=e.useState("newest"),i=e.useMemo(()=>ze(x=>o(x),500),[]);e.useEffect(()=>(a?i(a):(i(""),i.flush()),()=>i.cancel()),[a,i]);const m=e.useMemo(()=>Be(t,{search:l,statusFilter:c}),[t,l,c]);return{search:a,setSearch:r,debouncedSearch:l,statusFilter:c,setStatusFilter:u,sort:f,setSort:n,filteredTemplates:m}}function Rt({search:t,statusFilter:a,sort:r}){return String(t||"").trim()||r!=="newest"||a.length!==D.length?!0:!D.every(l=>a.includes(l))}function Mt({templates:t,totalRows:a,page:r,rowsPerPage:l,isLoadingInitialData:o,isDeleting:c,onDelete:u,onCreateTemplate:f,onSync:n,isSyncing:i,integrations:m,selectedIntegrationId:x,onSelectIntegration:h,onFiltersChange:d}){const{search:P,setSearch:z,debouncedSearch:V,statusFilter:v,setStatusFilter:W,sort:y,setSort:F,filteredTemplates:R}=zt(t),$=Rt({search:P,statusFilter:v,sort:y});e.useEffect(()=>{d?.({name:V,sort:y,status:v,page:1})},[d,V,y,v]);const G=e.useCallback(p=>{const S=(Array.isArray(p)?p:String(p||"").split(",")).filter(Boolean);W(S.length>0?S:D)},[W]),B=e.useCallback((p,N)=>{d?.({page:N+1})},[d]),b=e.useCallback(p=>{d?.({limit:parseInt(p.target.value,10),page:1})},[d]);return e.createElement("div",{className:"flex min-h-0 flex-1 flex-col gap-16"},e.createElement("div",{className:"shrink-0 space-y-16 rounded-12 border border-solid border-gray-200 bg-white p-20"},m?.length>0&&e.createElement(Ct,{integrations:m,selectedIntegrationId:x,onSelectIntegration:h,onSync:n,isSyncing:i}),e.createElement("div",{className:m?.length>0?"border-0 border-t border-solid border-gray-100 pt-16":""},e.createElement(Pt,{search:P,onSearchChange:z,statusFilter:v,onStatusFilterChange:G,sort:y,onSortChange:F,onCreateTemplate:f}))),e.createElement("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-12 border border-solid border-gray-200 bg-white"},e.createElement("div",{className:"min-h-0 flex-1 space-y-16 overflow-y-auto p-20"},o&&t.length===0?e.createElement("div",{className:"flex items-center justify-center py-20"},e.createElement(U,{size:26})):R.length===0?$?e.createElement("div",{className:"py-20 text-center text-16 text-gray-400"},"Nenhum modelo encontrado para os filtros aplicados."):e.createElement(At,{onCreateTemplate:f}):R.map(p=>e.createElement(wt,{key:p.id,template:p,isDeleting:c,onDelete:u}))),e.createElement("div",{className:"shrink-0 border-0 border-t border-solid border-gray-100"},e.createElement(Re,{className:"w-full",labelRowsPerPage:"Registros por página",labelDisplayedRows:({from:p,to:N,count:S})=>S!==-1?`${p}-${N} de ${S}`:`${p}-${N}`,rowsPerPageOptions:[10,25,50],component:"div",count:a||0,rowsPerPage:l||10,page:(r||1)-1,onChangePage:B,onChangeRowsPerPage:b}))))}function _t({companyId:t,integrationId:a,integrations:r,selectedIntegrationId:l,onSelectIntegration:o}){const c=Me(),u=_e(),[f,n]=e.useState("list"),[i,m]=e.useState(!1),[x,h]=e.useState(()=>({name:"",sort:"newest",status:D,page:1,limit:10,type:Q.CAMPAIGN}));e.useEffect(()=>{h(s=>s.page===1?s:{...s,page:1})},[a]);const{templates:d,totalRows:P,error:z,isLoadingInitialData:V,refresh:v}=Ye(t,a,x),W=e.useMemo(()=>d.filter(s=>Je(s?.category)),[d]),{createTemplate:y,deleteTemplate:F,syncTemplates:R,isCreating:$,isDeleting:G,isSyncing:B}=Ve(t,a),b=e.useCallback((s,g)=>{c.error(s?.response?.data?.message||Oe(s?.response?.data?.errorCode))},[c]),p=e.useCallback(async()=>{if(a)try{const s=await R();await v(),c.success(`Sincronização concluÃda${s?.synced?` (${s.synced} modelo(s))`:""}.`)}catch(s){b(s,"Falha ao sincronizar modelos.")}},[c,b,a,v,R]),N=e.useCallback(async s=>{try{await y({...s,type:Q.CAMPAIGN}),n("list"),await v(),c.success("Modelo criado com sucesso.")}catch(g){b(g,"Falha ao criar modelo.")}},[c,y,b,v]),S=e.useCallback(s=>{c.error(s||"Falha ao processar a imagem.")},[c]),pe=e.useCallback(async s=>{if(s?.id){try{await u({title:"Remover modelo",description:`Deseja realmente remover o modelo "${s.name}"? Essa ação remove também na Meta.`,cancellationText:"Cancelar",confirmationText:"Remover"})}catch{return}try{await F(s.id),await v(),c.success("Modelo removido com sucesso.")}catch(g){b(g,"Falha ao remover modelo.")}}},[c,u,F,b,v]),fe=e.useCallback(s=>{h(g=>{const ve=Array.isArray(s?.status)?s.status:g.status,ge=typeof s?.name=="string"?s.name:g.name,Ee=s?.sort||g.sort,xe=typeof s?.page=="number"?s.page:1,be=typeof s?.limit=="number"?s.limit:g.limit;return{name:ge,sort:Ee,status:ve,page:xe,limit:be,type:g.type}})},[]),Y=e.createElement(It,{open:i,onClose:()=>m(!1),onCreateTemplate:()=>{m(!1),n("create")}});return a?z?e.createElement("div",{className:"flex flex-1 flex-col items-center justify-center space-y-16 rounded-12 border border-solid border-gray-200 bg-white p-20"},e.createElement("div",{className:"text-16 text-gray-600"},"Problema ao carregar modelos da integração."),e.createElement(E,{variant:"outlined",onClick:()=>v()},"Tentar novamente")):f==="create"?e.createElement(e.Fragment,null,Y,e.createElement("div",{className:"min-h-0 flex-1 overflow-auto"},e.createElement(We,{templateType:Q.CAMPAIGN,onClose:()=>n("list"),onSubmit:N,loading:$,onUploadError:S}))):e.createElement(e.Fragment,null,Y,e.createElement("div",{className:"flex min-h-0 flex-1 flex-col space-y-24"},e.createElement("div",{className:"shrink-0"},e.createElement("div",{className:"flex items-center gap-8"},e.createElement("div",{className:"text-20 font-semibold text-gray-800"},"Modelos para campanhas"),e.createElement(de,{size:"small",className:"text-purple","aria-label":"Saiba mais sobre modelos de campanha",onClick:()=>m(!0)},e.createElement(Le,{fontSize:"small"}))),e.createElement("div",{className:"mt-4 text-16 text-gray-500"},"Crie modelos aprovados pela Meta para disparos em massa.")),e.createElement("div",{className:"flex min-h-0 flex-1 flex-col"},e.createElement(Mt,{templates:W,totalRows:P,page:x.page,rowsPerPage:x.limit,isLoadingInitialData:V,onDelete:pe,isDeleting:G,onCreateTemplate:()=>n("create"),onSync:p,isSyncing:B,integrations:r,selectedIntegrationId:l,onSelectIntegration:o,onFiltersChange:fe})))):e.createElement(e.Fragment,null,Y,e.createElement(Ke,null))}function Xt(){const{companyId:t,integrations:a,primaryIntegration:r,integrationId:l,integrationError:o,isLoadingIntegration:c,isRecoverableError:u,refreshIntegration:f}=qe(),[n,i]=e.useState(null),m=e.useMemo(()=>a.filter(d=>!!d?.wabaId),[a]);e.useEffect(()=>{i(d=>m.some(z=>String(z.integrationId)===String(d))?d:r?.integrationId||l||null)},[l,r,m]);const h=e.useMemo(()=>m.find(d=>String(d.integrationId)===String(n))||(r?.wabaId?r:null),[r,n,m])?.integrationId||null;return t?o&&!u?e.createElement("div",{className:"flex h-full flex-col items-center justify-center space-y-20 p-20"},e.createElement(te,{title:"Problema ao carregar os dados dos modelos WhatsApp"}),e.createElement(E,{onClick:()=>f(),variant:"outlined"},"Tentar novamente")):c?e.createElement("div",{className:"flex h-full items-center justify-center"},e.createElement(U,{size:32})):e.createElement("div",{className:"flex h-full min-h-0 flex-col px-16 py-16 sm:px-24"},e.createElement(ke,null,e.createElement(_t,{companyId:t,integrationId:h,integrations:m,selectedIntegrationId:h,onSelectIntegration:i}))):e.createElement("div",{className:"flex h-full items-center justify-center"},e.createElement(te,{title:"Não foi possÃvel identificar o estabelecimento atual"}))}export{Xt as default}; 4 5//# debugId=13c30caf-b6a1-5f5c-9021-b5a593d6be9d
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.