PageSourceSearch

https://vraust.ai/assets/BillingOverlay-mqg65996.js

js vraust.ai collected 2026-10-05 13:50:13 UTC 17,267 bytes, 1 lines download raw bytes

1import{aH as be,N as ve,r as d,Q as we,j as t,O as D,aI as je,R as I,Y as Se,W as ye,aJ as J,_ as Ne,ap as _e,b as Q,e as V,Z as ke,ar as G,U as Ce,aK as Pe,h as Re,$ as De,a4 as Ee,a as Me,B as U,H as Be,aq as Ae,S as Ie,E as Te,ab as Z,aL as Ve}from"./index-DOc5RAp9.js";function R(e,s,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e==null||e(a),n===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}var ee=["PageUp","PageDown"],te=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],se={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},E="Slider",[F,Ke,Oe]=be(E),[ne,rt]=ve(E,[Oe]),[Le,K]=ne(E),re=d.forwardRef((e,s)=>{const{name:n,min:r=0,max:a=100,step:o=1,orientation:i="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:x=[r],value:h,onValueChange:l=()=>{},onValueCommit:m=()=>{},inverted:f=!1,form:w,...p}=e,b=d.useRef(new Set),g=d.useRef(0),j=i==="horizontal"?$e:Ue,[v=[],M]=we({prop:h,defaultProp:x,onChange:S=>{var k;(k=[...b.current][g.current])==null||k.focus(),l(S)}}),O=d.useRef(v);function L(S){const y=We(v,S);B(S,y)}function he(S){B(S,g.current)}function ge(){const S=O.current[g.current];v[g.current]!==S&&m(v)}function B(S,y,{commit:k}={commit:!1}){const W=qe(o),$=Je(Math.round((S-r)/o)*o+r,W),A=J($,[r,a]);M((C=[])=>{const N=He(C,A,y);if(Ze(N,u*o)){g.current=N.indexOf(A);const X=String(N)!==String(C);return X&&k&&m(N),X?N:C}else return C})}return t.jsx(Le,{scope:e.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:g,thumbs:b.current,values:v,orientation:i,form:w,children:t.jsx(F.Provider,{scope:e.__scopeSlider,children:t.jsx(F.Slot,{scope:e.__scopeSlider,children:t.jsx(j,{"aria-disabled":c,"data-disabled":c?"":void 0,...p,ref:s,onPointerDown:R(p.onPointerDown,()=>{c||(O.current=v)}),min:r,max:a,inverted:f,onSlideStart:c?void 0:L,onSlideMove:c?void 0:he,onSlideEnd:c?void 0:ge,onHomeKeyDown:()=>!c&&B(r,0,{commit:!0}),onEndKeyDown:()=>!c&&B(a,v.length-1,{commit:!0}),onStepKeyDown:({event:S,direction:y})=>{if(!c){const $=ee.includes(S.key)||S.shiftKey&&te.includes(S.key)?10:1,A=g.current,C=v[A],N=o*$*y;B(C+N,A,{commit:!0})}}})})})})});re.displayName=E;var[ae,ie]=ne(E,{startEdge:"left",endEdge:"right",size:"width",direction:1}),$e=d.forwardRef((e,s)=>{const{min:n,max:r,dir:a,inverted:o,onSlideStart:i,onSlideMove:c,onSlideEnd:u,onStepKeyDown:x,...h}=e,[l,m]=d.useState(null),f=D(s,j=>m(j)),w=d.useRef(void 0),p=je(a),b=p==="ltr",g=b&&!o||!b&&o;function _(j){const v=w.current||l.getBoundingClientRect(),M=[0,v.width],L=Y(M,g?[n,r]:[r,n]);return w.current=v,L(j-v.left)}return t.jsx(ae,{scope:e.__scopeSlider,startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width",children:t.jsx(oe,{dir:p,"data-orientation":"horizontal",...h,ref:f,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:j=>{const v=_(j.clientX);i==null||i(v)},onSlideMove:j=>{const v=_(j.clientX);c==null||c(v)},onSlideEnd:()=>{w.current=void 0,u==null||u()},onStepKeyDown:j=>{const M=se[g?"from-left":"from-right"].includes(j.key);x==null||x({event:j,direction:M?-1:1})}})})}),Ue=d.forwardRef((e,s)=>{const{min:n,max:r,inverted:a,onSlideStart:o,onSlideMove:i,onSlideEnd:c,onStepKeyDown:u,...x}=e,h=d.useRef(null),l=D(s,h),m=d.useRef(void 0),f=!a;function w(p){const b=m.current||h.current.getBoundingClientRect(),g=[0,b.height],j=Y(g,f?[r,n]:[n,r]);return m.current=b,j(p-b.top)}return t.jsx(ae,{scope:e.__scopeSlider,startEdge:f?"bottom":"top",endEdge:f?"top":"bottom",size:"height",direction:f?1:-1,children:t.jsx(oe,{"data-orientation":"vertical",...x,ref:l,style:{...x.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:p=>{const b=w(p.clientY);o==null||o(b)},onSlideMove:p=>{const b=w(p.clientY);i==null||i(b)},onSlideEnd:()=>{m.current=void 0,c==null||c()},onStepKeyDown:p=>{const g=se[f?"from-bottom":"from-top"].includes(p.key);u==null||u({event:p,direction:g?-1:1})}})})}),oe=d.forwardRef((e,s)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:c,onStepKeyDown:u,...x}=e,h=K(E,n);return t.jsx(I.span,{...x,ref:s,onKeyDown:R(e.onKeyDown,l=>{l.key==="Home"?(i(l),l.preventDefault()):l.key==="End"?(c(l),l.preventDefault()):ee.concat(te).includes(l.key)&&
1(u(l),l.preventDefault())}),onPointerDown:R(e.onPointerDown,l=>{const m=l.target;m.setPointerCapture(l.pointerId),l.preventDefault(),h.thumbs.has(m)?m.focus():r(l)}),onPointerMove:R(e.onPointerMove,l=>{l.target.hasPointerCapture(l.pointerId)&&a(l)}),onPointerUp:R(e.onPointerUp,l=>{const m=l.target;m.hasPointerCapture(l.pointerId)&&(m.releasePointerCapture(l.pointerId),o(l))})})}),le="SliderTrack",ce=d.forwardRef((e,s)=>{const{__scopeSlider:n,...r}=e,a=K(le,n);return t.jsx(I.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:s})});ce.displayName=le;var z="SliderRange",de=d.forwardRef((e,s)=>{const{__scopeSlider:n,...r}=e,a=K(z,n),o=ie(z,n),i=d.useRef(null),c=D(s,i),u=a.values.length,x=a.values.map(m=>fe(m,a.min,a.max)),h=u>1?Math.min(...x):0,l=100-Math.max(...x);return t.jsx(I.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...e.style,[o.startEdge]:h+"%",[o.endEdge]:l+"%"}})});de.displayName=z;var H="SliderThumb",ue=d.forwardRef((e,s)=>{const n=Ke(e.__scopeSlider),[r,a]=d.useState(null),o=D(s,c=>a(c)),i=d.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return t.jsx(Fe,{...e,ref:o,index:i})}),Fe=d.forwardRef((e,s)=>{const{__scopeSlider:n,index:r,name:a,...o}=e,i=K(H,n),c=ie(H,n),[u,x]=d.useState(null),h=D(s,_=>x(_)),l=u?i.form||!!u.closest("form"):!0,m=Se(u),f=i.values[r],w=f===void 0?0:fe(f,i.min,i.max),p=Ye(r,i.values.length),b=m==null?void 0:m[c.size],g=b?Xe(b,w,c.direction):0;return d.useEffect(()=>{if(u)return i.thumbs.add(u),()=>{i.thumbs.delete(u)}},[u,i.thumbs]),t.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${w}% + ${g}px)`},children:[t.jsx(F.ItemSlot,{scope:e.__scopeSlider,children:t.jsx(I.span,{role:"slider","aria-label":e["aria-label"]||p,"aria-valuemin":i.min,"aria-valuenow":f,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...o,ref:h,style:f===void 0?{display:"none"}:e.style,onFocus:R(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),l&&t.jsx(me,{name:a??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:f},r)]})});ue.displayName=H;var ze="RadioBubbleInput",me=d.forwardRef(({__scopeSlider:e,value:s,...n},r)=>{const a=d.useRef(null),o=D(a,r),i=ye(s);return d.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(u,"value").set;if(i!==s&&h){const l=new Event("input",{bubbles:!0});h.call(c,s),c.dispatchEvent(l)}},[i,s]),t.jsx(I.input,{style:{display:"none"},...n,ref:o,defaultValue:s})});me.displayName=ze;function He(e=[],s,n){const r=[...e];return r[n]=s,r.sort((a,o)=>a-o)}function fe(e,s,n){const o=100/(n-s)*(e-s);return J(o,[0,100])}function Ye(e,s){return s>2?`Value ${e+1} of ${s}`:s===2?["Minimum","Maximum"][e]:void 0}function We(e,s){if(e.length===1)return 0;const n=e.map(a=>Math.abs(a-s)),r=Math.min(...n);return n.indexOf(r)}function Xe(e,s,n){const r=e/2,o=Y([0,50],[0,r]);return(r-o(s)*n)*n}function Ge(e){return e.slice(0,-1).map((s,n)=>e[n+1]-s)}function Ze(e,s){if(s>0){const n=Ge(e);return Math.min(...n)>=s}return!0}function Y(e,s){return n=>{if(e[0]===e[1]||s[0]===s[1])return s[0];const r=(s[1]-s[0])/(e[1]-e[0]);return s[0]+r*(n-e[0])}}function qe(e){return(String(e).split(".")[1]||"").length}function Je(e,s){const n=Math.pow(10,s);return Math.round(e*n)/n}var pe=re,Qe=ce,et=de,tt=ue;const xe=d.forwardRef(({className:e,...s},n)=>t.jsxs(pe,{ref:n,className:Ne("relative flex w-full touch-none select-none items-center",e),...s,children:[t.jsx(Qe,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:t.jsx(et,{className:"absolute h-full bg-primary"})}),t.jsx(tt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));xe.displayName=pe.displayName;
1function P(e){return e.toLocaleString()}function T(e){return(e/100).toFixed(2)}function q(){const{summary:e,loading:s,refresh:n}=_e(),{toast:r}=Q(),[a,o]=d.useState(0),[i,c]=d.useState(!1);if(d.useEffect(()=>{e&&o(e.overage_cap_cents??0)},[e==null?void 0:e.overage_cap_cents]),s)return t.jsxs("div",{className:"rounded-xl border border-[hsl(var(--dark-border))] bg-white/[0.02] p-5 flex items-center gap-2 text-sm text-[hsl(var(--dark-muted))]",children:[t.jsx(V,{className:"h-4 w-4 animate-spin"}),"Loading credit usage…"]});if(!e)return null;const u=e.granted>0?Math.min(100,Math.round(e.consumed/e.granted*100)):0,x=!!e.family_pool,h=x&&e.family_pool&&e.family_pool.granted>0?Math.min(100,Math.round(e.family_pool.consumed/e.family_pool.granted*100)):0,l=async()=>{c(!0);const{data:f,error:w}=await Re.rpc("set_user_overage_cap",{_cap_cents:a});w?r({title:"Could not update cap",description:w.message,variant:"destructive"}):f!=null&&f.success?(r({title:"Overage cap updated",description:`New limit: $${T(a)} / month`}),n()):r({title:"Could not update cap",description:(f==null?void 0:f.reason)||"Unknown error",variant:"destructive"}),c(!1)},m=a!==e.overage_cap_cents;return t.jsxs("div",{className:"rounded-xl border border-[hsl(var(--dark-border))] bg-white/[0.02] p-5 space-y-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ke,{className:"h-4 w-4 text-amber-300"}),t.jsx("p",{className:"text-sm font-semibold text-[hsl(var(--dark-fg))]",children:"Credit usage"})]}),t.jsx("span",{className:"text-[10px] uppercase tracking-wider text-[hsl(var(--dark-muted))]",children:e.plan_name})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[t.jsx("p",{className:"text-xs text-[hsl(var(--dark-muted))]",children:"This period"}),t.jsxs("p",{className:"text-xs text-[hsl(var(--dark-fg))]",children:[t.jsx("span",{className:"font-semibold",children:P(e.consumed)}),t.jsxs("span",{className:"text-[hsl(var(--dark-muted))]",children:[" / ",P(e.granted)," credits"]})]})]}),t.jsx(G,{value:u,className:"h-2 bg-white/[0.06]"}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[hsl(var(--dark-muted))]",children:[P(Math.max(0,e.granted-e.consumed))," credits remaining"]})]}),x&&e.family_pool&&t.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(Ce,{className:"h-3.5 w-3.5 text-emerald-300"}),t.jsx("p",{className:"text-xs font-medium text-[hsl(var(--dark-fg))]",children:"Family pool"})]}),t.jsx(G,{value:h,className:"h-1.5 bg-white/[0.06]"}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[hsl(var(--dark-muted))]",children:[P(e.family_pool.consumed)," / ",P(e.family_pool.granted)," pooled credits used"]})]}),e.overage_enabled&&t.jsxs("div",{className:"pt-3 border-t border-white/[0.06] space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-[hsl(var(--dark-fg))]",children:"Overage cap"}),t.jsxs("p",{className:"text-[11px] text-[hsl(var(--dark-muted))] mt-0.5 flex items-start gap-1",children:[t.jsx(Pe,{className:"h-3 w-3 mt-0.5 shrink-0"}),"Once allocation runs out, extra credits cost $",(e.overage_price_cents_per_credit/100).toFixed(2)," each, up to your cap."]})]}),t.jsxs("p",{className:"text-sm font-semibold text-[hsl(var(--dark-fg))] whitespace-nowrap",children:["$",T(a),"/mo"]})]}),t.jsx(xe,{value:[a],min:0,max:5e4,step:500,onValueChange:f=>o(f[0]),className:"py-1"}),t.jsxs("div",{className:"flex items-center justify-between text-[10px] text-[hsl(var(--dark-muted))]",children:[t.jsx("span",{children:"$0 (off)"}),t.jsx("span",{children:"$500 max"})]}),e.overage_consumed>0&&t.jsx("div",{className:"rounded-lg bg-amber-400/[0.06] border border-amber-400/20 px-3 py-2",children:t.jsxs("p",{className:"text-[11px] text-amber-200",children:["Used ",t.jsx("span",{className:"font-semibold",children:P(e.overage_consumed)})," overage credits this period"," · ",t.jsxs("span",{className:"font-semibold",children:["$",T(e.overage_consumed*e.overage_price_cents_per_credit)]})," billed at period end"]})}),m&&t.jsx("button",{onClick:l,disabled:i,className:"w-full h-9 rounded-lg bg-white text-black text-xs font-medium hover:bg-white/90 disabled:opacity-50 inline-flex items-center justify-center gap-2",children:i?t.jsx(V,{className:"h-3.5 w-3.5 animate-spin"}):`Save cap at $${T(a)}/mo`})]}),!e.overage_enabled&&t.jsx("p",{className:"text-[11px] text-[hsl(var(--dark-muted))] pt-2 border-t border-white/[0.06]",children:e.plan_id==="family"?"Family plan has a hard cap, upgrade individual members to unlock overage.":"Free plan has a hard cap, upgrade to Pro or Solo for overage."})]})}function st(){const{t:e,i18n:s}=De(),n=Ee(),{toast:r}=Q(),{loading:a,subscription:o,plan:i,isActive:c,isTrialing:u,cycle:x}=Me(),[h,l]=d.useState(!1),m=p=>p?new Date(p).toLocaleDateString(s.language,{year:"numeric",month:"short",day:"numeric"}):",",f=async()=>
1{l(!0);try{Z("cta_clicked",{location:"billing",label:"manage_subscription"});const p=await Ve(`${window.location.origin}/settings`);window.open(p,"_blank","noopener,noreferrer")}catch(p){r({title:e("billing.couldNotOpen"),description:p.message||e("billing.tryAgain"),variant:"destructive"}),Z("error_shown",{component:"BillingSection",message:(p==null?void 0:p.message)??"portal_failed"})}finally{l(!1)}};if(a)return t.jsxs("div",{className:"rounded-xl border border-[hsl(var(--dark-border))] bg-white/[0.02] p-5 flex items-center gap-2 text-sm text-[hsl(var(--dark-muted))]",children:[t.jsx(V,{className:"h-4 w-4 animate-spin"}),e("billing.loadingBilling")]});if(!c||!i)return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"rounded-xl border border-[hsl(var(--dark-border))] bg-white/[0.02] p-5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-[hsl(var(--dark-fg))]",children:e("billing.freePlan")}),t.jsx("p",{className:"text-xs text-[hsl(var(--dark-muted))] mt-0.5",children:e("billing.freePlanDesc")})]}),t.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/5 text-[10px] uppercase tracking-wider text-[hsl(var(--dark-muted))]",children:e("billing.lookedAfter")})]}),t.jsxs(U,{onClick:()=>{n("/pricing")},className:"w-full h-11 bg-white text-black hover:bg-white/90 font-medium rounded-xl",children:[t.jsx(Be,{className:"h-4 w-4 mr-2"}),e("billing.seePlans")]})]}),t.jsx(q,{})]});const w=o!=null&&o.cancel_at_period_end?e("billing.cancelsOn",{date:m(o.current_period_end)}):e("billing.renewsOn",{date:m((o==null?void 0:o.current_period_end)??null)});return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"rounded-xl border border-white/15 bg-gradient-to-br from-white/[0.06] to-white/[0.02] p-5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(Ae,{className:"h-4 w-4 text-amber-300"}),t.jsxs("p",{className:"text-sm font-semibold text-[hsl(var(--dark-fg))]",children:["Vraust ",i.name]}),u&&t.jsx("span",{className:"px-1.5 py-0.5 rounded-full bg-emerald-500/15 text-emerald-300 text-[10px] font-semibold uppercase tracking-wider",children:e("billing.trial")})]}),t.jsxs("p",{className:"text-xs text-[hsl(var(--dark-muted))]",children:[e(x==="annual"?"billing.billedYearly":"billing.billedMonthly")," · ",w]})]}),t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-emerald-500/15 text-emerald-300 text-[10px] font-semibold uppercase tracking-wider",children:[t.jsx(Ie,{className:"h-3 w-3"}),i.badge]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(U,{onClick:f,disabled:h,className:"h-11 bg-white text-black hover:bg-white/90 font-medium rounded-xl",children:h?t.jsx(V,{className:"h-4 w-4 animate-spin"}):t.jsxs(t.Fragment,{children:[e("billing.manageSubscription"),t.jsx(Te,{className:"h-3.5 w-3.5 ml-2"})]})}),t.jsx(U,{onClick:()=>{n("/pricing")},variant:"outline",className:"h-11 bg-transparent border-[hsl(var(--dark-border))] text-[hsl(var(--dark-fg))] hover:bg-white/5 rounded-xl",children:e("billing.changePlan")})]}),t.jsx("p",{className:"text-[11px] text-[hsl(var(--dark-muted))] mt-3 text-center",children:e("billing.billingHelp")})]}),t.jsx(q,{})]})}function at({onClose:e}){return t.jsx("div",{className:"px-6 py-6 max-w-3xl mx-auto",children:t.jsx(st,{})})}export{at 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.