@bpinternal/billing-ui 0.1.0 → 0.3.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,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"})});
1
+ (function(b,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):(b=typeof globalThis<"u"?globalThis:b||self,e(b.BillingUI={},b.ReactJsxRuntime,b.ReactQuery,b.React,b.StripeJs,b.ReactDOM,b.ReactStripeJs))})(this,function(b,e,be,w,bn,pn,_e){"use strict";const Za=new Map;function Xa(a){let s=Za.get(a);return s||(s=bn.loadStripe(a,{developerTools:{assistant:{enabled:!1}}}),Za.set(a,s)),s}const ya=w.createContext(null),un={capture:()=>{}};function hn(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 mn=({client:a,stripePublishableKey:s,email:n,locale:r="en-US",theme:t="light",onToast:o,analytics:l,featureLabels:c,billingVersion:d,workspaceId:p,persist:u=!0,manageBillingUrl:h,onBillingChange:g,refreshInterval:_=3e4,children:N})=>{const v=p||"default",[y]=w.useState(()=>new be.QueryClient({defaultOptions:{queries:{retry:1,staleTime:3e4,gcTime:1e3*60*60}}})),m=hn(t),S=w.useMemo(()=>Xa(s),[s]);w.useEffect(()=>{if(!u||typeof window>"u")return;const f=`bpb-cache:${v}`;try{const $=window.localStorage.getItem(f);$&&be.hydrate(y,JSON.parse($))}catch{window.localStorage.removeItem(f)}let i=null;const M=y.getQueryCache().subscribe($=>{$.type!=="added"&&$.type!=="removed"&&$.type!=="updated"||(i&&clearTimeout(i),i=setTimeout(()=>{try{window.localStorage.setItem(f,JSON.stringify(be.dehydrate(y)))}catch{}},250))});return()=>{i&&clearTimeout(i),M()}},[u,v,y]);const B=w.useCallback(()=>y.invalidateQueries({queryKey:["bpb",v]}),[y,v]),T=w.useCallback(f=>g==null?void 0:g(f),[g]),P=_>0?_:!1,A=w.useMemo(()=>({client:a,queryClient:y,scope:v,stripePromise:S,email:n,locale:r,isDark:m,toast:o??(()=>{}),analytics:l??un,featureLabels:c,isOutdatedBilling:d!==void 0&&d!=="v4",manageBillingUrl:h,refetchInterval:P,refresh:B,notifyBillingChange:T}),[a,y,v,S,n,r,m,o,l,c,d,h,P,B,T]);return e.jsx(ya.Provider,{value:A,children:e.jsx("div",{className:"bpb-scope","data-bpb-theme":m?"dark":"light",style:{display:"contents"},children:N})})};function U(){const a=w.useContext(ya);if(!a)throw new Error("@bpinternal/billing-ui components must be rendered inside <BillingProvider>");return a}function gn(){var a;return((a=w.useContext(ya))==null?void 0:a.isDark)??!1}const oe={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"},ce={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}=U();return be.useQuery({queryKey:ce.plans(n),queryFn:()=>a.listPlans({})},s)}function Me(){const{client:a,queryClient:s,scope:n}=U();return be.useQuery({queryKey:ce.addons(n),queryFn:()=>a.listAddons({})},s)}function ke(a){const{client:s,queryClient:n,scope:r,refetchInterval:t}=U();return be.useQuery({queryKey:ce.subscription(r),queryFn:()=>s.getSubscription({}),enabled:(a==null?void 0:a.enabled)??!0,refetchInterval:t},n)}function _a(a,s){const{client:n,queryClient:r,scope:t}=U();return be.useQuery({queryKey:ce.preview(t,a),queryFn:()=>n.previewSubscriptionUpdate(a),enabled:(s==null?void 0:s.enabled)??!0},r)}function fa(a){const{client:s,queryClient:n,scope:r}=U();return be.useQuery({queryKey:ce.paymentMethod(r),queryFn:()=>s.getPaymentMethod({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function va(a){const{client:s,queryClient:n,scope:r}=U();return be.useQuery({queryKey:ce.billingAddress(r),queryFn:()=>s.getBillingAddress({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function ka(a){const{client:s,queryClient:n,scope:r}=U();return be.useQuery({queryKey:ce.customer(r),queryFn:()=>s.getCustomer({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function Ja(a){const{client:s,queryClient:n,scope:r,refetchInterval:t}=U();return be.useQuery({queryKey:ce.invoices(r),queryFn:()=>s.listInvoices({}),enabled:(a==null?void 0:a.enabled)??!0,refetchInterval:t},n)}function Na(a){const{client:s,queryClient:n,scope:r}=U();return be.useQuery({queryKey:ce.readonly(r),queryFn:()=>s.getBillingReadonly({}),enabled:(a==null?void 0:a.enabled)??!0},n)}function Pe(a){const{client:s,queryClient:n,scope:r,refetchInterval:t}=U(),o=a!=null&&a.period?new Date(a.period):new Date,l=`${o.getUTCFullYear()}-${String(o.getUTCMonth()+1).padStart(2,"0")}`;return be.useQuery({queryKey:ce.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 Ra(a,s){const{client:n,queryClient:r,scope:t,refetchInterval:o}=U(),l=n.breakDownWorkspaceUsageByBot,c=n.listBots,d=typeof l=="function"&&typeof c=="function",p=s!=null&&s.period?new Date(s.period):new Date,u=`${p.getUTCFullYear()}-${String(p.getUTCMonth()+1).padStart(2,"0")}`;return be.useQuery({queryKey:ce.usageByBot(t,a,u),queryFn:async()=>{const[h,g]=await Promise.all([l({id:t,type:a,period:`${u}-01T00:00:00.000Z`}),c({})]),_=new Map(g.bots.map(N=>[N.id,N.name]));return h.data.map(N=>({botId:N.botId,name:_.get(N.botId)??N.botId,value:N.value})).sort((N,v)=>v.value-N.value)},enabled:d&&((s==null?void 0:s.enabled)??!0),refetchInterval:o},r)}function es(){const{client:a}=U();return typeof a.breakDownWorkspaceUsageByBot=="function"&&typeof a.listBots=="function"}function wa(){const{client:a,queryClient:s}=U();return be.useMutation({mutationFn:()=>a.createPaymentMethodIntent({})},s)}function Ca(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=U();return be.useMutation({mutationFn:t=>a.setPaymentMethod(t),onSuccess:async()=>{await s.invalidateQueries({queryKey:ce.paymentMethod(n)}),r({type:"payment-method"})}},s)}function Sa(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=U();return be.useMutation({mutationFn:async t=>{await a.setBillingAddress(t)},onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:ce.billingAddress(n)}),s.invalidateQueries({queryKey:ce.customer(n)})]),r({type:"billing-address"})}},s)}function Ia(){const{client:a,queryClient:s,scope:n}=U();return be.useMutation({mutationFn:r=>a.setCustomer(r),onSuccess:()=>s.invalidateQueries({queryKey:ce.customer(n)})},s)}function as(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=U();return be.useMutation({mutationFn:async t=>{await a.setAddons(t)},onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:ce.subscription(n)}),s.invalidateQueries({queryKey:ce.invoices(n)}),s.invalidateQueries({queryKey:["bpb",n,"preview"]})]),r({type:"addons"})}},s)}function Aa(){const{client:a,queryClient:s,scope:n,notifyBillingChange:r}=U();return be.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:ce.subscription(n)}),s.invalidateQueries({queryKey:ce.plans(n)}),s.invalidateQueries({queryKey:ce.invoices(n)}),s.invalidateQueries({queryKey:["bpb",n,"preview"]})]),r({type:"subscription"})}},s)}function ss(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=ss(a[s]))&&(r&&(r+=" "),r+=n)}else for(n in a)a[n]&&(r&&(r+=" "),r+=n);return r}function yn(){for(var a,s,n=0,r="",t=arguments.length;n<t;n++)(a=arguments[n])&&(s=ss(a))&&(r&&(r+=" "),r+=s);return r}const _n=(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},fn=(a,s)=>({classGroupId:a,validator:s}),ns=(a=new Map,s=null,n)=>({nextPart:a,validators:s,classGroupId:n}),ea="-",rs=[],vn="arbitrary..",kn=a=>{const s=wn(a),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=a;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Nn(l);const c=l.split(ea),d=c[0]===""&&c.length>1?1:0;return ts(c,d,s)},getConflictingClassGroupIds:(l,c)=>{if(c){const d=r[l],p=n[l];return d?p?_n(p,d):d:p||rs}return n[l]||rs}}},ts=(a,s,n)=>{if(a.length-s===0)return n.classGroupId;const t=a[s],o=n.nextPart.get(t);if(o){const p=ts(a,s+1,o);if(p)return p}const l=n.validators;if(l===null)return;const c=s===0?a.join(ea):a.slice(s).join(ea),d=l.length;for(let p=0;p<d;p++){const u=l[p];if(u.validator(c))return u.classGroupId}},Nn=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?vn+r:void 0})(),wn=a=>{const{theme:s,classGroups:n}=a;return Cn(n,s)},Cn=(a,s)=>{const n=ns();for(const r in a){const t=a[r];Ea(t,n,r,s)}return n},Ea=(a,s,n,r)=>{const t=a.length;for(let o=0;o<t;o++){const l=a[o];Sn(l,s,n,r)}},Sn=(a,s,n,r)=>{if(typeof a=="string"){In(a,s,n);return}if(typeof a=="function"){An(a,s,n,r);return}En(a,s,n,r)},In=(a,s,n)=>{const r=a===""?s:os(s,a);r.classGroupId=n},An=(a,s,n,r)=>{if(Tn(a)){Ea(a(r),s,n,r);return}s.validators===null&&(s.validators=[]),s.validators.push(fn(n,a))},En=(a,s,n,r)=>{const t=Object.entries(a),o=t.length;for(let l=0;l<o;l++){const[c,d]=t[l];Ea(d,os(s,c),n,r)}},os=(a,s)=>{let n=a;const r=s.split(ea),t=r.length;for(let o=0;o<t;o++){const l=r[o];let c=n.nextPart.get(l);c||(c=ns(),n.nextPart.set(l,c)),n=c}return n},Tn=a=>"isThemeGetter"in a&&a.isThemeGetter===!0,Ln=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)}}},Ta="!",ls=":",xn=[],cs=(a,s,n,r,t)=>({modifiers:a,hasImportantModifier:s,baseClassName:n,maybePostfixModifierPosition:r,isExternal:t}),Mn=a=>{const{prefix:s,experimentalParseClassName:n}=a;let r=t=>{const o=[];let l=0,c=0,d=0,p;const u=t.length;for(let v=0;v<u;v++){const y=t[v];if(l===0&&c===0){if(y===ls){o.push(t.slice(d,v)),d=v+1;continue}if(y==="/"){p=v;continue}}y==="["?l++:y==="]"?l--:y==="("?c++:y===")"&&c--}const h=o.length===0?t:t.slice(d);let g=h,_=!1;h.endsWith(Ta)?(g=h.slice(0,-1),_=!0):h.startsWith(Ta)&&(g=h.slice(1),_=!0);const N=p&&p>d?p-d:void 0;return cs(o,_,g,N)};if(s){const t=s+ls,o=r;r=l=>l.startsWith(t)?o(l.slice(t.length)):cs(xn,!1,l,void 0,!0)}if(n){const t=r;r=o=>n({className:o,parseClassName:t})}return r},Pn=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]==="[",d=s.has(l);c||d?(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}},Dn=a=>({cache:Ln(a.cacheSize),parseClassName:Mn(a),sortModifiers:Pn(a),postfixLookupClassGroupIds:Bn(a),...kn(a)}),Bn=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},zn=/\s+/,Un=(a,s)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:t,sortModifiers:o,postfixLookupClassGroupIds:l}=s,c=[],d=a.trim().split(zn);let p="";for(let u=d.length-1;u>=0;u-=1){const h=d[u],{isExternal:g,modifiers:_,hasImportantModifier:N,baseClassName:v,maybePostfixModifierPosition:y}=n(h);if(g){p=h+(p.length>0?" "+p:p);continue}let m=!!y,S;if(m){const f=v.substring(0,y);S=r(f);const i=S&&l[S]?r(v):void 0;i&&i!==S&&(S=i,m=!1)}else S=r(v);if(!S){if(!m){p=h+(p.length>0?" "+p:p);continue}if(S=r(v),!S){p=h+(p.length>0?" "+p:p);continue}m=!1}const B=_.length===0?"":_.length===1?_[0]:o(_).join(":"),T=N?B+Ta:B,P=T+S;if(c.indexOf(P)>-1)continue;c.push(P);const A=t(S,m);for(let f=0;f<A.length;++f){const i=A[f];c.push(T+i)}p=h+(p.length>0?" "+p:p)}return p},On=(...a)=>{let s=0,n,r,t="";for(;s<a.length;)(n=a[s++])&&(r=is(n))&&(t&&(t+=" "),t+=r);return t},is=a=>{if(typeof a=="string")return a;let s,n="";for(let r=0;r<a.length;r++)a[r]&&(s=is(a[r]))&&(n&&(n+=" "),n+=s);return n},Fn=(a,...s)=>{let n,r,t,o;const l=d=>{const p=s.reduce((u,h)=>h(u),a());return n=Dn(p),r=n.cache.get,t=n.cache.set,o=c,c(d)},c=d=>{const p=r(d);if(p)return p;const u=Un(d,n);return t(d,u),u};return o=l,(...d)=>o(On(...d))},$n=[],ue=a=>{const s=n=>n[a]||$n;return s.isThemeGetter=!0,s},ds=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,bs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,qn=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Wn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Gn=/\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$/,Vn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Kn=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,jn=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Le=a=>qn.test(a),F=a=>!!a&&!Number.isNaN(Number(a)),Ce=a=>!!a&&Number.isInteger(Number(a)),La=a=>a.endsWith("%")&&F(a.slice(0,-1)),Ae=a=>Wn.test(a),ps=()=>!0,Hn=a=>Gn.test(a)&&!Vn.test(a),xa=()=>!1,Yn=a=>Kn.test(a),Qn=a=>jn.test(a),Zn=a=>!C(a)&&!I(a),Xn=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)),Jn=a=>xe(a,_s,xa),C=a=>ds.test(a),De=a=>xe(a,fs,Hn),us=a=>xe(a,or,F),Rn=a=>xe(a,ks,ps),er=a=>xe(a,vs,xa),hs=a=>xe(a,gs,xa),ar=a=>xe(a,ys,Qn),aa=a=>xe(a,Ns,Yn),I=a=>bs.test(a),Ye=a=>Be(a,fs),sr=a=>Be(a,vs),ms=a=>Be(a,gs),nr=a=>Be(a,_s),rr=a=>Be(a,ys),sa=a=>Be(a,Ns,!0),tr=a=>Be(a,ks,!0),xe=(a,s,n)=>{const r=ds.exec(a);return r?r[1]?s(r[1]):n(r[2]):!1},Be=(a,s,n=!1)=>{const r=bs.exec(a);return r?r[1]?s(r[1]):n:!1},gs=a=>a==="position"||a==="percentage",ys=a=>a==="image"||a==="url",_s=a=>a==="length"||a==="size"||a==="bg-size",fs=a=>a==="length",or=a=>a==="number",vs=a=>a==="family-name",ks=a=>a==="number"||a==="weight",Ns=a=>a==="shadow",lr=Fn(()=>{const a=ue("color"),s=ue("font"),n=ue("text"),r=ue("font-weight"),t=ue("tracking"),o=ue("leading"),l=ue("breakpoint"),c=ue("container"),d=ue("spacing"),p=ue("radius"),u=ue("shadow"),h=ue("inset-shadow"),g=ue("text-shadow"),_=ue("drop-shadow"),N=ue("blur"),v=ue("perspective"),y=ue("aspect"),m=ue("ease"),S=ue("animate"),B=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...T(),I,C],A=()=>["auto","hidden","clip","visible","scroll"],f=()=>["auto","contain","none"],i=()=>[I,C,d],M=()=>[Le,"full","auto",...i()],$=()=>[Ce,"none","subgrid",I,C],se=()=>["auto",{span:["full",Ce,I,C]},Ce,I,C],x=()=>[Ce,"auto",I,C],re=()=>["auto","min","max","fr",I,C],ae=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],O=()=>["start","end","center","stretch","center-safe","end-safe"],K=()=>["auto",...i()],q=()=>[Le,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...i()],R=()=>[Le,"screen","full","dvw","lvw","svw","min","max","fit",...i()],L=()=>[Le,"screen","full","lh","dvh","lvh","svh","min","max","fit",...i()],k=()=>[a,I,C],E=()=>[...T(),ms,hs,{position:[I,C]}],W=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",nr,Jn,{size:[I,C]}],j=()=>[La,Ye,De],z=()=>["","none","full",p,I,C],H=()=>["",F,Ye,De],te=()=>["solid","dashed","dotted","double"],ve=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>[F,La,ms,hs],me=()=>["","none",N,I,C],he=()=>["none",F,I,C],Se=()=>["none",F,I,C],Ie=()=>[F,I,C],ge=()=>[Le,"full",...i()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ae],breakpoint:[Ae],color:[ps],container:[Ae],"drop-shadow":[Ae],ease:["in","out","in-out"],font:[Zn],"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",F],text:[Ae],"text-shadow":[Ae],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Le,C,I,y]}],container:["container"],"container-type":[{"@container":["","normal","size",I,C]}],"container-named":[Xn],columns:[{columns:[F,C,I,c]}],"break-after":[{"break-after":B()}],"break-before":[{"break-before":B()}],"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:P()}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:f()}],"overscroll-x":[{"overscroll-x":f()}],"overscroll-y":[{"overscroll-y":f()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[Ce,"auto",I,C]}],basis:[{basis:[Le,"full","auto",c,...i()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[F,Le,"auto","initial","none",C]}],grow:[{grow:["",F,I,C]}],shrink:[{shrink:["",F,I,C]}],order:[{order:[Ce,"first","last","none",I,C]}],"grid-cols":[{"grid-cols":$()}],"col-start-end":[{col:se()}],"col-start":[{"col-start":x()}],"col-end":[{"col-end":x()}],"grid-rows":[{"grid-rows":$()}],"row-start-end":[{row:se()}],"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":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:i()}],"gap-x":[{"gap-x":i()}],"gap-y":[{"gap-y":i()}],"justify-content":[{justify:[...ae(),"normal"]}],"justify-items":[{"justify-items":[...O(),"normal"]}],"justify-self":[{"justify-self":["auto",...O()]}],"align-content":[{content:["normal",...ae()]}],"align-items":[{items:[...O(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...O(),{baseline:["","last"]}]}],"place-content":[{"place-content":ae()}],"place-items":[{"place-items":[...O(),"baseline"]}],"place-self":[{"place-self":["auto",...O()]}],p:[{p:i()}],px:[{px:i()}],py:[{py:i()}],ps:[{ps:i()}],pe:[{pe:i()}],pbs:[{pbs:i()}],pbe:[{pbe:i()}],pt:[{pt:i()}],pr:[{pr:i()}],pb:[{pb:i()}],pl:[{pl:i()}],m:[{m:K()}],mx:[{mx:K()}],my:[{my:K()}],ms:[{ms:K()}],me:[{me:K()}],mbs:[{mbs:K()}],mbe:[{mbe:K()}],mt:[{mt:K()}],mr:[{mr:K()}],mb:[{mb:K()}],ml:[{ml:K()}],"space-x":[{"space-x":i()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":i()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],"inline-size":[{inline:["auto",...R()]}],"min-inline-size":[{"min-inline":["auto",...R()]}],"max-inline-size":[{"max-inline":["none",...R()]}],"block-size":[{block:["auto",...L()]}],"min-block-size":[{"min-block":["auto",...L()]}],"max-block-size":[{"max-block":["none",...L()]}],w:[{w:[c,"screen",...q()]}],"min-w":[{"min-w":[c,"screen","none",...q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[l]},...q()]}],h:[{h:["screen","lh",...q()]}],"min-h":[{"min-h":["screen","lh","none",...q()]}],"max-h":[{"max-h":["screen","lh",...q()]}],"font-size":[{text:["base",n,Ye,De]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,tr,Rn]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",La,C]}],"font-family":[{font:[sr,er,s]}],"font-features":[{"font-features":[C]}],"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,I,C]}],"line-clamp":[{"line-clamp":[F,"none",I,us]}],leading:[{leading:[o,...i()]}],"list-image":[{"list-image":["none",I,C]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",I,C]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:k()}],"text-color":[{text:k()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...te(),"wavy"]}],"text-decoration-thickness":[{decoration:[F,"from-font","auto",I,De]}],"text-decoration-color":[{decoration:k()}],"underline-offset":[{"underline-offset":[F,"auto",I,C]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:i()}],"tab-size":[{tab:[Ce,I,C]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",I,C]}],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",I,C]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:E()}],"bg-repeat":[{bg:W()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ce,I,C],radial:["",I,C],conic:[Ce,I,C]},rr,ar]}],"bg-color":[{bg:k()}],"gradient-from-pos":[{from:j()}],"gradient-via-pos":[{via:j()}],"gradient-to-pos":[{to:j()}],"gradient-from":[{from:k()}],"gradient-via":[{via:k()}],"gradient-to":[{to:k()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"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:[...te(),"hidden","none"]}],"divide-style":[{divide:[...te(),"hidden","none"]}],"border-color":[{border:k()}],"border-color-x":[{"border-x":k()}],"border-color-y":[{"border-y":k()}],"border-color-s":[{"border-s":k()}],"border-color-e":[{"border-e":k()}],"border-color-bs":[{"border-bs":k()}],"border-color-be":[{"border-be":k()}],"border-color-t":[{"border-t":k()}],"border-color-r":[{"border-r":k()}],"border-color-b":[{"border-b":k()}],"border-color-l":[{"border-l":k()}],"divide-color":[{divide:k()}],"outline-style":[{outline:[...te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[F,I,C]}],"outline-w":[{outline:["",F,Ye,De]}],"outline-color":[{outline:k()}],shadow:[{shadow:["","none",u,sa,aa]}],"shadow-color":[{shadow:k()}],"inset-shadow":[{"inset-shadow":["none",h,sa,aa]}],"inset-shadow-color":[{"inset-shadow":k()}],"ring-w":[{ring:H()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:k()}],"ring-offset-w":[{"ring-offset":[F,De]}],"ring-offset-color":[{"ring-offset":k()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":k()}],"text-shadow":[{"text-shadow":["none",g,sa,aa]}],"text-shadow-color":[{"text-shadow":k()}],opacity:[{opacity:[F,I,C]}],"mix-blend":[{"mix-blend":[...ve(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ve()}],"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":[F]}],"mask-image-linear-from-pos":[{"mask-linear-from":Q()}],"mask-image-linear-to-pos":[{"mask-linear-to":Q()}],"mask-image-linear-from-color":[{"mask-linear-from":k()}],"mask-image-linear-to-color":[{"mask-linear-to":k()}],"mask-image-t-from-pos":[{"mask-t-from":Q()}],"mask-image-t-to-pos":[{"mask-t-to":Q()}],"mask-image-t-from-color":[{"mask-t-from":k()}],"mask-image-t-to-color":[{"mask-t-to":k()}],"mask-image-r-from-pos":[{"mask-r-from":Q()}],"mask-image-r-to-pos":[{"mask-r-to":Q()}],"mask-image-r-from-color":[{"mask-r-from":k()}],"mask-image-r-to-color":[{"mask-r-to":k()}],"mask-image-b-from-pos":[{"mask-b-from":Q()}],"mask-image-b-to-pos":[{"mask-b-to":Q()}],"mask-image-b-from-color":[{"mask-b-from":k()}],"mask-image-b-to-color":[{"mask-b-to":k()}],"mask-image-l-from-pos":[{"mask-l-from":Q()}],"mask-image-l-to-pos":[{"mask-l-to":Q()}],"mask-image-l-from-color":[{"mask-l-from":k()}],"mask-image-l-to-color":[{"mask-l-to":k()}],"mask-image-x-from-pos":[{"mask-x-from":Q()}],"mask-image-x-to-pos":[{"mask-x-to":Q()}],"mask-image-x-from-color":[{"mask-x-from":k()}],"mask-image-x-to-color":[{"mask-x-to":k()}],"mask-image-y-from-pos":[{"mask-y-from":Q()}],"mask-image-y-to-pos":[{"mask-y-to":Q()}],"mask-image-y-from-color":[{"mask-y-from":k()}],"mask-image-y-to-color":[{"mask-y-to":k()}],"mask-image-radial":[{"mask-radial":[I,C]}],"mask-image-radial-from-pos":[{"mask-radial-from":Q()}],"mask-image-radial-to-pos":[{"mask-radial-to":Q()}],"mask-image-radial-from-color":[{"mask-radial-from":k()}],"mask-image-radial-to-color":[{"mask-radial-to":k()}],"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":T()}],"mask-image-conic-pos":[{"mask-conic":[F]}],"mask-image-conic-from-pos":[{"mask-conic-from":Q()}],"mask-image-conic-to-pos":[{"mask-conic-to":Q()}],"mask-image-conic-from-color":[{"mask-conic-from":k()}],"mask-image-conic-to-color":[{"mask-conic-to":k()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:E()}],"mask-repeat":[{mask:W()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",I,C]}],filter:[{filter:["","none",I,C]}],blur:[{blur:me()}],brightness:[{brightness:[F,I,C]}],contrast:[{contrast:[F,I,C]}],"drop-shadow":[{"drop-shadow":["","none",_,sa,aa]}],"drop-shadow-color":[{"drop-shadow":k()}],grayscale:[{grayscale:["",F,I,C]}],"hue-rotate":[{"hue-rotate":[F,I,C]}],invert:[{invert:["",F,I,C]}],saturate:[{saturate:[F,I,C]}],sepia:[{sepia:["",F,I,C]}],"backdrop-filter":[{"backdrop-filter":["","none",I,C]}],"backdrop-blur":[{"backdrop-blur":me()}],"backdrop-brightness":[{"backdrop-brightness":[F,I,C]}],"backdrop-contrast":[{"backdrop-contrast":[F,I,C]}],"backdrop-grayscale":[{"backdrop-grayscale":["",F,I,C]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[F,I,C]}],"backdrop-invert":[{"backdrop-invert":["",F,I,C]}],"backdrop-opacity":[{"backdrop-opacity":[F,I,C]}],"backdrop-saturate":[{"backdrop-saturate":[F,I,C]}],"backdrop-sepia":[{"backdrop-sepia":["",F,I,C]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":i()}],"border-spacing-x":[{"border-spacing-x":i()}],"border-spacing-y":[{"border-spacing-y":i()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",I,C]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[F,"initial",I,C]}],ease:[{ease:["linear","initial",m,I,C]}],delay:[{delay:[F,I,C]}],animate:[{animate:["none",S,I,C]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,I,C]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:Se()}],"scale-x":[{"scale-x":Se()}],"scale-y":[{"scale-y":Se()}],"scale-z":[{"scale-z":Se()}],"scale-3d":["scale-3d"],skew:[{skew:Ie()}],"skew-x":[{"skew-x":Ie()}],"skew-y":[{"skew-y":Ie()}],transform:[{transform:[I,C,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ge()}],"translate-x":[{"translate-x":ge()}],"translate-y":[{"translate-y":ge()}],"translate-z":[{"translate-z":ge()}],"translate-none":["translate-none"],zoom:[{zoom:[Ce,I,C]}],accent:[{accent:k()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:k()}],"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",I,C]}],"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":k()}],"scrollbar-track-color":[{"scrollbar-track":k()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":i()}],"scroll-mx":[{"scroll-mx":i()}],"scroll-my":[{"scroll-my":i()}],"scroll-ms":[{"scroll-ms":i()}],"scroll-me":[{"scroll-me":i()}],"scroll-mbs":[{"scroll-mbs":i()}],"scroll-mbe":[{"scroll-mbe":i()}],"scroll-mt":[{"scroll-mt":i()}],"scroll-mr":[{"scroll-mr":i()}],"scroll-mb":[{"scroll-mb":i()}],"scroll-ml":[{"scroll-ml":i()}],"scroll-p":[{"scroll-p":i()}],"scroll-px":[{"scroll-px":i()}],"scroll-py":[{"scroll-py":i()}],"scroll-ps":[{"scroll-ps":i()}],"scroll-pe":[{"scroll-pe":i()}],"scroll-pbs":[{"scroll-pbs":i()}],"scroll-pbe":[{"scroll-pbe":i()}],"scroll-pt":[{"scroll-pt":i()}],"scroll-pr":[{"scroll-pr":i()}],"scroll-pb":[{"scroll-pb":i()}],"scroll-pl":[{"scroll-pl":i()}],"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",I,C]}],fill:[{fill:["none",...k()]}],"stroke-w":[{stroke:[F,Ye,De,us]}],stroke:[{stroke:["none",...k()]}],"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 D(...a){return lr(yn(a))}function Z(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 ws(a,s){const n=new Date(a);return n.setDate(n.getDate()+s),n.toISOString()}function ee(a){return new Intl.NumberFormat("en-US").format(a)}function ze(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 ne(a){return a.replace("Plan - ","")}function Qe(a){return{usd:"$",eur:"€",gbp:"£",cad:"$",aud:"$",jpy:"¥"}[a.toLowerCase()]??`${a.toUpperCase()} `}const Ue=["community","plus","team","enterprise","managed"],cr=["community","plus","team","enterprise","managed"];function ie(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 cr.find(t=>t===n)??"community"}const Ma="https://botpress.com/contact-us/managed-plan",na={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:["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:[]},Pa={"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."},ir=[{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 Da(a,s){var n;return s!=null&&s[a]?s[a]:Pa[a]?Pa[a]:(n=ir.find(r=>r.test.test(a)))==null?void 0:n.describe(a)}function ra(a,s,n){return a.prices[s.id]??a.prices[ie(s)]??a.prices[n]??null}function Ze(a){return a.replace("Add-on - ","")}function Cs(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 Ss=[{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 Is(a,s,n){var t;if(!s)return[];const r=[];for(const o of Ss){const l=a.features[o.key]??0;let c=0;for(const d of s){const p=((t=d.increments)==null?void 0:t[o.key])??0,u=n[d.id]??0;c+=p*u}c>0&&r.push({...o,now:l,next:l+c})}return r}function As(a,s,n){var t;if(!a)return[];const r=[];for(const o of Ss){const l=a.features[o.key]??0;let c=0;for(const d of s??[])c+=(((t=d.increments)==null?void 0:t[o.key])??0)*(n[d.id]??0);(l>0||c>0)&&r.push({...o,base:l,added:c,total:l+c})}return r}function ta(a,s,n){var l;const r=Cs(a);if(!r)return null;const t=((l=r.increments)==null?void 0:l.conversation_sessions)??0,o=ra(r,s,n);return t<=0||!o||o.amount<=0?null:{packSize:t,amount:o.amount,currency:o.currency}}const oa=({variant:a="accent",children:s,className:n})=>e.jsx("span",{className:D("bpb-badge",`bpb-badge--${a}`,n),children:s}),pe=({variant:a="primary",size:s="md",block:n=!1,loading:r=!1,className:t,disabled:o,children:l,type:c="button",...d})=>e.jsxs("button",{type:c,className:D("bpb-btn",`bpb-btn--${a}`,`bpb-btn--${s}`,n&&"bpb-btn--block",t),disabled:o||r,"data-loading":r||void 0,...d,children:[r&&e.jsx("span",{className:"bpb-btn__spinner","aria-hidden":!0}),e.jsx("span",{className:"bpb-btn__label",children:l})]}),J=(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}),Es=({size:a,...s})=>e.jsx("svg",{...J(a,s),children:e.jsx("path",{d:"M3 8.5l3.5 3.5L13 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ba=({size:a,...s})=>e.jsxs("svg",{...J(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"})]}),Ts=({size:a,...s})=>e.jsx("svg",{...J(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"})}),za=({size:a,...s})=>e.jsxs("svg",{...J(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"})]}),Ls=({size:a,...s})=>e.jsx("svg",{...J(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"})}),la=({size:a,...s})=>e.jsxs("svg",{...J(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",{...J(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"})}),ca=({size:a,...s})=>e.jsx("svg",{...J(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"})}),Ms=({size:a,...s})=>e.jsxs("svg",{...J(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"})]}),Ps=({size:a,...s})=>e.jsxs("svg",{...J(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"})]}),Ds=({size:a,...s})=>e.jsxs("svg",{...J(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",{...J(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"})]}),Ua=({size:a,...s})=>e.jsxs("svg",{...J(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"})]}),dr=({size:a,...s})=>e.jsx("svg",{...J(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"})}),br=({size:a,...s})=>e.jsxs("svg",{...J(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"})]}),ia=({size:a,...s})=>e.jsx("svg",{...J(a,s),children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),da=({size:a,...s})=>e.jsx("svg",{...J(a,s),children:e.jsx("path",{d:"M4 6.5L8 10.5l4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Oa=({size:a,...s})=>e.jsx("svg",{...J(a,s),children:e.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Oe=({size:a,...s})=>e.jsx("svg",{...J(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",{...J(a,s),children:e.jsx("path",{d:"M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Us=({size:a,...s})=>e.jsx("svg",{...J(a,s),children:e.jsx("path",{d:"M8 3.5v9M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Os=({size:a,...s})=>e.jsxs("svg",{...J(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"})]}),Xe=({size:a,...s})=>e.jsx("svg",{...J(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"})}),pr=({size:a,...s})=>e.jsxs("svg",{...J(a,s),children:[e.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M8 10.5V5.5M5.5 8l2.5-2.5L10.5 8",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),ba=({size:a,...s})=>e.jsx("svg",{...J(a,s),children:e.jsx("path",{d:"M3 8h10M9 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Fa=({size:a,...s})=>e.jsx("svg",{...J(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"})}),ur=({size:a,...s})=>e.jsxs("svg",{...J(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"})]}),Fs=({size:a,...s})=>e.jsxs("svg",{...J(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"})]}),$a=({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 pa(a){const s=a.toLowerCase();return/seat|member|user|team|rbac|rout/.test(s)?Ms:/analytic|report|insight|dashboard/.test(s)?Ps:/whatsapp|channel|chat|message|conversation|webchat|voice/.test(s)?Ts:/storage|table|vector|file|gb|rows|db/.test(s)?la:/domain|help center|whitelabel|website|url|web/.test(s)?Ds:/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)?za:/integration|api|plugin|sdk|adk|studio/.test(s)?Ls:/ai|agent|model|gpt|llm/.test(s)?ca:Ba}const fe=({open:a,onOpenChange:s,size:n="md",children:r,className:t,showClose:o=!0,...l})=>{const c=w.useRef(null),d=gn(),p=w.useCallback(()=>s(!1),[s]);return w.useEffect(()=>{var g;if(!a)return;const u=_=>{_.key==="Escape"&&p()};document.addEventListener("keydown",u);const h=document.body.style.overflow;return document.body.style.overflow="hidden",(g=c.current)==null||g.focus(),()=>{document.removeEventListener("keydown",u),document.body.style.overflow=h}},[a,p]),a?pn.createPortal(e.jsx("div",{className:"bpb-portal bpb-dialog__overlay","data-bpb-theme":d?"dark":"light",onClick:p,children:e.jsxs("div",{ref:c,role:"dialog","aria-modal":"true","aria-label":l["aria-label"],tabIndex:-1,className:D("bpb-dialog",`bpb-dialog--${n}`,t),onClick:u=>u.stopPropagation(),children:[o&&e.jsx("button",{type:"button",className:"bpb-dialog__close","aria-label":"Close",onClick:p,children:e.jsx(ia,{size:18})}),r]})}),document.body):null},Je=({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})]}),Fe=()=>{const{manageBillingUrl:a}=U();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(pe,{variant:"primary",onClick:()=>window.open(a,"_blank","noopener"),children:["Open billing in Dashboard",e.jsx(Xe,{size:15})]})]})},$s=({options:a,value:s,onChange:n,className:r,...t})=>e.jsx("div",{role:"radiogroup","aria-label":t["aria-label"],className:D("bpb-segmented",r),children:a.map(o=>{const l=o.value===s;return e.jsxs("button",{type:"button",role:"radio","aria-checked":l,className:D("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)})}),G=({width:a,height:s=14,rounded:n=!1,className:r})=>e.jsx("span",{"aria-hidden":!0,className:D("bpb-skeleton",n&&"bpb-skeleton--rounded",r),style:{width:a??"100%",height:s}});function hr(a,s){const n=a.prices[s];return n||((s==="month"?a.prices.year:a.prices.month)??null)}function mr(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 gr(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 qs=({open:a,onOpenChange:s,onSelectPlan:n,recommendedPlanId:r="team",defaultInterval:t="year",excludePlanIds:o=[],planFeatures:l={},featureDescriptions:c})=>{var K,q,R;const{isOutdatedBilling:d,toast:p,analytics:u}=U(),[h,g]=w.useState(t),{data:_,isLoading:N}=we(),{data:v}=Me(),{data:y}=ke({enabled:a}),{data:m}=Na({enabled:a}),S=Aa(),B=(m==null?void 0:m.planReadonly)??!1;w.useEffect(()=>{a&&u.capture(oe.PLAN_PICKER_VIEWED,{interval:h})},[a,u]);const T=L=>{L!==h&&u.capture(oe.PLAN_INTERVAL_TOGGLED,{interval:L}),g(L)},P=y==null?void 0:y.plan.current.interval,A=_==null?void 0:_.find(L=>L.id===(y==null?void 0:y.plan.current.planId)),f=y?A?ie(A):"community":void 0,i=((K=y==null?void 0:y.plan.next)==null?void 0:K.planId)??null,M=!!i&&i!==(y==null?void 0:y.plan.current.planId),$=B||f==="enterprise"||f==="managed",se=w.useMemo(()=>_?_.filter(L=>ie(L)!=="managed"&&ie(L)!=="enterprise"&&!o.includes(L.id)).sort((L,k)=>Ue.indexOf(ie(L))-Ue.indexOf(ie(k))):[],[_,o]),x=w.useMemo(()=>gr(se),[se]),re=((R=(q=_==null?void 0:_.find(L=>ie(L)==="enterprise"))==null?void 0:q.metadata)==null?void 0:R.contact_url)??Ma,ae=L=>{S.mutate({planId:L.id,interval:h},{onSuccess:()=>{u.capture(oe.PLAN_DOWNGRADED,{plan_name:ne(L.name),interval:h,previous_plan_name:A?ne(A.name):void 0}),p({type:"success",message:"Plan downgraded"})},onError:()=>p({type:"error",message:"Downgrade failed"})})},O=()=>{y&&S.mutate({planId:y.plan.current.planId,interval:y.plan.current.interval},{onSuccess:()=>{u.capture(oe.PLAN_DOWNGRADE_CANCELLED,{plan_name:A?ne(A.name):y.plan.current.planId}),p({type:"success",message:"Scheduled downgrade canceled"})},onError:()=>p({type:"error",message:"Could not cancel the downgrade"})})};return d?e.jsx(fe,{open:a,onOpenChange:s,size:"md","aria-label":"Upgrade your plan",className:"bpb-scope",children:e.jsx(Fe,{})}):e.jsx(fe,{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:h,onChange:T,options:[{value:"month",label:"Monthly"},{value:"year",label:"Annual",badge:x>0?`Save ${x}%`:void 0}]})}),e.jsxs("div",{className:"bpb-upgrade__grid",children:[N&&[0,1,2].map(L=>e.jsxs("div",{className:"bpb-plan-card","aria-hidden":!0,children:[e.jsx(G,{width:120,height:22}),e.jsx(G,{width:90,height:40}),e.jsx(G,{width:"100%",height:36,rounded:!0}),e.jsx(G,{width:"100%",height:140})]},L)),se.map((L,k)=>{var le,X;const E=ie(L),W=hr(L,h),V=mr(L,h),j=(((le=L.prices.month)==null?void 0:le.amount)??0)<=0,z=E===f&&(f==="community"||h===P),H=E===f&&f!=="community"&&h!==P,te=!!i&&L.id===i&&!z,ve=f!==void 0&&Ue.indexOf(E)<Ue.indexOf(f),Q=(E===r||L.id===r)&&!z,me=z&&M?"cancel_downgrade":z?"current":H?"switch_interval":te?"next":ve?"downgrade":"upgrade",he=k>0?se[k-1]:void 0,Se=l[E]??na[E],Ie=L.features.conversation_sessions,ge=ta(v,L,h),Y=S.isPending&&(me==="downgrade"&&((X=S.variables)==null?void 0:X.planId)===L.id||me==="cancel_downgrade");return e.jsxs("div",{className:D("bpb-plan-card",Q&&"bpb-plan-card--highlighted bpb-glow"),"data-plan-id":L.id,children:[e.jsxs("div",{className:"bpb-plan-card__header",children:[e.jsxs("h3",{className:"bpb-plan-card__name",children:[ne(L.name),Q&&e.jsx(oa,{className:"bpb-plan-card__badge",children:"Recommended"})]}),e.jsx("p",{className:"bpb-plan-card__tagline",children:L.description}),e.jsx("div",{className:"bpb-plan-card__price",children:V!==null&&W?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bpb-plan-card__currency",children:Qe(W.currency)}),e.jsx("span",{className:"bpb-plan-card__amount",children:Number.isInteger(V)?V:V.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:Z(0,"usd",0)})})]}),Ie!==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:ee(Ie)}),e.jsxs("span",{className:"bpb-plan-card__metric-unit",children:["conversations",j?"":" / month"]})]}),ge?e.jsxs("p",{className:"bpb-plan-card__pack",children:["then ",Z(ge.amount,ge.currency,0)," per"," ",ee(ge.packSize)," more"]}):e.jsx("p",{className:"bpb-plan-card__pack",children:"No top-up"})]}),me==="current"&&e.jsx(pe,{variant:"outline",block:!0,disabled:!0,children:"Your current plan"}),me==="next"&&e.jsx(pe,{variant:"outline",block:!0,disabled:!0,children:"Next plan"}),me==="cancel_downgrade"&&e.jsx(pe,{variant:"primary",block:!0,loading:Y,onClick:O,children:"Cancel downgrade"}),me==="downgrade"&&e.jsx(pe,{variant:"outline",block:!0,disabled:$||S.isPending,loading:Y,onClick:()=>ae(L),children:"Downgrade"}),me==="switch_interval"&&e.jsx(pe,{variant:"primary",block:!0,disabled:$||S.isPending,title:$?"Your plan is managed by Botpress — contact us to change it":void 0,onClick:()=>{u.capture(oe.PLAN_UPGRADE_INITIATED,{plan_name:ne(L.name),interval:h,current_plan_name:A?ne(A.name):void 0}),n(L.id,h)},children:h==="year"?"Switch to annual":"Switch to monthly"}),me==="upgrade"&&e.jsx(pe,{variant:Q?"accent":"primary",block:!0,disabled:$||S.isPending,title:$?"Your plan is managed by Botpress — contact us to change it":void 0,onClick:()=>{u.capture(oe.PLAN_UPGRADE_INITIATED,{plan_name:ne(L.name),interval:h,current_plan_name:A?ne(A.name):void 0}),n(L.id,h)},children:"Upgrade"}),e.jsxs("ul",{className:"bpb-plan-card__features",children:[he&&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(Es,{size:13})}),e.jsxs("span",{children:["Everything in ",ne(he.name)]})]}),Se.map(de=>{const Ne=pa(de),$e=Da(de,c);return e.jsxs("li",{children:[e.jsx("span",{className:"bpb-plan-card__feature-chip",children:e.jsx(Ne,{size:13})}),$e?e.jsx(Je,{label:de,children:$e}):e.jsx("span",{children:de})]},de)})]})]},L.id)})]}),e.jsxs("p",{className:"bpb-upgrade__footer",children:["Need more, or running at scale?"," ",e.jsx("a",{href:re,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"}),"."]})]})})},qa='-apple-system, "ui-sans-serif", "system-ui", "Segoe UI", Helvetica, Arial, sans-serif',Wa="14px",Ws="10px";function Ga(a){return a?{theme:"night",variables:{fontFamily:qa,fontSizeBase:Wa,borderRadius:Ws,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:qa,fontSizeBase:Wa,borderRadius:Ws,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 Va(a){return{base:{fontFamily:qa,fontSize:Wa,color:a?"#f9f9f9":"#0d0d0d","::placeholder":{color:a?"#9b9b9b":"#8f8f8f"}},invalid:{color:a?"#ff8583":"#e02e2a"}}}const yr={pt:"pt-BR",es:"es-419"};function Ka(a){const s=a.split("-")[0]??a;return yr[s]??a}const _r=4,fr=({plan:a,interval:s,preview:n,isLoadingPreview:r,isPreviewError:t,canSubscribe:o,isSubmitting:l,onSubscribe:c})=>{var x,re,ae,O,K;const{locale:d}=U(),{data:p}=Me(),u=((x=a==null?void 0:a.prices.month)==null?void 0:x.currency)??((re=a==null?void 0:a.prices.year)==null?void 0:re.currency)??"usd",h=a==null?void 0:a.features.conversation_sessions,g=a&&ie(a)==="community"?"conversations":"conversations / month",_=a?ta(p,a,s):null,N=(n==null?void 0:n.costs.immediate.amountDue)??0,v=(n==null?void 0:n.costs.immediate.accountBalance)??0,y=(n==null?void 0:n.costs.nextCycle.total)??0,m=n!=null&&n.nextBillingDate?Ee(ws(n.nextBillingDate,1),d):null,S=a?na[ie(a)].slice(0,_r):[],B=a?((ae=a.prices[s])==null?void 0:ae.amount)??0:0,T=(n==null?void 0:n.costs.immediate.lineItems)??[],P=T.filter(q=>q.type==="discount"),A=T.filter(q=>q.type==="proration_credit"||q.type==="proration_charge").reduce((q,R)=>q+R.amount,0),f=!!(n!=null&&n.subscription.plan.effectiveDate),i=((O=a==null?void 0:a.prices.month)==null?void 0:O.amount)??0,M=((K=a==null?void 0:a.prices.year)==null?void 0:K.amount)??0,$=s==="year"&&i>0&&M>0?Math.round(i*12-M):0,se=Math.round($/12);return e.jsxs("div",{className:"bpb-summary-wrap",children:[e.jsxs("div",{className:"bpb-summary bpb-glow",children:[e.jsx("h3",{className:"bpb-summary__title",children:a?`${ne(a.name)} plan`:e.jsx(G,{width:140,height:24})}),h!==void 0&&e.jsxs("div",{className:"bpb-summary__metric",children:[e.jsx("span",{className:"bpb-summary__metric-value",children:ee(h)}),e.jsx("span",{className:"bpb-summary__metric-unit",children:g}),_&&e.jsxs("span",{className:"bpb-summary__metric-pack",children:["then ",Z(_.amount,_.currency,0)," per ",ee(_.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(q=>{const R=pa(q);return e.jsxs("li",{children:[e.jsx(R,{size:16,className:"bpb-summary__feature-icon"}),e.jsx("span",{children:q})]},q)})})]}),e.jsx("hr",{className:"bpb-summary__divider"}),r&&e.jsxs("div",{className:"bpb-summary__lines","aria-busy":"true",children:[e.jsx(G,{height:16}),e.jsx(G,{height:16}),e.jsx(G,{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&&f&&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?ne(a.name):""," plan",m?` — from ${m}`:""]}),e.jsxs("span",{className:"bpb-summary__line-amount",children:[Z(y,u),s==="year"?"/yr":"/mo"]})]}),e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:e.jsx(Je,{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:Z(N,u)})]}),e.jsxs("div",{className:"bpb-summary__line bpb-summary__line--total",children:[e.jsx("span",{children:"Due today"}),e.jsx("span",{children:Z(N,u)})]}),A<0&&e.jsxs("p",{className:"bpb-summary__addon-note",children:["You have ",Z(Math.abs(A),u)," of unused time credited toward your next invoice."]})]}),n&&!r&&!f&&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?ne(a.name):""," plan (",s==="year"?"annual":"monthly",")"]}),e.jsxs("span",{className:"bpb-summary__line-amount",children:[Z(B,u),s==="year"?"/yr":"/mo"]})]}),P.map((q,R)=>e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:q.description}),e.jsx("span",{className:"bpb-summary__line-amount",children:Z(q.amount,u)})]},`${q.id}-${R}`)),A!==0&&e.jsxs("div",{className:"bpb-summary__line",children:[e.jsx("span",{className:"bpb-summary__line-label",children:e.jsx(Je,{label:A<0?"Credit for unused time":"Adjustment for unused time",children:A<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:Z(A,u)})]}),v!==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:Z(v,u)})]}),e.jsxs("div",{className:"bpb-summary__line bpb-summary__line--total",children:[e.jsx("span",{children:"Due today"}),e.jsx("span",{children:Z(N,u)})]}),A<0&&N===0&&e.jsxs("p",{className:"bpb-summary__addon-note",children:["Your remaining balance of ",Z(Math.abs(A),u)," is applied as credit on your next invoice."]})]}),$>0&&e.jsxs("div",{className:"bpb-summary__savings",children:[e.jsx(Ba,{size:18,className:"bpb-summary__savings-icon"}),e.jsxs("span",{children:["You’re saving ",Z(se,u,0),"/month by choosing an annual plan. That’s"," ",Z($,u,0),"/year."]})]}),e.jsx(pe,{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 ${Z(y,u)}${s==="month"?"/month":"/year"}${m?` starting ${m}`:""}.`," ","Cancel anytime in Settings. By subscribing, you authorize Botpress to store and charge your payment method."]})]})},vr=["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"],kr={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"}]},Nr=[{type:"eu_vat",label:"EU VAT",description:"European VAT number"}];function Gs(a){if(!a)return[];const s=a.toUpperCase();return vr.includes(s)?Nr:kr[s]??[]}const ua=({label:a,className:s,id:n,...r})=>a?e.jsxs("label",{className:D("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:D("bpb-input__field",s),id:n,...r}),ja=({label:a,className:s,children:n,...r})=>e.jsxs("label",{className:D("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:D("bpb-input__field bpb-input__field--select",a&&"bpb-input__field--labeled"),...r,children:n}),e.jsx(da,{size:16,className:"bpb-input__chevron"})]})]}),wr=({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:D("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:[Z(r.amount,r.currency,0)," /mo"]})]}),t&&e.jsxs("button",{type:"button",role:"radio","aria-checked":s==="year",className:D("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(oa,{children:["Save ",o,"%"]})]}),e.jsxs("span",{className:"bpb-interval-card__price",children:[Z(t.amount/12,t.currency,0)," /mo"]})]})]})]})},Vs=({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"})]}),Cr=({stepNumber:a,savedCard:s,isDark:n,tab:r,onTabChange:t,onPaymentChange:o})=>{const[l,c]=w.useState(!1),d=r==="new"||!s;return e.jsxs("section",{className:"bpb-step",children:[e.jsx(Vs,{number:a,title:"Payment method"}),s&&e.jsxs("div",{className:"bpb-pay-tabs",role:"tablist","aria-label":"Payment method",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":r==="saved",className:D("bpb-pay-tab",r==="saved"&&"bpb-pay-tab--selected"),onClick:()=>t("saved"),children:[e.jsx(Ua,{size:16}),"Saved"]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":r==="new",className:D("bpb-pay-tab",r==="new"&&"bpb-pay-tab--selected"),onClick:()=>t("new"),children:[e.jsx(Ua,{size:16}),"New card"]})]}),s&&r==="saved"&&e.jsxs("div",{className:"bpb-saved-card",children:[e.jsx($a,{brand:s.brand}),e.jsxs("span",{className:"bpb-saved-card__number",children:[e.jsx("span",{className:"bpb-saved-card__brand",children:s.brand})," •••• ",s.lastFour]}),e.jsxs("span",{className:"bpb-saved-card__exp",children:[String(s.expMonth).padStart(2,"0"),"/",String(s.expYear).slice(-2)]})]}),d&&e.jsxs("div",{className:"bpb-payment-element",children:[!l&&e.jsx("div",{className:"bpb-payment-element__skeleton",children:e.jsx(G,{height:48})}),e.jsx("div",{className:D("bpb-card-element",!l&&"bpb-payment-element--hidden"),children:e.jsx(_e.CardElement,{options:{style:Va(n),hidePostalCode:!0},onReady:()=>c(!0),onChange:p=>o(p.complete)})})]})]})},Sr=({stepNumber:a,existingAddress:s,customerName:n,isLoading:r,editing:t,onEdit:o,onCancelEdit:l,onCompleteChange:c,onCountryChange:d,country:p,isBusiness:u,onIsBusinessChange:h,businessName:g,onBusinessNameChange:_,taxType:N,onTaxTypeChange:v,taxValue:y,onTaxValueChange:m})=>{const[S,B]=w.useState(!1),T=t||!s,P=Gs(p),A=P.find(f=>f.type===N);return e.jsxs("section",{className:"bpb-step",children:[e.jsx(Vs,{number:a,title:"Billing address"}),r?e.jsx(G,{height:72}):T?e.jsxs("div",{className:"bpb-payment-element",children:[!S&&e.jsxs("div",{className:"bpb-payment-element__skeleton",children:[e.jsx(G,{height:48}),e.jsx(G,{height:48})]}),e.jsx("div",{className:D(!S&&"bpb-payment-element--hidden"),children:e.jsx(_e.AddressElement,{options:{mode:"billing",display:{name:"full"},defaultValues:s?{name:n??void 0,address:{line1:s.lineOne,line2:s.lineTwo,city:s.city,state:s.state,postal_code:s.postalCode,country:s.country}}:void 0},onReady:()=>B(!0),onChange:f=>{c(f.complete),d(f.value.address.country||void 0)}})}),l&&t&&e.jsx("button",{type:"button",className:"bpb-address-cancel",onClick:l,children:"Cancel"})]}):e.jsxs("div",{className:"bpb-address-card",children:[e.jsxs("div",{className:"bpb-address-card__lines",children:[n&&e.jsx("span",{className:"bpb-address-card__name",children:n}),e.jsxs("span",{children:[s.lineOne,s.lineTwo?`, ${s.lineTwo}`:""]}),e.jsxs("span",{children:[s.city," ",s.state??""," ",s.postalCode," ",s.country]})]}),e.jsx("button",{type:"button",className:"bpb-link-button",onClick:o,children:"Update"})]}),e.jsxs("label",{className:"bpb-checkbox",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:f=>{h(f.target.checked),f.target.checked&&!N&&P[0]&&v(P[0].type)}}),e.jsx("span",{children:"I’m purchasing as business"})]}),u&&e.jsxs("div",{className:"bpb-business-fields",children:[e.jsx("h4",{className:"bpb-step__subtitle",children:"Business details"}),e.jsx(ua,{placeholder:"Business name",value:g,onChange:f=>_(f.target.value),autoComplete:"organization"}),P.length>0?e.jsxs(e.Fragment,{children:[e.jsx(ja,{"aria-label":"Tax ID type",value:N,onChange:f=>v(f.target.value),children:P.map(f=>e.jsxs("option",{value:f.type,children:[f.label," — ",f.description]},f.type))}),e.jsx(ua,{placeholder:A?A.description:"Tax ID number",value:y,onChange:f=>m(f.target.value),inputMode:"text"})]}):e.jsx("p",{className:"bpb-business-fields__note",children:p?"No tax ID is required for your billing country.":"Select your billing country above to add a tax ID."})]})]})},Ir=({planId:a,initialInterval:s,clientSecret:n,onSuccess:r})=>{var rn;const t=_e.useStripe(),o=_e.useElements(),{email:l,toast:c,analytics:d,isDark:p}=U(),[u,h]=w.useState(s),[g,_]=w.useState("payment"),[N,v]=w.useState(null),[y,m]=w.useState(!1),[S,B]=w.useState(!1),[T,P]=w.useState(!1),[A,f]=w.useState(void 0),[i,M]=w.useState(!1),[$,se]=w.useState(""),[x,re]=w.useState(""),[ae,O]=w.useState(""),[K,q]=w.useState(!1),[R,L]=w.useState(null),{data:k}=we(),{data:E}=ke(),{data:W,isLoading:V}=fa(),{data:j,isLoading:z}=va(),{data:H}=ka(),te=k==null?void 0:k.find(ye=>ye.id===a),ve=((rn=W==null?void 0:W.paymentMethod)==null?void 0:rn.card)??null,Q=(j==null?void 0:j.address)??null;w.useEffect(()=>{N===null&&!V&&W!==void 0&&v(ve?"saved":"new")},[N,V,W,ve]),w.useEffect(()=>{A===void 0&&Q&&f(Q.country)},[A,Q]);const me=w.useMemo(()=>({plan:{planId:a,interval:u}}),[a,u]),he=_a(me),Se=Ca(),Ie=Sa(),ge=Ia(),Y=Aa(),le=te?ne(te.name):"",X=N==="new"||!ve,de=S||!Q,Ne=X?y:!!ve,$e=de?T:!0;w.useEffect(()=>{_(Ne?"address":"payment")},[Ne]),w.useEffect(()=>{d.capture(oe.CHECKOUT_STEP_VIEWED,{plan_name:le,interval:u,step:g})},[d,g]);const Qa=ye=>{ye!==u&&d.capture(oe.CHECKOUT_INTERVAL_CHANGED,{plan_name:le,interval:ye}),h(ye)},nn=ye=>{d.capture(oe.PAYMENT_METHOD_SELECTED,{method:ye==="saved"?"saved_card":"new_card"}),v(ye)},qe=!!t&&!!o&&!!te&&!he.isError&&!!he.data&&Ne&&$e&&!K,Jr=async()=>{var tn,on,ln,cn;if(!t||!o||!te)return;q(!0),L(null);const ye=(We,ga)=>d.capture(oe.CHECKOUT_ERROR,{plan_name:le,interval:u,step:g,reason:We,message:ga});try{if(d.capture(oe.PAYMENT_DETAILS_CONFIRMED,{plan_name:le,interval:u}),X){const Ge=o.getElement(_e.CardElement);if(!Ge){L("Card field is not ready"),ye("card_element_not_ready");return}const{error:Ve,setupIntent:Te}=await t.confirmCardSetup(n,{payment_method:{card:Ge}});if(Ve){L(Ve.message??"Payment setup failed"),d.capture(oe.CHECKOUT_ERROR,{plan_name:le,interval:u,step:g,reason:Ve.code??"card_setup_failed",decline_code:Ve.decline_code,message:Ve.message});return}if(!(Te!=null&&Te.payment_method)||typeof Te.payment_method!="string"){L("Could not retrieve payment method"),ye("payment_method_missing");return}await Se.mutateAsync({paymentMethodId:Te.payment_method})}let We;if(de){const Ge=o.getElement("address");if(Ge){const{complete:Ve,value:Te}=await Ge.getValue();if(!Ve||!Te.address){L("Please complete your billing address"),ye("address_incomplete");return}const{address:He}=Te;We=((tn=Te.name)==null?void 0:tn.trim())||void 0,await Ie.mutateAsync({lineOne:He.line1??"",lineTwo:He.line2??void 0,city:He.city??"",state:He.state??void 0,postalCode:He.postal_code??"",country:He.country??""})}}const ga=i&&$.trim()||We||void 0,dn=i&&x&&ae.trim()?[{type:x,value:ae.trim()}]:void 0;(ga!==void 0||dn!==void 0)&&await ge.mutateAsync({name:ga,taxIds:dn});const Rr=((on=he.data)==null?void 0:on.costs.immediate.amountDue)??0,et=((ln=he.data)==null?void 0:ln.costs.nextCycle.total)??0;await Y.mutateAsync({planId:a,interval:u}),d.capture(oe.PLAN_UPGRADED,{plan_name:le,interval:u,amount_paid:Rr,next_cycle_amount:et,previous_plan_name:(cn=k==null?void 0:k.find(Ge=>Ge.id===(E==null?void 0:E.plan.current.planId)))==null?void 0:cn.name.replace("Plan - ",""),previous_interval:E==null?void 0:E.plan.current.interval}),c({type:"success",message:"Subscription activated"}),r()}catch(We){L("Something went wrong while processing your payment. You have not been charged twice."),ye("exception",We instanceof Error?We.message:void 0),c({type:"error",message:"Payment error"})}finally{q(!1)}};return e.jsxs("div",{className:"bpb-checkout__columns",children:[e.jsxs("div",{className:"bpb-checkout__main",children:[te&&e.jsx(wr,{plan:te,interval:u,onChange:Qa}),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(Cr,{stepNumber:1,savedCard:ve,isDark:p,tab:N??"new",onTabChange:nn,onPaymentChange:m}),g==="address"&&e.jsx(Sr,{stepNumber:2,existingAddress:Q,customerName:(H==null?void 0:H.name)??null,isLoading:z,editing:S,onEdit:()=>B(!0),onCancelEdit:Q?()=>B(!1):void 0,onCompleteChange:P,onCountryChange:f,country:A,isBusiness:i,onIsBusinessChange:M,businessName:$,onBusinessNameChange:se,taxType:x,onTaxTypeChange:re,taxValue:ae,onTaxValueChange:O}),R&&e.jsx("p",{role:"alert",className:"bpb-checkout__submit-error",children:R})]}),e.jsx("div",{className:"bpb-checkout__aside",children:e.jsx(fr,{plan:te,interval:u,preview:he.data,isLoadingPreview:he.isLoading,isPreviewError:he.isError,canSubscribe:qe,isSubmitting:K,onSubscribe:()=>void Jr()})})]})},Ks=({open:a,onOpenChange:s,planId:n,interval:r,onBack:t,onSuccess:o})=>{var v;const{stripePromise:l,isDark:c,locale:d,isOutdatedBilling:p}=U(),u=wa(),h=(v=u.data)==null?void 0:v.clientSecret,{mutate:g,reset:_}=u;w.useEffect(()=>{a&&!p?g():_()},[a,p,g,_]);const N=w.useMemo(()=>h?{clientSecret:h,appearance:Ga(c),locale:Ka(d)}:null,[h,c,d]);return p?e.jsx(fe,{open:a,onOpenChange:s,size:"md","aria-label":"Configure your plan",className:"bpb-scope",children:e.jsx(Fe,{})}):e.jsx(fe,{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(Oa,{size:18})}),e.jsx("h2",{className:"bpb-checkout__title",children:"Configure your plan"})]}),u.isError?e.jsxs("div",{className:"bpb-checkout__error-state",children:[e.jsx("p",{children:"We couldn’t start the payment session."}),u.error instanceof Error&&u.error.message&&e.jsx("p",{className:"bpb-checkout__error-detail",children:u.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(pe,{variant:"outline",onClick:()=>g(),children:"Try again"})]}):!N||!h?e.jsxs("div",{className:"bpb-checkout__columns","aria-busy":"true",children:[e.jsxs("div",{className:"bpb-checkout__main",children:[e.jsx(G,{height:56}),e.jsx(G,{height:56}),e.jsx(G,{height:120}),e.jsx(G,{height:56})]}),e.jsx("div",{className:"bpb-checkout__aside",children:e.jsx(G,{height:320})})]}):e.jsx(_e.Elements,{stripe:l,options:N,children:e.jsx(Ir,{planId:n,initialInterval:r,clientSecret:h,onSuccess:()=>{s(!1),o==null||o()}})})]})})},js=({value:a,onChange:s,min:n=0,max:r,step:t=1,className:o,...l})=>{const c=()=>s(Math.max(n,a-t)),d=()=>s(r===void 0?a+t:Math.min(r,a+t));return e.jsxs("div",{className:D("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:d,disabled:r!==void 0&&a>=r,children:e.jsx(Us,{size:14})})]})},Ar=({open:a,onOpenChange:s,onSuccess:n,onUpgrade:r})=>{const{isOutdatedBilling:t}=U();return t?e.jsx(fe,{open:a,onOpenChange:s,size:"md","aria-label":"Manage add-ons",className:"bpb-scope",children:e.jsx(Fe,{})}):e.jsx(fe,{open:a,onOpenChange:s,size:"md","aria-label":"Manage add-ons",className:"bpb-scope",children:e.jsx(Er,{onOpenChange:s,onSuccess:n,onUpgrade:r})})},Er=({onOpenChange:a,onSuccess:s,onUpgrade:n})=>{var q,R,L,k;const{toast:r,locale:t}=U(),{data:o}=ke(),{data:l}=Me(),{data:c}=we(),{data:d}=Na(),p=as(),[u,h]=w.useState(null),g=c==null?void 0:c.find(E=>E.id===(o==null?void 0:o.plan.current.planId)),_=(o==null?void 0:o.plan.current.interval)??"month",N=(d==null?void 0:d.addonsReadonly)??!1,v=o!=null&&o.plan.current.periodEnd?Ee(o.plan.current.periodEnd,t):null,y=w.useMemo(()=>{var W;if(!o||!l)return null;const E={};for(const V of l){const j=o.addons[V.id];E[V.id]=((W=j==null?void 0:j.next)==null?void 0:W.quantity)??(j==null?void 0:j.current.quantity)??0}return E},[o,l]),m=u??y,S=w.useMemo(()=>!l||!g?[]:l.flatMap(E=>{const W=ra(E,g,_);return W?[{addon:E,price:W}]:[]}),[l,g,_]),B=!!m&&!!y&&Object.keys(m).some(E=>m[E]!==y[E]),T=S.reduce((E,{addon:W,price:V})=>E+((m==null?void 0:m[W.id])??0)*V.amount,0),P=w.useMemo(()=>g&&m?{plan:{planId:g.id,interval:_},addons:m}:null,[g,_,m]),A=_a(P??{plan:{planId:"",interval:_}},{enabled:!!P&&B}),f=((q=g==null?void 0:g.prices[_])==null?void 0:q.currency)??"usd",i=((R=A.data)==null?void 0:R.costs.immediate.amountDue)??0,M=(L=A.data)!=null&&L.nextBillingDate?Ee(A.data.nextBillingDate,t):null,$=((k=g==null?void 0:g.prices[_])==null?void 0:k.amount)??0,se=$+T,x=g&&m?Is(g,l,m):[],re=(E,W)=>W==="bytes"?ze(E):ee(E),ae=(E,W)=>{const V=l==null?void 0:l.find(te=>te.id===E),j=V==null?void 0:V.increments;if(!j||W<=0)return null;const z=j.conversation_sessions??0;if(z>0)return`${ee(z*W)} convos`;const H=j.file_storage??0;return H>0?ze(H*W):null},O=()=>{m&&p.mutate({addons:m},{onSuccess:()=>{r({type:"success",message:"Subscription updated"}),a(!1),s==null||s()},onError:()=>r({type:"error",message:"Could not update your add-ons"})})},K=!o||!l||!c;return e.jsxs("div",{className:"bpb-manage-addons",children:[e.jsx("h2",{className:"bpb-manage-addons__title",children:"Manage add-ons"}),(K||S.length>0)&&e.jsx("p",{className:"bpb-manage-addons__subtitle",children:g?`Additional usage for your ${ne(g.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."}),K?e.jsxs("div",{className:"bpb-manage-addons__loading","aria-busy":"true",children:[e.jsx(G,{height:56}),e.jsx(G,{height:56})]}):S.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bpb-manage-addons__upgrade-gate",children:[e.jsx(pr,{size:28,className:"bpb-manage-addons__upgrade-icon"}),e.jsxs("div",{className:"bpb-manage-addons__upgrade-text",children:[e.jsx("p",{className:"bpb-manage-addons__upgrade-title",children:"Add-ons require a paid plan"}),e.jsx("p",{className:"bpb-manage-addons__upgrade-body",children:"Upgrade your plan to unlock extra conversations, storage, and more."})]})]}),e.jsx("div",{className:"bpb-manage-addons__actions",children:n?e.jsx(pe,{variant:"primary",className:"bpb-manage-addons__upgrade-cta",onClick:()=>{a(!1),n()},children:"Upgrade plan"}):e.jsx(pe,{variant:"outline",onClick:()=>a(!1),children:"Close"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bpb-addons",children:S.map(({addon:E,price:W})=>{var H;const V=((H=o==null?void 0:o.addons[E.id])==null?void 0:H.current.quantity)??0,j=(m==null?void 0:m[E.id])??0,z=j!==V?j===0?`${V} active now · removed${v?` ${v}`:" next cycle"}`:`${V} active now · ${j}${v?` from ${v}`:" next cycle"}`:V>0?`${V} 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:Ze(E.name)}),e.jsx("span",{className:"bpb-addon-row__description",children:E.description}),e.jsxs("span",{className:"bpb-addon-row__price",children:[Z(W.amount,W.currency)," each"]}),z&&e.jsx("span",{className:D("bpb-addon-row__status",j!==V&&"bpb-addon-row__status--changed"),children:z})]}),e.jsxs("div",{className:"bpb-addon-row__control",children:[ae(E.id,j)&&e.jsx("span",{className:"bpb-addon-row__grant",children:ae(E.id,j)}),e.jsx(js,{"aria-label":`${Ze(E.name)} quantity`,value:j,onChange:te=>h({...m??{},[E.id]:te})})]})]},E.id)})}),x.length>0&&e.jsxs("div",{className:"bpb-manage-addons__limits",children:[e.jsx("p",{className:"bpb-manage-addons__limits-title",children:"Your new limits"}),x.map(E=>e.jsxs("div",{className:"bpb-manage-addons__limit-row",children:[e.jsx("span",{className:"bpb-manage-addons__limit-label",children:E.label}),e.jsxs("span",{className:"bpb-manage-addons__limit-values",children:[e.jsx("span",{className:"bpb-manage-addons__limit-now",children:re(E.now,E.unit)}),e.jsx("span",{className:"bpb-manage-addons__limit-arrow","aria-hidden":!0,children:"→"}),e.jsx("span",{className:"bpb-manage-addons__limit-next",children:re(E.next,E.unit)})]})]},E.key))]}),e.jsxs("div",{className:"bpb-manage-addons__totals",children:[e.jsxs("div",{className:"bpb-manage-addons__line",children:[e.jsx("span",{children:g?`${ne(g.name)} plan`:"Plan"}),e.jsx("span",{children:Z($,f)})]}),S.map(({addon:E,price:W})=>{const V=(m==null?void 0:m[E.id])??0;return V<=0?null:e.jsxs("div",{className:"bpb-manage-addons__line",children:[e.jsxs("span",{children:[V,"× ",Ze(E.name)]}),e.jsx("span",{children:Z(W.amount*V,f)})]},E.id)}),e.jsxs("div",{className:"bpb-manage-addons__line bpb-manage-addons__line--total",children:[e.jsxs("span",{children:["Total ",_==="year"?"yearly":"monthly"," cost"]}),e.jsxs("span",{children:[Z(se,f),_==="year"?"/yr":"/mo"]})]}),B&&e.jsxs("div",{className:"bpb-manage-addons__line bpb-manage-addons__line--due",children:[e.jsx("span",{children:"Due today"}),e.jsx("span",{children:A.isLoading?"…":A.isError?"—":Z(Math.max(i,0),f)})]})]}),B&&!A.isError&&e.jsxs("p",{className:"bpb-manage-addons__note",children:[i>0?`You’ll be charged ${Z(i,f)} 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",M?` on ${M}`:"",", when you’ll be billed ",Z(T,f),_==="year"?"/yr":"/mo"," for them."]}),N&&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(pe,{variant:"outline",onClick:()=>a(!1),disabled:p.isPending,children:"Cancel"}),e.jsx(pe,{variant:"primary",disabled:!B||N,loading:p.isPending,onClick:O,children:"Update subscription"})]})]})]})},Tr={paid:"Paid",open:"Due",draft:"Draft",uncollectible:"Unpaid",void:"Void"},Lr=({open:a,onOpenChange:s})=>{const{isOutdatedBilling:n}=U();return n?e.jsx(fe,{open:a,onOpenChange:s,size:"md","aria-label":"Billing history",className:"bpb-scope",children:e.jsx(Fe,{})}):e.jsx(fe,{open:a,onOpenChange:s,size:"md","aria-label":"Billing history",className:"bpb-scope",children:e.jsx(xr,{open:a})})},xr=({open:a})=>{const{locale:s,analytics:n}=U(),{data:r,isLoading:t,isError:o}=Ja({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(G,{height:52}),e.jsx(G,{height:52}),e.jsx(G,{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:Tr[c.status]})]}),e.jsxs("div",{className:"bpb-invoices__row-end",children:[e.jsx("span",{className:"bpb-invoices__amount",children:Z(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(oe.INVOICE_DOWNLOADED,{status:c.status}),children:e.jsx(Fa,{size:16})}):e.jsx("span",{className:"bpb-invoices__download bpb-invoices__download--disabled","aria-hidden":!0,children:e.jsx(Fa,{size:16})})]})]},c.id))})]})},Mr=({open:a,onOpenChange:s,onSuccess:n})=>{var g;const{stripePromise:r,isDark:t,locale:o,isOutdatedBilling:l}=U(),c=wa(),d=(g=c.data)==null?void 0:g.clientSecret,{mutate:p,reset:u}=c;w.useEffect(()=>{a&&!l?p():u()},[a,l,p,u]);const h=w.useMemo(()=>d?{clientSecret:d,appearance:Ga(t),locale:Ka(o)}:null,[d,t,o]);return l?e.jsx(fe,{open:a,onOpenChange:s,size:"md","aria-label":"Payment & billing",className:"bpb-scope",children:e.jsx(Fe,{})}):e.jsx(fe,{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(pe,{variant:"outline",onClick:()=>p(),children:"Try again"})]}):!h||!d?e.jsxs("div",{className:"bpb-payment-dialog__loading","aria-busy":"true",children:[e.jsx(G,{height:48}),e.jsx(G,{height:120})]}):e.jsx(_e.Elements,{stripe:r,options:h,children:e.jsx(Pr,{clientSecret:d,isDark:t,onSuccess:n})})]})})},Pr=({clientSecret:a,isDark:s,onSuccess:n})=>{var ge;const r=_e.useStripe(),t=_e.useElements(),{toast:o,analytics:l}=U(),{data:c,isLoading:d}=fa(),{data:p,isLoading:u}=va(),{data:h,isLoading:g}=ka(),_=Ca(),N=Sa(),v=Ia(),y=((ge=c==null?void 0:c.paymentMethod)==null?void 0:ge.card)??null,m=(p==null?void 0:p.address)??null,S=(h==null?void 0:h.taxIds)??[],[B,T]=w.useState(!1),[P,A]=w.useState(!1),[f,i]=w.useState(!1),[M,$]=w.useState(!1),[se,x]=w.useState(null),[re,ae]=w.useState(!1),[O,K]=w.useState(!1),[q,R]=w.useState(null),[L,k]=w.useState(m==null?void 0:m.country),[E,W]=w.useState(S.length>0),[V,j]=w.useState(null),z=V??S.map(Y=>({type:Y.type,value:Y.value})),H=Gs(L),te=V!==null,ve=B||!y,Q=(Y,le)=>j(z.map((X,de)=>de===Y?{...X,...le}:X)),me=()=>{var Y;return j([...z,{type:((Y=H[0])==null?void 0:Y.type)??"",value:""}])},he=Y=>j(z.filter((le,X)=>X!==Y)),Se=async()=>{if(!r||!t)return;const Y=t.getElement(_e.CardElement);if(Y){$(!0),x(null);try{const{error:le,setupIntent:X}=await r.confirmCardSetup(a,{payment_method:{card:Y}});if(le){x(le.message??"Could not save your card");return}if(!(X!=null&&X.payment_method)||typeof X.payment_method!="string"){x("Could not retrieve payment method");return}await _.mutateAsync({paymentMethodId:X.payment_method}),l.capture(oe.PAYMENT_METHOD_UPDATED),o({type:"success",message:"Card updated"}),T(!1),n==null||n()}catch{x("We couldn’t save your card. Please check your details and try again.")}finally{$(!1)}}},Ie=async()=>{if(!t)return;const Y=t.getElement("address");if(!Y)return;const{complete:le,value:X}=await Y.getValue();if(!le||!X.address){R("Please complete your billing address.");return}K(!0),R(null);try{const{address:de,name:Ne}=X;await N.mutateAsync({lineOne:de.line1??"",lineTwo:de.line2??void 0,city:de.city??"",state:de.state??void 0,postalCode:de.postal_code??"",country:de.country??""});const $e=(Ne==null?void 0:Ne.trim())||void 0,Qa=z.filter(qe=>!!qe.type&&qe.value.trim()!=="").map(qe=>({type:qe.type,value:qe.value.trim()}));($e!==((h==null?void 0:h.name)??void 0)||te)&&await v.mutateAsync({name:$e,taxIds:Qa}),l.capture(oe.BILLING_ADDRESS_UPDATED),o({type:"success",message:"Billing details updated"}),n==null||n()}catch(de){const Ne=de instanceof Error&&de.message?de.message:"Could not update your billing details.";R(Ne),o({type:"error",message:"Could not update your billing details"})}finally{K(!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"}),d?e.jsx(G,{height:56}):ve?e.jsxs("div",{className:"bpb-payment-element",children:[!P&&e.jsx(G,{height:48}),e.jsx("div",{className:P?"bpb-card-element":"bpb-payment-element--hidden",children:e.jsx(_e.CardElement,{options:{style:Va(s),hidePostalCode:!0},onReady:()=>A(!0),onChange:Y=>i(Y.complete)})}),se&&e.jsx("p",{role:"alert",className:"bpb-payment-dialog__field-error",children:se}),e.jsxs("div",{className:"bpb-payment-dialog__section-actions",children:[y&&e.jsx(pe,{variant:"ghost",onClick:()=>T(!1),disabled:M,children:"Cancel"}),e.jsx(pe,{variant:"primary",disabled:!f,loading:M,onClick:Se,children:"Save card"})]})]}):e.jsxs("div",{className:"bpb-saved-card",children:[e.jsx($a,{brand:y.brand}),e.jsxs("span",{className:"bpb-saved-card__number",children:[e.jsx("span",{className:"bpb-saved-card__brand",children:y.brand})," •••• ",y.lastFour]}),e.jsxs("span",{className:"bpb-saved-card__exp",children:[String(y.expMonth).padStart(2,"0"),"/",String(y.expYear).slice(-2)]}),e.jsx("button",{type:"button",className:"bpb-link-button",onClick:()=>T(!0),children:"Replace"})]})]}),e.jsxs("section",{className:"bpb-payment-dialog__section",children:[e.jsx("h3",{className:"bpb-payment-dialog__section-title",children:"Billing address"}),u||g?e.jsx(G,{height:72}):e.jsxs("div",{className:"bpb-payment-element",children:[!re&&e.jsx(G,{height:120}),e.jsx("div",{className:re?void 0:"bpb-payment-element--hidden",children:e.jsx(_e.AddressElement,{options:{mode:"billing",display:{name:"full"},defaultValues:m?{name:(h==null?void 0:h.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:()=>ae(!0),onChange:Y=>k(Y.value.address.country||void 0)})}),e.jsxs("div",{className:"bpb-tax-section",children:[e.jsxs("button",{type:"button",className:"bpb-tax-toggle","aria-expanded":E,onClick:()=>W(Y=>!Y),children:[e.jsx(da,{size:16,className:D("bpb-tax-toggle__chevron",E&&"bpb-tax-toggle__chevron--open")}),"Tax IDs",S.length>0&&e.jsx("span",{className:"bpb-tax-toggle__count",children:S.length})]}),E&&e.jsxs("div",{className:"bpb-tax",children:[z.length===0&&e.jsx("p",{className:"bpb-tax__empty",children:"Add a VAT or tax registration number to show it on your invoices."}),z.map((Y,le)=>e.jsxs("div",{className:"bpb-tax__row",children:[e.jsxs(ja,{"aria-label":"Tax ID type",value:Y.type,onChange:X=>Q(le,{type:X.target.value}),children:[e.jsx("option",{value:"",children:"Select type"}),H.map(X=>e.jsx("option",{value:X.type,children:X.label},X.type)),Y.type&&!H.some(X=>X.type===Y.type)&&e.jsx("option",{value:Y.type,children:Y.type})]}),e.jsx(ua,{placeholder:"Tax ID number",value:Y.value,onChange:X=>Q(le,{value:X.target.value})}),e.jsx("button",{type:"button",className:"bpb-tax__remove","aria-label":"Remove tax ID",onClick:()=>he(le),children:e.jsx(ia,{size:14})})]},le)),e.jsx("button",{type:"button",className:"bpb-link-button bpb-tax__add",onClick:me,children:"+ Add tax ID"})]})]}),q&&e.jsx("p",{role:"alert",className:"bpb-payment-dialog__field-error",children:q}),e.jsx("div",{className:"bpb-payment-dialog__section-actions",children:e.jsx(pe,{variant:"primary",loading:O,onClick:Ie,children:"Save billing details"})})]})]})]})},Hs=(a,s,n)=>`bpb-dismissed:${a}:${s}:${n}`,Ys=()=>new Date().toLocaleDateString("en-CA");function Qs(a,s,n){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Hs(a,s,n))===Ys()}catch{return!1}}function Zs(a,s,n){if(!(typeof window>"u"))try{window.localStorage.setItem(Hs(a,s,n),Ys())}catch{}}const ha=1e9,Xs={incoming_messages_events:a=>`${ee(a)} incoming messages & events`,conversation_sessions:a=>`${ee(a)} conversation sessions`,table_rows:a=>`${ee(a)} table rows`,vector_db_storage:a=>`${ze(a)} vector database storage`,file_storage:a=>`${ze(a)} file storage`,collaborator_count:a=>a===1?"1 collaborator":`${ee(a)} collaborators`,bot_count:a=>a===1?"1 bot":`${ee(a)} bots`,indexed_file_count:a=>`${ee(a)} indexed files for RAG`,ai_spend:a=>`${Z(a/ha,"usd",0)} AI credit included`,always_alive:a=>a===1?"1 always-alive bot":`${ee(a)} always-alive bots`};function Dr(a,s,n){const r=(n==null?void 0:n[a])??Xs[a];return r?r(s):`${ee(s)} ${a.replaceAll("_"," ")}`}const 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 Ke(a,s){return s==="bytes"?ze(a):s==="nano-usd"?`$${(a/ha).toFixed(2)}`:ee(a)}function ma(a){return a>=90?"critical":a>=75?"warning":"normal"}function Re(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 Rs="outgrow-free",Br=.75,zr=5;function Ur(a,s){return a.prices[s]??(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}const Fr=({open:a,onOpenChange:s,onSelectPlan:n,recommendedPlanId:r="team",interval:t="year",planFeatures:o={},featureDescriptions:l,period:c})=>{var re,ae;const{isOutdatedBilling:d,analytics:p,scope:u}=U(),{data:h}=we(),{data:g}=Me(),{data:_}=ke({enabled:!d}),{data:N}=Pe({period:c,enabled:!d}),v=a!==void 0,[y,m]=w.useState(!1),S=h==null?void 0:h.find(O=>O.id===(_==null?void 0:_.plan.current.planId)),B=_?S?ie(S)==="community":!0:!1,T=w.useMemo(()=>Re(N).find(O=>O.key==="conversation_sessions"),[N]),P=!v&&!d&&B&&!!T&&T.pct/100>=Br&&!y&&!Qs(Rs,u,"modal"),A=v?!!a:P;w.useEffect(()=>{A&&p.capture(oe.PLAN_PICKER_VIEWED,{source:v?"outgrow_free":"outgrow_free_auto",interval:t})},[A,v,p]);const f=()=>{v||(Zs(Rs,u,"modal"),m(!0)),s==null||s(!1)},i=w.useMemo(()=>h?h.filter(O=>{const K=ie(O);return K!=="community"&&K!=="enterprise"&&K!=="managed"}).sort((O,K)=>Ue.indexOf(ie(O))-Ue.indexOf(ie(K))):[],[h]),M=((ae=(re=h==null?void 0:h.find(O=>ie(O)==="enterprise"))==null?void 0:re.metadata)==null?void 0:ae.contact_url)??Ma;if(d||!A)return null;const $=(T==null?void 0:T.quota)??(S==null?void 0:S.features.conversation_sessions)??100,se=(T==null?void 0:T.used)??0,x=T&&T.pct>0?Math.min(100,Math.max(5,Math.round(T.pct))):0;return e.jsx(fe,{open:A,onOpenChange:f,size:"xl","aria-label":"You’re about to outgrow the Free plan",children:e.jsxs("div",{className:"bpb-outgrow",children:[e.jsxs("header",{className:"bpb-outgrow__head",children:[e.jsx("h2",{className:"bpb-outgrow__title",children:"You’re about to outgrow the Free plan"}),e.jsxs("p",{className:"bpb-outgrow__lede",children:["Free includes ",e.jsxs("strong",{children:[ee($)," conversations total"]}),", and they don’t renew. Upgrading moves you to a ",e.jsx("strong",{children:"monthly allowance"}),", unlocks more channels, and adds conversation packs, so your agents never stop replying."]})]}),e.jsxs("div",{className:"bpb-outgrow__usage",children:[e.jsx("span",{className:"bpb-outgrow__usage-label",children:"So far"}),e.jsx("span",{className:"bpb-outgrow__usage-bar",role:"progressbar","aria-valuenow":x,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("span",{className:"bpb-outgrow__usage-fill",style:{width:`${x}%`}})}),e.jsxs("span",{className:"bpb-outgrow__usage-text",children:[e.jsxs("strong",{children:[ee(se)," of ",ee($)]})," ","free conversations used · they don’t renew"]})]}),e.jsx("div",{className:"bpb-outgrow__grid",children:i.map((O,K)=>{const q=ie(O),R=Ur(O,t),L=Or(O,t),k=q===r||O.id===r,E=O.features.conversation_sessions,W=ta(g,O,t),V=K>0?i[K-1]:void 0,j=(o[q]??na[q]).slice(0,zr);return e.jsxs("div",{className:D("bpb-plan-card",k&&"bpb-plan-card--highlighted bpb-glow"),"data-plan-id":O.id,children:[e.jsxs("div",{className:"bpb-plan-card__header",children:[e.jsxs("h3",{className:"bpb-plan-card__name",children:[ne(O.name),k&&e.jsx(oa,{className:"bpb-plan-card__badge",children:"Recommended"})]}),e.jsx("div",{className:"bpb-plan-card__price",children:L!==null&&R?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bpb-plan-card__currency",children:Qe(R.currency)}),e.jsx("span",{className:"bpb-plan-card__amount",children:Number.isInteger(L)?L:L.toFixed(2).replace(/\.00$/,"")}),e.jsx("span",{className:"bpb-plan-card__per",children:"/mo"})]}):e.jsxs("span",{className:"bpb-plan-card__amount",children:[Qe((R==null?void 0:R.currency)??"usd"),"0"]})})]}),E!==void 0&&e.jsxs("div",{className:"bpb-outgrow__allowance",children:[e.jsxs("p",{className:"bpb-outgrow__allowance-value",children:[e.jsxs("strong",{children:[ee(E)," conversations"]})," /mo"]}),e.jsx("p",{className:"bpb-outgrow__allowance-pack",children:W?`then ${Qe(W.currency)}${W.amount} per ${ee(W.packSize)} more`:"No top-up"})]}),e.jsxs(pe,{variant:k?"accent":"outline",block:!0,onClick:()=>{p.capture(oe.PLAN_UPGRADE_INITIATED,{plan_name:ne(O.name),interval:t,source:"outgrow_free"}),n(O.id,t),f()},children:["Upgrade to ",ne(O.name),k&&e.jsx(ba,{size:15})]}),e.jsxs("ul",{className:"bpb-plan-card__features",children:[V&&e.jsxs("li",{className:"bpb-outgrow__features-lead",children:["Everything in ",ne(V.name),", and"]}),j.map(z=>{const H=pa(z),te=Da(z,l);return e.jsxs("li",{children:[e.jsx("span",{className:"bpb-plan-card__feature-chip",children:e.jsx(H,{size:13})}),te?e.jsx(Je,{label:z,children:te}):e.jsx("span",{children:z})]},z)})]})]},O.id)})}),e.jsxs("footer",{className:"bpb-outgrow__footer",children:[e.jsxs("span",{children:["Need custom volume, SLAs, or voice?"," ",e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",children:"Talk to sales"})]}),e.jsxs("a",{className:"bpb-outgrow__compare",href:"https://botpress.com/pricing",target:"_blank",rel:"noopener noreferrer",children:["Compare all plans",e.jsx(Xe,{size:14})]})]})]})})},$r=[{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"}],je=(a,s)=>s==="bytes"?ze(a):s==="nano-usd"?`$${(a/ha).toFixed(2)}`:ee(a),qr=(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"})}})},Wr=({period:a})=>{const{data:s,isLoading:n,isError:r}=Ra("ai_spend",{period:a});if(r)return null;if(n)return e.jsx(G,{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:je(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))})},Ha=({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",d=n??a.quota,p=Math.max(0,a.quota-d),u=r?`${r} plan`:"your plan",h=p>0?`${je(d,s.unit)} from ${u} + ${je(p,s.unit)} from add-ons`:`${je(a.quota,s.unit)} from ${u}`;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:je(t,s.unit)}),e.jsxs("span",{className:"bpb-usage-row__quota",children:[" / ",je(a.quota,s.unit)]})]})]}),e.jsxs("span",{className:"bpb-usage-tip",tabIndex:0,role:"note","aria-label":h,children:[e.jsx("div",{className:"bpb-usage-bar",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:D("bpb-usage-bar__fill",`bpb-usage-bar__fill--${c}`),style:{width:`${l}%`}})}),e.jsx("span",{className:"bpb-usage-tip__bubble",role:"tooltip",children:h})]})]})},Gr=({period:a,showPeriodSelector:s=!0,periodMonths:n=12,className:r})=>{var f;const{isOutdatedBilling:t,locale:o}=U(),l=w.useMemo(()=>qr(n,o),[n,o]),[c,d]=w.useState(a??((f=l[0])==null?void 0:f.value)??""),p=es(),u=Math.max(0,l.findIndex(i=>i.value===c)),h=i=>{const M=l[u+i];M&&d(M.value)},{data:g,isLoading:_,isError:N}=Pe({period:c,enabled:!t}),{data:v}=ke({enabled:!t}),{data:y}=we(),m=y==null?void 0:y.find(i=>i.id===(v==null?void 0:v.plan.current.planId)),S=m?ne(m.name):void 0,B=i=>m==null?void 0:m.features[i];if(t)return e.jsx("div",{className:D("bpb-usage bpb-scope",r),children:e.jsx(Fe,{})});if(_)return e.jsxs("div",{className:D("bpb-usage bpb-scope",r),"aria-busy":"true",children:[e.jsx(G,{height:80}),e.jsx(G,{height:140})]});if(N||!g)return e.jsx("div",{className:D("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 T=g.conversation_sessions,P=g.ai_spend,A=$r.filter(i=>g[i.key]);return e.jsxs("div",{className:D("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:()=>h(1),disabled:u>=l.length-1,children:e.jsx(Oa,{size:15})}),e.jsxs("span",{className:"bpb-usage__period-field",children:[e.jsx(Fs,{size:15,className:"bpb-usage__period-icon"}),e.jsx("select",{className:"bpb-usage__period-select","aria-label":"Billing period",value:c,onChange:i=>d(i.target.value),children:l.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))}),e.jsx(da,{size:14,className:"bpb-usage__period-chevron"})]}),e.jsx("button",{type:"button",className:"bpb-usage__period-step","aria-label":"Next month",onClick:()=>h(-1),disabled:u<=0,children:e.jsx(Oe,{size:15})})]})]})]}),T&&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(Ha,{entry:T,metric:{key:"conversation_sessions",label:"Conversations",unit:"count"},planAllowance:B("conversation_sessions"),planName:S})})]}),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(i=>e.jsx(Ha,{entry:g[i.key],metric:i,planAllowance:B(i.key),planName:S},i.key))})]}),P&&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(Ha,{entry:P,metric:{key:"ai_spend",label:"AI spend",unit:"nano-usd"}})}),p&&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(Wr,{period:c})]})]})]})},en="usage-banner",Vr={conversation_sessions:"monthly conversations",table_rows:"table rows",vector_db_storage:"vector DB storage",file_storage:"file storage",ai_spend:"AI spend"},Kr=({position:a="inline",threshold:s=.9,onUpgrade:n,dismissible:r=!0,ctaLabel:t="Upgrade plan",period:o,className:l})=>{const{isOutdatedBilling:c,analytics:d,scope:p}=U(),{data:u}=Pe({period:o,enabled:!c}),[h,g]=w.useState({}),[_,N]=w.useState(!1),[v,y]=w.useState(null),m=u?Object.entries(u).map(([i,M])=>({key:i,pct:M.quota>0?(M.usage??0)/M.quota:0})).filter(i=>i.pct>=s).sort((i,M)=>M.pct-i.pct)[0]:void 0,S=!!m&&(h[m.key]||Qs(en,p,m.key));if(c||!m||S)return null;const B=Vr[m.key]??m.key.replace(/_/g," "),T=Math.min(100,Math.round(m.pct*100)),P=m.pct>=1,A=()=>{d.capture(oe.UPGRADE_CTA_CLICKED,{source:"usage_banner",metric:m.key,usage_pct:Math.round(m.pct*100)}),n?n():N(!0)},f=P?"critical":"warning";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:D("bpb-usage-banner bpb-scope",`bpb-usage-banner--${a}`,`bpb-usage-banner--${f}`,l),role:"alert","aria-live":"polite",children:[e.jsx(Os,{size:18,className:"bpb-usage-banner__icon"}),e.jsx("p",{className:"bpb-usage-banner__text",children:P?e.jsxs(e.Fragment,{children:["You’ve reached your ",B," limit. Upgrade now to avoid interruptions."]}):e.jsxs(e.Fragment,{children:["You’ve used ",e.jsxs("strong",{children:[T,"%"]})," of your ",B,". Upgrade to avoid hitting your limit."]})}),e.jsxs("div",{className:"bpb-usage-banner__actions",children:[e.jsx(pe,{variant:"primary",size:"sm",onClick:A,children:t}),r&&e.jsx("button",{type:"button",className:"bpb-usage-banner__dismiss","aria-label":"Dismiss",onClick:()=>{Zs(en,p,m.key),g(i=>({...i,[m.key]:!0}))},children:e.jsx(ia,{size:16})})]})]}),!n&&e.jsxs(e.Fragment,{children:[e.jsx(qs,{open:_,onOpenChange:N,onSelectPlan:(i,M)=>{N(!1),y({planId:i,interval:M})}}),v&&e.jsx(Ks,{open:!!v,onOpenChange:i=>!i&&y(null),planId:v.planId,interval:v.interval,onBack:()=>{y(null),N(!0)},onSuccess:()=>y(null)})]})]})},jr=({Icon:a,title:s,description:n,onClick:r,className:t})=>e.jsxs("button",{type:"button",className:D("bpb-action-card bpb-scope",t),onClick:r,children:[e.jsxs("div",{className:"bpb-action-card__header",children:[e.jsx(a,{size:20}),s]}),e.jsx("p",{className:"bpb-action-card__description",children:n})]}),Ya=({children:a})=>e.jsx("span",{className:"bpb-summary-card__icon","aria-hidden":"true",children:a}),an=({eyebrow:a,className:s})=>{const{manageBillingUrl:n}=U(),r=()=>n&&window.open(n,"_blank","noopener");return e.jsxs("button",{type:"button",className:D("bpb-summary-card bpb-scope",a==="Add-ons"?"bpb-summary-card--addons":"bpb-summary-card--plan",s),onClick:r,disabled:!n,children:[e.jsx(Ya,{children:a==="Add-ons"?e.jsx(ca,{size:22}):e.jsx(la,{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(Xe,{size:15})]})]})]})},Hr=({onManage:a,className:s})=>{var N,v;const{isOutdatedBilling:n}=U(),{data:r,isLoading:t}=ke({enabled:!n}),{data:o,isLoading:l}=we();if(n)return e.jsx(an,{eyebrow:"Current plan",className:s});if(t||l)return e.jsx(G,{height:84,rounded:!0,className:D("bpb-scope",s)});const c=r==null?void 0:r.plan.current,d=o==null?void 0:o.find(y=>y.id===(c==null?void 0:c.planId)),p=(c==null?void 0:c.interval)??"month",u=((N=d==null?void 0:d.prices[p])==null?void 0:N.amount)??0,h=((v=d==null?void 0:d.prices[p])==null?void 0:v.currency)??"usd",g=d==null?void 0:d.features.conversation_sessions,_=d?ie(d):"community";return e.jsxs("button",{type:"button",className:D("bpb-summary-card bpb-summary-card--plan bpb-scope",`bpb-summary-card--tier-${_==="managed"?"enterprise":_}`,s),onClick:a,children:[e.jsx(Ya,{children:e.jsx(la,{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:d?ne(d.name):"No plan"}),e.jsxs("span",{className:"bpb-summary-card__meta",children:[u>0?`${Z(u,h,0)}/${p==="year"?"yr":"mo"}`:"Free",g!==void 0&&` · ${ee(g)} conversations/mo`]})]}),e.jsxs("span",{className:"bpb-summary-card__action",children:["Manage",e.jsx(Oe,{size:16})]})]})]})},Yr=({onManage:a,className:s})=>{const{isOutdatedBilling:n}=U(),{data:r,isLoading:t}=ke({enabled:!n}),{data:o,isLoading:l}=Me();if(n)return e.jsx(an,{eyebrow:"Add-ons",className:s});if(t||l)return e.jsx(G,{height:84,rounded:!0,className:D("bpb-scope",s)});const c=(o??[]).flatMap(d=>{var u;const p=((u=r==null?void 0:r.addons[d.id])==null?void 0:u.current.quantity)??0;return p>0?[{name:Ze(d.name),quantity:p}]:[]});return e.jsxs("button",{type:"button",className:D("bpb-summary-card bpb-summary-card--addons bpb-scope",c.length>0&&"bpb-summary-card--active",s),onClick:a,children:[e.jsx(Ya,{children:e.jsx(ca,{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(d=>`${d.quantity}× ${d.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(Oe,{size:16})]})]})]})},Qr=({onManage:a,className:s})=>{var $,se;const{isOutdatedBilling:n,locale:r,manageBillingUrl:t,analytics:o}=U(),{data:l,isLoading:c}=ke({enabled:!n}),{data:d,isLoading:p}=we(),{data:u,isLoading:h}=Me();if(n){const x=()=>t&&window.open(t,"_blank","noopener");return e.jsxs("button",{type:"button",className:D("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(Xe,{size:16})]})]})}if(c||p||h)return e.jsx(G,{height:132,rounded:!0,className:D("bpb-scope",s)});const g=l==null?void 0:l.plan.current,_=d==null?void 0:d.find(x=>x.id===(g==null?void 0:g.planId)),N=(g==null?void 0:g.interval)??"month",v=(($=_==null?void 0:_.prices[N])==null?void 0:$.currency)??"usd",y=_?ie(_):"community",m=Object.fromEntries(Object.entries((l==null?void 0:l.addons)??{}).map(([x,re])=>{var ae;return[x,((ae=re.current)==null?void 0:ae.quantity)??0]})),S=((se=_==null?void 0:_.prices[N])==null?void 0:se.amount)??0,B=(u??[]).reduce((x,re)=>{const ae=_?ra(re,_,N):null;return x+(m[re.id]??0)*((ae==null?void 0:ae.amount)??0)},0),T=S+B,P=N==="year"?"/yr":"/mo",A=As(_,u,m).find(x=>x.key==="conversation_sessions"),f=y==="community"?"conversations":"conversations / month",i=g!=null&&g.periodEnd?Ee(g.periodEnd,r):null,M=y==="enterprise"||y==="managed";return e.jsxs("button",{type:"button",className:D("bpb-plan-banner",`bpb-plan-banner--${y}`,"bpb-scope",s),onClick:()=>{o.capture(oe.UPGRADE_CTA_CLICKED,{source:"plan_banner",current_tier:y}),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:_?ne(_.name):"No plan"}),A&&e.jsx("span",{className:"bpb-plan-banner__sub",children:A.added>0?e.jsxs(e.Fragment,{children:[ee(A.base)," + ",ee(A.added)," ",f]}):`${ee(A.total)} ${f}`})]}),e.jsxs("div",{className:"bpb-plan-banner__summary",children:[M?e.jsx("span",{className:"bpb-plan-banner__price",children:"Custom pricing"}):e.jsxs("span",{className:"bpb-plan-banner__price",children:[T>0?Z(T,v,0):"Free",T>0&&e.jsx("span",{className:"bpb-plan-banner__price-suffix",children:P})]}),e.jsxs("span",{className:"bpb-plan-banner__meta",children:[N==="year"?"Billed annually":"Billed monthly",B>0&&" · incl. add-ons"]}),i&&e.jsxs("span",{className:"bpb-plan-banner__meta",children:["Renews ",i]})]}),e.jsxs("span",{className:"bpb-plan-banner__cta",children:["Manage plan ",e.jsx(Oe,{size:16})]})]})},Zr=({onManage:a,period:s,variant:n="card",className:r,style:t})=>{const{isOutdatedBilling:o,locale:l}=U(),{data:c,isLoading:d}=ke({enabled:!o}),{data:p,isLoading:u}=we(),{data:h,isLoading:g}=Pe({period:s,enabled:!o});if(o)return null;if(d||u||g)return e.jsx(G,{height:72,rounded:!0,className:D("bpb-scope",r)});const _=p==null?void 0:p.find(x=>x.id===(c==null?void 0:c.plan.current.planId)),N=Re(h),v=N.find(x=>x.key==="conversation_sessions"),y=N[0],m=y&&y.key!=="conversation_sessions"&&y.pct>=75?y:v??y,S=m?Math.round(m.pct):0,B=S>0?Math.max(5,S):0,T=m?ma(m.pct):"normal",P=T!=="normal",A=_?ie(_)==="community":!1,f=c!=null&&c.plan.current.periodEnd?Ee(c.plan.current.periodEnd,l):null;let i=null,M=null;if(m&&P){const x=Ke(m.remaining,m.unit);i=T==="critical"?"Limit reached":"Running low",A&&m.key==="conversation_sessions"?M=T==="critical"?e.jsxs(e.Fragment,{children:["All your free conversations are used, and they ",e.jsx("strong",{children:"don’t renew"}),"."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:x})," free conversations left, and they ",e.jsx("strong",{children:"don’t renew"}),"."]}):M=T==="critical"?"Upgrade to keep going.":e.jsxs(e.Fragment,{children:["Only ",e.jsx("strong",{children:x})," left."]})}const $=e.jsx(e.Fragment,{children:m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bpb-plan-usage__head",children:[P&&e.jsx(Os,{size:16,className:D("bpb-plan-usage__alert",`bpb-plan-usage__alert--${T}`)}),e.jsx("span",{className:"bpb-plan-usage__plan",children:m.label}),e.jsxs("span",{className:"bpb-plan-usage__count",children:[Ke(m.used,m.unit)," / ",Ke(m.quota,m.unit)]}),a&&!P&&e.jsx(Oe,{size:15,className:"bpb-plan-usage__chevron"})]}),e.jsx("div",{className:"bpb-plan-usage__bar",role:"progressbar","aria-valuenow":S,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:D("bpb-plan-usage__fill",`bpb-plan-usage__fill--${T}`),style:{width:`${B}%`}})}),i?e.jsxs("p",{className:"bpb-plan-usage__status",children:[e.jsxs("strong",{className:D("bpb-plan-usage__status-word",`bpb-plan-usage__status-word--${T}`),children:[i,"."]})," ",M&&e.jsx("span",{className:"bpb-plan-usage__status-detail",children:M})]}):f&&e.jsxs("span",{className:"bpb-plan-usage__reset",children:["Resets ",f]}),a&&P&&e.jsxs("span",{className:"bpb-plan-usage__cta",children:["View plan options",e.jsx(ba,{size:14})]})]}):e.jsxs("div",{className:"bpb-plan-usage__head",children:[e.jsx("span",{className:"bpb-plan-usage__plan",children:_?ne(_.name):"Free"}),a&&e.jsx(Oe,{size:15,className:"bpb-plan-usage__chevron"})]})}),se=D("bpb-plan-usage bpb-scope",`bpb-plan-usage--${n}`,P&&`bpb-plan-usage--${T}`,a&&"bpb-plan-usage--clickable",r);return a?e.jsx("button",{type:"button",className:se,style:t,onClick:a,children:$}):e.jsx("div",{className:se,style:t,children:$})},sn=({children:a,delay:s=200,placement:n="top",period:r,onUpgrade:t,block:o=!1,className:l})=>{const{isOutdatedBilling:c,locale:d,analytics:p}=U(),{data:u}=Pe({period:r,enabled:!c}),{data:h}=ke({enabled:!c}),{data:g}=we(),[_,N]=w.useState(!1),v=w.useRef(null),y=()=>{v.current&&(clearTimeout(v.current),v.current=null)};w.useEffect(()=>y,[]);const m=Re(u),S=!c&&m.length>0,B=()=>{S&&(y(),v.current=setTimeout(()=>N(!0),Math.max(0,s)))},T=()=>{y(),N(!1)},P=g==null?void 0:g.find(x=>x.id===(h==null?void 0:h.plan.current.planId)),A=P?ne(P.name):"Free",f=h!=null&&h.plan.current.periodEnd?Ee(h.plan.current.periodEnd,d):null,i=P?ie(P)==="community":!P,M=i?m.find(x=>x.key==="conversation_sessions"):void 0,$=i&&!!t,se=()=>{p.capture(oe.UPGRADE_CTA_CLICKED,{source:"usage_popover"}),t==null||t()};return e.jsxs("span",{className:D("bpb-usage-pop bpb-scope",o&&"bpb-usage-pop--block",l),onMouseEnter:B,onMouseLeave:T,onFocus:B,onBlur:T,children:[a,_&&S&&e.jsxs("span",{className:D("bpb-usage-pop__card",`bpb-usage-pop__card--${n}`),role:"tooltip",children:[i?e.jsxs("span",{className:"bpb-usage-pop__header",children:[e.jsx("span",{className:"bpb-usage-pop__plan-name",children:"Free plan usage"}),M&&e.jsxs("span",{className:"bpb-usage-pop__subtitle",children:[e.jsxs("strong",{children:[ee(M.quota)," conversations"]})," included, total. They don’t renew, and Free has no top-ups."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"bpb-usage-pop__plan",children:[e.jsxs("span",{className:"bpb-usage-pop__plan-name",children:[A," plan"]}),f&&e.jsxs("span",{className:"bpb-usage-pop__reset",children:["Resets ",f]})]}),e.jsx("span",{className:"bpb-usage-pop__title",children:"Usage this period"})]}),m.map(x=>{const re=x.pct>0?Math.max(5,x.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:x.label}),e.jsxs("span",{className:"bpb-usage-pop__val",children:[Ke(x.used,x.unit)," / ",Ke(x.quota,x.unit)]})]}),e.jsx("span",{className:"bpb-usage-pop__bar",children:e.jsx("span",{className:D("bpb-usage-pop__fill",`bpb-usage-pop__fill--${ma(x.pct)}`),style:{width:`${re}%`}})})]},x.key)}),$&&e.jsxs("span",{className:"bpb-usage-pop__nudge",children:[e.jsxs("span",{className:"bpb-usage-pop__nudge-text",children:[e.jsx("strong",{children:"Need more room?"})," Plus includes 250 conversations a month, unlimited AI agents, and packs of 100 when you need them."]}),e.jsxs("button",{type:"button",className:"bpb-usage-pop__nudge-cta",onClick:se,children:["See what you get with Plus",e.jsx(ba,{size:14})]})]})]})]})},Xr=({size:a=20,thickness:s=3.5,showLabel:n=!1,onClick:r,popoverDelay:t=200,period:o,className:l,...c})=>{const{isOutdatedBilling:d}=U(),{data:p}=Pe({period:o,enabled:!d}),u=Re(p);if(d||u.length===0)return null;const h=u[0],g=ma(h.pct),_=h.pct>0?Math.max(5,h.pct):0,N=(a-s)/2,v=2*Math.PI*N,y=v*(1-_/100),m=c["aria-label"]??`${Math.round(h.pct)}% of your ${h.label.toLowerCase()} used`,S=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:N,fill:"none",strokeWidth:s}),e.jsx("circle",{className:D("bpb-usage-ring__arc",`bpb-usage-ring__arc--${g}`),cx:a/2,cy:a/2,r:N,fill:"none",strokeWidth:s,strokeLinecap:"round",strokeDasharray:v,strokeDashoffset:y,transform:`rotate(-90 ${a/2} ${a/2})`})]}),n&&e.jsxs("span",{className:"bpb-usage-ring__label",children:[Math.round(h.pct),"%"]})]}),B=D("bpb-usage-ring",r&&"bpb-usage-ring--clickable"),T=r?e.jsx("button",{type:"button",className:B,onClick:r,"aria-label":m,children:S}):e.jsx("span",{className:B,tabIndex:0,role:"img","aria-label":m,children:S});return e.jsx(sn,{delay:t,period:o,className:l,children:T})};b.AddonsSummaryCard=Yr,b.ArrowRightIcon=ba,b.BILLING_EVENTS=oe,b.Badge=oa,b.BankIcon=dr,b.BillingActionCard=jr,b.BillingProvider=mn,b.BoltIcon=ca,b.Button=pe,b.CalendarIcon=Fs,b.CardBrandBadge=$a,b.CardIcon=Ua,b.ChartIcon=Ps,b.CheckIcon=Es,b.CheckoutDialog=Ks,b.ChevronDownIcon=da,b.ChevronLeftIcon=Oa,b.ChevronRightIcon=Oe,b.CloseIcon=ia,b.DEFAULT_FEATURE_DESCRIPTIONS=Pa,b.DEFAULT_FEATURE_LABELS=Xs,b.DEFAULT_PLAN_FEATURES=na,b.Dialog=fe,b.DownloadIcon=Fa,b.ENTERPRISE_CONTACT_URL=Ma,b.ExternalLinkIcon=Xe,b.GlobeIcon=Ds,b.InfinityIcon=xs,b.InfoTooltip=Je,b.Input=ua,b.InvoicesDialog=Lr,b.LayersIcon=la,b.LockIcon=br,b.ManageAddonsDialog=Ar,b.MessageIcon=Ts,b.MinusIcon=zs,b.NANO_DOLLARS_PER_DOLLAR=ha,b.OutdatedBillingGate=Fe,b.OutgrowFreeDialog=Fr,b.PLAN_ORDER=Ue,b.PaintIcon=Bs,b.PaymentMethodDialog=Mr,b.PlanBanner=Qr,b.PlanSummaryCard=Hr,b.PlanUsageWidget=Zr,b.PlusIcon=Us,b.PuzzleIcon=Ls,b.ReceiptIcon=ur,b.SegmentedControl=$s,b.Select=ja,b.ShieldIcon=za,b.Skeleton=G,b.SparkleIcon=Ba,b.Stepper=js,b.USAGE_METRICS=Js,b.UpgradePlanDialog=qs,b.UsageBanner=Kr,b.UsageDashboard=Gr,b.UsagePopover=sn,b.UsageRing=Xr,b.UsersIcon=Ms,b.addDays=ws,b.addonDisplayName=Ze,b.addonLimitsPreview=Is,b.addonPrice=ra,b.billingKeys=ce,b.cn=D,b.conversationPackPrice=ta,b.conversationsAddon=Cs,b.currencySymbol=Qe,b.featureDescription=Da,b.featureLabel=Dr,b.formatBytes=ze,b.formatCurrency=Z,b.formatDate=Ee,b.formatQuantity=ee,b.formatUsage=Ke,b.getCardElementStyle=Va,b.getStripeAppearance=Ga,b.getStripePromise=Xa,b.iconForFeature=pa,b.planDisplayName=ne,b.planEntitlements=As,b.planKind=ie,b.toStripeLocale=Ka,b.usageItems=Re,b.usageTier=ma,b.useAddons=Me,b.useBilling=U,b.useBillingAddress=va,b.useBillingReadonly=Na,b.useCreatePaymentMethodIntent=wa,b.useCustomer=ka,b.useInvoices=Ja,b.usePaymentMethod=fa,b.usePlans=we,b.useSetAddons=as,b.useSetBillingAddress=Sa,b.useSetCustomer=Ia,b.useSetPaymentMethod=Ca,b.useSetSubscription=Aa,b.useSubscription=ke,b.useSubscriptionPreview=_a,b.useSupportsUsageByBot=es,b.useUsage=Pe,b.useUsageByBot=Ra,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});