PageSourceSearch

https://portal.avanza.com.br/assets/EmbedPortal-8420f484.js

js avanza.com.br collected 2026-10-01 15:00:59 UTC 24,719 bytes, 1 lines download raw bytes

1import{j as e}from"./ui-916dc9d9.js";import{S as je,P as ce}from"./PayInvoiceDrawerPortal-e5577e90.js";import{I as ye}from"./InvoiceInRecurrenceInfo-c3e1be5d.js";import{b4 as _,b5 as G,b6 as de,w as V,n as me,b7 as ue,a5 as ve,P as we,b2 as Ne,b8 as Ie,x as Ce,j as xe,a as q,Q as te,b3 as Pe,b9 as Ee,ba as se,bb as re,J as ne,bc as Se,g as ke,bd as Fe,be as Re,a0 as J,H as Te,o as fe,bf as Me,a1 as De,bg as Le,a2 as Ae,bh as Oe,aj as We,ak as $}from"./index-a2ab00f7.js";import{t as Ue,D as Be,a as he,v as ze,Q as He}from"./CreditCardPaymentError-8e6ac17e.js";import{r as l}from"./vendor-aea060b0.js";import{E as B,u as $e,I as qe,a as _e}from"./EmbedPortalProvider-0af06648.js";import{C as ge}from"./index-6b292738.js";import{E as Ve}from"./ErrorRequestGeneric-6f936de2.js";import{C as Je}from"./ContractStatus-d4da8aad.js";import{H as ae}from"./HelmetTitle-a7f2b938.js";import{P as Qe,B as Ke}from"./useBemobiDrawer-d7b0e5e3.js";import{u as Ge}from"./bemobiSmartCheckoutServices.hook-17709f05.js";import{f as Xe}from"./index-a3437bd6.js";import{S as Ye}from"./SmartCheckoutErrorScreen-e5a7be1f.js";import{E as Ze,a as et}from"./AutomaticPixQrCode-f44b7341.js";import{P as tt}from"./PaymentMethodConfig-665a382d.js";import{N as st,a as rt}from"./negotiation-origin-fa551dbc.js";import"./useInvoicePixStatus-31b26f1f.js";import"./index-72cc605b.js";import"./IconCircleCheck-18392a9c.js";import"./motion-b076d11a.js";import"./IconBrandWhatsapp-ae42609f.js";import"./pdf-viewer-9b371a90.js";import"./luxon-cc86f6dc.js";import"./IconCircleX-8a9b6a2a.js";import"./NegotiationError-a7cb9c5b.js";import"./NegotiateDebtsItems-0072d3bc.js";import"./useInvoiceContractsFromToken-a2dd5bb2.js";function nt({children:t}){return e.jsx("div",{className:"fixed w-full h-full top-0 left-0 bg-transparent",children:t})}function at(){return e.jsx("div",{className:"absolute top-0 left-0 w-screen h-screen bg-black/30 z-0"})}function ot({children:t}){return e.jsx("div",{children:t})}const oe={Root:nt,Overlay:at,Content:ot};function lt(t){const r=_();return r.pathname.includes(t)||r.search.includes(t)}function it(t,r){const s=t.split("?");if(s.length<2)return t;const o=s[0],p=s[1].split("&").filter(j=>!j.startsWith(`${r}=`));return p.length>0?`${o}?${p.join("&")}`:o}function Q(t,r,s){const o=it(s.pathname+s.search,t);r(o)}function ct({children:t}){return e.jsx("div",{className:"flex items-center justify-center h-full",children:t})}function X({children:t,limitHeight:r=!1}){const{isEmbedNoStyle:s}=G();return s()?e.jsx("div",{className:"p-3 overflow-auto h-full flex flex-col lg:justify-center",children:t}):e.jsx(ct,{children:e.jsx(ge.BoxedRoot,{limitHeight:r,children:t})})}function dt(t,r,s){r.set("invoiceId",t),s(`?${r.toString()}`)}function mt({invoices:t,disableReturn:r=!1,handleReturn:s,loading:o,error:c}){const[u]=de(),p=new URLSearchParams(u),j=V();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-row items-center gap-2 text-lg leading-[22px] text-neutral-900 font-medium mb-1",children:[!r&&e.jsx(me,{onClick:s,stroke:1.25,className:"cursor-pointer"})," ",e.jsx("span",{className:"text-lg",children:" Selecionar fatura"})]}),e.jsxs("div",{className:"h-full overflow-auto",children:[o&&e.jsx(ue,{}),!o&&c&&e.jsx("div",{className:"flex items-center justify-center h-full py-12 m-2",children:e.jsx(Ve,{message:"Não foi possível carregar suas faturas no momento. Tente novamente mais tarde ou contate a central."})}),!o&&!c&&(!t||t.length===0)&&e.jsx("div",{className:"flex flex-col bg-supportSuccess font-medium  rounded-lg items-center justify-center h-full py-12 text-center m-2",children:e.jsx("p",{className:"text-neutral-700 text-sm",children:"Não há faturas pendentes para o contrato selecionado."})}),!o&&!c&&t&&t.length>0&&t.map(a=>e.jsx("div",{className:"flex mt-2 min-h-[94px] items-center p-4 cursor-pointer border border-neutral-300 hover:border-primary rounded-lg hover:bg-primaryTransparent20 lg:text-xs text-[11px] justify-between relative cy-invoice-item-list",onClick:()=>dt(a==null?void 0:a.id,p,j),children:e.jsxs("div",{className:"flex items-start flex-col justify-start gap-1",children:[e.jsx("div",{className:"flex items-start",children:e.jsx(Ue,{title:"",status:a==null?void 0:a.paid,bold:!0,dueDate:a==null?void 0:a.dueDate})}),e.jsx("div",{className:"flex flex-col items-start text-sm mt-2",children:e.jsx("h4",{className:"text-[24px] font-semibold text-neutral-900",children:`R$ ${Be.formatAmou
1nt(a==null?void 0:a.amount)}`})}),e.jsxs("div",{className:"flex flex-col items-start mt-2",children:[e.jsx("h4",{className:"text-xs font-normal text-left text-neutral-600",children:"Vencimento"}),e.jsx("span",{className:"font-semibold text-left text-sm text-neutral-900",children:he.formatDueDate(a==null?void 0:a.dueDate)})]}),e.jsx(ve,{size:24,stroke:2,className:"text-black absolute right-4 top-[54px]"})]})},a.id))]})]})}function ut(){const{embedInvoices:t,isLoadingInvoices:r,isErrorInvoices:s,singleContract:o}=l.useContext(B),c=V(),u=_();return e.jsx(X,{limitHeight:!0,children:e.jsx(mt,{invoices:t,loading:r,error:s,disableReturn:o,handleReturn:()=>{Q("contractId",c,u)}})})}function xt(t,r,s){r.set("contractId",t),s(`?${r.toString()}`)}function ft({contracts:t,handleReturn:r,disableReturn:s,loading:o,onSelectContract:c}){const[u]=de(),p=new URLSearchParams(u),j=V(),[a,g]=l.useState("");return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex flex-row items-center gap-2 text-lg leading-[22px] text-neutral-900 font-medium mb-4",children:[!s&&e.jsx(me,{onClick:r,stroke:1.25,className:"cursor-pointer hover:text-primary"}),e.jsx("h3",{children:"Selecione o contrato"})]}),o&&e.jsx(ue,{}),!o&&e.jsx("div",{className:"flex-1 mb-4 overflow-y-auto max-h-[400px]",children:e.jsx("div",{className:"flex flex-col gap-2 pr-2",children:t==null?void 0:t.map(i=>e.jsx("div",{className:`cy-contract-item-list flex min-h-[94px] items-center p-4 cursor-pointer border border-neutral-300 hover:border-primary rounded-lg hover:bg-primaryTransparent20 lg:text-xs text-[11px] justify-between transition-colors ${a===i.id&&"border-primary bg-primaryTransparent20"}`,onClick:()=>g(i.id),children:e.jsxs("div",{className:"flex items-start flex-col justify-start",children:[e.jsx(Je,{status:i.status}),e.jsxs("span",{className:"mt-2",children:[e.jsx("span",{className:"font-semibold text-[12px] leading-normal",children:i.id}),e.jsx("span",{className:"text-primary mx-1",children:"•"}),e.jsx("span",{className:"text-[12px]",children:(i==null?void 0:i.anonymizedAddress)??(i==null?void 0:i.address)})]}),e.jsx("span",{className:"text-[14px] leading-[20px] mt-1",children:i.planName})]})},i.id))})}),e.jsx(we,{label:"Selecionar contrato",aditionalClasses:"!mt-4 !font-medium w-full",action:()=>c?c(a):xt(a,p,j),disabled:a===""})]})}function be(){const{embedContracts:t,loading:r,embedError:s,selectContract:o}=l.useContext(B);return e.jsxs(X,{limitHeight:!0,children:[s&&e.jsx("p",{className:"text-errordefault text-sm mb-3",children:s}),e.jsx(ft,{contracts:t,disableReturn:!0,loading:r,onSelectContract:o})]})}const ht="https://smart-checkout.bemobi.com/checkout?code=",gt="https://smart-checkout-dev.bemobi.com/checkout?code=";function bt({erpInvoiceId:t,invoiceDetails:r}){const{data:s,isLoading:o,isError:c,error:u}=Ge(t),p=s!=null&&s.isProduction?ht:gt,j=s!=null&&s.isProduction?"https://smart-checkout.bemobi.com":"https://smart-checkout-dev.bemobi.com",[a,g]=l.useState(!1),[i,I]=l.useState(!1),[N,n]=l.useState({hasError:!1}),d=l.useRef(null),S=l.useRef(!1);return l.useEffect(()=>{if(a||!(r!=null&&r.id))return;const w=async()=>{try{const f=await Ne(r.id);((f==null?void 0:f.paidByPix)===!1||(f==null?void 0:f.paidByPix)===void 0)&&I(!0),(f==null?void 0:f.paidByPix)===!0&&i&&g(!0)}catch{}};w();const y=Date.now(),x=3*60*1e3,v=setInterval(()=>{if(Date.now()-y>=x){clearInterval(v);return}w()},8e3);return()=>clearInterval(v)},[t,a,r,i]),l.useEffect(()=>{S.current=!1;const w=async y=>{var v,f,h,M,R,D;if(S.current||y.origin!==j||(v=d.current)!=null&&v.contentWindow&&y.source!==d.current.contentWindow)return;const x=y.data;if((x==null?void 0:x.status)==="DENIED"){S.current=!0;try{let F=null;try{F=(h=JSON.parse((f=x==null?void 0:x.transaction)==null?void 0:f.reason))==null?void 0:h.response_message}catch{F=null}n({hasError:!0,title:"Pagamento não aprovado",details:Xe(F??((R=(M=x==null?void 0:x.transaction)==null?void 0:M.reason)==null?void 0:R.response_message)??((D=x==null?void 0:x.transaction)==null?void 0:D.reason)??"Erro não tratado","payment")}),await Ie(t,x)}catch{S.current=!1}}};return window.addEventListener("message",w),()=>window.removeEventListener("message",w)},[t]),o||!(s!=null&&s.sessionId)?e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-white",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-gray-600"})}):N.hasError?e.jsx("div",{className:"fixed inset-0 flex flex-col items-center justify-center h-full p-8 bg-white",children:e.jsx("div",{className:"grid gap-3 w-full max-w-xl",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"p-4 bg-errordefault rounded-full items-center",children:e.jsx(ze,{size:24,stroke:1.25,className:"stroke-white"})}),e.jsx("h4",{className:"text-md font-semibold text-center",children:N.title??"Erro no pagamento"}),e.jsx("p",{className:"text-sm text-center opacity-80",children:N.details??"Ocorreu um erro desconhecido. Tente novamente mais tarde ou entre em contato com o suporte!"})]})})}):a?e.jsx("div",{className:"fixed inset-0 flex flex-col bg-white",children:e.jsx(Qe,{})}):e.jsx("iframe",{ref:d,src:p+s.sessionId,allow:"payment; clipboard-read; clipboard-write; publickey-credentials-get; publickey-credentials-create;",className:"fixed top-0 left-0 w-full h-full border-none",title:"Bemobi Checkout",sandbox:"allow-same-origin allow-scripts allow-forms allow-popups allow-top-navigation"})}function pt({onClose:t,logoUrl:r,companyName:s,showHeader:o=!0}){return e.jsxs("div",{role:"status",className:"flex flex-col h-full w-full bg-white font-figtree",children:[o&&e.jsx("div",{className:"flex items-center justify-center p-4 bg-secondary",children:r&&e.jsx("img",{src:r,alt:s||"Logo",className:"max-h-16 object-contain"})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col items-center justify-center gap-6 px-6 py-8 text-center",children:[e.jsx(je,{}),e.jsxs("div",{className:"flex flex-col gap-1.5 max-w-[300px]",children:[e.jsx("h4",{className:"text-xl font-semibold text-defaultTextDark",children:"Fatura já paga"}),e.jsx("p",{className:"text-sm leading-[22px] text-neutral-500",children:"O pagamento desta fatura já foi registrado. Você não precisa fazer mais nada."})]}),t&&e.jsx("button",{onClick:t,className:"w-full max-w-[320px] rounded-lg bg-primary text-primaryContrast py-3 text-sm font-medium hover:brightness-95 transition",children:"Fechar"})]})]})}function K(){var ee;const t=new URLSearchParams(window.location.search)??null,r=(t==null?void 0:t.get("raw"))==="true",[s,o]=l.useState(!1),[c,u]=l.useState(!1),{invoiceId:p}=Ce(),j=(t==null?void 0:t.get("contractId"))??null,[a,g]=l.useState(),i=V(),I=_(),{loading:N,embedContracts:n,activeContract:d,embedError:S,embedToken:w,embedInvoiceId:y,embedRaw:x,onClose:v}=l.useContext(B),f=xe(),h=p||a||y||null,M=r||!!x,R=((n==null?void 0:n.length)??0)>0;function D(){return lt("invoice")}function F(){return!!h}function O(){return!!j}const C=()=>
1{if(o(!1),p){const H=I.pathname.replace(`/${p}`,"");i(H+I.search,{replace:!0})}else a&&Q("invoiceId",i,I);!O()&&!y&&Q("contractId",i,I)},L=!N&&!!h&&(!!d||!!y||!R),{data:b,failureReason:W,refetch:z}=q({queryKey:[h,w],queryFn:()=>Pe(h,w),enabled:L,refetchOnWindowFocus:!1}),A=b?null:W,T=!!A&&!!h&&!!w,{data:E,isFetching:P}=q({queryKey:["embedPaidInvoiceCheck",h,w],queryFn:async()=>{const k=await Ee(w),U=((k==null?void 0:k.data)??[]).find(pe=>String(pe.erpInvoiceId)===String(h));return U!=null&&U.paid?U:null},enabled:T,retry:!1,refetchOnWindowFocus:!1});l.useEffect(()=>{const k=(t==null?void 0:t.get("invoiceId"))??null;g(k)},[t]),l.useEffect(()=>{h&&o(!0)},[h]);const m=()=>{C(),v==null||v()},Y={logoUrl:(ee=f==null?void 0:f.Logo)==null?void 0:ee.Content,companyName:f==null?void 0:f.Name},Z=(k,H)=>M?e.jsxs("div",{className:"fixed inset-0 z-50 bg-white flex flex-col",children:[e.jsx(ae,{title:k}),H(!1)]}):e.jsxs(te,{title:"Pagamento de Fatura",openedDrawer:s,closeDrawer:m,drawerContainerClasses:"p-0 overflow-hidden",children:[e.jsx(ae,{title:k}),H(!0)]});return N?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md lg:w-full w-[300px] mx-4",children:[e.jsx("div",{className:"flex justify-center items-center h-32",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-4 border-blue-600"})}),e.jsx("p",{className:"text-center text-gray-600 mt-4",children:"Carregando..."})]})}):S&&!R?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white rounded-lg p-6 max-w-md lg:w-full w-[300px] mx-4",children:e.jsx("div",{className:"flex flex-col items-center gap-4 py-8",children:e.jsx("p",{className:"text-errordefault text-sm text-center",children:S})})})}):R&&!d&&!y?e.jsx(be,{}):L&&!b&&!W?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md lg:w-full w-[300px] mx-4",children:[e.jsx("div",{className:"flex justify-center items-center h-32",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-4 border-blue-600"})}),e.jsx("p",{className:"text-center text-gray-600 mt-4",children:"Carregando dados da fatura..."})]})}):A&&T&&P&&E===void 0?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md lg:w-full w-[300px] mx-4",children:[e.jsx("div",{className:"flex justify-center items-center h-32",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-4 border-blue-600"})}),e.jsx("p",{className:"text-center text-gray-600 mt-4",children:"Carregando dados da fatura..."})]})}):A&&E?Z(`Fatura paga | ${h}`,k=>e.jsx(pt,{...Y,showHeader:!k,onClose:k?m:v})):A?Z(`Pagamento de Fatura | ${h}`,k=>e.jsx(Ye,{...Y,title:"Erro ao carregar dados da fatura",message:"Tente novamente em instantes.",onRetry:()=>z(),onClose:k?m:v,showHeader:!k,showSecureFooter:!1})):e.jsxs(e.Fragment,{children:[!F()&&D()&&e.jsx(ut,{}),b&&!b.useBemobiSmartCheckout&&F()&&e.jsx(ce,{open:s,closeDrawer:C,invoice:h}),(b==null?void 0:b.useBemobiSmartCheckout)&&(b==null?void 0:b.erpInvoiceId)&&F()&&(()=>{var U;return(!!((U=d==null?void 0:d.currentCard)!=null&&U.id)&&(d==null?void 0:d.collectionTypeId)===3||(b==null?void 0:b.recurrenceCollectionType)===3)&&!he.isBeforeToday(b==null?void 0:b.dueDate)&&!c?e.jsx(te,{title:"Pagamento de Fatura",openedDrawer:s,closeDrawer:()=>{C(),u(!1)},children:e.jsx(ye,{onConfirm:()=>u(!0)})}):M?e.jsx(bt,{erpInvoiceId:b.erpInvoiceId}):e.jsx(Ke,{open:s,onClose:()=>{C(),u(!1)},erpInvoiceId:b.erpInvoiceId,invoiceDetails:b})})()]})}function jt({token:t,contractId:r,saleId:s,invoiceId:o,raw:c=!1,singleContract:u=!1,primaryColor:p=null,secondaryColor:j=null,children:a}){const[g,i]=l.useState(null),[I,N]=l.useState(null),[n,d]=l.useState(!0),[S,w]=l.useState(null),[y,x]=l.useState(!1),[v,f]=l.useState([]),{sendEventToCompanies:h}=$e(),{pathname:M}=_(),R=M.includes("/negotiation"),D=M.includes("/invoice");l.useEffect(()=>{(async()=>{var E,P;d(!0),i(null),ne.getInstance().logout();try{if(ne.getInstance().login(t,""),localStorage.setItem("7azFrontAccessType","completeAccess"),Se({token:t}),N(t),!R&&!o)if(s){const m=await ke(t,s);i(m==null?void 0:m.data)}else if(r){const m=await re(t,r);i(m==null?void 0:m.data)}else{const m=await Fe(t);f(m==null?void 0:m.data)}}catch(m){w(((P=(E=m==null?void 0:m.response)==null?void 0:E.data)==null?void 0:P.message)??"Erro ao carregar dados do usuário")}finally{d(!1)}})()},[t,r,s,y]);const F=D&&!!I&&!n&&(!r||!!g),{data:O,isLoading:C,isError:L}=q(["openEmbedInvoicesJwt",r,s,g==null?void 0:g.id],async()=>{const T=await Re(I),E=(T==null?void 0:T.data)||[];return s?E.filter(P=>P.erpSaleId===s):g!=null&&g.id?E.filter(P=>P.erpContractId===g.id):E},{refetchOnWindowFocus:!1,refetchOnMount:!0,refetchInterval:y?3e3:!1,enabled:F}),b=O,W=C||!F,z=F&&L,A=l.useMemo(()=>({onClose:()=>{se({type:"event",data:{action:"close"}})},onAction:(T,E)=>{h(T,E),se({type:"action",data:{action:T,...E}})},embedToken:I,activeContract:g,loading:n,embedError:S,setContractHasChanged:x,contractHasChanged:y,embedContracts:v,embedInvoices:b,isLoadingInvoices:W,isErrorInvoices:z,singleContract:u,embedIsJwt:!0,embedContractId:r??null,embedSaleId:s??null,embedInvoiceId:o??null,embedRaw:c,embedPrimaryColor:p??null,embedSecondaryColor:j??null,selectContract:async T=>{var E,P;d(!0),w(null);try{const m=await re(t,T);i(m==null?void 0:m.data)}catch(m){w(((P=(E=m==null?void 0:m.response)==null?void 0:E.data)==null?void 0:P.message)??"Erro ao carregar dados do usuário")}finally{d(!1)}}}),[I,g,n,S,y,v,b,W,z,u]);return e.jsx(B.Provider,{value:A,children:a})}function yt(){return e.jsxs("div",{className:"flex flex-col gap-4 animate-pulse",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{className:"skeleton-bg h-6 w-48 rounded-md"}),e.jsx("div",{className:"skeleton-bg h-4 w-72 rounded-md"})]}),e.jsx("div",{className:"skeleton-bg h-3 w-24 rounded-md"}),e.jsx("div",{className:"skeleton-bg h-14 w-full rounded-xl"}),e.jsx("div",{className:"skeleton-bg h-3 w-40 rounded-md"}),e.jsx("div",{className:"flex flex-col gap-2",children:[1,2,3,4].map(t=>e.jsx("div",{className:"skeleton-bg h-14 w-full rounded-xl"},t))}),e.jsx("div",{className:"skeleton-bg h-11 w-full rounded-xl mt-2"})]})}function vt(){const{onClose:t,activeContract:r,embedError:s,contractHasChanged:o,loading:c}=l.useContext(B),{isEmbedNoStyle:u}=G(),{changePaymentMethod:p,bemobiChangePaymentMethod:j,changedPaymentMethod:a,availablePaymentsCards:g,availablePaymentsMethod:i,newPaymentMethod:I,setNewPaymentMethod:N,loadingCreditCardPayment:n,creditCardNumber:d,setCreditCardNumber:S,creditCardExpiration:w,setCreditCardExpiration:y,creditCardCvv:x,setCreditCardCvv:v,debitAccountData:f,setDebitAccountData:h,loadingChangePaymentMethod:M,setChangedPaymentMethod:R,currentPaymentMethod:D,newDebitForm:F,setNewDebitForm:O,clearChangePaymentData:C,automaticPixCode:L,changePaymentError:b}=l.useContext(Ze);xe();const W=[...g,...i].length>0,[z,A]=l.useState((r==null?void 0:r.collectionTypeId)??0),T=P=>{A(P),N(typeof P=="number"?P.toString():P)},E=P=>{A(P)};return l.useEffect(()=>{open||(C(),R(!1))},[open,N,S,y,v,h,R]),c?e.jsxs("div",{className:"relative",children:[!u()&&e.jsxs("button",{type:"button",className:"absolute right-0 top-0",onClick:()=>t(),children:[e.jsx("span",{className:"sr-only",children:"Fechar"}),e.jsx(J,{width:24,color:"#262626"})]}),e.jsx(yt,{})]}):e.jsxs("div",{className:"relative",children:[!u()&&e.jsxs("button",{type:"button",className:"absolute right-0 top-0",onClick:()=>t(),children:[e.jsx("span",{className:"sr-only",children:"Fechar"}),e.jsx(J,{width:24,color:"#262626"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx(ge.Title,{title:"Forma de pagamento"}),e.jsx("div",{className:"text-sm mt-3 mb-2 p-3 rounded-md border border-supportError bg-supportError",children:e.jsx("span",{className:"",children:s})})]}),!s&&e.jsx(tt,{changedPaymentMethod:a,hasAvailablePaymentMethod:W,activeContract:r,selectedPaymentMethod:z,newPaymentMethod:I,currentPaymentMethod:D,newDebitForm:F,creditCardNumber:d,setCreditCardNumber:S,creditCardExpiration:w,setCreditCardExpiration:y,creditCardCvv:x,setCreditCardCvv:v,loadingCreditCardPayment:n,debitAccountData:f,setDebitAccountData:h,loadingChangePaymentMethod:M,bemobiChangePaymentMethod:j,changePaymentMethod:p,handlePaymentMethod:T,setNewPaymentMethod:N,setNewDebitForm:O,handleCurrentPaymentMethod:E,setChangedPaymentMethod:R,contractHasChanged:o,automaticPixCode:L,changePaymentError:b})]})}function wt(){return e.jsx(X,{children:e.jsx(et,{children:e.jsx(vt,{})})})}function le(){const{permissions:t}=Te(),[r,s]=l.useState(!0),[o,c]=l.useState(!1),[u,p]=l.useState(null),{loading:j,embedToken:a,embedError:g,embedInvoiceId:i,embedContractId:I,embedIsJwt:N,onClose:n}=l.useContext(B),d=N?a:null,S=!!i,w=l.useMemo(()=>
1{if(t!=null&&t.canNegotiate)return!0;if(!a)return!1;try{const C=fe(a);return Array.isArray(C==null?void 0:C.role)&&C.role.includes("CanNegotiate")}catch{return!1}},[t==null?void 0:t.canNegotiate,a]),y=!j&&!!a&&w&&!S,x=N?I??null:null,{data:v,isLoading:f}=q({queryKey:d?["invoicesForNegotiation","embed-jwt",x??"all"]:["invoicesForNegotiation"],queryFn:async()=>(d?await Me(d,x):await De()).data??[],refetchOnWindowFocus:!1,staleTime:60*1e3,enabled:y}),{data:h,isLoading:M}=q({queryKey:d?["negotiateInvoiceForPayment","embed-jwt",x??"all"]:["negotiateInvoiceForPayment"],queryFn:async()=>(d?await Le(d,x):await Ae()).data??[],refetchOnWindowFocus:!1,staleTime:60*1e3,enabled:y}),R=()=>h!=null&&h.length?h.reduce((C,L)=>L.maximumDiscountPercentage>C.maximumDiscountPercentage?L:C):null,D=f||M,F=(v==null?void 0:v.length)>0,O=R();return S?e.jsx(K,{}):g?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-lg p-8 max-w-sm w-full text-center relative",children:[e.jsx(J,{className:"text-errordefault mx-auto mb-4",size:48}),e.jsx("p",{className:"text-gray-800 text-base font-medium",children:g})]})}):D||j?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-lg p-8 max-w-sm w-full text-center relative",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-800 text-base font-medium",children:"Carregando..."})]})}):!w&&!F&&!O?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-lg p-8 max-w-sm w-full text-center relative",children:[e.jsx(qe,{className:"text-success mx-auto mb-4",size:48}),e.jsx("p",{className:"text-gray-800 text-base font-medium",children:"Não há faturas pendentes de negociação"})]})}):e.jsxs(He,{children:[e.jsx(st,{open:r,setOpen:s,setShowNegotiationDrawerInvoice:c,invoiceDrawer:u,setInvoiceDrawer:p,authToken:d,erpContractId:N?I:null,onDismiss:N?n:void 0,origin:rt.CHECKOUT_SESSION}),o&&e.jsx(ce,{open:o,closeDrawer:c,invoice:u})]})}function ie({contractId:t,saleId:r,isJwtFlow:s}){const{activeContract:o,embedInvoiceId:c}=l.useContext(B),{isEmbedNoStyle:u}=G(),{pathname:p,search:j}=_(),a=s?!!o||!!r:!!t;return s&&c&&!p.includes("/invoice")?e.jsx(Oe,{to:`invoice${j}`,replace:!0}):e.jsxs(oe.Root,{children:[!u()&&e.jsx(oe.Overlay,{}),e.jsxs(We,{children:[e.jsx($,{path:"/change-payment",element:a?e.jsx(wt,{}):e.jsx(be,{})}),e.jsx($,{path:"/invoice/:invoiceId",element:e.jsx(K,{})}),e.jsx($,{path:"/invoice",element:e.jsx(K,{})}),e.jsx($,{path:"/negotiation/:invoiceId",element:e.jsx(le,{})}),e.jsx($,{path:"/negotiation",element:e.jsx(le,{})})]})]})}function Yt(){const t=new URLSearchParams(window.location.search)??null,r=(t==null?void 0:t.get("token"))??null,s=(t==null?void 0:t.get("embedTxId"))??null,o=(t==null?void 0:t.get("singleContract"))==="true";if(!r&&!s)return console.error("Parâmetros insuficientes."),null;let c=(t==null?void 0:t.get("contractId"))??null,u=null,p=null,j=!1,a=!1,g=null,i=null;if(r)try{const n=fe(r);c=c??(n==null?void 0:n.erpContractId)??null,u=(n==null?void 0:n.erpSaleId)??null,p=(n==null?void 0:n.invoiceId)??(n==null?void 0:n.erpInvoiceId)??null,j=(n==null?void 0:n.raw)==="true"||(n==null?void 0:n.raw)===!0,a=(n==null?void 0:n.singleContract)==="true"||(n==null?void 0:n.singleContract)===!0,g=(n==null?void 0:n.primaryColor)??null,i=(n==null?void 0:n.secondaryColor)??null}catch{return console.error("Token inválido."),null}if(r)return e.jsx(jt,{token:r,contractId:c,saleId:u,invoiceId:p,raw:j,singleContract:o||a,primaryColor:g,secondaryColor:i,children:e.jsx(ie,{contractId:c,saleId:u,isJwtFlow:!0})});const I=(t==null?void 0:t.get("primaryColor"))??null,N=(t==null?void 0:t.get("secondaryColor"))??null;return e.jsx(_e,{embedTxId:s,contractId:c,singleContract:o,primaryColor:I,secondaryColor:N,children:e.jsx(ie,{contractId:c,isJwtFlow:!1})})}export{Yt 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.