1import"../chunks/Bm6YAp9C.js";import"../chunks/8eo8wfh5.js";import{o as Pt}from"../chunks/QWZ8k-sP.js";import{k as It,a as o,p as be,h as s,t as u,aq as b,j as e,u as ue,b as xe,bK as wt,O as me,K as y,bL as yt,e as D,f as _,ac as Ae,i as a,a8 as We,a$ as ge,aY as le,aZ as ce,c as ke,a_ as Xe}from"../chunks/Dvx63mQ5.js";import{a as g}from"../chunks/BgRmz9Q1.js";import{i as S}from"../chunks/B7PSowks.js";import{e as kt,i as zt}from"../chunks/D-i3meZr.js";import{i as at}from"../chunks/C3FSNMbo.js";import{a as St}from"../chunks/DA7Ghcco.js";import{p as pe,r as Ct}from"../chunks/8x0rFZn3.js";import{I as ze}from"../chunks/jlnUts-0.js";import{I as Mt}from"../chunks/C8XVO-xY.js";import{I as At}from"../chunks/CxgCipJr.js";import{I as Dt}from"../chunks/DQY75DMD.js";import{J as $e}from"../chunks/PgiLNoRC.js";import{d as fe}from"../chunks/Bof1u0Bp.js";import{v as Tt,w as Rt,x as Yt,y as Et,z as Ft,A as Ut}from"../chunks/CwcU8LbC.js";import{T as De}from"../chunks/BB4mOl4y.js";import it from"../chunks/CWHzB0WY.js";import{S as m}from"../chunks/j_IQVH_b.js";import{T as nt}from"../chunks/GqiBFO-w.js";import{S as Vt}from"../chunks/CZ_xTpu7.js";import{B as A}from"../chunks/D8nRiFpA.js";import{t as E}from"../chunks/d_2NY89L.js";import{g as Ht}from"../chunks/SY-aXDk5.js";import{F as Ot}from"../chunks/Bobjo2Je.js";import{V as Bt}from"../chunks/B4-6HnFN.js";import{I as Lt}from"../chunks/COUwhuxb.js";import{R as he}from"../chunks/vp8BXnDT.js";import{T as qt}from"../chunks/OrkJeIFT.js";import{I as st}from"../chunks/BrYDvbVw.js";import{O as Nt}from"../chunks/DLtSTN2D.js";import{p as jt}from"../chunks/EfIOc01w.js";import{h as et}from"../chunks/C3JHmdT1.js";import{I as Se}from"../chunks/BxOlMW9B.js";import{a as Ce}from"../chunks/Ba2nDXGK.js";var Gt=new Set(["$$slots","$$events","$$legacy","size"]),Jt=It('<svg><path d="M5.5 9.511c.076.954.83 1.697 2.182 1.785V12h.6v-.709c1.4-.098 2.218-.846 2.218
1-1.932 0-.987-.626-1.496-1.745-1.76l-.473-.112V5.57c.6.068.982.396 1.074.85h1.052c-.076-.919-.864-1.638-2.126-1.716V4h-.6v.719c-1.195.117-2.01.836-2.01 1.853 0 .9.606 1.472 1.613 1.707l.397.098v2.034c-.615-.093-1.022-.43-1.114-.9zm2.177-2.166c-.59-.137-.91-.416-.91-.836 0-.47.345-.822.915-.925v1.76h-.005zm.692 1.193c.717.166 1.048.435 1.048.91 0 .542-.412.914-1.135.982V8.518z"></path><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"></path><path d="M8 13.5a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11m0 .5A6 6 0 1 0 8 2a6 6 0 0 0 0 12"></path></svg>');function Kt(O,v){let r=pe(v,"size",3,16),I=Ct(v,Gt);var p=Jt();St(p,()=>({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 16 16",width:r(),height:r(),...I})),o(O,p)}function Zt(O,v){be(v,!0);let r=ue(()=>I(v.status));function I(p){return p==="paid"?"green":p==="canceled"||p==="failed"?"red":"default"}De(O,{get color(){return e(r)},size:"small",children:(p,f)=>{s();var C=u();b(B=>g(C,B),[()=>v.status.toUpperCase()]),o(p,C)},$$slots:{default:!0}}),xe()}var Qt=D("<!> <!>",1),Wt=D("<!> <!>",1);function Xt(O,v){be(v,!1);let r=pe(v,"show",12,!1),I=pe(v,"id",8),p=pe(v,"email",8,""),f=me(!1),C=me("");function B(){if(e(f)&&!oe(e(C))){E.error("Invalid email address.");return}Tt(I(),e(f)?e(C):p()),E.success("Sending invoice..."),r(!1)}function oe(ae){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(ae)}wt(()=>e(f),()=>{e(f)||y(C,"")}),yt(),at(),it(O,{title:"Send Invoice",get show(){return r()},set show(F){r(F)},footer:F=>{var U=Qt(),L=_(U);A(L,{variant:"invisible",$$events:{click:()=>r(!1)},children:(w,Y)=>
1{s();var M=u("Cancel");o(w,M)},$$slots:{default:!0}});var R=a(L,2);A(R,{$$events:{click:B},children:(w,Y)=>{s();var M=u("Send Invoice");o(w,M)},$$slots:{default:!0}}),o(F,U)},children:(F,U)=>{var L=Wt(),R=_(L);m(R,{label:"Send invoice to",children:(Y,M)=>{{let V=Ae(()=>!e(f));nt(Y,{type:"email",get placeholder(){return p()},block:!0,get disabled(){return e(V)},get value(){return e(C)},set value(q){y(C,q)},$$legacy:!0})}},$$slots:{default:!0}});var w=a(R,2);m(w,{label:"Custom Email",children:(Y,M)=>{Vt(Y,{get checked(){return e(f)},set checked(V){y(f,V)},$$legacy:!0})},$$slots:{default:!0}}),o(F,L)},$$slots:{footer:!0,default:!0},$$legacy:!0}),xe()}var er=D("<!> <!>",1),tr=D('<div style="font-size: 14px; color: var(--text-light);"> <!></div>'),rr=D("<!> <!>",1),tt=D("<!> <!> <!> <!>",1);function or(O,v){be(v,!0);let r=pe(v,"show",15,!1),I=We(ae()),p=ge(We(I)),f=ge("requested_by_customer"),C=ge(""),B=ge(!1),oe=ue(()=>Ht(v.invoice.currency));function ae(){let R=v.invoice.amount;return v.refunds.forEach(w=>{w.status==="refunded"&&(R-=w.amount)}),R}let F=ue(()=>I>0?Math.round(e(p)/v.invoice.amount*100*100)/100:0),U=ue(()=>e(p)>I?`Amount exceeds max refundable of ${e(oe).format(I)}`:null);function L(){e(U)||(y(B,!0),Rt(v.invoice.id,e(p),e(f),e(C)).then(()=>{r(!1),E.success("Refund successful")}).catch(R=>{E.error(R.message)}).finally(()=>{y(B,!1)}))}it(O,{title:"Refund",get loading(){return e(B)},get show(){return r()},set show(w){r(w)},footer:w=>{var Y=er(),M=_(Y);A(M,{variant:"invisible",$$events:{click:()=>r(!1)},children:(q,K)=>{s();var Z=u("Cancel");o(q,Z)},$$slots:{default:!0}});var V=a(M,2);{let q=ue(()=>!!e(U));A(V,{color:"red",get disabled(){return e(q)},$$events:{click:L},children:(K,Z)=>{s();var $=u();b(()=>g($,v.invoice.paid_with==="bank_transfer"?"Mark as Refunded":"Refund")),o(K,$)},$$slots:{default:!0}})}o(w,Y)},children:(w,Y)=>{var M=tt(),V=_(M);{var q=x=>{st(x,{children:(Q,H)=>{s();var W=u(`This invoice was paid via bank transfer. First please refund the money to the customer 2 manually, then click the button below to mark it as refunded in our system.`);o(Q,W)},$$slots:{default:!0}})};S(V,x=>{v.invoice.paid_with==="bank_transfer"&&x(q)})}var K=a(V,2);m(K,{label:"Refund Amount",children:(x,Q)=>{Ot(x,{children:(H,W)=>{var J=rr(),N=_(J);nt(N,{type:"number",min:"0",get max(){return I},step:"0.01",block:!0,get value(){return e(p)},set value(k){y(p,k,!0)},start:k=>{s();var P=u();b(j=>g(P,j),[()=>v.invoice.currency.toUpperCase()]),o(k,P)},$$slots:{start:!0}});var X=a(N,2);{var ee=d=>{Bt(d,{state:"error",children:(k,P)=>{s();var j=u();b(()=>g(j,e(U))),o(k,j)},$$slots:{default:!0}})},de=d=>{var k=tr(),P=le(k),j=a(P);{var Pe=te=>{var ie=u();b(()=>g(ie,` · ${e(F)??""}% of total`)),o(te,ie)};S(j,te=>{e(p)>0&&te(Pe)})}ce(k),b(te=>g(P,`Max refundable: ${te??""} `),[()=>e(oe).format(I)]),o(d,k)};S(X,d=>{e(U)?d(ee):d(de,-1)})}o(H,J)},$$slots:{default:!0}})},$$slots:{default:!0}});var Z=a(K,2);m(Z,{label:"Reason",children:(x,Q)=>{Lt(x,{children:(H,W)=>{var J=tt(),N=_(J);he(N,{name:"reason",value:"requested_by_customer",get group(){return e(f)},set group(d){y(f,d,!0)},children:(d,k)=>{s();var P=u("Requested by Customer");o(d,P)},$$slots:{default:!0}});var X=a(N,2);he(X,{name:"reason",value:"duplicate",get group(){return e(f)},set group(d){y(f,d,!0)},children:(d,k)=>{s();var P=u("Duplicate");o(d,P)},$$slots:{default:!0}});var ee=a(X,2);he(ee,{name:"reason",value:"fraudulent",get group(){return e(f)},set group(d){y(f,d,!0)},children:(d,k)=>{s();var P=u("Fraudulent");o(d,P)},$$slots:{default:!0}});var de=a(ee,2);he(de,{name:"reason",value:"other",get group(){return e(f)},set group(d){y(f,d,!0)},children:(d,k)=>{s();var P=u("Other");o(d,P)},$$slots:{default:!0}}),o(H,J)},$$slots:{default:!0}})},$$slots:{default:!0}});var $=a(Z,2);m($,{label:"Comment",children:(x,Q)=>{qt(x,{block:!0,get value(){return e(C)},set value(H){y(C,H,!0)}})},$$slots:{default:!0}}),o(w,M)},$$slots:{footer:!0,default:!0}}),xe()}var ar=D("View Invoice PDF <!>",1),rt=D("<!> <!>",1),ir=D("<!> Refund",1),nr=D(" <!> <!>",1),ot=D("<!> Subscription",1),Me=D(" <!>",1),sr=D('<div class="charge svelte-4nlkwb"><div> </div> <div style="width: 80px;"> </div> <div class="subscription-id svelte-4nlkwb"><!></div> <div><!></div></div>'),lr=D('<div class="header svelte-4nlkwb"><!> <!> <!> <!> <!> <!></div> <div class="wrap svelte-4nlkwb"><!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!></div> <!> <!>',1);function Nr(O,v){be(v,!1);let r=me(),I=me(!1),p=me(!1);function f(){return Number(jt.params.id)}function C(){et("manage_billing")&&Yt(f()).then($=>{y(r,$)})}function B(){navigator.clipboard.writeText(e(r).invoice.id.toString()),E.success("Invoice ID copied to clipboard")}function oe($){navigator.clipboard.writeText($.toString()),E.success("Subscription ID copied to clipboard")}function ae(){navigator.clipboard.writeText(e(r).invoice.stripe_payment_intent_id.toString()),E.success("Stripe Payment Intent ID copied to clipboard")}function F(){navigator.clipboard.writeText(location.origin+`/pay?invoice=${e(r).invoice.uuid}`),E.success("Pay link copied to clipboard")}function U($){return $.replace(/_/g," ").replace(/\b\w/g,x=>x.toUpperCase())}function L($){return $?{auto:"Auto (marked as paid by system)",card:"Card",bank_transfer:"Bank Transfer"}[$]??$:"â"}async function R(){await Ce({title:"Cancel Invoice",content:"Are you sure you want to cancel this invoice?",confirmText:"Cancel Invoice",cancelText:"Abort",danger:!0})&&(Ft(f(),"canceled"),E.success("Cancelling invoice..."),location.reload())}async function w(){await Ce({title:"Regenerate Invoice",content:"Are you sure you want to regenerate this invoice? The invoice HTML/PDF will be recreated from the current data. This will NOT send the invoice to the customer.",confirmText:"Regenerate Invoice",cancelText:"Abort"})&&(await Et(f()),E.success("Invoice regenerated."))}async function Y(){await Ce({title:"Mark Invoice as Paid",content:"Are you sure you want to manually mark this invoice as paid?",confirmText:"Mark as Paid",cancelText:"Abort"})&&(await Ut(f()),E.success("Invoice marked as paid"),location.reload())}Pt(C),at();
2var M=ke(),V=_(M);{var q=$=>{var x=ke(),Q=_(x);{var H=W=>{var J=lr(),N=_(J),X=le(N);A(X,{variant:"outline",size:"medium",as:"a",get href(){return`/api/public/invoice/${e(r).invoice.uuid??""}`},target:"_blank",children:(t,l)=>{s();var n=ar(),i=a(_(n));Mt(i,{size:12}),o(t,n)},$$slots:{default:!0}});var ee=a(X,2);{var de=t=>{var l=rt(),n=_(l);A(n,{size:"medium",color:"gray",$$events:{click:R},children:(c,T)=>{s();var h=u("Cancel Invoice");o(c,h)},$$slots:{default:!0}});var i=a(n,2);A(i,{size:"medium",color:"accent",$$events:{click:Y},children:(c,T)=>{s();var h=u("Mark as Paid");o(c,h)},$$slots:{default:!0}}),o(t,l)};S(ee,t=>{e(r).invoice.status==="pending"&&t(de)})}var d=a(ee,2);{var k=t=>{A(t,{size:"medium",variant:"outline",$$events:{click:F},children:(l,n)=>{s();var i=u("Copy Pay Link");o(l,i)},$$slots:{default:!0}})};S(d,t=>{(e(r).invoice.status==="pending"||e(r).invoice.status==="failed")&&t(k)})}var P=a(d,2);A(P,{size:"medium",color:"blue",$$events:{click:()=>y(I,!0)},children:(t,l)=>{s();var n=u("Send Invoice");o(t,n)},$$slots:{default:!0}});var j=a(P,2);A(j,{size:"medium",variant:"outline",$$events:{click:w},children:(t,l)=>{s();var n=u("Regenerate Invoice");o(t,n)},$$slots:{default:!0}});var Pe=a(j,2);{var te=t=>{A(t,{variant:"outline",size:"medium",$$events:{click:()=>y(p,!0)},children:(l,n)=>{var i=ir(),c=_(i);At(c,{size:16}),s(),o(l,i)},$$slots:{default:!0}})};S(Pe,t=>{e(r).invoice.status==="paid"&&e(r).invoice.paid_with!=="auto"&&t(te)})}ce(N);var ie=a(N,2),Te=le(ie);m(Te,{label:"Invoice ID",children:(t,l)=>{s();var n=nr(),i=_(n),c=a(i);Se(c,{size:"small",color:"input",$$events:{click:B},children:(h,G)=>{ze(h,{size:12})},$$slots:{default:!0}});var T=a(c,2);Zt(T,{get status(){return e(r).invoice.status}}),b(()=>g(i,`${e(r).invoice.id??""} `)),o(t,n)},$$slots:{default:!0}});var Re=a(Te,2);m(Re,{label:"Amount",children:(t,l)=>{s();var n=u();b((i,c)=>g(n,`${i??""} 3 ${c??""}`),[()=>{var i;return((i=e(r).invoice.currency)==null?void 0:i.toUpperCase())??"EUR"},()=>{var i;return(i=e(r).invoice.amount)==null?void 0:i.toFixed(2)}]),o(t,n)},$$slots:{default:!0}});var Ye=a(Re,2);m(Ye,{label:"Invoice Date",children:(t,l)=>{s();var n=u();b(i=>g(n,i),[()=>fe.utc(e(r).invoice.invoice_date).format("YYYY-MM-DD")]),o(t,n)},$$slots:{default:!0}});var Ee=a(Ye,2);m(Ee,{label:"Event",children:(t,l)=>{De(t,{color:"blue",children:(n,i)=>{s();var c=u();b(T=>g(c,T),[()=>U(e(r).invoice.event)]),o(n,c)},$$slots:{default:!0}})},$$slots:{default:!0}});var Fe=a(Ee,2);m(Fe,{label:"Paid With",children:(t,l)=>{s();var n=u();b(i=>g(n,i),[()=>L(e(r).invoice.paid_with)]),o(t,n)},$$slots:{default:!0}});var Ue=a(Fe,2);{var lt=t=>{m(t,{label:"Starting Subscription ID",children:(l,n)=>{s();var i=Me(),c=_(i),T=a(c);{let h=Ae(()=>`/sudo/core/subscriptions/${e(r).invoice.starting_subscription_id}`);A(T,{variant:"outline",size:"medium",as:"a",get href(){return e(h)},children:(G,_e)=>{var re=ot(),ne=_(re);Kt(ne,{size:16}),s(),o(G,re)},$$slots:{default:!0}})}b(()=>g(c,`${e(r).invoice.starting_subscription_id??""} 4 Â `)),o(l,i)},$$slots:{default:!0}})},ct=t=>{m(t,{label:"Changing Subscription ID",children:(l,n)=>{s();var i=Me(),c=_(i),T=a(c);{let h=Ae(()=>`/sudo/core/subscriptions/${e(r).invoice.changing_subscription_change.subscription.id}`);A(T,{variant:"outline",size:"medium",as:"a",get href(){return e(h)},children:(G,_e)=>{var re=ot(),ne=_(re);Dt(ne,{size:16}),s(),o(G,re)},$$slots:{default:!0}})}b(()=>g(c,`${e(r).invoice.changing_subscription_change.subscription.id??""} 5 Â `)),o(l,i)},$$slots:{default:!0}})};S(Ue,t=>{e(r).invoice.starting_subscription_id?t(lt):e(r).invoice.changing_subscription_change&&t(ct,1)})}var Ve=a(Ue,2);{var ut=t=>{m(t,{label:"Stripe Payment Intent ID",children:(l,n)=>{s();var i=Me(),c=_(i),T=a(c);Se(T,{size:"small",color:"input",$$events:{click:ae},children:(h,G)=>{ze(h,{size:12})},$$slots:{default:!0}}),b(()=>g(c,`${e(r).invoice.stripe_payment_intent_id??""} `)),o(l,i)},$$slots:{default:!0}})};S(Ve,t=>{e(r).invoice.stripe_payment_intent_id&&t(ut)})}var He=a(Ve,2);m(He,{label:"Created At",children:(t,l)=>{s();var n=u();b(i=>g(n,i),[()=>fe.unix(e(r).invoice.created_at).utc().format("YYYY-MM-DD HH:mm:ss")]),o(t,n)},$$slots:{default:!0}});var Oe=a(He,2);{var dt=t=>{m(t,{label:"Generated At",children:(l,n)=>{s();var i=u();b(c=>g(i,c),[()=>fe.unix(e(r).invoice.generated_at).utc().format("YYYY-MM-DD HH:mm:ss")]),o(l,i)},$$slots:{default:!0}})};S(Oe,t=>{e(r).invoice.generated_at&&t(dt)})}var Be=a(Oe,2);{var vt=t=>{m(t,{label:"Sent At",children:(l,n)=>{s();var i=u();b(c=>g(i,c),[()=>fe.unix(e(r).invoice.sent_at).utc().format("YYYY-MM-DD HH:mm:ss")]),o(l,i)},$$slots:{default:!0}})};S(Be,t=>{e(r).invoice.sent_at&&t(vt)})}var Le=a(Be,2);m(Le,{label:"Organization",children:(t,l)=>{Nt(t,{get organization(){return e(r).invoice.organization}})},$$slots:{default:!0}});var qe=a(Le,2);{var $t=t=>{m(t,{label:"Subscription Charges",nested:n=>{var i=ke(),c=_(i);kt(c,1,()=>e(r).invoice.subscription_charges,zt,(T,h)=>{var G=sr(),_e=le(G),re=Xe(_e,!0),ne=a(_e,2),pt=Xe(ne),Ie=a(ne,2),_t=le(Ie);{var gt=z=>{var se=rt(),ve=_(se);De(ve,{size:"small",color:"blue",children:(ye,xt)=>{s();var Qe=u();b(()=>g(Qe,`Subscription ID: ${e(h).subscription.id??""}`)),o(ye,Qe)},$$slots:{default:!0}});var we=a(ve,2);Se(we,{size:"medium",color:"input",$$events:{click:()=>oe(e(h).subscription.id)},children:(ye,xt)=>{ze(ye,{size:12})},$$slots:{default:!0}}
5),o(z,se)};S(_t,z=>{e(h).subscription&&z(gt)})}ce(Ie);var Ze=a(Ie,2),ht=le(Ze);{var bt=z=>{A(z,{size:"small",variant:"outline",as:"a",get href(){return`/sudo/core/subscriptions/${e(h).subscription.id??""}`},children:(se,ve)=>{s();var we=u("View Subscription");o(se,we)},$$slots:{default:!0}})};S(ht,z=>{e(h).subscription&&z(bt)})}ce(Ze),ce(G),b((z,se,ve)=>{g(re,z),g(pt,`${se??""} 6 ${ve??""}`)},[()=>fe.utc(e(h).charge_date).format("YYYY-MM-DD"),()=>{var z;return((z=e(r).invoice.currency)==null?void 0:z.toUpperCase())??"EUR"},()=>{var z;return(z=e(h).amount)==null?void 0:z.toFixed(2)}]),o(T,G)}),o(n,i)},$$slots:{nested:!0}})};S(qe,t=>{e(r).invoice.subscription_charges.length>0&&t($t)})}var Ne=a(qe,2);m(Ne,{label:"Invoice",column:!0,children:(t,l)=>{$e(t,{get data(){return e(r).invoice},without:["html"]})},$$slots:{default:!0}});var je=a(Ne,2);m(je,{label:"Charges",column:!0,children:(t,l)=>{$e(t,{get data(){return e(r).invoice.subscription_charges}})},$$slots:{default:!0}});var Ge=a(je,2);m(Ge,{label:"Refunds",column:!0,children:(t,l)=>{$e(t,{get data(){return e(r).invoice.refunds}})},$$slots:{default:!0}});var Je=a(Ge,2);m(Je,{label:"Subscriptions",column:!0,children:(t,l)=>{$e(t,{get data(){return e(r).subscription}})},$$slots:{default:!0}});var ft=a(Je,2);m(ft,{label:"Organization",column:!0,children:(t,l)=>{$e(t,{get data(){return e(r).invoice.organization},without:["subscriptions_count"]})},$$slots:{default:!0}}),ce(ie);var Ke=a(ie,2);Xt(Ke,{get id(){return e(r).invoice.id},get email(){return e(r).invoice.organization.billing_email},get show(){return e(I)},set show(t){y(I,t)},$$legacy:!0});var mt=a(Ke,2);or(mt,{get invoice(){return e(r).invoice},get refunds(){return e(r).invoice.refunds},get show(){return e(p)},set show(t){y(p,t)},$$legacy:!0}),o(W,J)};S(Q,W=>{e(r)&&W(H)})}o($,x)},K=ue(()=>et("manage_billing")),Z=$=>{st($,{children:(x,Q)=>{s();var H=u("You do not have permissions to view this page");o(x,H)},$$slots:{default:!0}})};S(V,$=>{e(K)?$(q):$(Z,-1)})}o(O,M),xe()}export{Nr as component};
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.