@bpinternal/billing-ui 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("@tanstack/react-query"),require("react"),require("@stripe/stripe-js"),require("react-dom"),require("@stripe/react-stripe-js")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@tanstack/react-query","react","@stripe/stripe-js","react-dom","@stripe/react-stripe-js"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.BillingUI={},d.ReactJsxRuntime,d.ReactQuery,d.React,d.StripeJs,d.ReactDOM,d.ReactStripeJs))})(this,function(d,e,ne,w,sn,nn,me){"use strict";const Ga=new Map;function ja(a){let s=Ga.get(a);return s||(s=sn.loadStripe(a,{developerTools:{assistant:{enabled:!1}}}),Ga.set(a,s)),s}const ba=w.createContext(null);function rn(a){const[s,n]=w.useState(()=>typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches);return w.useEffect(()=>{if(a!=="system")return;const r=window.matchMedia("(prefers-color-scheme: dark)"),t=o=>n(o.matches);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)},[a]),a==="system"?s:a==="dark"}const tn=({client:a,stripePublishableKey:s,email:n,locale:r="en-US",theme:t="light",onToast:o,analytics:l,featureLabels:i,billingVersion:c,workspaceId:h,persist:b=!0,manageBillingUrl:p,onBillingChange:y,refreshInterval:_=3e4,children:C})=>{const v=h||"default",[m]=w.useState(()=>new ne.QueryClient({defaultOptions:{queries:{retry:1,staleTime:3e4,gcTime:1e3*60*60}}})),S=rn(t),I=w.useMemo(()=>ja(s),[s]);w.useEffect(()=>{if(!b||typeof window>"u")return;const P=`bpb-cache:${v}`;try{const x=window.localStorage.getItem(P);x&&ne.hydrate(m,JSON.parse(x))}catch{window.localStorage.removeItem(P)}let u=null;const B=m.getQueryCache().subscribe(x=>{x.type!=="added"&&x.type!=="removed"&&x.type!=="updated"||(u&&clearTimeout(u),u=setTimeout(()=>{try{window.localStorage.setItem(P,JSON.stringify(ne.dehydrate(m)))}catch{}},250))});return()=>{u&&clearTimeout(u),B()}},[b,v,m]);const L=w.useCallback(()=>m.invalidateQueries({queryKey:["bpb",v]}),[m,v]),D=w.useCallback(P=>y==null?void 0:y(P),[y]),f=_>0?_:!1,A=w.useMemo(()=>({client:a,queryClient:m,scope:v,stripePromise:I,email:n,locale:r,isDark:S,toast:o??(()=>{}),analytics:l??{},featureLabels:i,isOutdatedBilling:c!==void 0&&c!=="v4",manageBillingUrl:p,refetchInterval:f,refresh:L,notifyBillingChange:D}),[a,m,v,I,n,r,S,o,l,i,c,p,f,L,D]);return e.jsx(ba.Provider,{value:A,children:e.jsx("div",{className:"bpb-scope","data-bpb-theme":S?"dark":"light",style:{display:"contents"},children:C})})};function E(){const a=w.useContext(ba);if(!a)throw new Error("@bpinternal/billing-ui components must be rendered inside <BillingProvider>");return a}function on(){var a;return((a=w.useContext(ba))==null?void 0:a.isDark)??!1}const ae={root:a=>["bpb",a],plans:a=>["bpb",a,"plans"],addons:a=>["bpb",a,"addons"],subscription:a=>["bpb",a,"subscription"],preview:(a,s)=>["bpb",a,"preview",s],paymentMethod:a=>["bpb",a,"payment-method"],billingAddress:a=>["bpb",a,"billing-address"],customer:a=>["bpb",a,"customer"],invoices:a=>["bpb",a,"invoices"],readonly:a=>["bpb",a,"billing-readonly"],usages:(a,s)=>["bpb",a,"usages",s],bots:a=>["bpb",a,"bots"],usageByBot:(a,s,n)=>["bpb",a,"usage-by-bot",s,n]};function we(){const{client:a,queryClient:s,scope:n}=E();return ne.useQuery({queryKey:ae.plans(n),queryFn:()=>a.listPlans({})},s)}function De(){const{client:a,queryClient:s,scope:n}=E();return ne.useQuery({queryKey:ae.addons(n),queryFn:()=>a.listAddons({})},s)}function _e(a){const{client:s,queryClient:n,scope:r,refetchInterval:t}=E();return ne.useQuery({queryKey:ae.subscription(r),queryFn:()=>s.getSubscription({}),enabled:(a==null?void 0:a.enabled)??!0,refetchInterval:t},n)}function pa(a,s){const{client:n,queryClient:r,scope:t}=E();return ne.useQuery({queryKey:ae.preview(t,a),queryFn:()=>n.previewSubscriptionUpdate(a),enabled:(s==null?void 0:s.enabled)??!0},r)}function ua(a){const{client:s,queryClient:n,scope:r}=E();return ne.useQuery({queryKey:ae.paymentMethod(r),queryFn:()=>s.getPaymentMethod({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function ha(a){const{client:s,queryClient:n,scope:r}=E();return ne.useQuery({queryKey:ae.billingAddress(r),queryFn:()=>s.getBillingAddress({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function ma(a){const{client:s,queryClient:n,scope:r}=E();return ne.useQuery({queryKey:ae.customer(r),queryFn:()=>s.getCustomer({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function Va(a){const{client:s,queryClient:n,scope:r,refetchInterval:t}=E();return ne.useQuery({queryKey:ae.invoices(r),queryFn:()=>s.listInvoices({}),enabled:(a==null?void 0:a.enabled)??!0,refetchInterval:t},n)}function ga(a){const{client:s,queryClient:n,scope:r}=E();return ne.useQuery({queryKey:ae.readonly(r),queryFn:()=>s.getBillingReadonly({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function Ue(a){const{client:s,queryClient:n,scope:r,refetchInterval:t}=E(),o=a!=null&&a.period?new Date(a.period):new Date,l=`${o.getUTCFullYear()}-${String(o.getUTCMonth()+1).padStart(2,"0")}`;return ne.useQuery({queryKey:ae.usages(r,l),queryFn:()=>s.getWorkspaceUsages({period:`${l}-01T00:00:00.000Z`}).then(i=>i.quotas),enabled:(a==null?void 0:a.enabled)??!0,refetchInterval:t},n)}function Ka(a,s){const{client:n,queryClient:r,scope:t,refetchInterval:o}=E(),l=n.breakDownWorkspaceUsageByBot,i=n.listBots,c=typeof l=="function"&&typeof i=="function",h=s!=null&&s.period?new Date(s.period):new Date,b=`${h.getUTCFullYear()}-${String(h.getUTCMonth()+1).padStart(2,"0")}`;return ne.useQuery({queryKey:ae.usageByBot(t,a,b),queryFn:async()=>{const[p,y]=await Promise.all([l({id:t,type:a,period:`${b}-01T00:00:00.000Z`}),i({})]),_=new Map(y.bots.map(C=>[C.id,C.name]));return p.data.map(C=>({botId:C.botId,name:_.get(C.botId)??C.botId,value:C.value})).sort((C,v)=>v.value-C.value)},enabled:c&&((s==null?void 0:s.enabled)??!0),refetchInterval:o},r)}function Ya(){const{client:a}=E();return typeof a.breakDownWorkspaceUsageByBot=="function"&&typeof a.listBots=="function"}function ya(){const{client:a,queryClient:s}=E();return ne.useMutation({mutationFn:()=>a.createPaymentMethodIntent({})},s)}function fa(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=E();return ne.useMutation({mutationFn:t=>a.setPaymentMethod(t),onSuccess:async()=>{await s.invalidateQueries({queryKey:ae.paymentMethod(n)}),r({type:"payment-method"})}},s)}function _a(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=E();return ne.useMutation({mutationFn:async t=>{await a.setBillingAddress(t)},onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:ae.billingAddress(n)}),s.invalidateQueries({queryKey:ae.customer(n)})]),r({type:"billing-address"})}},s)}function va(){const{client:a,queryClient:s,scope:n}=E();return ne.useMutation({mutationFn:r=>a.setCustomer(r),onSuccess:()=>s.invalidateQueries({queryKey:ae.customer(n)})},s)}function Ha(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=E();return ne.useMutation({mutationFn:async t=>{await a.setAddons(t)},onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:ae.subscription(n)}),s.invalidateQueries({queryKey:ae.invoices(n)}),s.invalidateQueries({queryKey:["bpb",n,"preview"]})]),r({type:"addons"})}},s)}function ka(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=E();return ne.useMutation({mutationFn:async t=>{await a.setPlan({planId:t.planId,interval:t.interval,couponCode:t.couponCode}),t.addons&&Object.keys(t.addons).length>0&&await a.setAddons({addons:t.addons,couponCode:t.couponCode})},onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:ae.subscription(n)}),s.invalidateQueries({queryKey:ae.plans(n)}),s.invalidateQueries({queryKey:ae.invoices(n)}),s.invalidateQueries({queryKey:["bpb",n,"preview"]})]),r({type:"subscription"})}},s)}function Qa(a){var s,n,r="";if(typeof a=="string"||typeof a=="number")r+=a;else if(typeof a=="object")if(Array.isArray(a)){var t=a.length;for(s=0;s<t;s++)a[s]&&(n=Qa(a[s]))&&(r&&(r+=" "),r+=n)}else for(n in a)a[n]&&(r&&(r+=" "),r+=n);return r}function ln(){for(var a,s,n=0,r="",t=arguments.length;n<t;n++)(a=arguments[n])&&(s=Qa(a))&&(r&&(r+=" "),r+=s);return r}const cn=(a,s)=>{const n=new Array(a.length+s.length);for(let r=0;r<a.length;r++)n[r]=a[r];for(let r=0;r<s.length;r++)n[a.length+r]=s[r];return n},dn=(a,s)=>({classGroupId:a,validator:s}),Za=(a=new Map,s=null,n)=>({nextPart:a,validators:s,classGroupId:n}),je="-",Xa=[],bn="arbitrary..",pn=a=>{const s=hn(a),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=a;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return un(l);const i=l.split(je),c=i[0]===""&&i.length>1?1:0;return Ja(i,c,s)},getConflictingClassGroupIds:(l,i)=>{if(i){const c=r[l],h=n[l];return c?h?cn(h,c):c:h||Xa}return n[l]||Xa}}},Ja=(a,s,n)=>{if(a.length-s===0)return n.classGroupId;const t=a[s],o=n.nextPart.get(t);if(o){const h=Ja(a,s+1,o);if(h)return h}const l=n.validators;if(l===null)return;const i=s===0?a.join(je):a.slice(s).join(je),c=l.length;for(let h=0;h<c;h++){const b=l[h];if(b.validator(i))return b.classGroupId}},un=a=>a.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const s=a.slice(1,-1),n=s.indexOf(":"),r=s.slice(0,n);return r?bn+r:void 0})(),hn=a=>{const{theme:s,classGroups:n}=a;return mn(n,s)},mn=(a,s)=>{const n=Za();for(const r in a){const t=a[r];Na(t,n,r,s)}return n},Na=(a,s,n,r)=>{const t=a.length;for(let o=0;o<t;o++){const l=a[o];gn(l,s,n,r)}},gn=(a,s,n,r)=>{if(typeof a=="string"){yn(a,s,n);return}if(typeof a=="function"){fn(a,s,n,r);return}_n(a,s,n,r)},yn=(a,s,n)=>{const r=a===""?s:Ra(s,a);r.classGroupId=n},fn=(a,s,n,r)=>{if(vn(a)){Na(a(r),s,n,r);return}s.validators===null&&(s.validators=[]),s.validators.push(dn(n,a))},_n=(a,s,n,r)=>{const t=Object.entries(a),o=t.length;for(let l=0;l<o;l++){const[i,c]=t[l];Na(c,Ra(s,i),n,r)}},Ra=(a,s)=>{let n=a;const r=s.split(je),t=r.length;for(let o=0;o<t;o++){const l=r[o];let i=n.nextPart.get(l);i||(i=Za(),n.nextPart.set(l,i)),n=i}return n},vn=a=>"isThemeGetter"in a&&a.isThemeGetter===!0,kn=a=>{if(a<1)return{get:()=>{},set:()=>{}};let s=0,n=Object.create(null),r=Object.create(null);const t=(o,l)=>{n[o]=l,s++,s>a&&(s=0,r=n,n=Object.create(null))};return{get(o){let l=n[o];if(l!==void 0)return l;if((l=r[o])!==void 0)return t(o,l),l},set(o,l){o in n?n[o]=l:t(o,l)}}},wa="!",es=":",Nn=[],as=(a,s,n,r,t)=>({modifiers:a,hasImportantModifier:s,baseClassName:n,maybePostfixModifierPosition:r,isExternal:t}),wn=a=>{const{prefix:s,experimentalParseClassName:n}=a;let r=t=>{const o=[];let l=0,i=0,c=0,h;const b=t.length;for(let v=0;v<b;v++){const m=t[v];if(l===0&&i===0){if(m===es){o.push(t.slice(c,v)),c=v+1;continue}if(m==="/"){h=v;continue}}m==="["?l++:m==="]"?l--:m==="("?i++:m===")"&&i--}const p=o.length===0?t:t.slice(c);let y=p,_=!1;p.endsWith(wa)?(y=p.slice(0,-1),_=!0):p.startsWith(wa)&&(y=p.slice(1),_=!0);const C=h&&h>c?h-c:void 0;return as(o,_,y,C)};if(s){const t=s+es,o=r;r=l=>l.startsWith(t)?o(l.slice(t.length)):as(Nn,!1,l,void 0,!0)}if(n){const t=r;r=o=>n({className:o,parseClassName:t})}return r},Cn=a=>{const s=new Map;return a.orderSensitiveModifiers.forEach((n,r)=>{s.set(n,1e6+r)}),n=>{const r=[];let t=[];for(let o=0;o<n.length;o++){const l=n[o],i=l[0]==="[",c=s.has(l);i||c?(t.length>0&&(t.sort(),r.push(...t),t=[]),r.push(l)):t.push(l)}return t.length>0&&(t.sort(),r.push(...t)),r}},Sn=a=>({cache:kn(a.cacheSize),parseClassName:wn(a),sortModifiers:Cn(a),postfixLookupClassGroupIds:In(a),...pn(a)}),In=a=>{const s=Object.create(null),n=a.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)s[n[r]]=!0;return s},xn=/\s+/,An=(a,s)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:t,sortModifiers:o,postfixLookupClassGroupIds:l}=s,i=[],c=a.trim().split(xn);let h="";for(let b=c.length-1;b>=0;b-=1){const p=c[b],{isExternal:y,modifiers:_,hasImportantModifier:C,baseClassName:v,maybePostfixModifierPosition:m}=n(p);if(y){h=p+(h.length>0?" "+h:h);continue}let S=!!m,I;if(S){const P=v.substring(0,m);I=r(P);const u=I&&l[I]?r(v):void 0;u&&u!==I&&(I=u,S=!1)}else I=r(v);if(!I){if(!S){h=p+(h.length>0?" "+h:h);continue}if(I=r(v),!I){h=p+(h.length>0?" "+h:h);continue}S=!1}const L=_.length===0?"":_.length===1?_[0]:o(_).join(":"),D=C?L+wa:L,f=D+I;if(i.indexOf(f)>-1)continue;i.push(f);const A=t(I,S);for(let P=0;P<A.length;++P){const u=A[P];i.push(D+u)}h=p+(h.length>0?" "+h:h)}return h},Mn=(...a)=>{let s=0,n,r,t="";for(;s<a.length;)(n=a[s++])&&(r=ss(n))&&(t&&(t+=" "),t+=r);return t},ss=a=>{if(typeof a=="string")return a;let s,n="";for(let r=0;r<a.length;r++)a[r]&&(s=ss(a[r]))&&(n&&(n+=" "),n+=s);return n},Tn=(a,...s)=>{let n,r,t,o;const l=c=>{const h=s.reduce((b,p)=>p(b),a());return n=Sn(h),r=n.cache.get,t=n.cache.set,o=i,i(c)},i=c=>{const h=r(c);if(h)return h;const b=An(c,n);return t(c,b),b};return o=l,(...c)=>o(Mn(...c))},Bn=[],te=a=>{const s=n=>n[a]||Bn;return s.isThemeGetter=!0,s},ns=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,rs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ln=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Pn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,En=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,zn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Dn=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Un=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ae=a=>Ln.test(a),z=a=>!!a&&!Number.isNaN(Number(a)),ve=a=>!!a&&Number.isInteger(Number(a)),Ca=a=>a.endsWith("%")&&z(a.slice(0,-1)),Ce=a=>Pn.test(a),ts=()=>!0,$n=a=>En.test(a)&&!zn.test(a),Sa=()=>!1,Fn=a=>Dn.test(a),On=a=>Un.test(a),qn=a=>!k(a)&&!N(a),Wn=a=>a.startsWith("@container")&&(a[10]==="/"&&a[11]!==void 0||a[11]==="s"&&a[16]!==void 0&&a.startsWith("-size/",10)||a[11]==="n"&&a[18]!==void 0&&a.startsWith("-normal/",10)),Gn=a=>Me(a,bs,Sa),k=a=>ns.test(a),Te=a=>Me(a,ps,$n),os=a=>Me(a,Xn,z),jn=a=>Me(a,hs,ts),Vn=a=>Me(a,us,Sa),ls=a=>Me(a,is,Sa),Kn=a=>Me(a,ds,On),Ve=a=>Me(a,ms,Fn),N=a=>rs.test(a),qe=a=>Be(a,ps),Yn=a=>Be(a,us),cs=a=>Be(a,is),Hn=a=>Be(a,bs),Qn=a=>Be(a,ds),Ke=a=>Be(a,ms,!0),Zn=a=>Be(a,hs,!0),Me=(a,s,n)=>{const r=ns.exec(a);return r?r[1]?s(r[1]):n(r[2]):!1},Be=(a,s,n=!1)=>{const r=rs.exec(a);return r?r[1]?s(r[1]):n:!1},is=a=>a==="position"||a==="percentage",ds=a=>a==="image"||a==="url",bs=a=>a==="length"||a==="size"||a==="bg-size",ps=a=>a==="length",Xn=a=>a==="number",us=a=>a==="family-name",hs=a=>a==="number"||a==="weight",ms=a=>a==="shadow",Jn=Tn(()=>{const a=te("color"),s=te("font"),n=te("text"),r=te("font-weight"),t=te("tracking"),o=te("leading"),l=te("breakpoint"),i=te("container"),c=te("spacing"),h=te("radius"),b=te("shadow"),p=te("inset-shadow"),y=te("text-shadow"),_=te("drop-shadow"),C=te("blur"),v=te("perspective"),m=te("aspect"),S=te("ease"),I=te("animate"),L=()=>["auto","avoid","all","avoid-page","page","left","right","column"],D=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],f=()=>[...D(),N,k],A=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],u=()=>[N,k,c],B=()=>[Ae,"full","auto",...u()],x=()=>[ve,"none","subgrid",N,k],R=()=>["auto",{span:["full",ve,N,k]},ve,N,k],X=()=>[ve,"auto",N,k],ue=()=>["auto","min","max","fr",N,k],pe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],oe=()=>["start","end","center","stretch","center-safe","end-safe"],U=()=>["auto",...u()],J=()=>[Ae,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...u()],M=()=>[Ae,"screen","full","dvw","lvw","svw","min","max","fit",...u()],le=()=>[Ae,"screen","full","lh","dvh","lvh","svh","min","max","fit",...u()],g=()=>[a,N,k],W=()=>[...D(),cs,ls,{position:[N,k]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],G=()=>["auto","cover","contain",Hn,Gn,{size:[N,k]}],Y=()=>[Ca,qe,Te],V=()=>["","none","full",h,N,k],H=()=>["",z,qe,Te],ke=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],O=()=>[z,Ca,cs,ls],de=()=>["","none",C,N,k],re=()=>["none",z,N,k],fe=()=>["none",z,N,k],ce=()=>[z,N,k],$=()=>[Ae,"full",...u()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ce],breakpoint:[Ce],color:[ts],container:[Ce],"drop-shadow":[Ce],ease:["in","out","in-out"],font:[qn],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ce],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ce],shadow:[Ce],spacing:["px",z],text:[Ce],"text-shadow":[Ce],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ae,k,N,m]}],container:["container"],"container-type":[{"@container":["","normal","size",N,k]}],"container-named":[Wn],columns:[{columns:[z,k,N,i]}],"break-after":[{"break-after":L()}],"break-before":[{"break-before":L()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:f()}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:B()}],"inset-x":[{"inset-x":B()}],"inset-y":[{"inset-y":B()}],start:[{"inset-s":B(),start:B()}],end:[{"inset-e":B(),end:B()}],"inset-bs":[{"inset-bs":B()}],"inset-be":[{"inset-be":B()}],top:[{top:B()}],right:[{right:B()}],bottom:[{bottom:B()}],left:[{left:B()}],visibility:["visible","invisible","collapse"],z:[{z:[ve,"auto",N,k]}],basis:[{basis:[Ae,"full","auto",i,...u()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[z,Ae,"auto","initial","none",k]}],grow:[{grow:["",z,N,k]}],shrink:[{shrink:["",z,N,k]}],order:[{order:[ve,"first","last","none",N,k]}],"grid-cols":[{"grid-cols":x()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":X()}],"col-end":[{"col-end":X()}],"grid-rows":[{"grid-rows":x()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":X()}],"row-end":[{"row-end":X()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ue()}],"auto-rows":[{"auto-rows":ue()}],gap:[{gap:u()}],"gap-x":[{"gap-x":u()}],"gap-y":[{"gap-y":u()}],"justify-content":[{justify:[...pe(),"normal"]}],"justify-items":[{"justify-items":[...oe(),"normal"]}],"justify-self":[{"justify-self":["auto",...oe()]}],"align-content":[{content:["normal",...pe()]}],"align-items":[{items:[...oe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...oe(),{baseline:["","last"]}]}],"place-content":[{"place-content":pe()}],"place-items":[{"place-items":[...oe(),"baseline"]}],"place-self":[{"place-self":["auto",...oe()]}],p:[{p:u()}],px:[{px:u()}],py:[{py:u()}],ps:[{ps:u()}],pe:[{pe:u()}],pbs:[{pbs:u()}],pbe:[{pbe:u()}],pt:[{pt:u()}],pr:[{pr:u()}],pb:[{pb:u()}],pl:[{pl:u()}],m:[{m:U()}],mx:[{mx:U()}],my:[{my:U()}],ms:[{ms:U()}],me:[{me:U()}],mbs:[{mbs:U()}],mbe:[{mbe:U()}],mt:[{mt:U()}],mr:[{mr:U()}],mb:[{mb:U()}],ml:[{ml:U()}],"space-x":[{"space-x":u()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":u()}],"space-y-reverse":["space-y-reverse"],size:[{size:J()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...le()]}],"min-block-size":[{"min-block":["auto",...le()]}],"max-block-size":[{"max-block":["none",...le()]}],w:[{w:[i,"screen",...J()]}],"min-w":[{"min-w":[i,"screen","none",...J()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...J()]}],h:[{h:["screen","lh",...J()]}],"min-h":[{"min-h":["screen","lh","none",...J()]}],"max-h":[{"max-h":["screen","lh",...J()]}],"font-size":[{text:["base",n,qe,Te]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Zn,jn]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ca,k]}],"font-family":[{font:[Yn,Vn,s]}],"font-features":[{"font-features":[k]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[t,N,k]}],"line-clamp":[{"line-clamp":[z,"none",N,os]}],leading:[{leading:[o,...u()]}],"list-image":[{"list-image":["none",N,k]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",N,k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:g()}],"text-color":[{text:g()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ke(),"wavy"]}],"text-decoration-thickness":[{decoration:[z,"from-font","auto",N,Te]}],"text-decoration-color":[{decoration:g()}],"underline-offset":[{"underline-offset":[z,"auto",N,k]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:u()}],"tab-size":[{tab:[ve,N,k]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",N,k]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",N,k]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:G()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ve,N,k],radial:["",N,k],conic:[ve,N,k]},Qn,Kn]}],"bg-color":[{bg:g()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:g()}],"gradient-via":[{via:g()}],"gradient-to":[{to:g()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-bs":[{"border-bs":H()}],"border-w-be":[{"border-be":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":H()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ke(),"hidden","none"]}],"divide-style":[{divide:[...ke(),"hidden","none"]}],"border-color":[{border:g()}],"border-color-x":[{"border-x":g()}],"border-color-y":[{"border-y":g()}],"border-color-s":[{"border-s":g()}],"border-color-e":[{"border-e":g()}],"border-color-bs":[{"border-bs":g()}],"border-color-be":[{"border-be":g()}],"border-color-t":[{"border-t":g()}],"border-color-r":[{"border-r":g()}],"border-color-b":[{"border-b":g()}],"border-color-l":[{"border-l":g()}],"divide-color":[{divide:g()}],"outline-style":[{outline:[...ke(),"none","hidden"]}],"outline-offset":[{"outline-offset":[z,N,k]}],"outline-w":[{outline:["",z,qe,Te]}],"outline-color":[{outline:g()}],shadow:[{shadow:["","none",b,Ke,Ve]}],"shadow-color":[{shadow:g()}],"inset-shadow":[{"inset-shadow":["none",p,Ke,Ve]}],"inset-shadow-color":[{"inset-shadow":g()}],"ring-w":[{ring:H()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:g()}],"ring-offset-w":[{"ring-offset":[z,Te]}],"ring-offset-color":[{"ring-offset":g()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":g()}],"text-shadow":[{"text-shadow":["none",y,Ke,Ve]}],"text-shadow-color":[{"text-shadow":g()}],opacity:[{opacity:[z,N,k]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[z]}],"mask-image-linear-from-pos":[{"mask-linear-from":O()}],"mask-image-linear-to-pos":[{"mask-linear-to":O()}],"mask-image-linear-from-color":[{"mask-linear-from":g()}],"mask-image-linear-to-color":[{"mask-linear-to":g()}],"mask-image-t-from-pos":[{"mask-t-from":O()}],"mask-image-t-to-pos":[{"mask-t-to":O()}],"mask-image-t-from-color":[{"mask-t-from":g()}],"mask-image-t-to-color":[{"mask-t-to":g()}],"mask-image-r-from-pos":[{"mask-r-from":O()}],"mask-image-r-to-pos":[{"mask-r-to":O()}],"mask-image-r-from-color":[{"mask-r-from":g()}],"mask-image-r-to-color":[{"mask-r-to":g()}],"mask-image-b-from-pos":[{"mask-b-from":O()}],"mask-image-b-to-pos":[{"mask-b-to":O()}],"mask-image-b-from-color":[{"mask-b-from":g()}],"mask-image-b-to-color":[{"mask-b-to":g()}],"mask-image-l-from-pos":[{"mask-l-from":O()}],"mask-image-l-to-pos":[{"mask-l-to":O()}],"mask-image-l-from-color":[{"mask-l-from":g()}],"mask-image-l-to-color":[{"mask-l-to":g()}],"mask-image-x-from-pos":[{"mask-x-from":O()}],"mask-image-x-to-pos":[{"mask-x-to":O()}],"mask-image-x-from-color":[{"mask-x-from":g()}],"mask-image-x-to-color":[{"mask-x-to":g()}],"mask-image-y-from-pos":[{"mask-y-from":O()}],"mask-image-y-to-pos":[{"mask-y-to":O()}],"mask-image-y-from-color":[{"mask-y-from":g()}],"mask-image-y-to-color":[{"mask-y-to":g()}],"mask-image-radial":[{"mask-radial":[N,k]}],"mask-image-radial-from-pos":[{"mask-radial-from":O()}],"mask-image-radial-to-pos":[{"mask-radial-to":O()}],"mask-image-radial-from-color":[{"mask-radial-from":g()}],"mask-image-radial-to-color":[{"mask-radial-to":g()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":D()}],"mask-image-conic-pos":[{"mask-conic":[z]}],"mask-image-conic-from-pos":[{"mask-conic-from":O()}],"mask-image-conic-to-pos":[{"mask-conic-to":O()}],"mask-image-conic-from-color":[{"mask-conic-from":g()}],"mask-image-conic-to-color":[{"mask-conic-to":g()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:G()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",N,k]}],filter:[{filter:["","none",N,k]}],blur:[{blur:de()}],brightness:[{brightness:[z,N,k]}],contrast:[{contrast:[z,N,k]}],"drop-shadow":[{"drop-shadow":["","none",_,Ke,Ve]}],"drop-shadow-color":[{"drop-shadow":g()}],grayscale:[{grayscale:["",z,N,k]}],"hue-rotate":[{"hue-rotate":[z,N,k]}],invert:[{invert:["",z,N,k]}],saturate:[{saturate:[z,N,k]}],sepia:[{sepia:["",z,N,k]}],"backdrop-filter":[{"backdrop-filter":["","none",N,k]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[z,N,k]}],"backdrop-contrast":[{"backdrop-contrast":[z,N,k]}],"backdrop-grayscale":[{"backdrop-grayscale":["",z,N,k]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[z,N,k]}],"backdrop-invert":[{"backdrop-invert":["",z,N,k]}],"backdrop-opacity":[{"backdrop-opacity":[z,N,k]}],"backdrop-saturate":[{"backdrop-saturate":[z,N,k]}],"backdrop-sepia":[{"backdrop-sepia":["",z,N,k]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":u()}],"border-spacing-x":[{"border-spacing-x":u()}],"border-spacing-y":[{"border-spacing-y":u()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",N,k]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[z,"initial",N,k]}],ease:[{ease:["linear","initial",S,N,k]}],delay:[{delay:[z,N,k]}],animate:[{animate:["none",I,N,k]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,N,k]}],"perspective-origin":[{"perspective-origin":f()}],rotate:[{rotate:re()}],"rotate-x":[{"rotate-x":re()}],"rotate-y":[{"rotate-y":re()}],"rotate-z":[{"rotate-z":re()}],scale:[{scale:fe()}],"scale-x":[{"scale-x":fe()}],"scale-y":[{"scale-y":fe()}],"scale-z":[{"scale-z":fe()}],"scale-3d":["scale-3d"],skew:[{skew:ce()}],"skew-x":[{"skew-x":ce()}],"skew-y":[{"skew-y":ce()}],transform:[{transform:[N,k,"","none","gpu","cpu"]}],"transform-origin":[{origin:f()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:$()}],"translate-x":[{"translate-x":$()}],"translate-y":[{"translate-y":$()}],"translate-z":[{"translate-z":$()}],"translate-none":["translate-none"],zoom:[{zoom:[ve,N,k]}],accent:[{accent:g()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:g()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",N,k]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":g()}],"scrollbar-track-color":[{"scrollbar-track":g()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":u()}],"scroll-mx":[{"scroll-mx":u()}],"scroll-my":[{"scroll-my":u()}],"scroll-ms":[{"scroll-ms":u()}],"scroll-me":[{"scroll-me":u()}],"scroll-mbs":[{"scroll-mbs":u()}],"scroll-mbe":[{"scroll-mbe":u()}],"scroll-mt":[{"scroll-mt":u()}],"scroll-mr":[{"scroll-mr":u()}],"scroll-mb":[{"scroll-mb":u()}],"scroll-ml":[{"scroll-ml":u()}],"scroll-p":[{"scroll-p":u()}],"scroll-px":[{"scroll-px":u()}],"scroll-py":[{"scroll-py":u()}],"scroll-ps":[{"scroll-ps":u()}],"scroll-pe":[{"scroll-pe":u()}],"scroll-pbs":[{"scroll-pbs":u()}],"scroll-pbe":[{"scroll-pbe":u()}],"scroll-pt":[{"scroll-pt":u()}],"scroll-pr":[{"scroll-pr":u()}],"scroll-pb":[{"scroll-pb":u()}],"scroll-pl":[{"scroll-pl":u()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",N,k]}],fill:[{fill:["none",...g()]}],"stroke-w":[{stroke:[z,qe,Te,os]}],stroke:[{stroke:["none",...g()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function T(...a){return Jn(ln(a))}function j(a,s="usd",n=2){return new Intl.NumberFormat("en-US",{style:"currency",currency:s.toUpperCase(),minimumFractionDigits:n,maximumFractionDigits:n}).format(a)}function Se(a,s="en-US"){return new Date(a).toLocaleDateString(s,{month:"short",day:"numeric",year:"numeric"})}function gs(a,s){const n=new Date(a);return n.setDate(n.getDate()+s),n.toISOString()}function se(a){return new Intl.NumberFormat("en-US").format(a)}function Le(a){if(a<=0)return"0 MB";const s=a/1e9;if(s>=1)return`${Number.isInteger(s)?s:s.toFixed(1)} GB`;const n=a/1e6;return`${Number.isInteger(n)?n:n.toFixed(0)} MB`}function ee(a){return a.replace("Plan - ","")}function ys(a){return{usd:"$",eur:"€",gbp:"£",cad:"$",aud:"$",jpy:"¥"}[a.toLowerCase()]??`${a.toUpperCase()} `}const We=["community","plus","team","enterprise","managed"],Rn=["community","plus","team","enterprise","managed"];function ge(a){var r;const s=a.name.toLowerCase();if(s.includes("community")||s.includes("pay-as-you-go")||s.includes("free"))return"community";if(s.includes("plus"))return"plus";if(s.includes("team"))return"team";if(s.includes("managed"))return"managed";if(s.includes("enterprise"))return"enterprise";const n=(r=a.metadata)==null?void 0:r.legacyName;return Rn.find(t=>t===n)??"community"}const fs="https://botpress.com/contact-us/managed-plan",Ia={community:["AI usage included","3 seats","3 AI agents","Botpress Desk","Botpress Studio + ADK","Help center","1K table rows","100MB file storage","100MB vector DB storage","Community support"],plus:["3 seats","Unlimited AI agents","WhatsApp channel","Help Center custom domain","Whitelabel webchat","100K table rows","10GB file storage","1GB vector DB storage","Technical support via live chat"],team:["Unlimited seats","Teams, routing & RBAC","Team-level analytics","500K table rows","50GB file storage","5GB vector DB storage"],enterprise:["Voice channel","Dedicated support","SLA & security review","Custom storage"],managed:[]},xa={"AI usage included":"A monthly allowance of AI model spend is bundled into every plan — no separate AI bill.","3 seats":"Up to 3 team members can collaborate in this workspace.","Unlimited seats":"Invite as many team members to the workspace as you need.","3 AI agents":"Build and publish up to 3 distinct AI agents.","Unlimited AI agents":"Build and publish as many AI agents as you need.","Botpress Desk":"The human-handoff inbox where agents triage and reply to live conversations.","Botpress Studio + ADK":"The visual Studio builder plus the Agent Development Kit for building agents in code.","Help center":"A hosted knowledge base your agent answers from and customers can browse.","Help Center custom domain":"Serve your help center from your own domain instead of a Botpress URL.","WhatsApp channel":"Connect your agent to WhatsApp to chat with customers there.","Voice channel":"Connect your agent to phone/voice so it can handle spoken conversations.","Whitelabel webchat":"Remove Botpress branding from the web chat widget so it’s fully your own.","Teams, routing & RBAC":"Organize members into teams, route conversations between them, and control access by role.","Team-level analytics":"Performance and volume metrics broken down per team.","Technical support via live chat":"Reach the Botpress support team over live chat for help.","Community support":"Get help from the Botpress community forum and Discord.","Dedicated support":"A named contact and priority support channel for your account.","SLA & security review":"A contractual uptime SLA and a security/compliance review for your procurement.","Custom storage":"Storage limits tailored to your workload, beyond the standard tiers."},er=[{test:/table rows/i,describe:a=>`${a.replace(/ table rows/i,"")} rows across all your data tables.`},{test:/file storage/i,describe:a=>`${a.replace(/ file storage/i,"")} of uploaded files (documents, images, attachments).`},{test:/vector db storage/i,describe:a=>`${a.replace(/ vector db storage/i,"")} of embeddings for knowledge-base search and retrieval.`}];function _s(a,s){var n;return s!=null&&s[a]?s[a]:xa[a]?xa[a]:(n=er.find(r=>r.test.test(a)))==null?void 0:n.describe(a)}function Ye(a,s,n){return a.prices[s.id]??a.prices[ge(s)]??a.prices[n]??null}function Ge(a){return a.replace("Add-on - ","")}function vs(a){return(a==null?void 0:a.find(s=>{var n;return(((n=s.increments)==null?void 0:n.conversation_sessions)??0)>0}))??null}const ks=[{key:"conversation_sessions",label:"Conversations / month",unit:"count"},{key:"table_rows",label:"Table rows",unit:"count"},{key:"vector_db_storage",label:"Vector DB storage",unit:"bytes"},{key:"file_storage",label:"File storage",unit:"bytes"}];function Ns(a,s,n){var t;if(!s)return[];const r=[];for(const o of ks){const l=a.features[o.key]??0;let i=0;for(const c of s){const h=((t=c.increments)==null?void 0:t[o.key])??0,b=n[c.id]??0;i+=h*b}i>0&&r.push({...o,now:l,next:l+i})}return r}function ws(a,s,n){var t;if(!a)return[];const r=[];for(const o of ks){const l=a.features[o.key]??0;let i=0;for(const c of s??[])i+=(((t=c.increments)==null?void 0:t[o.key])??0)*(n[c.id]??0);(l>0||i>0)&&r.push({...o,base:l,added:i,total:l+i})}return r}function Aa(a,s,n){var l;const r=vs(a);if(!r)return null;const t=((l=r.increments)==null?void 0:l.conversation_sessions)??0,o=Ye(r,s,n);return t<=0||!o||o.amount<=0?null:{packSize:t,amount:o.amount,currency:o.currency}}const Ma=({variant:a="accent",children:s,className:n})=>e.jsx("span",{className:T("bpb-badge",`bpb-badge--${a}`,n),children:s}),ie=({variant:a="primary",size:s="md",block:n=!1,loading:r=!1,className:t,disabled:o,children:l,type:i="button",...c})=>e.jsxs("button",{type:i,className:T("bpb-btn",`bpb-btn--${a}`,`bpb-btn--${s}`,n&&"bpb-btn--block",t),disabled:o||r,"data-loading":r||void 0,...c,children:[r&&e.jsx("span",{className:"bpb-btn__spinner","aria-hidden":!0}),e.jsx("span",{className:"bpb-btn__label",children:l})]}),Q=(a,s)=>({width:a??16,height:a??16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,...s}),Cs=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M3 8.5l3.5 3.5L13 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ta=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M8 1.5l1.4 3.6a1 1 0 00.6.6L13.5 7l-3.5 1.4a1 1 0 00-.6.6L8 12.5 6.6 9a1 1 0 00-.6-.6L2.5 7 6 5.7a1 1 0 00.6-.6L8 1.5z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M12.8 11l.5 1.2 1.2.5-1.2.5-.5 1.3-.5-1.3-1.2-.5 1.2-.5.5-1.2z",fill:"currentColor"})]}),Ss=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M2.5 8a5.5 5.5 0 115.5 5.5c-.9 0-1.8-.2-2.5-.6L2.5 13.5l.6-3A5.5 5.5 0 012.5 8z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})}),Ba=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M8 1.8l5 1.8v4c0 3.2-2.1 5.4-5 6.6-2.9-1.2-5-3.4-5-6.6v-4l5-1.8z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M5.8 8l1.6 1.6 2.8-3",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),Is=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M6 2.5h3v1.6a1.4 1.4 0 102.8 0V2.5h1.7v3h-1.6a1.4 1.4 0 100 2.8h1.6v3h-3v1.6a1.4 1.4 0 11-2.8 0v-1.6h-3v-3h1.6a1.4 1.4 0 100-2.8H2.5v-3H6z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})}),He=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M8 2l6 3-6 3-6-3 6-3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M2 8l6 3 6-3M2 11l6 3 6-3",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})]}),xs=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M8 8c-1.2-1.6-2-2.4-3.3-2.4a2.4 2.4 0 100 4.8C6 10.4 6.8 9.6 8 8zm0 0c1.2 1.6 2 2.4 3.3 2.4a2.4 2.4 0 100-4.8C10 5.6 9.2 6.4 8 8z",stroke:"currentColor",strokeWidth:"1.3"})}),Qe=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M8.5 1.5L3 9h4l-.5 5.5L12 7H8l.5-5.5z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})}),As=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("circle",{cx:"6",cy:"5.5",r:"2.2",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M2 13c0-2.2 1.8-3.6 4-3.6s4 1.4 4 3.6",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),e.jsx("path",{d:"M10.5 3.6a2.2 2.2 0 010 4.1M11 9.6c1.7.3 3 1.6 3 3.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),Ms=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M2.5 2.5v11h11",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M5 10l2.2-2.4 2 1.6L12.5 5.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),Ts=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M2 8h12M8 2c1.8 1.6 2.8 3.8 2.8 6S9.8 12.4 8 14C6.2 12.4 5.2 10.2 5.2 8S6.2 3.6 8 2z",stroke:"currentColor",strokeWidth:"1.3"})]}),Bs=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M2.5 11.5L9 5l2 2-6.5 6.5H2.5v-2z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M9 5l1.8-1.8a1.4 1.4 0 012 2L11 7",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})]}),La=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("rect",{x:"1.8",y:"3.5",width:"12.4",height:"9",rx:"1.6",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M1.8 6.4h12.4",stroke:"currentColor",strokeWidth:"1.3"})]}),ar=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M2 6l6-3.5L14 6v1H2V6zM3 7v5M6.3 7v5M9.7 7v5M13 7v5M2 12.5h12",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})}),sr=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1.4",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M5.5 7V5.5a2.5 2.5 0 015 0V7",stroke:"currentColor",strokeWidth:"1.3"})]}),Ze=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Xe=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M4 6.5L8 10.5l4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ls=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),$e=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M6 3.5L10.5 8L6 12.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ps=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Es=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M8 3.5v9M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),nr=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M8 2.2L14.5 13.2a.7.7 0 01-.6 1H2.1a.7.7 0 01-.6-1L8 2.2z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 6.3v3.1",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("circle",{cx:"8",cy:"11.6",r:"0.85",fill:"currentColor"})]}),Je=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M9 3.5h3.5V7M12 4L7 9M11 9.5v2a1 1 0 01-1 1H4.5a1 1 0 01-1-1V6a1 1 0 011-1h2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}),Pa=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M8 2.5v7M5 7l3 3 3-3M3 12.5h10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}),rr=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M4 2h8v12l-1.5-1-1.5 1-1.5-1-1.5 1L4 14V2z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.2 5.5h3.6M6.2 8h3.6",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),zs=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("rect",{x:"2.5",y:"3.5",width:"11",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M2.5 6.5h11M5.5 2v2.5M10.5 2v2.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),Re=({brand:a})=>{const s=a==="visa"?"VISA":a==="mastercard"?"MC":a==="amex"?"AMEX":a==="discover"?"DISC":a.slice(0,4).toUpperCase(),n=a==="visa"?"#1a1f71":a==="mastercard"?"#252525":a==="amex"?"#016fd0":"#5d5d5d";return e.jsx("span",{"aria-hidden":!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:34,height:22,padding:"0 4px",borderRadius:4,background:n,color:"#fff",fontSize:9,fontWeight:700,letterSpacing:"0.04em"},children:s})};function Ea(a){const s=a.toLowerCase();return/seat|member|user|team|rbac|rout/.test(s)?As:/analytic|report|insight|dashboard/.test(s)?Ms:/whatsapp|channel|chat|message|conversation|webchat|voice/.test(s)?Ss:/storage|table|vector|file|gb|rows|db/.test(s)?He:/domain|help center|whitelabel|website|url|web/.test(s)?Ts:/brand|theme|custom|white-?label/.test(s)?Bs:/unlimited|infinit/.test(s)?xs:/security|sla|compliance|soc|audit/.test(s)||/support|sla|dedicated|priority/.test(s)?Ba:/integration|api|plugin|sdk|adk|studio/.test(s)?Is:/ai|agent|model|gpt|llm/.test(s)?Qe:Ta}const ye=({open:a,onOpenChange:s,size:n="md",children:r,className:t,showClose:o=!0,...l})=>{const i=w.useRef(null),c=on(),h=w.useCallback(()=>s(!1),[s]);return w.useEffect(()=>{var y;if(!a)return;const b=_=>{_.key==="Escape"&&h()};document.addEventListener("keydown",b);const p=document.body.style.overflow;return document.body.style.overflow="hidden",(y=i.current)==null||y.focus(),()=>{document.removeEventListener("keydown",b),document.body.style.overflow=p}},[a,h]),a?nn.createPortal(e.jsx("div",{className:"bpb-portal bpb-dialog__overlay","data-bpb-theme":c?"dark":"light",onClick:h,children:e.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":l["aria-label"],tabIndex:-1,className:T("bpb-dialog",`bpb-dialog--${n}`,t),onClick:b=>b.stopPropagation(),children:[o&&e.jsx("button",{type:"button",className:"bpb-dialog__close","aria-label":"Close",onClick:h,children:e.jsx(Ze,{size:18})}),r]})}),document.body):null},ea=({label:a,children:s})=>e.jsxs("span",{className:"bpb-tooltip",tabIndex:0,role:"note",children:[e.jsx("span",{className:"bpb-tooltip__term",children:a}),e.jsx("span",{className:"bpb-tooltip__bubble",role:"tooltip",children:s})]}),Pe=()=>{const{manageBillingUrl:a}=E();return e.jsxs("div",{className:"bpb-outdated",children:[e.jsx("h3",{className:"bpb-outdated__title",children:"Billing is managed in the Botpress Dashboard"}),e.jsx("p",{className:"bpb-outdated__text",children:"This workspace is on an earlier billing system, so plan changes and payment details can’t be managed here."}),a&&e.jsxs(ie,{variant:"primary",onClick:()=>window.open(a,"_blank","noopener"),children:["Open billing in Dashboard",e.jsx(Je,{size:15})]})]})},Ds=({options:a,value:s,onChange:n,className:r,...t})=>e.jsx("div",{role:"radiogroup","aria-label":t["aria-label"],className:T("bpb-segmented",r),children:a.map(o=>{const l=o.value===s;return e.jsxs("button",{type:"button",role:"radio","aria-checked":l,className:T("bpb-segmented__option",l&&"bpb-segmented__option--selected"),onClick:()=>n(o.value),children:[o.label,o.badge&&e.jsx("span",{className:"bpb-segmented__badge",children:o.badge})]},o.value)})}),q=({width:a,height:s=14,rounded:n=!1,className:r})=>e.jsx("span",{"aria-hidden":!0,className:T("bpb-skeleton",n&&"bpb-skeleton--rounded",r),style:{width:a??"100%",height:s}});function tr(a,s){const n=a.prices[s];return n||((s==="month"?a.prices.year:a.prices.month)??null)}function or(a,s){var t,o;const n=(t=a.prices.month)==null?void 0:t.amount;if(s==="month")return n??null;const r=((o=a.prices.year)==null?void 0:o.amount)??(n===void 0?void 0:n*12);return r===void 0?null:r/12}function lr(a){var n,r;let s=0;for(const t of a){const o=(n=t.prices.month)==null?void 0:n.amount,l=(r=t.prices.year)==null?void 0:r.amount;o&&l&&o>0&&(s=Math.max(s,1-l/(o*12)))}return Math.round(s*100)}const Us=({open:a,onOpenChange:s,onSelectPlan:n,recommendedPlanId:r="team",defaultInterval:t="year",excludePlanIds:o=[],planFeatures:l={},featureDescriptions:i})=>{var oe,U,J;const{isOutdatedBilling:c,toast:h,analytics:b}=E(),[p,y]=w.useState(t),{data:_,isLoading:C}=we(),{data:v}=De(),{data:m}=_e({enabled:a}),{data:S}=ga({enabled:a}),I=ka(),L=(S==null?void 0:S.planReadonly)??!1,D=m==null?void 0:m.plan.current.interval,f=_==null?void 0:_.find(M=>M.id===(m==null?void 0:m.plan.current.planId)),A=m?f?ge(f):"community":void 0,P=((oe=m==null?void 0:m.plan.next)==null?void 0:oe.planId)??null,u=!!P&&P!==(m==null?void 0:m.plan.current.planId),B=L||A==="enterprise"||A==="managed",x=w.useMemo(()=>_?_.filter(M=>ge(M)!=="managed"&&ge(M)!=="enterprise"&&!o.includes(M.id)).sort((M,le)=>We.indexOf(ge(M))-We.indexOf(ge(le))):[],[_,o]),R=w.useMemo(()=>lr(x),[x]),X=((J=(U=_==null?void 0:_.find(M=>ge(M)==="enterprise"))==null?void 0:U.metadata)==null?void 0:J.contact_url)??fs,ue=M=>{I.mutate({planId:M.id,interval:p},{onSuccess:()=>{var le;(le=b.trackPlanDowngraded)==null||le.call(b,{plan_name:ee(M.name),interval:p,previous_plan_name:f?ee(f.name):void 0}),h({type:"success",message:"Plan downgraded"})},onError:()=>h({type:"error",message:"Downgrade failed"})})},pe=()=>{m&&I.mutate({planId:m.plan.current.planId,interval:m.plan.current.interval},{onSuccess:()=>{var M;(M=b.trackPlanDowngradeCancelled)==null||M.call(b,{plan_name:f?ee(f.name):m.plan.current.planId}),h({type:"success",message:"Scheduled downgrade canceled"})},onError:()=>h({type:"error",message:"Could not cancel the downgrade"})})};return c?e.jsx(ye,{open:a,onOpenChange:s,size:"md","aria-label":"Upgrade your plan",className:"bpb-scope",children:e.jsx(Pe,{})}):e.jsx(ye,{open:a,onOpenChange:s,size:"xl","aria-label":"Upgrade your plan",className:"bpb-scope",children:e.jsxs("div",{className:"bpb-upgrade",children:[e.jsx("h2",{className:"bpb-upgrade__title",children:"Upgrade your plan"}),e.jsx("div",{className:"bpb-upgrade__toggle",children:e.jsx(Ds,{"aria-label":"Billing interval",value:p,onChange:y,options:[{value:"month",label:"Monthly"},{value:"year",label:"Annual",badge:R>0?`Save ${R}%`:void 0}]})}),e.jsxs("div",{className:"bpb-upgrade__grid",children:[C&&[0,1,2].map(M=>e.jsxs("div",{className:"bpb-plan-card","aria-hidden":!0,children:[e.jsx(q,{width:120,height:22}),e.jsx(q,{width:90,height:40}),e.jsx(q,{width:"100%",height:36,rounded:!0}),e.jsx(q,{width:"100%",height:140})]},M)),x.map((M,le)=>{var be,K;const g=ge(M),W=tr(M,p),F=or(M,p),G=(((be=M.prices.month)==null?void 0:be.amount)??0)<=0,Y=g===A&&(A==="community"||p===D),V=g===A&&A!=="community"&&p!==D,H=!!P&&M.id===P&&!Y,ke=A!==void 0&&We.indexOf(g)<We.indexOf(A),he=(g===r||M.id===r)&&!Y,O=Y&&u?"cancel_downgrade":Y?"current":V?"switch_interval":H?"next":ke?"downgrade":"upgrade",de=le>0?x[le-1]:void 0,re=l[g]??Ia[g],fe=M.features.conversation_sessions,ce=Aa(v,M,p),$=I.isPending&&(O==="downgrade"&&((K=I.variables)==null?void 0:K.planId)===M.id||O==="cancel_downgrade");return e.jsxs("div",{className:T("bpb-plan-card",he&&"bpb-plan-card--highlighted"),"data-plan-id":M.id,children:[e.jsxs("div",{className:"bpb-plan-card__header",children:[e.jsxs("h3",{className:"bpb-plan-card__name",children:[ee(M.name),he&&e.jsx(Ma,{className:"bpb-plan-card__badge",children:"Recommended"})]}),e.jsx("p",{className:"bpb-plan-card__tagline",children:M.description}),e.jsx("div",{className:"bpb-plan-card__price",children:F!==null&&W?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bpb-plan-card__currency",children:ys(W.currency)}),e.jsx("span",{className:"bpb-plan-card__amount",children:Number.isInteger(F)?F:F.toFixed(2).replace(/\.00$/,"")}),e.jsxs("span",{className:"bpb-plan-card__per",children:["/ month (",W.currency.toUpperCase(),")"]})]}):e.jsx("span",{className:"bpb-plan-card__amount",children:j(0,"usd",0)})})]}),fe!==void 0&&e.jsxs("div",{className:"bpb-plan-card__allowance",children:[e.jsxs("div",{className:"bpb-plan-card__metric",children:[e.jsx("span",{className:"bpb-plan-card__metric-value",children:se(fe)}),e.jsxs("span",{className:"bpb-plan-card__metric-unit",children:["conversations",G?"":" / month"]})]}),ce?e.jsxs("p",{className:"bpb-plan-card__pack",children:["then ",j(ce.amount,ce.currency,0)," per"," ",se(ce.packSize)," more"]}):e.jsx("p",{className:"bpb-plan-card__pack",children:"No top-up"})]}),O==="current"&&e.jsx(ie,{variant:"outline",block:!0,disabled:!0,children:"Your current plan"}),O==="next"&&e.jsx(ie,{variant:"outline",block:!0,disabled:!0,children:"Next plan"}),O==="cancel_downgrade"&&e.jsx(ie,{variant:"primary",block:!0,loading:$,onClick:pe,children:"Cancel downgrade"}),O==="downgrade"&&e.jsx(ie,{variant:"outline",block:!0,disabled:B||I.isPending,loading:$,onClick:()=>ue(M),children:"Downgrade"}),O==="switch_interval"&&e.jsx(ie,{variant:"primary",block:!0,disabled:B||I.isPending,title:B?"Your plan is managed by Botpress — contact us to change it":void 0,onClick:()=>{var Z;(Z=b.trackPlanUpgradeInitiated)==null||Z.call(b,{plan_name:ee(M.name),interval:p,current_plan_name:f?ee(f.name):void 0}),n(M.id,p)},children:p==="year"?"Switch to annual":"Switch to monthly"}),O==="upgrade"&&e.jsx(ie,{variant:he?"accent":"primary",block:!0,disabled:B||I.isPending,title:B?"Your plan is managed by Botpress — contact us to change it":void 0,onClick:()=>{var Z;(Z=b.trackPlanUpgradeInitiated)==null||Z.call(b,{plan_name:ee(M.name),interval:p,current_plan_name:f?ee(f.name):void 0}),n(M.id,p)},children:"Upgrade"}),e.jsxs("ul",{className:"bpb-plan-card__features",children:[de&&e.jsxs("li",{className:"bpb-plan-card__features-lead",children:[e.jsx("span",{className:"bpb-plan-card__feature-chip bpb-plan-card__feature-chip--lead",children:e.jsx(Cs,{size:13})}),e.jsxs("span",{children:["Everything in ",ee(de.name)]})]}),re.map(Z=>{const Ne=Ea(Z),Ie=_s(Z,i);return e.jsxs("li",{children:[e.jsx("span",{className:"bpb-plan-card__feature-chip",children:e.jsx(Ne,{size:13})}),Ie?e.jsx(ea,{label:Z,children:Ie}):e.jsx("span",{children:Z})]},Z)})]})]},M.id)})]}),e.jsxs("p",{className:"bpb-upgrade__footer",children:["Need more, or running at scale?"," ",e.jsx("a",{href:X,target:"_blank",rel:"noopener noreferrer",children:"Contact us"})," ","about Enterprise. Compare plans at"," ",e.jsx("a",{href:"https://botpress.com/pricing",target:"_blank",rel:"noopener noreferrer",children:"botpress.com/pricing"}),"."]})]})})},za='-apple-system, "ui-sans-serif", "system-ui", "Segoe UI", Helvetica, Arial, sans-serif',Da="14px",$s="10px";function Ua(a){return a?{theme:"night",variables:{fontFamily:za,fontSizeBase:Da,borderRadius:$s,colorPrimary:"#ececec",colorBackground:"#1c1c1c",colorText:"#f9f9f9",colorTextSecondary:"#b4b4b4",colorTextPlaceholder:"#9b9b9b",colorDanger:"#ff8583"},rules:{".Input":{backgroundColor:"#212121",border:"1px solid rgba(255,255,255,0.12)",boxShadow:"none",color:"#f9f9f9"},".Input:focus":{border:"1px solid rgba(255,255,255,0.3)",boxShadow:"none"},".Label":{color:"#ececec",fontWeight:"500",fontSize:"12px"},".Error":{color:"#ff8583"},".Tab":{border:"1px solid rgba(255,255,255,0.12)",boxShadow:"none"}}}:{theme:"stripe",variables:{fontFamily:za,fontSizeBase:Da,borderRadius:$s,colorPrimary:"#0d0d0d",colorBackground:"#f7f7f7",colorText:"#0d0d0d",colorTextSecondary:"#5d5d5d",colorTextPlaceholder:"#8f8f8f",colorDanger:"#e02e2a"},rules:{".Input":{backgroundColor:"#f7f7f7",border:"1px solid transparent",boxShadow:"none",color:"#0d0d0d"},".Input:focus":{backgroundColor:"#fff",border:"1px solid #0d0d0d",boxShadow:"none"},".Label":{color:"#5d5d5d",fontWeight:"500",fontSize:"12px"},".Error":{color:"#e02e2a"},".Tab":{border:"1px solid #0d0d0d1a",boxShadow:"none",backgroundColor:"#f7f7f7"},".Tab--selected":{border:"1px solid #0d0d0d",backgroundColor:"#fff"},".Block":{backgroundColor:"#f9f9f9",boxShadow:"none"}}}}function $a(a){return{base:{fontFamily:za,fontSize:Da,color:a?"#f9f9f9":"#0d0d0d","::placeholder":{color:a?"#9b9b9b":"#8f8f8f"}},invalid:{color:a?"#ff8583":"#e02e2a"}}}const cr={pt:"pt-BR",es:"es-419"};function Fa(a){const s=a.split("-")[0]??a;return cr[s]??a}const ir=4,dr=({plan:a,interval:s,preview:n,isLoadingPreview:r,isPreviewError:t,canSubscribe:o,isSubmitting:l,onSubscribe:i})=>{var R,X,ue,pe,oe;const{locale:c}=E(),{data:h}=De(),b=((R=a==null?void 0:a.prices.month)==null?void 0:R.currency)??((X=a==null?void 0:a.prices.year)==null?void 0:X.currency)??"usd",p=a==null?void 0:a.features.conversation_sessions,y=a?Aa(h,a,s):null,_=(n==null?void 0:n.costs.immediate.amountDue)??0,C=(n==null?void 0:n.costs.immediate.accountBalance)??0,v=(n==null?void 0:n.costs.nextCycle.total)??0,m=n!=null&&n.nextBillingDate?Se(gs(n.nextBillingDate,1),c):null,S=a?Ia[ge(a)].slice(0,ir):[],I=a?((ue=a.prices[s])==null?void 0:ue.amount)??0:0,L=(n==null?void 0:n.costs.immediate.lineItems)??[],D=L.filter(U=>U.type==="discount"),f=L.filter(U=>U.type==="proration_credit"||U.type==="proration_charge").reduce((U,J)=>U+J.amount,0),A=!!(n!=null&&n.subscription.plan.effectiveDate),P=((pe=a==null?void 0:a.prices.month)==null?void 0:pe.amount)??0,u=((oe=a==null?void 0:a.prices.year)==null?void 0:oe.amount)??0,B=s==="year"&&P>0&&u>0?Math.round(P*12-u):0,x=Math.round(B/12);return e.jsxs("div",{className:"bpb-summary-wrap",children:[e.jsxs("div",{className:"bpb-summary",children:[e.jsx("h3",{className:"bpb-summary__title",children:a?`${ee(a.name)} plan`:e.jsx(q,{width:140,height:24})}),p!==void 0&&e.jsxs("div",{className:"bpb-summary__metric",children:[e.jsx("span",{className:"bpb-summary__metric-value",children:se(p)}),e.jsx("span",{className:"bpb-summary__metric-unit",children:"conversations / month"}),y&&e.jsxs("span",{className:"bpb-summary__metric-pack",children:["then ",j(y.amount,y.currency,0)," per ",se(y.packSize)]})]}),S.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"bpb-summary__features-label",children:"Top features"}),e.jsx("ul",{className:"bpb-summary__features",children:S.map(U=>{const J=Ea(U);return e.jsxs("li",{children:[e.jsx(J,{size:16,className:"bpb-summary__feature-icon"}),e.jsx("span",{children:U})]},U)})})]}),e.jsx("hr",{className:"bpb-summary__divider"}),r&&e.jsxs("div",{className:"bpb-summary__lines","aria-busy":"true",children:[e.jsx(q,{height:16}),e.jsx(q,{height:16}),e.jsx(q,{height:20})]}),t&&e.jsx("p",{role:"alert",className:"bpb-summary__error",children:"We couldn’t compute your total. Try again in a moment."}),n&&!r&&A&&e.jsxs("div",{className:"bpb-summary__lines",children:[e.jsxs("div",{className:"bpb-summary__line",children:[e.jsxs("span",{className:"bpb-summary__line-label",children:[a?ee(a.name):""," plan",m?` — from ${m}`:""]}),e.jsxs("span",{className:"bpb-summary__line-amount",children:[j(v,b),s==="year"?"/yr":"/mo"]})]}),e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:e.jsx(ea,{label:"Prorated for today",children:"Switching mid-period, we charge only for the time left in your current billing period. The full plan price above is billed at your next renewal, not today."})}),e.jsx("span",{className:"bpb-summary__line-amount",children:j(_,b)})]}),e.jsxs("div",{className:"bpb-summary__line bpb-summary__line--total",children:[e.jsx("span",{children:"Due today"}),e.jsx("span",{children:j(_,b)})]}),f<0&&e.jsxs("p",{className:"bpb-summary__addon-note",children:["You have ",j(Math.abs(f),b)," of unused time credited toward your next invoice."]})]}),n&&!r&&!A&&e.jsxs("div",{className:"bpb-summary__lines",children:[e.jsxs("div",{className:"bpb-summary__line",children:[e.jsxs("span",{className:"bpb-summary__line-label",children:[a?ee(a.name):""," plan (",s==="year"?"annual":"monthly",")"]}),e.jsxs("span",{className:"bpb-summary__line-amount",children:[j(I,b),s==="year"?"/yr":"/mo"]})]}),D.map((U,J)=>e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:U.description}),e.jsx("span",{className:"bpb-summary__line-amount",children:j(U.amount,b)})]},`${U.id}-${J}`)),f!==0&&e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:e.jsx(ea,{label:f<0?"Credit for unused time":"Adjustment for unused time",children:f<0?"You already paid for time left in your current billing period. We credit that unused time and re-apply it at your new rate, so you’re never double-charged.":"Switching mid-cycle means we prorate the difference between your old and new plan for the days remaining in your current billing period."})}),e.jsx("span",{className:"bpb-summary__line-amount",children:j(f,b)})]}),C!==0&&e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:"Account credit"}),e.jsx("span",{className:"bpb-summary__line-amount",children:j(C,b)})]}),e.jsxs("div",{className:"bpb-summary__line bpb-summary__line--total",children:[e.jsx("span",{children:"Due today"}),e.jsx("span",{children:j(_,b)})]}),f<0&&_===0&&e.jsxs("p",{className:"bpb-summary__addon-note",children:["Your remaining balance of ",j(Math.abs(f),b)," is applied as credit on your next invoice."]})]}),B>0&&e.jsxs("div",{className:"bpb-summary__savings",children:[e.jsx(Ta,{size:18,className:"bpb-summary__savings-icon"}),e.jsxs("span",{children:["You’re saving ",j(x,b,0),"/month by choosing an annual plan. That’s"," ",j(B,b,0),"/year."]})]}),e.jsx(ie,{variant:"primary",size:"lg",block:!0,className:"bpb-summary__cta",disabled:!o,loading:l,onClick:i,children:t?"Preview unavailable":"Subscribe"})]}),e.jsxs("p",{className:"bpb-summary__fineprint",children:["Renews ",s==="month"?"monthly":"annually"," until cancelled.",n&&` You’ll be charged ${j(v,b)}${s==="month"?"/month":"/year"}${m?` starting ${m}`:""}.`," ","Cancel anytime in Settings. By subscribing, you authorize Botpress to store and charge your payment method."]})]})},br=["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE"],pr={CA:[{type:"ca_bn",label:"CA BN",description:"Canadian BN"},{type:"ca_gst_hst",label:"CA GST/HST",description:"Canadian GST/HST number"},{type:"ca_qst",label:"CA QST",description:"Canadian QST number (Québec)"},{type:"ca_pst_bc",label:"CA PST-BC",description:"Canadian PST number (British Columbia)"},{type:"ca_pst_mb",label:"CA PST-MB",description:"Canadian PST number (Manitoba)"},{type:"ca_pst_sk",label:"CA PST-SK",description:"Canadian PST number (Saskatchewan)"}],US:[{type:"us_ein",label:"US EIN",description:"United States EIN"}],GB:[{type:"gb_vat",label:"GB VAT",description:"United Kingdom VAT number"}],AU:[{type:"au_abn",label:"AU ABN",description:"Australian Business Number"}],NZ:[{type:"nz_gst",label:"NZ GST",description:"New Zealand GST number"}],IN:[{type:"in_gst",label:"IN GST",description:"Indian GST number"}],JP:[{type:"jp_cn",label:"JP CN",description:"Japanese Corporate Number"}],BR:[{type:"br_cnpj",label:"BR CNPJ",description:"Brazilian CNPJ number"},{type:"br_cpf",label:"BR CPF",description:"Brazilian CPF number"}],MX:[{type:"mx_rfc",label:"MX RFC",description:"Mexican RFC number"}],CH:[{type:"ch_vat",label:"CH VAT",description:"Switzerland VAT number"}],AE:[{type:"ae_trn",label:"AE TRN",description:"United Arab Emirates TRN"}],SG:[{type:"sg_gst",label:"SG GST",description:"Singaporean GST number"},{type:"sg_uen",label:"SG UEN",description:"Singaporean UEN"}],ZA:[{type:"za_vat",label:"ZA VAT",description:"South African VAT number"}]},ur=[{type:"eu_vat",label:"EU VAT",description:"European VAT number"}];function Fs(a){if(!a)return[];const s=a.toUpperCase();return br.includes(s)?ur:pr[s]??[]}const aa=({label:a,className:s,id:n,...r})=>a?e.jsxs("label",{className:T("bpb-input",s),children:[e.jsx("span",{className:"bpb-input__label",children:a}),e.jsx("input",{className:"bpb-input__field bpb-input__field--labeled",id:n,...r})]}):e.jsx("input",{className:T("bpb-input__field",s),id:n,...r}),Oa=({label:a,className:s,children:n,...r})=>e.jsxs("label",{className:T("bpb-input",s),children:[a&&e.jsx("span",{className:"bpb-input__label",children:a}),e.jsxs("span",{className:"bpb-input__select-wrap",children:[e.jsx("select",{className:T("bpb-input__field bpb-input__field--select",a&&"bpb-input__field--labeled"),...r,children:n}),e.jsx(Xe,{size:16,className:"bpb-input__chevron"})]})]}),hr=({plan:a,interval:s,onChange:n})=>{const r=a.prices.month,t=a.prices.year,o=r&&t&&r.amount>0?Math.round((1-t.amount/(r.amount*12))*100):0;return e.jsxs("section",{className:"bpb-checkout__section",children:[e.jsx("h3",{className:"bpb-checkout__section-title",children:"Plan details"}),e.jsxs("div",{className:"bpb-interval-cards",role:"radiogroup","aria-label":"Billing interval",children:[r&&e.jsxs("button",{type:"button",role:"radio","aria-checked":s==="month",className:T("bpb-interval-card",s==="month"&&"bpb-interval-card--selected"),onClick:()=>n("month"),children:[e.jsx("span",{className:"bpb-interval-card__title",children:"Monthly billing"}),e.jsxs("span",{className:"bpb-interval-card__price",children:[j(r.amount,r.currency,0)," /mo"]})]}),t&&e.jsxs("button",{type:"button",role:"radio","aria-checked":s==="year",className:T("bpb-interval-card",s==="year"&&"bpb-interval-card--selected"),onClick:()=>n("year"),children:[e.jsxs("span",{className:"bpb-interval-card__title",children:["Annual billing",o>0&&e.jsxs(Ma,{children:["Save ",o,"%"]})]}),e.jsxs("span",{className:"bpb-interval-card__price",children:[j(t.amount/12,t.currency,0)," /mo"]})]})]})]})},sa=({number:a,title:s,onEdit:n})=>e.jsxs("div",{className:"bpb-step__header",children:[n?e.jsxs("button",{type:"button",className:"bpb-step__title bpb-step__title--button",onClick:n,children:[a,". ",s]}):e.jsxs("h3",{className:"bpb-step__title",children:[a,". ",s]}),n&&e.jsx("button",{type:"button",className:"bpb-step__edit",onClick:n,children:"Edit"})]}),mr=({stepNumber:a,collapsed:s,summary:n,savedCard:r,isDark:t,tab:o,onTabChange:l,onPaymentChange:i,canContinue:c,onContinue:h,onEdit:b})=>{const[p,y]=w.useState(!1),_=o==="new"||!r;return s?e.jsxs("section",{className:"bpb-step bpb-step--collapsed",children:[e.jsx(sa,{number:a,title:"Payment method",onEdit:b}),r&&o!=="new"?e.jsxs("div",{className:"bpb-saved-card bpb-saved-card--readonly",children:[e.jsx(Re,{brand:r.brand}),e.jsxs("span",{className:"bpb-saved-card__number",children:[e.jsx("span",{className:"bpb-saved-card__brand",children:r.brand})," •••• ",r.lastFour]}),e.jsxs("span",{className:"bpb-saved-card__exp",children:[String(r.expMonth).padStart(2,"0"),"/",String(r.expYear).slice(-2)]})]}):e.jsx("p",{className:"bpb-step__summary",children:n})]}):e.jsxs("section",{className:"bpb-step",children:[e.jsx(sa,{number:a,title:"Payment method"}),r&&e.jsxs("div",{className:"bpb-pay-tabs",role:"tablist","aria-label":"Payment method",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":o==="saved",className:T("bpb-pay-tab",o==="saved"&&"bpb-pay-tab--selected"),onClick:()=>l("saved"),children:[e.jsx(La,{size:16}),"Saved"]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":o==="new",className:T("bpb-pay-tab",o==="new"&&"bpb-pay-tab--selected"),onClick:()=>l("new"),children:[e.jsx(La,{size:16}),"New card"]})]}),r&&o==="saved"&&e.jsxs("div",{className:"bpb-saved-card",children:[e.jsx(Re,{brand:r.brand}),e.jsxs("span",{className:"bpb-saved-card__number",children:[e.jsx("span",{className:"bpb-saved-card__brand",children:r.brand})," •••• ",r.lastFour]}),e.jsxs("span",{className:"bpb-saved-card__exp",children:[String(r.expMonth).padStart(2,"0"),"/",String(r.expYear).slice(-2)]})]}),_&&e.jsxs("div",{className:"bpb-payment-element",children:[!p&&e.jsx("div",{className:"bpb-payment-element__skeleton",children:e.jsx(q,{height:48})}),e.jsx("div",{className:T("bpb-card-element",!p&&"bpb-payment-element--hidden"),children:e.jsx(me.CardElement,{options:{style:$a(t),hidePostalCode:!0},onReady:()=>y(!0),onChange:C=>i(C.complete)})})]}),e.jsx(ie,{variant:"primary",block:!0,disabled:!c,onClick:h,children:"Next"})]})},gr=({stepNumber:a,collapsed:s,summary:n,onEditStep:r,existingAddress:t,customerName:o,isLoading:l,editing:i,onEdit:c,onCancelEdit:h,onCompleteChange:b,onCountryChange:p,country:y,isBusiness:_,onIsBusinessChange:C,businessName:v,onBusinessNameChange:m,taxType:S,onTaxTypeChange:I,taxValue:L,onTaxValueChange:D})=>{const[f,A]=w.useState(!1),P=i||!t,u=Fs(y),B=u.find(x=>x.type===S);return s?e.jsxs("section",{className:"bpb-step bpb-step--collapsed",children:[e.jsx(sa,{number:a,title:"Billing address",onEdit:r}),t?e.jsx("div",{className:"bpb-address-card bpb-address-card--readonly",children:e.jsxs("div",{className:"bpb-address-card__lines",children:[o&&e.jsx("span",{className:"bpb-address-card__name",children:o}),e.jsxs("span",{children:[t.lineOne,t.lineTwo?`, ${t.lineTwo}`:""]}),e.jsx("span",{children:[t.city,t.state,t.postalCode,t.country].filter(Boolean).join(", ")})]})}):e.jsx("p",{className:"bpb-step__summary",children:n})]}):e.jsxs("section",{className:"bpb-step",children:[e.jsx(sa,{number:a,title:"Billing address"}),l?e.jsx(q,{height:72}):P?e.jsxs("div",{className:"bpb-payment-element",children:[!f&&e.jsxs("div",{className:"bpb-payment-element__skeleton",children:[e.jsx(q,{height:48}),e.jsx(q,{height:48})]}),e.jsx("div",{className:T(!f&&"bpb-payment-element--hidden"),children:e.jsx(me.AddressElement,{options:{mode:"billing",display:{name:"full"},defaultValues:t?{name:o??void 0,address:{line1:t.lineOne,line2:t.lineTwo,city:t.city,state:t.state,postal_code:t.postalCode,country:t.country}}:void 0},onReady:()=>A(!0),onChange:x=>{b(x.complete),p(x.value.address.country||void 0)}})}),h&&i&&e.jsx("button",{type:"button",className:"bpb-address-cancel",onClick:h,children:"Cancel"})]}):e.jsxs("div",{className:"bpb-address-card",children:[e.jsxs("div",{className:"bpb-address-card__lines",children:[o&&e.jsx("span",{className:"bpb-address-card__name",children:o}),e.jsxs("span",{children:[t.lineOne,t.lineTwo?`, ${t.lineTwo}`:""]}),e.jsxs("span",{children:[t.city," ",t.state??""," ",t.postalCode," ",t.country]})]}),e.jsx("button",{type:"button",className:"bpb-link-button",onClick:c,children:"Update"})]}),e.jsxs("label",{className:"bpb-checkbox",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:x=>{C(x.target.checked),x.target.checked&&!S&&u[0]&&I(u[0].type)}}),e.jsx("span",{children:"I’m purchasing as business"})]}),_&&e.jsxs("div",{className:"bpb-business-fields",children:[e.jsx("h4",{className:"bpb-step__subtitle",children:"Business details"}),e.jsx(aa,{placeholder:"Business name",value:v,onChange:x=>m(x.target.value),autoComplete:"organization"}),u.length>0?e.jsxs(e.Fragment,{children:[e.jsx(Oa,{"aria-label":"Tax ID type",value:S,onChange:x=>I(x.target.value),children:u.map(x=>e.jsxs("option",{value:x.type,children:[x.label," — ",x.description]},x.type))}),e.jsx(aa,{placeholder:B?B.description:"Tax ID number",value:L,onChange:x=>D(x.target.value),inputMode:"text"})]}):e.jsx("p",{className:"bpb-business-fields__note",children:y?"No tax ID is required for your billing country.":"Select your billing country above to add a tax ID."})]})]})},yr=({planId:a,initialInterval:s,clientSecret:n,onSuccess:r})=>{var Ys;const t=me.useStripe(),o=me.useElements(),{email:l,toast:i,analytics:c,isDark:h}=E(),[b,p]=w.useState(s),[y,_]=w.useState("payment"),[C,v]=w.useState(!1),[m,S]=w.useState(null),[I,L]=w.useState(!1),[D,f]=w.useState(!1),[A,P]=w.useState(!1),[u,B]=w.useState(void 0),[x,R]=w.useState(!1),[X,ue]=w.useState(""),[pe,oe]=w.useState(""),[U,J]=w.useState(""),[M,le]=w.useState(!1),[g,W]=w.useState(null),{data:F}=we(),{data:G}=_e(),{data:Y,isLoading:V}=ua(),{data:H,isLoading:ke}=ha(),{data:he}=ma(),O=F==null?void 0:F.find(ia=>ia.id===a),de=((Ys=Y==null?void 0:Y.paymentMethod)==null?void 0:Ys.card)??null,re=(H==null?void 0:H.address)??null;w.useEffect(()=>{m===null&&!V&&Y!==void 0&&S(de?"saved":"new")},[m,V,Y,de]),w.useEffect(()=>{u===void 0&&re&&B(re.country)},[u,re]);const fe=w.useMemo(()=>({plan:{planId:a,interval:b}}),[a,b]),ce=pa(fe),$=fa(),be=_a(),K=va(),Z=ka(),Ne=O?ee(O.name):"",Ie=m==="new"||!de,la=D||!re,ca=Ie?I:!!de,Ee=la?A:!0,Ks=()=>{ca&&(v(!0),_("address"))},Ur=y==="address"&&!!t&&!!o&&!!O&&!ce.isError&&!!ce.data&&ca&&Ee&&!M,$r=de?`${de.brand.charAt(0).toUpperCase()}${de.brand.slice(1)} •••• ${de.lastFour}`:null,Fr=Ie?"New card":$r??"Saved card",Or=re?`${re.city}${re.state?`, ${re.state}`:""} ${re.country}`:"Not set",qr=async()=>{var ia,Hs,Qs,Zs,Xs,Js;if(!(!t||!o||!O)){le(!0),W(null);try{if((ia=c.trackPaymentDetailsConfirmed)==null||ia.call(c,{plan_name:Ne,interval:b}),Ie){const ze=o.getElement(me.CardElement);if(!ze){W("Card field is not ready");return}const{error:da,setupIntent:xe}=await t.confirmCardSetup(n,{payment_method:{card:ze}});if(da){W(da.message??"Payment setup failed");return}if(!(xe!=null&&xe.payment_method)||typeof xe.payment_method!="string"){W("Could not retrieve payment method");return}await $.mutateAsync({paymentMethodId:xe.payment_method})}let Rs;if(la){const ze=o.getElement("address");if(ze){const{complete:da,value:xe}=await ze.getValue();if(!da||!xe.address){W("Please complete your billing address");return}const{address:Oe}=xe;Rs=((Hs=xe.name)==null?void 0:Hs.trim())||void 0,await be.mutateAsync({lineOne:Oe.line1??"",lineTwo:Oe.line2??void 0,city:Oe.city??"",state:Oe.state??void 0,postalCode:Oe.postal_code??"",country:Oe.country??""})}}const en=x&&X.trim()||Rs||void 0,an=x&&pe&&U.trim()?[{type:pe,value:U.trim()}]:void 0;(en!==void 0||an!==void 0)&&await K.mutateAsync({name:en,taxIds:an});const Wr=((Qs=ce.data)==null?void 0:Qs.costs.immediate.amountDue)??0,Gr=((Zs=ce.data)==null?void 0:Zs.costs.nextCycle.total)??0;await Z.mutateAsync({planId:a,interval:b}),(Js=c.trackPlanUpgraded)==null||Js.call(c,{plan_name:Ne,interval:b,amount_paid:Wr,next_cycle_amount:Gr,previous_plan_name:(Xs=F==null?void 0:F.find(ze=>ze.id===(G==null?void 0:G.plan.current.planId)))==null?void 0:Xs.name.replace("Plan - ",""),previous_interval:G==null?void 0:G.plan.current.interval}),i({type:"success",message:"Subscription activated"}),r()}catch{W("Something went wrong while processing your payment. You have not been charged twice."),i({type:"error",message:"Payment error"})}finally{le(!1)}}};return e.jsxs("div",{className:"bpb-checkout__columns",children:[e.jsxs("div",{className:"bpb-checkout__main",children:[O&&e.jsx(hr,{plan:O,interval:b,onChange:p}),l&&e.jsxs("section",{className:"bpb-checkout__section",children:[e.jsx("h3",{className:"bpb-checkout__section-title",children:"Contact information"}),e.jsxs("div",{className:"bpb-checkout__static-field",children:[e.jsx("span",{className:"bpb-checkout__static-label",children:"Email"}),e.jsx("span",{children:l})]})]}),e.jsx(mr,{stepNumber:1,collapsed:y!=="payment",summary:Fr,savedCard:de,isDark:h,tab:m??"new",onTabChange:S,onPaymentChange:L,canContinue:ca,onContinue:Ks,onEdit:()=>_("payment")}),C&&e.jsx(gr,{stepNumber:2,collapsed:y!=="address",summary:Or,onEditStep:Ks,existingAddress:re,customerName:(he==null?void 0:he.name)??null,isLoading:ke,editing:D,onEdit:()=>f(!0),onCancelEdit:re?()=>f(!1):void 0,onCompleteChange:P,onCountryChange:B,country:u,isBusiness:x,onIsBusinessChange:R,businessName:X,onBusinessNameChange:ue,taxType:pe,onTaxTypeChange:oe,taxValue:U,onTaxValueChange:J}),g&&e.jsx("p",{role:"alert",className:"bpb-checkout__submit-error",children:g})]}),e.jsx("div",{className:"bpb-checkout__aside",children:e.jsx(dr,{plan:O,interval:b,preview:ce.data,isLoadingPreview:ce.isLoading,isPreviewError:ce.isError,canSubscribe:Ur,isSubmitting:M,onSubscribe:()=>void qr()})})]})},Os=({open:a,onOpenChange:s,planId:n,interval:r,onBack:t,onSuccess:o})=>{var v;const{stripePromise:l,isDark:i,locale:c,isOutdatedBilling:h}=E(),b=ya(),p=(v=b.data)==null?void 0:v.clientSecret,{mutate:y,reset:_}=b;w.useEffect(()=>{a&&!h?y():_()},[a,h,y,_]);const C=w.useMemo(()=>p?{clientSecret:p,appearance:Ua(i),locale:Fa(c)}:null,[p,i,c]);return h?e.jsx(ye,{open:a,onOpenChange:s,size:"md","aria-label":"Configure your plan",className:"bpb-scope",children:e.jsx(Pe,{})}):e.jsx(ye,{open:a,onOpenChange:s,size:"xl","aria-label":"Configure your plan",className:"bpb-scope",children:e.jsxs("div",{className:"bpb-checkout",children:[e.jsxs("header",{className:"bpb-checkout__header",children:[t&&e.jsx("button",{type:"button",className:"bpb-checkout__back","aria-label":"Back to plans",onClick:t,children:"‹"}),e.jsx("h2",{className:"bpb-checkout__title",children:"Configure your plan"})]}),b.isError?e.jsxs("div",{className:"bpb-checkout__error-state",children:[e.jsx("p",{children:"We couldn’t start the payment session."}),b.error instanceof Error&&b.error.message&&e.jsx("p",{className:"bpb-checkout__error-detail",children:b.error.message}),e.jsx("p",{className:"bpb-checkout__error-detail",children:"If this persists, the workspace may not exist in this environment or may not be on billing v4."}),e.jsx(ie,{variant:"outline",onClick:()=>y(),children:"Try again"})]}):!C||!p?e.jsxs("div",{className:"bpb-checkout__columns","aria-busy":"true",children:[e.jsxs("div",{className:"bpb-checkout__main",children:[e.jsx(q,{height:56}),e.jsx(q,{height:56}),e.jsx(q,{height:120}),e.jsx(q,{height:56})]}),e.jsx("div",{className:"bpb-checkout__aside",children:e.jsx(q,{height:320})})]}):e.jsx(me.Elements,{stripe:l,options:C,children:e.jsx(yr,{planId:n,initialInterval:r,clientSecret:p,onSuccess:()=>{s(!1),o==null||o()}})})]})})},qs=({value:a,onChange:s,min:n=0,max:r,step:t=1,className:o,...l})=>{const i=()=>s(Math.max(n,a-t)),c=()=>s(r===void 0?a+t:Math.min(r,a+t));return e.jsxs("div",{className:T("bpb-stepper",o),children:[e.jsx("button",{type:"button",className:"bpb-stepper__btn","aria-label":`Decrease ${l["aria-label"]}`,onClick:i,disabled:a<=n,children:e.jsx(Ps,{size:14})}),e.jsx("span",{className:"bpb-stepper__value","aria-label":l["aria-label"],children:a}),e.jsx("button",{type:"button",className:"bpb-stepper__btn","aria-label":`Increase ${l["aria-label"]}`,onClick:c,disabled:r!==void 0&&a>=r,children:e.jsx(Es,{size:14})})]})},fr=({open:a,onOpenChange:s,onSuccess:n})=>{const{isOutdatedBilling:r}=E();return r?e.jsx(ye,{open:a,onOpenChange:s,size:"md","aria-label":"Manage add-ons",className:"bpb-scope",children:e.jsx(Pe,{})}):e.jsx(ye,{open:a,onOpenChange:s,size:"md","aria-label":"Manage add-ons",className:"bpb-scope",children:e.jsx(_r,{onOpenChange:s,onSuccess:n})})},_r=({onOpenChange:a,onSuccess:s})=>{var U,J,M,le;const{toast:n,locale:r}=E(),{data:t}=_e(),{data:o}=De(),{data:l}=we(),{data:i}=ga(),c=Ha(),[h,b]=w.useState(null),p=l==null?void 0:l.find(g=>g.id===(t==null?void 0:t.plan.current.planId)),y=(t==null?void 0:t.plan.current.interval)??"month",_=(i==null?void 0:i.addonsReadonly)??!1,C=t!=null&&t.plan.current.periodEnd?Se(t.plan.current.periodEnd,r):null,v=w.useMemo(()=>{var W;if(!t||!o)return null;const g={};for(const F of o){const G=t.addons[F.id];g[F.id]=((W=G==null?void 0:G.next)==null?void 0:W.quantity)??(G==null?void 0:G.current.quantity)??0}return g},[t,o]),m=h??v,S=w.useMemo(()=>!o||!p?[]:o.flatMap(g=>{const W=Ye(g,p,y);return W?[{addon:g,price:W}]:[]}),[o,p,y]),I=!!m&&!!v&&Object.keys(m).some(g=>m[g]!==v[g]),L=S.reduce((g,{addon:W,price:F})=>g+((m==null?void 0:m[W.id])??0)*F.amount,0),D=w.useMemo(()=>p&&m?{plan:{planId:p.id,interval:y},addons:m}:null,[p,y,m]),f=pa(D??{plan:{planId:"",interval:y}},{enabled:!!D&&I}),A=((U=p==null?void 0:p.prices[y])==null?void 0:U.currency)??"usd",P=((J=f.data)==null?void 0:J.costs.immediate.amountDue)??0,u=(M=f.data)!=null&&M.nextBillingDate?Se(f.data.nextBillingDate,r):null,B=((le=p==null?void 0:p.prices[y])==null?void 0:le.amount)??0,x=B+L,R=p&&m?Ns(p,o,m):[],X=(g,W)=>W==="bytes"?Le(g):se(g),ue=(g,W)=>{const F=o==null?void 0:o.find(H=>H.id===g),G=F==null?void 0:F.increments;if(!G||W<=0)return null;const Y=G.conversation_sessions??0;if(Y>0)return`${se(Y*W)} convos`;const V=G.file_storage??0;return V>0?Le(V*W):null},pe=()=>{m&&c.mutate({addons:m},{onSuccess:()=>{n({type:"success",message:"Subscription updated"}),a(!1),s==null||s()},onError:()=>n({type:"error",message:"Could not update your add-ons"})})},oe=!t||!o||!l;return e.jsxs("div",{className:"bpb-manage-addons",children:[e.jsx("h2",{className:"bpb-manage-addons__title",children:"Manage add-ons"}),e.jsx("p",{className:"bpb-manage-addons__subtitle",children:p?`Additional usage for your ${ee(p.name)} plan. Set a quantity to 0 to remove an add-on.`:"Additional usage for your plan. Set a quantity to 0 to remove an add-on."}),oe?e.jsxs("div",{className:"bpb-manage-addons__loading","aria-busy":"true",children:[e.jsx(q,{height:56}),e.jsx(q,{height:56})]}):S.length===0?e.jsxs("p",{className:"bpb-manage-addons__empty",children:["Add-ons aren’t available on the ",p?ee(p.name):"current"," plan. Upgrade to a paid plan to add extra usage."]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bpb-addons",children:S.map(({addon:g,price:W})=>{var V;const F=((V=t==null?void 0:t.addons[g.id])==null?void 0:V.current.quantity)??0,G=(m==null?void 0:m[g.id])??0,Y=G!==F?G===0?`${F} active now · removed${C?` ${C}`:" next cycle"}`:`${F} active now · ${G}${C?` from ${C}`:" next cycle"}`:F>0?`${F} active`:null;return e.jsxs("div",{className:"bpb-addon-row",children:[e.jsxs("div",{className:"bpb-addon-row__info",children:[e.jsx("span",{className:"bpb-addon-row__name",children:Ge(g.name)}),e.jsx("span",{className:"bpb-addon-row__description",children:g.description}),e.jsxs("span",{className:"bpb-addon-row__price",children:[j(W.amount,W.currency)," each"]}),Y&&e.jsx("span",{className:T("bpb-addon-row__status",G!==F&&"bpb-addon-row__status--changed"),children:Y})]}),e.jsxs("div",{className:"bpb-addon-row__control",children:[ue(g.id,G)&&e.jsx("span",{className:"bpb-addon-row__grant",children:ue(g.id,G)}),e.jsx(qs,{"aria-label":`${Ge(g.name)} quantity`,value:G,onChange:H=>b({...m??{},[g.id]:H})})]})]},g.id)})}),R.length>0&&e.jsxs("div",{className:"bpb-manage-addons__limits",children:[e.jsx("p",{className:"bpb-manage-addons__limits-title",children:"Your new limits"}),R.map(g=>e.jsxs("div",{className:"bpb-manage-addons__limit-row",children:[e.jsx("span",{className:"bpb-manage-addons__limit-label",children:g.label}),e.jsxs("span",{className:"bpb-manage-addons__limit-values",children:[e.jsx("span",{className:"bpb-manage-addons__limit-now",children:X(g.now,g.unit)}),e.jsx("span",{className:"bpb-manage-addons__limit-arrow","aria-hidden":!0,children:"→"}),e.jsx("span",{className:"bpb-manage-addons__limit-next",children:X(g.next,g.unit)})]})]},g.key))]}),e.jsxs("div",{className:"bpb-manage-addons__totals",children:[e.jsxs("div",{className:"bpb-manage-addons__line",children:[e.jsx("span",{children:p?`${ee(p.name)} plan`:"Plan"}),e.jsx("span",{children:j(B,A)})]}),S.map(({addon:g,price:W})=>{const F=(m==null?void 0:m[g.id])??0;return F<=0?null:e.jsxs("div",{className:"bpb-manage-addons__line",children:[e.jsxs("span",{children:[F,"× ",Ge(g.name)]}),e.jsx("span",{children:j(W.amount*F,A)})]},g.id)}),e.jsxs("div",{className:"bpb-manage-addons__line bpb-manage-addons__line--total",children:[e.jsxs("span",{children:["Total ",y==="year"?"yearly":"monthly"," cost"]}),e.jsxs("span",{children:[j(x,A),y==="year"?"/yr":"/mo"]})]}),I&&e.jsxs("div",{className:"bpb-manage-addons__line bpb-manage-addons__line--due",children:[e.jsx("span",{children:"Due today"}),e.jsx("span",{children:f.isLoading?"…":f.isError?"—":j(Math.max(P,0),A)})]})]}),I&&!f.isError&&e.jsxs("p",{className:"bpb-manage-addons__note",children:[P>0?`You’ll be charged ${j(P,A)} now for the rest of this billing period. `:"No charge today — the change is prorated. ","Add-ons stay active until you remove them and renew with your plan",u?` on ${u}`:"",", when you’ll be billed ",j(L,A),y==="year"?"/yr":"/mo"," for them."]}),_&&e.jsx("p",{className:"bpb-manage-addons__note",role:"alert",children:"Add-ons for this workspace are managed by Botpress — contact us to change them."}),e.jsxs("div",{className:"bpb-manage-addons__actions",children:[e.jsx(ie,{variant:"outline",onClick:()=>a(!1),disabled:c.isPending,children:"Cancel"}),e.jsx(ie,{variant:"primary",disabled:!I||_,loading:c.isPending,onClick:pe,children:"Update subscription"})]})]})]})},vr={paid:"Paid",open:"Due",draft:"Draft",uncollectible:"Unpaid",void:"Void"},kr=({open:a,onOpenChange:s})=>{const{isOutdatedBilling:n}=E();return n?e.jsx(ye,{open:a,onOpenChange:s,size:"md","aria-label":"Billing history",className:"bpb-scope",children:e.jsx(Pe,{})}):e.jsx(ye,{open:a,onOpenChange:s,size:"md","aria-label":"Billing history",className:"bpb-scope",children:e.jsx(Nr,{open:a})})},Nr=({open:a})=>{const{locale:s}=E(),{data:n,isLoading:r,isError:t}=Va({enabled:a}),o=(n==null?void 0:n.invoices)??[];return e.jsxs("div",{className:"bpb-invoices",children:[e.jsx("h2",{className:"bpb-invoices__title",children:"Billing history"}),r?e.jsxs("div",{className:"bpb-invoices__loading","aria-busy":"true",children:[e.jsx(q,{height:52}),e.jsx(q,{height:52}),e.jsx(q,{height:52})]}):t?e.jsx("p",{className:"bpb-invoices__empty",role:"alert",children:"We couldn’t load your invoices. Try again in a moment."}):o.length===0?e.jsx("p",{className:"bpb-invoices__empty",children:"No invoices yet. They’ll appear here after your first charge."}):e.jsx("ul",{className:"bpb-invoices__list",children:o.map(l=>e.jsxs("li",{className:"bpb-invoices__row",children:[e.jsxs("div",{className:"bpb-invoices__row-main",children:[e.jsx("span",{className:"bpb-invoices__date",children:Se(l.createdAt,s)}),e.jsx("span",{className:`bpb-invoices__status bpb-invoices__status--${l.status}`,children:vr[l.status]})]}),e.jsxs("div",{className:"bpb-invoices__row-end",children:[e.jsx("span",{className:"bpb-invoices__amount",children:j(l.amount,l.currency)}),l.pdfUrl?e.jsx("a",{className:"bpb-invoices__download",href:l.pdfUrl,target:"_blank",rel:"noopener noreferrer","aria-label":`Download invoice from ${Se(l.createdAt,s)}`,children:e.jsx(Pa,{size:16})}):e.jsx("span",{className:"bpb-invoices__download bpb-invoices__download--disabled","aria-hidden":!0,children:e.jsx(Pa,{size:16})})]})]},l.id))})]})},wr=({open:a,onOpenChange:s,onSuccess:n})=>{var y;const{stripePromise:r,isDark:t,locale:o,isOutdatedBilling:l}=E(),i=ya(),c=(y=i.data)==null?void 0:y.clientSecret,{mutate:h,reset:b}=i;w.useEffect(()=>{a&&!l?h():b()},[a,l,h,b]);const p=w.useMemo(()=>c?{clientSecret:c,appearance:Ua(t),locale:Fa(o)}:null,[c,t,o]);return l?e.jsx(ye,{open:a,onOpenChange:s,size:"md","aria-label":"Payment & billing",className:"bpb-scope",children:e.jsx(Pe,{})}):e.jsx(ye,{open:a,onOpenChange:s,size:"md","aria-label":"Payment & billing",className:"bpb-scope",children:e.jsxs("div",{className:"bpb-payment-dialog",children:[e.jsx("h2",{className:"bpb-payment-dialog__title",children:"Payment & billing"}),i.isError?e.jsxs("div",{className:"bpb-payment-dialog__error",children:[e.jsx("p",{children:"We couldn’t start a secure session."}),e.jsx(ie,{variant:"outline",onClick:()=>h(),children:"Try again"})]}):!p||!c?e.jsxs("div",{className:"bpb-payment-dialog__loading","aria-busy":"true",children:[e.jsx(q,{height:48}),e.jsx(q,{height:120})]}):e.jsx(me.Elements,{stripe:r,options:p,children:e.jsx(Cr,{clientSecret:c,isDark:t,onSuccess:n})})]})})},Cr=({clientSecret:a,isDark:s,onSuccess:n})=>{var ce;const r=me.useStripe(),t=me.useElements(),{toast:o}=E(),{data:l,isLoading:i}=ua(),{data:c,isLoading:h}=ha(),{data:b,isLoading:p}=ma(),y=fa(),_=_a(),C=va(),v=((ce=l==null?void 0:l.paymentMethod)==null?void 0:ce.card)??null,m=(c==null?void 0:c.address)??null,S=(b==null?void 0:b.taxIds)??[],[I,L]=w.useState(!1),[D,f]=w.useState(!1),[A,P]=w.useState(!1),[u,B]=w.useState(!1),[x,R]=w.useState(null),[X,ue]=w.useState(!1),[pe,oe]=w.useState(!1),[U,J]=w.useState(null),[M,le]=w.useState(m==null?void 0:m.country),[g,W]=w.useState(S.length>0),[F,G]=w.useState(null),Y=F??S.map($=>({type:$.type,value:$.value})),V=Fs(M),H=F!==null,ke=I||!v,he=($,be)=>G(Y.map((K,Z)=>Z===$?{...K,...be}:K)),O=()=>{var $;return G([...Y,{type:(($=V[0])==null?void 0:$.type)??"",value:""}])},de=$=>G(Y.filter((be,K)=>K!==$)),re=async()=>{if(!r||!t)return;const $=t.getElement(me.CardElement);if($){B(!0),R(null);try{const{error:be,setupIntent:K}=await r.confirmCardSetup(a,{payment_method:{card:$}});if(be){R(be.message??"Could not save your card");return}if(!(K!=null&&K.payment_method)||typeof K.payment_method!="string"){R("Could not retrieve payment method");return}await y.mutateAsync({paymentMethodId:K.payment_method}),o({type:"success",message:"Card updated"}),L(!1),n==null||n()}catch{R("We couldn’t save your card. Please check your details and try again.")}finally{B(!1)}}},fe=async()=>{if(!t)return;const $=t.getElement("address");if(!$)return;const{complete:be,value:K}=await $.getValue();if(!be||!K.address){J("Please complete your billing address.");return}oe(!0),J(null);try{const{address:Z,name:Ne}=K;await _.mutateAsync({lineOne:Z.line1??"",lineTwo:Z.line2??void 0,city:Z.city??"",state:Z.state??void 0,postalCode:Z.postal_code??"",country:Z.country??""});const Ie=(Ne==null?void 0:Ne.trim())||void 0,la=Y.filter(Ee=>!!Ee.type&&Ee.value.trim()!=="").map(Ee=>({type:Ee.type,value:Ee.value.trim()}));(Ie!==((b==null?void 0:b.name)??void 0)||H)&&await C.mutateAsync({name:Ie,taxIds:la}),o({type:"success",message:"Billing details updated"}),n==null||n()}catch(Z){const Ne=Z instanceof Error&&Z.message?Z.message:"Could not update your billing details.";J(Ne),o({type:"error",message:"Could not update your billing details"})}finally{oe(!1)}};return e.jsxs("div",{className:"bpb-payment-dialog__sections",children:[e.jsxs("section",{className:"bpb-payment-dialog__section",children:[e.jsx("h3",{className:"bpb-payment-dialog__section-title",children:"Payment method"}),i?e.jsx(q,{height:56}):ke?e.jsxs("div",{className:"bpb-payment-element",children:[!D&&e.jsx(q,{height:48}),e.jsx("div",{className:D?"bpb-card-element":"bpb-payment-element--hidden",children:e.jsx(me.CardElement,{options:{style:$a(s),hidePostalCode:!0},onReady:()=>f(!0),onChange:$=>P($.complete)})}),x&&e.jsx("p",{role:"alert",className:"bpb-payment-dialog__field-error",children:x}),e.jsxs("div",{className:"bpb-payment-dialog__section-actions",children:[v&&e.jsx(ie,{variant:"ghost",onClick:()=>L(!1),disabled:u,children:"Cancel"}),e.jsx(ie,{variant:"primary",disabled:!A,loading:u,onClick:re,children:"Save card"})]})]}):e.jsxs("div",{className:"bpb-saved-card",children:[e.jsx(Re,{brand:v.brand}),e.jsxs("span",{className:"bpb-saved-card__number",children:[e.jsx("span",{className:"bpb-saved-card__brand",children:v.brand})," •••• ",v.lastFour]}),e.jsxs("span",{className:"bpb-saved-card__exp",children:[String(v.expMonth).padStart(2,"0"),"/",String(v.expYear).slice(-2)]}),e.jsx("button",{type:"button",className:"bpb-link-button",onClick:()=>L(!0),children:"Replace"})]})]}),e.jsxs("section",{className:"bpb-payment-dialog__section",children:[e.jsx("h3",{className:"bpb-payment-dialog__section-title",children:"Billing address"}),h||p?e.jsx(q,{height:72}):e.jsxs("div",{className:"bpb-payment-element",children:[!X&&e.jsx(q,{height:120}),e.jsx("div",{className:X?void 0:"bpb-payment-element--hidden",children:e.jsx(me.AddressElement,{options:{mode:"billing",display:{name:"full"},defaultValues:m?{name:(b==null?void 0:b.name)??void 0,address:{line1:m.lineOne,line2:m.lineTwo,city:m.city,state:m.state,postal_code:m.postalCode,country:m.country}}:void 0},onReady:()=>ue(!0),onChange:$=>le($.value.address.country||void 0)})}),e.jsxs("div",{className:"bpb-tax-section",children:[e.jsxs("button",{type:"button",className:"bpb-tax-toggle","aria-expanded":g,onClick:()=>W($=>!$),children:[e.jsx(Xe,{size:16,className:T("bpb-tax-toggle__chevron",g&&"bpb-tax-toggle__chevron--open")}),"Tax IDs",S.length>0&&e.jsx("span",{className:"bpb-tax-toggle__count",children:S.length})]}),g&&e.jsxs("div",{className:"bpb-tax",children:[Y.length===0&&e.jsx("p",{className:"bpb-tax__empty",children:"Add a VAT or tax registration number to show it on your invoices."}),Y.map(($,be)=>e.jsxs("div",{className:"bpb-tax__row",children:[e.jsxs(Oa,{"aria-label":"Tax ID type",value:$.type,onChange:K=>he(be,{type:K.target.value}),children:[e.jsx("option",{value:"",children:"Select type"}),V.map(K=>e.jsx("option",{value:K.type,children:K.label},K.type)),$.type&&!V.some(K=>K.type===$.type)&&e.jsx("option",{value:$.type,children:$.type})]}),e.jsx(aa,{placeholder:"Tax ID number",value:$.value,onChange:K=>he(be,{value:K.target.value})}),e.jsx("button",{type:"button",className:"bpb-tax__remove","aria-label":"Remove tax ID",onClick:()=>de(be),children:e.jsx(Ze,{size:14})})]},be)),e.jsx("button",{type:"button",className:"bpb-link-button bpb-tax__add",onClick:O,children:"+ Add tax ID"})]})]}),U&&e.jsx("p",{role:"alert",className:"bpb-payment-dialog__field-error",children:U}),e.jsx("div",{className:"bpb-payment-dialog__section-actions",children:e.jsx(ie,{variant:"primary",loading:pe,onClick:fe,children:"Save billing details"})})]})]})]})},na=1e9,Ws={incoming_messages_events:a=>`${se(a)} incoming messages & events`,conversation_sessions:a=>`${se(a)} conversation sessions`,table_rows:a=>`${se(a)} table rows`,vector_db_storage:a=>`${Le(a)} vector database storage`,file_storage:a=>`${Le(a)} file storage`,collaborator_count:a=>a===1?"1 collaborator":`${se(a)} collaborators`,bot_count:a=>a===1?"1 bot":`${se(a)} bots`,indexed_file_count:a=>`${se(a)} indexed files for RAG`,ai_spend:a=>`${j(a/na,"usd",0)} AI credit included`,always_alive:a=>a===1?"1 always-alive bot":`${se(a)} always-alive bots`};function Sr(a,s,n){const r=(n==null?void 0:n[a])??Ws[a];return r?r(s):`${se(s)} ${a.replaceAll("_"," ")}`}const Ir=[{key:"table_rows",label:"Table rows",unit:"count"},{key:"vector_db_storage",label:"Vector DB storage",unit:"bytes"},{key:"file_storage",label:"File storage",unit:"bytes"}],Fe=(a,s)=>s==="bytes"?Le(a):s==="nano-usd"?`$${(a/na).toFixed(2)}`:se(a),xr=(a,s)=>{const n=new Date;return Array.from({length:a},(r,t)=>{const o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()-t,1));return{value:o.toISOString(),label:o.toLocaleDateString(s,{month:"long",year:"numeric",timeZone:"UTC"})}})},Ar=({period:a})=>{const{data:s,isLoading:n,isError:r}=Ka("ai_spend",{period:a});if(r)return null;if(n)return e.jsx(q,{height:96});if(!s||s.length===0)return e.jsx("p",{className:"bpb-usage__group-hint",children:"No per-bot AI spend this period."});const t=Math.max(...s.map(o=>o.value),1);return e.jsx("div",{className:"bpb-usage-bots",children:s.map(o=>e.jsxs("div",{className:"bpb-usage-bot",children:[e.jsxs("div",{className:"bpb-usage-bot__head",children:[e.jsx("span",{className:"bpb-usage-bot__name",title:o.name,children:o.name}),e.jsx("span",{className:"bpb-usage-bot__value",children:Fe(o.value,"nano-usd")})]}),e.jsx("div",{className:"bpb-usage-bar",role:"presentation",children:e.jsx("div",{className:"bpb-usage-bar__fill bpb-usage-bar__fill--normal",style:{width:`${Math.max(2,Math.round(o.value/t*100))}%`}})})]},o.botId))})},qa=({entry:a,metric:s,planAllowance:n,planName:r})=>{const t=a.usage??0,o=a.quota>0?Math.max(0,Math.min(100,Math.round(t/a.quota*100))):0,l=o>0?Math.max(5,o):0,i=o>=90?"critical":o>=75?"warning":"normal",c=n??a.quota,h=Math.max(0,a.quota-c),b=r?`${r} plan`:"your plan",p=h>0?`${Fe(c,s.unit)} from ${b} + ${Fe(h,s.unit)} from add-ons`:`${Fe(a.quota,s.unit)} from ${b}`;return e.jsxs("div",{className:"bpb-usage-row",children:[e.jsxs("div",{className:"bpb-usage-row__head",children:[e.jsx("span",{className:"bpb-usage-row__label",children:s.label}),e.jsxs("span",{className:"bpb-usage-row__value",children:[e.jsx("span",{className:"bpb-usage-row__used",children:Fe(t,s.unit)}),e.jsxs("span",{className:"bpb-usage-row__quota",children:[" / ",Fe(a.quota,s.unit)]})]})]}),e.jsxs("span",{className:"bpb-usage-tip",tabIndex:0,role:"note","aria-label":p,children:[e.jsx("div",{className:"bpb-usage-bar",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:T("bpb-usage-bar__fill",`bpb-usage-bar__fill--${i}`),style:{width:`${l}%`}})}),e.jsx("span",{className:"bpb-usage-tip__bubble",role:"tooltip",children:p})]})]})},Mr=({period:a,showPeriodSelector:s=!0,periodMonths:n=12,className:r})=>{var P;const{isOutdatedBilling:t,locale:o}=E(),l=w.useMemo(()=>xr(n,o),[n,o]),[i,c]=w.useState(a??((P=l[0])==null?void 0:P.value)??""),h=Ya(),b=Math.max(0,l.findIndex(u=>u.value===i)),p=u=>{const B=l[b+u];B&&c(B.value)},{data:y,isLoading:_,isError:C}=Ue({period:i,enabled:!t}),{data:v}=_e({enabled:!t}),{data:m}=we(),S=m==null?void 0:m.find(u=>u.id===(v==null?void 0:v.plan.current.planId)),I=S?ee(S.name):void 0,L=u=>S==null?void 0:S.features[u];if(t)return e.jsx("div",{className:T("bpb-usage bpb-scope",r),children:e.jsx(Pe,{})});if(_)return e.jsxs("div",{className:T("bpb-usage bpb-scope",r),"aria-busy":"true",children:[e.jsx(q,{height:80}),e.jsx(q,{height:140})]});if(C||!y)return e.jsx("div",{className:T("bpb-usage bpb-scope",r),children:e.jsx("p",{className:"bpb-usage__error",role:"alert",children:"We couldn’t load your usage. Try again in a moment."})});const D=y.conversation_sessions,f=y.ai_spend,A=Ir.filter(u=>y[u.key]);return e.jsxs("div",{className:T("bpb-usage bpb-scope",r),children:[s&&l.length>1&&e.jsxs("div",{className:"bpb-usage__header",children:[e.jsx("span",{className:"bpb-usage__header-title",children:"Usage"}),e.jsxs("div",{className:"bpb-usage__period",children:[e.jsx("span",{className:"bpb-usage__period-label",children:"Billing period"}),e.jsxs("div",{className:"bpb-usage__period-control",children:[e.jsx("button",{type:"button",className:"bpb-usage__period-step","aria-label":"Previous month",onClick:()=>p(1),disabled:b>=l.length-1,children:e.jsx(Ls,{size:15})}),e.jsxs("span",{className:"bpb-usage__period-field",children:[e.jsx(zs,{size:15,className:"bpb-usage__period-icon"}),e.jsx("select",{className:"bpb-usage__period-select","aria-label":"Billing period",value:i,onChange:u=>c(u.target.value),children:l.map(u=>e.jsx("option",{value:u.value,children:u.label},u.value))}),e.jsx(Xe,{size:14,className:"bpb-usage__period-chevron"})]}),e.jsx("button",{type:"button",className:"bpb-usage__period-step","aria-label":"Next month",onClick:()=>p(-1),disabled:b<=0,children:e.jsx($e,{size:15})})]})]})]}),D&&e.jsxs("section",{className:"bpb-usage__group",children:[e.jsx("h3",{className:"bpb-usage__group-title",children:"Conversations"}),e.jsx("p",{className:"bpb-usage__group-hint",children:"Each conversation includes AI usage. When you reach your limit, extra conversations are added automatically so service continues."}),e.jsx("div",{className:"bpb-usage__card",children:e.jsx(qa,{entry:D,metric:{key:"conversation_sessions",label:"Conversations",unit:"count"},planAllowance:L("conversation_sessions"),planName:I})})]}),A.length>0&&e.jsxs("section",{className:"bpb-usage__group",children:[e.jsx("h3",{className:"bpb-usage__group-title",children:"Storage"}),e.jsx("p",{className:"bpb-usage__group-hint",children:"Shared across files, knowledge base, and tables."}),e.jsx("div",{className:"bpb-usage__card",children:A.map(u=>e.jsx(qa,{entry:y[u.key],metric:u,planAllowance:L(u.key),planName:I},u.key))})]}),f&&e.jsxs("section",{className:"bpb-usage__group",children:[e.jsx("h3",{className:"bpb-usage__group-title",children:"AI usage"}),e.jsx("p",{className:"bpb-usage__group-hint",children:"Each conversation includes an AI allowance — this is how much you’ve used."}),e.jsx("div",{className:"bpb-usage__card",children:e.jsx(qa,{entry:f,metric:{key:"ai_spend",label:"AI spend",unit:"nano-usd"}})}),h&&e.jsxs("div",{className:"bpb-usage__card bpb-usage__card--bots",children:[e.jsx("span",{className:"bpb-usage__subhead",children:"AI spend by bot"}),e.jsx(Ar,{period:i})]})]})]})},Tr={conversation_sessions:"monthly conversations",table_rows:"table rows",vector_db_storage:"vector DB storage",file_storage:"file storage",ai_spend:"AI spend"},Br=({position:a="inline",threshold:s=.9,onUpgrade:n,dismissible:r=!0,ctaLabel:t="Upgrade plan",period:o,className:l})=>{const{isOutdatedBilling:i}=E(),{data:c}=Ue({period:o,enabled:!i}),[h,b]=w.useState(!1),[p,y]=w.useState(!1),[_,C]=w.useState(null),v=c?Object.entries(c).map(([f,A])=>({key:f,pct:A.quota>0?(A.usage??0)/A.quota:0})).filter(f=>f.pct>=s).sort((f,A)=>A.pct-f.pct)[0]:void 0;if(i||!v||h)return null;const m=Tr[v.key]??v.key.replace(/_/g," "),S=Math.min(100,Math.round(v.pct*100)),I=n??(()=>y(!0)),L=v.pct>=1,D=L?"critical":"warning";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:T("bpb-usage-banner bpb-scope",`bpb-usage-banner--${a}`,`bpb-usage-banner--${D}`,l),role:"alert","aria-live":"polite",children:[e.jsx(nr,{size:18,className:"bpb-usage-banner__icon"}),e.jsx("p",{className:"bpb-usage-banner__text",children:L?e.jsxs(e.Fragment,{children:["You’ve reached your ",m," limit. Upgrade now to avoid interruptions."]}):e.jsxs(e.Fragment,{children:["You’ve used ",e.jsxs("strong",{children:[S,"%"]})," of your ",m,". Upgrade to avoid hitting your limit."]})}),e.jsxs("div",{className:"bpb-usage-banner__actions",children:[e.jsx(ie,{variant:"primary",size:"sm",onClick:I,children:t}),r&&e.jsx("button",{type:"button",className:"bpb-usage-banner__dismiss","aria-label":"Dismiss",onClick:()=>b(!0),children:e.jsx(Ze,{size:16})})]})]}),!n&&e.jsxs(e.Fragment,{children:[e.jsx(Us,{open:p,onOpenChange:y,onSelectPlan:(f,A)=>{y(!1),C({planId:f,interval:A})}}),_&&e.jsx(Os,{open:!!_,onOpenChange:f=>!f&&C(null),planId:_.planId,interval:_.interval,onBack:()=>{C(null),y(!0)},onSuccess:()=>C(null)})]})]})},Wa=({children:a})=>e.jsx("span",{className:"bpb-summary-card__icon","aria-hidden":"true",children:a}),Gs=({eyebrow:a,className:s})=>{const{manageBillingUrl:n}=E(),r=()=>n&&window.open(n,"_blank","noopener");return e.jsxs("button",{type:"button",className:T("bpb-summary-card bpb-scope",a==="Add-ons"?"bpb-summary-card--addons":"bpb-summary-card--plan",s),onClick:r,disabled:!n,children:[e.jsx(Wa,{children:a==="Add-ons"?e.jsx(Qe,{size:22}):e.jsx(He,{size:22})}),e.jsxs("div",{className:"bpb-summary-card__content",children:[e.jsxs("div",{className:"bpb-summary-card__body",children:[e.jsx("span",{className:"bpb-summary-card__eyebrow",children:a}),e.jsx("span",{className:"bpb-summary-card__title",children:"Managed in Dashboard"}),e.jsx("span",{className:"bpb-summary-card__meta",children:"This workspace uses an earlier billing system."})]}),e.jsxs("span",{className:"bpb-summary-card__action",children:["Open",e.jsx(Je,{size:15})]})]})]})},Lr=({onManage:a,className:s})=>{var C,v;const{isOutdatedBilling:n}=E(),{data:r,isLoading:t}=_e({enabled:!n}),{data:o,isLoading:l}=we();if(n)return e.jsx(Gs,{eyebrow:"Current plan",className:s});if(t||l)return e.jsx(q,{height:84,rounded:!0,className:T("bpb-scope",s)});const i=r==null?void 0:r.plan.current,c=o==null?void 0:o.find(m=>m.id===(i==null?void 0:i.planId)),h=(i==null?void 0:i.interval)??"month",b=((C=c==null?void 0:c.prices[h])==null?void 0:C.amount)??0,p=((v=c==null?void 0:c.prices[h])==null?void 0:v.currency)??"usd",y=c==null?void 0:c.features.conversation_sessions,_=c?ge(c):"community";return e.jsxs("button",{type:"button",className:T("bpb-summary-card bpb-summary-card--plan bpb-scope",`bpb-summary-card--tier-${_==="managed"?"enterprise":_}`,s),onClick:a,children:[e.jsx(Wa,{children:e.jsx(He,{size:22})}),e.jsxs("div",{className:"bpb-summary-card__content",children:[e.jsxs("div",{className:"bpb-summary-card__body",children:[e.jsx("span",{className:"bpb-summary-card__eyebrow",children:"Current plan"}),e.jsx("span",{className:"bpb-summary-card__title",children:c?ee(c.name):"No plan"}),e.jsxs("span",{className:"bpb-summary-card__meta",children:[b>0?`${j(b,p,0)}/${h==="year"?"yr":"mo"}`:"Free",y!==void 0&&` · ${se(y)} conversations/mo`]})]}),e.jsxs("span",{className:"bpb-summary-card__action",children:["Manage",e.jsx($e,{size:16})]})]})]})},Pr=({onManage:a,className:s})=>{const{isOutdatedBilling:n}=E(),{data:r,isLoading:t}=_e({enabled:!n}),{data:o,isLoading:l}=De();if(n)return e.jsx(Gs,{eyebrow:"Add-ons",className:s});if(t||l)return e.jsx(q,{height:84,rounded:!0,className:T("bpb-scope",s)});const i=(o??[]).flatMap(c=>{var b;const h=((b=r==null?void 0:r.addons[c.id])==null?void 0:b.current.quantity)??0;return h>0?[{name:Ge(c.name),quantity:h}]:[]});return e.jsxs("button",{type:"button",className:T("bpb-summary-card bpb-summary-card--addons bpb-scope",i.length>0&&"bpb-summary-card--active",s),onClick:a,children:[e.jsx(Wa,{children:e.jsx(Qe,{size:22})}),e.jsxs("div",{className:"bpb-summary-card__content",children:[e.jsxs("div",{className:"bpb-summary-card__body",children:[e.jsx("span",{className:"bpb-summary-card__eyebrow",children:"Add-ons"}),i.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"bpb-summary-card__title",children:[i.length," active add-on",i.length>1?"s":""]}),e.jsx("span",{className:"bpb-summary-card__meta",children:i.map(c=>`${c.quantity}× ${c.name}`).join(" · ")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bpb-summary-card__title",children:"No add-ons"}),e.jsx("span",{className:"bpb-summary-card__meta",children:"Add extra conversations or storage"})]})]}),e.jsxs("span",{className:"bpb-summary-card__action",children:["Manage",e.jsx($e,{size:16})]})]})]})},Er=({onManage:a,className:s})=>{var u,B;const{isOutdatedBilling:n,locale:r,manageBillingUrl:t}=E(),{data:o,isLoading:l}=_e({enabled:!n}),{data:i,isLoading:c}=we(),{data:h,isLoading:b}=De();if(n){const x=()=>t&&window.open(t,"_blank","noopener");return e.jsxs("button",{type:"button",className:T("bpb-plan-banner bpb-plan-banner--community bpb-scope",s),onClick:x,disabled:!t,children:[e.jsxs("div",{className:"bpb-plan-banner__main",children:[e.jsx("span",{className:"bpb-plan-banner__eyebrow",children:"Current plan"}),e.jsx("span",{className:"bpb-plan-banner__name",children:"Managed in Dashboard"}),e.jsx("span",{className:"bpb-plan-banner__sub",children:"This workspace uses an earlier billing system."})]}),e.jsxs("span",{className:"bpb-plan-banner__cta",children:["Open ",e.jsx(Je,{size:16})]})]})}if(l||c||b)return e.jsx(q,{height:132,rounded:!0,className:T("bpb-scope",s)});const p=o==null?void 0:o.plan.current,y=i==null?void 0:i.find(x=>x.id===(p==null?void 0:p.planId)),_=(p==null?void 0:p.interval)??"month",C=((u=y==null?void 0:y.prices[_])==null?void 0:u.currency)??"usd",v=y?ge(y):"community",m=Object.fromEntries(Object.entries((o==null?void 0:o.addons)??{}).map(([x,R])=>{var X;return[x,((X=R.current)==null?void 0:X.quantity)??0]})),S=((B=y==null?void 0:y.prices[_])==null?void 0:B.amount)??0,I=(h??[]).reduce((x,R)=>{const X=y?Ye(R,y,_):null;return x+(m[R.id]??0)*((X==null?void 0:X.amount)??0)},0),L=S+I,D=_==="year"?"/yr":"/mo",f=ws(y,h,m).find(x=>x.key==="conversation_sessions"),A=p!=null&&p.periodEnd?Se(p.periodEnd,r):null,P=v==="enterprise"||v==="managed";return e.jsxs("button",{type:"button",className:T("bpb-plan-banner",`bpb-plan-banner--${v}`,"bpb-scope",s),onClick:a,children:[e.jsxs("div",{className:"bpb-plan-banner__main",children:[e.jsx("span",{className:"bpb-plan-banner__eyebrow",children:"Current plan"}),e.jsx("span",{className:"bpb-plan-banner__name",children:y?ee(y.name):"No plan"}),f&&e.jsx("span",{className:"bpb-plan-banner__sub",children:f.added>0?e.jsxs(e.Fragment,{children:[se(f.base)," + ",se(f.added)," conversations / month"]}):`${se(f.total)} conversations / month`})]}),e.jsxs("div",{className:"bpb-plan-banner__summary",children:[P?e.jsx("span",{className:"bpb-plan-banner__price",children:"Custom pricing"}):e.jsxs("span",{className:"bpb-plan-banner__price",children:[L>0?j(L,C,0):"Free",L>0&&e.jsx("span",{className:"bpb-plan-banner__price-suffix",children:D})]}),e.jsxs("span",{className:"bpb-plan-banner__meta",children:[_==="year"?"Billed annually":"Billed monthly",I>0&&" · incl. add-ons"]}),A&&e.jsxs("span",{className:"bpb-plan-banner__meta",children:["Renews ",A]})]}),e.jsxs("span",{className:"bpb-plan-banner__cta",children:["Manage plan ",e.jsx($e,{size:16})]})]})},js=[{key:"conversation_sessions",label:"Conversations",unit:"count"},{key:"ai_spend",label:"AI spend",unit:"nano-usd"},{key:"table_rows",label:"Table rows",unit:"count"},{key:"vector_db_storage",label:"Vector DB storage",unit:"bytes"},{key:"file_storage",label:"File storage",unit:"bytes"}];function ra(a,s){return s==="bytes"?Le(a):s==="nano-usd"?`$${(a/na).toFixed(2)}`:se(a)}function ta(a){return a>=90?"critical":a>=75?"warning":"normal"}function oa(a){return a?js.flatMap(({key:s,label:n,unit:r})=>{const t=a[s];if(!t||t.quota<=0)return[];const o=t.usage??0,l=Math.max(0,Math.min(100,o/t.quota*100));return[{key:s,label:n,unit:r,used:o,quota:t.quota,remaining:Math.max(0,t.quota-o),pct:l}]}).sort((s,n)=>n.pct-s.pct):[]}const zr=({onManage:a,period:s,variant:n="card",className:r,style:t})=>{const{isOutdatedBilling:o,locale:l}=E(),{data:i,isLoading:c}=_e({enabled:!o}),{data:h,isLoading:b}=we(),{data:p,isLoading:y}=Ue({period:s,enabled:!o});if(o)return null;if(c||b||y)return e.jsx(q,{height:72,rounded:!0,className:T("bpb-scope",r)});const _=h==null?void 0:h.find(u=>u.id===(i==null?void 0:i.plan.current.planId)),C=oa(p),v=C.find(u=>u.key==="conversation_sessions"),m=C[0],S=m&&m.key!=="conversation_sessions"&&m.pct>=75?m:v??m,I=S?Math.round(S.pct):0,L=I>0?Math.max(5,I):0,D=S?ta(S.pct):"normal",f=i!=null&&i.plan.current.periodEnd?Se(i.plan.current.periodEnd,l):null,A=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bpb-plan-usage__head",children:[e.jsx("span",{className:"bpb-plan-usage__plan",children:_?ee(_.name):"Free"}),a&&e.jsx($e,{size:15,className:"bpb-plan-usage__chevron"})]}),S&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bpb-plan-usage__meta",children:[e.jsx("span",{className:"bpb-plan-usage__meta-label",children:S.label}),e.jsxs("span",{className:"bpb-plan-usage__meta-value",children:[e.jsx("strong",{children:ra(S.remaining,S.unit)})," left"]})]}),e.jsx("div",{className:"bpb-plan-usage__bar",role:"progressbar","aria-valuenow":I,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:T("bpb-plan-usage__fill",`bpb-plan-usage__fill--${D}`),style:{width:`${L}%`}})}),f&&e.jsxs("span",{className:"bpb-plan-usage__reset",children:["Resets ",f]})]})]}),P=T("bpb-plan-usage bpb-scope",`bpb-plan-usage--${n}`,a&&"bpb-plan-usage--clickable",r);return a?e.jsx("button",{type:"button",className:P,style:t,onClick:a,children:A}):e.jsx("div",{className:P,style:t,children:A})},Vs=({children:a,delay:s=200,placement:n="top",period:r,className:t})=>{const{isOutdatedBilling:o,locale:l}=E(),{data:i}=Ue({period:r,enabled:!o}),{data:c}=_e({enabled:!o}),{data:h}=we(),[b,p]=w.useState(!1),y=w.useRef(null),_=()=>{y.current&&(clearTimeout(y.current),y.current=null)};w.useEffect(()=>_,[]);const C=oa(i),v=!o&&C.length>0,m=()=>{v&&(_(),y.current=setTimeout(()=>p(!0),Math.max(0,s)))},S=()=>{_(),p(!1)},I=h==null?void 0:h.find(f=>f.id===(c==null?void 0:c.plan.current.planId)),L=I?ee(I.name):"Free",D=c!=null&&c.plan.current.periodEnd?Se(c.plan.current.periodEnd,l):null;return e.jsxs("span",{className:T("bpb-usage-pop bpb-scope",t),onMouseEnter:m,onMouseLeave:S,onFocus:m,onBlur:S,children:[a,b&&v&&e.jsxs("span",{className:T("bpb-usage-pop__card",`bpb-usage-pop__card--${n}`),role:"tooltip",children:[e.jsxs("span",{className:"bpb-usage-pop__plan",children:[e.jsxs("span",{className:"bpb-usage-pop__plan-name",children:[L," plan"]}),D&&e.jsxs("span",{className:"bpb-usage-pop__reset",children:["Resets ",D]})]}),e.jsx("span",{className:"bpb-usage-pop__title",children:"Usage this period"}),C.map(f=>{const A=f.pct>0?Math.max(5,f.pct):0;return e.jsxs("span",{className:"bpb-usage-pop__item",children:[e.jsxs("span",{className:"bpb-usage-pop__head",children:[e.jsx("span",{className:"bpb-usage-pop__name",children:f.label}),e.jsxs("span",{className:"bpb-usage-pop__val",children:[ra(f.used,f.unit)," / ",ra(f.quota,f.unit)]})]}),e.jsx("span",{className:"bpb-usage-pop__bar",children:e.jsx("span",{className:T("bpb-usage-pop__fill",`bpb-usage-pop__fill--${ta(f.pct)}`),style:{width:`${A}%`}})})]},f.key)})]})]})},Dr=({size:a=20,thickness:s=3.5,showLabel:n=!1,onClick:r,popoverDelay:t=200,period:o,className:l,...i})=>{const{isOutdatedBilling:c}=E(),{data:h}=Ue({period:o,enabled:!c}),b=oa(h);if(c||b.length===0)return null;const p=b[0],y=ta(p.pct),_=p.pct>0?Math.max(5,p.pct):0,C=(a-s)/2,v=2*Math.PI*C,m=v*(1-_/100),S=i["aria-label"]??`${Math.round(p.pct)}% of your ${p.label.toLowerCase()} used`,I=e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"bpb-usage-ring__svg",width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":!0,children:[e.jsx("circle",{className:"bpb-usage-ring__track",cx:a/2,cy:a/2,r:C,fill:"none",strokeWidth:s}),e.jsx("circle",{className:T("bpb-usage-ring__arc",`bpb-usage-ring__arc--${y}`),cx:a/2,cy:a/2,r:C,fill:"none",strokeWidth:s,strokeLinecap:"round",strokeDasharray:v,strokeDashoffset:m,transform:`rotate(-90 ${a/2} ${a/2})`})]}),n&&e.jsxs("span",{className:"bpb-usage-ring__label",children:[Math.round(p.pct),"%"]})]}),L=T("bpb-usage-ring",r&&"bpb-usage-ring--clickable"),D=r?e.jsx("button",{type:"button",className:L,onClick:r,"aria-label":S,children:I}):e.jsx("span",{className:L,tabIndex:0,role:"img","aria-label":S,children:I});return e.jsx(Vs,{delay:t,period:o,className:l,children:D})};d.AddonsSummaryCard=Pr,d.Badge=Ma,d.BankIcon=ar,d.BillingProvider=tn,d.BoltIcon=Qe,d.Button=ie,d.CalendarIcon=zs,d.CardBrandBadge=Re,d.CardIcon=La,d.ChartIcon=Ms,d.CheckIcon=Cs,d.CheckoutDialog=Os,d.ChevronDownIcon=Xe,d.ChevronLeftIcon=Ls,d.ChevronRightIcon=$e,d.CloseIcon=Ze,d.DEFAULT_FEATURE_DESCRIPTIONS=xa,d.DEFAULT_FEATURE_LABELS=Ws,d.DEFAULT_PLAN_FEATURES=Ia,d.Dialog=ye,d.DownloadIcon=Pa,d.ENTERPRISE_CONTACT_URL=fs,d.ExternalLinkIcon=Je,d.GlobeIcon=Ts,d.InfinityIcon=xs,d.InfoTooltip=ea,d.Input=aa,d.InvoicesDialog=kr,d.LayersIcon=He,d.LockIcon=sr,d.ManageAddonsDialog=fr,d.MessageIcon=Ss,d.MinusIcon=Ps,d.NANO_DOLLARS_PER_DOLLAR=na,d.OutdatedBillingGate=Pe,d.PLAN_ORDER=We,d.PaintIcon=Bs,d.PaymentMethodDialog=wr,d.PlanBanner=Er,d.PlanSummaryCard=Lr,d.PlanUsageWidget=zr,d.PlusIcon=Es,d.PuzzleIcon=Is,d.ReceiptIcon=rr,d.SegmentedControl=Ds,d.Select=Oa,d.ShieldIcon=Ba,d.Skeleton=q,d.SparkleIcon=Ta,d.Stepper=qs,d.USAGE_METRICS=js,d.UpgradePlanDialog=Us,d.UsageBanner=Br,d.UsageDashboard=Mr,d.UsagePopover=Vs,d.UsageRing=Dr,d.UsersIcon=As,d.addDays=gs,d.addonDisplayName=Ge,d.addonLimitsPreview=Ns,d.addonPrice=Ye,d.billingKeys=ae,d.cn=T,d.conversationPackPrice=Aa,d.conversationsAddon=vs,d.currencySymbol=ys,d.featureDescription=_s,d.featureLabel=Sr,d.formatBytes=Le,d.formatCurrency=j,d.formatDate=Se,d.formatQuantity=se,d.formatUsage=ra,d.getCardElementStyle=$a,d.getStripeAppearance=Ua,d.getStripePromise=ja,d.iconForFeature=Ea,d.planDisplayName=ee,d.planEntitlements=ws,d.planKind=ge,d.toStripeLocale=Fa,d.usageItems=oa,d.usageTier=ta,d.useAddons=De,d.useBilling=E,d.useBillingAddress=ha,d.useBillingReadonly=ga,d.useCreatePaymentMethodIntent=ya,d.useCustomer=ma,d.useInvoices=Va,d.usePaymentMethod=ua,d.usePlans=we,d.useSetAddons=Ha,d.useSetBillingAddress=_a,d.useSetCustomer=va,d.useSetPaymentMethod=fa,d.useSetSubscription=ka,d.useSubscription=_e,d.useSubscriptionPreview=pa,d.useSupportsUsageByBot=Ya,d.useUsage=Ue,d.useUsageByBot=Ka,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("@tanstack/react-query"),require("react"),require("@stripe/stripe-js"),require("react-dom"),require("@stripe/react-stripe-js")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@tanstack/react-query","react","@stripe/stripe-js","react-dom","@stripe/react-stripe-js"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.BillingUI={},d.ReactJsxRuntime,d.ReactQuery,d.React,d.StripeJs,d.ReactDOM,d.ReactStripeJs))})(this,function(d,e,oe,N,nn,rn,ye){"use strict";const ja=new Map;function Ya(a){let s=ja.get(a);return s||(s=nn.loadStripe(a,{developerTools:{assistant:{enabled:!1}}}),ja.set(a,s)),s}const ua=N.createContext(null),tn={capture:()=>{}};function on(a){const[s,n]=N.useState(()=>typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches);return N.useEffect(()=>{if(a!=="system")return;const r=window.matchMedia("(prefers-color-scheme: dark)"),t=o=>n(o.matches);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)},[a]),a==="system"?s:a==="dark"}const ln=({client:a,stripePublishableKey:s,email:n,locale:r="en-US",theme:t="light",onToast:o,analytics:l,featureLabels:c,billingVersion:i,workspaceId:h,persist:m=!0,manageBillingUrl:b,onBillingChange:y,refreshInterval:f=3e4,children:w})=>{const C=h||"default",[u]=N.useState(()=>new oe.QueryClient({defaultOptions:{queries:{retry:1,staleTime:3e4,gcTime:1e3*60*60}}})),_=on(t),A=N.useMemo(()=>Ya(s),[s]);N.useEffect(()=>{if(!m||typeof window>"u")return;const E=`bpb-cache:${C}`;try{const x=window.localStorage.getItem(E);x&&oe.hydrate(u,JSON.parse(x))}catch{window.localStorage.removeItem(E)}let p=null;const B=u.getQueryCache().subscribe(x=>{x.type!=="added"&&x.type!=="removed"&&x.type!=="updated"||(p&&clearTimeout(p),p=setTimeout(()=>{try{window.localStorage.setItem(E,JSON.stringify(oe.dehydrate(u)))}catch{}},250))});return()=>{p&&clearTimeout(p),B()}},[m,C,u]);const O=N.useCallback(()=>u.invalidateQueries({queryKey:["bpb",C]}),[u,C]),M=N.useCallback(E=>y==null?void 0:y(E),[y]),S=f>0?f:!1,I=N.useMemo(()=>({client:a,queryClient:u,scope:C,stripePromise:A,email:n,locale:r,isDark:_,toast:o??(()=>{}),analytics:l??tn,featureLabels:c,isOutdatedBilling:i!==void 0&&i!=="v4",manageBillingUrl:b,refetchInterval:S,refresh:O,notifyBillingChange:M}),[a,u,C,A,n,r,_,o,l,c,i,b,S,O,M]);return e.jsx(ua.Provider,{value:I,children:e.jsx("div",{className:"bpb-scope","data-bpb-theme":_?"dark":"light",style:{display:"contents"},children:w})})};function P(){const a=N.useContext(ua);if(!a)throw new Error("@bpinternal/billing-ui components must be rendered inside <BillingProvider>");return a}function cn(){var a;return((a=N.useContext(ua))==null?void 0:a.isDark)??!1}const le={PLAN_PICKER_VIEWED:"billing_plan_picker_viewed",PLAN_INTERVAL_TOGGLED:"billing_plan_interval_toggled",PLAN_UPGRADE_INITIATED:"billing_plan_upgrade_initiated",PLAN_DOWNGRADED:"billing_plan_downgraded",PLAN_DOWNGRADE_CANCELLED:"billing_plan_downgrade_cancelled",CHECKOUT_STEP_VIEWED:"billing_checkout_step_viewed",CHECKOUT_INTERVAL_CHANGED:"billing_checkout_interval_changed",PAYMENT_METHOD_SELECTED:"billing_payment_method_selected",PAYMENT_DETAILS_CONFIRMED:"billing_payment_details_confirmed",PLAN_UPGRADED:"billing_plan_upgraded",CHECKOUT_ERROR:"billing_checkout_error",PAYMENT_METHOD_UPDATED:"billing_payment_method_updated",BILLING_ADDRESS_UPDATED:"billing_address_updated",INVOICE_DOWNLOADED:"billing_invoice_downloaded",UPGRADE_CTA_CLICKED:"billing_upgrade_cta_clicked"},se={root:a=>["bpb",a],plans:a=>["bpb",a,"plans"],addons:a=>["bpb",a,"addons"],subscription:a=>["bpb",a,"subscription"],preview:(a,s)=>["bpb",a,"preview",s],paymentMethod:a=>["bpb",a,"payment-method"],billingAddress:a=>["bpb",a,"billing-address"],customer:a=>["bpb",a,"customer"],invoices:a=>["bpb",a,"invoices"],readonly:a=>["bpb",a,"billing-readonly"],usages:(a,s)=>["bpb",a,"usages",s],bots:a=>["bpb",a,"bots"],usageByBot:(a,s,n)=>["bpb",a,"usage-by-bot",s,n]};function Ie(){const{client:a,queryClient:s,scope:n}=P();return oe.useQuery({queryKey:se.plans(n),queryFn:()=>a.listPlans({})},s)}function qe(){const{client:a,queryClient:s,scope:n}=P();return oe.useQuery({queryKey:se.addons(n),queryFn:()=>a.listAddons({})},s)}function ke(a){const{client:s,queryClient:n,scope:r,refetchInterval:t}=P();return oe.useQuery({queryKey:se.subscription(r),queryFn:()=>s.getSubscription({}),enabled:(a==null?void 0:a.enabled)??!0,refetchInterval:t},n)}function ha(a,s){const{client:n,queryClient:r,scope:t}=P();return oe.useQuery({queryKey:se.preview(t,a),queryFn:()=>n.previewSubscriptionUpdate(a),enabled:(s==null?void 0:s.enabled)??!0},r)}function ma(a){const{client:s,queryClient:n,scope:r}=P();return oe.useQuery({queryKey:se.paymentMethod(r),queryFn:()=>s.getPaymentMethod({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function ga(a){const{client:s,queryClient:n,scope:r}=P();return oe.useQuery({queryKey:se.billingAddress(r),queryFn:()=>s.getBillingAddress({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function ya(a){const{client:s,queryClient:n,scope:r}=P();return oe.useQuery({queryKey:se.customer(r),queryFn:()=>s.getCustomer({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function Ha(a){const{client:s,queryClient:n,scope:r,refetchInterval:t}=P();return oe.useQuery({queryKey:se.invoices(r),queryFn:()=>s.listInvoices({}),enabled:(a==null?void 0:a.enabled)??!0,refetchInterval:t},n)}function fa(a){const{client:s,queryClient:n,scope:r}=P();return oe.useQuery({queryKey:se.readonly(r),queryFn:()=>s.getBillingReadonly({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function We(a){const{client:s,queryClient:n,scope:r,refetchInterval:t}=P(),o=a!=null&&a.period?new Date(a.period):new Date,l=`${o.getUTCFullYear()}-${String(o.getUTCMonth()+1).padStart(2,"0")}`;return oe.useQuery({queryKey:se.usages(r,l),queryFn:()=>s.getWorkspaceUsages({period:`${l}-01T00:00:00.000Z`}).then(c=>c.quotas),enabled:(a==null?void 0:a.enabled)??!0,refetchInterval:t},n)}function Qa(a,s){const{client:n,queryClient:r,scope:t,refetchInterval:o}=P(),l=n.breakDownWorkspaceUsageByBot,c=n.listBots,i=typeof l=="function"&&typeof c=="function",h=s!=null&&s.period?new Date(s.period):new Date,m=`${h.getUTCFullYear()}-${String(h.getUTCMonth()+1).padStart(2,"0")}`;return oe.useQuery({queryKey:se.usageByBot(t,a,m),queryFn:async()=>{const[b,y]=await Promise.all([l({id:t,type:a,period:`${m}-01T00:00:00.000Z`}),c({})]),f=new Map(y.bots.map(w=>[w.id,w.name]));return b.data.map(w=>({botId:w.botId,name:f.get(w.botId)??w.botId,value:w.value})).sort((w,C)=>C.value-w.value)},enabled:i&&((s==null?void 0:s.enabled)??!0),refetchInterval:o},r)}function Za(){const{client:a}=P();return typeof a.breakDownWorkspaceUsageByBot=="function"&&typeof a.listBots=="function"}function _a(){const{client:a,queryClient:s}=P();return oe.useMutation({mutationFn:()=>a.createPaymentMethodIntent({})},s)}function va(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=P();return oe.useMutation({mutationFn:t=>a.setPaymentMethod(t),onSuccess:async()=>{await s.invalidateQueries({queryKey:se.paymentMethod(n)}),r({type:"payment-method"})}},s)}function ka(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=P();return oe.useMutation({mutationFn:async t=>{await a.setBillingAddress(t)},onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:se.billingAddress(n)}),s.invalidateQueries({queryKey:se.customer(n)})]),r({type:"billing-address"})}},s)}function Na(){const{client:a,queryClient:s,scope:n}=P();return oe.useMutation({mutationFn:r=>a.setCustomer(r),onSuccess:()=>s.invalidateQueries({queryKey:se.customer(n)})},s)}function Xa(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=P();return oe.useMutation({mutationFn:async t=>{await a.setAddons(t)},onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:se.subscription(n)}),s.invalidateQueries({queryKey:se.invoices(n)}),s.invalidateQueries({queryKey:["bpb",n,"preview"]})]),r({type:"addons"})}},s)}function wa(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=P();return oe.useMutation({mutationFn:async t=>{await a.setPlan({planId:t.planId,interval:t.interval,couponCode:t.couponCode}),t.addons&&Object.keys(t.addons).length>0&&await a.setAddons({addons:t.addons,couponCode:t.couponCode})},onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:se.subscription(n)}),s.invalidateQueries({queryKey:se.plans(n)}),s.invalidateQueries({queryKey:se.invoices(n)}),s.invalidateQueries({queryKey:["bpb",n,"preview"]})]),r({type:"subscription"})}},s)}function Ja(a){var s,n,r="";if(typeof a=="string"||typeof a=="number")r+=a;else if(typeof a=="object")if(Array.isArray(a)){var t=a.length;for(s=0;s<t;s++)a[s]&&(n=Ja(a[s]))&&(r&&(r+=" "),r+=n)}else for(n in a)a[n]&&(r&&(r+=" "),r+=n);return r}function dn(){for(var a,s,n=0,r="",t=arguments.length;n<t;n++)(a=arguments[n])&&(s=Ja(a))&&(r&&(r+=" "),r+=s);return r}const bn=(a,s)=>{const n=new Array(a.length+s.length);for(let r=0;r<a.length;r++)n[r]=a[r];for(let r=0;r<s.length;r++)n[a.length+r]=s[r];return n},pn=(a,s)=>({classGroupId:a,validator:s}),Ra=(a=new Map,s=null,n)=>({nextPart:a,validators:s,classGroupId:n}),Ze="-",es=[],un="arbitrary..",hn=a=>{const s=gn(a),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=a;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return mn(l);const c=l.split(Ze),i=c[0]===""&&c.length>1?1:0;return as(c,i,s)},getConflictingClassGroupIds:(l,c)=>{if(c){const i=r[l],h=n[l];return i?h?bn(h,i):i:h||es}return n[l]||es}}},as=(a,s,n)=>{if(a.length-s===0)return n.classGroupId;const t=a[s],o=n.nextPart.get(t);if(o){const h=as(a,s+1,o);if(h)return h}const l=n.validators;if(l===null)return;const c=s===0?a.join(Ze):a.slice(s).join(Ze),i=l.length;for(let h=0;h<i;h++){const m=l[h];if(m.validator(c))return m.classGroupId}},mn=a=>a.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const s=a.slice(1,-1),n=s.indexOf(":"),r=s.slice(0,n);return r?un+r:void 0})(),gn=a=>{const{theme:s,classGroups:n}=a;return yn(n,s)},yn=(a,s)=>{const n=Ra();for(const r in a){const t=a[r];Ca(t,n,r,s)}return n},Ca=(a,s,n,r)=>{const t=a.length;for(let o=0;o<t;o++){const l=a[o];fn(l,s,n,r)}},fn=(a,s,n,r)=>{if(typeof a=="string"){_n(a,s,n);return}if(typeof a=="function"){vn(a,s,n,r);return}kn(a,s,n,r)},_n=(a,s,n)=>{const r=a===""?s:ss(s,a);r.classGroupId=n},vn=(a,s,n,r)=>{if(Nn(a)){Ca(a(r),s,n,r);return}s.validators===null&&(s.validators=[]),s.validators.push(pn(n,a))},kn=(a,s,n,r)=>{const t=Object.entries(a),o=t.length;for(let l=0;l<o;l++){const[c,i]=t[l];Ca(i,ss(s,c),n,r)}},ss=(a,s)=>{let n=a;const r=s.split(Ze),t=r.length;for(let o=0;o<t;o++){const l=r[o];let c=n.nextPart.get(l);c||(c=Ra(),n.nextPart.set(l,c)),n=c}return n},Nn=a=>"isThemeGetter"in a&&a.isThemeGetter===!0,wn=a=>{if(a<1)return{get:()=>{},set:()=>{}};let s=0,n=Object.create(null),r=Object.create(null);const t=(o,l)=>{n[o]=l,s++,s>a&&(s=0,r=n,n=Object.create(null))};return{get(o){let l=n[o];if(l!==void 0)return l;if((l=r[o])!==void 0)return t(o,l),l},set(o,l){o in n?n[o]=l:t(o,l)}}},Sa="!",ns=":",Cn=[],rs=(a,s,n,r,t)=>({modifiers:a,hasImportantModifier:s,baseClassName:n,maybePostfixModifierPosition:r,isExternal:t}),Sn=a=>{const{prefix:s,experimentalParseClassName:n}=a;let r=t=>{const o=[];let l=0,c=0,i=0,h;const m=t.length;for(let C=0;C<m;C++){const u=t[C];if(l===0&&c===0){if(u===ns){o.push(t.slice(i,C)),i=C+1;continue}if(u==="/"){h=C;continue}}u==="["?l++:u==="]"?l--:u==="("?c++:u===")"&&c--}const b=o.length===0?t:t.slice(i);let y=b,f=!1;b.endsWith(Sa)?(y=b.slice(0,-1),f=!0):b.startsWith(Sa)&&(y=b.slice(1),f=!0);const w=h&&h>i?h-i:void 0;return rs(o,f,y,w)};if(s){const t=s+ns,o=r;r=l=>l.startsWith(t)?o(l.slice(t.length)):rs(Cn,!1,l,void 0,!0)}if(n){const t=r;r=o=>n({className:o,parseClassName:t})}return r},In=a=>{const s=new Map;return a.orderSensitiveModifiers.forEach((n,r)=>{s.set(n,1e6+r)}),n=>{const r=[];let t=[];for(let o=0;o<n.length;o++){const l=n[o],c=l[0]==="[",i=s.has(l);c||i?(t.length>0&&(t.sort(),r.push(...t),t=[]),r.push(l)):t.push(l)}return t.length>0&&(t.sort(),r.push(...t)),r}},An=a=>({cache:wn(a.cacheSize),parseClassName:Sn(a),sortModifiers:In(a),postfixLookupClassGroupIds:En(a),...hn(a)}),En=a=>{const s=Object.create(null),n=a.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)s[n[r]]=!0;return s},Tn=/\s+/,xn=(a,s)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:t,sortModifiers:o,postfixLookupClassGroupIds:l}=s,c=[],i=a.trim().split(Tn);let h="";for(let m=i.length-1;m>=0;m-=1){const b=i[m],{isExternal:y,modifiers:f,hasImportantModifier:w,baseClassName:C,maybePostfixModifierPosition:u}=n(b);if(y){h=b+(h.length>0?" "+h:h);continue}let _=!!u,A;if(_){const E=C.substring(0,u);A=r(E);const p=A&&l[A]?r(C):void 0;p&&p!==A&&(A=p,_=!1)}else A=r(C);if(!A){if(!_){h=b+(h.length>0?" "+h:h);continue}if(A=r(C),!A){h=b+(h.length>0?" "+h:h);continue}_=!1}const O=f.length===0?"":f.length===1?f[0]:o(f).join(":"),M=w?O+Sa:O,S=M+A;if(c.indexOf(S)>-1)continue;c.push(S);const I=t(A,_);for(let E=0;E<I.length;++E){const p=I[E];c.push(M+p)}h=b+(h.length>0?" "+h:h)}return h},Ln=(...a)=>{let s=0,n,r,t="";for(;s<a.length;)(n=a[s++])&&(r=ts(n))&&(t&&(t+=" "),t+=r);return t},ts=a=>{if(typeof a=="string")return a;let s,n="";for(let r=0;r<a.length;r++)a[r]&&(s=ts(a[r]))&&(n&&(n+=" "),n+=s);return n},Mn=(a,...s)=>{let n,r,t,o;const l=i=>{const h=s.reduce((m,b)=>b(m),a());return n=An(h),r=n.cache.get,t=n.cache.set,o=c,c(i)},c=i=>{const h=r(i);if(h)return h;const m=xn(i,n);return t(i,m),m};return o=l,(...i)=>o(Ln(...i))},Pn=[],ce=a=>{const s=n=>n[a]||Pn;return s.isThemeGetter=!0,s},os=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ls=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Dn=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Bn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,zn=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Un=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,On=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$n=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xe=a=>Dn.test(a),D=a=>!!a&&!Number.isNaN(Number(a)),Ne=a=>!!a&&Number.isInteger(Number(a)),Ia=a=>a.endsWith("%")&&D(a.slice(0,-1)),Ae=a=>Bn.test(a),cs=()=>!0,Fn=a=>zn.test(a)&&!Un.test(a),Aa=()=>!1,qn=a=>On.test(a),Wn=a=>$n.test(a),Gn=a=>!v(a)&&!k(a),Vn=a=>a.startsWith("@container")&&(a[10]==="/"&&a[11]!==void 0||a[11]==="s"&&a[16]!==void 0&&a.startsWith("-size/",10)||a[11]==="n"&&a[18]!==void 0&&a.startsWith("-normal/",10)),Kn=a=>Le(a,hs,Aa),v=a=>os.test(a),Pe=a=>Le(a,ms,Fn),is=a=>Le(a,Rn,D),jn=a=>Le(a,ys,cs),Yn=a=>Le(a,gs,Aa),ds=a=>Le(a,ps,Aa),Hn=a=>Le(a,us,Wn),Xe=a=>Le(a,fs,qn),k=a=>ls.test(a),je=a=>De(a,ms),Qn=a=>De(a,gs),bs=a=>De(a,ps),Zn=a=>De(a,hs),Xn=a=>De(a,us),Je=a=>De(a,fs,!0),Jn=a=>De(a,ys,!0),Le=(a,s,n)=>{const r=os.exec(a);return r?r[1]?s(r[1]):n(r[2]):!1},De=(a,s,n=!1)=>{const r=ls.exec(a);return r?r[1]?s(r[1]):n:!1},ps=a=>a==="position"||a==="percentage",us=a=>a==="image"||a==="url",hs=a=>a==="length"||a==="size"||a==="bg-size",ms=a=>a==="length",Rn=a=>a==="number",gs=a=>a==="family-name",ys=a=>a==="number"||a==="weight",fs=a=>a==="shadow",er=Mn(()=>{const a=ce("color"),s=ce("font"),n=ce("text"),r=ce("font-weight"),t=ce("tracking"),o=ce("leading"),l=ce("breakpoint"),c=ce("container"),i=ce("spacing"),h=ce("radius"),m=ce("shadow"),b=ce("inset-shadow"),y=ce("text-shadow"),f=ce("drop-shadow"),w=ce("blur"),C=ce("perspective"),u=ce("aspect"),_=ce("ease"),A=ce("animate"),O=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...M(),k,v],I=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],p=()=>[k,v,i],B=()=>[xe,"full","auto",...p()],x=()=>[Ne,"none","subgrid",k,v],Y=()=>["auto",{span:["full",Ne,k,v]},Ne,k,v],Z=()=>[Ne,"auto",k,v],ae=()=>["auto","min","max","fr",k,v],pe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],de=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...p()],J=()=>[xe,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...p()],ue=()=>[xe,"screen","full","dvw","lvw","svw","min","max","fit",...p()],T=()=>[xe,"screen","full","lh","dvh","lvh","svh","min","max","fit",...p()],g=()=>[a,k,v],U=()=>[...M(),bs,ds,{position:[k,v]}],W=()=>["no-repeat",{repeat:["","x","y","space","round"]}],F=()=>["auto","cover","contain",Zn,Kn,{size:[k,v]}],re=()=>[Ia,je,Pe],q=()=>["","none","full",h,k,v],j=()=>["",D,je,Pe],we=()=>["solid","dashed","dotted","double"],Ce=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],G=()=>[D,Ia,bs,ds],R=()=>["","none",w,k,v],te=()=>["none",D,k,v],Se=()=>["none",D,k,v],he=()=>[D,k,v],me=()=>[xe,"full",...p()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ae],breakpoint:[Ae],color:[cs],container:[Ae],"drop-shadow":[Ae],ease:["in","out","in-out"],font:[Gn],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ae],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ae],shadow:[Ae],spacing:["px",D],text:[Ae],"text-shadow":[Ae],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",xe,v,k,u]}],container:["container"],"container-type":[{"@container":["","normal","size",k,v]}],"container-named":[Vn],columns:[{columns:[D,v,k,c]}],"break-after":[{"break-after":O()}],"break-before":[{"break-before":O()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:S()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:B()}],"inset-x":[{"inset-x":B()}],"inset-y":[{"inset-y":B()}],start:[{"inset-s":B(),start:B()}],end:[{"inset-e":B(),end:B()}],"inset-bs":[{"inset-bs":B()}],"inset-be":[{"inset-be":B()}],top:[{top:B()}],right:[{right:B()}],bottom:[{bottom:B()}],left:[{left:B()}],visibility:["visible","invisible","collapse"],z:[{z:[Ne,"auto",k,v]}],basis:[{basis:[xe,"full","auto",c,...p()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[D,xe,"auto","initial","none",v]}],grow:[{grow:["",D,k,v]}],shrink:[{shrink:["",D,k,v]}],order:[{order:[Ne,"first","last","none",k,v]}],"grid-cols":[{"grid-cols":x()}],"col-start-end":[{col:Y()}],"col-start":[{"col-start":Z()}],"col-end":[{"col-end":Z()}],"grid-rows":[{"grid-rows":x()}],"row-start-end":[{row:Y()}],"row-start":[{"row-start":Z()}],"row-end":[{"row-end":Z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ae()}],"auto-rows":[{"auto-rows":ae()}],gap:[{gap:p()}],"gap-x":[{"gap-x":p()}],"gap-y":[{"gap-y":p()}],"justify-content":[{justify:[...pe(),"normal"]}],"justify-items":[{"justify-items":[...de(),"normal"]}],"justify-self":[{"justify-self":["auto",...de()]}],"align-content":[{content:["normal",...pe()]}],"align-items":[{items:[...de(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...de(),{baseline:["","last"]}]}],"place-content":[{"place-content":pe()}],"place-items":[{"place-items":[...de(),"baseline"]}],"place-self":[{"place-self":["auto",...de()]}],p:[{p:p()}],px:[{px:p()}],py:[{py:p()}],ps:[{ps:p()}],pe:[{pe:p()}],pbs:[{pbs:p()}],pbe:[{pbe:p()}],pt:[{pt:p()}],pr:[{pr:p()}],pb:[{pb:p()}],pl:[{pl:p()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mbs:[{mbs:z()}],mbe:[{mbe:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":p()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":p()}],"space-y-reverse":["space-y-reverse"],size:[{size:J()}],"inline-size":[{inline:["auto",...ue()]}],"min-inline-size":[{"min-inline":["auto",...ue()]}],"max-inline-size":[{"max-inline":["none",...ue()]}],"block-size":[{block:["auto",...T()]}],"min-block-size":[{"min-block":["auto",...T()]}],"max-block-size":[{"max-block":["none",...T()]}],w:[{w:[c,"screen",...J()]}],"min-w":[{"min-w":[c,"screen","none",...J()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[l]},...J()]}],h:[{h:["screen","lh",...J()]}],"min-h":[{"min-h":["screen","lh","none",...J()]}],"max-h":[{"max-h":["screen","lh",...J()]}],"font-size":[{text:["base",n,je,Pe]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Jn,jn]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ia,v]}],"font-family":[{font:[Qn,Yn,s]}],"font-features":[{"font-features":[v]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[t,k,v]}],"line-clamp":[{"line-clamp":[D,"none",k,is]}],leading:[{leading:[o,...p()]}],"list-image":[{"list-image":["none",k,v]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",k,v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:g()}],"text-color":[{text:g()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...we(),"wavy"]}],"text-decoration-thickness":[{decoration:[D,"from-font","auto",k,Pe]}],"text-decoration-color":[{decoration:g()}],"underline-offset":[{"underline-offset":[D,"auto",k,v]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:p()}],"tab-size":[{tab:[Ne,k,v]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",k,v]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",k,v]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:U()}],"bg-repeat":[{bg:W()}],"bg-size":[{bg:F()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ne,k,v],radial:["",k,v],conic:[Ne,k,v]},Xn,Hn]}],"bg-color":[{bg:g()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:g()}],"gradient-via":[{via:g()}],"gradient-to":[{to:g()}],rounded:[{rounded:q()}],"rounded-s":[{"rounded-s":q()}],"rounded-e":[{"rounded-e":q()}],"rounded-t":[{"rounded-t":q()}],"rounded-r":[{"rounded-r":q()}],"rounded-b":[{"rounded-b":q()}],"rounded-l":[{"rounded-l":q()}],"rounded-ss":[{"rounded-ss":q()}],"rounded-se":[{"rounded-se":q()}],"rounded-ee":[{"rounded-ee":q()}],"rounded-es":[{"rounded-es":q()}],"rounded-tl":[{"rounded-tl":q()}],"rounded-tr":[{"rounded-tr":q()}],"rounded-br":[{"rounded-br":q()}],"rounded-bl":[{"rounded-bl":q()}],"border-w":[{border:j()}],"border-w-x":[{"border-x":j()}],"border-w-y":[{"border-y":j()}],"border-w-s":[{"border-s":j()}],"border-w-e":[{"border-e":j()}],"border-w-bs":[{"border-bs":j()}],"border-w-be":[{"border-be":j()}],"border-w-t":[{"border-t":j()}],"border-w-r":[{"border-r":j()}],"border-w-b":[{"border-b":j()}],"border-w-l":[{"border-l":j()}],"divide-x":[{"divide-x":j()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":j()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...we(),"hidden","none"]}],"divide-style":[{divide:[...we(),"hidden","none"]}],"border-color":[{border:g()}],"border-color-x":[{"border-x":g()}],"border-color-y":[{"border-y":g()}],"border-color-s":[{"border-s":g()}],"border-color-e":[{"border-e":g()}],"border-color-bs":[{"border-bs":g()}],"border-color-be":[{"border-be":g()}],"border-color-t":[{"border-t":g()}],"border-color-r":[{"border-r":g()}],"border-color-b":[{"border-b":g()}],"border-color-l":[{"border-l":g()}],"divide-color":[{divide:g()}],"outline-style":[{outline:[...we(),"none","hidden"]}],"outline-offset":[{"outline-offset":[D,k,v]}],"outline-w":[{outline:["",D,je,Pe]}],"outline-color":[{outline:g()}],shadow:[{shadow:["","none",m,Je,Xe]}],"shadow-color":[{shadow:g()}],"inset-shadow":[{"inset-shadow":["none",b,Je,Xe]}],"inset-shadow-color":[{"inset-shadow":g()}],"ring-w":[{ring:j()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:g()}],"ring-offset-w":[{"ring-offset":[D,Pe]}],"ring-offset-color":[{"ring-offset":g()}],"inset-ring-w":[{"inset-ring":j()}],"inset-ring-color":[{"inset-ring":g()}],"text-shadow":[{"text-shadow":["none",y,Je,Xe]}],"text-shadow-color":[{"text-shadow":g()}],opacity:[{opacity:[D,k,v]}],"mix-blend":[{"mix-blend":[...Ce(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Ce()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[D]}],"mask-image-linear-from-pos":[{"mask-linear-from":G()}],"mask-image-linear-to-pos":[{"mask-linear-to":G()}],"mask-image-linear-from-color":[{"mask-linear-from":g()}],"mask-image-linear-to-color":[{"mask-linear-to":g()}],"mask-image-t-from-pos":[{"mask-t-from":G()}],"mask-image-t-to-pos":[{"mask-t-to":G()}],"mask-image-t-from-color":[{"mask-t-from":g()}],"mask-image-t-to-color":[{"mask-t-to":g()}],"mask-image-r-from-pos":[{"mask-r-from":G()}],"mask-image-r-to-pos":[{"mask-r-to":G()}],"mask-image-r-from-color":[{"mask-r-from":g()}],"mask-image-r-to-color":[{"mask-r-to":g()}],"mask-image-b-from-pos":[{"mask-b-from":G()}],"mask-image-b-to-pos":[{"mask-b-to":G()}],"mask-image-b-from-color":[{"mask-b-from":g()}],"mask-image-b-to-color":[{"mask-b-to":g()}],"mask-image-l-from-pos":[{"mask-l-from":G()}],"mask-image-l-to-pos":[{"mask-l-to":G()}],"mask-image-l-from-color":[{"mask-l-from":g()}],"mask-image-l-to-color":[{"mask-l-to":g()}],"mask-image-x-from-pos":[{"mask-x-from":G()}],"mask-image-x-to-pos":[{"mask-x-to":G()}],"mask-image-x-from-color":[{"mask-x-from":g()}],"mask-image-x-to-color":[{"mask-x-to":g()}],"mask-image-y-from-pos":[{"mask-y-from":G()}],"mask-image-y-to-pos":[{"mask-y-to":G()}],"mask-image-y-from-color":[{"mask-y-from":g()}],"mask-image-y-to-color":[{"mask-y-to":g()}],"mask-image-radial":[{"mask-radial":[k,v]}],"mask-image-radial-from-pos":[{"mask-radial-from":G()}],"mask-image-radial-to-pos":[{"mask-radial-to":G()}],"mask-image-radial-from-color":[{"mask-radial-from":g()}],"mask-image-radial-to-color":[{"mask-radial-to":g()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":M()}],"mask-image-conic-pos":[{"mask-conic":[D]}],"mask-image-conic-from-pos":[{"mask-conic-from":G()}],"mask-image-conic-to-pos":[{"mask-conic-to":G()}],"mask-image-conic-from-color":[{"mask-conic-from":g()}],"mask-image-conic-to-color":[{"mask-conic-to":g()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:U()}],"mask-repeat":[{mask:W()}],"mask-size":[{mask:F()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",k,v]}],filter:[{filter:["","none",k,v]}],blur:[{blur:R()}],brightness:[{brightness:[D,k,v]}],contrast:[{contrast:[D,k,v]}],"drop-shadow":[{"drop-shadow":["","none",f,Je,Xe]}],"drop-shadow-color":[{"drop-shadow":g()}],grayscale:[{grayscale:["",D,k,v]}],"hue-rotate":[{"hue-rotate":[D,k,v]}],invert:[{invert:["",D,k,v]}],saturate:[{saturate:[D,k,v]}],sepia:[{sepia:["",D,k,v]}],"backdrop-filter":[{"backdrop-filter":["","none",k,v]}],"backdrop-blur":[{"backdrop-blur":R()}],"backdrop-brightness":[{"backdrop-brightness":[D,k,v]}],"backdrop-contrast":[{"backdrop-contrast":[D,k,v]}],"backdrop-grayscale":[{"backdrop-grayscale":["",D,k,v]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[D,k,v]}],"backdrop-invert":[{"backdrop-invert":["",D,k,v]}],"backdrop-opacity":[{"backdrop-opacity":[D,k,v]}],"backdrop-saturate":[{"backdrop-saturate":[D,k,v]}],"backdrop-sepia":[{"backdrop-sepia":["",D,k,v]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":p()}],"border-spacing-x":[{"border-spacing-x":p()}],"border-spacing-y":[{"border-spacing-y":p()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",k,v]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[D,"initial",k,v]}],ease:[{ease:["linear","initial",_,k,v]}],delay:[{delay:[D,k,v]}],animate:[{animate:["none",A,k,v]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[C,k,v]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:Se()}],"scale-x":[{"scale-x":Se()}],"scale-y":[{"scale-y":Se()}],"scale-z":[{"scale-z":Se()}],"scale-3d":["scale-3d"],skew:[{skew:he()}],"skew-x":[{"skew-x":he()}],"skew-y":[{"skew-y":he()}],transform:[{transform:[k,v,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:me()}],"translate-x":[{"translate-x":me()}],"translate-y":[{"translate-y":me()}],"translate-z":[{"translate-z":me()}],"translate-none":["translate-none"],zoom:[{zoom:[Ne,k,v]}],accent:[{accent:g()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:g()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",k,v]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":g()}],"scrollbar-track-color":[{"scrollbar-track":g()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":p()}],"scroll-mx":[{"scroll-mx":p()}],"scroll-my":[{"scroll-my":p()}],"scroll-ms":[{"scroll-ms":p()}],"scroll-me":[{"scroll-me":p()}],"scroll-mbs":[{"scroll-mbs":p()}],"scroll-mbe":[{"scroll-mbe":p()}],"scroll-mt":[{"scroll-mt":p()}],"scroll-mr":[{"scroll-mr":p()}],"scroll-mb":[{"scroll-mb":p()}],"scroll-ml":[{"scroll-ml":p()}],"scroll-p":[{"scroll-p":p()}],"scroll-px":[{"scroll-px":p()}],"scroll-py":[{"scroll-py":p()}],"scroll-ps":[{"scroll-ps":p()}],"scroll-pe":[{"scroll-pe":p()}],"scroll-pbs":[{"scroll-pbs":p()}],"scroll-pbe":[{"scroll-pbe":p()}],"scroll-pt":[{"scroll-pt":p()}],"scroll-pr":[{"scroll-pr":p()}],"scroll-pb":[{"scroll-pb":p()}],"scroll-pl":[{"scroll-pl":p()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",k,v]}],fill:[{fill:["none",...g()]}],"stroke-w":[{stroke:[D,je,Pe,is]}],stroke:[{stroke:["none",...g()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function L(...a){return er(dn(a))}function K(a,s="usd",n=2){return new Intl.NumberFormat("en-US",{style:"currency",currency:s.toUpperCase(),minimumFractionDigits:n,maximumFractionDigits:n}).format(a)}function Ee(a,s="en-US"){return new Date(a).toLocaleDateString(s,{month:"short",day:"numeric",year:"numeric"})}function _s(a,s){const n=new Date(a);return n.setDate(n.getDate()+s),n.toISOString()}function ne(a){return new Intl.NumberFormat("en-US").format(a)}function Be(a){if(a<=0)return"0 MB";const s=a/1e9;if(s>=1)return`${Number.isInteger(s)?s:s.toFixed(1)} GB`;const n=a/1e6;return`${Number.isInteger(n)?n:n.toFixed(0)} MB`}function ee(a){return a.replace("Plan - ","")}function vs(a){return{usd:"$",eur:"€",gbp:"£",cad:"$",aud:"$",jpy:"¥"}[a.toLowerCase()]??`${a.toUpperCase()} `}const Ye=["community","plus","team","enterprise","managed"],ar=["community","plus","team","enterprise","managed"];function fe(a){var r;const s=a.name.toLowerCase();if(s.includes("community")||s.includes("pay-as-you-go")||s.includes("free"))return"community";if(s.includes("plus"))return"plus";if(s.includes("team"))return"team";if(s.includes("managed"))return"managed";if(s.includes("enterprise"))return"enterprise";const n=(r=a.metadata)==null?void 0:r.legacyName;return ar.find(t=>t===n)??"community"}const ks="https://botpress.com/contact-us/managed-plan",Ea={community:["AI usage included","3 seats","3 AI agents","Botpress Desk","Botpress Studio + ADK","Help center","1K table rows","100MB file storage","100MB vector DB storage","Community support"],plus:["3 seats","Unlimited AI agents","WhatsApp channel","Help Center custom domain","Whitelabel webchat","100K table rows","10GB file storage","1GB vector DB storage","Technical support via live chat"],team:["Unlimited seats","Teams, routing & RBAC","Team-level analytics","500K table rows","50GB file storage","5GB vector DB storage"],enterprise:["Voice channel","Dedicated support","SLA & security review","Custom storage"],managed:[]},Ta={"AI usage included":"A monthly allowance of AI model spend is bundled into every plan — no separate AI bill.","3 seats":"Up to 3 team members can collaborate in this workspace.","Unlimited seats":"Invite as many team members to the workspace as you need.","3 AI agents":"Build and publish up to 3 distinct AI agents.","Unlimited AI agents":"Build and publish as many AI agents as you need.","Botpress Desk":"The human-handoff inbox where agents triage and reply to live conversations.","Botpress Studio + ADK":"The visual Studio builder plus the Agent Development Kit for building agents in code.","Help center":"A hosted knowledge base your agent answers from and customers can browse.","Help Center custom domain":"Serve your help center from your own domain instead of a Botpress URL.","WhatsApp channel":"Connect your agent to WhatsApp to chat with customers there.","Voice channel":"Connect your agent to phone/voice so it can handle spoken conversations.","Whitelabel webchat":"Remove Botpress branding from the web chat widget so it’s fully your own.","Teams, routing & RBAC":"Organize members into teams, route conversations between them, and control access by role.","Team-level analytics":"Performance and volume metrics broken down per team.","Technical support via live chat":"Reach the Botpress support team over live chat for help.","Community support":"Get help from the Botpress community forum and Discord.","Dedicated support":"A named contact and priority support channel for your account.","SLA & security review":"A contractual uptime SLA and a security/compliance review for your procurement.","Custom storage":"Storage limits tailored to your workload, beyond the standard tiers."},sr=[{test:/table rows/i,describe:a=>`${a.replace(/ table rows/i,"")} rows across all your data tables.`},{test:/file storage/i,describe:a=>`${a.replace(/ file storage/i,"")} of uploaded files (documents, images, attachments).`},{test:/vector db storage/i,describe:a=>`${a.replace(/ vector db storage/i,"")} of embeddings for knowledge-base search and retrieval.`}];function Ns(a,s){var n;return s!=null&&s[a]?s[a]:Ta[a]?Ta[a]:(n=sr.find(r=>r.test.test(a)))==null?void 0:n.describe(a)}function Re(a,s,n){return a.prices[s.id]??a.prices[fe(s)]??a.prices[n]??null}function He(a){return a.replace("Add-on - ","")}function ws(a){return(a==null?void 0:a.find(s=>{var n;return(((n=s.increments)==null?void 0:n.conversation_sessions)??0)>0}))??null}const Cs=[{key:"conversation_sessions",label:"Conversations / month",unit:"count"},{key:"table_rows",label:"Table rows",unit:"count"},{key:"vector_db_storage",label:"Vector DB storage",unit:"bytes"},{key:"file_storage",label:"File storage",unit:"bytes"}];function Ss(a,s,n){var t;if(!s)return[];const r=[];for(const o of Cs){const l=a.features[o.key]??0;let c=0;for(const i of s){const h=((t=i.increments)==null?void 0:t[o.key])??0,m=n[i.id]??0;c+=h*m}c>0&&r.push({...o,now:l,next:l+c})}return r}function Is(a,s,n){var t;if(!a)return[];const r=[];for(const o of Cs){const l=a.features[o.key]??0;let c=0;for(const i of s??[])c+=(((t=i.increments)==null?void 0:t[o.key])??0)*(n[i.id]??0);(l>0||c>0)&&r.push({...o,base:l,added:c,total:l+c})}return r}function xa(a,s,n){var l;const r=ws(a);if(!r)return null;const t=((l=r.increments)==null?void 0:l.conversation_sessions)??0,o=Re(r,s,n);return t<=0||!o||o.amount<=0?null:{packSize:t,amount:o.amount,currency:o.currency}}const La=({variant:a="accent",children:s,className:n})=>e.jsx("span",{className:L("bpb-badge",`bpb-badge--${a}`,n),children:s}),ie=({variant:a="primary",size:s="md",block:n=!1,loading:r=!1,className:t,disabled:o,children:l,type:c="button",...i})=>e.jsxs("button",{type:c,className:L("bpb-btn",`bpb-btn--${a}`,`bpb-btn--${s}`,n&&"bpb-btn--block",t),disabled:o||r,"data-loading":r||void 0,...i,children:[r&&e.jsx("span",{className:"bpb-btn__spinner","aria-hidden":!0}),e.jsx("span",{className:"bpb-btn__label",children:l})]}),Q=(a,s)=>({width:a??16,height:a??16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,...s}),As=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M3 8.5l3.5 3.5L13 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ma=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M8 1.5l1.4 3.6a1 1 0 00.6.6L13.5 7l-3.5 1.4a1 1 0 00-.6.6L8 12.5 6.6 9a1 1 0 00-.6-.6L2.5 7 6 5.7a1 1 0 00.6-.6L8 1.5z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M12.8 11l.5 1.2 1.2.5-1.2.5-.5 1.3-.5-1.3-1.2-.5 1.2-.5.5-1.2z",fill:"currentColor"})]}),Es=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M2.5 8a5.5 5.5 0 115.5 5.5c-.9 0-1.8-.2-2.5-.6L2.5 13.5l.6-3A5.5 5.5 0 012.5 8z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})}),Pa=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M8 1.8l5 1.8v4c0 3.2-2.1 5.4-5 6.6-2.9-1.2-5-3.4-5-6.6v-4l5-1.8z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M5.8 8l1.6 1.6 2.8-3",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),Ts=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M6 2.5h3v1.6a1.4 1.4 0 102.8 0V2.5h1.7v3h-1.6a1.4 1.4 0 100 2.8h1.6v3h-3v1.6a1.4 1.4 0 11-2.8 0v-1.6h-3v-3h1.6a1.4 1.4 0 100-2.8H2.5v-3H6z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})}),ea=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M8 2l6 3-6 3-6-3 6-3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M2 8l6 3 6-3M2 11l6 3 6-3",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})]}),xs=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M8 8c-1.2-1.6-2-2.4-3.3-2.4a2.4 2.4 0 100 4.8C6 10.4 6.8 9.6 8 8zm0 0c1.2 1.6 2 2.4 3.3 2.4a2.4 2.4 0 100-4.8C10 5.6 9.2 6.4 8 8z",stroke:"currentColor",strokeWidth:"1.3"})}),aa=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M8.5 1.5L3 9h4l-.5 5.5L12 7H8l.5-5.5z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})}),Ls=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("circle",{cx:"6",cy:"5.5",r:"2.2",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M2 13c0-2.2 1.8-3.6 4-3.6s4 1.4 4 3.6",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),e.jsx("path",{d:"M10.5 3.6a2.2 2.2 0 010 4.1M11 9.6c1.7.3 3 1.6 3 3.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),Ms=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M2.5 2.5v11h11",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M5 10l2.2-2.4 2 1.6L12.5 5.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),Ps=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M2 8h12M8 2c1.8 1.6 2.8 3.8 2.8 6S9.8 12.4 8 14C6.2 12.4 5.2 10.2 5.2 8S6.2 3.6 8 2z",stroke:"currentColor",strokeWidth:"1.3"})]}),Ds=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M2.5 11.5L9 5l2 2-6.5 6.5H2.5v-2z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M9 5l1.8-1.8a1.4 1.4 0 012 2L11 7",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})]}),Da=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("rect",{x:"1.8",y:"3.5",width:"12.4",height:"9",rx:"1.6",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M1.8 6.4h12.4",stroke:"currentColor",strokeWidth:"1.3"})]}),nr=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M2 6l6-3.5L14 6v1H2V6zM3 7v5M6.3 7v5M9.7 7v5M13 7v5M2 12.5h12",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})}),rr=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1.4",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M5.5 7V5.5a2.5 2.5 0 015 0V7",stroke:"currentColor",strokeWidth:"1.3"})]}),sa=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),na=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M4 6.5L8 10.5l4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Bs=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ge=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M6 3.5L10.5 8L6 12.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),zs=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Us=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M8 3.5v9M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),tr=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M8 2.2L14.5 13.2a.7.7 0 01-.6 1H2.1a.7.7 0 01-.6-1L8 2.2z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 6.3v3.1",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("circle",{cx:"8",cy:"11.6",r:"0.85",fill:"currentColor"})]}),ra=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M9 3.5h3.5V7M12 4L7 9M11 9.5v2a1 1 0 01-1 1H4.5a1 1 0 01-1-1V6a1 1 0 011-1h2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}),Ba=({size:a,...s})=>e.jsx("svg",{...Q(a,s),children:e.jsx("path",{d:"M8 2.5v7M5 7l3 3 3-3M3 12.5h10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}),or=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("path",{d:"M4 2h8v12l-1.5-1-1.5 1-1.5-1-1.5 1L4 14V2z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.2 5.5h3.6M6.2 8h3.6",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),Os=({size:a,...s})=>e.jsxs("svg",{...Q(a,s),children:[e.jsx("rect",{x:"2.5",y:"3.5",width:"11",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M2.5 6.5h11M5.5 2v2.5M10.5 2v2.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),ta=({brand:a})=>{const s=a==="visa"?"VISA":a==="mastercard"?"MC":a==="amex"?"AMEX":a==="discover"?"DISC":a.slice(0,4).toUpperCase(),n=a==="visa"?"#1a1f71":a==="mastercard"?"#252525":a==="amex"?"#016fd0":"#5d5d5d";return e.jsx("span",{"aria-hidden":!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:34,height:22,padding:"0 4px",borderRadius:4,background:n,color:"#fff",fontSize:9,fontWeight:700,letterSpacing:"0.04em"},children:s})};function za(a){const s=a.toLowerCase();return/seat|member|user|team|rbac|rout/.test(s)?Ls:/analytic|report|insight|dashboard/.test(s)?Ms:/whatsapp|channel|chat|message|conversation|webchat|voice/.test(s)?Es:/storage|table|vector|file|gb|rows|db/.test(s)?ea:/domain|help center|whitelabel|website|url|web/.test(s)?Ps:/brand|theme|custom|white-?label/.test(s)?Ds:/unlimited|infinit/.test(s)?xs:/security|sla|compliance|soc|audit/.test(s)||/support|sla|dedicated|priority/.test(s)?Pa:/integration|api|plugin|sdk|adk|studio/.test(s)?Ts:/ai|agent|model|gpt|llm/.test(s)?aa:Ma}const _e=({open:a,onOpenChange:s,size:n="md",children:r,className:t,showClose:o=!0,...l})=>{const c=N.useRef(null),i=cn(),h=N.useCallback(()=>s(!1),[s]);return N.useEffect(()=>{var y;if(!a)return;const m=f=>{f.key==="Escape"&&h()};document.addEventListener("keydown",m);const b=document.body.style.overflow;return document.body.style.overflow="hidden",(y=c.current)==null||y.focus(),()=>{document.removeEventListener("keydown",m),document.body.style.overflow=b}},[a,h]),a?rn.createPortal(e.jsx("div",{className:"bpb-portal bpb-dialog__overlay","data-bpb-theme":i?"dark":"light",onClick:h,children:e.jsxs("div",{ref:c,role:"dialog","aria-modal":"true","aria-label":l["aria-label"],tabIndex:-1,className:L("bpb-dialog",`bpb-dialog--${n}`,t),onClick:m=>m.stopPropagation(),children:[o&&e.jsx("button",{type:"button",className:"bpb-dialog__close","aria-label":"Close",onClick:h,children:e.jsx(sa,{size:18})}),r]})}),document.body):null},oa=({label:a,children:s})=>e.jsxs("span",{className:"bpb-tooltip",tabIndex:0,role:"note",children:[e.jsx("span",{className:"bpb-tooltip__term",children:a}),e.jsx("span",{className:"bpb-tooltip__bubble",role:"tooltip",children:s})]}),ze=()=>{const{manageBillingUrl:a}=P();return e.jsxs("div",{className:"bpb-outdated",children:[e.jsx("h3",{className:"bpb-outdated__title",children:"Billing is managed in the Botpress Dashboard"}),e.jsx("p",{className:"bpb-outdated__text",children:"This workspace is on an earlier billing system, so plan changes and payment details can’t be managed here."}),a&&e.jsxs(ie,{variant:"primary",onClick:()=>window.open(a,"_blank","noopener"),children:["Open billing in Dashboard",e.jsx(ra,{size:15})]})]})},$s=({options:a,value:s,onChange:n,className:r,...t})=>e.jsx("div",{role:"radiogroup","aria-label":t["aria-label"],className:L("bpb-segmented",r),children:a.map(o=>{const l=o.value===s;return e.jsxs("button",{type:"button",role:"radio","aria-checked":l,className:L("bpb-segmented__option",l&&"bpb-segmented__option--selected"),onClick:()=>n(o.value),children:[o.label,o.badge&&e.jsx("span",{className:"bpb-segmented__badge",children:o.badge})]},o.value)})}),$=({width:a,height:s=14,rounded:n=!1,className:r})=>e.jsx("span",{"aria-hidden":!0,className:L("bpb-skeleton",n&&"bpb-skeleton--rounded",r),style:{width:a??"100%",height:s}});function lr(a,s){const n=a.prices[s];return n||((s==="month"?a.prices.year:a.prices.month)??null)}function cr(a,s){var t,o;const n=(t=a.prices.month)==null?void 0:t.amount;if(s==="month")return n??null;const r=((o=a.prices.year)==null?void 0:o.amount)??(n===void 0?void 0:n*12);return r===void 0?null:r/12}function ir(a){var n,r;let s=0;for(const t of a){const o=(n=t.prices.month)==null?void 0:n.amount,l=(r=t.prices.year)==null?void 0:r.amount;o&&l&&o>0&&(s=Math.max(s,1-l/(o*12)))}return Math.round(s*100)}const Fs=({open:a,onOpenChange:s,onSelectPlan:n,recommendedPlanId:r="team",defaultInterval:t="year",excludePlanIds:o=[],planFeatures:l={},featureDescriptions:c})=>{var z,J,ue;const{isOutdatedBilling:i,toast:h,analytics:m}=P(),[b,y]=N.useState(t),{data:f,isLoading:w}=Ie(),{data:C}=qe(),{data:u}=ke({enabled:a}),{data:_}=fa({enabled:a}),A=wa(),O=(_==null?void 0:_.planReadonly)??!1;N.useEffect(()=>{a&&m.capture(le.PLAN_PICKER_VIEWED,{interval:b})},[a,m]);const M=T=>{T!==b&&m.capture(le.PLAN_INTERVAL_TOGGLED,{interval:T}),y(T)},S=u==null?void 0:u.plan.current.interval,I=f==null?void 0:f.find(T=>T.id===(u==null?void 0:u.plan.current.planId)),E=u?I?fe(I):"community":void 0,p=((z=u==null?void 0:u.plan.next)==null?void 0:z.planId)??null,B=!!p&&p!==(u==null?void 0:u.plan.current.planId),x=O||E==="enterprise"||E==="managed",Y=N.useMemo(()=>f?f.filter(T=>fe(T)!=="managed"&&fe(T)!=="enterprise"&&!o.includes(T.id)).sort((T,g)=>Ye.indexOf(fe(T))-Ye.indexOf(fe(g))):[],[f,o]),Z=N.useMemo(()=>ir(Y),[Y]),ae=((ue=(J=f==null?void 0:f.find(T=>fe(T)==="enterprise"))==null?void 0:J.metadata)==null?void 0:ue.contact_url)??ks,pe=T=>{A.mutate({planId:T.id,interval:b},{onSuccess:()=>{m.capture(le.PLAN_DOWNGRADED,{plan_name:ee(T.name),interval:b,previous_plan_name:I?ee(I.name):void 0}),h({type:"success",message:"Plan downgraded"})},onError:()=>h({type:"error",message:"Downgrade failed"})})},de=()=>{u&&A.mutate({planId:u.plan.current.planId,interval:u.plan.current.interval},{onSuccess:()=>{m.capture(le.PLAN_DOWNGRADE_CANCELLED,{plan_name:I?ee(I.name):u.plan.current.planId}),h({type:"success",message:"Scheduled downgrade canceled"})},onError:()=>h({type:"error",message:"Could not cancel the downgrade"})})};return i?e.jsx(_e,{open:a,onOpenChange:s,size:"md","aria-label":"Upgrade your plan",className:"bpb-scope",children:e.jsx(ze,{})}):e.jsx(_e,{open:a,onOpenChange:s,size:"xl","aria-label":"Upgrade your plan",className:"bpb-scope",children:e.jsxs("div",{className:"bpb-upgrade",children:[e.jsx("h2",{className:"bpb-upgrade__title",children:"Upgrade your plan"}),e.jsx("div",{className:"bpb-upgrade__toggle",children:e.jsx($s,{"aria-label":"Billing interval",value:b,onChange:M,options:[{value:"month",label:"Monthly"},{value:"year",label:"Annual",badge:Z>0?`Save ${Z}%`:void 0}]})}),e.jsxs("div",{className:"bpb-upgrade__grid",children:[w&&[0,1,2].map(T=>e.jsxs("div",{className:"bpb-plan-card","aria-hidden":!0,children:[e.jsx($,{width:120,height:22}),e.jsx($,{width:90,height:40}),e.jsx($,{width:"100%",height:36,rounded:!0}),e.jsx($,{width:"100%",height:140})]},T)),Y.map((T,g)=>{var be,H;const U=fe(T),W=lr(T,b),F=cr(T,b),re=(((be=T.prices.month)==null?void 0:be.amount)??0)<=0,q=U===E&&(E==="community"||b===S),j=U===E&&E!=="community"&&b!==S,we=!!p&&T.id===p&&!q,Ce=E!==void 0&&Ye.indexOf(U)<Ye.indexOf(E),G=(U===r||T.id===r)&&!q,R=q&&B?"cancel_downgrade":q?"current":j?"switch_interval":we?"next":Ce?"downgrade":"upgrade",te=g>0?Y[g-1]:void 0,Se=l[U]??Ea[U],he=T.features.conversation_sessions,me=xa(C,T,b),V=A.isPending&&(R==="downgrade"&&((H=A.variables)==null?void 0:H.planId)===T.id||R==="cancel_downgrade");return e.jsxs("div",{className:L("bpb-plan-card",G&&"bpb-plan-card--highlighted"),"data-plan-id":T.id,children:[e.jsxs("div",{className:"bpb-plan-card__header",children:[e.jsxs("h3",{className:"bpb-plan-card__name",children:[ee(T.name),G&&e.jsx(La,{className:"bpb-plan-card__badge",children:"Recommended"})]}),e.jsx("p",{className:"bpb-plan-card__tagline",children:T.description}),e.jsx("div",{className:"bpb-plan-card__price",children:F!==null&&W?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bpb-plan-card__currency",children:vs(W.currency)}),e.jsx("span",{className:"bpb-plan-card__amount",children:Number.isInteger(F)?F:F.toFixed(2).replace(/\.00$/,"")}),e.jsxs("span",{className:"bpb-plan-card__per",children:["/ month (",W.currency.toUpperCase(),")"]})]}):e.jsx("span",{className:"bpb-plan-card__amount",children:K(0,"usd",0)})})]}),he!==void 0&&e.jsxs("div",{className:"bpb-plan-card__allowance",children:[e.jsxs("div",{className:"bpb-plan-card__metric",children:[e.jsx("span",{className:"bpb-plan-card__metric-value",children:ne(he)}),e.jsxs("span",{className:"bpb-plan-card__metric-unit",children:["conversations",re?"":" / month"]})]}),me?e.jsxs("p",{className:"bpb-plan-card__pack",children:["then ",K(me.amount,me.currency,0)," per"," ",ne(me.packSize)," more"]}):e.jsx("p",{className:"bpb-plan-card__pack",children:"No top-up"})]}),R==="current"&&e.jsx(ie,{variant:"outline",block:!0,disabled:!0,children:"Your current plan"}),R==="next"&&e.jsx(ie,{variant:"outline",block:!0,disabled:!0,children:"Next plan"}),R==="cancel_downgrade"&&e.jsx(ie,{variant:"primary",block:!0,loading:V,onClick:de,children:"Cancel downgrade"}),R==="downgrade"&&e.jsx(ie,{variant:"outline",block:!0,disabled:x||A.isPending,loading:V,onClick:()=>pe(T),children:"Downgrade"}),R==="switch_interval"&&e.jsx(ie,{variant:"primary",block:!0,disabled:x||A.isPending,title:x?"Your plan is managed by Botpress — contact us to change it":void 0,onClick:()=>{m.capture(le.PLAN_UPGRADE_INITIATED,{plan_name:ee(T.name),interval:b,current_plan_name:I?ee(I.name):void 0}),n(T.id,b)},children:b==="year"?"Switch to annual":"Switch to monthly"}),R==="upgrade"&&e.jsx(ie,{variant:G?"accent":"primary",block:!0,disabled:x||A.isPending,title:x?"Your plan is managed by Botpress — contact us to change it":void 0,onClick:()=>{m.capture(le.PLAN_UPGRADE_INITIATED,{plan_name:ee(T.name),interval:b,current_plan_name:I?ee(I.name):void 0}),n(T.id,b)},children:"Upgrade"}),e.jsxs("ul",{className:"bpb-plan-card__features",children:[te&&e.jsxs("li",{className:"bpb-plan-card__features-lead",children:[e.jsx("span",{className:"bpb-plan-card__feature-chip bpb-plan-card__feature-chip--lead",children:e.jsx(As,{size:13})}),e.jsxs("span",{children:["Everything in ",ee(te.name)]})]}),Se.map(X=>{const ve=za(X),Me=Ns(X,c);return e.jsxs("li",{children:[e.jsx("span",{className:"bpb-plan-card__feature-chip",children:e.jsx(ve,{size:13})}),Me?e.jsx(oa,{label:X,children:Me}):e.jsx("span",{children:X})]},X)})]})]},T.id)})]}),e.jsxs("p",{className:"bpb-upgrade__footer",children:["Need more, or running at scale?"," ",e.jsx("a",{href:ae,target:"_blank",rel:"noopener noreferrer",children:"Contact us"})," ","about Enterprise. Compare plans at"," ",e.jsx("a",{href:"https://botpress.com/pricing",target:"_blank",rel:"noopener noreferrer",children:"botpress.com/pricing"}),"."]})]})})},Ua='-apple-system, "ui-sans-serif", "system-ui", "Segoe UI", Helvetica, Arial, sans-serif',Oa="14px",qs="10px";function $a(a){return a?{theme:"night",variables:{fontFamily:Ua,fontSizeBase:Oa,borderRadius:qs,colorPrimary:"#ececec",colorBackground:"#1c1c1c",colorText:"#f9f9f9",colorTextSecondary:"#b4b4b4",colorTextPlaceholder:"#9b9b9b",colorDanger:"#ff8583"},rules:{".Input":{backgroundColor:"#212121",border:"1px solid rgba(255,255,255,0.12)",boxShadow:"none",color:"#f9f9f9"},".Input:focus":{border:"1px solid rgba(255,255,255,0.3)",boxShadow:"none"},".Label":{color:"#ececec",fontWeight:"500",fontSize:"12px"},".Error":{color:"#ff8583"},".Tab":{border:"1px solid rgba(255,255,255,0.12)",boxShadow:"none"}}}:{theme:"stripe",variables:{fontFamily:Ua,fontSizeBase:Oa,borderRadius:qs,colorPrimary:"#0d0d0d",colorBackground:"#f7f7f7",colorText:"#0d0d0d",colorTextSecondary:"#5d5d5d",colorTextPlaceholder:"#8f8f8f",colorDanger:"#e02e2a"},rules:{".Input":{backgroundColor:"#f7f7f7",border:"1px solid transparent",boxShadow:"none",color:"#0d0d0d"},".Input:focus":{backgroundColor:"#fff",border:"1px solid #0d0d0d",boxShadow:"none"},".Label":{color:"#5d5d5d",fontWeight:"500",fontSize:"12px"},".Error":{color:"#e02e2a"},".Tab":{border:"1px solid #0d0d0d1a",boxShadow:"none",backgroundColor:"#f7f7f7"},".Tab--selected":{border:"1px solid #0d0d0d",backgroundColor:"#fff"},".Block":{backgroundColor:"#f9f9f9",boxShadow:"none"}}}}function Fa(a){return{base:{fontFamily:Ua,fontSize:Oa,color:a?"#f9f9f9":"#0d0d0d","::placeholder":{color:a?"#9b9b9b":"#8f8f8f"}},invalid:{color:a?"#ff8583":"#e02e2a"}}}const dr={pt:"pt-BR",es:"es-419"};function qa(a){const s=a.split("-")[0]??a;return dr[s]??a}const br=4,pr=({plan:a,interval:s,preview:n,isLoadingPreview:r,isPreviewError:t,canSubscribe:o,isSubmitting:l,onSubscribe:c})=>{var Y,Z,ae,pe,de;const{locale:i}=P(),{data:h}=qe(),m=((Y=a==null?void 0:a.prices.month)==null?void 0:Y.currency)??((Z=a==null?void 0:a.prices.year)==null?void 0:Z.currency)??"usd",b=a==null?void 0:a.features.conversation_sessions,y=a?xa(h,a,s):null,f=(n==null?void 0:n.costs.immediate.amountDue)??0,w=(n==null?void 0:n.costs.immediate.accountBalance)??0,C=(n==null?void 0:n.costs.nextCycle.total)??0,u=n!=null&&n.nextBillingDate?Ee(_s(n.nextBillingDate,1),i):null,_=a?Ea[fe(a)].slice(0,br):[],A=a?((ae=a.prices[s])==null?void 0:ae.amount)??0:0,O=(n==null?void 0:n.costs.immediate.lineItems)??[],M=O.filter(z=>z.type==="discount"),S=O.filter(z=>z.type==="proration_credit"||z.type==="proration_charge").reduce((z,J)=>z+J.amount,0),I=!!(n!=null&&n.subscription.plan.effectiveDate),E=((pe=a==null?void 0:a.prices.month)==null?void 0:pe.amount)??0,p=((de=a==null?void 0:a.prices.year)==null?void 0:de.amount)??0,B=s==="year"&&E>0&&p>0?Math.round(E*12-p):0,x=Math.round(B/12);return e.jsxs("div",{className:"bpb-summary-wrap",children:[e.jsxs("div",{className:"bpb-summary",children:[e.jsx("h3",{className:"bpb-summary__title",children:a?`${ee(a.name)} plan`:e.jsx($,{width:140,height:24})}),b!==void 0&&e.jsxs("div",{className:"bpb-summary__metric",children:[e.jsx("span",{className:"bpb-summary__metric-value",children:ne(b)}),e.jsx("span",{className:"bpb-summary__metric-unit",children:"conversations / month"}),y&&e.jsxs("span",{className:"bpb-summary__metric-pack",children:["then ",K(y.amount,y.currency,0)," per ",ne(y.packSize)]})]}),_.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"bpb-summary__features-label",children:"Top features"}),e.jsx("ul",{className:"bpb-summary__features",children:_.map(z=>{const J=za(z);return e.jsxs("li",{children:[e.jsx(J,{size:16,className:"bpb-summary__feature-icon"}),e.jsx("span",{children:z})]},z)})})]}),e.jsx("hr",{className:"bpb-summary__divider"}),r&&e.jsxs("div",{className:"bpb-summary__lines","aria-busy":"true",children:[e.jsx($,{height:16}),e.jsx($,{height:16}),e.jsx($,{height:20})]}),t&&e.jsx("p",{role:"alert",className:"bpb-summary__error",children:"We couldn’t compute your total. Try again in a moment."}),n&&!r&&I&&e.jsxs("div",{className:"bpb-summary__lines",children:[e.jsxs("div",{className:"bpb-summary__line",children:[e.jsxs("span",{className:"bpb-summary__line-label",children:[a?ee(a.name):""," plan",u?` — from ${u}`:""]}),e.jsxs("span",{className:"bpb-summary__line-amount",children:[K(C,m),s==="year"?"/yr":"/mo"]})]}),e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:e.jsx(oa,{label:"Prorated for today",children:"Switching mid-period, we charge only for the time left in your current billing period. The full plan price above is billed at your next renewal, not today."})}),e.jsx("span",{className:"bpb-summary__line-amount",children:K(f,m)})]}),e.jsxs("div",{className:"bpb-summary__line bpb-summary__line--total",children:[e.jsx("span",{children:"Due today"}),e.jsx("span",{children:K(f,m)})]}),S<0&&e.jsxs("p",{className:"bpb-summary__addon-note",children:["You have ",K(Math.abs(S),m)," of unused time credited toward your next invoice."]})]}),n&&!r&&!I&&e.jsxs("div",{className:"bpb-summary__lines",children:[e.jsxs("div",{className:"bpb-summary__line",children:[e.jsxs("span",{className:"bpb-summary__line-label",children:[a?ee(a.name):""," plan (",s==="year"?"annual":"monthly",")"]}),e.jsxs("span",{className:"bpb-summary__line-amount",children:[K(A,m),s==="year"?"/yr":"/mo"]})]}),M.map((z,J)=>e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:z.description}),e.jsx("span",{className:"bpb-summary__line-amount",children:K(z.amount,m)})]},`${z.id}-${J}`)),S!==0&&e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:e.jsx(oa,{label:S<0?"Credit for unused time":"Adjustment for unused time",children:S<0?"You already paid for time left in your current billing period. We credit that unused time and re-apply it at your new rate, so you’re never double-charged.":"Switching mid-cycle means we prorate the difference between your old and new plan for the days remaining in your current billing period."})}),e.jsx("span",{className:"bpb-summary__line-amount",children:K(S,m)})]}),w!==0&&e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:"Account credit"}),e.jsx("span",{className:"bpb-summary__line-amount",children:K(w,m)})]}),e.jsxs("div",{className:"bpb-summary__line bpb-summary__line--total",children:[e.jsx("span",{children:"Due today"}),e.jsx("span",{children:K(f,m)})]}),S<0&&f===0&&e.jsxs("p",{className:"bpb-summary__addon-note",children:["Your remaining balance of ",K(Math.abs(S),m)," is applied as credit on your next invoice."]})]}),B>0&&e.jsxs("div",{className:"bpb-summary__savings",children:[e.jsx(Ma,{size:18,className:"bpb-summary__savings-icon"}),e.jsxs("span",{children:["You’re saving ",K(x,m,0),"/month by choosing an annual plan. That’s"," ",K(B,m,0),"/year."]})]}),e.jsx(ie,{variant:"primary",size:"lg",block:!0,className:"bpb-summary__cta",disabled:!o,loading:l,onClick:c,children:t?"Preview unavailable":"Subscribe"})]}),e.jsxs("p",{className:"bpb-summary__fineprint",children:["Renews ",s==="month"?"monthly":"annually"," until cancelled.",n&&` You’ll be charged ${K(C,m)}${s==="month"?"/month":"/year"}${u?` starting ${u}`:""}.`," ","Cancel anytime in Settings. By subscribing, you authorize Botpress to store and charge your payment method."]})]})},ur=["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE"],hr={CA:[{type:"ca_bn",label:"CA BN",description:"Canadian BN"},{type:"ca_gst_hst",label:"CA GST/HST",description:"Canadian GST/HST number"},{type:"ca_qst",label:"CA QST",description:"Canadian QST number (Québec)"},{type:"ca_pst_bc",label:"CA PST-BC",description:"Canadian PST number (British Columbia)"},{type:"ca_pst_mb",label:"CA PST-MB",description:"Canadian PST number (Manitoba)"},{type:"ca_pst_sk",label:"CA PST-SK",description:"Canadian PST number (Saskatchewan)"}],US:[{type:"us_ein",label:"US EIN",description:"United States EIN"}],GB:[{type:"gb_vat",label:"GB VAT",description:"United Kingdom VAT number"}],AU:[{type:"au_abn",label:"AU ABN",description:"Australian Business Number"}],NZ:[{type:"nz_gst",label:"NZ GST",description:"New Zealand GST number"}],IN:[{type:"in_gst",label:"IN GST",description:"Indian GST number"}],JP:[{type:"jp_cn",label:"JP CN",description:"Japanese Corporate Number"}],BR:[{type:"br_cnpj",label:"BR CNPJ",description:"Brazilian CNPJ number"},{type:"br_cpf",label:"BR CPF",description:"Brazilian CPF number"}],MX:[{type:"mx_rfc",label:"MX RFC",description:"Mexican RFC number"}],CH:[{type:"ch_vat",label:"CH VAT",description:"Switzerland VAT number"}],AE:[{type:"ae_trn",label:"AE TRN",description:"United Arab Emirates TRN"}],SG:[{type:"sg_gst",label:"SG GST",description:"Singaporean GST number"},{type:"sg_uen",label:"SG UEN",description:"Singaporean UEN"}],ZA:[{type:"za_vat",label:"ZA VAT",description:"South African VAT number"}]},mr=[{type:"eu_vat",label:"EU VAT",description:"European VAT number"}];function Ws(a){if(!a)return[];const s=a.toUpperCase();return ur.includes(s)?mr:hr[s]??[]}const la=({label:a,className:s,id:n,...r})=>a?e.jsxs("label",{className:L("bpb-input",s),children:[e.jsx("span",{className:"bpb-input__label",children:a}),e.jsx("input",{className:"bpb-input__field bpb-input__field--labeled",id:n,...r})]}):e.jsx("input",{className:L("bpb-input__field",s),id:n,...r}),Wa=({label:a,className:s,children:n,...r})=>e.jsxs("label",{className:L("bpb-input",s),children:[a&&e.jsx("span",{className:"bpb-input__label",children:a}),e.jsxs("span",{className:"bpb-input__select-wrap",children:[e.jsx("select",{className:L("bpb-input__field bpb-input__field--select",a&&"bpb-input__field--labeled"),...r,children:n}),e.jsx(na,{size:16,className:"bpb-input__chevron"})]})]}),gr=({plan:a,interval:s,onChange:n})=>{const r=a.prices.month,t=a.prices.year,o=r&&t&&r.amount>0?Math.round((1-t.amount/(r.amount*12))*100):0;return e.jsxs("section",{className:"bpb-checkout__section",children:[e.jsx("h3",{className:"bpb-checkout__section-title",children:"Plan details"}),e.jsxs("div",{className:"bpb-interval-cards",role:"radiogroup","aria-label":"Billing interval",children:[r&&e.jsxs("button",{type:"button",role:"radio","aria-checked":s==="month",className:L("bpb-interval-card",s==="month"&&"bpb-interval-card--selected"),onClick:()=>n("month"),children:[e.jsx("span",{className:"bpb-interval-card__title",children:"Monthly billing"}),e.jsxs("span",{className:"bpb-interval-card__price",children:[K(r.amount,r.currency,0)," /mo"]})]}),t&&e.jsxs("button",{type:"button",role:"radio","aria-checked":s==="year",className:L("bpb-interval-card",s==="year"&&"bpb-interval-card--selected"),onClick:()=>n("year"),children:[e.jsxs("span",{className:"bpb-interval-card__title",children:["Annual billing",o>0&&e.jsxs(La,{children:["Save ",o,"%"]})]}),e.jsxs("span",{className:"bpb-interval-card__price",children:[K(t.amount/12,t.currency,0)," /mo"]})]})]})]})},Ga=({number:a,title:s,onEdit:n})=>e.jsxs("div",{className:"bpb-step__header",children:[n?e.jsxs("button",{type:"button",className:"bpb-step__title bpb-step__title--button",onClick:n,children:[a,". ",s]}):e.jsxs("h3",{className:"bpb-step__title",children:[a,". ",s]}),n&&e.jsx("button",{type:"button",className:"bpb-step__edit",onClick:n,children:"Edit"})]}),yr=({stepNumber:a,collapsed:s,summary:n,savedCard:r,isDark:t,tab:o,onTabChange:l,onPaymentChange:c,canContinue:i,onContinue:h,onEdit:m})=>{const[b,y]=N.useState(!1),f=o==="new"||!r;return e.jsxs("section",{className:L("bpb-step",s&&"bpb-step--collapsed"),children:[e.jsx(Ga,{number:a,title:"Payment method",onEdit:s?m:void 0}),s?r&&o!=="new"?e.jsxs("div",{className:"bpb-saved-card bpb-saved-card--readonly",children:[e.jsx(ta,{brand:r.brand}),e.jsxs("span",{className:"bpb-saved-card__number",children:[e.jsx("span",{className:"bpb-saved-card__brand",children:r.brand})," •••• ",r.lastFour]}),e.jsxs("span",{className:"bpb-saved-card__exp",children:[String(r.expMonth).padStart(2,"0"),"/",String(r.expYear).slice(-2)]})]}):e.jsx("p",{className:"bpb-step__summary",children:n}):e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"bpb-pay-tabs",role:"tablist","aria-label":"Payment method",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":o==="saved",className:L("bpb-pay-tab",o==="saved"&&"bpb-pay-tab--selected"),onClick:()=>l("saved"),children:[e.jsx(Da,{size:16}),"Saved"]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":o==="new",className:L("bpb-pay-tab",o==="new"&&"bpb-pay-tab--selected"),onClick:()=>l("new"),children:[e.jsx(Da,{size:16}),"New card"]})]}),r&&o==="saved"&&e.jsxs("div",{className:"bpb-saved-card",children:[e.jsx(ta,{brand:r.brand}),e.jsxs("span",{className:"bpb-saved-card__number",children:[e.jsx("span",{className:"bpb-saved-card__brand",children:r.brand})," •••• ",r.lastFour]}),e.jsxs("span",{className:"bpb-saved-card__exp",children:[String(r.expMonth).padStart(2,"0"),"/",String(r.expYear).slice(-2)]})]})]}),f&&e.jsxs("div",{className:L("bpb-payment-element",s&&"bpb-payment-element--hidden"),children:[!b&&!s&&e.jsx("div",{className:"bpb-payment-element__skeleton",children:e.jsx($,{height:48})}),e.jsx("div",{className:L("bpb-card-element",!b&&"bpb-payment-element--hidden"),children:e.jsx(ye.CardElement,{options:{style:Fa(t),hidePostalCode:!0},onReady:()=>y(!0),onChange:w=>c(w.complete)})})]}),!s&&e.jsx(ie,{variant:"primary",block:!0,disabled:!i,onClick:h,children:"Next"})]})},fr=({stepNumber:a,collapsed:s,summary:n,onEditStep:r,existingAddress:t,customerName:o,isLoading:l,editing:c,onEdit:i,onCancelEdit:h,onCompleteChange:m,onCountryChange:b,country:y,isBusiness:f,onIsBusinessChange:w,businessName:C,onBusinessNameChange:u,taxType:_,onTaxTypeChange:A,taxValue:O,onTaxValueChange:M})=>{const[S,I]=N.useState(!1),E=c||!t,p=Ws(y),B=p.find(x=>x.type===_);return s?e.jsxs("section",{className:"bpb-step bpb-step--collapsed",children:[e.jsx(Ga,{number:a,title:"Billing address",onEdit:r}),t?e.jsx("div",{className:"bpb-address-card bpb-address-card--readonly",children:e.jsxs("div",{className:"bpb-address-card__lines",children:[o&&e.jsx("span",{className:"bpb-address-card__name",children:o}),e.jsxs("span",{children:[t.lineOne,t.lineTwo?`, ${t.lineTwo}`:""]}),e.jsx("span",{children:[t.city,t.state,t.postalCode,t.country].filter(Boolean).join(", ")})]})}):e.jsx("p",{className:"bpb-step__summary",children:n})]}):e.jsxs("section",{className:"bpb-step",children:[e.jsx(Ga,{number:a,title:"Billing address"}),l?e.jsx($,{height:72}):E?e.jsxs("div",{className:"bpb-payment-element",children:[!S&&e.jsxs("div",{className:"bpb-payment-element__skeleton",children:[e.jsx($,{height:48}),e.jsx($,{height:48})]}),e.jsx("div",{className:L(!S&&"bpb-payment-element--hidden"),children:e.jsx(ye.AddressElement,{options:{mode:"billing",display:{name:"full"},defaultValues:t?{name:o??void 0,address:{line1:t.lineOne,line2:t.lineTwo,city:t.city,state:t.state,postal_code:t.postalCode,country:t.country}}:void 0},onReady:()=>I(!0),onChange:x=>{m(x.complete),b(x.value.address.country||void 0)}})}),h&&c&&e.jsx("button",{type:"button",className:"bpb-address-cancel",onClick:h,children:"Cancel"})]}):e.jsxs("div",{className:"bpb-address-card",children:[e.jsxs("div",{className:"bpb-address-card__lines",children:[o&&e.jsx("span",{className:"bpb-address-card__name",children:o}),e.jsxs("span",{children:[t.lineOne,t.lineTwo?`, ${t.lineTwo}`:""]}),e.jsxs("span",{children:[t.city," ",t.state??""," ",t.postalCode," ",t.country]})]}),e.jsx("button",{type:"button",className:"bpb-link-button",onClick:i,children:"Update"})]}),e.jsxs("label",{className:"bpb-checkbox",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:x=>{w(x.target.checked),x.target.checked&&!_&&p[0]&&A(p[0].type)}}),e.jsx("span",{children:"I’m purchasing as business"})]}),f&&e.jsxs("div",{className:"bpb-business-fields",children:[e.jsx("h4",{className:"bpb-step__subtitle",children:"Business details"}),e.jsx(la,{placeholder:"Business name",value:C,onChange:x=>u(x.target.value),autoComplete:"organization"}),p.length>0?e.jsxs(e.Fragment,{children:[e.jsx(Wa,{"aria-label":"Tax ID type",value:_,onChange:x=>A(x.target.value),children:p.map(x=>e.jsxs("option",{value:x.type,children:[x.label," — ",x.description]},x.type))}),e.jsx(la,{placeholder:B?B.description:"Tax ID number",value:O,onChange:x=>M(x.target.value),inputMode:"text"})]}):e.jsx("p",{className:"bpb-business-fields__note",children:y?"No tax ID is required for your billing country.":"Select your billing country above to add a tax ID."})]})]})},_r=({planId:a,initialInterval:s,clientSecret:n,onSuccess:r})=>{var Xs;const t=ye.useStripe(),o=ye.useElements(),{email:l,toast:c,analytics:i,isDark:h}=P(),[m,b]=N.useState(s),[y,f]=N.useState("payment"),[w,C]=N.useState(!1),[u,_]=N.useState(null),[A,O]=N.useState(!1),[M,S]=N.useState(!1),[I,E]=N.useState(!1),[p,B]=N.useState(void 0),[x,Y]=N.useState(!1),[Z,ae]=N.useState(""),[pe,de]=N.useState(""),[z,J]=N.useState(""),[ue,T]=N.useState(!1),[g,U]=N.useState(null),{data:W}=Ie(),{data:F}=ke(),{data:re,isLoading:q}=ma(),{data:j,isLoading:we}=ga(),{data:Ce}=ya(),G=W==null?void 0:W.find(ge=>ge.id===a),R=((Xs=re==null?void 0:re.paymentMethod)==null?void 0:Xs.card)??null,te=(j==null?void 0:j.address)??null;N.useEffect(()=>{u===null&&!q&&re!==void 0&&_(R?"saved":"new")},[u,q,re,R]),N.useEffect(()=>{p===void 0&&te&&B(te.country)},[p,te]);const Se=N.useMemo(()=>({plan:{planId:a,interval:m}}),[a,m]),he=ha(Se),me=va(),V=ka(),be=Na(),H=wa(),X=G?ee(G.name):"";N.useEffect(()=>{i.capture(le.CHECKOUT_STEP_VIEWED,{step:y,plan_name:X,interval:m})},[y,i]);const ve=u==="new"||!R,Me=M||!te,Qe=ve?A:!!R,Qs=Me?I:!0,Ue=ge=>{ge!==m&&i.capture(le.CHECKOUT_INTERVAL_CHANGED,{plan_name:X,interval:ge}),b(ge)},$r=ge=>{i.capture(le.PAYMENT_METHOD_SELECTED,{method:ge==="saved"?"saved_card":"new_card"}),_(ge)},Zs=()=>{Qe&&(C(!0),f("address"))},Fr=y==="address"&&!!t&&!!o&&!!G&&!he.isError&&!!he.data&&Qe&&Qs&&!ue,qr=R?`${R.brand.charAt(0).toUpperCase()}${R.brand.slice(1)} •••• ${R.lastFour}`:null,Wr=ve?"New card":qr??"Saved card",Gr=te?`${te.city}${te.state?`, ${te.state}`:""} ${te.country}`:"Not set",Vr=async()=>{var Js,Rs,en,an;if(!t||!o||!G)return;T(!0),U(null);const ge=(Oe,pa)=>i.capture(le.CHECKOUT_ERROR,{plan_name:X,interval:m,step:y,reason:Oe,message:pa});try{if(i.capture(le.PAYMENT_DETAILS_CONFIRMED,{plan_name:X,interval:m}),ve){const $e=o.getElement(ye.CardElement);if(!$e){U("Card field is not ready"),ge("card_element_not_ready");return}const{error:Fe,setupIntent:Te}=await t.confirmCardSetup(n,{payment_method:{card:$e}});if(Fe){U(Fe.message??"Payment setup failed"),i.capture(le.CHECKOUT_ERROR,{plan_name:X,interval:m,step:y,reason:Fe.code??"card_setup_failed",decline_code:Fe.decline_code,message:Fe.message});return}if(!(Te!=null&&Te.payment_method)||typeof Te.payment_method!="string"){U("Could not retrieve payment method"),ge("payment_method_missing");return}await me.mutateAsync({paymentMethodId:Te.payment_method})}let Oe;if(Me){const $e=o.getElement("address");if($e){const{complete:Fe,value:Te}=await $e.getValue();if(!Fe||!Te.address){U("Please complete your billing address"),ge("address_incomplete");return}const{address:Ke}=Te;Oe=((Js=Te.name)==null?void 0:Js.trim())||void 0,await V.mutateAsync({lineOne:Ke.line1??"",lineTwo:Ke.line2??void 0,city:Ke.city??"",state:Ke.state??void 0,postalCode:Ke.postal_code??"",country:Ke.country??""})}}const pa=x&&Z.trim()||Oe||void 0,sn=x&&pe&&z.trim()?[{type:pe,value:z.trim()}]:void 0;(pa!==void 0||sn!==void 0)&&await be.mutateAsync({name:pa,taxIds:sn});const Kr=((Rs=he.data)==null?void 0:Rs.costs.immediate.amountDue)??0,jr=((en=he.data)==null?void 0:en.costs.nextCycle.total)??0;await H.mutateAsync({planId:a,interval:m}),i.capture(le.PLAN_UPGRADED,{plan_name:X,interval:m,amount_paid:Kr,next_cycle_amount:jr,previous_plan_name:(an=W==null?void 0:W.find($e=>$e.id===(F==null?void 0:F.plan.current.planId)))==null?void 0:an.name.replace("Plan - ",""),previous_interval:F==null?void 0:F.plan.current.interval}),c({type:"success",message:"Subscription activated"}),r()}catch(Oe){U("Something went wrong while processing your payment. You have not been charged twice."),ge("exception",Oe instanceof Error?Oe.message:void 0),c({type:"error",message:"Payment error"})}finally{T(!1)}};return e.jsxs("div",{className:"bpb-checkout__columns",children:[e.jsxs("div",{className:"bpb-checkout__main",children:[G&&e.jsx(gr,{plan:G,interval:m,onChange:Ue}),l&&e.jsxs("section",{className:"bpb-checkout__section",children:[e.jsx("h3",{className:"bpb-checkout__section-title",children:"Contact information"}),e.jsxs("div",{className:"bpb-checkout__static-field",children:[e.jsx("span",{className:"bpb-checkout__static-label",children:"Email"}),e.jsx("span",{children:l})]})]}),e.jsx(yr,{stepNumber:1,collapsed:y!=="payment",summary:Wr,savedCard:R,isDark:h,tab:u??"new",onTabChange:$r,onPaymentChange:O,canContinue:Qe,onContinue:Zs,onEdit:()=>f("payment")}),w&&e.jsx(fr,{stepNumber:2,collapsed:y!=="address",summary:Gr,onEditStep:Zs,existingAddress:te,customerName:(Ce==null?void 0:Ce.name)??null,isLoading:we,editing:M,onEdit:()=>S(!0),onCancelEdit:te?()=>S(!1):void 0,onCompleteChange:E,onCountryChange:B,country:p,isBusiness:x,onIsBusinessChange:Y,businessName:Z,onBusinessNameChange:ae,taxType:pe,onTaxTypeChange:de,taxValue:z,onTaxValueChange:J}),g&&e.jsx("p",{role:"alert",className:"bpb-checkout__submit-error",children:g})]}),e.jsx("div",{className:"bpb-checkout__aside",children:e.jsx(pr,{plan:G,interval:m,preview:he.data,isLoadingPreview:he.isLoading,isPreviewError:he.isError,canSubscribe:Fr,isSubmitting:ue,onSubscribe:()=>void Vr()})})]})},Gs=({open:a,onOpenChange:s,planId:n,interval:r,onBack:t,onSuccess:o})=>{var C;const{stripePromise:l,isDark:c,locale:i,isOutdatedBilling:h}=P(),m=_a(),b=(C=m.data)==null?void 0:C.clientSecret,{mutate:y,reset:f}=m;N.useEffect(()=>{a&&!h?y():f()},[a,h,y,f]);const w=N.useMemo(()=>b?{clientSecret:b,appearance:$a(c),locale:qa(i)}:null,[b,c,i]);return h?e.jsx(_e,{open:a,onOpenChange:s,size:"md","aria-label":"Configure your plan",className:"bpb-scope",children:e.jsx(ze,{})}):e.jsx(_e,{open:a,onOpenChange:s,size:"xl","aria-label":"Configure your plan",className:"bpb-scope",children:e.jsxs("div",{className:"bpb-checkout",children:[e.jsxs("header",{className:"bpb-checkout__header",children:[t&&e.jsx("button",{type:"button",className:"bpb-checkout__back","aria-label":"Back to plans",onClick:t,children:"‹"}),e.jsx("h2",{className:"bpb-checkout__title",children:"Configure your plan"})]}),m.isError?e.jsxs("div",{className:"bpb-checkout__error-state",children:[e.jsx("p",{children:"We couldn’t start the payment session."}),m.error instanceof Error&&m.error.message&&e.jsx("p",{className:"bpb-checkout__error-detail",children:m.error.message}),e.jsx("p",{className:"bpb-checkout__error-detail",children:"If this persists, the workspace may not exist in this environment or may not be on billing v4."}),e.jsx(ie,{variant:"outline",onClick:()=>y(),children:"Try again"})]}):!w||!b?e.jsxs("div",{className:"bpb-checkout__columns","aria-busy":"true",children:[e.jsxs("div",{className:"bpb-checkout__main",children:[e.jsx($,{height:56}),e.jsx($,{height:56}),e.jsx($,{height:120}),e.jsx($,{height:56})]}),e.jsx("div",{className:"bpb-checkout__aside",children:e.jsx($,{height:320})})]}):e.jsx(ye.Elements,{stripe:l,options:w,children:e.jsx(_r,{planId:n,initialInterval:r,clientSecret:b,onSuccess:()=>{s(!1),o==null||o()}})})]})})},Vs=({value:a,onChange:s,min:n=0,max:r,step:t=1,className:o,...l})=>{const c=()=>s(Math.max(n,a-t)),i=()=>s(r===void 0?a+t:Math.min(r,a+t));return e.jsxs("div",{className:L("bpb-stepper",o),children:[e.jsx("button",{type:"button",className:"bpb-stepper__btn","aria-label":`Decrease ${l["aria-label"]}`,onClick:c,disabled:a<=n,children:e.jsx(zs,{size:14})}),e.jsx("span",{className:"bpb-stepper__value","aria-label":l["aria-label"],children:a}),e.jsx("button",{type:"button",className:"bpb-stepper__btn","aria-label":`Increase ${l["aria-label"]}`,onClick:i,disabled:r!==void 0&&a>=r,children:e.jsx(Us,{size:14})})]})},vr=({open:a,onOpenChange:s,onSuccess:n})=>{const{isOutdatedBilling:r}=P();return r?e.jsx(_e,{open:a,onOpenChange:s,size:"md","aria-label":"Manage add-ons",className:"bpb-scope",children:e.jsx(ze,{})}):e.jsx(_e,{open:a,onOpenChange:s,size:"md","aria-label":"Manage add-ons",className:"bpb-scope",children:e.jsx(kr,{onOpenChange:s,onSuccess:n})})},kr=({onOpenChange:a,onSuccess:s})=>{var z,J,ue,T;const{toast:n,locale:r}=P(),{data:t}=ke(),{data:o}=qe(),{data:l}=Ie(),{data:c}=fa(),i=Xa(),[h,m]=N.useState(null),b=l==null?void 0:l.find(g=>g.id===(t==null?void 0:t.plan.current.planId)),y=(t==null?void 0:t.plan.current.interval)??"month",f=(c==null?void 0:c.addonsReadonly)??!1,w=t!=null&&t.plan.current.periodEnd?Ee(t.plan.current.periodEnd,r):null,C=N.useMemo(()=>{var U;if(!t||!o)return null;const g={};for(const W of o){const F=t.addons[W.id];g[W.id]=((U=F==null?void 0:F.next)==null?void 0:U.quantity)??(F==null?void 0:F.current.quantity)??0}return g},[t,o]),u=h??C,_=N.useMemo(()=>!o||!b?[]:o.flatMap(g=>{const U=Re(g,b,y);return U?[{addon:g,price:U}]:[]}),[o,b,y]),A=!!u&&!!C&&Object.keys(u).some(g=>u[g]!==C[g]),O=_.reduce((g,{addon:U,price:W})=>g+((u==null?void 0:u[U.id])??0)*W.amount,0),M=N.useMemo(()=>b&&u?{plan:{planId:b.id,interval:y},addons:u}:null,[b,y,u]),S=ha(M??{plan:{planId:"",interval:y}},{enabled:!!M&&A}),I=((z=b==null?void 0:b.prices[y])==null?void 0:z.currency)??"usd",E=((J=S.data)==null?void 0:J.costs.immediate.amountDue)??0,p=(ue=S.data)!=null&&ue.nextBillingDate?Ee(S.data.nextBillingDate,r):null,B=((T=b==null?void 0:b.prices[y])==null?void 0:T.amount)??0,x=B+O,Y=b&&u?Ss(b,o,u):[],Z=(g,U)=>U==="bytes"?Be(g):ne(g),ae=(g,U)=>{const W=o==null?void 0:o.find(j=>j.id===g),F=W==null?void 0:W.increments;if(!F||U<=0)return null;const re=F.conversation_sessions??0;if(re>0)return`${ne(re*U)} convos`;const q=F.file_storage??0;return q>0?Be(q*U):null},pe=()=>{u&&i.mutate({addons:u},{onSuccess:()=>{n({type:"success",message:"Subscription updated"}),a(!1),s==null||s()},onError:()=>n({type:"error",message:"Could not update your add-ons"})})},de=!t||!o||!l;return e.jsxs("div",{className:"bpb-manage-addons",children:[e.jsx("h2",{className:"bpb-manage-addons__title",children:"Manage add-ons"}),e.jsx("p",{className:"bpb-manage-addons__subtitle",children:b?`Additional usage for your ${ee(b.name)} plan. Set a quantity to 0 to remove an add-on.`:"Additional usage for your plan. Set a quantity to 0 to remove an add-on."}),de?e.jsxs("div",{className:"bpb-manage-addons__loading","aria-busy":"true",children:[e.jsx($,{height:56}),e.jsx($,{height:56})]}):_.length===0?e.jsxs("p",{className:"bpb-manage-addons__empty",children:["Add-ons aren’t available on the ",b?ee(b.name):"current"," plan. Upgrade to a paid plan to add extra usage."]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bpb-addons",children:_.map(({addon:g,price:U})=>{var q;const W=((q=t==null?void 0:t.addons[g.id])==null?void 0:q.current.quantity)??0,F=(u==null?void 0:u[g.id])??0,re=F!==W?F===0?`${W} active now · removed${w?` ${w}`:" next cycle"}`:`${W} active now · ${F}${w?` from ${w}`:" next cycle"}`:W>0?`${W} active`:null;return e.jsxs("div",{className:"bpb-addon-row",children:[e.jsxs("div",{className:"bpb-addon-row__info",children:[e.jsx("span",{className:"bpb-addon-row__name",children:He(g.name)}),e.jsx("span",{className:"bpb-addon-row__description",children:g.description}),e.jsxs("span",{className:"bpb-addon-row__price",children:[K(U.amount,U.currency)," each"]}),re&&e.jsx("span",{className:L("bpb-addon-row__status",F!==W&&"bpb-addon-row__status--changed"),children:re})]}),e.jsxs("div",{className:"bpb-addon-row__control",children:[ae(g.id,F)&&e.jsx("span",{className:"bpb-addon-row__grant",children:ae(g.id,F)}),e.jsx(Vs,{"aria-label":`${He(g.name)} quantity`,value:F,onChange:j=>m({...u??{},[g.id]:j})})]})]},g.id)})}),Y.length>0&&e.jsxs("div",{className:"bpb-manage-addons__limits",children:[e.jsx("p",{className:"bpb-manage-addons__limits-title",children:"Your new limits"}),Y.map(g=>e.jsxs("div",{className:"bpb-manage-addons__limit-row",children:[e.jsx("span",{className:"bpb-manage-addons__limit-label",children:g.label}),e.jsxs("span",{className:"bpb-manage-addons__limit-values",children:[e.jsx("span",{className:"bpb-manage-addons__limit-now",children:Z(g.now,g.unit)}),e.jsx("span",{className:"bpb-manage-addons__limit-arrow","aria-hidden":!0,children:"→"}),e.jsx("span",{className:"bpb-manage-addons__limit-next",children:Z(g.next,g.unit)})]})]},g.key))]}),e.jsxs("div",{className:"bpb-manage-addons__totals",children:[e.jsxs("div",{className:"bpb-manage-addons__line",children:[e.jsx("span",{children:b?`${ee(b.name)} plan`:"Plan"}),e.jsx("span",{children:K(B,I)})]}),_.map(({addon:g,price:U})=>{const W=(u==null?void 0:u[g.id])??0;return W<=0?null:e.jsxs("div",{className:"bpb-manage-addons__line",children:[e.jsxs("span",{children:[W,"× ",He(g.name)]}),e.jsx("span",{children:K(U.amount*W,I)})]},g.id)}),e.jsxs("div",{className:"bpb-manage-addons__line bpb-manage-addons__line--total",children:[e.jsxs("span",{children:["Total ",y==="year"?"yearly":"monthly"," cost"]}),e.jsxs("span",{children:[K(x,I),y==="year"?"/yr":"/mo"]})]}),A&&e.jsxs("div",{className:"bpb-manage-addons__line bpb-manage-addons__line--due",children:[e.jsx("span",{children:"Due today"}),e.jsx("span",{children:S.isLoading?"…":S.isError?"—":K(Math.max(E,0),I)})]})]}),A&&!S.isError&&e.jsxs("p",{className:"bpb-manage-addons__note",children:[E>0?`You’ll be charged ${K(E,I)} now for the rest of this billing period. `:"No charge today — the change is prorated. ","Add-ons stay active until you remove them and renew with your plan",p?` on ${p}`:"",", when you’ll be billed ",K(O,I),y==="year"?"/yr":"/mo"," for them."]}),f&&e.jsx("p",{className:"bpb-manage-addons__note",role:"alert",children:"Add-ons for this workspace are managed by Botpress — contact us to change them."}),e.jsxs("div",{className:"bpb-manage-addons__actions",children:[e.jsx(ie,{variant:"outline",onClick:()=>a(!1),disabled:i.isPending,children:"Cancel"}),e.jsx(ie,{variant:"primary",disabled:!A||f,loading:i.isPending,onClick:pe,children:"Update subscription"})]})]})]})},Nr={paid:"Paid",open:"Due",draft:"Draft",uncollectible:"Unpaid",void:"Void"},wr=({open:a,onOpenChange:s})=>{const{isOutdatedBilling:n}=P();return n?e.jsx(_e,{open:a,onOpenChange:s,size:"md","aria-label":"Billing history",className:"bpb-scope",children:e.jsx(ze,{})}):e.jsx(_e,{open:a,onOpenChange:s,size:"md","aria-label":"Billing history",className:"bpb-scope",children:e.jsx(Cr,{open:a})})},Cr=({open:a})=>{const{locale:s,analytics:n}=P(),{data:r,isLoading:t,isError:o}=Ha({enabled:a}),l=(r==null?void 0:r.invoices)??[];return e.jsxs("div",{className:"bpb-invoices",children:[e.jsx("h2",{className:"bpb-invoices__title",children:"Billing history"}),t?e.jsxs("div",{className:"bpb-invoices__loading","aria-busy":"true",children:[e.jsx($,{height:52}),e.jsx($,{height:52}),e.jsx($,{height:52})]}):o?e.jsx("p",{className:"bpb-invoices__empty",role:"alert",children:"We couldn’t load your invoices. Try again in a moment."}):l.length===0?e.jsx("p",{className:"bpb-invoices__empty",children:"No invoices yet. They’ll appear here after your first charge."}):e.jsx("ul",{className:"bpb-invoices__list",children:l.map(c=>e.jsxs("li",{className:"bpb-invoices__row",children:[e.jsxs("div",{className:"bpb-invoices__row-main",children:[e.jsx("span",{className:"bpb-invoices__date",children:Ee(c.createdAt,s)}),e.jsx("span",{className:`bpb-invoices__status bpb-invoices__status--${c.status}`,children:Nr[c.status]})]}),e.jsxs("div",{className:"bpb-invoices__row-end",children:[e.jsx("span",{className:"bpb-invoices__amount",children:K(c.amount,c.currency)}),c.pdfUrl?e.jsx("a",{className:"bpb-invoices__download",href:c.pdfUrl,target:"_blank",rel:"noopener noreferrer","aria-label":`Download invoice from ${Ee(c.createdAt,s)}`,onClick:()=>n.capture(le.INVOICE_DOWNLOADED,{status:c.status}),children:e.jsx(Ba,{size:16})}):e.jsx("span",{className:"bpb-invoices__download bpb-invoices__download--disabled","aria-hidden":!0,children:e.jsx(Ba,{size:16})})]})]},c.id))})]})},Sr=({open:a,onOpenChange:s,onSuccess:n})=>{var y;const{stripePromise:r,isDark:t,locale:o,isOutdatedBilling:l}=P(),c=_a(),i=(y=c.data)==null?void 0:y.clientSecret,{mutate:h,reset:m}=c;N.useEffect(()=>{a&&!l?h():m()},[a,l,h,m]);const b=N.useMemo(()=>i?{clientSecret:i,appearance:$a(t),locale:qa(o)}:null,[i,t,o]);return l?e.jsx(_e,{open:a,onOpenChange:s,size:"md","aria-label":"Payment & billing",className:"bpb-scope",children:e.jsx(ze,{})}):e.jsx(_e,{open:a,onOpenChange:s,size:"md","aria-label":"Payment & billing",className:"bpb-scope",children:e.jsxs("div",{className:"bpb-payment-dialog",children:[e.jsx("h2",{className:"bpb-payment-dialog__title",children:"Payment & billing"}),c.isError?e.jsxs("div",{className:"bpb-payment-dialog__error",children:[e.jsx("p",{children:"We couldn’t start a secure session."}),e.jsx(ie,{variant:"outline",onClick:()=>h(),children:"Try again"})]}):!b||!i?e.jsxs("div",{className:"bpb-payment-dialog__loading","aria-busy":"true",children:[e.jsx($,{height:48}),e.jsx($,{height:120})]}):e.jsx(ye.Elements,{stripe:r,options:b,children:e.jsx(Ir,{clientSecret:i,isDark:t,onSuccess:n})})]})})},Ir=({clientSecret:a,isDark:s,onSuccess:n})=>{var me;const r=ye.useStripe(),t=ye.useElements(),{toast:o,analytics:l}=P(),{data:c,isLoading:i}=ma(),{data:h,isLoading:m}=ga(),{data:b,isLoading:y}=ya(),f=va(),w=ka(),C=Na(),u=((me=c==null?void 0:c.paymentMethod)==null?void 0:me.card)??null,_=(h==null?void 0:h.address)??null,A=(b==null?void 0:b.taxIds)??[],[O,M]=N.useState(!1),[S,I]=N.useState(!1),[E,p]=N.useState(!1),[B,x]=N.useState(!1),[Y,Z]=N.useState(null),[ae,pe]=N.useState(!1),[de,z]=N.useState(!1),[J,ue]=N.useState(null),[T,g]=N.useState(_==null?void 0:_.country),[U,W]=N.useState(A.length>0),[F,re]=N.useState(null),q=F??A.map(V=>({type:V.type,value:V.value})),j=Ws(T),we=F!==null,Ce=O||!u,G=(V,be)=>re(q.map((H,X)=>X===V?{...H,...be}:H)),R=()=>{var V;return re([...q,{type:((V=j[0])==null?void 0:V.type)??"",value:""}])},te=V=>re(q.filter((be,H)=>H!==V)),Se=async()=>{if(!r||!t)return;const V=t.getElement(ye.CardElement);if(V){x(!0),Z(null);try{const{error:be,setupIntent:H}=await r.confirmCardSetup(a,{payment_method:{card:V}});if(be){Z(be.message??"Could not save your card");return}if(!(H!=null&&H.payment_method)||typeof H.payment_method!="string"){Z("Could not retrieve payment method");return}await f.mutateAsync({paymentMethodId:H.payment_method}),l.capture(le.PAYMENT_METHOD_UPDATED),o({type:"success",message:"Card updated"}),M(!1),n==null||n()}catch{Z("We couldn’t save your card. Please check your details and try again.")}finally{x(!1)}}},he=async()=>{if(!t)return;const V=t.getElement("address");if(!V)return;const{complete:be,value:H}=await V.getValue();if(!be||!H.address){ue("Please complete your billing address.");return}z(!0),ue(null);try{const{address:X,name:ve}=H;await w.mutateAsync({lineOne:X.line1??"",lineTwo:X.line2??void 0,city:X.city??"",state:X.state??void 0,postalCode:X.postal_code??"",country:X.country??""});const Me=(ve==null?void 0:ve.trim())||void 0,Qe=q.filter(Ue=>!!Ue.type&&Ue.value.trim()!=="").map(Ue=>({type:Ue.type,value:Ue.value.trim()}));(Me!==((b==null?void 0:b.name)??void 0)||we)&&await C.mutateAsync({name:Me,taxIds:Qe}),l.capture(le.BILLING_ADDRESS_UPDATED),o({type:"success",message:"Billing details updated"}),n==null||n()}catch(X){const ve=X instanceof Error&&X.message?X.message:"Could not update your billing details.";ue(ve),o({type:"error",message:"Could not update your billing details"})}finally{z(!1)}};return e.jsxs("div",{className:"bpb-payment-dialog__sections",children:[e.jsxs("section",{className:"bpb-payment-dialog__section",children:[e.jsx("h3",{className:"bpb-payment-dialog__section-title",children:"Payment method"}),i?e.jsx($,{height:56}):Ce?e.jsxs("div",{className:"bpb-payment-element",children:[!S&&e.jsx($,{height:48}),e.jsx("div",{className:S?"bpb-card-element":"bpb-payment-element--hidden",children:e.jsx(ye.CardElement,{options:{style:Fa(s),hidePostalCode:!0},onReady:()=>I(!0),onChange:V=>p(V.complete)})}),Y&&e.jsx("p",{role:"alert",className:"bpb-payment-dialog__field-error",children:Y}),e.jsxs("div",{className:"bpb-payment-dialog__section-actions",children:[u&&e.jsx(ie,{variant:"ghost",onClick:()=>M(!1),disabled:B,children:"Cancel"}),e.jsx(ie,{variant:"primary",disabled:!E,loading:B,onClick:Se,children:"Save card"})]})]}):e.jsxs("div",{className:"bpb-saved-card",children:[e.jsx(ta,{brand:u.brand}),e.jsxs("span",{className:"bpb-saved-card__number",children:[e.jsx("span",{className:"bpb-saved-card__brand",children:u.brand})," •••• ",u.lastFour]}),e.jsxs("span",{className:"bpb-saved-card__exp",children:[String(u.expMonth).padStart(2,"0"),"/",String(u.expYear).slice(-2)]}),e.jsx("button",{type:"button",className:"bpb-link-button",onClick:()=>M(!0),children:"Replace"})]})]}),e.jsxs("section",{className:"bpb-payment-dialog__section",children:[e.jsx("h3",{className:"bpb-payment-dialog__section-title",children:"Billing address"}),m||y?e.jsx($,{height:72}):e.jsxs("div",{className:"bpb-payment-element",children:[!ae&&e.jsx($,{height:120}),e.jsx("div",{className:ae?void 0:"bpb-payment-element--hidden",children:e.jsx(ye.AddressElement,{options:{mode:"billing",display:{name:"full"},defaultValues:_?{name:(b==null?void 0:b.name)??void 0,address:{line1:_.lineOne,line2:_.lineTwo,city:_.city,state:_.state,postal_code:_.postalCode,country:_.country}}:void 0},onReady:()=>pe(!0),onChange:V=>g(V.value.address.country||void 0)})}),e.jsxs("div",{className:"bpb-tax-section",children:[e.jsxs("button",{type:"button",className:"bpb-tax-toggle","aria-expanded":U,onClick:()=>W(V=>!V),children:[e.jsx(na,{size:16,className:L("bpb-tax-toggle__chevron",U&&"bpb-tax-toggle__chevron--open")}),"Tax IDs",A.length>0&&e.jsx("span",{className:"bpb-tax-toggle__count",children:A.length})]}),U&&e.jsxs("div",{className:"bpb-tax",children:[q.length===0&&e.jsx("p",{className:"bpb-tax__empty",children:"Add a VAT or tax registration number to show it on your invoices."}),q.map((V,be)=>e.jsxs("div",{className:"bpb-tax__row",children:[e.jsxs(Wa,{"aria-label":"Tax ID type",value:V.type,onChange:H=>G(be,{type:H.target.value}),children:[e.jsx("option",{value:"",children:"Select type"}),j.map(H=>e.jsx("option",{value:H.type,children:H.label},H.type)),V.type&&!j.some(H=>H.type===V.type)&&e.jsx("option",{value:V.type,children:V.type})]}),e.jsx(la,{placeholder:"Tax ID number",value:V.value,onChange:H=>G(be,{value:H.target.value})}),e.jsx("button",{type:"button",className:"bpb-tax__remove","aria-label":"Remove tax ID",onClick:()=>te(be),children:e.jsx(sa,{size:14})})]},be)),e.jsx("button",{type:"button",className:"bpb-link-button bpb-tax__add",onClick:R,children:"+ Add tax ID"})]})]}),J&&e.jsx("p",{role:"alert",className:"bpb-payment-dialog__field-error",children:J}),e.jsx("div",{className:"bpb-payment-dialog__section-actions",children:e.jsx(ie,{variant:"primary",loading:de,onClick:he,children:"Save billing details"})})]})]})]})},ca=1e9,Ks={incoming_messages_events:a=>`${ne(a)} incoming messages & events`,conversation_sessions:a=>`${ne(a)} conversation sessions`,table_rows:a=>`${ne(a)} table rows`,vector_db_storage:a=>`${Be(a)} vector database storage`,file_storage:a=>`${Be(a)} file storage`,collaborator_count:a=>a===1?"1 collaborator":`${ne(a)} collaborators`,bot_count:a=>a===1?"1 bot":`${ne(a)} bots`,indexed_file_count:a=>`${ne(a)} indexed files for RAG`,ai_spend:a=>`${K(a/ca,"usd",0)} AI credit included`,always_alive:a=>a===1?"1 always-alive bot":`${ne(a)} always-alive bots`};function Ar(a,s,n){const r=(n==null?void 0:n[a])??Ks[a];return r?r(s):`${ne(s)} ${a.replaceAll("_"," ")}`}const Er=[{key:"table_rows",label:"Table rows",unit:"count"},{key:"vector_db_storage",label:"Vector DB storage",unit:"bytes"},{key:"file_storage",label:"File storage",unit:"bytes"}],Ve=(a,s)=>s==="bytes"?Be(a):s==="nano-usd"?`$${(a/ca).toFixed(2)}`:ne(a),Tr=(a,s)=>{const n=new Date;return Array.from({length:a},(r,t)=>{const o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()-t,1));return{value:o.toISOString(),label:o.toLocaleDateString(s,{month:"long",year:"numeric",timeZone:"UTC"})}})},xr=({period:a})=>{const{data:s,isLoading:n,isError:r}=Qa("ai_spend",{period:a});if(r)return null;if(n)return e.jsx($,{height:96});if(!s||s.length===0)return e.jsx("p",{className:"bpb-usage__group-hint",children:"No per-bot AI spend this period."});const t=Math.max(...s.map(o=>o.value),1);return e.jsx("div",{className:"bpb-usage-bots",children:s.map(o=>e.jsxs("div",{className:"bpb-usage-bot",children:[e.jsxs("div",{className:"bpb-usage-bot__head",children:[e.jsx("span",{className:"bpb-usage-bot__name",title:o.name,children:o.name}),e.jsx("span",{className:"bpb-usage-bot__value",children:Ve(o.value,"nano-usd")})]}),e.jsx("div",{className:"bpb-usage-bar",role:"presentation",children:e.jsx("div",{className:"bpb-usage-bar__fill bpb-usage-bar__fill--normal",style:{width:`${Math.max(2,Math.round(o.value/t*100))}%`}})})]},o.botId))})},Va=({entry:a,metric:s,planAllowance:n,planName:r})=>{const t=a.usage??0,o=a.quota>0?Math.max(0,Math.min(100,Math.round(t/a.quota*100))):0,l=o>0?Math.max(5,o):0,c=o>=90?"critical":o>=75?"warning":"normal",i=n??a.quota,h=Math.max(0,a.quota-i),m=r?`${r} plan`:"your plan",b=h>0?`${Ve(i,s.unit)} from ${m} + ${Ve(h,s.unit)} from add-ons`:`${Ve(a.quota,s.unit)} from ${m}`;return e.jsxs("div",{className:"bpb-usage-row",children:[e.jsxs("div",{className:"bpb-usage-row__head",children:[e.jsx("span",{className:"bpb-usage-row__label",children:s.label}),e.jsxs("span",{className:"bpb-usage-row__value",children:[e.jsx("span",{className:"bpb-usage-row__used",children:Ve(t,s.unit)}),e.jsxs("span",{className:"bpb-usage-row__quota",children:[" / ",Ve(a.quota,s.unit)]})]})]}),e.jsxs("span",{className:"bpb-usage-tip",tabIndex:0,role:"note","aria-label":b,children:[e.jsx("div",{className:"bpb-usage-bar",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:L("bpb-usage-bar__fill",`bpb-usage-bar__fill--${c}`),style:{width:`${l}%`}})}),e.jsx("span",{className:"bpb-usage-tip__bubble",role:"tooltip",children:b})]})]})},Lr=({period:a,showPeriodSelector:s=!0,periodMonths:n=12,className:r})=>{var E;const{isOutdatedBilling:t,locale:o}=P(),l=N.useMemo(()=>Tr(n,o),[n,o]),[c,i]=N.useState(a??((E=l[0])==null?void 0:E.value)??""),h=Za(),m=Math.max(0,l.findIndex(p=>p.value===c)),b=p=>{const B=l[m+p];B&&i(B.value)},{data:y,isLoading:f,isError:w}=We({period:c,enabled:!t}),{data:C}=ke({enabled:!t}),{data:u}=Ie(),_=u==null?void 0:u.find(p=>p.id===(C==null?void 0:C.plan.current.planId)),A=_?ee(_.name):void 0,O=p=>_==null?void 0:_.features[p];if(t)return e.jsx("div",{className:L("bpb-usage bpb-scope",r),children:e.jsx(ze,{})});if(f)return e.jsxs("div",{className:L("bpb-usage bpb-scope",r),"aria-busy":"true",children:[e.jsx($,{height:80}),e.jsx($,{height:140})]});if(w||!y)return e.jsx("div",{className:L("bpb-usage bpb-scope",r),children:e.jsx("p",{className:"bpb-usage__error",role:"alert",children:"We couldn’t load your usage. Try again in a moment."})});const M=y.conversation_sessions,S=y.ai_spend,I=Er.filter(p=>y[p.key]);return e.jsxs("div",{className:L("bpb-usage bpb-scope",r),children:[s&&l.length>1&&e.jsxs("div",{className:"bpb-usage__header",children:[e.jsx("span",{className:"bpb-usage__header-title",children:"Usage"}),e.jsxs("div",{className:"bpb-usage__period",children:[e.jsx("span",{className:"bpb-usage__period-label",children:"Billing period"}),e.jsxs("div",{className:"bpb-usage__period-control",children:[e.jsx("button",{type:"button",className:"bpb-usage__period-step","aria-label":"Previous month",onClick:()=>b(1),disabled:m>=l.length-1,children:e.jsx(Bs,{size:15})}),e.jsxs("span",{className:"bpb-usage__period-field",children:[e.jsx(Os,{size:15,className:"bpb-usage__period-icon"}),e.jsx("select",{className:"bpb-usage__period-select","aria-label":"Billing period",value:c,onChange:p=>i(p.target.value),children:l.map(p=>e.jsx("option",{value:p.value,children:p.label},p.value))}),e.jsx(na,{size:14,className:"bpb-usage__period-chevron"})]}),e.jsx("button",{type:"button",className:"bpb-usage__period-step","aria-label":"Next month",onClick:()=>b(-1),disabled:m<=0,children:e.jsx(Ge,{size:15})})]})]})]}),M&&e.jsxs("section",{className:"bpb-usage__group",children:[e.jsx("h3",{className:"bpb-usage__group-title",children:"Conversations"}),e.jsx("p",{className:"bpb-usage__group-hint",children:"Each conversation includes AI usage. When you reach your limit, extra conversations are added automatically so service continues."}),e.jsx("div",{className:"bpb-usage__card",children:e.jsx(Va,{entry:M,metric:{key:"conversation_sessions",label:"Conversations",unit:"count"},planAllowance:O("conversation_sessions"),planName:A})})]}),I.length>0&&e.jsxs("section",{className:"bpb-usage__group",children:[e.jsx("h3",{className:"bpb-usage__group-title",children:"Storage"}),e.jsx("p",{className:"bpb-usage__group-hint",children:"Shared across files, knowledge base, and tables."}),e.jsx("div",{className:"bpb-usage__card",children:I.map(p=>e.jsx(Va,{entry:y[p.key],metric:p,planAllowance:O(p.key),planName:A},p.key))})]}),S&&e.jsxs("section",{className:"bpb-usage__group",children:[e.jsx("h3",{className:"bpb-usage__group-title",children:"AI usage"}),e.jsx("p",{className:"bpb-usage__group-hint",children:"Each conversation includes an AI allowance — this is how much you’ve used."}),e.jsx("div",{className:"bpb-usage__card",children:e.jsx(Va,{entry:S,metric:{key:"ai_spend",label:"AI spend",unit:"nano-usd"}})}),h&&e.jsxs("div",{className:"bpb-usage__card bpb-usage__card--bots",children:[e.jsx("span",{className:"bpb-usage__subhead",children:"AI spend by bot"}),e.jsx(xr,{period:c})]})]})]})},Mr={conversation_sessions:"monthly conversations",table_rows:"table rows",vector_db_storage:"vector DB storage",file_storage:"file storage",ai_spend:"AI spend"},Pr=({position:a="inline",threshold:s=.9,onUpgrade:n,dismissible:r=!0,ctaLabel:t="Upgrade plan",period:o,className:l})=>{const{isOutdatedBilling:c,analytics:i}=P(),{data:h}=We({period:o,enabled:!c}),[m,b]=N.useState(!1),[y,f]=N.useState(!1),[w,C]=N.useState(null),u=h?Object.entries(h).map(([I,E])=>({key:I,pct:E.quota>0?(E.usage??0)/E.quota:0})).filter(I=>I.pct>=s).sort((I,E)=>E.pct-I.pct)[0]:void 0;if(c||!u||m)return null;const _=Mr[u.key]??u.key.replace(/_/g," "),A=Math.min(100,Math.round(u.pct*100)),O=u.pct>=1,M=()=>{i.capture(le.UPGRADE_CTA_CLICKED,{source:"usage_banner",metric:u.key,usage_pct:Math.round(u.pct*100)}),n?n():f(!0)},S=O?"critical":"warning";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:L("bpb-usage-banner bpb-scope",`bpb-usage-banner--${a}`,`bpb-usage-banner--${S}`,l),role:"alert","aria-live":"polite",children:[e.jsx(tr,{size:18,className:"bpb-usage-banner__icon"}),e.jsx("p",{className:"bpb-usage-banner__text",children:O?e.jsxs(e.Fragment,{children:["You’ve reached your ",_," limit. Upgrade now to avoid interruptions."]}):e.jsxs(e.Fragment,{children:["You’ve used ",e.jsxs("strong",{children:[A,"%"]})," of your ",_,". Upgrade to avoid hitting your limit."]})}),e.jsxs("div",{className:"bpb-usage-banner__actions",children:[e.jsx(ie,{variant:"primary",size:"sm",onClick:M,children:t}),r&&e.jsx("button",{type:"button",className:"bpb-usage-banner__dismiss","aria-label":"Dismiss",onClick:()=>b(!0),children:e.jsx(sa,{size:16})})]})]}),!n&&e.jsxs(e.Fragment,{children:[e.jsx(Fs,{open:y,onOpenChange:f,onSelectPlan:(I,E)=>{f(!1),C({planId:I,interval:E})}}),w&&e.jsx(Gs,{open:!!w,onOpenChange:I=>!I&&C(null),planId:w.planId,interval:w.interval,onBack:()=>{C(null),f(!0)},onSuccess:()=>C(null)})]})]})},Ka=({children:a})=>e.jsx("span",{className:"bpb-summary-card__icon","aria-hidden":"true",children:a}),js=({eyebrow:a,className:s})=>{const{manageBillingUrl:n}=P(),r=()=>n&&window.open(n,"_blank","noopener");return e.jsxs("button",{type:"button",className:L("bpb-summary-card bpb-scope",a==="Add-ons"?"bpb-summary-card--addons":"bpb-summary-card--plan",s),onClick:r,disabled:!n,children:[e.jsx(Ka,{children:a==="Add-ons"?e.jsx(aa,{size:22}):e.jsx(ea,{size:22})}),e.jsxs("div",{className:"bpb-summary-card__content",children:[e.jsxs("div",{className:"bpb-summary-card__body",children:[e.jsx("span",{className:"bpb-summary-card__eyebrow",children:a}),e.jsx("span",{className:"bpb-summary-card__title",children:"Managed in Dashboard"}),e.jsx("span",{className:"bpb-summary-card__meta",children:"This workspace uses an earlier billing system."})]}),e.jsxs("span",{className:"bpb-summary-card__action",children:["Open",e.jsx(ra,{size:15})]})]})]})},Dr=({onManage:a,className:s})=>{var w,C;const{isOutdatedBilling:n}=P(),{data:r,isLoading:t}=ke({enabled:!n}),{data:o,isLoading:l}=Ie();if(n)return e.jsx(js,{eyebrow:"Current plan",className:s});if(t||l)return e.jsx($,{height:84,rounded:!0,className:L("bpb-scope",s)});const c=r==null?void 0:r.plan.current,i=o==null?void 0:o.find(u=>u.id===(c==null?void 0:c.planId)),h=(c==null?void 0:c.interval)??"month",m=((w=i==null?void 0:i.prices[h])==null?void 0:w.amount)??0,b=((C=i==null?void 0:i.prices[h])==null?void 0:C.currency)??"usd",y=i==null?void 0:i.features.conversation_sessions,f=i?fe(i):"community";return e.jsxs("button",{type:"button",className:L("bpb-summary-card bpb-summary-card--plan bpb-scope",`bpb-summary-card--tier-${f==="managed"?"enterprise":f}`,s),onClick:a,children:[e.jsx(Ka,{children:e.jsx(ea,{size:22})}),e.jsxs("div",{className:"bpb-summary-card__content",children:[e.jsxs("div",{className:"bpb-summary-card__body",children:[e.jsx("span",{className:"bpb-summary-card__eyebrow",children:"Current plan"}),e.jsx("span",{className:"bpb-summary-card__title",children:i?ee(i.name):"No plan"}),e.jsxs("span",{className:"bpb-summary-card__meta",children:[m>0?`${K(m,b,0)}/${h==="year"?"yr":"mo"}`:"Free",y!==void 0&&` · ${ne(y)} conversations/mo`]})]}),e.jsxs("span",{className:"bpb-summary-card__action",children:["Manage",e.jsx(Ge,{size:16})]})]})]})},Br=({onManage:a,className:s})=>{const{isOutdatedBilling:n}=P(),{data:r,isLoading:t}=ke({enabled:!n}),{data:o,isLoading:l}=qe();if(n)return e.jsx(js,{eyebrow:"Add-ons",className:s});if(t||l)return e.jsx($,{height:84,rounded:!0,className:L("bpb-scope",s)});const c=(o??[]).flatMap(i=>{var m;const h=((m=r==null?void 0:r.addons[i.id])==null?void 0:m.current.quantity)??0;return h>0?[{name:He(i.name),quantity:h}]:[]});return e.jsxs("button",{type:"button",className:L("bpb-summary-card bpb-summary-card--addons bpb-scope",c.length>0&&"bpb-summary-card--active",s),onClick:a,children:[e.jsx(Ka,{children:e.jsx(aa,{size:22})}),e.jsxs("div",{className:"bpb-summary-card__content",children:[e.jsxs("div",{className:"bpb-summary-card__body",children:[e.jsx("span",{className:"bpb-summary-card__eyebrow",children:"Add-ons"}),c.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"bpb-summary-card__title",children:[c.length," active add-on",c.length>1?"s":""]}),e.jsx("span",{className:"bpb-summary-card__meta",children:c.map(i=>`${i.quantity}× ${i.name}`).join(" · ")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bpb-summary-card__title",children:"No add-ons"}),e.jsx("span",{className:"bpb-summary-card__meta",children:"Add extra conversations or storage"})]})]}),e.jsxs("span",{className:"bpb-summary-card__action",children:["Manage",e.jsx(Ge,{size:16})]})]})]})},zr=({onManage:a,className:s})=>{var B,x;const{isOutdatedBilling:n,locale:r,manageBillingUrl:t,analytics:o}=P(),{data:l,isLoading:c}=ke({enabled:!n}),{data:i,isLoading:h}=Ie(),{data:m,isLoading:b}=qe();if(n){const Y=()=>t&&window.open(t,"_blank","noopener");return e.jsxs("button",{type:"button",className:L("bpb-plan-banner bpb-plan-banner--community bpb-scope",s),onClick:Y,disabled:!t,children:[e.jsxs("div",{className:"bpb-plan-banner__main",children:[e.jsx("span",{className:"bpb-plan-banner__eyebrow",children:"Current plan"}),e.jsx("span",{className:"bpb-plan-banner__name",children:"Managed in Dashboard"}),e.jsx("span",{className:"bpb-plan-banner__sub",children:"This workspace uses an earlier billing system."})]}),e.jsxs("span",{className:"bpb-plan-banner__cta",children:["Open ",e.jsx(ra,{size:16})]})]})}if(c||h||b)return e.jsx($,{height:132,rounded:!0,className:L("bpb-scope",s)});const y=l==null?void 0:l.plan.current,f=i==null?void 0:i.find(Y=>Y.id===(y==null?void 0:y.planId)),w=(y==null?void 0:y.interval)??"month",C=((B=f==null?void 0:f.prices[w])==null?void 0:B.currency)??"usd",u=f?fe(f):"community",_=Object.fromEntries(Object.entries((l==null?void 0:l.addons)??{}).map(([Y,Z])=>{var ae;return[Y,((ae=Z.current)==null?void 0:ae.quantity)??0]})),A=((x=f==null?void 0:f.prices[w])==null?void 0:x.amount)??0,O=(m??[]).reduce((Y,Z)=>{const ae=f?Re(Z,f,w):null;return Y+(_[Z.id]??0)*((ae==null?void 0:ae.amount)??0)},0),M=A+O,S=w==="year"?"/yr":"/mo",I=Is(f,m,_).find(Y=>Y.key==="conversation_sessions"),E=y!=null&&y.periodEnd?Ee(y.periodEnd,r):null,p=u==="enterprise"||u==="managed";return e.jsxs("button",{type:"button",className:L("bpb-plan-banner",`bpb-plan-banner--${u}`,"bpb-scope",s),onClick:()=>{o.capture(le.UPGRADE_CTA_CLICKED,{source:"plan_banner",current_tier:u}),a()},children:[e.jsxs("div",{className:"bpb-plan-banner__main",children:[e.jsx("span",{className:"bpb-plan-banner__eyebrow",children:"Current plan"}),e.jsx("span",{className:"bpb-plan-banner__name",children:f?ee(f.name):"No plan"}),I&&e.jsx("span",{className:"bpb-plan-banner__sub",children:I.added>0?e.jsxs(e.Fragment,{children:[ne(I.base)," + ",ne(I.added)," conversations / month"]}):`${ne(I.total)} conversations / month`})]}),e.jsxs("div",{className:"bpb-plan-banner__summary",children:[p?e.jsx("span",{className:"bpb-plan-banner__price",children:"Custom pricing"}):e.jsxs("span",{className:"bpb-plan-banner__price",children:[M>0?K(M,C,0):"Free",M>0&&e.jsx("span",{className:"bpb-plan-banner__price-suffix",children:S})]}),e.jsxs("span",{className:"bpb-plan-banner__meta",children:[w==="year"?"Billed annually":"Billed monthly",O>0&&" · incl. add-ons"]}),E&&e.jsxs("span",{className:"bpb-plan-banner__meta",children:["Renews ",E]})]}),e.jsxs("span",{className:"bpb-plan-banner__cta",children:["Manage plan ",e.jsx(Ge,{size:16})]})]})},Ys=[{key:"conversation_sessions",label:"Conversations",unit:"count"},{key:"ai_spend",label:"AI spend",unit:"nano-usd"},{key:"table_rows",label:"Table rows",unit:"count"},{key:"vector_db_storage",label:"Vector DB storage",unit:"bytes"},{key:"file_storage",label:"File storage",unit:"bytes"}];function ia(a,s){return s==="bytes"?Be(a):s==="nano-usd"?`$${(a/ca).toFixed(2)}`:ne(a)}function da(a){return a>=90?"critical":a>=75?"warning":"normal"}function ba(a){return a?Ys.flatMap(({key:s,label:n,unit:r})=>{const t=a[s];if(!t||t.quota<=0)return[];const o=t.usage??0,l=Math.max(0,Math.min(100,o/t.quota*100));return[{key:s,label:n,unit:r,used:o,quota:t.quota,remaining:Math.max(0,t.quota-o),pct:l}]}).sort((s,n)=>n.pct-s.pct):[]}const Ur=({onManage:a,period:s,variant:n="card",className:r,style:t})=>{const{isOutdatedBilling:o,locale:l}=P(),{data:c,isLoading:i}=ke({enabled:!o}),{data:h,isLoading:m}=Ie(),{data:b,isLoading:y}=We({period:s,enabled:!o});if(o)return null;if(i||m||y)return e.jsx($,{height:72,rounded:!0,className:L("bpb-scope",r)});const f=h==null?void 0:h.find(p=>p.id===(c==null?void 0:c.plan.current.planId)),w=ba(b),C=w.find(p=>p.key==="conversation_sessions"),u=w[0],_=u&&u.key!=="conversation_sessions"&&u.pct>=75?u:C??u,A=_?Math.round(_.pct):0,O=A>0?Math.max(5,A):0,M=_?da(_.pct):"normal",S=c!=null&&c.plan.current.periodEnd?Ee(c.plan.current.periodEnd,l):null,I=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bpb-plan-usage__head",children:[e.jsx("span",{className:"bpb-plan-usage__plan",children:f?ee(f.name):"Free"}),a&&e.jsx(Ge,{size:15,className:"bpb-plan-usage__chevron"})]}),_&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bpb-plan-usage__meta",children:[e.jsx("span",{className:"bpb-plan-usage__meta-label",children:_.label}),e.jsxs("span",{className:"bpb-plan-usage__meta-value",children:[e.jsx("strong",{children:ia(_.remaining,_.unit)})," left"]})]}),e.jsx("div",{className:"bpb-plan-usage__bar",role:"progressbar","aria-valuenow":A,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:L("bpb-plan-usage__fill",`bpb-plan-usage__fill--${M}`),style:{width:`${O}%`}})}),S&&e.jsxs("span",{className:"bpb-plan-usage__reset",children:["Resets ",S]})]})]}),E=L("bpb-plan-usage bpb-scope",`bpb-plan-usage--${n}`,a&&"bpb-plan-usage--clickable",r);return a?e.jsx("button",{type:"button",className:E,style:t,onClick:a,children:I}):e.jsx("div",{className:E,style:t,children:I})},Hs=({children:a,delay:s=200,placement:n="top",period:r,className:t})=>{const{isOutdatedBilling:o,locale:l}=P(),{data:c}=We({period:r,enabled:!o}),{data:i}=ke({enabled:!o}),{data:h}=Ie(),[m,b]=N.useState(!1),y=N.useRef(null),f=()=>{y.current&&(clearTimeout(y.current),y.current=null)};N.useEffect(()=>f,[]);const w=ba(c),C=!o&&w.length>0,u=()=>{C&&(f(),y.current=setTimeout(()=>b(!0),Math.max(0,s)))},_=()=>{f(),b(!1)},A=h==null?void 0:h.find(S=>S.id===(i==null?void 0:i.plan.current.planId)),O=A?ee(A.name):"Free",M=i!=null&&i.plan.current.periodEnd?Ee(i.plan.current.periodEnd,l):null;return e.jsxs("span",{className:L("bpb-usage-pop bpb-scope",t),onMouseEnter:u,onMouseLeave:_,onFocus:u,onBlur:_,children:[a,m&&C&&e.jsxs("span",{className:L("bpb-usage-pop__card",`bpb-usage-pop__card--${n}`),role:"tooltip",children:[e.jsxs("span",{className:"bpb-usage-pop__plan",children:[e.jsxs("span",{className:"bpb-usage-pop__plan-name",children:[O," plan"]}),M&&e.jsxs("span",{className:"bpb-usage-pop__reset",children:["Resets ",M]})]}),e.jsx("span",{className:"bpb-usage-pop__title",children:"Usage this period"}),w.map(S=>{const I=S.pct>0?Math.max(5,S.pct):0;return e.jsxs("span",{className:"bpb-usage-pop__item",children:[e.jsxs("span",{className:"bpb-usage-pop__head",children:[e.jsx("span",{className:"bpb-usage-pop__name",children:S.label}),e.jsxs("span",{className:"bpb-usage-pop__val",children:[ia(S.used,S.unit)," / ",ia(S.quota,S.unit)]})]}),e.jsx("span",{className:"bpb-usage-pop__bar",children:e.jsx("span",{className:L("bpb-usage-pop__fill",`bpb-usage-pop__fill--${da(S.pct)}`),style:{width:`${I}%`}})})]},S.key)})]})]})},Or=({size:a=20,thickness:s=3.5,showLabel:n=!1,onClick:r,popoverDelay:t=200,period:o,className:l,...c})=>{const{isOutdatedBilling:i}=P(),{data:h}=We({period:o,enabled:!i}),m=ba(h);if(i||m.length===0)return null;const b=m[0],y=da(b.pct),f=b.pct>0?Math.max(5,b.pct):0,w=(a-s)/2,C=2*Math.PI*w,u=C*(1-f/100),_=c["aria-label"]??`${Math.round(b.pct)}% of your ${b.label.toLowerCase()} used`,A=e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"bpb-usage-ring__svg",width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":!0,children:[e.jsx("circle",{className:"bpb-usage-ring__track",cx:a/2,cy:a/2,r:w,fill:"none",strokeWidth:s}),e.jsx("circle",{className:L("bpb-usage-ring__arc",`bpb-usage-ring__arc--${y}`),cx:a/2,cy:a/2,r:w,fill:"none",strokeWidth:s,strokeLinecap:"round",strokeDasharray:C,strokeDashoffset:u,transform:`rotate(-90 ${a/2} ${a/2})`})]}),n&&e.jsxs("span",{className:"bpb-usage-ring__label",children:[Math.round(b.pct),"%"]})]}),O=L("bpb-usage-ring",r&&"bpb-usage-ring--clickable"),M=r?e.jsx("button",{type:"button",className:O,onClick:r,"aria-label":_,children:A}):e.jsx("span",{className:O,tabIndex:0,role:"img","aria-label":_,children:A});return e.jsx(Hs,{delay:t,period:o,className:l,children:M})};d.AddonsSummaryCard=Br,d.BILLING_EVENTS=le,d.Badge=La,d.BankIcon=nr,d.BillingProvider=ln,d.BoltIcon=aa,d.Button=ie,d.CalendarIcon=Os,d.CardBrandBadge=ta,d.CardIcon=Da,d.ChartIcon=Ms,d.CheckIcon=As,d.CheckoutDialog=Gs,d.ChevronDownIcon=na,d.ChevronLeftIcon=Bs,d.ChevronRightIcon=Ge,d.CloseIcon=sa,d.DEFAULT_FEATURE_DESCRIPTIONS=Ta,d.DEFAULT_FEATURE_LABELS=Ks,d.DEFAULT_PLAN_FEATURES=Ea,d.Dialog=_e,d.DownloadIcon=Ba,d.ENTERPRISE_CONTACT_URL=ks,d.ExternalLinkIcon=ra,d.GlobeIcon=Ps,d.InfinityIcon=xs,d.InfoTooltip=oa,d.Input=la,d.InvoicesDialog=wr,d.LayersIcon=ea,d.LockIcon=rr,d.ManageAddonsDialog=vr,d.MessageIcon=Es,d.MinusIcon=zs,d.NANO_DOLLARS_PER_DOLLAR=ca,d.OutdatedBillingGate=ze,d.PLAN_ORDER=Ye,d.PaintIcon=Ds,d.PaymentMethodDialog=Sr,d.PlanBanner=zr,d.PlanSummaryCard=Dr,d.PlanUsageWidget=Ur,d.PlusIcon=Us,d.PuzzleIcon=Ts,d.ReceiptIcon=or,d.SegmentedControl=$s,d.Select=Wa,d.ShieldIcon=Pa,d.Skeleton=$,d.SparkleIcon=Ma,d.Stepper=Vs,d.USAGE_METRICS=Ys,d.UpgradePlanDialog=Fs,d.UsageBanner=Pr,d.UsageDashboard=Lr,d.UsagePopover=Hs,d.UsageRing=Or,d.UsersIcon=Ls,d.addDays=_s,d.addonDisplayName=He,d.addonLimitsPreview=Ss,d.addonPrice=Re,d.billingKeys=se,d.cn=L,d.conversationPackPrice=xa,d.conversationsAddon=ws,d.currencySymbol=vs,d.featureDescription=Ns,d.featureLabel=Ar,d.formatBytes=Be,d.formatCurrency=K,d.formatDate=Ee,d.formatQuantity=ne,d.formatUsage=ia,d.getCardElementStyle=Fa,d.getStripeAppearance=$a,d.getStripePromise=Ya,d.iconForFeature=za,d.planDisplayName=ee,d.planEntitlements=Is,d.planKind=fe,d.toStripeLocale=qa,d.usageItems=ba,d.usageTier=da,d.useAddons=qe,d.useBilling=P,d.useBillingAddress=ga,d.useBillingReadonly=fa,d.useCreatePaymentMethodIntent=_a,d.useCustomer=ya,d.useInvoices=Ha,d.usePaymentMethod=ma,d.usePlans=Ie,d.useSetAddons=Xa,d.useSetBillingAddress=ka,d.useSetCustomer=Na,d.useSetPaymentMethod=va,d.useSetSubscription=wa,d.useSubscription=ke,d.useSubscriptionPreview=ha,d.useSupportsUsageByBot=Za,d.useUsage=We,d.useUsageByBot=Qa,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});