@bpinternal/billing-ui 0.3.0 → 0.3.1
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.
- package/dist/index.js +13 -4
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4525,7 +4525,7 @@ const gn = ({ label: e, className: n, id: t, ...r }) => e ? /* @__PURE__ */ s("l
|
|
|
4525
4525
|
editing: o,
|
|
4526
4526
|
onEdit: i,
|
|
4527
4527
|
onCancelEdit: l,
|
|
4528
|
-
|
|
4528
|
+
onReady: c,
|
|
4529
4529
|
onCountryChange: u,
|
|
4530
4530
|
country: p,
|
|
4531
4531
|
isBusiness: b,
|
|
@@ -4551,6 +4551,13 @@ const gn = ({ label: e, className: n, id: t, ...r }) => e ? /* @__PURE__ */ s("l
|
|
|
4551
4551
|
options: {
|
|
4552
4552
|
mode: "billing",
|
|
4553
4553
|
display: { name: "full" },
|
|
4554
|
+
// Render all address fields immediately. In the default 'automatic'
|
|
4555
|
+
// mode Stripe shows a single autocomplete search box that only
|
|
4556
|
+
// expands line1/city/state/postal once the user picks a suggestion
|
|
4557
|
+
// or starts typing — and for a returning Link consumer it collapses
|
|
4558
|
+
// to a stored Name+Country pill. Both states report `complete: false`
|
|
4559
|
+
// with no visible inputs, which silently keeps Subscribe disabled.
|
|
4560
|
+
autocomplete: { mode: "disabled" },
|
|
4554
4561
|
defaultValues: n ? {
|
|
4555
4562
|
name: t ?? void 0,
|
|
4556
4563
|
address: {
|
|
@@ -4563,9 +4570,11 @@ const gn = ({ label: e, className: n, id: t, ...r }) => e ? /* @__PURE__ */ s("l
|
|
|
4563
4570
|
}
|
|
4564
4571
|
} : void 0
|
|
4565
4572
|
},
|
|
4566
|
-
onReady: () =>
|
|
4573
|
+
onReady: () => {
|
|
4574
|
+
D(!0), c();
|
|
4575
|
+
},
|
|
4567
4576
|
onChange: (f) => {
|
|
4568
|
-
|
|
4577
|
+
u(f.value.address.country || void 0);
|
|
4569
4578
|
}
|
|
4570
4579
|
}
|
|
4571
4580
|
) }),
|
|
@@ -4758,7 +4767,7 @@ const gn = ({ label: e, className: n, id: t, ...r }) => e ? /* @__PURE__ */ s("l
|
|
|
4758
4767
|
editing: w,
|
|
4759
4768
|
onEdit: () => D(!0),
|
|
4760
4769
|
onCancelEdit: Y ? () => D(!1) : void 0,
|
|
4761
|
-
|
|
4770
|
+
onReady: () => M(!0),
|
|
4762
4771
|
onCountryChange: f,
|
|
4763
4772
|
country: A,
|
|
4764
4773
|
isBusiness: d,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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"})});
|
|
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,onReady: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"},autocomplete:{mode:"disabled"},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),c()},onChange:f=>{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,onReady:()=>P(!0),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"})});
|