@metrifox/react-sdk 2.0.2 → 2.0.3

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.cjs CHANGED
@@ -77,7 +77,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
77
77
  data-[selected]:bg-[var(--cp-tabs-active-bg)]
78
78
  data-[selected]:text-[var(--cp-tabs-active-text)]
79
79
  data-[selected]:shadow-sm`,children:"Usage"})]}),a.jsxs(Fo,{className:"w-full",children:[a.jsx(yn,{children:a.jsx(xS,{entitlements:n})}),i.length>0&&a.jsx(yn,{children:a.jsx(CS,{meteredEntitlements:i})})]})]})})})},_S=({tenantDetails:e,paymentMethod:t})=>{const{address:n}=Qd(e?.billing_address),i=[{label:"Billed to",value:e?.full_name||"-"},{label:"Billing email",value:e?.billing_email||"-"},{label:"Billing address",value:n||"-"}];return a.jsx(nr,{title:"Payment",children:a.jsx(b,{className:"bg-[var(--cp-section-content-bg)] border border-[var(--cp-section-content-border)] rounded-[var(--cp-section-content-radius)]",style:{padding:"var(--cp-section-content-padding)"},children:a.jsxs(b,{className:"grid grid-cols-4 gap-8 justify-between",children:[i?.map((r,o)=>a.jsxs(b,{children:[a.jsx("div",{className:"mb-1",style:{color:"var(--cp-section-label-color)",fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:r?.label}),a.jsx("div",{style:{color:"var(--cp-section-value-color)",fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)",marginTop:"8px"},children:r?.value||"-"})]},o)),a.jsxs(b,{children:[a.jsx("div",{className:"mb-2",style:{color:"var(--cp-section-label-color)",fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:"Payment method"}),t?a.jsxs(b,{className:"flex items-center gap-x-2 mt-2",children:[a.jsx(b,{className:"bg-[#1a1f71] rounded px-1.5 py-0.5 text-white font-bold text-[10px]",children:"VISA"}),a.jsxs("div",{className:"flex items-center",style:{color:"var(--cp-section-value-color)",fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)"},children:["**** ",t?.display_name," ",a.jsxs("span",{className:"ml-2",style:{color:"var(--cp-section-label-color)",fontSize:"var(--cp-section-label-size)",fontWeight:"normal"},children:["Expires ",String(t?.exp_month).padStart(2,"0"),"/",String(t?.exp_year).slice(-2)]})]})]}):a.jsx("div",{style:{color:"var(--cp-section-value-color)",fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)"},children:"-"})]})]})})})},jS="!bg-[var(--select-bg)] !border-[var(--select-border)] text-[var(--select-text)] placeholder-[var(--select-placeholder)]",$S="!bg-[var(--select-dropdown-bg)] !border-[var(--select-dropdown-border)] [&_.text-base-default-600]:!text-[var(--select-option-text)] [&_li:hover]:!bg-[var(--select-option-hover-bg)]",zd=({value:e,onChange:t,options:n,disabled:i=!1,placeholderText:r="Select Country",className:o="ml-auto w-[15rem]"})=>a.jsx(b,{className:o,children:a.jsx(Zc,{value:e,onChange:t,options:n,disabled:i,placeholderText:r,containerClassName:jS,optionsContainerClassName:$S})}),Md={plans:{currentPlanCard:{header:{background:O("grey-200")||"#e5e7eb",textColor:O("grey-900")||"#111827"},gradientColor:O("grey-200")||"#e5e7eb"},planCards:{background:O("metrifox-white")||"#ffffff",border:{color:O("grey-200")||"#e5e7eb",width:"1px",radius:"8px"},header:{background:O("grey-200")||"#e5e7eb",textColor:O("grey-900")||"#111827"},description:{textColor:O("grey-500")||"#6b7280",textButtonColor:O("blue-600")||"#2563eb"},price:{amountColor:O("grey-900")||"#111827",primaryTextColor:O("grey-500")||"#6b7280",secondaryTextColor:O("grey-400")||"#9ca3af",background:"transparent",borderColor:"transparent"}},planFeatures:{textColor:O("grey-700")||"#374151",iconColor:O("metrifox-green")||"#0BB02F"},planButton:{background:O("metrifox-primary")||"#3D3D3D",textColor:O("metrifox-white")||"#ffffff",secondaryBackground:O("background-system-secondary")||"#E4E4E7",secondaryTextColor:O("metrifox-black")||"#3F3F46",textButtonColor:O("blue-600")||"#2563eb"},planToggle:{background:O("grey-200")||"#e5e7eb",activeBackground:O("grey-800")||"#1f2937",activeText:O("metrifox-white")||"#ffffff",inactiveText:O("grey-500")||"#6b7280"},planTags:{freeTrialBackground:O("blue-100")||"#dbeafe",freeTrialText:O("blue-800")||"#1e40af"}},tabs:{inactiveText:O("grey-400")||"#9ca3af",activeText:O("blue-600")||"#2563eb",indicator:O("blue-600")||"#2563eb",borderColor:O("grey-400")||"#9ca3af"},select:{background:O("background-system-primary")||"#ffffff",borderColor:O("grey-300")||"#d1d5db",textColor:O("neutral-800")||"#262626",caretColor:O("grey-500")||"#6b7280",dropdownBackground:O("metrifox-white")||"#ffffff",dropdownBorderColor:O("grey-300")||"#d1d5db",optionTextColor:O("base-default-600")||"#4b5563",optionHoverBackground:O("grey-100")||"#f3f4f6"},checkoutBar:{background:O("grey-50")||"#f9fafb",borderColor:O("grey-200")||"#e5e7eb",textColor:O("metrifox-black")||"#3F3F46",buttonBackground:O("blue-600")||"#2563eb",buttonTextColor:O("metrifox-white")||"#ffffff"}},Rd=(e,t,n)=>{const{theme:i}=or(),r=i?.pricingTable,o=i?.customerPortal?.plans,s=!e1(o),l=Md.plans,u=t&&s?{plans:{currentPlanCard:o?.currentPlanCard!=null?er.all([l?.currentPlanCard??{},o.currentPlanCard]):l?.currentPlanCard,planCards:o?.planCards!=null?er.all([l?.planCards??{},o.planCards]):l?.planCards,planFeatures:o?.planFeatures!=null?er.all([l?.planFeatures??{},o.planFeatures]):l?.planFeatures,planButton:o?.planButton!=null?er.all([l?.planButton??{},o.planButton]):l?.planButton,planToggle:o?.planToggle!=null?er.all([l?.planToggle??{},o.planToggle]):l?.planToggle,planTags:o?.planTags!=null?er.all([l?.planTags??{},o.planTags]):l?.planTags}}:r||{},c=er.all([Md,u]),d=e?Md:n?er.all([c,n]):c,f=P7(d),p=al(d),g={...f,...p};return{theme:d,cssVars:g}},Fd=({selectedInterval:e,intervals:t,isCustomerPortal:n=!1,isPricePage:i,setSelectedInterval:r})=>{const o=!i&&!n,{cssVars:s}=Rd(o,n);return a.jsx(b,{style:n?{}:s,children:a.jsx(b,{"data-testid":"plan-tabs",className:"inline-flex items-center gap-1 bg-[var(--pt-interval-bg,var(--cp-tabs-bg))] border border-[var(--pt-interval-border,var(--cp-tabs-border,var(--cp-section-content-border)))] p-1 rounded-lg shadow-sm",children:t.map(l=>{const u=e===l;return a.jsx(b,{className:`py-1.5 px-6 rounded-md cursor-pointer transition-all flex items-center justify-center
80
- ${u?"bg-[var(--pt-interval-active-bg,var(--cp-tabs-active-bg))] shadow-sm":"bg-transparent hover:opacity-80"}`,onClick:()=>r(l),children:a.jsx(F,{variant:"body6",className:"font-medium whitespace-nowrap",color:u?"text-[var(--pt-interval-active-text,var(--cp-tabs-active-text))]":"text-[var(--pt-interval-inactive-text,var(--cp-tabs-inactive-text))]",children:Rt(l)})},l)})})})},Ud=e=>{const t=m.useMemo(()=>ry(e||[]),[e]),[n,i]=m.useState(""),r=m.useMemo(()=>[...t.includes(Ve.DAILY)?[Ve.DAILY]:[],...t.includes(Ve.WEEKLY)?[Ve.WEEKLY]:[],...t.includes(Ve.MONTHLY)?[Ve.MONTHLY]:[],...t.includes(Ve.QUARTERLY)?[Ve.QUARTERLY]:[],...t.includes(Ve.BIANNUALLY)?[Ve.BIANNUALLY]:[],...t.includes(Ve.YEARLY)?[Ve.YEARLY]:[]],[t]);return m.useEffect(()=>{!n&&r[0]&&i(r[0])},[r,n]),{intervals:r,selectedInterval:n,setSelectedInterval:i}},g4=ti(e=>({plans:[],setPlans:t=>e(n=>({plans:typeof t=="function"?t(n.plans):t}))}));function Vd(e,t){let n;try{n=e()}catch{return}return{getItem:r=>{var o;const s=u=>u===null?null:JSON.parse(u,void 0),l=(o=n.getItem(r))!=null?o:null;return l instanceof Promise?l.then(s):s(l)},setItem:(r,o)=>n.setItem(r,JSON.stringify(o,void 0)),removeItem:r=>n.removeItem(r)}}const Zd=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(i){return Zd(i)(n)},catch(i){return this}}}catch(n){return{then(i){return this},catch(i){return Zd(i)(n)}}}},SS=(e,t)=>(n,i,r)=>{let o={storage:Vd(()=>localStorage),partialize:v=>v,version:0,merge:(v,y)=>({...y,...v}),...t},s=!1;const l=new Set,u=new Set;let c=o.storage;if(!c)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...v)},i,r);const d=()=>{const v=o.partialize({...i()});return c.setItem(o.name,{state:v,version:o.version})},f=r.setState;r.setState=(v,y)=>(f(v,y),d());const p=e((...v)=>(n(...v),d()),i,r);r.getInitialState=()=>p;let g;const h=()=>{var v,y;if(!c)return;s=!1,l.forEach(x=>{var C;return x((C=i())!=null?C:p)});const w=((y=o.onRehydrateStorage)==null?void 0:y.call(o,(v=i())!=null?v:p))||void 0;return Zd(c.getItem.bind(c))(o.name).then(x=>{if(x)if(typeof x.version=="number"&&x.version!==o.version){if(o.migrate){const C=o.migrate(x.state,x.version);return C instanceof Promise?C.then($=>[!0,$]):[!0,C]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,x.state];return[!1,void 0]}).then(x=>{var C;const[$,k]=x;if(g=o.merge(k,(C=i())!=null?C:p),n(g,!0),$)return d()}).then(()=>{w?.(g,void 0),g=i(),s=!0,u.forEach(x=>x(g))}).catch(x=>{w?.(void 0,x)})};return r.persist={setOptions:v=>{o={...o,...v},v.storage&&(c=v.storage)},clearStorage:()=>{c?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>h(),hasHydrated:()=>s,onHydrate:v=>(l.add(v),()=>{l.delete(v)}),onFinishHydration:v=>(u.add(v),()=>{u.delete(v)})},o.skipHydration||h(),g||p},v4=SS,mo=ti()(v4(e=>({selections:{},setSelection:(t,n)=>e(i=>({selections:{...i.selections,[t]:n}}))}),{name:"metrifox:stairstep-selections",storage:Vd(()=>localStorage)})),wa=({selectedInterval:e,publishedOnly:t=!1})=>{const{plans:n}=g4(),[i,r]=m.useState(40),o=m.useCallback(d=>{if(!d)return;const f=d.published_version||d,p=d.draft_version;return t?f?.is_visible?f:void 0:f||p},[t]),s=n?.some(d=>!!o(d)?.description),l=n?.some(d=>!!o(d)?.trial_duration_value),u=n?.some(d=>{const f=o(d);return f?f.price_options?.some(p=>p.price?.billing_interval===e)||f.entitlement_price_options?.filter(p=>p.price.billing_interval===e).length===1||f.credit_attachment_price_options?.filter(p=>p.price.billing_interval===e).length===1||f.is_free||f.is_custom:!1}),c=n?.some(d=>{const f=o(d);return f?[f.credit_attachment_price_options,f.entitlement_price_options].some(p=>Array.isArray(p)&&p.some(g=>g.price?.billing_interval===e)):!1});return m.useEffect(()=>{n.forEach(d=>{const f=o(d);if(!f)return;const p=[...f.credit_attachment_price_options||[],...f.entitlement_price_options||[]].filter(w=>w.price?.billing_interval===e),g=w=>{const x=w,C=x?.price?.name||x?.price?.owner?.feature?.name||x?.price?.owner?.name,{price:$,label:k,currencySymbol:S}=Ho(x);return`${C} from ${S}${$}${k?`/${k}`:""}`.length>40?39:24},h=p[0]?g(p[0]):0,v=p[1]?g(p[1]):0,y=h+v;r(w=>y>w?y:w)})},[n,e,o]),{dynamicCardHeight:i,shouldShowDescription:s,shouldShowFreeTrial:l,shouldShowFixedPrice:u,shouldShowDynamicPrices:c}},b4=({entitlements:e,baseEntitlementsPlanName:t,credits:n})=>{const i=cl(e).filter(r=>r?.is_visible);return a.jsxs(b,{children:[a.jsx(H,{variant:"label7",className:"text-[var(--pt-feature-text)] mb-3",as:"p",children:t?`Everything in ${t} plus:`:e.length>0?"Included:":"\xA0"}),a.jsxs("ul",{className:"flex flex-col gap-y-3",children:[n?.map((r,o)=>a.jsxs("li",{className:"flex items-center gap-[10px]",children:[" ",a.jsx("span",{style:{color:"var(--pt-feature-icon, theme(colors.green.600))"},className:"flex items-center",children:a.jsx(ge,{name:"check",color:"currentColor",size:16})}),a.jsxs(F,{variant:"body5",className:"text-[var(--pt-feature-text)]",children:[r.included_allowance+" ",r.included_allowance===1?r.credit_unit_singular:r.credit_unit_plural]})]},o)),i?.map((r,o)=>a.jsxs("li",{className:"flex items-center gap-[10px]",children:[" ",a.jsx("span",{style:{color:"var(--pt-feature-icon, theme(colors.green.600))"},className:"flex items-center",children:a.jsx(ge,{name:"check",color:"currentColor",size:16})}),a.jsx(F,{variant:"body5",className:"text-[var(--pt-feature-text)]",children:r.display_text})]},o))]})]})},NS=(e,t=[])=>{const n=mo(D=>D.selections),i=e?.price?.billing_interval,r=e?.price.tiers,o=e?.price.currency,s=e?.price?.invoice_timing,l=xt(o),u=D=>{const B=e?.price?.owner,z=B?.included_usage||0,W=D?.find(M=>M.first_unit===z);if(!W)return{price:null,label:null};const{unit_price:J,package_price:q,package_size:V,pricing_model:I,flat_fee:T}=W;return T?{price:T.toFixed(2),label:""}:{per_unit:{price:J?.toFixed(2),label:`per. ${B?.feature?.unit_singular||B?.credit_unit_singular}`},per_package:{price:q?.toFixed(2),label:`for ${V} ${B?.feature?.unit_plural}`}}[I]??{price:null,label:null}},{price:c,label:d}=u(r),f=e?.price?.is_custom&&e?.price?.billing_interval_value>1?`every ${e?.price?.billing_interval_value} ${ey[i]}`:i,p=[Ve.DAILY,Ve.WEEKLY],g={[Ve.DAILY]:"day",[Ve.WEEKLY]:"week"},h=i,v=p.includes(h)?g[h]:"month",y=m.useMemo(()=>t.reduce((D,B)=>{const z=n[B.id];return D+(z||0)},0),[t,n]),w=e?.price?.price??0,x=Wo(i,e?.price?.billing_interval_value),C=w+y,$=x>1?C/x:C,k=C,S=$.toFixed(2),P=k.toFixed(2);return{amount:S,billedText:f,intervalText:v,billingAmount:P,tierPrice:c,tierLabel:d,currencySymbol:l,invoiceTiming:s,intervalValue:e?.price?.billing_interval_value}},ES=({priceOption:e,interval:t,stairstepPrices:n=[]})=>{const{amount:i,billedText:r,billingAmount:o,intervalText:s,currencySymbol:l,intervalValue:u}=NS(e,n),c=_e(i).split("."),d=c?c[0]:"0",f=c&&c.length>1?c[1]:"00";return a.jsxs(b,{className:"p-2 border-b border-grey-200 last:border-0",children:[a.jsx(b,{className:"flex items-center justify-between",children:a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Fixed recurring"})}),a.jsxs(b,{className:"flex items-end",children:[a.jsxs(H,{variant:"label3",children:[l,d]}),a.jsxs(H,{variant:"label6",className:"mb-[5px]",children:[".",f]}),a.jsxs(F,{variant:"body4",className:"mb-[5px] text-[var(--pt-card-price-secondary-text)]",children:["/",s]})]}),(t!==Ve.MONTHLY||u!==1)&&a.jsxs(F,{className:"-mt-[4px] mb-1",variant:"body6",children:["Billed"," ",a.jsxs(H,{as:"span",variant:"label8",className:"inline-block",children:[l,_e(o)," ",r.toLowerCase()]})]})]})},TS=({interval:e,dynamicPrices:t,showMoreCard:n,dynamicAsFixedPrice:i,showMore:r})=>{const[o,s]=m.useState(""),{dynamicCardHeight:l}=wa({selectedInterval:e}),u=n?"":"flex flex-col",c=n?{}:{height:l+20},d=m.useMemo(()=>t.filter(f=>f?.price?.tier_type!==Bt.STAIRSTEP),[t]);return a.jsxs(b,{className:u,style:c,children:[(n?d:d.slice(0,2)).map(f=>{const p=f?.price?.name||f?.price?.owner?.feature?.name||f?.price?.owner?.name,g=ty(f?.price.tiers,f.price.currency),{price:h,label:v,currencySymbol:y,isPercentage:w}=Ho(f),x=g?.length===1;return n?a.jsxs(b,{className:"p-2 border-b border-[var(--pt-card-price-border)] last:border-0",children:[a.jsxs(b,{className:"flex justify-between items-center",children:[a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-1",children:p}),x&&a.jsxs(b,{className:"flex items-center cursor-pointer",children:[a.jsxs(H,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!w&&y,h]}),v&&a.jsxs(F,{variant:"body5",color:"text-[var(--pt-card-price-secondary-text)]",className:"mr-1",children:[w?"\xA0":"/",v]})]})]}),!x&&a.jsxs(b,{className:"flex justify-between items-center",children:[a.jsx(F,{variant:"body5",className:"text-[var(--pt-card-price-primary-text)]",children:"Starts at"}),a.jsxs(b,{className:"flex items-center cursor-pointer",onClick:C=>{C.stopPropagation(),s(o===f.id?"":f.id)},children:[a.jsxs(H,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!w&&y,h]}),a.jsxs(F,{variant:"body5",color:"text-[var(--pt-card-price-secondary-text)]",className:"mr-1",children:[w?"\xA0":"/",v]}),g.length>1&&a.jsx(ge,{name:o===f.id?"arrow-up-light":"arrow-down-linear",size:16,color:"grey-400"})]})]}),o===f.id&&g.length>1&&a.jsx(b,{className:"bg-grey-200 p-2 mt-1 rounded-lg",children:a.jsx(b,{className:"flex flex-col gap-y",children:g?.map(C=>a.jsxs(b,{className:"flex justify-between items-center",children:[a.jsx(F,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:C?.label}),a.jsxs(F,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:[C?.price,C?.package?`/${C?.package} ${v}`:""]})]},C?.label))})})]},f.id):i?null:a.jsx(b,{className:"mt-1",children:a.jsxs(b,{className:"flex items-center gap-x-1 flex-wrap",children:[a.jsx(H,{variant:"label8",className:"text-[var(--pt-card-price-secondary-text)] whitespace-nowrap",children:p}),a.jsx(F,{variant:"body7",className:"text-[var(--pt-card-price-primary-text)]",children:x?"at":"from"}),a.jsxs(b,{className:"flex items-center",children:[a.jsxs(H,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!w&&y,h]}),v&&a.jsxs(F,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:[w?"\xA0":"/",v]})]})]})},f.id)}),!n&&!!t?.length&&a.jsx(b,{className:"flex justify-center mt-auto",children:a.jsx(Kr,{onClick:f=>{r(),f?.stopPropagation()},className:"mt-2",children:a.jsx(F,{variant:"body8",className:"text-[var(--pt-card-description-link)] underline",children:"Explore all prices \u2192"})})})]})},y4=({priceOption:e})=>{const t=mo(x=>x.selections),n=Ho(e),i=e?.price?.tier_type===Bt.STAIRSTEP?t[e.id]:void 0,r=e?.price?.billing_interval,o=e?.price?.billing_interval_value||1,s=Wo(r,o),l=e?.price?.owner?.feature?.usage_model===Vo.PERSISTENT_USE,u=s>1&&l,c=i!==void 0&&u?i/s:i,d=i!==void 0,f=d?_e(c):n.price,p=d?"":n.label,g=d?xt(e?.price?.currency)||"":n.currencySymbol,h=d?!1:n.isPercentage,v=f?.split("."),y=v?v[0]:"0",w=v&&v.length>1?v[1]:"00";return a.jsxs(b,{className:"p-2 border-b border-grey-200 last:border-0",children:[a.jsx(b,{className:"flex items-center justify-between",children:a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Starts at"})}),a.jsxs(b,{className:"flex items-end",children:[!h&&a.jsxs(a.Fragment,{children:[a.jsxs(H,{variant:"label3",children:[g,y]}),a.jsxs(H,{variant:"label6",className:"mb-[5px]",children:[".",w]})]}),h&&a.jsx(H,{variant:"label3",children:f}),p&&a.jsxs(F,{variant:"body4",className:"mb-[5px] text-[var(--pt-card-price-secondary-text)]",children:[h?"\xA0":"/",p]})]})]})},IS=({interval:e,dynamicPrices:t,showMore:n})=>{const{dynamicCardHeight:i}=wa({selectedInterval:e}),r={height:i+118},o=mo(h=>h.selections),{stairstepPriceOptions:s,regularPriceOptions:l}=m.useMemo(()=>{const h=[],v=[];return t.forEach(y=>{y?.price?.tier_type===Bt.STAIRSTEP?h.push(y):v.push(y)}),{stairstepPriceOptions:h,regularPriceOptions:v}},[t]),u=m.useMemo(()=>s.reduce((h,v)=>{const y=o[v.id],w=v?.price?.billing_interval_value||1,x=Wo(e,w),C=v?.price?.owner?.feature?.usage_model===Vo.PERSISTENT_USE,$=x>1&&C,k=y!==void 0&&$?y/x:y;return h+(k||0)},0),[e,s,o]),c=s.length>0&&s[0]?.price?.currency&&xt(s[0].price.currency)||"",d=_e(u).split("."),f=d?d[0]:"0",p=d&&d.length>1?d[1]:"00",g=s.length>0?1:2;return a.jsxs(b,{className:"flex flex-col",style:r,children:[a.jsxs(b,{children:[s.length>0&&a.jsxs(b,{className:"pt-2",children:[a.jsx(b,{className:"flex items-center justify-between",children:a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Starts at"})}),a.jsxs(b,{className:"flex items-end",children:[a.jsxs(H,{variant:"label3",children:[c,f]}),a.jsxs(H,{variant:"label6",className:"mb-[5px]",children:[".",p]})]})]}),l.slice(0,g).map(h=>{const v=h?.price?.name||h?.price?.owner?.feature?.name||h?.price?.owner?.name,{price:y,label:w,currencySymbol:x,isPercentage:C}=Ho(h);return a.jsxs(b,{className:"mt-1 p-2 border-b border-[var(--pt-card-price-border)] last:border-0",children:[a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-secondary-text)] whitespace-nowrap",children:v}),a.jsxs(b,{className:"flex items-center justify-between gap-x-1 flex-wrap mt-1",children:[a.jsx(F,{variant:"body7",className:"text-[var(--pt-card-price-primary-text)]",children:"Starts at"}),a.jsxs(b,{className:"flex items-end",children:[a.jsxs(H,{variant:"label6",color:"text-[var(--pt-card-price-amount)]",children:[!C&&x,y]}),w&&a.jsxs(F,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",className:"mb-[2px]",children:[C?"\xA0":"/",w]})]})]})]},h.id)})]}),!!t?.length&&a.jsx(b,{className:"flex justify-center mt-auto",children:a.jsx(Kr,{onClick:h=>{n(),h?.stopPropagation()},className:"mt-2",children:a.jsx(F,{variant:"body8",className:"text-[var(--pt-card-description-link)] underline",children:"Explore all prices \u2192"})})})]})},x4=({interval:e,priceOptions:t,showMoreCard:n,entitlementPriceOptions:i,creditAttachmentPriceOptions:r,dynamicPrices:o})=>{const{setSelection:s}=mo(),l=mo(c=>c.selections),u=m.useMemo(()=>{if(o)return o.filter(d=>d?.price?.tier_type===Bt.STAIRSTEP);if(!t||!i||!r)return[];const c=Bo(e,i);return[...Bo(e,r),...c].filter(d=>d?.price?.tier_type===Bt.STAIRSTEP)},[e,t,o,i,r]);return a.jsx(b,{children:(n?u:u.slice(0,3)).map(c=>a.jsx(DS,{price:c,selections:l,setSelection:s},c.id))})},DS=({price:e,selections:t,setSelection:n})=>{const i=e.price?.tiers||[],r=e.price?.currency||"",o=Xd(r),s=J7[e.price?.billing_interval],l=e?.price.owner,u=l?.feature?.unit_singular||l?.credit_unit_singular||l?.unit_singular,c=l?.feature?.unit_plural||l?.credit_unit_plural||l?.unit_plural,d=i.map(h=>{const v={label:`${h.total_unit_quantity||0} ${h.total_unit_quantity&&h.total_unit_quantity>1?c:u} /${s}`,value:h.flat_fee?String(h.flat_fee):"0"};return h.flat_fee&&(v.description=`${o}${_e(h.flat_fee)}`),v}),f=t[e.id],p=d[0]?.value?parseFloat(d[0].value):0,g=String(f||p);return m.useEffect(()=>{!t[e.id]&&d.length>0&&d[0]?.value&&n(e.id,parseFloat(d[0].value))},[e.id,d.length,n]),a.jsx(b,{className:"mb-3 last:mb-0",children:a.jsx(Zc,{size:"small",options:d,className:"w-full",value:g,showDescriptionInline:!0,onChange:h=>{n(e.id,parseFloat(h))},containerClassName:"!bg-white !border-grey-200 !px-4 !py-3 hover:!border-grey-300 transition-colors"})})},LS=({interval:e,priceOptions:t,entitlementPriceOptions:n,creditAttachmentPriceOptions:i,isPricePage:r,trialTag:o,showMoreCard:s,isFree:l,isCustom:u,showMore:c,addPriceButton:d})=>{const{shouldShowFixedPrice:f,shouldShowFreeTrial:p,shouldShowDynamicPrices:g}=wa({selectedInterval:e,publishedOnly:r}),h=Tf(e,t),v=Bo(e,n),y=Bo(e,i),w=v.length===1&&!h,x=y.length===1&&!h&&v.length===0,C=[...y,...v],$=C.filter(S=>S?.price?.tier_type===Bt.STAIRSTEP);if(!r&&!h&&v.length===0&&!y.length&&!l&&!u)return a.jsxs(a.Fragment,{children:[a.jsx(b,{className:"h-[94px] flex items-center",children:a.jsx(b,{className:"w-full bg-grey-100 border border-grey-200 rounded-2xl p-2 mb-3",children:d||a.jsx(F,{variant:"body6",className:"text-[var(--pt-card-price-amount)]",children:"No price added yet"})})}),p&&a.jsx(b,{className:"h-6"})]});const k=!!(h||w||x||l||u);return a.jsxs(a.Fragment,{children:[a.jsxs(b,{className:s?"bg-[var(--pt-card-price-bg)] border border-[var(--pt-card-price-border)] rounded-2xl p-2 mb-3 text-[var(--pt-card-price-amount)]":"text-[var(--pt-card-price-amount)]",children:[f&&k&&a.jsxs(b,{className:s?"":"h-[98px]",children:[l&&a.jsx(b,{className:"p-2",children:a.jsx(b,{className:"flex items-center justify-between pt-[21px] pb-4",children:a.jsx(H,{variant:"label3",children:"Free"})})}),u&&a.jsx(b,{className:"p-2",children:a.jsx(b,{className:"flex items-center justify-between pt-[21px] pb-4",children:a.jsx(H,{variant:"label4",children:"Custom"})})}),h&&a.jsx(ES,{interval:e,priceOption:h,stairstepPrices:$}),w&&!h&&!s&&a.jsx(y4,{priceOption:v[0]}),x&&!h&&!w&&!s&&a.jsx(y4,{priceOption:y[0]})]}),!k&&!s&&a.jsx(IS,{dynamicPrices:C,showMore:c,interval:e}),p&&!r&&a.jsx(b,{className:"h-6",children:o}),g&&a.jsx(a.Fragment,{children:!!(h||w||x||l||u||s)&&a.jsx(TS,{interval:e,dynamicPrices:C,showMoreCard:s,dynamicAsFixedPrice:w||x,showMore:c})})]}),s&&$.length>0&&a.jsx(b,{className:"mt-4 mb-2",children:a.jsx(x4,{interval:e,showMoreCard:s,priceOptions:t,dynamicPrices:$,entitlementPriceOptions:n,creditAttachmentPriceOptions:i})})]})},PS=({description:e,entitlements:t,baseEntitlementsPlanName:n,priceContent:i})=>a.jsxs(b,{children:[a.jsx(H,{variant:"label7",className:"mb-2 text-[var(--pt-card-description)]",children:"Description"}),a.jsx(F,{variant:"body5",className:"mb-4 text-[var(--pt-card-description)]",children:e}),i,a.jsx(b4,{entitlements:t,baseEntitlementsPlanName:n})]});function OS(e){m.useEffect(function(){typeof e=="function"&&e()},[])}var AS="Expected a function",w4=NaN,zS="[object Symbol]",MS=/^\s+|\s+$/g,RS=/^[-+]0x[0-9a-f]+$/i,FS=/^0b[01]+$/i,US=/^0o[0-7]+$/i,VS=parseInt,ZS=typeof Er=="object"&&Er&&Er.Object===Object&&Er,BS=typeof self=="object"&&self&&self.Object===Object&&self,WS=ZS||BS||Function("return this")(),HS=Object.prototype,KS=HS.toString,GS=Math.max,JS=Math.min,Bd=function(){return WS.Date.now()};function qS(e,t,n){var i,r,o,s,l,u,c=0,d=!1,f=!1,p=!0;if(typeof e!="function")throw new TypeError(AS);t=C4(t)||0,Wd(n)&&(d=!!n.leading,f="maxWait"in n,o=f?GS(C4(n.maxWait)||0,t):o,p="trailing"in n?!!n.trailing:p);function g(S){var P=i,D=r;return i=r=void 0,c=S,s=e.apply(D,P),s}function h(S){return c=S,l=setTimeout(w,t),d?g(S):s}function v(S){var P=S-u,D=S-c,B=t-P;return f?JS(B,o-D):B}function y(S){var P=S-u,D=S-c;return u===void 0||P>=t||P<0||f&&D>=o}function w(){var S=Bd();if(y(S))return x(S);l=setTimeout(w,v(S))}function x(S){return l=void 0,p&&i?g(S):(i=r=void 0,s)}function C(){l!==void 0&&clearTimeout(l),c=0,i=u=r=l=void 0}function $(){return l===void 0?s:x(Bd())}function k(){var S=Bd(),P=y(S);if(i=arguments,r=this,u=S,P){if(l===void 0)return h(u);if(f)return l=setTimeout(w,t),g(u)}return l===void 0&&(l=setTimeout(w,t)),s}return k.cancel=C,k.flush=$,k}function Wd(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function YS(e){return!!e&&typeof e=="object"}function XS(e){return typeof e=="symbol"||YS(e)&&KS.call(e)==zS}function C4(e){if(typeof e=="number")return e;if(XS(e))return w4;if(Wd(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Wd(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(MS,"");var n=FS.test(e);return n||US.test(e)?VS(e.slice(2),n?2:8):RS.test(e)?w4:+e}var QS=qS,eN=qn(QS);function tN(e,t,n){var i=m.useCallback(function(o){return eN(o,t,n)},[t,n]),r=m.useRef(i(e));return m.useEffect(function(){r.current=i(e)},[e,i]),r.current}function rN(e,t){var n=m.useRef(!1);typeof t<"u"&&!Array.isArray(t)?t=[t]:Array.isArray(t)&&t.length===0&&console.warn("Using [] as the second argument makes useDidUpdate a noop. The second argument should either be `undefined` or an array of length greater than 0."),m.useEffect(function(){n.current?e():n.current=!0},t),m.useEffect(function(){return function(){n.current=!1}},[])}var k4=typeof window>"u"?m.useEffect:m.useLayoutEffect;function nN(e,t){t===void 0&&(t=!1);var n=t?k4:m.useEffect,i=m.useRef(e);return n(function(){i.current=e}),i}function iN(e){var t=nN(e);function n(){for(var i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];typeof t.current=="function"&&t.current.apply(t,i)}return n}var oN=process.env.NODE_ENV!=="production",_4=function(){};if(oN){var sN=function(e){var t="Warning: ".concat(e);typeof console<"u"&&console.error(t);try{throw new Error(t)}catch{}};_4=function(e,t){e||sN(t)}}function aN(e,t,n,i,r,o){i===void 0&&(i={}),r===void 0&&(r=!0),o===void 0&&(o=!1);var s=iN(n),l=o?k4:m.useEffect;l(function(){return _4(typeof e<"u","[useGlobalObjectEventListener]: Cannot attach event handlers to undefined."),typeof e<"u"&&r?(e.addEventListener(t,s,i),function(){e.removeEventListener(t,s,i)}):function(){}},[t,i])}function lN(e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1),typeof window<"u"?aN(window,"resize",e,{passive:!0},t,n):console.warn("useOnWindowResize can't attach an event listener as window is undefined.")}var j4="...",cN=0,Ca=function(){return"__clamp_text_key__".concat(cN++)};function uN(e){var t=e.text,n=e.ellipsis,i=n===void 0?j4:n,r=e.lines,o=r===void 0?3:r,s=e.expanded,l=s===void 0?!1:s,u=e.debounceTime,c=u===void 0?300:u,d=e.charWidth,f=d===void 0?1.2:d,p=m.useState(function(){return{noClamp:!1,clampedText:".",key:Ca()}}),g=p[0],h=g.noClamp,v=g.clampedText,y=g.key,w=p[1],x=m.useRef(),C=m.useRef(0),$=m.useCallback(function(S){var P=S.lineHeight,D=S.originalText,B=S.expanded,z=S.ellipsis,W=S.lines,J=S.charWidth,q=x.current;if(!q)return;if(!D||B){w({noClamp:!0,clampedText:D,key:Ca()});return}var V=P*W+1,I=0;typeof z=="string"?I=z===j4?5:Math.ceil(z.length*J):typeof z=="number"&&(I=Math.ceil(z*J));var T=0,M=0,R=D.length;if(!q.clientHeight)return;function Q(){var ee,le=(ee=q?.clientHeight)!==null&&ee!==void 0?ee:1;le<=V?T=M+1:R=M-1}for(;T<=R;){if(M=Math.floor((T+R)/2),q.innerText=D.slice(0,M),M===D.length){w({clampedText:D,noClamp:!0,key:Ca()});return}Q()}var Z=D.slice(0,Math.max(M-I,0)).trim()+(typeof z=="string"?z:"");q.innerText=Z,w({noClamp:!1,clampedText:Z,key:Ca()})},[]),k=tN($,c);return lN(function(){return k({lineHeight:C.current,originalText:t,expanded:l,ellipsis:i,lines:o,charWidth:f})}),OS(function(){var S,P;if(t&&!C.current){var D=((P=(S=x.current)===null||S===void 0?void 0:S.clientHeight)!==null&&P!==void 0?P:1)+1;C.current=D,$({lineHeight:D,originalText:t,expanded:l,ellipsis:i,lines:o,charWidth:f})}}),rN(function(){$({lineHeight:C.current,originalText:t,expanded:l,ellipsis:i,lines:o,charWidth:f})},[l,t,f,i,o]),[x,{noClamp:h,clampedText:v,key:y}]}const dN=({description:e,showDetails:t})=>{const[n,{noClamp:i,clampedText:r,key:o}]=uN({text:e,ellipsis:12.5,lines:3});return e?a.jsx(F,{variant:"body6",className:"text-[var(--pt-card-description-text)]",children:a.jsxs("span",{ref:n,className:"w-full inline-block",children:[r,!i&&a.jsxs(a.Fragment,{children:["...",a.jsx(Kr,{onClick:s=>{t(),s?.stopPropagation()},className:"!inline",children:a.jsx(F,{variant:"body6",className:"text-[var(--pt-card-description-link)] border-b border-[var(--pt-card-description-link)]",children:"See more"})})]})]},o)}):null},ka=({plan:e,interval:t,featureOrderMap:n,isPricePage:i,isCustomerPortal:r=!1,statusTag:o,addPriceButton:s,buttonText:l,isCurrentPlan:u,planActions:c,cardAction:d,buttonAction:f})=>{const p=!i&&!r,{theme:g,cssVars:h}=Rd(p,r),{setPlans:v}=g4(),{shouldShowDescription:y}=wa({selectedInterval:t,publishedOnly:i}),[w,x]=m.useState(!1);if(m.useEffect(()=>{e&&v(oe=>[...oe,e])},[e,v]),!e)return null;const{name:C,entitlements:$,base_entitlements_plan_name:k,is_free:S,is_custom:P,custom_cta_text:D,description:B,price_options:z,entitlement_price_options:W,credit_attachment_price_options:J,credit_attachments:q,trial_duration_unit:V,trial_duration_value:I,version_id:T,is_visible:M,is_invoiceable:R,status:Q}=e,Z=W.map((oe,Te)=>({item:oe,index:Te})).sort((oe,Te)=>{const xe=oe.item.price.owner?.feature?.id,Ne=Te.item.price.owner?.feature?.id,Ie=n.get(xe)??Number.MAX_SAFE_INTEGER,qe=n.get(Ne)??Number.MAX_SAFE_INTEGER;return Ie===qe?oe.index-Te.index:Ie-qe}).map(({item:oe})=>oe),ee=Tf(t,[...z,...Z,...J]),le=V&&I,ie=I===1?V:`${V}s`,Y=cl([...$]).filter(oe=>oe?.is_visible),se=ny(Y,n),we=q?.filter(oe=>oe.included_allowance);if(!ee&&!S&&!P&&i||!M&&i||!R&&i||!ee&&Q!==Ef.DRAFT&&(z?.length>0||W?.length>0||J?.length>0))return null;const ke=oe=>a.jsx(LS,{trialTag:le&&a.jsx(An,{background:"bg-[var(--pt-free-trial-bg)]",textColor:"text-[var(--pt-free-trial-text)]",size:"small",children:a.jsx(F,{variant:"body6",className:"text-[var(--pt-free-trial-text)]",children:`${I} ${ie} Free trial`})}),offering:e,interval:t,priceOptions:z,entitlementPriceOptions:Z,creditAttachmentPriceOptions:J,isPricePage:i,versionId:T,showMoreCard:oe,showMore:()=>x(!0),isFree:S,isCustom:P,addPriceButton:s}),fe="relative flex-[0_0_auto] w-[330px] cursor-pointer",Ee=P?D:S?"Get started":le?`Start ${I} ${ie} free trial`:"Buy now",be=i?Ee:l,$e=()=>{f?.()},de=u?"var(--pt-current-sub-card-radius, var(--pt-card-radius, 1rem))":"var(--pt-card-radius, 1rem)";return a.jsxs(b,{className:`flex flex-col border text-wrap shrink-0 ${u?"bg-[var(--pt-current-sub-card-header-bg)]":"bg-[var(--pt-card-header-bg)]"} ${fe}`,onClick:d,style:{...r||i?{}:h,...u&&!r&&!i?al(g):{},borderRadius:de,borderColor:"var(--pt-card-border, #e5e7eb)",borderWidth:"var(--pt-card-border-width, 1px)",borderStyle:"solid"},children:[a.jsxs(b,{className:"flex items-center justify-between pl-4 pr-[5px] pt-[6px] pb-[2px]",children:[a.jsx(H,{variant:"label7",className:`${u?"text-[var(--pt-current-sub-card-header-text)]":"text-[var(--pt-card-header-text)]"}`,children:C}),a.jsxs(b,{className:"flex items-center gap-x-2",children:[o," ",c]})]}),a.jsxs(b,{className:`flex-grow border border-[var(--pt-card-header-bg)] w-full p-2 pb-[40px] ${u?"":"bg-[var(--pt-card-bg)]"}`,style:{borderRadius:`calc(${de} - 2px)`,...u?{background:"var(--pt-card-bg)",backgroundImage:"var(--pt-card-gradient)"}:{}},children:[y&&a.jsx(b,{className:"h-[51px] mt-1",children:a.jsx(dN,{description:B,showDetails:()=>x(!0)})}),ke(),(i||r)&&a.jsx(rr,{className:"w-full !text-[var(--pt-button-text)] !bg-[var(--pt-button-bg)] mt-3",onClick:$e,disabled:u,children:be}),a.jsx(b,{className:"mt-4 mb-2",children:a.jsx(x4,{interval:t,showMoreCard:!1,priceOptions:z,entitlementPriceOptions:Z,creditAttachmentPriceOptions:J})}),a.jsx(b,{className:"px-2 mt-3",children:a.jsx(b4,{entitlements:se,credits:we,baseEntitlementsPlanName:k})})]}),a.jsx(Hr,{isOpen:w,onClose:()=>x(!1),title:C,size:"small",modalClassName:"!bg-[var(--pt-card-bg)]",bottomBorder:"border-[var(--pt-card-price-border)]",topContent:a.jsxs(b,{className:"flex justify-between items-center gap-x-2 border-b border-[var(--pt-card-price-border)] pb-4 px-4 mb-[-16px] mx-[-16px]",children:[a.jsx(vr,{variant:"h6",className:"text-[var(--pt-card-description-text)]",children:C}),a.jsx("span",{onClick:()=>x(!1),className:"cursor-pointer",style:{color:"var(--pt-card-description-text, theme(colors.grey.500))"},children:a.jsx(ge,{name:"circle-close",size:24,color:"currentColor"})})]}),bottomContent:a.jsxs(b,{className:"flex justify-end gap-x-2",children:[a.jsx(Ni,{onClick:()=>x(!1),className:"!text-[var(--cp-modal-footer-secondary-text)] !bg-[var(--cp-modal-footer-secondary-bg)]",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width, 1px)",borderColor:"var(--cp-modal-footer-secondary-border, theme(colors.grey.200))",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:i?"Cancel":"Close"}),i&&a.jsx(rr,{onClick:$e,className:"!text-[var(--cp-modal-footer-primary-text)] !bg-[var(--cp-modal-footer-primary-bg)]",style:{borderWidth:"var(--cp-modal-footer-primary-border-width, 0px)",borderColor:"var(--cp-modal-footer-primary-border, transparent)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:be})]}),children:a.jsx(PS,{baseEntitlementsPlanName:k,description:B,entitlements:$,priceContent:ke(!0)})})]})},fN=async({productKey:e,checkoutUsername:t,countryCode:n})=>{const{data:i}=await Fe().get("/product_catalogues/public/products",{params:{product_key:e,checkout_username:t,country_code:n}});return i},pN=({productKey:e,checkoutUsername:t,countryCode:n,enabled:i=!0})=>{const[r,o]=m.useState(null),[s,l]=m.useState(null),[u,c]=m.useState(!1),d=m.useCallback(async()=>{if(i){c(!0);try{const f=await fN({productKey:e,checkoutUsername:t,countryCode:n});o(f?.data)}catch(f){const p=f,g=p?.response?.data?.data?.error||p?.message;l(g||"Failed to load public product")}finally{c(!1)}}},[e,t,n,i]);return m.useEffect(()=>{i&&d()},[d,i]),{product:r,error:s,isLoading:u,refetch:d}};var $r=(e=>(e.PLAN="plan",e.ADD_ON="add_on",e.SINGLE_PURCHASE="single_purchase",e))($r||{}),$4=(e=>(e.STRICT_AUTO_DETECT="strict_auto_detect",e.SMART_PRE_FILL="smart_pre_fill",e))($4||{});const mN=async e=>{const{data:t}=await Fe().get(`/product_catalogues/public/localization-settings?checkout_username=${e}`);return t},hN=e=>{const[t,n]=m.useState(null),[i,r]=m.useState(!0);return m.useEffect(()=>{(async()=>{try{const o=await mN(e);n(o?.data)}catch{}finally{r(!1)}})()},[e]),{settings:t,loading:i}},gN=async(e,t)=>{const{data:n}=await Fe().get(`/product_catalogues/public/products/${e}/localizations?status=active&checkout_username=${t}`);return n},vN=(e,t,n=!0)=>{const[i,r]=m.useState([]),[o,s]=m.useState(null),[l,u]=m.useState(n);return m.useEffect(()=>{if(!n){u(!1);return}e&&(async()=>{try{const c=(await gN(e,t))?.data;r(c?.localizations||[]),s(c?.tenant_country||null)}catch{}finally{u(!1)}})()},[e,t,n]),{localizations:i,tenantCountry:o,loading:l}},bN=(e=!0)=>{const[t,n]=m.useState(void 0),[i,r]=m.useState(!0),[o,s]=m.useState(null);return m.useEffect(()=>{if(!e){r(!1);return}r(!0),(async()=>{try{const l="https://api.bigdatacloud.net/data/reverse-geocode-client",u=(await F1.get(l)).data;u&&n({code:u.countryCode,name:u.countryName})}catch(l){s(l)}finally{r(!1)}})()},[e]),{country:t,loading:i,error:o}},_a="GLOBAL",Hd=(e,t)=>{const[n,i]=m.useState(void 0),[r,o]=m.useState(""),{settings:s,loading:l}=hN(t),u=s?.selection===$4.SMART_PRE_FILL,{localizations:c=[],loading:d}=vN(e,t,u),f=m.useMemo(()=>new Set(c.map($=>$.country_code)),[c]),{country:p,loading:g,error:h}=bN(u),v=m.useMemo(()=>{const $=c?.map(k=>({country_code:k.country_code,currency_code:k.currency_code}))??[];return[{country_code:_a,currency_code:r},...$]},[c,r]),y=m.useMemo(()=>v.map($=>$.country_code===_a?{label:`Global (${$.currency_code} ${xt($.currency_code)})`,value:$.country_code}:{label:`${V4($.country_code)} ${U4($.country_code)} (${xt($.currency_code)})`,value:$.country_code}),[v]),w=m.useMemo(()=>{if(!(!u||!p))return f.has(p.code)?p.code:_a},[u,p,f]),x=n??w;m.useEffect(()=>{!n&&w&&i(w)},[n,i,w]);const C=m.useMemo(()=>x===_a?void 0:x,[x]);return{selectedCountry:x,setSelectedCountry:i,setOfferingCurrency:o,allLocalizations:y,showLocalizationDropdown:u,apiCountryCode:C,isResolvingLocalization:l||!(!u||!d&&!g&&(x||h))}},yN=({selectedTab:e,setSelectedTab:t,tabOptions:n})=>a.jsx(b,{className:"w-full flex justify-center border-b border-[var(--pt-tabs-border)] mb-6",children:n.map(i=>{const r=e===i.value;return a.jsx(b,{className:`px-4 py-2 text-center cursor-pointer ${r?"border-b border-[var(--pt-tabs-indicator)]":""}
80
+ ${u?"bg-[var(--pt-interval-active-bg,var(--cp-tabs-active-bg))] shadow-sm":"bg-transparent hover:opacity-80"}`,onClick:()=>r(l),children:a.jsx(F,{variant:"body6",className:"font-medium whitespace-nowrap",color:u?"text-[var(--pt-interval-active-text,var(--cp-tabs-active-text))]":"text-[var(--pt-interval-inactive-text,var(--cp-tabs-inactive-text))]",children:Rt(l)})},l)})})})},Ud=e=>{const t=m.useMemo(()=>ry(e||[]),[e]),[n,i]=m.useState(""),r=m.useMemo(()=>[...t.includes(Ve.DAILY)?[Ve.DAILY]:[],...t.includes(Ve.WEEKLY)?[Ve.WEEKLY]:[],...t.includes(Ve.MONTHLY)?[Ve.MONTHLY]:[],...t.includes(Ve.QUARTERLY)?[Ve.QUARTERLY]:[],...t.includes(Ve.BIANNUALLY)?[Ve.BIANNUALLY]:[],...t.includes(Ve.YEARLY)?[Ve.YEARLY]:[]],[t]);return m.useEffect(()=>{!n&&r[0]&&i(r[0])},[r,n]),{intervals:r,selectedInterval:n,setSelectedInterval:i}},g4=ti(e=>({plans:[],setPlans:t=>e(n=>({plans:typeof t=="function"?t(n.plans):t}))}));function Vd(e,t){let n;try{n=e()}catch{return}return{getItem:r=>{var o;const s=u=>u===null?null:JSON.parse(u,void 0),l=(o=n.getItem(r))!=null?o:null;return l instanceof Promise?l.then(s):s(l)},setItem:(r,o)=>n.setItem(r,JSON.stringify(o,void 0)),removeItem:r=>n.removeItem(r)}}const Zd=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(i){return Zd(i)(n)},catch(i){return this}}}catch(n){return{then(i){return this},catch(i){return Zd(i)(n)}}}},SS=(e,t)=>(n,i,r)=>{let o={storage:Vd(()=>localStorage),partialize:v=>v,version:0,merge:(v,y)=>({...y,...v}),...t},s=!1;const l=new Set,u=new Set;let c=o.storage;if(!c)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...v)},i,r);const d=()=>{const v=o.partialize({...i()});return c.setItem(o.name,{state:v,version:o.version})},f=r.setState;r.setState=(v,y)=>(f(v,y),d());const p=e((...v)=>(n(...v),d()),i,r);r.getInitialState=()=>p;let g;const h=()=>{var v,y;if(!c)return;s=!1,l.forEach(x=>{var C;return x((C=i())!=null?C:p)});const w=((y=o.onRehydrateStorage)==null?void 0:y.call(o,(v=i())!=null?v:p))||void 0;return Zd(c.getItem.bind(c))(o.name).then(x=>{if(x)if(typeof x.version=="number"&&x.version!==o.version){if(o.migrate){const C=o.migrate(x.state,x.version);return C instanceof Promise?C.then($=>[!0,$]):[!0,C]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,x.state];return[!1,void 0]}).then(x=>{var C;const[$,k]=x;if(g=o.merge(k,(C=i())!=null?C:p),n(g,!0),$)return d()}).then(()=>{w?.(g,void 0),g=i(),s=!0,u.forEach(x=>x(g))}).catch(x=>{w?.(void 0,x)})};return r.persist={setOptions:v=>{o={...o,...v},v.storage&&(c=v.storage)},clearStorage:()=>{c?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>h(),hasHydrated:()=>s,onHydrate:v=>(l.add(v),()=>{l.delete(v)}),onFinishHydration:v=>(u.add(v),()=>{u.delete(v)})},o.skipHydration||h(),g||p},v4=SS,mo=ti()(v4(e=>({selections:{},setSelection:(t,n)=>e(i=>({selections:{...i.selections,[t]:n}}))}),{name:"metrifox:stairstep-selections",storage:Vd(()=>localStorage)})),wa=({selectedInterval:e,publishedOnly:t=!1})=>{const{plans:n}=g4(),[i,r]=m.useState(40),o=m.useCallback(d=>{if(!d)return;const f=d.published_version||d,p=d.draft_version;return t?f?.is_visible?f:void 0:f||p},[t]),s=n?.some(d=>!!o(d)?.description),l=n?.some(d=>!!o(d)?.trial_duration_value),u=n?.some(d=>{const f=o(d);return f?f.price_options?.some(p=>p.price?.billing_interval===e)||f.entitlement_price_options?.filter(p=>p.price.billing_interval===e).length===1||f.credit_attachment_price_options?.filter(p=>p.price.billing_interval===e).length===1||f.is_free||f.is_custom:!1}),c=n?.some(d=>{const f=o(d);return f?[f.credit_attachment_price_options,f.entitlement_price_options].some(p=>Array.isArray(p)&&p.some(g=>g.price?.billing_interval===e)):!1});return m.useEffect(()=>{n.forEach(d=>{const f=o(d);if(!f)return;const p=[...f.credit_attachment_price_options||[],...f.entitlement_price_options||[]].filter(w=>w.price?.billing_interval===e),g=w=>{const x=w,C=x?.price?.name||x?.price?.owner?.feature?.name||x?.price?.owner?.name,{price:$,label:k,currencySymbol:S}=Ho(x);return`${C} from ${S}${$}${k?`/${k}`:""}`.length>40?39:24},h=p[0]?g(p[0]):0,v=p[1]?g(p[1]):0,y=h+v;r(w=>y>w?y:w)})},[n,e,o]),{dynamicCardHeight:i,shouldShowDescription:s,shouldShowFreeTrial:l,shouldShowFixedPrice:u,shouldShowDynamicPrices:c}},b4=({entitlements:e,baseEntitlementsPlanName:t,credits:n})=>{const i=cl(e).filter(r=>r?.is_visible);return a.jsxs(b,{children:[a.jsx(H,{variant:"label7",className:"text-[var(--pt-feature-text)] mb-3",as:"p",children:t?`Everything in ${t} plus:`:e.length>0?"Included:":"\xA0"}),a.jsxs("ul",{className:"flex flex-col gap-y-3",children:[n?.map((r,o)=>a.jsxs("li",{className:"flex items-center gap-[10px]",children:[" ",a.jsx("span",{style:{color:"var(--pt-feature-icon, theme(colors.green.600))"},className:"flex items-center",children:a.jsx(ge,{name:"check",color:"currentColor",size:16})}),a.jsxs(F,{variant:"body5",className:"text-[var(--pt-feature-text)]",children:[r.included_allowance+" ",r.included_allowance===1?r.credit_unit_singular:r.credit_unit_plural]})]},o)),i?.map((r,o)=>a.jsxs("li",{className:"flex items-center gap-[10px]",children:[" ",a.jsx("span",{style:{color:"var(--pt-feature-icon, theme(colors.green.600))"},className:"flex items-center",children:a.jsx(ge,{name:"check",color:"currentColor",size:16})}),a.jsx(F,{variant:"body5",className:"text-[var(--pt-feature-text)]",children:r.display_text})]},o))]})]})},NS=(e,t=[])=>{const n=mo(D=>D.selections),i=e?.price?.billing_interval,r=e?.price.tiers,o=e?.price.currency,s=e?.price?.invoice_timing,l=xt(o),u=D=>{const B=e?.price?.owner,z=B?.included_usage||0,W=D?.find(M=>M.first_unit===z);if(!W)return{price:null,label:null};const{unit_price:J,package_price:q,package_size:V,pricing_model:I,flat_fee:T}=W;return T?{price:T.toFixed(2),label:""}:{per_unit:{price:J?.toFixed(2),label:`per. ${B?.feature?.unit_singular||B?.credit_unit_singular}`},per_package:{price:q?.toFixed(2),label:`for ${V} ${B?.feature?.unit_plural}`}}[I]??{price:null,label:null}},{price:c,label:d}=u(r),f=e?.price?.is_custom&&e?.price?.billing_interval_value>1?`every ${e?.price?.billing_interval_value} ${ey[i]}`:i,p=[Ve.DAILY,Ve.WEEKLY],g={[Ve.DAILY]:"day",[Ve.WEEKLY]:"week"},h=i,v=p.includes(h)?g[h]:"month",y=m.useMemo(()=>t.reduce((D,B)=>{const z=n[B.id];return D+(z||0)},0),[t,n]),w=e?.price?.price??0,x=Wo(i,e?.price?.billing_interval_value),C=w+y,$=x>1?C/x:C,k=C,S=$.toFixed(2),P=k.toFixed(2);return{amount:S,billedText:f,intervalText:v,billingAmount:P,tierPrice:c,tierLabel:d,currencySymbol:l,invoiceTiming:s,intervalValue:e?.price?.billing_interval_value}},ES=({priceOption:e,interval:t,stairstepPrices:n=[]})=>{const{amount:i,billedText:r,billingAmount:o,intervalText:s,currencySymbol:l,intervalValue:u}=NS(e,n),c=_e(i).split("."),d=c?c[0]:"0",f=c&&c.length>1?c[1]:"00";return a.jsxs(b,{className:"p-2 border-b border-grey-200 last:border-0",children:[a.jsx(b,{className:"flex items-center justify-between",children:a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Fixed recurring"})}),a.jsxs(b,{className:"flex items-end",children:[a.jsxs(H,{variant:"label3",children:[l,d]}),a.jsxs(H,{variant:"label6",className:"mb-[5px]",children:[".",f]}),a.jsxs(F,{variant:"body4",className:"mb-[5px] text-[var(--pt-card-price-secondary-text)]",children:["/",s]})]}),(t!==Ve.MONTHLY||u!==1)&&a.jsxs(F,{className:"-mt-[4px] mb-1",variant:"body6",children:["Billed"," ",a.jsxs(H,{as:"span",variant:"label8",className:"inline-block",children:[l,_e(o)," ",r.toLowerCase()]})]})]})},TS=({interval:e,dynamicPrices:t,showMoreCard:n,dynamicAsFixedPrice:i,showMore:r})=>{const[o,s]=m.useState(""),{dynamicCardHeight:l}=wa({selectedInterval:e}),u=n?"":"flex flex-col",c=n?{}:{height:l+20},d=m.useMemo(()=>t.filter(f=>f?.price?.tier_type!==Bt.STAIRSTEP),[t]);return a.jsxs(b,{className:u,style:c,children:[(n?d:d.slice(0,2)).map(f=>{const p=f?.price?.name||f?.price?.owner?.feature?.name||f?.price?.owner?.name,g=ty(f?.price.tiers,f.price.currency),{price:h,label:v,currencySymbol:y,isPercentage:w}=Ho(f),x=g?.length===1;return n?a.jsxs(b,{className:"p-2 border-b border-[var(--pt-card-price-border)] last:border-0",children:[a.jsxs(b,{className:"flex justify-between items-center",children:[a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-1",children:p}),x&&a.jsxs(b,{className:"flex items-center cursor-pointer",children:[a.jsxs(H,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!w&&y,h]}),v&&a.jsxs(F,{variant:"body5",color:"text-[var(--pt-card-price-secondary-text)]",className:"mr-1",children:[w?"\xA0":"/",v]})]})]}),!x&&a.jsxs(b,{className:"flex justify-between items-center",children:[a.jsx(F,{variant:"body5",className:"text-[var(--pt-card-price-primary-text)]",children:"Starts at"}),a.jsxs(b,{className:"flex items-center cursor-pointer",onClick:C=>{C.stopPropagation(),s(o===f.id?"":f.id)},children:[a.jsxs(H,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!w&&y,h]}),a.jsxs(F,{variant:"body5",color:"text-[var(--pt-card-price-secondary-text)]",className:"mr-1",children:[w?"\xA0":"/",v]}),g.length>1&&a.jsx(ge,{name:o===f.id?"arrow-up-light":"arrow-down-linear",size:16,color:"grey-400"})]})]}),o===f.id&&g.length>1&&a.jsx(b,{className:"bg-grey-200 p-2 mt-1 rounded-lg",children:a.jsx(b,{className:"flex flex-col gap-y",children:g?.map(C=>a.jsxs(b,{className:"flex justify-between items-center",children:[a.jsx(F,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:C?.label}),a.jsxs(F,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:[C?.price,C?.package?`/${C?.package} ${v}`:""]})]},C?.label))})})]},f.id):i?null:a.jsx(b,{className:"mt-1",children:a.jsxs(b,{className:"flex items-center gap-x-1 flex-wrap",children:[a.jsx(H,{variant:"label8",className:"text-[var(--pt-card-price-secondary-text)] whitespace-nowrap",children:p}),a.jsx(F,{variant:"body7",className:"text-[var(--pt-card-price-primary-text)]",children:x?"at":"from"}),a.jsxs(b,{className:"flex items-center",children:[a.jsxs(H,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!w&&y,h]}),v&&a.jsxs(F,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:[w?"\xA0":"/",v]})]})]})},f.id)}),!n&&!!t?.length&&a.jsx(b,{className:"flex justify-center mt-auto",children:a.jsx(Kr,{onClick:f=>{r(),f?.stopPropagation()},className:"mt-2",children:a.jsx(F,{variant:"body8",className:"text-[var(--pt-card-description-link)] underline",children:"Explore all prices \u2192"})})})]})},y4=({priceOption:e})=>{const t=mo(x=>x.selections),n=Ho(e),i=e?.price?.tier_type===Bt.STAIRSTEP?t[e.id]:void 0,r=e?.price?.billing_interval,o=e?.price?.billing_interval_value||1,s=Wo(r,o),l=e?.price?.owner?.feature?.usage_model===Vo.PERSISTENT_USE,u=s>1&&l,c=i!==void 0&&u?i/s:i,d=i!==void 0,f=d?_e(c):n.price,p=d?"":n.label,g=d?xt(e?.price?.currency)||"":n.currencySymbol,h=d?!1:n.isPercentage,v=f?.split("."),y=v?v[0]:"0",w=v&&v.length>1?v[1]:"00";return a.jsxs(b,{className:"p-2 border-b border-grey-200 last:border-0",children:[a.jsx(b,{className:"flex items-center justify-between",children:a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Starts at"})}),a.jsxs(b,{className:"flex items-end",children:[!h&&a.jsxs(a.Fragment,{children:[a.jsxs(H,{variant:"label3",children:[g,y]}),a.jsxs(H,{variant:"label6",className:"mb-[5px]",children:[".",w]})]}),h&&a.jsx(H,{variant:"label3",children:f}),p&&a.jsxs(F,{variant:"body4",className:"mb-[5px] text-[var(--pt-card-price-secondary-text)]",children:[h?"\xA0":"/",p]})]})]})},IS=({interval:e,dynamicPrices:t,showMore:n})=>{const{dynamicCardHeight:i}=wa({selectedInterval:e}),r={height:i+118},o=mo(h=>h.selections),{stairstepPriceOptions:s,regularPriceOptions:l}=m.useMemo(()=>{const h=[],v=[];return t.forEach(y=>{y?.price?.tier_type===Bt.STAIRSTEP?h.push(y):v.push(y)}),{stairstepPriceOptions:h,regularPriceOptions:v}},[t]),u=m.useMemo(()=>s.reduce((h,v)=>{const y=o[v.id],w=v?.price?.billing_interval_value||1,x=Wo(e,w),C=v?.price?.owner?.feature?.usage_model===Vo.PERSISTENT_USE,$=x>1&&C,k=y!==void 0&&$?y/x:y;return h+(k||0)},0),[e,s,o]),c=s.length>0&&s[0]?.price?.currency&&xt(s[0].price.currency)||"",d=_e(u).split("."),f=d?d[0]:"0",p=d&&d.length>1?d[1]:"00",g=s.length>0?1:2;return a.jsxs(b,{className:"flex flex-col",style:r,children:[a.jsxs(b,{children:[s.length>0&&a.jsxs(b,{className:"pt-2",children:[a.jsx(b,{className:"flex items-center justify-between",children:a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Starts at"})}),a.jsxs(b,{className:"flex items-end",children:[a.jsxs(H,{variant:"label3",children:[c,f]}),a.jsxs(H,{variant:"label6",className:"mb-[5px]",children:[".",p]})]})]}),l.slice(0,g).map(h=>{const v=h?.price?.name||h?.price?.owner?.feature?.name||h?.price?.owner?.name,{price:y,label:w,currencySymbol:x,isPercentage:C}=Ho(h);return a.jsxs(b,{className:"mt-1 p-2 border-b border-[var(--pt-card-price-border)] last:border-0",children:[a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-price-secondary-text)] whitespace-nowrap",children:v}),a.jsxs(b,{className:"flex items-center justify-between gap-x-1 flex-wrap mt-1",children:[a.jsx(F,{variant:"body7",className:"text-[var(--pt-card-price-primary-text)]",children:"Starts at"}),a.jsxs(b,{className:"flex items-end",children:[a.jsxs(H,{variant:"label6",color:"text-[var(--pt-card-price-amount)]",children:[!C&&x,y]}),w&&a.jsxs(F,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",className:"mb-[2px]",children:[C?"\xA0":"/",w]})]})]})]},h.id)})]}),!!t?.length&&a.jsx(b,{className:"flex justify-center mt-auto",children:a.jsx(Kr,{onClick:h=>{n(),h?.stopPropagation()},className:"mt-2",children:a.jsx(F,{variant:"body8",className:"text-[var(--pt-card-description-link)] underline",children:"Explore all prices \u2192"})})})]})},x4=({interval:e,priceOptions:t,showMoreCard:n,entitlementPriceOptions:i,creditAttachmentPriceOptions:r,dynamicPrices:o})=>{const{setSelection:s}=mo(),l=mo(c=>c.selections),u=m.useMemo(()=>{if(o)return o.filter(d=>d?.price?.tier_type===Bt.STAIRSTEP);if(!t||!i||!r)return[];const c=Bo(e,i);return[...Bo(e,r),...c].filter(d=>d?.price?.tier_type===Bt.STAIRSTEP)},[e,t,o,i,r]);return a.jsx(b,{children:(n?u:u.slice(0,3)).map(c=>a.jsx(DS,{price:c,selections:l,setSelection:s},c.id))})},DS=({price:e,selections:t,setSelection:n})=>{const i=e.price?.tiers||[],r=e.price?.currency||"",o=Xd(r),s=J7[e.price?.billing_interval],l=e?.price.owner,u=l?.feature?.unit_singular||l?.credit_unit_singular||l?.unit_singular,c=l?.feature?.unit_plural||l?.credit_unit_plural||l?.unit_plural,d=i.map(h=>{const v={label:`${h.total_unit_quantity||0} ${h.total_unit_quantity&&h.total_unit_quantity>1?c:u} /${s}`,value:h.flat_fee?String(h.flat_fee):"0"};return h.flat_fee&&(v.description=`${o}${_e(h.flat_fee)}`),v}),f=t[e.id],p=d[0]?.value?parseFloat(d[0].value):0,g=String(f||p);return m.useEffect(()=>{!t[e.id]&&d.length>0&&d[0]?.value&&n(e.id,parseFloat(d[0].value))},[e.id,d.length,n]),a.jsx(b,{className:"mb-3 last:mb-0",children:a.jsx(Zc,{size:"small",options:d,className:"w-full",value:g,showDescriptionInline:!0,onChange:h=>{n(e.id,parseFloat(h))},containerClassName:"!bg-white !border-grey-200 !px-4 !py-3 hover:!border-grey-300 transition-colors"})})},LS=({interval:e,priceOptions:t,entitlementPriceOptions:n,creditAttachmentPriceOptions:i,isPricePage:r,trialTag:o,showMoreCard:s,isFree:l,isCustom:u,showMore:c,addPriceButton:d})=>{const{shouldShowFixedPrice:f,shouldShowFreeTrial:p,shouldShowDynamicPrices:g}=wa({selectedInterval:e,publishedOnly:r}),h=Tf(e,t),v=Bo(e,n),y=Bo(e,i),w=v.length===1&&!h,x=y.length===1&&!h&&v.length===0,C=[...y,...v],$=C.filter(S=>S?.price?.tier_type===Bt.STAIRSTEP);if(!r&&!h&&v.length===0&&!y.length&&!l&&!u)return a.jsxs(a.Fragment,{children:[a.jsx(b,{className:"h-[94px] flex items-center",children:a.jsx(b,{className:"w-full bg-grey-100 border border-grey-200 rounded-2xl p-2 mb-3",children:d||a.jsx(F,{variant:"body6",className:"text-[var(--pt-card-price-amount)]",children:"No price added yet"})})}),p&&a.jsx(b,{className:"h-6"})]});const k=!!(h||w||x||l||u);return a.jsxs(a.Fragment,{children:[a.jsxs(b,{className:s?"bg-[var(--pt-card-price-bg)] border border-[var(--pt-card-price-border)] rounded-2xl p-2 mb-3 text-[var(--pt-card-price-amount)]":"text-[var(--pt-card-price-amount)]",children:[f&&k&&a.jsxs(b,{className:s?"":"h-[98px]",children:[l&&a.jsx(b,{className:"p-2",children:a.jsx(b,{className:"flex items-center justify-between pt-[21px] pb-4",children:a.jsx(H,{variant:"label3",children:"Free"})})}),u&&a.jsx(b,{className:"p-2",children:a.jsx(b,{className:"flex items-center justify-between pt-[21px] pb-4",children:a.jsx(H,{variant:"label4",children:"Custom"})})}),h&&a.jsx(ES,{interval:e,priceOption:h,stairstepPrices:$}),w&&!h&&!s&&a.jsx(y4,{priceOption:v[0]}),x&&!h&&!w&&!s&&a.jsx(y4,{priceOption:y[0]})]}),!k&&!s&&a.jsx(IS,{dynamicPrices:C,showMore:c,interval:e}),p&&!r&&a.jsx(b,{className:"h-6",children:o}),g&&a.jsx(a.Fragment,{children:!!(h||w||x||l||u||s)&&a.jsx(TS,{interval:e,dynamicPrices:C,showMoreCard:s,dynamicAsFixedPrice:w||x,showMore:c})})]}),s&&$.length>0&&a.jsx(b,{className:"mt-4 mb-2",children:a.jsx(x4,{interval:e,showMoreCard:s,priceOptions:t,dynamicPrices:$,entitlementPriceOptions:n,creditAttachmentPriceOptions:i})})]})},PS=({description:e,entitlements:t,baseEntitlementsPlanName:n,priceContent:i})=>a.jsxs(b,{children:[a.jsx(H,{variant:"label7",className:"mb-2 text-[var(--pt-card-description)]",children:"Description"}),a.jsx(F,{variant:"body5",className:"mb-4 text-[var(--pt-card-description)]",children:e}),i,a.jsx(b4,{entitlements:t,baseEntitlementsPlanName:n})]});function OS(e){m.useEffect(function(){typeof e=="function"&&e()},[])}var AS="Expected a function",w4=NaN,zS="[object Symbol]",MS=/^\s+|\s+$/g,RS=/^[-+]0x[0-9a-f]+$/i,FS=/^0b[01]+$/i,US=/^0o[0-7]+$/i,VS=parseInt,ZS=typeof Er=="object"&&Er&&Er.Object===Object&&Er,BS=typeof self=="object"&&self&&self.Object===Object&&self,WS=ZS||BS||Function("return this")(),HS=Object.prototype,KS=HS.toString,GS=Math.max,JS=Math.min,Bd=function(){return WS.Date.now()};function qS(e,t,n){var i,r,o,s,l,u,c=0,d=!1,f=!1,p=!0;if(typeof e!="function")throw new TypeError(AS);t=C4(t)||0,Wd(n)&&(d=!!n.leading,f="maxWait"in n,o=f?GS(C4(n.maxWait)||0,t):o,p="trailing"in n?!!n.trailing:p);function g(S){var P=i,D=r;return i=r=void 0,c=S,s=e.apply(D,P),s}function h(S){return c=S,l=setTimeout(w,t),d?g(S):s}function v(S){var P=S-u,D=S-c,B=t-P;return f?JS(B,o-D):B}function y(S){var P=S-u,D=S-c;return u===void 0||P>=t||P<0||f&&D>=o}function w(){var S=Bd();if(y(S))return x(S);l=setTimeout(w,v(S))}function x(S){return l=void 0,p&&i?g(S):(i=r=void 0,s)}function C(){l!==void 0&&clearTimeout(l),c=0,i=u=r=l=void 0}function $(){return l===void 0?s:x(Bd())}function k(){var S=Bd(),P=y(S);if(i=arguments,r=this,u=S,P){if(l===void 0)return h(u);if(f)return l=setTimeout(w,t),g(u)}return l===void 0&&(l=setTimeout(w,t)),s}return k.cancel=C,k.flush=$,k}function Wd(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function YS(e){return!!e&&typeof e=="object"}function XS(e){return typeof e=="symbol"||YS(e)&&KS.call(e)==zS}function C4(e){if(typeof e=="number")return e;if(XS(e))return w4;if(Wd(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Wd(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(MS,"");var n=FS.test(e);return n||US.test(e)?VS(e.slice(2),n?2:8):RS.test(e)?w4:+e}var QS=qS,eN=qn(QS);function tN(e,t,n){var i=m.useCallback(function(o){return eN(o,t,n)},[t,n]),r=m.useRef(i(e));return m.useEffect(function(){r.current=i(e)},[e,i]),r.current}function rN(e,t){var n=m.useRef(!1);typeof t<"u"&&!Array.isArray(t)?t=[t]:Array.isArray(t)&&t.length===0&&console.warn("Using [] as the second argument makes useDidUpdate a noop. The second argument should either be `undefined` or an array of length greater than 0."),m.useEffect(function(){n.current?e():n.current=!0},t),m.useEffect(function(){return function(){n.current=!1}},[])}var k4=typeof window>"u"?m.useEffect:m.useLayoutEffect;function nN(e,t){t===void 0&&(t=!1);var n=t?k4:m.useEffect,i=m.useRef(e);return n(function(){i.current=e}),i}function iN(e){var t=nN(e);function n(){for(var i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];typeof t.current=="function"&&t.current.apply(t,i)}return n}var oN=process.env.NODE_ENV!=="production",_4=function(){};if(oN){var sN=function(e){var t="Warning: ".concat(e);typeof console<"u"&&console.error(t);try{throw new Error(t)}catch{}};_4=function(e,t){e||sN(t)}}function aN(e,t,n,i,r,o){i===void 0&&(i={}),r===void 0&&(r=!0),o===void 0&&(o=!1);var s=iN(n),l=o?k4:m.useEffect;l(function(){return _4(typeof e<"u","[useGlobalObjectEventListener]: Cannot attach event handlers to undefined."),typeof e<"u"&&r?(e.addEventListener(t,s,i),function(){e.removeEventListener(t,s,i)}):function(){}},[t,i])}function lN(e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1),typeof window<"u"?aN(window,"resize",e,{passive:!0},t,n):console.warn("useOnWindowResize can't attach an event listener as window is undefined.")}var j4="...",cN=0,Ca=function(){return"__clamp_text_key__".concat(cN++)};function uN(e){var t=e.text,n=e.ellipsis,i=n===void 0?j4:n,r=e.lines,o=r===void 0?3:r,s=e.expanded,l=s===void 0?!1:s,u=e.debounceTime,c=u===void 0?300:u,d=e.charWidth,f=d===void 0?1.2:d,p=m.useState(function(){return{noClamp:!1,clampedText:".",key:Ca()}}),g=p[0],h=g.noClamp,v=g.clampedText,y=g.key,w=p[1],x=m.useRef(),C=m.useRef(0),$=m.useCallback(function(S){var P=S.lineHeight,D=S.originalText,B=S.expanded,z=S.ellipsis,W=S.lines,J=S.charWidth,q=x.current;if(!q)return;if(!D||B){w({noClamp:!0,clampedText:D,key:Ca()});return}var V=P*W+1,I=0;typeof z=="string"?I=z===j4?5:Math.ceil(z.length*J):typeof z=="number"&&(I=Math.ceil(z*J));var T=0,M=0,R=D.length;if(!q.clientHeight)return;function Q(){var ee,le=(ee=q?.clientHeight)!==null&&ee!==void 0?ee:1;le<=V?T=M+1:R=M-1}for(;T<=R;){if(M=Math.floor((T+R)/2),q.innerText=D.slice(0,M),M===D.length){w({clampedText:D,noClamp:!0,key:Ca()});return}Q()}var Z=D.slice(0,Math.max(M-I,0)).trim()+(typeof z=="string"?z:"");q.innerText=Z,w({noClamp:!1,clampedText:Z,key:Ca()})},[]),k=tN($,c);return lN(function(){return k({lineHeight:C.current,originalText:t,expanded:l,ellipsis:i,lines:o,charWidth:f})}),OS(function(){var S,P;if(t&&!C.current){var D=((P=(S=x.current)===null||S===void 0?void 0:S.clientHeight)!==null&&P!==void 0?P:1)+1;C.current=D,$({lineHeight:D,originalText:t,expanded:l,ellipsis:i,lines:o,charWidth:f})}}),rN(function(){$({lineHeight:C.current,originalText:t,expanded:l,ellipsis:i,lines:o,charWidth:f})},[l,t,f,i,o]),[x,{noClamp:h,clampedText:v,key:y}]}const dN=({description:e,showDetails:t})=>{const[n,{noClamp:i,clampedText:r,key:o}]=uN({text:e,ellipsis:12.5,lines:3});return e?a.jsx(F,{variant:"body6",className:"text-[var(--pt-card-description-text)]",children:a.jsxs("span",{ref:n,className:"w-full inline-block",children:[r,!i&&a.jsxs(a.Fragment,{children:["...",a.jsx(Kr,{onClick:s=>{t(),s?.stopPropagation()},className:"!inline",children:a.jsx(F,{variant:"body6",className:"text-[var(--pt-card-description-link)] border-b border-[var(--pt-card-description-link)]",children:"See more"})})]})]},o)}):null},ka=({plan:e,interval:t,featureOrderMap:n,isPricePage:i,isCustomerPortal:r=!1,statusTag:o,addPriceButton:s,buttonText:l,isCurrentPlan:u,planActions:c,cardAction:d,buttonAction:f})=>{const p=!i&&!r,{theme:g,cssVars:h}=Rd(p,r),{setPlans:v}=g4(),{shouldShowDescription:y}=wa({selectedInterval:t,publishedOnly:i}),[w,x]=m.useState(!1);if(m.useEffect(()=>{e&&v(oe=>[...oe,e])},[e,v]),!e)return null;const{name:C,entitlements:$,base_entitlements_plan_name:k,is_free:S,is_custom:P,custom_cta_text:D,description:B,price_options:z,entitlement_price_options:W,credit_attachment_price_options:J,credit_attachments:q,trial_duration_unit:V,trial_duration_value:I,version_id:T,is_visible:M,is_invoiceable:R,status:Q}=e,Z=W.map((oe,Te)=>({item:oe,index:Te})).sort((oe,Te)=>{const xe=oe.item.price.owner?.feature?.id,Ne=Te.item.price.owner?.feature?.id,Ie=n.get(xe)??Number.MAX_SAFE_INTEGER,qe=n.get(Ne)??Number.MAX_SAFE_INTEGER;return Ie===qe?oe.index-Te.index:Ie-qe}).map(({item:oe})=>oe),ee=Tf(t,[...z,...Z,...J]),le=V&&I,ie=I===1?V:`${V}s`,Y=cl([...$]).filter(oe=>oe?.is_visible),se=ny(Y,n),we=q?.filter(oe=>oe.included_allowance);if(!ee&&!S&&!P&&i||!M&&i||!R&&i||!ee&&Q!==Ef.DRAFT&&(z?.length>0||W?.length>0||J?.length>0))return null;const ke=oe=>a.jsx(LS,{trialTag:le&&a.jsx(An,{background:"bg-[var(--pt-free-trial-bg)]",textColor:"text-[var(--pt-free-trial-text)]",size:"small",children:a.jsx(F,{variant:"body6",className:"text-[var(--pt-free-trial-text)]",children:`${I} ${ie} Free trial`})}),offering:e,interval:t,priceOptions:z,entitlementPriceOptions:Z,creditAttachmentPriceOptions:J,isPricePage:i,versionId:T,showMoreCard:oe,showMore:()=>x(!0),isFree:S,isCustom:P,addPriceButton:s}),fe="relative flex-[0_0_auto] w-[330px] cursor-pointer",Ee=P?D:S?"Join for free":le?`Start ${I} ${ie} free trial`:"Subscribe",be=i?Ee:l,$e=()=>{f?.()},de=u?"var(--pt-current-sub-card-radius, var(--pt-card-radius, 1rem))":"var(--pt-card-radius, 1rem)";return a.jsxs(b,{className:`flex flex-col border text-wrap shrink-0 ${u?"bg-[var(--pt-current-sub-card-header-bg)]":"bg-[var(--pt-card-header-bg)]"} ${fe}`,onClick:d,style:{...r||i?{}:h,...u&&!r&&!i?al(g):{},borderRadius:de,borderColor:"var(--pt-card-border, #e5e7eb)",borderWidth:"var(--pt-card-border-width, 1px)",borderStyle:"solid"},children:[a.jsxs(b,{className:"flex items-center justify-between pl-4 pr-[5px] pt-[6px] pb-[2px]",children:[a.jsx(H,{variant:"label7",className:`${u?"text-[var(--pt-current-sub-card-header-text)]":"text-[var(--pt-card-header-text)]"}`,children:C}),a.jsxs(b,{className:"flex items-center gap-x-2",children:[o," ",c]})]}),a.jsxs(b,{className:`flex-grow border border-[var(--pt-card-header-bg)] w-full p-2 pb-[40px] ${u?"":"bg-[var(--pt-card-bg)]"}`,style:{borderRadius:`calc(${de} - 2px)`,...u?{background:"var(--pt-card-bg)",backgroundImage:"var(--pt-card-gradient)"}:{}},children:[y&&a.jsx(b,{className:"h-[51px] mt-1",children:a.jsx(dN,{description:B,showDetails:()=>x(!0)})}),ke(),(i||r)&&a.jsx(rr,{className:"w-full !text-[var(--pt-button-text)] !bg-[var(--pt-button-bg)] mt-3",onClick:$e,disabled:u,children:be}),a.jsx(b,{className:"mt-4 mb-2",children:a.jsx(x4,{interval:t,showMoreCard:!1,priceOptions:z,entitlementPriceOptions:Z,creditAttachmentPriceOptions:J})}),a.jsx(b,{className:"px-2 mt-3",children:a.jsx(b4,{entitlements:se,credits:we,baseEntitlementsPlanName:k})})]}),a.jsx(Hr,{isOpen:w,onClose:()=>x(!1),title:C,size:"small",modalClassName:"!bg-[var(--pt-card-bg)]",bottomBorder:"border-[var(--pt-card-price-border)]",topContent:a.jsxs(b,{className:"flex justify-between items-center gap-x-2 border-b border-[var(--pt-card-price-border)] pb-4 px-4 mb-[-16px] mx-[-16px]",children:[a.jsx(vr,{variant:"h6",className:"text-[var(--pt-card-description-text)]",children:C}),a.jsx("span",{onClick:()=>x(!1),className:"cursor-pointer",style:{color:"var(--pt-card-description-text, theme(colors.grey.500))"},children:a.jsx(ge,{name:"circle-close",size:24,color:"currentColor"})})]}),bottomContent:a.jsxs(b,{className:"flex justify-end gap-x-2",children:[a.jsx(Ni,{onClick:()=>x(!1),className:"!text-[var(--cp-modal-footer-secondary-text)] !bg-[var(--cp-modal-footer-secondary-bg)]",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width, 1px)",borderColor:"var(--cp-modal-footer-secondary-border, theme(colors.grey.200))",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:i?"Cancel":"Close"}),i&&a.jsx(rr,{onClick:$e,className:"!text-[var(--cp-modal-footer-primary-text)] !bg-[var(--cp-modal-footer-primary-bg)]",style:{borderWidth:"var(--cp-modal-footer-primary-border-width, 0px)",borderColor:"var(--cp-modal-footer-primary-border, transparent)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:be})]}),children:a.jsx(PS,{baseEntitlementsPlanName:k,description:B,entitlements:$,priceContent:ke(!0)})})]})},fN=async({productKey:e,checkoutUsername:t,countryCode:n})=>{const{data:i}=await Fe().get("/product_catalogues/public/products",{params:{product_key:e,checkout_username:t,country_code:n}});return i},pN=({productKey:e,checkoutUsername:t,countryCode:n,enabled:i=!0})=>{const[r,o]=m.useState(null),[s,l]=m.useState(null),[u,c]=m.useState(!1),d=m.useCallback(async()=>{if(i){c(!0);try{const f=await fN({productKey:e,checkoutUsername:t,countryCode:n});o(f?.data)}catch(f){const p=f,g=p?.response?.data?.data?.error||p?.message;l(g||"Failed to load public product")}finally{c(!1)}}},[e,t,n,i]);return m.useEffect(()=>{i&&d()},[d,i]),{product:r,error:s,isLoading:u,refetch:d}};var $r=(e=>(e.PLAN="plan",e.ADD_ON="add_on",e.SINGLE_PURCHASE="single_purchase",e))($r||{}),$4=(e=>(e.STRICT_AUTO_DETECT="strict_auto_detect",e.SMART_PRE_FILL="smart_pre_fill",e))($4||{});const mN=async e=>{const{data:t}=await Fe().get(`/product_catalogues/public/localization-settings?checkout_username=${e}`);return t},hN=e=>{const[t,n]=m.useState(null),[i,r]=m.useState(!0);return m.useEffect(()=>{(async()=>{try{const o=await mN(e);n(o?.data)}catch{}finally{r(!1)}})()},[e]),{settings:t,loading:i}},gN=async(e,t)=>{const{data:n}=await Fe().get(`/product_catalogues/public/products/${e}/localizations?status=active&checkout_username=${t}`);return n},vN=(e,t,n=!0)=>{const[i,r]=m.useState([]),[o,s]=m.useState(null),[l,u]=m.useState(n);return m.useEffect(()=>{if(!n){u(!1);return}e&&(async()=>{try{const c=(await gN(e,t))?.data;r(c?.localizations||[]),s(c?.tenant_country||null)}catch{}finally{u(!1)}})()},[e,t,n]),{localizations:i,tenantCountry:o,loading:l}},bN=(e=!0)=>{const[t,n]=m.useState(void 0),[i,r]=m.useState(!0),[o,s]=m.useState(null);return m.useEffect(()=>{if(!e){r(!1);return}r(!0),(async()=>{try{const l="https://api.bigdatacloud.net/data/reverse-geocode-client",u=(await F1.get(l)).data;u&&n({code:u.countryCode,name:u.countryName})}catch(l){s(l)}finally{r(!1)}})()},[e]),{country:t,loading:i,error:o}},_a="GLOBAL",Hd=(e,t)=>{const[n,i]=m.useState(void 0),[r,o]=m.useState(""),{settings:s,loading:l}=hN(t),u=s?.selection===$4.SMART_PRE_FILL,{localizations:c=[],loading:d}=vN(e,t,u),f=m.useMemo(()=>new Set(c.map($=>$.country_code)),[c]),{country:p,loading:g,error:h}=bN(u),v=m.useMemo(()=>{const $=c?.map(k=>({country_code:k.country_code,currency_code:k.currency_code}))??[];return[{country_code:_a,currency_code:r},...$]},[c,r]),y=m.useMemo(()=>v.map($=>$.country_code===_a?{label:`Global (${$.currency_code} ${xt($.currency_code)})`,value:$.country_code}:{label:`${V4($.country_code)} ${U4($.country_code)} (${xt($.currency_code)})`,value:$.country_code}),[v]),w=m.useMemo(()=>{if(!(!u||!p))return f.has(p.code)?p.code:_a},[u,p,f]),x=n??w;m.useEffect(()=>{!n&&w&&i(w)},[n,i,w]);const C=m.useMemo(()=>x===_a?void 0:x,[x]);return{selectedCountry:x,setSelectedCountry:i,setOfferingCurrency:o,allLocalizations:y,showLocalizationDropdown:u,apiCountryCode:C,isResolvingLocalization:l||!(!u||!d&&!g&&(x||h))}},yN=({selectedTab:e,setSelectedTab:t,tabOptions:n})=>a.jsx(b,{className:"w-full flex justify-center border-b border-[var(--pt-tabs-border)] mb-6",children:n.map(i=>{const r=e===i.value;return a.jsx(b,{className:`px-4 py-2 text-center cursor-pointer ${r?"border-b border-[var(--pt-tabs-indicator)]":""}
81
81
  `,onClick:()=>t(i.value),children:a.jsx(H,{variant:"label7",color:r?"text-[var(--pt-tabs-active-text)]":"text-[var(--pt-tabs-inactive-text]",children:i.label})},i.value)})}),S4=ti()(v4(e=>({singlePurchaseItems:[],setSinglePurchaseItems:t=>e({singlePurchaseItems:t})}),{name:"metrifox:cart",storage:Vd(()=>localStorage)})),xN=({value:e,onChange:t,min:n=0,max:i=1/0,step:r=1,disabled:o=!1,className:s=""})=>{const l=()=>{e>n&&t(e-r)},u=()=>{e<i&&t(e+r)},c="min-h-6 min-w-6 flex items-center justify-center rounded-lg bg-grey-200 hover:bg-grey-100 disabled:cursor-not-allowed",d=()=>{e===0&&t(1)};return a.jsxs(b,{className:`flex items-center overflow-hidden w-fit gap-x-2 ${s}`,children:[a.jsx("button",{type:"button",onClick:l,disabled:o||e<=n,className:c,"aria-label":"Decrease quantity",children:a.jsx(ge,{name:"minus",size:16,color:"metrifox-black"})}),a.jsx(Oi,{value:e.toString(),onChange:f=>/^\d*$/.test(f.target.value)?t(Number(f.target.value)):null,onBlur:d,className:"text-center [&_input]:text-center w-[102px] max-w-[102px]",size:"x-small"}),a.jsx("button",{type:"button",onClick:u,disabled:o||e>=i,className:c,"aria-label":"Increase quantity",children:a.jsx(ge,{name:"add",size:16,color:"metrifox-black"})})]})},wN=e=>{const{singlePurchaseItems:t,setSinglePurchaseItems:n}=S4(),[i,r]=m.useState(1),{price_options:o}=e,s=o[0],l=t.find(p=>p.item.version_id===e.version_id),u=()=>{const p=t.filter(g=>g.item.version_id!==e.version_id);n(p),r(1)},c=p=>{const g={item:e,priceOption:s,quantity:p||i},h=t.findIndex(v=>v.item.version_id===e.version_id);if(h>=0){const v=[...t];v[h]=g,n(v)}else n([...t,g])},d=p=>{r(p),p===0?u():l&&c(p)},f=!!l;return m.useEffect(()=>{l&&r(l.quantity)},[l]),{inCart:f,quantity:i,removeItemFromCart:u,handleQuantity:d,addItemToCart:c}},CN=({singlePurchase:e})=>{const{quantity:t,inCart:n,handleQuantity:i,addItemToCart:r,removeItemFromCart:o}=wN(e.published_version),{price_options:s,description:l,name:u,is_visible:c}=e.published_version,d=s[0],f=d?.price.currency,p=d?.price.price?.toString().split("."),g=p?p[0]:"0",h=p&&p.length>1?p[1]:"00";return c?a.jsxs(b,{className:"flex flex-col bg-[var(--pt-card-header-bg)] rounded-2xl border border-grey-100 w-full min-h-[187px]",children:[a.jsx(b,{className:"px-4 pt-2 pb-[2px]",children:a.jsx(H,{variant:"label7",className:"text-[var(--pt-card-header-text)]",children:u})}),a.jsxs(b,{className:"flex flex-col flex-grow bg-[var(--pt-card-bg)] rounded-[14px] border border-[var(--pt-card-header-bg)] w-full p-2",children:[a.jsx(b,{className:"bg-[var(--pt-card-price-bg)] border border-[var(--pt-card-price-border)] rounded-2xl p-2 mb-3 ",children:a.jsxs(b,{className:"flex items-end text-[var(--pt-card-price-amount)]",children:[a.jsxs(H,{variant:"label3",children:[xt(f),g]}),a.jsxs(H,{variant:"label6",className:"mb-[5px]",children:[".",h]})]})}),a.jsx(F,{variant:"body5",className:"mb-3 flex-1 text-[var(--pt-card-description-text)]",children:l}),a.jsxs(b,{className:"flex justify-between items-center gap-x-6",children:[a.jsx(xN,{value:t,onChange:i,className:"!w-max"}),n&&a.jsx(Kr,{className:"w-fit !text-[var(--pt-button-link)]",onClick:o,trailingIcon:"trash",children:"Remove from cart"}),!n&&a.jsx(rr,{className:"w-fit !text-[var(--pt-button-text)] !bg-[var(--pt-button-bg)]",onClick:()=>r(),children:"Add to cart"})]})]})]}):null},kN=({singlePurchases:e,checkoutUsername:t})=>{const{webAppUrl:n}=or.getState(),{singlePurchaseItems:i}=S4(),[r,o]=m.useState(""),s=!!i?.length,l=()=>{const c=window.open(`${n||Jn}/${t}/checkout`,"_blank"),d=i;let f=!1;function p(g){switch(g.data.type){case"READY":c?.postMessage({v:1,type:"INIT_CART",payload:d},"*");break;case"ACK":f=!0,window.removeEventListener("message",p);break}}window.addEventListener("message",p),setTimeout(()=>{f||(ht.error("Checkout failed to initialize. Please try again.",{position:"top-center"}),c?.close())},4e3)},u=m.useMemo(()=>{const c=r.toLowerCase();return e?.filter(d=>d.published_version.name.toLowerCase().includes(c))},[r,e]);return a.jsx(H1,{children:a.jsxs(b,{children:[a.jsx(b,{className:"flex items-center justify-between px-4 pb-4",children:a.jsx(Oi,{className:"w-[281px]",leadingContent:a.jsx(ge,{name:"search",size:16}),value:r,placeholderText:"Search",onChange:c=>o(c.target.value),trailingContent:r&&a.jsx(Uc,{icon:"circle-close-filled",size:18,color:"grey-500",className:"!px-0",onClick:()=>o("")})})}),a.jsxs(b,{className:`grid gap-4 px-4 lg:grid-cols-3 max-lg:grid-cols-2 max-sm:grid-cols-1 ${s?"pb-[72px]":""}`,children:[u?.map(c=>a.jsx(CN,{singlePurchase:c},c.id)),s&&a.jsx(b,{className:"max-w-[1089px] w-full bottom-4 max-md:bottom-0 left-1/2 -translate-x-1/2 fixed flex justify-end",children:a.jsxs(b,{className:"max-md:w-full w-full flex items-center justify-between gap-x-6 border border-[var(--pt-checkout-bar-border)] bg-[var(--pt-checkout-bar-bg)] rounded-lg py-2 px-4 max-md:rounded-none max-md:pb-4",children:[a.jsx(b,{className:"flex items-center gap-x-1",children:a.jsxs(F,{variant:"body4",className:"text-[var(--pt-checkout-bar-text)]",children:[i?.length," item",i?.length!==1?"s":""," ","in cart"]})}),a.jsx(rr,{onClick:l,className:"!bg-[var(--pt-checkout-bar-button-bg)] !text-[var(--pt-checkout-bar-button-text)]",children:"Proceed to checkout"})]})})]})]})})},_N=({checkoutUsername:e,productKey:t,plansOnly:n,singlePurchasesOnly:i,showTabHeader:r=!0,theme:o,currentPlanOfferingKey:s})=>{const{webAppUrl:l}=or.getState(),{cssVars:u}=Rd(void 0,void 0,o),{selectedCountry:c,setSelectedCountry:d,allLocalizations:f,showLocalizationDropdown:p,apiCountryCode:g,isResolvingLocalization:h,setOfferingCurrency:v}=Hd(t,e),{product:y,isLoading:w}=pN({productKey:t,checkoutUsername:e,countryCode:g,enabled:!h}),[x,C]=m.useState($r.PLAN),$=y?.plans,k=y?.single_purchases,{intervals:S,selectedInterval:P,setSelectedInterval:D}=Ud($),{featureOrderMap:B}=ul($||[]),z=n||!n&&!i,W=i||!n&&!i,J=[...z?[{label:"Plan and pricing",value:$r.PLAN}]:[],...W&&k?.length>0?[{label:"Single purchases",value:$r.SINGLE_PURCHASE}]:[]],q=T=>{C(T)},V=T=>{const M=`${l||Jn}/${e}/checkout/${T}?billing_period=${P}${p&&c?`&localization=${c}`:""}`;window.open(M,"_blank")};m.useEffect(()=>{!z&&W?C($r.SINGLE_PURCHASE):z&&!W&&C($r.PLAN)},[z,W]),m.useEffect(()=>{y?.currency_code&&v(y.currency_code)},[y,v]);const I=a.jsx(b,{className:"max-w-[1089px] mx-auto px-4",children:a.jsxs("div",{className:"animate-pulse space-y-4 py-10",children:[a.jsx("div",{className:"flex justify-center mb-10",children:a.jsx("div",{className:"h-10 w-40 bg-grey-200 rounded-lg"})}),a.jsx("div",{className:"w-full flex items-center mb-4 gap-x-4",children:[1,2,3].map(T=>a.jsx("div",{className:"h-[500px] bg-grey-200 rounded-lg flex-grow"},T))})]})});return w||h?I:a.jsx(b,{className:"flex justify-center",style:{...u,fontFamily:"var(--pt-font-family)"},children:a.jsxs(b,{className:"group w-full max-w-[1089px] bg-transparent h-full rounded-2xl md:px-6 py-5",children:[a.jsx(b,{className:"flex justify-between items-center mb-4",children:r&&a.jsx(yN,{selectedTab:x,setSelectedTab:T=>q(T),tabOptions:J})}),z&&x===$r.PLAN&&a.jsxs(a.Fragment,{children:[a.jsxs(b,{className:`flex items-center mb-4 ${p&&f.length>0?"justify-between relative":"justify-center"}`,children:[a.jsx(b,{className:p&&f.length>0?"absolute left-1/2 transform -translate-x-1/2":"",children:a.jsx(Fd,{selectedInterval:P,intervals:S,setSelectedInterval:D})}),p&&f.length>0&&a.jsx(zd,{value:c||"",onChange:d,options:f,disabled:h,placeholderText:"Select Country"})]}),a.jsx(b,{className:"flex gap-x-2 overflow-x-auto whitespace-nowrap px-6 py-4 -mx-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-track]:bg-grey-100 [&::-webkit-scrollbar-thumb]:bg-grey-300 [&::-webkit-scrollbar-thumb]:rounded-full",children:$?.map(T=>a.jsx(ka,{plan:T?.published_version,interval:P,featureOrderMap:B,buttonAction:()=>V(T.offering_key),isPricePage:!0,isCurrentPlan:s!=null&&T.offering_key===s},T.id))})]}),W&&x===$r.SINGLE_PURCHASE&&a.jsx(kN,{singlePurchases:k,checkoutUsername:e})]})})},jN=async({product_key:e,customer_key:t,country_code:n})=>{const{data:i}=await Fe().get("/sdk/product_catalogues/products/published-plans",{params:{...e&&{product_key:e},...t&&{customer_key:t},...n&&{country_code:n}}});return i},N4=({product_key:e,customer_key:t,country_code:n})=>{const[i,r]=m.useState(null),[o,s]=m.useState(!1),l=m.useCallback(async()=>{s(!0);try{const u=await jN({...e&&{product_key:e},...t&&{customer_key:t},...n&&{country_code:n}});r(u?.data)}catch(u){ht.error(u instanceof Error?u.message:"Failed to load product plans")}finally{s(!1)}},[e,t,n]);return m.useEffect(()=>{l()},[l]),{productPlans:i,isLoading:o,refetch:l}},$N=({product:e,tenantDetails:t})=>{const{customerKey:n,setPlans:i}=zr(),r=e?.product_key,o=t?.tenant_checkout_username??"",s=e?.subscription&&(e.subscription.status===rt.ACTIVE||e.subscription.status===rt.IN_TRIAL),l=!s,{selectedCountry:u,setSelectedCountry:c,allLocalizations:d,showLocalizationDropdown:f,isResolvingLocalization:p,setOfferingCurrency:g,apiCountryCode:h}=Hd(r??"",o),{productPlans:v}=N4({product_key:r,customer_key:n,...!s&&h&&{country_code:h}}),y=m.useMemo(()=>{const S=v?.plans||[],P=new Map;return S.forEach(D=>{D.is_visible&&(!P.get(D.offering_key)||D.is_current_plan)&&P.set(D.offering_key,D)}),Array.from(P.values())},[v]),w=m.useMemo(()=>y?.findIndex(S=>S?.is_current_plan)??-1,[y]),{intervals:x,selectedInterval:C,setSelectedInterval:$}=Ud(y||[]),k=S=>{const P=l&&f&&u?`&localization=${u}`:"",D=S+`&billing_period=${C}${P}`;window.open(D,"_blank","noopener,noreferrer")};return m.useEffect(()=>{y&&y?.length>0&&i(y)},[y,i]),m.useEffect(()=>{e?.subscription?.currency_code&&g(e.subscription.currency_code)},[e?.subscription?.currency_code,g]),!y||y?.length===0?null:a.jsx(nr,{title:"Plan",action:null,className:"min-w-0",children:a.jsxs(b,{className:"bg-[var(--cp-section-content-bg)] border border-[var(--cp-section-content-border)] rounded-[var(--cp-section-content-radius)] mt-2 min-w-0",style:{padding:"var(--cp-section-content-padding)"},children:[x.length>0&&a.jsxs(b,{className:`flex items-center mb-2.5 ${l&&f&&d.length>0?"justify-between relative":"justify-center"}`,children:[a.jsx(b,{className:l&&f&&d.length>0?"absolute left-1/2 transform -translate-x-1/2":"",children:a.jsx(Fd,{selectedInterval:C,intervals:x,setSelectedInterval:$,isCustomerPortal:!0})}),l&&f&&d.length>0&&a.jsx(zd,{value:u||"",onChange:c,options:d,disabled:p,placeholderText:"Select Country"})]}),a.jsx(b,{className:"flex gap-x-2 overflow-x-auto whitespace-nowrap px-6 py-4 -mx-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-track]:bg-grey-100 [&::-webkit-scrollbar-thumb]:bg-grey-300 [&::-webkit-scrollbar-thumb]:rounded-full",children:y?.map((S,P)=>{const D=S?.is_current_plan,{featureOrderMap:B}=ul(y||[]),z=D?"Current plan":P>=w?"Upgrade":"Downgrade";return a.jsx(ka,{plan:S,featureOrderMap:B,interval:C,buttonText:z,buttonAction:()=>k(S?.checkout_url),isCurrentPlan:D,isCustomerPortal:!0},S.id)})})]})})},SN=()=>a.jsx(b,{className:"flex justify-center items-center gap-x-2 py-4",children:a.jsxs(b,{className:"flex items-center gap-1",children:[a.jsx(F,{variant:"body7",color:"text-metrifox-black",children:"Powered by"}),a.jsx(Df,{height:30,width:100})]})}),NN=async({subscriptionId:e})=>{const{data:t}=await Fe().get(`/sdk/subscriptions/${e}/grouped-items`);return t},EN=({subscriptionId:e})=>{const[t,n]=m.useState(null),[i,r]=m.useState(!1),o=m.useCallback(async()=>{if(!e){ht.error("Missing subscriptionId");return}r(!0);try{const s=await NN({subscriptionId:e});n(s?.data)}catch(s){ht.error(s instanceof Error?s.message:"Failed to load subscription items")}finally{r(!1)}},[e]);return m.useEffect(()=>{o()},[o]),{items:t,isLoading:i,refetch:o}},TN=async()=>{const{data:e}=await Fe().get("/sdk/subscription-settings");return e},IN=()=>{const[e,t]=m.useState(null),[n,i]=m.useState(!1),r=m.useCallback(async()=>{i(!0);try{const o=await TN();t(o?.data)}catch(o){ht.error(o instanceof Error?o.message:"Failed to load subscription items")}finally{i(!1)}},[]);return m.useEffect(()=>{r()},[r]),{settings:e,isLoading:n,refetch:r}},DN=async e=>{const{data:t}=await Fe().delete(`/sdk/subscriptions/${e}/cancel-scheduled-subscription`);return t},LN=({subscriptionId:e,isOpen:t,onClose:n,changeType:i})=>{const r=i===Rr.ADDON_REMOVE?"add-on removal":i,o="Cancel scheduled change?",s=`You are about to cancel the scheduled ${r} for this subscription. Do you want to continue?`,[l,u]=m.useState(!1),{customerRefetch:c}=zr();return a.jsx(Hr,{size:"small",title:o,isOpen:t,onClose:n,bottomContent:a.jsxs(b,{className:"flex justify-end gap-x-2",children:[a.jsx(Gr,{className:"!bg-[var(--cp-modal-footer-secondary-bg)] !text-[var(--cp-modal-footer-secondary-text)]",onClick:n,size:"x-small",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width)",borderColor:"var(--cp-modal-footer-secondary-border)",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:"Cancel"}),a.jsx(rr,{className:"!text-[var(--cp-modal-footer-primary-text)] !bg-[var(--cp-modal-footer-primary-bg)]",onClick:async()=>{u(!0);try{const d=await DN(e);ht.success(d.message),u(!1),n(),c()}catch(d){ht.error(d instanceof Error?d.message:"An error ocurred"),u(!1)}},size:"x-small",isLoading:l,disabled:l,style:{borderWidth:"var(--cp-modal-footer-primary-border-width)",borderColor:"var(--cp-modal-footer-primary-border)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:"Continue"})]}),showCloseButton:!1,className:"bg-metrifox-white",children:a.jsx(F,{variant:"body4",className:"text-[var(--cp-modal-desc-color)]",children:s})})},PN=async e=>{const{data:t}=await Fe().post("/sdk/subscriptions/schedule-cancellation",e);return t},ON=({subscriptionId:e,isOpen:t,onClose:n})=>{const[i,r]=m.useState(!1),{customerRefetch:o}=zr();return a.jsxs(Hr,{size:"small",title:"Cancel subscription?",isOpen:t,onClose:n,bottomContent:a.jsxs(b,{className:"flex justify-end gap-x-2",children:[a.jsx(Gr,{className:"!bg-[var(--cp-modal-footer-secondary-bg)] !text-[var(--cp-modal-footer-secondary-text)]",onClick:n,size:"x-small",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width)",borderColor:"var(--cp-modal-footer-secondary-border)",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:"Cancel"}),a.jsx(rr,{className:"!bg-[var(--cp-modal-footer-primary-bg)] !text-[var(--cp-modal-footer-primary-text)]",onClick:async()=>{r(!0);try{const s=await PN({id:e});ht.success(s.message),r(!1),n(),o()}catch(s){ht.error(s instanceof Error?s.message:"An error ocurred"),r(!1)}},size:"x-small",isLoading:i,disabled:i,style:{borderWidth:"var(--cp-modal-footer-primary-border-width)",borderColor:"var(--cp-modal-footer-primary-border)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:"Confirm"})]}),showCloseButton:!1,className:"bg-metrifox-white",children:[a.jsx(H,{variant:"label7",className:"text-[var(--cp-modal-title-color)]",children:"Are you sure you want to proceed?"}),a.jsx(F,{variant:"body4",className:"mt-5 text-[var(--cp-modal-desc-color)]",children:"This subscription is scheduled to be canceled at the end of the billing cycle"})]})},AN=async e=>{const{data:t}=await Fe().post("/sdk/subscriptions/revert-cancellation",e);return t},zN=({subscriptionId:e,isOpen:t,onClose:n})=>{const[i,r]=m.useState(!1),{customerRefetch:o}=zr();return a.jsxs(Hr,{size:"small",title:"Undo cancellation?",isOpen:t,onClose:n,bottomContent:a.jsxs(b,{className:"flex justify-end gap-x-2",children:[a.jsx(Gr,{className:"!bg-[var(--cp-modal-footer-secondary-bg)] !text-[var(--cp-modal-footer-secondary-text)]",onClick:n,size:"x-small",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width)",borderColor:"var(--cp-modal-footer-secondary-border)",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:"Cancel"}),a.jsx(rr,{className:"!text-[var(--cp-modal-footer-primary-text)] !bg-[var(--cp-modal-footer-primary-bg)]",onClick:async()=>{r(!0);try{const s=await AN({id:e});ht.success(s.message),r(!1),n(),o()}catch(s){ht.error(s instanceof Error?s.message:"An error ocurred"),r(!1)}},size:"x-small",isLoading:i,disabled:i,style:{borderWidth:"var(--cp-modal-footer-primary-border-width)",borderColor:"var(--cp-modal-footer-primary-border)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:"Next"})]}),showCloseButton:!1,className:"bg-metrifox-white",children:[a.jsx(F,{variant:"body4",className:"text-[var(--cp-modal-desc-color)]",children:"Keep subscription active?"}),a.jsx(F,{variant:"body4",className:"mt-5 text-[var(--cp-modal-desc-color)]",children:"The subscription would keep going and renew as usual."})]})},MN={"bottom-end":"right-0 top-full mt-1","bottom-start":"left-0 top-full mt-1","top-end":"right-0 bottom-full mb-1","top-start":"left-0 bottom-full mb-1"},RN=({trigger:e,children:t,position:n="bottom-end",disabled:i=!1,triggerClassName:r="",panelClassName:o="",className:s=""})=>{const[l,u]=m.useState(!1),c=m.useRef(null);Jh(c,()=>u(!1));const d=()=>u(!1),f=()=>!i&&u(g=>!g),p={onClick:()=>f(),"aria-haspopup":!0,"aria-expanded":l,"aria-disabled":i,className:r};return a.jsxs("div",{className:`relative inline-block ${s}`,ref:c,children:[e(p),l&&a.jsx("div",{className:`absolute z-[100] overflow-hidden ${MN[n]} ${o}`,role:"menu",children:typeof t=="function"?t(d):t})]})},FN="inline-flex items-center justify-center text-[var(--cp-popover-trigger-icon-color)] hover:opacity-80 !bg-transparent !border-0 cursor-pointer p-1 outline-none",UN="min-w-[10rem] py-1 rounded-[var(--cp-popover-menu-radius)] bg-[var(--cp-popover-menu-bg)] border border-[var(--cp-popover-menu-border)] shadow-lg",VN="block w-full text-left p-[var(--cp-popover-menu-item-padding)] text-[var(--cp-popover-menu-item-text)] hover:bg-[var(--cp-popover-menu-item-hover-bg)] transition-colors cursor-pointer border-0 border-b border-b-[var(--cp-popover-menu-divider)] last:border-b-0 bg-transparent",ZN=({actions:e,disabled:t=!1})=>e.length===0?null:a.jsx(RN,{position:"bottom-end",disabled:t,triggerClassName:FN,panelClassName:UN,trigger:n=>a.jsx(Uc,{...n,icon:"more",size:24,color:"currentColor","aria-label":"Subscription actions"}),children:n=>a.jsx(b,{className:"flex flex-col",children:e.map((i,r)=>a.jsx("button",{type:"button",className:`${VN} ${i.danger?"!text-[var(--cp-popover-menu-item-danger-text)]":""}`,onClick:()=>{i.onClick(),n()},children:a.jsx(F,{variant:"body6",as:"span",children:i.label})},r))})}),BN=({subscriptionLineItems:e,handleUpdateQuantity:t,canUpdateQuantities:n,subscription:i,tenantDetails:r})=>{const{webAppUrl:o}=or.getState(),s=()=>{const c=r?.tenant_checkout_username,d=i?.offering_key,f=i?.id;if(!c||!d||!f)return;const p=`${o||Jn}/${c}/${d}/addons?subscription=${f}&manage=addon_add`;window.open(p,"_blank","noopener,noreferrer")},l=e.filter(c=>c.offering_type===ll.PLAN),u=e.filter(c=>c.offering_type===ll.ADDON);return a.jsxs(b,{className:"mt-8",children:[a.jsxs(b,{className:"flex items-center justify-between mb-4",children:[a.jsx(vr,{variant:"h5",className:"text-[var(--cp-section-header-color)]",style:{fontSize:"var(--cp-section-header-size)",fontWeight:"var(--cp-section-header-weight)"},children:"Subscription items"}),n&&a.jsx(Kr,{className:"!text-[var(--cp-link-color,#3b82f6)] underline !p-0 font-medium",onClick:c=>{c?.stopPropagation(),t()},children:"Manage item quantities"})]}),a.jsxs(b,{"data-testid":"subscription-items-container",className:"rounded-[var(--cp-section-content-radius)] overflow-hidden bg-[var(--cp-section-content-bg,var(--color-gray-50))] border border-[var(--cp-section-content-border,var(--color-gray-200))]",style:{padding:"var(--cp-section-content-padding)"},children:[l.length>0&&l.map(c=>a.jsxs(b,{children:[a.jsx(b,{className:"mb-3 mt-4",children:a.jsx(H,{variant:"label8",className:"text-[var(--cp-section-label-color)]",style:{fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:"Plan"})}),a.jsx(b,{className:"space-y-2",children:c?.items?.map(d=>a.jsx(E4,{item:d},d.id))})]},c?.offering_key)),u.length>0&&a.jsxs(b,{className:"mt-4",children:[a.jsxs(b,{className:"relative z-[100] flex items-center justify-between mb-3 mt-4",children:[a.jsx(H,{variant:"label8",className:"text-[var(--cp-section-label-color)]",style:{fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:"Add-ons"}),a.jsx(Ni,{size:"small",onClick:s,className:"!bg-[var(--cp-btn-secondary-bg)] !text-[var(--cp-btn-secondary-text)] !border-[var(--cp-btn-secondary-border)] !rounded-[var(--cp-btn-secondary-radius)] !px-5 !py-2",style:{fontSize:"var(--cp-btn-secondary-size)",fontWeight:"var(--cp-btn-secondary-weight)",borderWidth:"var(--cp-btn-secondary-border-width, 1px)",borderStyle:"solid"},children:" Manage add-on"})]}),a.jsx(b,{className:"space-y-2",children:u.map((c,d)=>a.jsx(WN,{item:c},d))})]})]})]})},E4=({item:e,isChild:t})=>{const n=t?"bg-[var(--cp-subscription-child-bg,white)]":"bg-[var(--cp-subscription-item-bg,white)]",i=t?"border-[var(--cp-subscription-child-border,var(--color-gray-200))]":"border-[var(--cp-subscription-item-border,var(--color-gray-200))]",r=t?"text-[var(--cp-subscription-child-text)]":"text-[var(--cp-subscription-item-text)]",o=t?"text-[var(--cp-subscription-child-quantity,var(--color-gray-500,#6b7280))]":"text-[var(--cp-subscription-item-quantity,var(--color-gray-500,#6b7280))]";return a.jsxs(b,{className:`${n} border ${i} rounded-[var(--cp-section-content-radius)] px-4 py-3 flex items-center justify-between`,children:[a.jsxs(b,{className:"flex items-center gap-2",children:[a.jsx(H,{variant:"label7",className:`${r}`,style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 600)"},children:Rt(e?.name)}),e?.quantity>0&&e?.source_type!==Zo.PLAN&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`${o} opacity-75`,children:"\u2022"}),a.jsxs(F,{variant:"body6",className:`${o} font-normal`,children:[e.quantity," ",e.name?.toLowerCase()]})]})]}),a.jsxs(F,{variant:"body6",className:`${r}`,style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 500)"},children:[xt(e?.currency_code),_e(e?.total_amount)]})]})},WN=({item:e})=>{const[t,n]=m.useState(!1),i=e?.items?.filter(o=>o?.source_type===Zo.ADDON)?.[0],r=e?.items?.filter(o=>o?.source_type!==Zo.ADDON);return a.jsxs(b,{className:"bg-[var(--cp-subscription-item-bg,white)] border border-[var(--cp-subscription-item-border,var(--color-gray-200))] rounded-[var(--cp-section-content-radius)] px-4 py-3",children:[a.jsxs(b,{className:"flex justify-between items-center gap-2 w-full cursor-pointer",onClick:()=>{r&&r?.length>0&&n(!t)},children:[a.jsx(H,{variant:"label7",className:"text-[var(--cp-subscription-item-text)]",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 600)"},children:Rt(e?.name)}),a.jsxs(b,{className:"flex justify-end items-center",children:[i&&a.jsxs(F,{variant:"body6",className:"text-[var(--cp-subscription-item-text)]",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 500)"},children:[xt(i?.currency_code),_e(i?.total_amount)]}),r&&r?.length>0&&a.jsx(ge,{name:"arrow-down",size:14})]})]}),t&&a.jsx(b,{className:"bg-[var(--cp-section-content-bg,var(--color-gray-50))] space-y-2 p-4 mt-3",children:r.map(o=>a.jsx(E4,{item:o,isChild:!0},o.id))})]})},HN=({subscription:e,tenantDetails:t})=>{const n=e?.status,{text:i}=X7(n),{customerKey:r}=zr(),[o,s]=m.useState(!1),[l,u]=m.useState(!1),[c,d]=m.useState(!1),[f,p]=m.useState(!1),g=m.useRef(null),{invoiceDetails:h}=Nc({invoiceId:e?.upcoming_invoice?.invoice_id||""}),{items:v}=EN({subscriptionId:e?.id}),{settings:y}=IN(),w=[{label:"Current plan",value:e?.plan_name||"-"},{label:"Status",value:i},{label:"Start date",value:at(e?.starts_at)},...n===rt.ACTIVE?[{label:"Current billing period",value:e?.current_billing_period_start&&e?.current_billing_period_end?a.jsxs(b,{children:[a.jsxs(b,{className:"font-medium",children:[at(e.current_billing_period_start)," -"," ",at(e.current_billing_period_end)]}),a.jsx(b,{className:"mt-1 text-sm opacity-80",children:"(Auto-renew)"})]}):"-"}]:[],...n===rt.IN_TRIAL?[{label:"Trial end date",value:at(e?.trial_end_date)},{label:"Trial period",value:e?.starts_at&&e?.trial_end_date?a.jsx(b,{children:a.jsxs(b,{children:[at(e?.starts_at)," -"," ",at(e?.trial_end_date)]})}):"-"}]:[],...n===rt.ACTIVE?[{label:"End date",value:e?.ends_at?at(e?.ends_at):"-"}]:[]],x=[...n===rt.ACTIVE?[{label:"Next billing date",value:e?.renews_at?at(e?.renews_at):"-"},{label:"Invoice due",value:e?.renews_at?at(e?.renews_at):"-"},{label:"Next estimated bill",value:e?.next_billing_amount?a.jsxs(b,{className:"mt-2",children:[a.jsxs(b,{className:"font-medium",children:[xt(e.currency_code),e.next_billing_amount]}),a.jsx(b,{className:"text-sm opacity-80 mt-0.5 block",children:"(Monthly)"})]}):"-"}]:[]],C=()=>{const z=`${window.location.origin}/${t.tenant_checkout_username}/${e.offering_key}/subscriptions/${e.id}?customer=${r}`;window.open(z,"_blank","noopener,noreferrer")},$=n===rt.ACTIVE||n===rt.IN_TRIAL,k=!!e?.scheduled_change,S=e?.scheduled_change,P=[{label:"Manage",onClick:()=>{document.getElementById(T4.plan)?.scrollIntoView({behavior:"smooth"})}},...$?k?[{label:`Cancel ${S===Rr.ADDON_REMOVE?"add-on removal":S}`,onClick:()=>p(!0)}]:e?.ends_at?[{label:"Undo cancellation",onClick:()=>d(!0)}]:y?.customer_can_cancel?[{label:"Cancel subscription",onClick:()=>u(!0),danger:!0}]:[]:[]],D=()=>S===Rr.UPGRADE?`This subscription is scheduled to be upgraded on ${at(e.renews_at)}`:S===Rr.DOWNGRADE?`This subscription is scheduled to be downgraded on ${at(e.renews_at)}`:S===Rr.ADDON_REMOVE?`An add-on removal is scheduled to occur on ${at(e.renews_at)}`:`This subscription is scheduled to be canceled at the end of the billing cycle on ${at(e.ends_at)}`,B=k&&e?.renews_at||e?.ends_at&&!k;return a.jsxs(a.Fragment,{children:[B&&e.status!==rt.DEACTIVATED&&a.jsxs(b,{className:"py-3 px-4 flex items-center justify-between",style:{backgroundColor:"var(--cp-info-banner-bg)",borderRadius:"var(--cp-info-banner-radius)"},children:[a.jsx(H,{variant:"label8",className:"flex-1 text-center text-[var(--cp-info-banner-text)]",children:D()}),!k&&a.jsx(Gr,{onClick:()=>d(!0),className:"!border-[var(--cp-info-banner-btn-border)] !text-[var(--cp-info-banner-btn-text)]",children:"Undo cancellation"}),k&&a.jsxs(Gr,{onClick:()=>p(!0),className:"!border-[var(--cp-info-banner-btn-border)] !text-[var(--cp-info-banner-btn-text)]",children:["Cancel"," ",S===Rr.ADDON_REMOVE?"add-on removal":S]})]}),a.jsxs(nr,{title:"Subscription",action:P.length>0?a.jsx(ZN,{actions:P}):null,children:[a.jsx(b,{"data-testid":"subscription-content-box",className:"bg-[var(--cp-section-content-bg,var(--color-gray-50))] border border-[var(--cp-section-content-border,var(--color-gray-200))] rounded-[var(--cp-section-content-radius)]",style:{padding:"var(--cp-section-content-padding)"},children:a.jsx(b,{className:"flex justify-between flex-wrap gap-6",children:w.map((z,W)=>a.jsxs(b,{children:[a.jsx(H,{variant:"label8",className:"text-[var(--cp-section-label-color)]",style:{fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:z?.label}),a.jsx(b,{className:"text-[var(--cp-section-value-color)] mt-2",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)"},children:z.value})]},W))})}),e?.upcoming_invoice&&a.jsx(b,{className:"flex justify-end mt-2",children:a.jsx(Kr,{className:"!text-[var(--cp-link-color,#3b82f6)] underline !p-0 text-sm",onClick:()=>s(!0),children:"Preview invoice"})}),x.length>0&&a.jsx(b,{"data-testid":"subscription-content-box",className:"bg-[var(--cp-section-content-bg,var(--color-gray-50))] border border-[var(--cp-section-content-border,var(--color-gray-200))] rounded-[var(--cp-section-content-radius)] mt-2",style:{padding:"var(--cp-section-content-padding)"},children:a.jsx(b,{className:"flex justify-between flex-wrap gap-6",children:x.map((z,W)=>a.jsxs(b,{children:[a.jsx(H,{variant:"label8",className:"text-[var(--cp-section-label-color)]",style:{fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:z?.label}),a.jsx(b,{className:"text-[var(--cp-section-value-color)] mt-2",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)"},children:z.value})]},W))})}),e?.subscription_items?.length>0&&a.jsx(BN,{subscriptionLineItems:v??[],handleUpdateQuantity:C,canUpdateQuantities:e?.can_update_quantities,subscription:e,tenantDetails:t}),o&&a.jsx(Sc,{isOpen:o,onClose:()=>s(!1),contentRef:g,content:a.jsx(dl,{data:h}),modalTitle:"Invoice preview"}),a.jsx(ON,{subscriptionId:e.id,isOpen:l,onClose:()=>u(!1)}),a.jsx(zN,{subscriptionId:e.id,isOpen:c,onClose:()=>d(!1)}),a.jsx(LN,{subscriptionId:e.id,isOpen:f,onClose:()=>p(!1),changeType:e?.scheduled_change})]})]})},KN=({upcomingInvoice:e})=>{const[t,n]=m.useState(!1),i=m.useRef(null),{invoiceDetails:r}=Nc({invoiceId:e?.invoice_id});return a.jsxs(nr,{title:"Upcoming Invoice",children:[a.jsx(b,{className:"bg-[var(--cp-section-content-bg)] border border-[var(--cp-section-content-border)] rounded-[var(--cp-section-content-radius)]",style:{padding:"var(--cp-section-content-padding)"},children:a.jsxs(b,{className:"w-full flex items-center justify-between mb-0",children:[a.jsxs(b,{className:"flex items-center gap-3",children:[a.jsx(H,{variant:"label7",className:"text-[var(--cp-section-value-color)]",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 500)"},children:"Upcoming Invoice"}),a.jsx(b,{className:"flex items-center gap-2",children:a.jsx(An,{background:"bg-purple-500",size:"small",children:a.jsxs(H,{variant:"label8",className:"text-metrifox-white",children:[e?.currency?.symbol,e?.amount]})})}),a.jsxs(F,{variant:"body6",className:"text-[var(--cp-section-value-color)]",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 400)"},children:["Due"," ",new Date(e?.due_date).toLocaleString(e?.currency?.country_code,{month:"short",day:"numeric",year:"numeric"})]})]}),a.jsx(Kr,{className:"!text-[var(--cp-link-color)] underline cursor-pointer",onClick:()=>{n(!0)},children:"Preview invoice"})]})}),t&&a.jsx(Sc,{isOpen:t,onClose:()=>n(!1),contentRef:i,content:a.jsx(dl,{data:r}),modalTitle:"Invoice preview"})]})},GN=[{key:"subscription"},{key:"creditBalance"},{key:"entitlementUsage"},{key:"paymentOverview"},{key:"billingHistory"},{key:"plan"}],T4={upcomingInvoice:"upcoming-invoice",subscription:"subscription",creditBalance:"credit-balance",entitlementUsage:"entitlement-usage",paymentOverview:"payment-overview",billingHistory:"billing-history",plan:"plan"},I4=({product:e,tenantDetails:t,sectionsConfig:n,customerWallets:i})=>{const r=n||GN,o={upcomingInvoice:()=>e?.subscription?.upcoming_invoice?a.jsx(KN,{upcomingInvoice:e.subscription.upcoming_invoice}):null,subscription:()=>e?.subscription?a.jsx(HN,{subscription:e.subscription,tenantDetails:t}):null,creditBalance:()=>i&&i.length>0?a.jsx(gS,{tenantDetails:t,wallets:i}):null,entitlementUsage:()=>e?.subscription?a.jsx(kS,{subscriptionId:e?.subscription?.id}):null,paymentOverview:()=>a.jsx(_S,{paymentMethod:e.payment_method,tenantDetails:t}),billingHistory:()=>e?.subscription?.id?a.jsx(ek,{subscriptionId:e.subscription?.id}):null,plan:()=>e?.product_key?a.jsx($N,{product:e,tenantDetails:t}):null};return a.jsxs(b,{className:"space-y-6 w-full min-w-0",children:[r.filter(s=>!s.hidden).map(s=>{const l=T4[s.key]??s.key;if(s.component)return a.jsx("section",{id:l,className:"w-full",children:a.jsx(s.component,{product:e,tenantDetails:t,...s.props})},s.key);const u=o[s.key],c=u?u(s.props):null;return c?a.jsx("section",{id:l,className:"w-full",children:c},s.key):null}),a.jsx(SN,{})," "]})},Kd=({children:e,className:t="",style:n})=>a.jsx(b,{"data-testid":"portal-container",className:`min-h-screen w-full flex justify-center bg-[var(--cp-section-bg,var(--color-background-50))] ${t}`,style:n,children:a.jsx("div",{className:"w-full max-w-[60rem] min-w-0 space-y-8 flex flex-col items-center",style:{padding:"var(--cp-container-padding, 40px 24px)"},children:e})}),JN=({checkoutUsername:e})=>{const{webAppUrl:t}=or.getState(),{customerKey:n}=zr(),[i,r]=m.useState(""),{selectedCountry:o,setSelectedCountry:s,allLocalizations:l,showLocalizationDropdown:u,isResolvingLocalization:c,setOfferingCurrency:d,apiCountryCode:f}=Hd(i,e),{productPlans:p,isLoading:g}=N4({customer_key:n,...i&&f&&{country_code:f}}),h=p?.plans||[],{intervals:v,selectedInterval:y,setSelectedInterval:w}=Ud(h),{featureOrderMap:x}=ul(h||[]),C=!!(i&&u&&l.length>0);m.useEffect(()=>{const k=p?.plans||[];if(k.length>0){const S=k[0],P=S?.product_currency_code,D=S?.product_key;D&&r(D),P&&d(P)}},[p,d]);const $=k=>{const S=C&&o?`&localization=${o}`:"",P=`${t||Jn}/${e}/checkout/${k}?billing_period=${y}&customer=${n}${S}`;window.open(P,"_blank")};return g||i&&c?a.jsx(nr,{title:a.jsxs(b,{className:"flex items-center gap-2",children:[a.jsx(b,{className:"p-1.5 bg-[var(--cp-section-icon-bg)] rounded-lg",children:a.jsx(ge,{name:"subtitle",size:18,color:"var(--cp-section-icon-color)"})}),a.jsx("span",{children:"Plan"})]}),children:a.jsx(b,{className:"flex items-center justify-center py-12",children:a.jsx(hr,{size:"big"})})}):a.jsx(nr,{title:a.jsxs(b,{className:"flex items-center gap-2",children:[a.jsx(b,{className:"p-1.5 bg-[var(--cp-section-icon-bg)] rounded-lg",children:a.jsx(ge,{name:"subtitle",size:18,color:"var(--cp-section-icon-color)"})}),a.jsx("span",{children:"Plan"})]}),children:a.jsxs(b,{className:"bg-[var(--cp-section-content-bg)] border border-[var(--cp-section-content-border)] rounded-[var(--cp-section-content-radius)] mt-2 min-w-0",style:{padding:"var(--cp-section-content-padding)"},children:[a.jsxs(b,{className:`flex items-center mb-2.5 ${C?"justify-between relative":"justify-center"}`,children:[a.jsx(b,{className:C?"absolute left-1/2 transform -translate-x-1/2":"",children:a.jsx(Fd,{selectedInterval:y,intervals:v,setSelectedInterval:w,isCustomerPortal:!0,isPricePage:!0})}),C&&a.jsx(zd,{value:o||"",onChange:s,options:l,disabled:c,placeholderText:"Select Country"})]}),a.jsx(b,{className:"flex gap-x-2 overflow-x-auto whitespace-nowrap px-6 py-4 -mx-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-track]:bg-grey-100 [&::-webkit-scrollbar-thumb]:bg-grey-300 [&::-webkit-scrollbar-thumb]:rounded-full",children:h?.map(k=>a.jsx(ka,{plan:k,interval:y,featureOrderMap:x,buttonAction:()=>$(k.offering_key),isCustomerPortal:!0,isPricePage:!0},k.id))})]})})},qN=()=>a.jsx(nr,{title:a.jsxs(b,{className:"flex items-center gap-2",children:[a.jsx(b,{className:"p-1.5 bg-[var(--cp-section-icon-bg)] rounded-lg",children:a.jsx(ge,{name:"money",size:18,color:"var(--cp-section-icon-color)"})}),a.jsx("span",{children:"Subscription"})]}),children:a.jsxs(b,{className:"flex flex-col items-center justify-center py-6 px-4",children:[a.jsx(ge,{name:"subtitle",size:40,color:"grey-400"}),a.jsx(F,{variant:"body7",className:"text-[var(--cp-section-empty-text)] mt-2 text-center",children:"You currently have no active subscriptions."})]})}),YN=({customerKey:e,sectionsConfig:t,theme:n})=>{const[i,r]=m.useState(0),{setCustomerKey:o,setCustomerRefetch:s}=zr(),{cssVars:l}=kf(n),{customerDetails:u,error:c,refetch:d,isLoading:f}=y7({customerKey:e}),{customerWallets:p}=V7({customerKey:e});if(m.useEffect(()=>{o(e),s(d)},[e,d,o,s]),c)return a.jsx(Kd,{style:{...l,backgroundColor:"var(--cp-bg)",borderRadius:"var(--cp-radius)",fontFamily:"var(--cp-font-family)"},children:a.jsx(b,{className:"max-w-[60rem] mx-auto py-6 px-4",children:a.jsxs("div",{className:"bg-red-50 p-4 rounded-lg text-red-700",children:["Error loading customer details: ",c]})})});if(f||!u)return a.jsx(Kd,{style:{...l,backgroundColor:"var(--cp-bg)",borderRadius:"var(--cp-radius)",fontFamily:"var(--cp-font-family)"},children:a.jsx(b,{className:"min-h-[200px] flex flex-col items-center justify-center gap-4 py-12 px-4",role:"status","aria-live":"polite",children:a.jsx(hr,{size:"big",color:"white"})})});const{subscriptions:g,...h}=u||{},v=g||[];return a.jsx(H1,{children:a.jsxs(Kd,{style:{...l,backgroundColor:"var(--cp-bg)",borderRadius:"var(--cp-radius)",fontFamily:"var(--cp-font-family)"},children:[v.length===0&&a.jsxs(a.Fragment,{children:[a.jsx(qN,{}),a.jsx(JN,{checkoutUsername:h?.tenant_checkout_username})]}),v&&v.length>1?a.jsxs(vn,{className:"w-full min-w-0 flex flex-col items-center",defaultIndex:i,onChange:y=>r(y),children:[a.jsx(bn,{className:"inline-flex items-center gap-1 bg-[var(--cp-tabs-bg)] border border-[var(--cp-tabs-border)] p-1 rounded-lg mb-8 shadow-sm",children:v.map(y=>a.jsx(Ar,{className:`px-6 py-2 rounded-md text-sm font-medium transition-all outline-none
82
82
  text-[var(--cp-tabs-inactive-text)] hover:text-gray-900 bg-transparent
83
83
  data-[selected]:bg-[var(--cp-tabs-active-bg)]
package/dist/index.js CHANGED
@@ -77,7 +77,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
77
77
  data-[selected]:bg-[var(--cp-tabs-active-bg)]
78
78
  data-[selected]:text-[var(--cp-tabs-active-text)]
79
79
  data-[selected]:shadow-sm`,children:"Usage"})]}),g(qo,{className:"w-full",children:[l(Tn,{children:l(jN,{entitlements:n})}),i.length>0&&l(Tn,{children:l(RN,{meteredEntitlements:i})})]})]})})})},VN=({tenantDetails:e,paymentMethod:t})=>{const{address:n}=p1(e?.billing_address),i=[{label:"Billed to",value:e?.full_name||"-"},{label:"Billing email",value:e?.billing_email||"-"},{label:"Billing address",value:n||"-"}];return l(dr,{title:"Payment",children:l(b,{className:"bg-[var(--cp-section-content-bg)] border border-[var(--cp-section-content-border)] rounded-[var(--cp-section-content-radius)]",style:{padding:"var(--cp-section-content-padding)"},children:g(b,{className:"grid grid-cols-4 gap-8 justify-between",children:[i?.map((r,o)=>g(b,{children:[l("div",{className:"mb-1",style:{color:"var(--cp-section-label-color)",fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:r?.label}),l("div",{style:{color:"var(--cp-section-value-color)",fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)",marginTop:"8px"},children:r?.value||"-"})]},o)),g(b,{children:[l("div",{className:"mb-2",style:{color:"var(--cp-section-label-color)",fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:"Payment method"}),t?g(b,{className:"flex items-center gap-x-2 mt-2",children:[l(b,{className:"bg-[#1a1f71] rounded px-1.5 py-0.5 text-white font-bold text-[10px]",children:"VISA"}),g("div",{className:"flex items-center",style:{color:"var(--cp-section-value-color)",fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)"},children:["**** ",t?.display_name," ",g("span",{className:"ml-2",style:{color:"var(--cp-section-label-color)",fontSize:"var(--cp-section-label-size)",fontWeight:"normal"},children:["Expires ",String(t?.exp_month).padStart(2,"0"),"/",String(t?.exp_year).slice(-2)]})]})]}):l("div",{style:{color:"var(--cp-section-value-color)",fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)"},children:"-"})]})]})})})},ZN="!bg-[var(--select-bg)] !border-[var(--select-border)] text-[var(--select-text)] placeholder-[var(--select-placeholder)]",BN="!bg-[var(--select-dropdown-bg)] !border-[var(--select-dropdown-border)] [&_.text-base-default-600]:!text-[var(--select-option-text)] [&_li:hover]:!bg-[var(--select-option-hover-bg)]",Jd=({value:e,onChange:t,options:n,disabled:i=!1,placeholderText:r="Select Country",className:o="ml-auto w-[15rem]"})=>l(b,{className:o,children:l(tu,{value:e,onChange:t,options:n,disabled:i,placeholderText:r,containerClassName:ZN,optionsContainerClassName:BN})}),qd={plans:{currentPlanCard:{header:{background:z("grey-200")||"#e5e7eb",textColor:z("grey-900")||"#111827"},gradientColor:z("grey-200")||"#e5e7eb"},planCards:{background:z("metrifox-white")||"#ffffff",border:{color:z("grey-200")||"#e5e7eb",width:"1px",radius:"8px"},header:{background:z("grey-200")||"#e5e7eb",textColor:z("grey-900")||"#111827"},description:{textColor:z("grey-500")||"#6b7280",textButtonColor:z("blue-600")||"#2563eb"},price:{amountColor:z("grey-900")||"#111827",primaryTextColor:z("grey-500")||"#6b7280",secondaryTextColor:z("grey-400")||"#9ca3af",background:"transparent",borderColor:"transparent"}},planFeatures:{textColor:z("grey-700")||"#374151",iconColor:z("metrifox-green")||"#0BB02F"},planButton:{background:z("metrifox-primary")||"#3D3D3D",textColor:z("metrifox-white")||"#ffffff",secondaryBackground:z("background-system-secondary")||"#E4E4E7",secondaryTextColor:z("metrifox-black")||"#3F3F46",textButtonColor:z("blue-600")||"#2563eb"},planToggle:{background:z("grey-200")||"#e5e7eb",activeBackground:z("grey-800")||"#1f2937",activeText:z("metrifox-white")||"#ffffff",inactiveText:z("grey-500")||"#6b7280"},planTags:{freeTrialBackground:z("blue-100")||"#dbeafe",freeTrialText:z("blue-800")||"#1e40af"}},tabs:{inactiveText:z("grey-400")||"#9ca3af",activeText:z("blue-600")||"#2563eb",indicator:z("blue-600")||"#2563eb",borderColor:z("grey-400")||"#9ca3af"},select:{background:z("background-system-primary")||"#ffffff",borderColor:z("grey-300")||"#d1d5db",textColor:z("neutral-800")||"#262626",caretColor:z("grey-500")||"#6b7280",dropdownBackground:z("metrifox-white")||"#ffffff",dropdownBorderColor:z("grey-300")||"#d1d5db",optionTextColor:z("base-default-600")||"#4b5563",optionHoverBackground:z("grey-100")||"#f3f4f6"},checkoutBar:{background:z("grey-50")||"#f9fafb",borderColor:z("grey-200")||"#e5e7eb",textColor:z("metrifox-black")||"#3F3F46",buttonBackground:z("blue-600")||"#2563eb",buttonTextColor:z("metrifox-white")||"#ffffff"}},Yd=(e,t,n)=>{const{theme:i}=pr(),r=i?.pricingTable,o=i?.customerPortal?.plans,a=!m1(o),s=qd.plans,u=t&&a?{plans:{currentPlanCard:o?.currentPlanCard!=null?lr.all([s?.currentPlanCard??{},o.currentPlanCard]):s?.currentPlanCard,planCards:o?.planCards!=null?lr.all([s?.planCards??{},o.planCards]):s?.planCards,planFeatures:o?.planFeatures!=null?lr.all([s?.planFeatures??{},o.planFeatures]):s?.planFeatures,planButton:o?.planButton!=null?lr.all([s?.planButton??{},o.planButton]):s?.planButton,planToggle:o?.planToggle!=null?lr.all([s?.planToggle??{},o.planToggle]):s?.planToggle,planTags:o?.planTags!=null?lr.all([s?.planTags??{},o.planTags]):s?.planTags}}:r||{},c=lr.all([qd,u]),d=e?qd:n?lr.all([c,n]):c,f=X7(d),p=yl(d),h={...f,...p};return{theme:d,cssVars:h}},Xd=({selectedInterval:e,intervals:t,isCustomerPortal:n=!1,isPricePage:i,setSelectedInterval:r})=>{const o=!i&&!n,{cssVars:a}=Yd(o,n);return l(b,{style:n?{}:a,children:l(b,{"data-testid":"plan-tabs",className:"inline-flex items-center gap-1 bg-[var(--pt-interval-bg,var(--cp-tabs-bg))] border border-[var(--pt-interval-border,var(--cp-tabs-border,var(--cp-section-content-border)))] p-1 rounded-lg shadow-sm",children:t.map(s=>{const u=e===s;return l(b,{className:`py-1.5 px-6 rounded-md cursor-pointer transition-all flex items-center justify-center
80
- ${u?"bg-[var(--pt-interval-active-bg,var(--cp-tabs-active-bg))] shadow-sm":"bg-transparent hover:opacity-80"}`,onClick:()=>r(s),children:l(U,{variant:"body6",className:"font-medium whitespace-nowrap",color:u?"text-[var(--pt-interval-active-text,var(--cp-tabs-active-text))]":"text-[var(--pt-interval-inactive-text,var(--cp-tabs-inactive-text))]",children:Kt(s)})},s)})})})},Qd=e=>{const t=Re(()=>wy(e||[]),[e]),[n,i]=G(""),r=Re(()=>[...t.includes(Ge.DAILY)?[Ge.DAILY]:[],...t.includes(Ge.WEEKLY)?[Ge.WEEKLY]:[],...t.includes(Ge.MONTHLY)?[Ge.MONTHLY]:[],...t.includes(Ge.QUARTERLY)?[Ge.QUARTERLY]:[],...t.includes(Ge.BIANNUALLY)?[Ge.BIANNUALLY]:[],...t.includes(Ge.YEARLY)?[Ge.YEARLY]:[]],[t]);return de(()=>{!n&&r[0]&&i(r[0])},[r,n]),{intervals:r,selectedInterval:n,setSelectedInterval:i}},I4=ui(e=>({plans:[],setPlans:t=>e(n=>({plans:typeof t=="function"?t(n.plans):t}))}));function e1(e,t){let n;try{n=e()}catch{return}return{getItem:r=>{var o;const a=u=>u===null?null:JSON.parse(u,void 0),s=(o=n.getItem(r))!=null?o:null;return s instanceof Promise?s.then(a):a(s)},setItem:(r,o)=>n.setItem(r,JSON.stringify(o,void 0)),removeItem:r=>n.removeItem(r)}}const t1=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(i){return t1(i)(n)},catch(i){return this}}}catch(n){return{then(i){return this},catch(i){return t1(i)(n)}}}},WN=(e,t)=>(n,i,r)=>{let o={storage:e1(()=>localStorage),partialize:v=>v,version:0,merge:(v,y)=>({...y,...v}),...t},a=!1;const s=new Set,u=new Set;let c=o.storage;if(!c)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...v)},i,r);const d=()=>{const v=o.partialize({...i()});return c.setItem(o.name,{state:v,version:o.version})},f=r.setState;r.setState=(v,y)=>(f(v,y),d());const p=e((...v)=>(n(...v),d()),i,r);r.getInitialState=()=>p;let h;const m=()=>{var v,y;if(!c)return;a=!1,s.forEach(w=>{var k;return w((k=i())!=null?k:p)});const x=((y=o.onRehydrateStorage)==null?void 0:y.call(o,(v=i())!=null?v:p))||void 0;return t1(c.getItem.bind(c))(o.name).then(w=>{if(w)if(typeof w.version=="number"&&w.version!==o.version){if(o.migrate){const k=o.migrate(w.state,w.version);return k instanceof Promise?k.then(S=>[!0,S]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,w.state];return[!1,void 0]}).then(w=>{var k;const[S,C]=w;if(h=o.merge(C,(k=i())!=null?k:p),n(h,!0),S)return d()}).then(()=>{x?.(h,void 0),h=i(),a=!0,u.forEach(w=>w(h))}).catch(w=>{x?.(void 0,w)})};return r.persist={setOptions:v=>{o={...o,...v},v.storage&&(c=v.storage)},clearStorage:()=>{c?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>m(),hasHydrated:()=>a,onHydrate:v=>(s.add(v),()=>{s.delete(v)}),onFinishHydration:v=>(u.add(v),()=>{u.delete(v)})},o.skipHydration||m(),h||p},D4=WN,Co=ui()(D4(e=>({selections:{},setSelection:(t,n)=>e(i=>({selections:{...i.selections,[t]:n}}))}),{name:"metrifox:stairstep-selections",storage:e1(()=>localStorage)})),Ds=({selectedInterval:e,publishedOnly:t=!1})=>{const{plans:n}=I4(),[i,r]=G(40),o=Ne(d=>{if(!d)return;const f=d.published_version||d,p=d.draft_version;return t?f?.is_visible?f:void 0:f||p},[t]),a=n?.some(d=>!!o(d)?.description),s=n?.some(d=>!!o(d)?.trial_duration_value),u=n?.some(d=>{const f=o(d);return f?f.price_options?.some(p=>p.price?.billing_interval===e)||f.entitlement_price_options?.filter(p=>p.price.billing_interval===e).length===1||f.credit_attachment_price_options?.filter(p=>p.price.billing_interval===e).length===1||f.is_free||f.is_custom:!1}),c=n?.some(d=>{const f=o(d);return f?[f.credit_attachment_price_options,f.entitlement_price_options].some(p=>Array.isArray(p)&&p.some(h=>h.price?.billing_interval===e)):!1});return de(()=>{n.forEach(d=>{const f=o(d);if(!f)return;const p=[...f.credit_attachment_price_options||[],...f.entitlement_price_options||[]].filter(x=>x.price?.billing_interval===e),h=x=>{const w=x,k=w?.price?.name||w?.price?.owner?.feature?.name||w?.price?.owner?.name,{price:S,label:C,currencySymbol:N}=ra(w);return`${k} from ${N}${S}${C?`/${C}`:""}`.length>40?39:24},m=p[0]?h(p[0]):0,v=p[1]?h(p[1]):0,y=m+v;r(x=>y>x?y:x)})},[n,e,o]),{dynamicCardHeight:i,shouldShowDescription:a,shouldShowFreeTrial:s,shouldShowFixedPrice:u,shouldShowDynamicPrices:c}},L4=({entitlements:e,baseEntitlementsPlanName:t,credits:n})=>{const i=xl(e).filter(r=>r?.is_visible);return g(b,{children:[l(K,{variant:"label7",className:"text-[var(--pt-feature-text)] mb-3",as:"p",children:t?`Everything in ${t} plus:`:e.length>0?"Included:":"\xA0"}),g("ul",{className:"flex flex-col gap-y-3",children:[n?.map((r,o)=>g("li",{className:"flex items-center gap-[10px]",children:[" ",l("span",{style:{color:"var(--pt-feature-icon, theme(colors.green.600))"},className:"flex items-center",children:l(ye,{name:"check",color:"currentColor",size:16})}),g(U,{variant:"body5",className:"text-[var(--pt-feature-text)]",children:[r.included_allowance+" ",r.included_allowance===1?r.credit_unit_singular:r.credit_unit_plural]})]},o)),i?.map((r,o)=>g("li",{className:"flex items-center gap-[10px]",children:[" ",l("span",{style:{color:"var(--pt-feature-icon, theme(colors.green.600))"},className:"flex items-center",children:l(ye,{name:"check",color:"currentColor",size:16})}),l(U,{variant:"body5",className:"text-[var(--pt-feature-text)]",children:r.display_text})]},o))]})]})},HN=(e,t=[])=>{const n=Co(L=>L.selections),i=e?.price?.billing_interval,r=e?.price.tiers,o=e?.price.currency,a=e?.price?.invoice_timing,s=Tt(o),u=L=>{const W=e?.price?.owner,j=W?.included_usage||0,H=L?.find(F=>F.first_unit===j);if(!H)return{price:null,label:null};const{unit_price:Y,package_price:X,package_size:Z,pricing_model:D,flat_fee:I}=H;return I?{price:I.toFixed(2),label:""}:{per_unit:{price:Y?.toFixed(2),label:`per. ${W?.feature?.unit_singular||W?.credit_unit_singular}`},per_package:{price:X?.toFixed(2),label:`for ${Z} ${W?.feature?.unit_plural}`}}[D]??{price:null,label:null}},{price:c,label:d}=u(r),f=e?.price?.is_custom&&e?.price?.billing_interval_value>1?`every ${e?.price?.billing_interval_value} ${by[i]}`:i,p=[Ge.DAILY,Ge.WEEKLY],h={[Ge.DAILY]:"day",[Ge.WEEKLY]:"week"},m=i,v=p.includes(m)?h[m]:"month",y=Re(()=>t.reduce((L,W)=>{const j=n[W.id];return L+(j||0)},0),[t,n]),x=e?.price?.price??0,w=ta(i,e?.price?.billing_interval_value),k=x+y,S=w>1?k/w:k,C=k,N=S.toFixed(2),A=C.toFixed(2);return{amount:N,billedText:f,intervalText:v,billingAmount:A,tierPrice:c,tierLabel:d,currencySymbol:s,invoiceTiming:a,intervalValue:e?.price?.billing_interval_value}},KN=({priceOption:e,interval:t,stairstepPrices:n=[]})=>{const{amount:i,billedText:r,billingAmount:o,intervalText:a,currencySymbol:s,intervalValue:u}=HN(e,n),c=Te(i).split("."),d=c?c[0]:"0",f=c&&c.length>1?c[1]:"00";return g(b,{className:"p-2 border-b border-grey-200 last:border-0",children:[l(b,{className:"flex items-center justify-between",children:l(K,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Fixed recurring"})}),g(b,{className:"flex items-end",children:[g(K,{variant:"label3",children:[s,d]}),g(K,{variant:"label6",className:"mb-[5px]",children:[".",f]}),g(U,{variant:"body4",className:"mb-[5px] text-[var(--pt-card-price-secondary-text)]",children:["/",a]})]}),(t!==Ge.MONTHLY||u!==1)&&g(U,{className:"-mt-[4px] mb-1",variant:"body6",children:["Billed"," ",g(K,{as:"span",variant:"label8",className:"inline-block",children:[s,Te(o)," ",r.toLowerCase()]})]})]})},GN=({interval:e,dynamicPrices:t,showMoreCard:n,dynamicAsFixedPrice:i,showMore:r})=>{const[o,a]=G(""),{dynamicCardHeight:s}=Ds({selectedInterval:e}),u=n?"":"flex flex-col",c=n?{}:{height:s+20},d=Re(()=>t.filter(f=>f?.price?.tier_type!==Xt.STAIRSTEP),[t]);return g(b,{className:u,style:c,children:[(n?d:d.slice(0,2)).map(f=>{const p=f?.price?.name||f?.price?.owner?.feature?.name||f?.price?.owner?.name,h=yy(f?.price.tiers,f.price.currency),{price:m,label:v,currencySymbol:y,isPercentage:x}=ra(f),w=h?.length===1;return n?g(b,{className:"p-2 border-b border-[var(--pt-card-price-border)] last:border-0",children:[g(b,{className:"flex justify-between items-center",children:[l(K,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-1",children:p}),w&&g(b,{className:"flex items-center cursor-pointer",children:[g(K,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!x&&y,m]}),v&&g(U,{variant:"body5",color:"text-[var(--pt-card-price-secondary-text)]",className:"mr-1",children:[x?"\xA0":"/",v]})]})]}),!w&&g(b,{className:"flex justify-between items-center",children:[l(U,{variant:"body5",className:"text-[var(--pt-card-price-primary-text)]",children:"Starts at"}),g(b,{className:"flex items-center cursor-pointer",onClick:k=>{k.stopPropagation(),a(o===f.id?"":f.id)},children:[g(K,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!x&&y,m]}),g(U,{variant:"body5",color:"text-[var(--pt-card-price-secondary-text)]",className:"mr-1",children:[x?"\xA0":"/",v]}),h.length>1&&l(ye,{name:o===f.id?"arrow-up-light":"arrow-down-linear",size:16,color:"grey-400"})]})]}),o===f.id&&h.length>1&&l(b,{className:"bg-grey-200 p-2 mt-1 rounded-lg",children:l(b,{className:"flex flex-col gap-y",children:h?.map(k=>g(b,{className:"flex justify-between items-center",children:[l(U,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:k?.label}),g(U,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:[k?.price,k?.package?`/${k?.package} ${v}`:""]})]},k?.label))})})]},f.id):i?null:l(b,{className:"mt-1",children:g(b,{className:"flex items-center gap-x-1 flex-wrap",children:[l(K,{variant:"label8",className:"text-[var(--pt-card-price-secondary-text)] whitespace-nowrap",children:p}),l(U,{variant:"body7",className:"text-[var(--pt-card-price-primary-text)]",children:w?"at":"from"}),g(b,{className:"flex items-center",children:[g(K,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!x&&y,m]}),v&&g(U,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:[x?"\xA0":"/",v]})]})]})},f.id)}),!n&&!!t?.length&&l(b,{className:"flex justify-center mt-auto",children:l(rn,{onClick:f=>{r(),f?.stopPropagation()},className:"mt-2",children:l(U,{variant:"body8",className:"text-[var(--pt-card-description-link)] underline",children:"Explore all prices \u2192"})})})]})},P4=({priceOption:e})=>{const t=Co(w=>w.selections),n=ra(e),i=e?.price?.tier_type===Xt.STAIRSTEP?t[e.id]:void 0,r=e?.price?.billing_interval,o=e?.price?.billing_interval_value||1,a=ta(r,o),s=e?.price?.owner?.feature?.usage_model===Xo.PERSISTENT_USE,u=a>1&&s,c=i!==void 0&&u?i/a:i,d=i!==void 0,f=d?Te(c):n.price,p=d?"":n.label,h=d?Tt(e?.price?.currency)||"":n.currencySymbol,m=d?!1:n.isPercentage,v=f?.split("."),y=v?v[0]:"0",x=v&&v.length>1?v[1]:"00";return g(b,{className:"p-2 border-b border-grey-200 last:border-0",children:[l(b,{className:"flex items-center justify-between",children:l(K,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Starts at"})}),g(b,{className:"flex items-end",children:[!m&&g(tt,{children:[g(K,{variant:"label3",children:[h,y]}),g(K,{variant:"label6",className:"mb-[5px]",children:[".",x]})]}),m&&l(K,{variant:"label3",children:f}),p&&g(U,{variant:"body4",className:"mb-[5px] text-[var(--pt-card-price-secondary-text)]",children:[m?"\xA0":"/",p]})]})]})},JN=({interval:e,dynamicPrices:t,showMore:n})=>{const{dynamicCardHeight:i}=Ds({selectedInterval:e}),r={height:i+118},o=Co(m=>m.selections),{stairstepPriceOptions:a,regularPriceOptions:s}=Re(()=>{const m=[],v=[];return t.forEach(y=>{y?.price?.tier_type===Xt.STAIRSTEP?m.push(y):v.push(y)}),{stairstepPriceOptions:m,regularPriceOptions:v}},[t]),u=Re(()=>a.reduce((m,v)=>{const y=o[v.id],x=v?.price?.billing_interval_value||1,w=ta(e,x),k=v?.price?.owner?.feature?.usage_model===Xo.PERSISTENT_USE,S=w>1&&k,C=y!==void 0&&S?y/w:y;return m+(C||0)},0),[e,a,o]),c=a.length>0&&a[0]?.price?.currency&&Tt(a[0].price.currency)||"",d=Te(u).split("."),f=d?d[0]:"0",p=d&&d.length>1?d[1]:"00",h=a.length>0?1:2;return g(b,{className:"flex flex-col",style:r,children:[g(b,{children:[a.length>0&&g(b,{className:"pt-2",children:[l(b,{className:"flex items-center justify-between",children:l(K,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Starts at"})}),g(b,{className:"flex items-end",children:[g(K,{variant:"label3",children:[c,f]}),g(K,{variant:"label6",className:"mb-[5px]",children:[".",p]})]})]}),s.slice(0,h).map(m=>{const v=m?.price?.name||m?.price?.owner?.feature?.name||m?.price?.owner?.name,{price:y,label:x,currencySymbol:w,isPercentage:k}=ra(m);return g(b,{className:"mt-1 p-2 border-b border-[var(--pt-card-price-border)] last:border-0",children:[l(K,{variant:"label7",className:"text-[var(--pt-card-price-secondary-text)] whitespace-nowrap",children:v}),g(b,{className:"flex items-center justify-between gap-x-1 flex-wrap mt-1",children:[l(U,{variant:"body7",className:"text-[var(--pt-card-price-primary-text)]",children:"Starts at"}),g(b,{className:"flex items-end",children:[g(K,{variant:"label6",color:"text-[var(--pt-card-price-amount)]",children:[!k&&w,y]}),x&&g(U,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",className:"mb-[2px]",children:[k?"\xA0":"/",x]})]})]})]},m.id)})]}),!!t?.length&&l(b,{className:"flex justify-center mt-auto",children:l(rn,{onClick:m=>{n(),m?.stopPropagation()},className:"mt-2",children:l(U,{variant:"body8",className:"text-[var(--pt-card-description-link)] underline",children:"Explore all prices \u2192"})})})]})},A4=({interval:e,priceOptions:t,showMoreCard:n,entitlementPriceOptions:i,creditAttachmentPriceOptions:r,dynamicPrices:o})=>{const{setSelection:a}=Co(),s=Co(c=>c.selections),u=Re(()=>{if(o)return o.filter(d=>d?.price?.tier_type===Xt.STAIRSTEP);if(!t||!i||!r)return[];const c=ea(e,i);return[...ea(e,r),...c].filter(d=>d?.price?.tier_type===Xt.STAIRSTEP)},[e,t,o,i,r]);return l(b,{children:(n?u:u.slice(0,3)).map(c=>l(qN,{price:c,selections:s,setSelection:a},c.id))})},qN=({price:e,selections:t,setSelection:n})=>{const i=e.price?.tiers||[],r=e.price?.currency||"",o=f1(r),a=py[e.price?.billing_interval],s=e?.price.owner,u=s?.feature?.unit_singular||s?.credit_unit_singular||s?.unit_singular,c=s?.feature?.unit_plural||s?.credit_unit_plural||s?.unit_plural,d=i.map(m=>{const v={label:`${m.total_unit_quantity||0} ${m.total_unit_quantity&&m.total_unit_quantity>1?c:u} /${a}`,value:m.flat_fee?String(m.flat_fee):"0"};return m.flat_fee&&(v.description=`${o}${Te(m.flat_fee)}`),v}),f=t[e.id],p=d[0]?.value?parseFloat(d[0].value):0,h=String(f||p);return de(()=>{!t[e.id]&&d.length>0&&d[0]?.value&&n(e.id,parseFloat(d[0].value))},[e.id,d.length,n]),l(b,{className:"mb-3 last:mb-0",children:l(tu,{size:"small",options:d,className:"w-full",value:h,showDescriptionInline:!0,onChange:m=>{n(e.id,parseFloat(m))},containerClassName:"!bg-white !border-grey-200 !px-4 !py-3 hover:!border-grey-300 transition-colors"})})},YN=({interval:e,priceOptions:t,entitlementPriceOptions:n,creditAttachmentPriceOptions:i,isPricePage:r,trialTag:o,showMoreCard:a,isFree:s,isCustom:u,showMore:c,addPriceButton:d})=>{const{shouldShowFixedPrice:f,shouldShowFreeTrial:p,shouldShowDynamicPrices:h}=Ds({selectedInterval:e,publishedOnly:r}),m=Bf(e,t),v=ea(e,n),y=ea(e,i),x=v.length===1&&!m,w=y.length===1&&!m&&v.length===0,k=[...y,...v],S=k.filter(N=>N?.price?.tier_type===Xt.STAIRSTEP);if(!r&&!m&&v.length===0&&!y.length&&!s&&!u)return g(tt,{children:[l(b,{className:"h-[94px] flex items-center",children:l(b,{className:"w-full bg-grey-100 border border-grey-200 rounded-2xl p-2 mb-3",children:d||l(U,{variant:"body6",className:"text-[var(--pt-card-price-amount)]",children:"No price added yet"})})}),p&&l(b,{className:"h-6"})]});const C=!!(m||x||w||s||u);return g(tt,{children:[g(b,{className:a?"bg-[var(--pt-card-price-bg)] border border-[var(--pt-card-price-border)] rounded-2xl p-2 mb-3 text-[var(--pt-card-price-amount)]":"text-[var(--pt-card-price-amount)]",children:[f&&C&&g(b,{className:a?"":"h-[98px]",children:[s&&l(b,{className:"p-2",children:l(b,{className:"flex items-center justify-between pt-[21px] pb-4",children:l(K,{variant:"label3",children:"Free"})})}),u&&l(b,{className:"p-2",children:l(b,{className:"flex items-center justify-between pt-[21px] pb-4",children:l(K,{variant:"label4",children:"Custom"})})}),m&&l(KN,{interval:e,priceOption:m,stairstepPrices:S}),x&&!m&&!a&&l(P4,{priceOption:v[0]}),w&&!m&&!x&&!a&&l(P4,{priceOption:y[0]})]}),!C&&!a&&l(JN,{dynamicPrices:k,showMore:c,interval:e}),p&&!r&&l(b,{className:"h-6",children:o}),h&&l(tt,{children:!!(m||x||w||s||u||a)&&l(GN,{interval:e,dynamicPrices:k,showMoreCard:a,dynamicAsFixedPrice:x||w,showMore:c})})]}),a&&S.length>0&&l(b,{className:"mt-4 mb-2",children:l(A4,{interval:e,showMoreCard:a,priceOptions:t,dynamicPrices:S,entitlementPriceOptions:n,creditAttachmentPriceOptions:i})})]})},XN=({description:e,entitlements:t,baseEntitlementsPlanName:n,priceContent:i})=>g(b,{children:[l(K,{variant:"label7",className:"mb-2 text-[var(--pt-card-description)]",children:"Description"}),l(U,{variant:"body5",className:"mb-4 text-[var(--pt-card-description)]",children:e}),i,l(L4,{entitlements:t,baseEntitlementsPlanName:n})]});function QN(e){de(function(){typeof e=="function"&&e()},[])}var eT="Expected a function",O4=NaN,tT="[object Symbol]",rT=/^\s+|\s+$/g,nT=/^[-+]0x[0-9a-f]+$/i,iT=/^0b[01]+$/i,oT=/^0o[0-7]+$/i,aT=parseInt,sT=typeof jr=="object"&&jr&&jr.Object===Object&&jr,lT=typeof self=="object"&&self&&self.Object===Object&&self,cT=sT||lT||Function("return this")(),uT=Object.prototype,dT=uT.toString,fT=Math.max,pT=Math.min,r1=function(){return cT.Date.now()};function mT(e,t,n){var i,r,o,a,s,u,c=0,d=!1,f=!1,p=!0;if(typeof e!="function")throw new TypeError(eT);t=z4(t)||0,n1(n)&&(d=!!n.leading,f="maxWait"in n,o=f?fT(z4(n.maxWait)||0,t):o,p="trailing"in n?!!n.trailing:p);function h(N){var A=i,L=r;return i=r=void 0,c=N,a=e.apply(L,A),a}function m(N){return c=N,s=setTimeout(x,t),d?h(N):a}function v(N){var A=N-u,L=N-c,W=t-A;return f?pT(W,o-L):W}function y(N){var A=N-u,L=N-c;return u===void 0||A>=t||A<0||f&&L>=o}function x(){var N=r1();if(y(N))return w(N);s=setTimeout(x,v(N))}function w(N){return s=void 0,p&&i?h(N):(i=r=void 0,a)}function k(){s!==void 0&&clearTimeout(s),c=0,i=u=r=s=void 0}function S(){return s===void 0?a:w(r1())}function C(){var N=r1(),A=y(N);if(i=arguments,r=this,u=N,A){if(s===void 0)return m(u);if(f)return s=setTimeout(x,t),h(u)}return s===void 0&&(s=setTimeout(x,t)),a}return C.cancel=k,C.flush=S,C}function n1(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function hT(e){return!!e&&typeof e=="object"}function gT(e){return typeof e=="symbol"||hT(e)&&dT.call(e)==tT}function z4(e){if(typeof e=="number")return e;if(gT(e))return O4;if(n1(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=n1(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(rT,"");var n=iT.test(e);return n||oT.test(e)?aT(e.slice(2),n?2:8):nT.test(e)?O4:+e}var vT=mT,bT=oi(vT);function yT(e,t,n){var i=Ne(function(o){return bT(o,t,n)},[t,n]),r=De(i(e));return de(function(){r.current=i(e)},[e,i]),r.current}function wT(e,t){var n=De(!1);typeof t<"u"&&!Array.isArray(t)?t=[t]:Array.isArray(t)&&t.length===0&&console.warn("Using [] as the second argument makes useDidUpdate a noop. The second argument should either be `undefined` or an array of length greater than 0."),de(function(){n.current?e():n.current=!0},t),de(function(){return function(){n.current=!1}},[])}var M4=typeof window>"u"?de:zs;function xT(e,t){t===void 0&&(t=!1);var n=t?M4:de,i=De(e);return n(function(){i.current=e}),i}function kT(e){var t=xT(e);function n(){for(var i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];typeof t.current=="function"&&t.current.apply(t,i)}return n}var CT=process.env.NODE_ENV!=="production",j4=function(){};if(CT){var _T=function(e){var t="Warning: ".concat(e);typeof console<"u"&&console.error(t);try{throw new Error(t)}catch{}};j4=function(e,t){e||_T(t)}}function $T(e,t,n,i,r,o){i===void 0&&(i={}),r===void 0&&(r=!0),o===void 0&&(o=!1);var a=kT(n),s=o?M4:de;s(function(){return j4(typeof e<"u","[useGlobalObjectEventListener]: Cannot attach event handlers to undefined."),typeof e<"u"&&r?(e.addEventListener(t,a,i),function(){e.removeEventListener(t,a,i)}):function(){}},[t,i])}function ST(e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1),typeof window<"u"?$T(window,"resize",e,{passive:!0},t,n):console.warn("useOnWindowResize can't attach an event listener as window is undefined.")}var F4="...",NT=0,Ls=function(){return"__clamp_text_key__".concat(NT++)};function TT(e){var t=e.text,n=e.ellipsis,i=n===void 0?F4:n,r=e.lines,o=r===void 0?3:r,a=e.expanded,s=a===void 0?!1:a,u=e.debounceTime,c=u===void 0?300:u,d=e.charWidth,f=d===void 0?1.2:d,p=G(function(){return{noClamp:!1,clampedText:".",key:Ls()}}),h=p[0],m=h.noClamp,v=h.clampedText,y=h.key,x=p[1],w=De(),k=De(0),S=Ne(function(N){var A=N.lineHeight,L=N.originalText,W=N.expanded,j=N.ellipsis,H=N.lines,Y=N.charWidth,X=w.current;if(!X)return;if(!L||W){x({noClamp:!0,clampedText:L,key:Ls()});return}var Z=A*H+1,D=0;typeof j=="string"?D=j===F4?5:Math.ceil(j.length*Y):typeof j=="number"&&(D=Math.ceil(j*Y));var I=0,F=0,R=L.length;if(!X.clientHeight)return;function te(){var re,ue=(re=X?.clientHeight)!==null&&re!==void 0?re:1;ue<=Z?I=F+1:R=F-1}for(;I<=R;){if(F=Math.floor((I+R)/2),X.innerText=L.slice(0,F),F===L.length){x({clampedText:L,noClamp:!0,key:Ls()});return}te()}var B=L.slice(0,Math.max(F-D,0)).trim()+(typeof j=="string"?j:"");X.innerText=B,x({noClamp:!1,clampedText:B,key:Ls()})},[]),C=yT(S,c);return ST(function(){return C({lineHeight:k.current,originalText:t,expanded:s,ellipsis:i,lines:o,charWidth:f})}),QN(function(){var N,A;if(t&&!k.current){var L=((A=(N=w.current)===null||N===void 0?void 0:N.clientHeight)!==null&&A!==void 0?A:1)+1;k.current=L,S({lineHeight:L,originalText:t,expanded:s,ellipsis:i,lines:o,charWidth:f})}}),wT(function(){S({lineHeight:k.current,originalText:t,expanded:s,ellipsis:i,lines:o,charWidth:f})},[s,t,f,i,o]),[w,{noClamp:m,clampedText:v,key:y}]}const ET=({description:e,showDetails:t})=>{const[n,{noClamp:i,clampedText:r,key:o}]=TT({text:e,ellipsis:12.5,lines:3});return e?l(U,{variant:"body6",className:"text-[var(--pt-card-description-text)]",children:g("span",{ref:n,className:"w-full inline-block",children:[r,!i&&g(tt,{children:["...",l(rn,{onClick:a=>{t(),a?.stopPropagation()},className:"!inline",children:l(U,{variant:"body6",className:"text-[var(--pt-card-description-link)] border-b border-[var(--pt-card-description-link)]",children:"See more"})})]})]},o)}):null},Ps=({plan:e,interval:t,featureOrderMap:n,isPricePage:i,isCustomerPortal:r=!1,statusTag:o,addPriceButton:a,buttonText:s,isCurrentPlan:u,planActions:c,cardAction:d,buttonAction:f})=>{const p=!i&&!r,{theme:h,cssVars:m}=Yd(p,r),{setPlans:v}=I4(),{shouldShowDescription:y}=Ds({selectedInterval:t,publishedOnly:i}),[x,w]=G(!1);if(de(()=>{e&&v(se=>[...se,e])},[e,v]),!e)return null;const{name:k,entitlements:S,base_entitlements_plan_name:C,is_free:N,is_custom:A,custom_cta_text:L,description:W,price_options:j,entitlement_price_options:H,credit_attachment_price_options:Y,credit_attachments:X,trial_duration_unit:Z,trial_duration_value:D,version_id:I,is_visible:F,is_invoiceable:R,status:te}=e,B=H.map((se,Oe)=>({item:se,index:Oe})).sort((se,Oe)=>{const Ce=se.item.price.owner?.feature?.id,Pe=Oe.item.price.owner?.feature?.id,ze=n.get(Ce)??Number.MAX_SAFE_INTEGER,nt=n.get(Pe)??Number.MAX_SAFE_INTEGER;return ze===nt?se.index-Oe.index:ze-nt}).map(({item:se})=>se),re=Bf(t,[...j,...B,...Y]),ue=Z&&D,ae=D===1?Z:`${Z}s`,Q=xl([...S]).filter(se=>se?.is_visible),le=xy(Q,n),_e=X?.filter(se=>se.included_allowance);if(!re&&!N&&!A&&i||!F&&i||!R&&i||!re&&te!==Zf.DRAFT&&(j?.length>0||H?.length>0||Y?.length>0))return null;const Se=se=>l(YN,{trialTag:ue&&l(Wn,{background:"bg-[var(--pt-free-trial-bg)]",textColor:"text-[var(--pt-free-trial-text)]",size:"small",children:l(U,{variant:"body6",className:"text-[var(--pt-free-trial-text)]",children:`${D} ${ae} Free trial`})}),offering:e,interval:t,priceOptions:j,entitlementPriceOptions:B,creditAttachmentPriceOptions:Y,isPricePage:i,versionId:I,showMoreCard:se,showMore:()=>w(!0),isFree:N,isCustom:A,addPriceButton:a}),he="relative flex-[0_0_auto] w-[330px] cursor-pointer",Ae=A?L:N?"Get started":ue?`Start ${D} ${ae} free trial`:"Buy now",xe=i?Ae:s,Ie=()=>{f?.()},me=u?"var(--pt-current-sub-card-radius, var(--pt-card-radius, 1rem))":"var(--pt-card-radius, 1rem)";return g(b,{className:`flex flex-col border text-wrap shrink-0 ${u?"bg-[var(--pt-current-sub-card-header-bg)]":"bg-[var(--pt-card-header-bg)]"} ${he}`,onClick:d,style:{...r||i?{}:m,...u&&!r&&!i?yl(h):{},borderRadius:me,borderColor:"var(--pt-card-border, #e5e7eb)",borderWidth:"var(--pt-card-border-width, 1px)",borderStyle:"solid"},children:[g(b,{className:"flex items-center justify-between pl-4 pr-[5px] pt-[6px] pb-[2px]",children:[l(K,{variant:"label7",className:`${u?"text-[var(--pt-current-sub-card-header-text)]":"text-[var(--pt-card-header-text)]"}`,children:k}),g(b,{className:"flex items-center gap-x-2",children:[o," ",c]})]}),g(b,{className:`flex-grow border border-[var(--pt-card-header-bg)] w-full p-2 pb-[40px] ${u?"":"bg-[var(--pt-card-bg)]"}`,style:{borderRadius:`calc(${me} - 2px)`,...u?{background:"var(--pt-card-bg)",backgroundImage:"var(--pt-card-gradient)"}:{}},children:[y&&l(b,{className:"h-[51px] mt-1",children:l(ET,{description:W,showDetails:()=>w(!0)})}),Se(),(i||r)&&l(ur,{className:"w-full !text-[var(--pt-button-text)] !bg-[var(--pt-button-bg)] mt-3",onClick:Ie,disabled:u,children:xe}),l(b,{className:"mt-4 mb-2",children:l(A4,{interval:t,showMoreCard:!1,priceOptions:j,entitlementPriceOptions:B,creditAttachmentPriceOptions:Y})}),l(b,{className:"px-2 mt-3",children:l(L4,{entitlements:le,credits:_e,baseEntitlementsPlanName:C})})]}),l(tn,{isOpen:x,onClose:()=>w(!1),title:k,size:"small",modalClassName:"!bg-[var(--pt-card-bg)]",bottomBorder:"border-[var(--pt-card-price-border)]",topContent:g(b,{className:"flex justify-between items-center gap-x-2 border-b border-[var(--pt-card-price-border)] pb-4 px-4 mb-[-16px] mx-[-16px]",children:[l(Sr,{variant:"h6",className:"text-[var(--pt-card-description-text)]",children:k}),l("span",{onClick:()=>w(!1),className:"cursor-pointer",style:{color:"var(--pt-card-description-text, theme(colors.grey.500))"},children:l(ye,{name:"circle-close",size:24,color:"currentColor"})})]}),bottomContent:g(b,{className:"flex justify-end gap-x-2",children:[l(Mi,{onClick:()=>w(!1),className:"!text-[var(--cp-modal-footer-secondary-text)] !bg-[var(--cp-modal-footer-secondary-bg)]",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width, 1px)",borderColor:"var(--cp-modal-footer-secondary-border, theme(colors.grey.200))",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:i?"Cancel":"Close"}),i&&l(ur,{onClick:Ie,className:"!text-[var(--cp-modal-footer-primary-text)] !bg-[var(--cp-modal-footer-primary-bg)]",style:{borderWidth:"var(--cp-modal-footer-primary-border-width, 0px)",borderColor:"var(--cp-modal-footer-primary-border, transparent)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:xe})]}),children:l(XN,{baseEntitlementsPlanName:C,description:W,entitlements:S,priceContent:Se(!0)})})]})},IT=async({productKey:e,checkoutUsername:t,countryCode:n})=>{const{data:i}=await He().get("/product_catalogues/public/products",{params:{product_key:e,checkout_username:t,country_code:n}});return i},DT=({productKey:e,checkoutUsername:t,countryCode:n,enabled:i=!0})=>{const[r,o]=G(null),[a,s]=G(null),[u,c]=G(!1),d=Ne(async()=>{if(i){c(!0);try{const f=await IT({productKey:e,checkoutUsername:t,countryCode:n});o(f?.data)}catch(f){const p=f,h=p?.response?.data?.data?.error||p?.message;s(h||"Failed to load public product")}finally{c(!1)}}},[e,t,n,i]);return de(()=>{i&&d()},[d,i]),{product:r,error:a,isLoading:u,refetch:d}};var Or=(e=>(e.PLAN="plan",e.ADD_ON="add_on",e.SINGLE_PURCHASE="single_purchase",e))(Or||{}),R4=(e=>(e.STRICT_AUTO_DETECT="strict_auto_detect",e.SMART_PRE_FILL="smart_pre_fill",e))(R4||{});const LT=async e=>{const{data:t}=await He().get(`/product_catalogues/public/localization-settings?checkout_username=${e}`);return t},PT=e=>{const[t,n]=G(null),[i,r]=G(!0);return de(()=>{(async()=>{try{const o=await LT(e);n(o?.data)}catch{}finally{r(!1)}})()},[e]),{settings:t,loading:i}},AT=async(e,t)=>{const{data:n}=await He().get(`/product_catalogues/public/products/${e}/localizations?status=active&checkout_username=${t}`);return n},OT=(e,t,n=!0)=>{const[i,r]=G([]),[o,a]=G(null),[s,u]=G(n);return de(()=>{if(!n){u(!1);return}e&&(async()=>{try{const c=(await AT(e,t))?.data;r(c?.localizations||[]),a(c?.tenant_country||null)}catch{}finally{u(!1)}})()},[e,t,n]),{localizations:i,tenantCountry:o,loading:s}},zT=(e=!0)=>{const[t,n]=G(void 0),[i,r]=G(!0),[o,a]=G(null);return de(()=>{if(!e){r(!1);return}r(!0),(async()=>{try{const s="https://api.bigdatacloud.net/data/reverse-geocode-client",u=(await ef.get(s)).data;u&&n({code:u.countryCode,name:u.countryName})}catch(s){a(s)}finally{r(!1)}})()},[e]),{country:t,loading:i,error:o}},As="GLOBAL",i1=(e,t)=>{const[n,i]=G(void 0),[r,o]=G(""),{settings:a,loading:s}=PT(t),u=a?.selection===R4.SMART_PRE_FILL,{localizations:c=[],loading:d}=OT(e,t,u),f=Re(()=>new Set(c.map(S=>S.country_code)),[c]),{country:p,loading:h,error:m}=zT(u),v=Re(()=>{const S=c?.map(C=>({country_code:C.country_code,currency_code:C.currency_code}))??[];return[{country_code:As,currency_code:r},...S]},[c,r]),y=Re(()=>v.map(S=>S.country_code===As?{label:`Global (${S.currency_code} ${Tt(S.currency_code)})`,value:S.country_code}:{label:`${av(S.country_code)} ${ov(S.country_code)} (${Tt(S.currency_code)})`,value:S.country_code}),[v]),x=Re(()=>{if(!(!u||!p))return f.has(p.code)?p.code:As},[u,p,f]),w=n??x;de(()=>{!n&&x&&i(x)},[n,i,x]);const k=Re(()=>w===As?void 0:w,[w]);return{selectedCountry:w,setSelectedCountry:i,setOfferingCurrency:o,allLocalizations:y,showLocalizationDropdown:u,apiCountryCode:k,isResolvingLocalization:s||!(!u||!d&&!h&&(w||m))}},MT=({selectedTab:e,setSelectedTab:t,tabOptions:n})=>l(b,{className:"w-full flex justify-center border-b border-[var(--pt-tabs-border)] mb-6",children:n.map(i=>{const r=e===i.value;return l(b,{className:`px-4 py-2 text-center cursor-pointer ${r?"border-b border-[var(--pt-tabs-indicator)]":""}
80
+ ${u?"bg-[var(--pt-interval-active-bg,var(--cp-tabs-active-bg))] shadow-sm":"bg-transparent hover:opacity-80"}`,onClick:()=>r(s),children:l(U,{variant:"body6",className:"font-medium whitespace-nowrap",color:u?"text-[var(--pt-interval-active-text,var(--cp-tabs-active-text))]":"text-[var(--pt-interval-inactive-text,var(--cp-tabs-inactive-text))]",children:Kt(s)})},s)})})})},Qd=e=>{const t=Re(()=>wy(e||[]),[e]),[n,i]=G(""),r=Re(()=>[...t.includes(Ge.DAILY)?[Ge.DAILY]:[],...t.includes(Ge.WEEKLY)?[Ge.WEEKLY]:[],...t.includes(Ge.MONTHLY)?[Ge.MONTHLY]:[],...t.includes(Ge.QUARTERLY)?[Ge.QUARTERLY]:[],...t.includes(Ge.BIANNUALLY)?[Ge.BIANNUALLY]:[],...t.includes(Ge.YEARLY)?[Ge.YEARLY]:[]],[t]);return de(()=>{!n&&r[0]&&i(r[0])},[r,n]),{intervals:r,selectedInterval:n,setSelectedInterval:i}},I4=ui(e=>({plans:[],setPlans:t=>e(n=>({plans:typeof t=="function"?t(n.plans):t}))}));function e1(e,t){let n;try{n=e()}catch{return}return{getItem:r=>{var o;const a=u=>u===null?null:JSON.parse(u,void 0),s=(o=n.getItem(r))!=null?o:null;return s instanceof Promise?s.then(a):a(s)},setItem:(r,o)=>n.setItem(r,JSON.stringify(o,void 0)),removeItem:r=>n.removeItem(r)}}const t1=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(i){return t1(i)(n)},catch(i){return this}}}catch(n){return{then(i){return this},catch(i){return t1(i)(n)}}}},WN=(e,t)=>(n,i,r)=>{let o={storage:e1(()=>localStorage),partialize:v=>v,version:0,merge:(v,y)=>({...y,...v}),...t},a=!1;const s=new Set,u=new Set;let c=o.storage;if(!c)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...v)},i,r);const d=()=>{const v=o.partialize({...i()});return c.setItem(o.name,{state:v,version:o.version})},f=r.setState;r.setState=(v,y)=>(f(v,y),d());const p=e((...v)=>(n(...v),d()),i,r);r.getInitialState=()=>p;let h;const m=()=>{var v,y;if(!c)return;a=!1,s.forEach(w=>{var k;return w((k=i())!=null?k:p)});const x=((y=o.onRehydrateStorage)==null?void 0:y.call(o,(v=i())!=null?v:p))||void 0;return t1(c.getItem.bind(c))(o.name).then(w=>{if(w)if(typeof w.version=="number"&&w.version!==o.version){if(o.migrate){const k=o.migrate(w.state,w.version);return k instanceof Promise?k.then(S=>[!0,S]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,w.state];return[!1,void 0]}).then(w=>{var k;const[S,C]=w;if(h=o.merge(C,(k=i())!=null?k:p),n(h,!0),S)return d()}).then(()=>{x?.(h,void 0),h=i(),a=!0,u.forEach(w=>w(h))}).catch(w=>{x?.(void 0,w)})};return r.persist={setOptions:v=>{o={...o,...v},v.storage&&(c=v.storage)},clearStorage:()=>{c?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>m(),hasHydrated:()=>a,onHydrate:v=>(s.add(v),()=>{s.delete(v)}),onFinishHydration:v=>(u.add(v),()=>{u.delete(v)})},o.skipHydration||m(),h||p},D4=WN,Co=ui()(D4(e=>({selections:{},setSelection:(t,n)=>e(i=>({selections:{...i.selections,[t]:n}}))}),{name:"metrifox:stairstep-selections",storage:e1(()=>localStorage)})),Ds=({selectedInterval:e,publishedOnly:t=!1})=>{const{plans:n}=I4(),[i,r]=G(40),o=Ne(d=>{if(!d)return;const f=d.published_version||d,p=d.draft_version;return t?f?.is_visible?f:void 0:f||p},[t]),a=n?.some(d=>!!o(d)?.description),s=n?.some(d=>!!o(d)?.trial_duration_value),u=n?.some(d=>{const f=o(d);return f?f.price_options?.some(p=>p.price?.billing_interval===e)||f.entitlement_price_options?.filter(p=>p.price.billing_interval===e).length===1||f.credit_attachment_price_options?.filter(p=>p.price.billing_interval===e).length===1||f.is_free||f.is_custom:!1}),c=n?.some(d=>{const f=o(d);return f?[f.credit_attachment_price_options,f.entitlement_price_options].some(p=>Array.isArray(p)&&p.some(h=>h.price?.billing_interval===e)):!1});return de(()=>{n.forEach(d=>{const f=o(d);if(!f)return;const p=[...f.credit_attachment_price_options||[],...f.entitlement_price_options||[]].filter(x=>x.price?.billing_interval===e),h=x=>{const w=x,k=w?.price?.name||w?.price?.owner?.feature?.name||w?.price?.owner?.name,{price:S,label:C,currencySymbol:N}=ra(w);return`${k} from ${N}${S}${C?`/${C}`:""}`.length>40?39:24},m=p[0]?h(p[0]):0,v=p[1]?h(p[1]):0,y=m+v;r(x=>y>x?y:x)})},[n,e,o]),{dynamicCardHeight:i,shouldShowDescription:a,shouldShowFreeTrial:s,shouldShowFixedPrice:u,shouldShowDynamicPrices:c}},L4=({entitlements:e,baseEntitlementsPlanName:t,credits:n})=>{const i=xl(e).filter(r=>r?.is_visible);return g(b,{children:[l(K,{variant:"label7",className:"text-[var(--pt-feature-text)] mb-3",as:"p",children:t?`Everything in ${t} plus:`:e.length>0?"Included:":"\xA0"}),g("ul",{className:"flex flex-col gap-y-3",children:[n?.map((r,o)=>g("li",{className:"flex items-center gap-[10px]",children:[" ",l("span",{style:{color:"var(--pt-feature-icon, theme(colors.green.600))"},className:"flex items-center",children:l(ye,{name:"check",color:"currentColor",size:16})}),g(U,{variant:"body5",className:"text-[var(--pt-feature-text)]",children:[r.included_allowance+" ",r.included_allowance===1?r.credit_unit_singular:r.credit_unit_plural]})]},o)),i?.map((r,o)=>g("li",{className:"flex items-center gap-[10px]",children:[" ",l("span",{style:{color:"var(--pt-feature-icon, theme(colors.green.600))"},className:"flex items-center",children:l(ye,{name:"check",color:"currentColor",size:16})}),l(U,{variant:"body5",className:"text-[var(--pt-feature-text)]",children:r.display_text})]},o))]})]})},HN=(e,t=[])=>{const n=Co(L=>L.selections),i=e?.price?.billing_interval,r=e?.price.tiers,o=e?.price.currency,a=e?.price?.invoice_timing,s=Tt(o),u=L=>{const W=e?.price?.owner,j=W?.included_usage||0,H=L?.find(F=>F.first_unit===j);if(!H)return{price:null,label:null};const{unit_price:Y,package_price:X,package_size:Z,pricing_model:D,flat_fee:I}=H;return I?{price:I.toFixed(2),label:""}:{per_unit:{price:Y?.toFixed(2),label:`per. ${W?.feature?.unit_singular||W?.credit_unit_singular}`},per_package:{price:X?.toFixed(2),label:`for ${Z} ${W?.feature?.unit_plural}`}}[D]??{price:null,label:null}},{price:c,label:d}=u(r),f=e?.price?.is_custom&&e?.price?.billing_interval_value>1?`every ${e?.price?.billing_interval_value} ${by[i]}`:i,p=[Ge.DAILY,Ge.WEEKLY],h={[Ge.DAILY]:"day",[Ge.WEEKLY]:"week"},m=i,v=p.includes(m)?h[m]:"month",y=Re(()=>t.reduce((L,W)=>{const j=n[W.id];return L+(j||0)},0),[t,n]),x=e?.price?.price??0,w=ta(i,e?.price?.billing_interval_value),k=x+y,S=w>1?k/w:k,C=k,N=S.toFixed(2),A=C.toFixed(2);return{amount:N,billedText:f,intervalText:v,billingAmount:A,tierPrice:c,tierLabel:d,currencySymbol:s,invoiceTiming:a,intervalValue:e?.price?.billing_interval_value}},KN=({priceOption:e,interval:t,stairstepPrices:n=[]})=>{const{amount:i,billedText:r,billingAmount:o,intervalText:a,currencySymbol:s,intervalValue:u}=HN(e,n),c=Te(i).split("."),d=c?c[0]:"0",f=c&&c.length>1?c[1]:"00";return g(b,{className:"p-2 border-b border-grey-200 last:border-0",children:[l(b,{className:"flex items-center justify-between",children:l(K,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Fixed recurring"})}),g(b,{className:"flex items-end",children:[g(K,{variant:"label3",children:[s,d]}),g(K,{variant:"label6",className:"mb-[5px]",children:[".",f]}),g(U,{variant:"body4",className:"mb-[5px] text-[var(--pt-card-price-secondary-text)]",children:["/",a]})]}),(t!==Ge.MONTHLY||u!==1)&&g(U,{className:"-mt-[4px] mb-1",variant:"body6",children:["Billed"," ",g(K,{as:"span",variant:"label8",className:"inline-block",children:[s,Te(o)," ",r.toLowerCase()]})]})]})},GN=({interval:e,dynamicPrices:t,showMoreCard:n,dynamicAsFixedPrice:i,showMore:r})=>{const[o,a]=G(""),{dynamicCardHeight:s}=Ds({selectedInterval:e}),u=n?"":"flex flex-col",c=n?{}:{height:s+20},d=Re(()=>t.filter(f=>f?.price?.tier_type!==Xt.STAIRSTEP),[t]);return g(b,{className:u,style:c,children:[(n?d:d.slice(0,2)).map(f=>{const p=f?.price?.name||f?.price?.owner?.feature?.name||f?.price?.owner?.name,h=yy(f?.price.tiers,f.price.currency),{price:m,label:v,currencySymbol:y,isPercentage:x}=ra(f),w=h?.length===1;return n?g(b,{className:"p-2 border-b border-[var(--pt-card-price-border)] last:border-0",children:[g(b,{className:"flex justify-between items-center",children:[l(K,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-1",children:p}),w&&g(b,{className:"flex items-center cursor-pointer",children:[g(K,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!x&&y,m]}),v&&g(U,{variant:"body5",color:"text-[var(--pt-card-price-secondary-text)]",className:"mr-1",children:[x?"\xA0":"/",v]})]})]}),!w&&g(b,{className:"flex justify-between items-center",children:[l(U,{variant:"body5",className:"text-[var(--pt-card-price-primary-text)]",children:"Starts at"}),g(b,{className:"flex items-center cursor-pointer",onClick:k=>{k.stopPropagation(),a(o===f.id?"":f.id)},children:[g(K,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!x&&y,m]}),g(U,{variant:"body5",color:"text-[var(--pt-card-price-secondary-text)]",className:"mr-1",children:[x?"\xA0":"/",v]}),h.length>1&&l(ye,{name:o===f.id?"arrow-up-light":"arrow-down-linear",size:16,color:"grey-400"})]})]}),o===f.id&&h.length>1&&l(b,{className:"bg-grey-200 p-2 mt-1 rounded-lg",children:l(b,{className:"flex flex-col gap-y",children:h?.map(k=>g(b,{className:"flex justify-between items-center",children:[l(U,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:k?.label}),g(U,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:[k?.price,k?.package?`/${k?.package} ${v}`:""]})]},k?.label))})})]},f.id):i?null:l(b,{className:"mt-1",children:g(b,{className:"flex items-center gap-x-1 flex-wrap",children:[l(K,{variant:"label8",className:"text-[var(--pt-card-price-secondary-text)] whitespace-nowrap",children:p}),l(U,{variant:"body7",className:"text-[var(--pt-card-price-primary-text)]",children:w?"at":"from"}),g(b,{className:"flex items-center",children:[g(K,{variant:"label7",color:"text-[var(--pt-card-price-amount)]",children:[!x&&y,m]}),v&&g(U,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",children:[x?"\xA0":"/",v]})]})]})},f.id)}),!n&&!!t?.length&&l(b,{className:"flex justify-center mt-auto",children:l(rn,{onClick:f=>{r(),f?.stopPropagation()},className:"mt-2",children:l(U,{variant:"body8",className:"text-[var(--pt-card-description-link)] underline",children:"Explore all prices \u2192"})})})]})},P4=({priceOption:e})=>{const t=Co(w=>w.selections),n=ra(e),i=e?.price?.tier_type===Xt.STAIRSTEP?t[e.id]:void 0,r=e?.price?.billing_interval,o=e?.price?.billing_interval_value||1,a=ta(r,o),s=e?.price?.owner?.feature?.usage_model===Xo.PERSISTENT_USE,u=a>1&&s,c=i!==void 0&&u?i/a:i,d=i!==void 0,f=d?Te(c):n.price,p=d?"":n.label,h=d?Tt(e?.price?.currency)||"":n.currencySymbol,m=d?!1:n.isPercentage,v=f?.split("."),y=v?v[0]:"0",x=v&&v.length>1?v[1]:"00";return g(b,{className:"p-2 border-b border-grey-200 last:border-0",children:[l(b,{className:"flex items-center justify-between",children:l(K,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Starts at"})}),g(b,{className:"flex items-end",children:[!m&&g(tt,{children:[g(K,{variant:"label3",children:[h,y]}),g(K,{variant:"label6",className:"mb-[5px]",children:[".",x]})]}),m&&l(K,{variant:"label3",children:f}),p&&g(U,{variant:"body4",className:"mb-[5px] text-[var(--pt-card-price-secondary-text)]",children:[m?"\xA0":"/",p]})]})]})},JN=({interval:e,dynamicPrices:t,showMore:n})=>{const{dynamicCardHeight:i}=Ds({selectedInterval:e}),r={height:i+118},o=Co(m=>m.selections),{stairstepPriceOptions:a,regularPriceOptions:s}=Re(()=>{const m=[],v=[];return t.forEach(y=>{y?.price?.tier_type===Xt.STAIRSTEP?m.push(y):v.push(y)}),{stairstepPriceOptions:m,regularPriceOptions:v}},[t]),u=Re(()=>a.reduce((m,v)=>{const y=o[v.id],x=v?.price?.billing_interval_value||1,w=ta(e,x),k=v?.price?.owner?.feature?.usage_model===Xo.PERSISTENT_USE,S=w>1&&k,C=y!==void 0&&S?y/w:y;return m+(C||0)},0),[e,a,o]),c=a.length>0&&a[0]?.price?.currency&&Tt(a[0].price.currency)||"",d=Te(u).split("."),f=d?d[0]:"0",p=d&&d.length>1?d[1]:"00",h=a.length>0?1:2;return g(b,{className:"flex flex-col",style:r,children:[g(b,{children:[a.length>0&&g(b,{className:"pt-2",children:[l(b,{className:"flex items-center justify-between",children:l(K,{variant:"label7",className:"text-[var(--pt-card-price-primary-text)] mb-2",children:"Starts at"})}),g(b,{className:"flex items-end",children:[g(K,{variant:"label3",children:[c,f]}),g(K,{variant:"label6",className:"mb-[5px]",children:[".",p]})]})]}),s.slice(0,h).map(m=>{const v=m?.price?.name||m?.price?.owner?.feature?.name||m?.price?.owner?.name,{price:y,label:x,currencySymbol:w,isPercentage:k}=ra(m);return g(b,{className:"mt-1 p-2 border-b border-[var(--pt-card-price-border)] last:border-0",children:[l(K,{variant:"label7",className:"text-[var(--pt-card-price-secondary-text)] whitespace-nowrap",children:v}),g(b,{className:"flex items-center justify-between gap-x-1 flex-wrap mt-1",children:[l(U,{variant:"body7",className:"text-[var(--pt-card-price-primary-text)]",children:"Starts at"}),g(b,{className:"flex items-end",children:[g(K,{variant:"label6",color:"text-[var(--pt-card-price-amount)]",children:[!k&&w,y]}),x&&g(U,{variant:"body7",color:"text-[var(--pt-card-price-secondary-text)]",className:"mb-[2px]",children:[k?"\xA0":"/",x]})]})]})]},m.id)})]}),!!t?.length&&l(b,{className:"flex justify-center mt-auto",children:l(rn,{onClick:m=>{n(),m?.stopPropagation()},className:"mt-2",children:l(U,{variant:"body8",className:"text-[var(--pt-card-description-link)] underline",children:"Explore all prices \u2192"})})})]})},A4=({interval:e,priceOptions:t,showMoreCard:n,entitlementPriceOptions:i,creditAttachmentPriceOptions:r,dynamicPrices:o})=>{const{setSelection:a}=Co(),s=Co(c=>c.selections),u=Re(()=>{if(o)return o.filter(d=>d?.price?.tier_type===Xt.STAIRSTEP);if(!t||!i||!r)return[];const c=ea(e,i);return[...ea(e,r),...c].filter(d=>d?.price?.tier_type===Xt.STAIRSTEP)},[e,t,o,i,r]);return l(b,{children:(n?u:u.slice(0,3)).map(c=>l(qN,{price:c,selections:s,setSelection:a},c.id))})},qN=({price:e,selections:t,setSelection:n})=>{const i=e.price?.tiers||[],r=e.price?.currency||"",o=f1(r),a=py[e.price?.billing_interval],s=e?.price.owner,u=s?.feature?.unit_singular||s?.credit_unit_singular||s?.unit_singular,c=s?.feature?.unit_plural||s?.credit_unit_plural||s?.unit_plural,d=i.map(m=>{const v={label:`${m.total_unit_quantity||0} ${m.total_unit_quantity&&m.total_unit_quantity>1?c:u} /${a}`,value:m.flat_fee?String(m.flat_fee):"0"};return m.flat_fee&&(v.description=`${o}${Te(m.flat_fee)}`),v}),f=t[e.id],p=d[0]?.value?parseFloat(d[0].value):0,h=String(f||p);return de(()=>{!t[e.id]&&d.length>0&&d[0]?.value&&n(e.id,parseFloat(d[0].value))},[e.id,d.length,n]),l(b,{className:"mb-3 last:mb-0",children:l(tu,{size:"small",options:d,className:"w-full",value:h,showDescriptionInline:!0,onChange:m=>{n(e.id,parseFloat(m))},containerClassName:"!bg-white !border-grey-200 !px-4 !py-3 hover:!border-grey-300 transition-colors"})})},YN=({interval:e,priceOptions:t,entitlementPriceOptions:n,creditAttachmentPriceOptions:i,isPricePage:r,trialTag:o,showMoreCard:a,isFree:s,isCustom:u,showMore:c,addPriceButton:d})=>{const{shouldShowFixedPrice:f,shouldShowFreeTrial:p,shouldShowDynamicPrices:h}=Ds({selectedInterval:e,publishedOnly:r}),m=Bf(e,t),v=ea(e,n),y=ea(e,i),x=v.length===1&&!m,w=y.length===1&&!m&&v.length===0,k=[...y,...v],S=k.filter(N=>N?.price?.tier_type===Xt.STAIRSTEP);if(!r&&!m&&v.length===0&&!y.length&&!s&&!u)return g(tt,{children:[l(b,{className:"h-[94px] flex items-center",children:l(b,{className:"w-full bg-grey-100 border border-grey-200 rounded-2xl p-2 mb-3",children:d||l(U,{variant:"body6",className:"text-[var(--pt-card-price-amount)]",children:"No price added yet"})})}),p&&l(b,{className:"h-6"})]});const C=!!(m||x||w||s||u);return g(tt,{children:[g(b,{className:a?"bg-[var(--pt-card-price-bg)] border border-[var(--pt-card-price-border)] rounded-2xl p-2 mb-3 text-[var(--pt-card-price-amount)]":"text-[var(--pt-card-price-amount)]",children:[f&&C&&g(b,{className:a?"":"h-[98px]",children:[s&&l(b,{className:"p-2",children:l(b,{className:"flex items-center justify-between pt-[21px] pb-4",children:l(K,{variant:"label3",children:"Free"})})}),u&&l(b,{className:"p-2",children:l(b,{className:"flex items-center justify-between pt-[21px] pb-4",children:l(K,{variant:"label4",children:"Custom"})})}),m&&l(KN,{interval:e,priceOption:m,stairstepPrices:S}),x&&!m&&!a&&l(P4,{priceOption:v[0]}),w&&!m&&!x&&!a&&l(P4,{priceOption:y[0]})]}),!C&&!a&&l(JN,{dynamicPrices:k,showMore:c,interval:e}),p&&!r&&l(b,{className:"h-6",children:o}),h&&l(tt,{children:!!(m||x||w||s||u||a)&&l(GN,{interval:e,dynamicPrices:k,showMoreCard:a,dynamicAsFixedPrice:x||w,showMore:c})})]}),a&&S.length>0&&l(b,{className:"mt-4 mb-2",children:l(A4,{interval:e,showMoreCard:a,priceOptions:t,dynamicPrices:S,entitlementPriceOptions:n,creditAttachmentPriceOptions:i})})]})},XN=({description:e,entitlements:t,baseEntitlementsPlanName:n,priceContent:i})=>g(b,{children:[l(K,{variant:"label7",className:"mb-2 text-[var(--pt-card-description)]",children:"Description"}),l(U,{variant:"body5",className:"mb-4 text-[var(--pt-card-description)]",children:e}),i,l(L4,{entitlements:t,baseEntitlementsPlanName:n})]});function QN(e){de(function(){typeof e=="function"&&e()},[])}var eT="Expected a function",O4=NaN,tT="[object Symbol]",rT=/^\s+|\s+$/g,nT=/^[-+]0x[0-9a-f]+$/i,iT=/^0b[01]+$/i,oT=/^0o[0-7]+$/i,aT=parseInt,sT=typeof jr=="object"&&jr&&jr.Object===Object&&jr,lT=typeof self=="object"&&self&&self.Object===Object&&self,cT=sT||lT||Function("return this")(),uT=Object.prototype,dT=uT.toString,fT=Math.max,pT=Math.min,r1=function(){return cT.Date.now()};function mT(e,t,n){var i,r,o,a,s,u,c=0,d=!1,f=!1,p=!0;if(typeof e!="function")throw new TypeError(eT);t=z4(t)||0,n1(n)&&(d=!!n.leading,f="maxWait"in n,o=f?fT(z4(n.maxWait)||0,t):o,p="trailing"in n?!!n.trailing:p);function h(N){var A=i,L=r;return i=r=void 0,c=N,a=e.apply(L,A),a}function m(N){return c=N,s=setTimeout(x,t),d?h(N):a}function v(N){var A=N-u,L=N-c,W=t-A;return f?pT(W,o-L):W}function y(N){var A=N-u,L=N-c;return u===void 0||A>=t||A<0||f&&L>=o}function x(){var N=r1();if(y(N))return w(N);s=setTimeout(x,v(N))}function w(N){return s=void 0,p&&i?h(N):(i=r=void 0,a)}function k(){s!==void 0&&clearTimeout(s),c=0,i=u=r=s=void 0}function S(){return s===void 0?a:w(r1())}function C(){var N=r1(),A=y(N);if(i=arguments,r=this,u=N,A){if(s===void 0)return m(u);if(f)return s=setTimeout(x,t),h(u)}return s===void 0&&(s=setTimeout(x,t)),a}return C.cancel=k,C.flush=S,C}function n1(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function hT(e){return!!e&&typeof e=="object"}function gT(e){return typeof e=="symbol"||hT(e)&&dT.call(e)==tT}function z4(e){if(typeof e=="number")return e;if(gT(e))return O4;if(n1(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=n1(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(rT,"");var n=iT.test(e);return n||oT.test(e)?aT(e.slice(2),n?2:8):nT.test(e)?O4:+e}var vT=mT,bT=oi(vT);function yT(e,t,n){var i=Ne(function(o){return bT(o,t,n)},[t,n]),r=De(i(e));return de(function(){r.current=i(e)},[e,i]),r.current}function wT(e,t){var n=De(!1);typeof t<"u"&&!Array.isArray(t)?t=[t]:Array.isArray(t)&&t.length===0&&console.warn("Using [] as the second argument makes useDidUpdate a noop. The second argument should either be `undefined` or an array of length greater than 0."),de(function(){n.current?e():n.current=!0},t),de(function(){return function(){n.current=!1}},[])}var M4=typeof window>"u"?de:zs;function xT(e,t){t===void 0&&(t=!1);var n=t?M4:de,i=De(e);return n(function(){i.current=e}),i}function kT(e){var t=xT(e);function n(){for(var i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];typeof t.current=="function"&&t.current.apply(t,i)}return n}var CT=process.env.NODE_ENV!=="production",j4=function(){};if(CT){var _T=function(e){var t="Warning: ".concat(e);typeof console<"u"&&console.error(t);try{throw new Error(t)}catch{}};j4=function(e,t){e||_T(t)}}function $T(e,t,n,i,r,o){i===void 0&&(i={}),r===void 0&&(r=!0),o===void 0&&(o=!1);var a=kT(n),s=o?M4:de;s(function(){return j4(typeof e<"u","[useGlobalObjectEventListener]: Cannot attach event handlers to undefined."),typeof e<"u"&&r?(e.addEventListener(t,a,i),function(){e.removeEventListener(t,a,i)}):function(){}},[t,i])}function ST(e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1),typeof window<"u"?$T(window,"resize",e,{passive:!0},t,n):console.warn("useOnWindowResize can't attach an event listener as window is undefined.")}var F4="...",NT=0,Ls=function(){return"__clamp_text_key__".concat(NT++)};function TT(e){var t=e.text,n=e.ellipsis,i=n===void 0?F4:n,r=e.lines,o=r===void 0?3:r,a=e.expanded,s=a===void 0?!1:a,u=e.debounceTime,c=u===void 0?300:u,d=e.charWidth,f=d===void 0?1.2:d,p=G(function(){return{noClamp:!1,clampedText:".",key:Ls()}}),h=p[0],m=h.noClamp,v=h.clampedText,y=h.key,x=p[1],w=De(),k=De(0),S=Ne(function(N){var A=N.lineHeight,L=N.originalText,W=N.expanded,j=N.ellipsis,H=N.lines,Y=N.charWidth,X=w.current;if(!X)return;if(!L||W){x({noClamp:!0,clampedText:L,key:Ls()});return}var Z=A*H+1,D=0;typeof j=="string"?D=j===F4?5:Math.ceil(j.length*Y):typeof j=="number"&&(D=Math.ceil(j*Y));var I=0,F=0,R=L.length;if(!X.clientHeight)return;function te(){var re,ue=(re=X?.clientHeight)!==null&&re!==void 0?re:1;ue<=Z?I=F+1:R=F-1}for(;I<=R;){if(F=Math.floor((I+R)/2),X.innerText=L.slice(0,F),F===L.length){x({clampedText:L,noClamp:!0,key:Ls()});return}te()}var B=L.slice(0,Math.max(F-D,0)).trim()+(typeof j=="string"?j:"");X.innerText=B,x({noClamp:!1,clampedText:B,key:Ls()})},[]),C=yT(S,c);return ST(function(){return C({lineHeight:k.current,originalText:t,expanded:s,ellipsis:i,lines:o,charWidth:f})}),QN(function(){var N,A;if(t&&!k.current){var L=((A=(N=w.current)===null||N===void 0?void 0:N.clientHeight)!==null&&A!==void 0?A:1)+1;k.current=L,S({lineHeight:L,originalText:t,expanded:s,ellipsis:i,lines:o,charWidth:f})}}),wT(function(){S({lineHeight:k.current,originalText:t,expanded:s,ellipsis:i,lines:o,charWidth:f})},[s,t,f,i,o]),[w,{noClamp:m,clampedText:v,key:y}]}const ET=({description:e,showDetails:t})=>{const[n,{noClamp:i,clampedText:r,key:o}]=TT({text:e,ellipsis:12.5,lines:3});return e?l(U,{variant:"body6",className:"text-[var(--pt-card-description-text)]",children:g("span",{ref:n,className:"w-full inline-block",children:[r,!i&&g(tt,{children:["...",l(rn,{onClick:a=>{t(),a?.stopPropagation()},className:"!inline",children:l(U,{variant:"body6",className:"text-[var(--pt-card-description-link)] border-b border-[var(--pt-card-description-link)]",children:"See more"})})]})]},o)}):null},Ps=({plan:e,interval:t,featureOrderMap:n,isPricePage:i,isCustomerPortal:r=!1,statusTag:o,addPriceButton:a,buttonText:s,isCurrentPlan:u,planActions:c,cardAction:d,buttonAction:f})=>{const p=!i&&!r,{theme:h,cssVars:m}=Yd(p,r),{setPlans:v}=I4(),{shouldShowDescription:y}=Ds({selectedInterval:t,publishedOnly:i}),[x,w]=G(!1);if(de(()=>{e&&v(se=>[...se,e])},[e,v]),!e)return null;const{name:k,entitlements:S,base_entitlements_plan_name:C,is_free:N,is_custom:A,custom_cta_text:L,description:W,price_options:j,entitlement_price_options:H,credit_attachment_price_options:Y,credit_attachments:X,trial_duration_unit:Z,trial_duration_value:D,version_id:I,is_visible:F,is_invoiceable:R,status:te}=e,B=H.map((se,Oe)=>({item:se,index:Oe})).sort((se,Oe)=>{const Ce=se.item.price.owner?.feature?.id,Pe=Oe.item.price.owner?.feature?.id,ze=n.get(Ce)??Number.MAX_SAFE_INTEGER,nt=n.get(Pe)??Number.MAX_SAFE_INTEGER;return ze===nt?se.index-Oe.index:ze-nt}).map(({item:se})=>se),re=Bf(t,[...j,...B,...Y]),ue=Z&&D,ae=D===1?Z:`${Z}s`,Q=xl([...S]).filter(se=>se?.is_visible),le=xy(Q,n),_e=X?.filter(se=>se.included_allowance);if(!re&&!N&&!A&&i||!F&&i||!R&&i||!re&&te!==Zf.DRAFT&&(j?.length>0||H?.length>0||Y?.length>0))return null;const Se=se=>l(YN,{trialTag:ue&&l(Wn,{background:"bg-[var(--pt-free-trial-bg)]",textColor:"text-[var(--pt-free-trial-text)]",size:"small",children:l(U,{variant:"body6",className:"text-[var(--pt-free-trial-text)]",children:`${D} ${ae} Free trial`})}),offering:e,interval:t,priceOptions:j,entitlementPriceOptions:B,creditAttachmentPriceOptions:Y,isPricePage:i,versionId:I,showMoreCard:se,showMore:()=>w(!0),isFree:N,isCustom:A,addPriceButton:a}),he="relative flex-[0_0_auto] w-[330px] cursor-pointer",Ae=A?L:N?"Join for free":ue?`Start ${D} ${ae} free trial`:"Subscribe",xe=i?Ae:s,Ie=()=>{f?.()},me=u?"var(--pt-current-sub-card-radius, var(--pt-card-radius, 1rem))":"var(--pt-card-radius, 1rem)";return g(b,{className:`flex flex-col border text-wrap shrink-0 ${u?"bg-[var(--pt-current-sub-card-header-bg)]":"bg-[var(--pt-card-header-bg)]"} ${he}`,onClick:d,style:{...r||i?{}:m,...u&&!r&&!i?yl(h):{},borderRadius:me,borderColor:"var(--pt-card-border, #e5e7eb)",borderWidth:"var(--pt-card-border-width, 1px)",borderStyle:"solid"},children:[g(b,{className:"flex items-center justify-between pl-4 pr-[5px] pt-[6px] pb-[2px]",children:[l(K,{variant:"label7",className:`${u?"text-[var(--pt-current-sub-card-header-text)]":"text-[var(--pt-card-header-text)]"}`,children:k}),g(b,{className:"flex items-center gap-x-2",children:[o," ",c]})]}),g(b,{className:`flex-grow border border-[var(--pt-card-header-bg)] w-full p-2 pb-[40px] ${u?"":"bg-[var(--pt-card-bg)]"}`,style:{borderRadius:`calc(${me} - 2px)`,...u?{background:"var(--pt-card-bg)",backgroundImage:"var(--pt-card-gradient)"}:{}},children:[y&&l(b,{className:"h-[51px] mt-1",children:l(ET,{description:W,showDetails:()=>w(!0)})}),Se(),(i||r)&&l(ur,{className:"w-full !text-[var(--pt-button-text)] !bg-[var(--pt-button-bg)] mt-3",onClick:Ie,disabled:u,children:xe}),l(b,{className:"mt-4 mb-2",children:l(A4,{interval:t,showMoreCard:!1,priceOptions:j,entitlementPriceOptions:B,creditAttachmentPriceOptions:Y})}),l(b,{className:"px-2 mt-3",children:l(L4,{entitlements:le,credits:_e,baseEntitlementsPlanName:C})})]}),l(tn,{isOpen:x,onClose:()=>w(!1),title:k,size:"small",modalClassName:"!bg-[var(--pt-card-bg)]",bottomBorder:"border-[var(--pt-card-price-border)]",topContent:g(b,{className:"flex justify-between items-center gap-x-2 border-b border-[var(--pt-card-price-border)] pb-4 px-4 mb-[-16px] mx-[-16px]",children:[l(Sr,{variant:"h6",className:"text-[var(--pt-card-description-text)]",children:k}),l("span",{onClick:()=>w(!1),className:"cursor-pointer",style:{color:"var(--pt-card-description-text, theme(colors.grey.500))"},children:l(ye,{name:"circle-close",size:24,color:"currentColor"})})]}),bottomContent:g(b,{className:"flex justify-end gap-x-2",children:[l(Mi,{onClick:()=>w(!1),className:"!text-[var(--cp-modal-footer-secondary-text)] !bg-[var(--cp-modal-footer-secondary-bg)]",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width, 1px)",borderColor:"var(--cp-modal-footer-secondary-border, theme(colors.grey.200))",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:i?"Cancel":"Close"}),i&&l(ur,{onClick:Ie,className:"!text-[var(--cp-modal-footer-primary-text)] !bg-[var(--cp-modal-footer-primary-bg)]",style:{borderWidth:"var(--cp-modal-footer-primary-border-width, 0px)",borderColor:"var(--cp-modal-footer-primary-border, transparent)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:xe})]}),children:l(XN,{baseEntitlementsPlanName:C,description:W,entitlements:S,priceContent:Se(!0)})})]})},IT=async({productKey:e,checkoutUsername:t,countryCode:n})=>{const{data:i}=await He().get("/product_catalogues/public/products",{params:{product_key:e,checkout_username:t,country_code:n}});return i},DT=({productKey:e,checkoutUsername:t,countryCode:n,enabled:i=!0})=>{const[r,o]=G(null),[a,s]=G(null),[u,c]=G(!1),d=Ne(async()=>{if(i){c(!0);try{const f=await IT({productKey:e,checkoutUsername:t,countryCode:n});o(f?.data)}catch(f){const p=f,h=p?.response?.data?.data?.error||p?.message;s(h||"Failed to load public product")}finally{c(!1)}}},[e,t,n,i]);return de(()=>{i&&d()},[d,i]),{product:r,error:a,isLoading:u,refetch:d}};var Or=(e=>(e.PLAN="plan",e.ADD_ON="add_on",e.SINGLE_PURCHASE="single_purchase",e))(Or||{}),R4=(e=>(e.STRICT_AUTO_DETECT="strict_auto_detect",e.SMART_PRE_FILL="smart_pre_fill",e))(R4||{});const LT=async e=>{const{data:t}=await He().get(`/product_catalogues/public/localization-settings?checkout_username=${e}`);return t},PT=e=>{const[t,n]=G(null),[i,r]=G(!0);return de(()=>{(async()=>{try{const o=await LT(e);n(o?.data)}catch{}finally{r(!1)}})()},[e]),{settings:t,loading:i}},AT=async(e,t)=>{const{data:n}=await He().get(`/product_catalogues/public/products/${e}/localizations?status=active&checkout_username=${t}`);return n},OT=(e,t,n=!0)=>{const[i,r]=G([]),[o,a]=G(null),[s,u]=G(n);return de(()=>{if(!n){u(!1);return}e&&(async()=>{try{const c=(await AT(e,t))?.data;r(c?.localizations||[]),a(c?.tenant_country||null)}catch{}finally{u(!1)}})()},[e,t,n]),{localizations:i,tenantCountry:o,loading:s}},zT=(e=!0)=>{const[t,n]=G(void 0),[i,r]=G(!0),[o,a]=G(null);return de(()=>{if(!e){r(!1);return}r(!0),(async()=>{try{const s="https://api.bigdatacloud.net/data/reverse-geocode-client",u=(await ef.get(s)).data;u&&n({code:u.countryCode,name:u.countryName})}catch(s){a(s)}finally{r(!1)}})()},[e]),{country:t,loading:i,error:o}},As="GLOBAL",i1=(e,t)=>{const[n,i]=G(void 0),[r,o]=G(""),{settings:a,loading:s}=PT(t),u=a?.selection===R4.SMART_PRE_FILL,{localizations:c=[],loading:d}=OT(e,t,u),f=Re(()=>new Set(c.map(S=>S.country_code)),[c]),{country:p,loading:h,error:m}=zT(u),v=Re(()=>{const S=c?.map(C=>({country_code:C.country_code,currency_code:C.currency_code}))??[];return[{country_code:As,currency_code:r},...S]},[c,r]),y=Re(()=>v.map(S=>S.country_code===As?{label:`Global (${S.currency_code} ${Tt(S.currency_code)})`,value:S.country_code}:{label:`${av(S.country_code)} ${ov(S.country_code)} (${Tt(S.currency_code)})`,value:S.country_code}),[v]),x=Re(()=>{if(!(!u||!p))return f.has(p.code)?p.code:As},[u,p,f]),w=n??x;de(()=>{!n&&x&&i(x)},[n,i,x]);const k=Re(()=>w===As?void 0:w,[w]);return{selectedCountry:w,setSelectedCountry:i,setOfferingCurrency:o,allLocalizations:y,showLocalizationDropdown:u,apiCountryCode:k,isResolvingLocalization:s||!(!u||!d&&!h&&(w||m))}},MT=({selectedTab:e,setSelectedTab:t,tabOptions:n})=>l(b,{className:"w-full flex justify-center border-b border-[var(--pt-tabs-border)] mb-6",children:n.map(i=>{const r=e===i.value;return l(b,{className:`px-4 py-2 text-center cursor-pointer ${r?"border-b border-[var(--pt-tabs-indicator)]":""}
81
81
  `,onClick:()=>t(i.value),children:l(K,{variant:"label7",color:r?"text-[var(--pt-tabs-active-text)]":"text-[var(--pt-tabs-inactive-text]",children:i.label})},i.value)})}),U4=ui()(D4(e=>({singlePurchaseItems:[],setSinglePurchaseItems:t=>e({singlePurchaseItems:t})}),{name:"metrifox:cart",storage:e1(()=>localStorage)})),jT=({value:e,onChange:t,min:n=0,max:i=1/0,step:r=1,disabled:o=!1,className:a=""})=>{const s=()=>{e>n&&t(e-r)},u=()=>{e<i&&t(e+r)},c="min-h-6 min-w-6 flex items-center justify-center rounded-lg bg-grey-200 hover:bg-grey-100 disabled:cursor-not-allowed",d=()=>{e===0&&t(1)};return g(b,{className:`flex items-center overflow-hidden w-fit gap-x-2 ${a}`,children:[l("button",{type:"button",onClick:s,disabled:o||e<=n,className:c,"aria-label":"Decrease quantity",children:l(ye,{name:"minus",size:16,color:"metrifox-black"})}),l(Bi,{value:e.toString(),onChange:f=>/^\d*$/.test(f.target.value)?t(Number(f.target.value)):null,onBlur:d,className:"text-center [&_input]:text-center w-[102px] max-w-[102px]",size:"x-small"}),l("button",{type:"button",onClick:u,disabled:o||e>=i,className:c,"aria-label":"Increase quantity",children:l(ye,{name:"add",size:16,color:"metrifox-black"})})]})},FT=e=>{const{singlePurchaseItems:t,setSinglePurchaseItems:n}=U4(),[i,r]=G(1),{price_options:o}=e,a=o[0],s=t.find(p=>p.item.version_id===e.version_id),u=()=>{const p=t.filter(h=>h.item.version_id!==e.version_id);n(p),r(1)},c=p=>{const h={item:e,priceOption:a,quantity:p||i},m=t.findIndex(v=>v.item.version_id===e.version_id);if(m>=0){const v=[...t];v[m]=h,n(v)}else n([...t,h])},d=p=>{r(p),p===0?u():s&&c(p)},f=!!s;return de(()=>{s&&r(s.quantity)},[s]),{inCart:f,quantity:i,removeItemFromCart:u,handleQuantity:d,addItemToCart:c}},RT=({singlePurchase:e})=>{const{quantity:t,inCart:n,handleQuantity:i,addItemToCart:r,removeItemFromCart:o}=FT(e.published_version),{price_options:a,description:s,name:u,is_visible:c}=e.published_version,d=a[0],f=d?.price.currency,p=d?.price.price?.toString().split("."),h=p?p[0]:"0",m=p&&p.length>1?p[1]:"00";return c?g(b,{className:"flex flex-col bg-[var(--pt-card-header-bg)] rounded-2xl border border-grey-100 w-full min-h-[187px]",children:[l(b,{className:"px-4 pt-2 pb-[2px]",children:l(K,{variant:"label7",className:"text-[var(--pt-card-header-text)]",children:u})}),g(b,{className:"flex flex-col flex-grow bg-[var(--pt-card-bg)] rounded-[14px] border border-[var(--pt-card-header-bg)] w-full p-2",children:[l(b,{className:"bg-[var(--pt-card-price-bg)] border border-[var(--pt-card-price-border)] rounded-2xl p-2 mb-3 ",children:g(b,{className:"flex items-end text-[var(--pt-card-price-amount)]",children:[g(K,{variant:"label3",children:[Tt(f),h]}),g(K,{variant:"label6",className:"mb-[5px]",children:[".",m]})]})}),l(U,{variant:"body5",className:"mb-3 flex-1 text-[var(--pt-card-description-text)]",children:s}),g(b,{className:"flex justify-between items-center gap-x-6",children:[l(jT,{value:t,onChange:i,className:"!w-max"}),n&&l(rn,{className:"w-fit !text-[var(--pt-button-link)]",onClick:o,trailingIcon:"trash",children:"Remove from cart"}),!n&&l(ur,{className:"w-fit !text-[var(--pt-button-text)] !bg-[var(--pt-button-bg)]",onClick:()=>r(),children:"Add to cart"})]})]})]}):null},UT=({singlePurchases:e,checkoutUsername:t})=>{const{webAppUrl:n}=pr.getState(),{singlePurchaseItems:i}=U4(),[r,o]=G(""),a=!!i?.length,s=()=>{const c=window.open(`${n||ii}/${t}/checkout`,"_blank"),d=i;let f=!1;function p(h){switch(h.data.type){case"READY":c?.postMessage({v:1,type:"INIT_CART",payload:d},"*");break;case"ACK":f=!0,window.removeEventListener("message",p);break}}window.addEventListener("message",p),setTimeout(()=>{f||(Ct.error("Checkout failed to initialize. Please try again.",{position:"top-center"}),c?.close())},4e3)},u=Re(()=>{const c=r.toLowerCase();return e?.filter(d=>d.published_version.name.toLowerCase().includes(c))},[r,e]);return l(sf,{children:g(b,{children:[l(b,{className:"flex items-center justify-between px-4 pb-4",children:l(Bi,{className:"w-[281px]",leadingContent:l(ye,{name:"search",size:16}),value:r,placeholderText:"Search",onChange:c=>o(c.target.value),trailingContent:r&&l(Qc,{icon:"circle-close-filled",size:18,color:"grey-500",className:"!px-0",onClick:()=>o("")})})}),g(b,{className:`grid gap-4 px-4 lg:grid-cols-3 max-lg:grid-cols-2 max-sm:grid-cols-1 ${a?"pb-[72px]":""}`,children:[u?.map(c=>l(RT,{singlePurchase:c},c.id)),a&&l(b,{className:"max-w-[1089px] w-full bottom-4 max-md:bottom-0 left-1/2 -translate-x-1/2 fixed flex justify-end",children:g(b,{className:"max-md:w-full w-full flex items-center justify-between gap-x-6 border border-[var(--pt-checkout-bar-border)] bg-[var(--pt-checkout-bar-bg)] rounded-lg py-2 px-4 max-md:rounded-none max-md:pb-4",children:[l(b,{className:"flex items-center gap-x-1",children:g(U,{variant:"body4",className:"text-[var(--pt-checkout-bar-text)]",children:[i?.length," item",i?.length!==1?"s":""," ","in cart"]})}),l(ur,{onClick:s,className:"!bg-[var(--pt-checkout-bar-button-bg)] !text-[var(--pt-checkout-bar-button-text)]",children:"Proceed to checkout"})]})})]})]})})},VT=({checkoutUsername:e,productKey:t,plansOnly:n,singlePurchasesOnly:i,showTabHeader:r=!0,theme:o,currentPlanOfferingKey:a})=>{const{webAppUrl:s}=pr.getState(),{cssVars:u}=Yd(void 0,void 0,o),{selectedCountry:c,setSelectedCountry:d,allLocalizations:f,showLocalizationDropdown:p,apiCountryCode:h,isResolvingLocalization:m,setOfferingCurrency:v}=i1(t,e),{product:y,isLoading:x}=DT({productKey:t,checkoutUsername:e,countryCode:h,enabled:!m}),[w,k]=G(Or.PLAN),S=y?.plans,C=y?.single_purchases,{intervals:N,selectedInterval:A,setSelectedInterval:L}=Qd(S),{featureOrderMap:W}=kl(S||[]),j=n||!n&&!i,H=i||!n&&!i,Y=[...j?[{label:"Plan and pricing",value:Or.PLAN}]:[],...H&&C?.length>0?[{label:"Single purchases",value:Or.SINGLE_PURCHASE}]:[]],X=I=>{k(I)},Z=I=>{const F=`${s||ii}/${e}/checkout/${I}?billing_period=${A}${p&&c?`&localization=${c}`:""}`;window.open(F,"_blank")};de(()=>{!j&&H?k(Or.SINGLE_PURCHASE):j&&!H&&k(Or.PLAN)},[j,H]),de(()=>{y?.currency_code&&v(y.currency_code)},[y,v]);const D=l(b,{className:"max-w-[1089px] mx-auto px-4",children:g("div",{className:"animate-pulse space-y-4 py-10",children:[l("div",{className:"flex justify-center mb-10",children:l("div",{className:"h-10 w-40 bg-grey-200 rounded-lg"})}),l("div",{className:"w-full flex items-center mb-4 gap-x-4",children:[1,2,3].map(I=>l("div",{className:"h-[500px] bg-grey-200 rounded-lg flex-grow"},I))})]})});return x||m?D:l(b,{className:"flex justify-center",style:{...u,fontFamily:"var(--pt-font-family)"},children:g(b,{className:"group w-full max-w-[1089px] bg-transparent h-full rounded-2xl md:px-6 py-5",children:[l(b,{className:"flex justify-between items-center mb-4",children:r&&l(MT,{selectedTab:w,setSelectedTab:I=>X(I),tabOptions:Y})}),j&&w===Or.PLAN&&g(tt,{children:[g(b,{className:`flex items-center mb-4 ${p&&f.length>0?"justify-between relative":"justify-center"}`,children:[l(b,{className:p&&f.length>0?"absolute left-1/2 transform -translate-x-1/2":"",children:l(Xd,{selectedInterval:A,intervals:N,setSelectedInterval:L})}),p&&f.length>0&&l(Jd,{value:c||"",onChange:d,options:f,disabled:m,placeholderText:"Select Country"})]}),l(b,{className:"flex gap-x-2 overflow-x-auto whitespace-nowrap px-6 py-4 -mx-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-track]:bg-grey-100 [&::-webkit-scrollbar-thumb]:bg-grey-300 [&::-webkit-scrollbar-thumb]:rounded-full",children:S?.map(I=>l(Ps,{plan:I?.published_version,interval:A,featureOrderMap:W,buttonAction:()=>Z(I.offering_key),isPricePage:!0,isCurrentPlan:a!=null&&I.offering_key===a},I.id))})]}),H&&w===Or.SINGLE_PURCHASE&&l(UT,{singlePurchases:C,checkoutUsername:e})]})})},ZT=async({product_key:e,customer_key:t,country_code:n})=>{const{data:i}=await He().get("/sdk/product_catalogues/products/published-plans",{params:{...e&&{product_key:e},...t&&{customer_key:t},...n&&{country_code:n}}});return i},V4=({product_key:e,customer_key:t,country_code:n})=>{const[i,r]=G(null),[o,a]=G(!1),s=Ne(async()=>{a(!0);try{const u=await ZT({...e&&{product_key:e},...t&&{customer_key:t},...n&&{country_code:n}});r(u?.data)}catch(u){Ct.error(u instanceof Error?u.message:"Failed to load product plans")}finally{a(!1)}},[e,t,n]);return de(()=>{s()},[s]),{productPlans:i,isLoading:o,refetch:s}},BT=({product:e,tenantDetails:t})=>{const{customerKey:n,setPlans:i}=Hr(),r=e?.product_key,o=t?.tenant_checkout_username??"",a=e?.subscription&&(e.subscription.status===ut.ACTIVE||e.subscription.status===ut.IN_TRIAL),s=!a,{selectedCountry:u,setSelectedCountry:c,allLocalizations:d,showLocalizationDropdown:f,isResolvingLocalization:p,setOfferingCurrency:h,apiCountryCode:m}=i1(r??"",o),{productPlans:v}=V4({product_key:r,customer_key:n,...!a&&m&&{country_code:m}}),y=Re(()=>{const N=v?.plans||[],A=new Map;return N.forEach(L=>{L.is_visible&&(!A.get(L.offering_key)||L.is_current_plan)&&A.set(L.offering_key,L)}),Array.from(A.values())},[v]),x=Re(()=>y?.findIndex(N=>N?.is_current_plan)??-1,[y]),{intervals:w,selectedInterval:k,setSelectedInterval:S}=Qd(y||[]),C=N=>{const A=s&&f&&u?`&localization=${u}`:"",L=N+`&billing_period=${k}${A}`;window.open(L,"_blank","noopener,noreferrer")};return de(()=>{y&&y?.length>0&&i(y)},[y,i]),de(()=>{e?.subscription?.currency_code&&h(e.subscription.currency_code)},[e?.subscription?.currency_code,h]),!y||y?.length===0?null:l(dr,{title:"Plan",action:null,className:"min-w-0",children:g(b,{className:"bg-[var(--cp-section-content-bg)] border border-[var(--cp-section-content-border)] rounded-[var(--cp-section-content-radius)] mt-2 min-w-0",style:{padding:"var(--cp-section-content-padding)"},children:[w.length>0&&g(b,{className:`flex items-center mb-2.5 ${s&&f&&d.length>0?"justify-between relative":"justify-center"}`,children:[l(b,{className:s&&f&&d.length>0?"absolute left-1/2 transform -translate-x-1/2":"",children:l(Xd,{selectedInterval:k,intervals:w,setSelectedInterval:S,isCustomerPortal:!0})}),s&&f&&d.length>0&&l(Jd,{value:u||"",onChange:c,options:d,disabled:p,placeholderText:"Select Country"})]}),l(b,{className:"flex gap-x-2 overflow-x-auto whitespace-nowrap px-6 py-4 -mx-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-track]:bg-grey-100 [&::-webkit-scrollbar-thumb]:bg-grey-300 [&::-webkit-scrollbar-thumb]:rounded-full",children:y?.map((N,A)=>{const L=N?.is_current_plan,{featureOrderMap:W}=kl(y||[]),j=L?"Current plan":A>=x?"Upgrade":"Downgrade";return l(Ps,{plan:N,featureOrderMap:W,interval:k,buttonText:j,buttonAction:()=>C(N?.checkout_url),isCurrentPlan:L,isCustomerPortal:!0},N.id)})})]})})},WT=()=>l(b,{className:"flex justify-center items-center gap-x-2 py-4",children:g(b,{className:"flex items-center gap-1",children:[l(U,{variant:"body7",color:"text-metrifox-black",children:"Powered by"}),l(Hf,{height:30,width:100})]})}),HT=async({subscriptionId:e})=>{const{data:t}=await He().get(`/sdk/subscriptions/${e}/grouped-items`);return t},KT=({subscriptionId:e})=>{const[t,n]=G(null),[i,r]=G(!1),o=Ne(async()=>{if(!e){Ct.error("Missing subscriptionId");return}r(!0);try{const a=await HT({subscriptionId:e});n(a?.data)}catch(a){Ct.error(a instanceof Error?a.message:"Failed to load subscription items")}finally{r(!1)}},[e]);return de(()=>{o()},[o]),{items:t,isLoading:i,refetch:o}},GT=async()=>{const{data:e}=await He().get("/sdk/subscription-settings");return e},JT=()=>{const[e,t]=G(null),[n,i]=G(!1),r=Ne(async()=>{i(!0);try{const o=await GT();t(o?.data)}catch(o){Ct.error(o instanceof Error?o.message:"Failed to load subscription items")}finally{i(!1)}},[]);return de(()=>{r()},[r]),{settings:e,isLoading:n,refetch:r}},qT=async e=>{const{data:t}=await He().delete(`/sdk/subscriptions/${e}/cancel-scheduled-subscription`);return t},YT=({subscriptionId:e,isOpen:t,onClose:n,changeType:i})=>{const r=i===Gr.ADDON_REMOVE?"add-on removal":i,o="Cancel scheduled change?",a=`You are about to cancel the scheduled ${r} for this subscription. Do you want to continue?`,[s,u]=G(!1),{customerRefetch:c}=Hr();return l(tn,{size:"small",title:o,isOpen:t,onClose:n,bottomContent:g(b,{className:"flex justify-end gap-x-2",children:[l(nn,{className:"!bg-[var(--cp-modal-footer-secondary-bg)] !text-[var(--cp-modal-footer-secondary-text)]",onClick:n,size:"x-small",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width)",borderColor:"var(--cp-modal-footer-secondary-border)",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:"Cancel"}),l(ur,{className:"!text-[var(--cp-modal-footer-primary-text)] !bg-[var(--cp-modal-footer-primary-bg)]",onClick:async()=>{u(!0);try{const d=await qT(e);Ct.success(d.message),u(!1),n(),c()}catch(d){Ct.error(d instanceof Error?d.message:"An error ocurred"),u(!1)}},size:"x-small",isLoading:s,disabled:s,style:{borderWidth:"var(--cp-modal-footer-primary-border-width)",borderColor:"var(--cp-modal-footer-primary-border)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:"Continue"})]}),showCloseButton:!1,className:"bg-metrifox-white",children:l(U,{variant:"body4",className:"text-[var(--cp-modal-desc-color)]",children:a})})},XT=async e=>{const{data:t}=await He().post("/sdk/subscriptions/schedule-cancellation",e);return t},QT=({subscriptionId:e,isOpen:t,onClose:n})=>{const[i,r]=G(!1),{customerRefetch:o}=Hr();return g(tn,{size:"small",title:"Cancel subscription?",isOpen:t,onClose:n,bottomContent:g(b,{className:"flex justify-end gap-x-2",children:[l(nn,{className:"!bg-[var(--cp-modal-footer-secondary-bg)] !text-[var(--cp-modal-footer-secondary-text)]",onClick:n,size:"x-small",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width)",borderColor:"var(--cp-modal-footer-secondary-border)",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:"Cancel"}),l(ur,{className:"!bg-[var(--cp-modal-footer-primary-bg)] !text-[var(--cp-modal-footer-primary-text)]",onClick:async()=>{r(!0);try{const a=await XT({id:e});Ct.success(a.message),r(!1),n(),o()}catch(a){Ct.error(a instanceof Error?a.message:"An error ocurred"),r(!1)}},size:"x-small",isLoading:i,disabled:i,style:{borderWidth:"var(--cp-modal-footer-primary-border-width)",borderColor:"var(--cp-modal-footer-primary-border)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:"Confirm"})]}),showCloseButton:!1,className:"bg-metrifox-white",children:[l(K,{variant:"label7",className:"text-[var(--cp-modal-title-color)]",children:"Are you sure you want to proceed?"}),l(U,{variant:"body4",className:"mt-5 text-[var(--cp-modal-desc-color)]",children:"This subscription is scheduled to be canceled at the end of the billing cycle"})]})},eE=async e=>{const{data:t}=await He().post("/sdk/subscriptions/revert-cancellation",e);return t},tE=({subscriptionId:e,isOpen:t,onClose:n})=>{const[i,r]=G(!1),{customerRefetch:o}=Hr();return g(tn,{size:"small",title:"Undo cancellation?",isOpen:t,onClose:n,bottomContent:g(b,{className:"flex justify-end gap-x-2",children:[l(nn,{className:"!bg-[var(--cp-modal-footer-secondary-bg)] !text-[var(--cp-modal-footer-secondary-text)]",onClick:n,size:"x-small",style:{borderWidth:"var(--cp-modal-footer-secondary-border-width)",borderColor:"var(--cp-modal-footer-secondary-border)",borderRadius:"var(--cp-modal-footer-secondary-radius)",borderStyle:"solid"},children:"Cancel"}),l(ur,{className:"!text-[var(--cp-modal-footer-primary-text)] !bg-[var(--cp-modal-footer-primary-bg)]",onClick:async()=>{r(!0);try{const a=await eE({id:e});Ct.success(a.message),r(!1),n(),o()}catch(a){Ct.error(a instanceof Error?a.message:"An error ocurred"),r(!1)}},size:"x-small",isLoading:i,disabled:i,style:{borderWidth:"var(--cp-modal-footer-primary-border-width)",borderColor:"var(--cp-modal-footer-primary-border)",borderRadius:"var(--cp-modal-footer-primary-radius)",borderStyle:"solid"},children:"Next"})]}),showCloseButton:!1,className:"bg-metrifox-white",children:[l(U,{variant:"body4",className:"text-[var(--cp-modal-desc-color)]",children:"Keep subscription active?"}),l(U,{variant:"body4",className:"mt-5 text-[var(--cp-modal-desc-color)]",children:"The subscription would keep going and renew as usual."})]})},rE={"bottom-end":"right-0 top-full mt-1","bottom-start":"left-0 top-full mt-1","top-end":"right-0 bottom-full mb-1","top-start":"left-0 bottom-full mb-1"},nE=({trigger:e,children:t,position:n="bottom-end",disabled:i=!1,triggerClassName:r="",panelClassName:o="",className:a=""})=>{const[s,u]=G(!1),c=De(null);c0(c,()=>u(!1));const d=()=>u(!1),f=()=>!i&&u(h=>!h),p={onClick:()=>f(),"aria-haspopup":!0,"aria-expanded":s,"aria-disabled":i,className:r};return g("div",{className:`relative inline-block ${a}`,ref:c,children:[e(p),s&&l("div",{className:`absolute z-[100] overflow-hidden ${rE[n]} ${o}`,role:"menu",children:typeof t=="function"?t(d):t})]})},iE="inline-flex items-center justify-center text-[var(--cp-popover-trigger-icon-color)] hover:opacity-80 !bg-transparent !border-0 cursor-pointer p-1 outline-none",oE="min-w-[10rem] py-1 rounded-[var(--cp-popover-menu-radius)] bg-[var(--cp-popover-menu-bg)] border border-[var(--cp-popover-menu-border)] shadow-lg",aE="block w-full text-left p-[var(--cp-popover-menu-item-padding)] text-[var(--cp-popover-menu-item-text)] hover:bg-[var(--cp-popover-menu-item-hover-bg)] transition-colors cursor-pointer border-0 border-b border-b-[var(--cp-popover-menu-divider)] last:border-b-0 bg-transparent",sE=({actions:e,disabled:t=!1})=>e.length===0?null:l(nE,{position:"bottom-end",disabled:t,triggerClassName:iE,panelClassName:oE,trigger:n=>l(Qc,{...n,icon:"more",size:24,color:"currentColor","aria-label":"Subscription actions"}),children:n=>l(b,{className:"flex flex-col",children:e.map((i,r)=>l("button",{type:"button",className:`${aE} ${i.danger?"!text-[var(--cp-popover-menu-item-danger-text)]":""}`,onClick:()=>{i.onClick(),n()},children:l(U,{variant:"body6",as:"span",children:i.label})},r))})}),lE=({subscriptionLineItems:e,handleUpdateQuantity:t,canUpdateQuantities:n,subscription:i,tenantDetails:r})=>{const{webAppUrl:o}=pr.getState(),a=()=>{const c=r?.tenant_checkout_username,d=i?.offering_key,f=i?.id;if(!c||!d||!f)return;const p=`${o||ii}/${c}/${d}/addons?subscription=${f}&manage=addon_add`;window.open(p,"_blank","noopener,noreferrer")},s=e.filter(c=>c.offering_type===wl.PLAN),u=e.filter(c=>c.offering_type===wl.ADDON);return g(b,{className:"mt-8",children:[g(b,{className:"flex items-center justify-between mb-4",children:[l(Sr,{variant:"h5",className:"text-[var(--cp-section-header-color)]",style:{fontSize:"var(--cp-section-header-size)",fontWeight:"var(--cp-section-header-weight)"},children:"Subscription items"}),n&&l(rn,{className:"!text-[var(--cp-link-color,#3b82f6)] underline !p-0 font-medium",onClick:c=>{c?.stopPropagation(),t()},children:"Manage item quantities"})]}),g(b,{"data-testid":"subscription-items-container",className:"rounded-[var(--cp-section-content-radius)] overflow-hidden bg-[var(--cp-section-content-bg,var(--color-gray-50))] border border-[var(--cp-section-content-border,var(--color-gray-200))]",style:{padding:"var(--cp-section-content-padding)"},children:[s.length>0&&s.map(c=>g(b,{children:[l(b,{className:"mb-3 mt-4",children:l(K,{variant:"label8",className:"text-[var(--cp-section-label-color)]",style:{fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:"Plan"})}),l(b,{className:"space-y-2",children:c?.items?.map(d=>l(Z4,{item:d},d.id))})]},c?.offering_key)),u.length>0&&g(b,{className:"mt-4",children:[g(b,{className:"relative z-[100] flex items-center justify-between mb-3 mt-4",children:[l(K,{variant:"label8",className:"text-[var(--cp-section-label-color)]",style:{fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:"Add-ons"}),l(Mi,{size:"small",onClick:a,className:"!bg-[var(--cp-btn-secondary-bg)] !text-[var(--cp-btn-secondary-text)] !border-[var(--cp-btn-secondary-border)] !rounded-[var(--cp-btn-secondary-radius)] !px-5 !py-2",style:{fontSize:"var(--cp-btn-secondary-size)",fontWeight:"var(--cp-btn-secondary-weight)",borderWidth:"var(--cp-btn-secondary-border-width, 1px)",borderStyle:"solid"},children:" Manage add-on"})]}),l(b,{className:"space-y-2",children:u.map((c,d)=>l(cE,{item:c},d))})]})]})]})},Z4=({item:e,isChild:t})=>{const n=t?"bg-[var(--cp-subscription-child-bg,white)]":"bg-[var(--cp-subscription-item-bg,white)]",i=t?"border-[var(--cp-subscription-child-border,var(--color-gray-200))]":"border-[var(--cp-subscription-item-border,var(--color-gray-200))]",r=t?"text-[var(--cp-subscription-child-text)]":"text-[var(--cp-subscription-item-text)]",o=t?"text-[var(--cp-subscription-child-quantity,var(--color-gray-500,#6b7280))]":"text-[var(--cp-subscription-item-quantity,var(--color-gray-500,#6b7280))]";return g(b,{className:`${n} border ${i} rounded-[var(--cp-section-content-radius)] px-4 py-3 flex items-center justify-between`,children:[g(b,{className:"flex items-center gap-2",children:[l(K,{variant:"label7",className:`${r}`,style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 600)"},children:Kt(e?.name)}),e?.quantity>0&&e?.source_type!==Qo.PLAN&&g(tt,{children:[l("span",{className:`${o} opacity-75`,children:"\u2022"}),g(U,{variant:"body6",className:`${o} font-normal`,children:[e.quantity," ",e.name?.toLowerCase()]})]})]}),g(U,{variant:"body6",className:`${r}`,style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 500)"},children:[Tt(e?.currency_code),Te(e?.total_amount)]})]})},cE=({item:e})=>{const[t,n]=G(!1),i=e?.items?.filter(o=>o?.source_type===Qo.ADDON)?.[0],r=e?.items?.filter(o=>o?.source_type!==Qo.ADDON);return g(b,{className:"bg-[var(--cp-subscription-item-bg,white)] border border-[var(--cp-subscription-item-border,var(--color-gray-200))] rounded-[var(--cp-section-content-radius)] px-4 py-3",children:[g(b,{className:"flex justify-between items-center gap-2 w-full cursor-pointer",onClick:()=>{r&&r?.length>0&&n(!t)},children:[l(K,{variant:"label7",className:"text-[var(--cp-subscription-item-text)]",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 600)"},children:Kt(e?.name)}),g(b,{className:"flex justify-end items-center",children:[i&&g(U,{variant:"body6",className:"text-[var(--cp-subscription-item-text)]",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 500)"},children:[Tt(i?.currency_code),Te(i?.total_amount)]}),r&&r?.length>0&&l(ye,{name:"arrow-down",size:14})]})]}),t&&l(b,{className:"bg-[var(--cp-section-content-bg,var(--color-gray-50))] space-y-2 p-4 mt-3",children:r.map(o=>l(Z4,{item:o,isChild:!0},o.id))})]})},uE=({subscription:e,tenantDetails:t})=>{const n=e?.status,{text:i}=gy(n),{customerKey:r}=Hr(),[o,a]=G(!1),[s,u]=G(!1),[c,d]=G(!1),[f,p]=G(!1),h=De(null),{invoiceDetails:m}=Rc({invoiceId:e?.upcoming_invoice?.invoice_id||""}),{items:v}=KT({subscriptionId:e?.id}),{settings:y}=JT(),x=[{label:"Current plan",value:e?.plan_name||"-"},{label:"Status",value:i},{label:"Start date",value:ht(e?.starts_at)},...n===ut.ACTIVE?[{label:"Current billing period",value:e?.current_billing_period_start&&e?.current_billing_period_end?g(b,{children:[g(b,{className:"font-medium",children:[ht(e.current_billing_period_start)," -"," ",ht(e.current_billing_period_end)]}),l(b,{className:"mt-1 text-sm opacity-80",children:"(Auto-renew)"})]}):"-"}]:[],...n===ut.IN_TRIAL?[{label:"Trial end date",value:ht(e?.trial_end_date)},{label:"Trial period",value:e?.starts_at&&e?.trial_end_date?l(b,{children:g(b,{children:[ht(e?.starts_at)," -"," ",ht(e?.trial_end_date)]})}):"-"}]:[],...n===ut.ACTIVE?[{label:"End date",value:e?.ends_at?ht(e?.ends_at):"-"}]:[]],w=[...n===ut.ACTIVE?[{label:"Next billing date",value:e?.renews_at?ht(e?.renews_at):"-"},{label:"Invoice due",value:e?.renews_at?ht(e?.renews_at):"-"},{label:"Next estimated bill",value:e?.next_billing_amount?g(b,{className:"mt-2",children:[g(b,{className:"font-medium",children:[Tt(e.currency_code),e.next_billing_amount]}),l(b,{className:"text-sm opacity-80 mt-0.5 block",children:"(Monthly)"})]}):"-"}]:[]],k=()=>{const j=`${window.location.origin}/${t.tenant_checkout_username}/${e.offering_key}/subscriptions/${e.id}?customer=${r}`;window.open(j,"_blank","noopener,noreferrer")},S=n===ut.ACTIVE||n===ut.IN_TRIAL,C=!!e?.scheduled_change,N=e?.scheduled_change,A=[{label:"Manage",onClick:()=>{document.getElementById(B4.plan)?.scrollIntoView({behavior:"smooth"})}},...S?C?[{label:`Cancel ${N===Gr.ADDON_REMOVE?"add-on removal":N}`,onClick:()=>p(!0)}]:e?.ends_at?[{label:"Undo cancellation",onClick:()=>d(!0)}]:y?.customer_can_cancel?[{label:"Cancel subscription",onClick:()=>u(!0),danger:!0}]:[]:[]],L=()=>N===Gr.UPGRADE?`This subscription is scheduled to be upgraded on ${ht(e.renews_at)}`:N===Gr.DOWNGRADE?`This subscription is scheduled to be downgraded on ${ht(e.renews_at)}`:N===Gr.ADDON_REMOVE?`An add-on removal is scheduled to occur on ${ht(e.renews_at)}`:`This subscription is scheduled to be canceled at the end of the billing cycle on ${ht(e.ends_at)}`,W=C&&e?.renews_at||e?.ends_at&&!C;return g(tt,{children:[W&&e.status!==ut.DEACTIVATED&&g(b,{className:"py-3 px-4 flex items-center justify-between",style:{backgroundColor:"var(--cp-info-banner-bg)",borderRadius:"var(--cp-info-banner-radius)"},children:[l(K,{variant:"label8",className:"flex-1 text-center text-[var(--cp-info-banner-text)]",children:L()}),!C&&l(nn,{onClick:()=>d(!0),className:"!border-[var(--cp-info-banner-btn-border)] !text-[var(--cp-info-banner-btn-text)]",children:"Undo cancellation"}),C&&g(nn,{onClick:()=>p(!0),className:"!border-[var(--cp-info-banner-btn-border)] !text-[var(--cp-info-banner-btn-text)]",children:["Cancel"," ",N===Gr.ADDON_REMOVE?"add-on removal":N]})]}),g(dr,{title:"Subscription",action:A.length>0?l(sE,{actions:A}):null,children:[l(b,{"data-testid":"subscription-content-box",className:"bg-[var(--cp-section-content-bg,var(--color-gray-50))] border border-[var(--cp-section-content-border,var(--color-gray-200))] rounded-[var(--cp-section-content-radius)]",style:{padding:"var(--cp-section-content-padding)"},children:l(b,{className:"flex justify-between flex-wrap gap-6",children:x.map((j,H)=>g(b,{children:[l(K,{variant:"label8",className:"text-[var(--cp-section-label-color)]",style:{fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:j?.label}),l(b,{className:"text-[var(--cp-section-value-color)] mt-2",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)"},children:j.value})]},H))})}),e?.upcoming_invoice&&l(b,{className:"flex justify-end mt-2",children:l(rn,{className:"!text-[var(--cp-link-color,#3b82f6)] underline !p-0 text-sm",onClick:()=>a(!0),children:"Preview invoice"})}),w.length>0&&l(b,{"data-testid":"subscription-content-box",className:"bg-[var(--cp-section-content-bg,var(--color-gray-50))] border border-[var(--cp-section-content-border,var(--color-gray-200))] rounded-[var(--cp-section-content-radius)] mt-2",style:{padding:"var(--cp-section-content-padding)"},children:l(b,{className:"flex justify-between flex-wrap gap-6",children:w.map((j,H)=>g(b,{children:[l(K,{variant:"label8",className:"text-[var(--cp-section-label-color)]",style:{fontSize:"var(--cp-section-label-size)",fontWeight:"var(--cp-section-label-weight)"},children:j?.label}),l(b,{className:"text-[var(--cp-section-value-color)] mt-2",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight)"},children:j.value})]},H))})}),e?.subscription_items?.length>0&&l(lE,{subscriptionLineItems:v??[],handleUpdateQuantity:k,canUpdateQuantities:e?.can_update_quantities,subscription:e,tenantDetails:t}),o&&l(Fc,{isOpen:o,onClose:()=>a(!1),contentRef:h,content:l(Cl,{data:m}),modalTitle:"Invoice preview"}),l(QT,{subscriptionId:e.id,isOpen:s,onClose:()=>u(!1)}),l(tE,{subscriptionId:e.id,isOpen:c,onClose:()=>d(!1)}),l(YT,{subscriptionId:e.id,isOpen:f,onClose:()=>p(!1),changeType:e?.scheduled_change})]})]})},dE=({upcomingInvoice:e})=>{const[t,n]=G(!1),i=De(null),{invoiceDetails:r}=Rc({invoiceId:e?.invoice_id});return g(dr,{title:"Upcoming Invoice",children:[l(b,{className:"bg-[var(--cp-section-content-bg)] border border-[var(--cp-section-content-border)] rounded-[var(--cp-section-content-radius)]",style:{padding:"var(--cp-section-content-padding)"},children:g(b,{className:"w-full flex items-center justify-between mb-0",children:[g(b,{className:"flex items-center gap-3",children:[l(K,{variant:"label7",className:"text-[var(--cp-section-value-color)]",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 500)"},children:"Upcoming Invoice"}),l(b,{className:"flex items-center gap-2",children:l(Wn,{background:"bg-purple-500",size:"small",children:g(K,{variant:"label8",className:"text-metrifox-white",children:[e?.currency?.symbol,e?.amount]})})}),g(U,{variant:"body6",className:"text-[var(--cp-section-value-color)]",style:{fontSize:"var(--cp-section-value-size)",fontWeight:"var(--cp-section-value-weight, 400)"},children:["Due"," ",new Date(e?.due_date).toLocaleString(e?.currency?.country_code,{month:"short",day:"numeric",year:"numeric"})]})]}),l(rn,{className:"!text-[var(--cp-link-color)] underline cursor-pointer",onClick:()=>{n(!0)},children:"Preview invoice"})]})}),t&&l(Fc,{isOpen:t,onClose:()=>n(!1),contentRef:i,content:l(Cl,{data:r}),modalTitle:"Invoice preview"})]})},fE=[{key:"subscription"},{key:"creditBalance"},{key:"entitlementUsage"},{key:"paymentOverview"},{key:"billingHistory"},{key:"plan"}],B4={upcomingInvoice:"upcoming-invoice",subscription:"subscription",creditBalance:"credit-balance",entitlementUsage:"entitlement-usage",paymentOverview:"payment-overview",billingHistory:"billing-history",plan:"plan"},W4=({product:e,tenantDetails:t,sectionsConfig:n,customerWallets:i})=>{const r=n||fE,o={upcomingInvoice:()=>e?.subscription?.upcoming_invoice?l(dE,{upcomingInvoice:e.subscription.upcoming_invoice}):null,subscription:()=>e?.subscription?l(uE,{subscription:e.subscription,tenantDetails:t}):null,creditBalance:()=>i&&i.length>0?l(AN,{tenantDetails:t,wallets:i}):null,entitlementUsage:()=>e?.subscription?l(UN,{subscriptionId:e?.subscription?.id}):null,paymentOverview:()=>l(VN,{paymentMethod:e.payment_method,tenantDetails:t}),billingHistory:()=>e?.subscription?.id?l(bC,{subscriptionId:e.subscription?.id}):null,plan:()=>e?.product_key?l(BT,{product:e,tenantDetails:t}):null};return g(b,{className:"space-y-6 w-full min-w-0",children:[r.filter(a=>!a.hidden).map(a=>{const s=B4[a.key]??a.key;if(a.component)return l("section",{id:s,className:"w-full",children:l(a.component,{product:e,tenantDetails:t,...a.props})},a.key);const u=o[a.key],c=u?u(a.props):null;return c?l("section",{id:s,className:"w-full",children:c},a.key):null}),l(WT,{})," "]})},o1=({children:e,className:t="",style:n})=>l(b,{"data-testid":"portal-container",className:`min-h-screen w-full flex justify-center bg-[var(--cp-section-bg,var(--color-background-50))] ${t}`,style:n,children:l("div",{className:"w-full max-w-[60rem] min-w-0 space-y-8 flex flex-col items-center",style:{padding:"var(--cp-container-padding, 40px 24px)"},children:e})}),pE=({checkoutUsername:e})=>{const{webAppUrl:t}=pr.getState(),{customerKey:n}=Hr(),[i,r]=G(""),{selectedCountry:o,setSelectedCountry:a,allLocalizations:s,showLocalizationDropdown:u,isResolvingLocalization:c,setOfferingCurrency:d,apiCountryCode:f}=i1(i,e),{productPlans:p,isLoading:h}=V4({customer_key:n,...i&&f&&{country_code:f}}),m=p?.plans||[],{intervals:v,selectedInterval:y,setSelectedInterval:x}=Qd(m),{featureOrderMap:w}=kl(m||[]),k=!!(i&&u&&s.length>0);de(()=>{const C=p?.plans||[];if(C.length>0){const N=C[0],A=N?.product_currency_code,L=N?.product_key;L&&r(L),A&&d(A)}},[p,d]);const S=C=>{const N=k&&o?`&localization=${o}`:"",A=`${t||ii}/${e}/checkout/${C}?billing_period=${y}&customer=${n}${N}`;window.open(A,"_blank")};return h||i&&c?l(dr,{title:g(b,{className:"flex items-center gap-2",children:[l(b,{className:"p-1.5 bg-[var(--cp-section-icon-bg)] rounded-lg",children:l(ye,{name:"subtitle",size:18,color:"var(--cp-section-icon-color)"})}),l("span",{children:"Plan"})]}),children:l(b,{className:"flex items-center justify-center py-12",children:l(_r,{size:"big"})})}):l(dr,{title:g(b,{className:"flex items-center gap-2",children:[l(b,{className:"p-1.5 bg-[var(--cp-section-icon-bg)] rounded-lg",children:l(ye,{name:"subtitle",size:18,color:"var(--cp-section-icon-color)"})}),l("span",{children:"Plan"})]}),children:g(b,{className:"bg-[var(--cp-section-content-bg)] border border-[var(--cp-section-content-border)] rounded-[var(--cp-section-content-radius)] mt-2 min-w-0",style:{padding:"var(--cp-section-content-padding)"},children:[g(b,{className:`flex items-center mb-2.5 ${k?"justify-between relative":"justify-center"}`,children:[l(b,{className:k?"absolute left-1/2 transform -translate-x-1/2":"",children:l(Xd,{selectedInterval:y,intervals:v,setSelectedInterval:x,isCustomerPortal:!0,isPricePage:!0})}),k&&l(Jd,{value:o||"",onChange:a,options:s,disabled:c,placeholderText:"Select Country"})]}),l(b,{className:"flex gap-x-2 overflow-x-auto whitespace-nowrap px-6 py-4 -mx-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-track]:bg-grey-100 [&::-webkit-scrollbar-thumb]:bg-grey-300 [&::-webkit-scrollbar-thumb]:rounded-full",children:m?.map(C=>l(Ps,{plan:C,interval:y,featureOrderMap:w,buttonAction:()=>S(C.offering_key),isCustomerPortal:!0,isPricePage:!0},C.id))})]})})},mE=()=>l(dr,{title:g(b,{className:"flex items-center gap-2",children:[l(b,{className:"p-1.5 bg-[var(--cp-section-icon-bg)] rounded-lg",children:l(ye,{name:"money",size:18,color:"var(--cp-section-icon-color)"})}),l("span",{children:"Subscription"})]}),children:g(b,{className:"flex flex-col items-center justify-center py-6 px-4",children:[l(ye,{name:"subtitle",size:40,color:"grey-400"}),l(U,{variant:"body7",className:"text-[var(--cp-section-empty-text)] mt-2 text-center",children:"You currently have no active subscriptions."})]})}),hE=({customerKey:e,sectionsConfig:t,theme:n})=>{const[i,r]=G(0),{setCustomerKey:o,setCustomerRefetch:a}=Hr(),{cssVars:s}=Mf(n),{customerDetails:u,error:c,refetch:d,isLoading:f}=M7({customerKey:e}),{customerWallets:p}=ay({customerKey:e});if(de(()=>{o(e),a(d)},[e,d,o,a]),c)return l(o1,{style:{...s,backgroundColor:"var(--cp-bg)",borderRadius:"var(--cp-radius)",fontFamily:"var(--cp-font-family)"},children:l(b,{className:"max-w-[60rem] mx-auto py-6 px-4",children:g("div",{className:"bg-red-50 p-4 rounded-lg text-red-700",children:["Error loading customer details: ",c]})})});if(f||!u)return l(o1,{style:{...s,backgroundColor:"var(--cp-bg)",borderRadius:"var(--cp-radius)",fontFamily:"var(--cp-font-family)"},children:l(b,{className:"min-h-[200px] flex flex-col items-center justify-center gap-4 py-12 px-4",role:"status","aria-live":"polite",children:l(_r,{size:"big",color:"white"})})});const{subscriptions:h,...m}=u||{},v=h||[];return l(sf,{children:g(o1,{style:{...s,backgroundColor:"var(--cp-bg)",borderRadius:"var(--cp-radius)",fontFamily:"var(--cp-font-family)"},children:[v.length===0&&g(tt,{children:[l(mE,{}),l(pE,{checkoutUsername:m?.tenant_checkout_username})]}),v&&v.length>1?g(Sn,{className:"w-full min-w-0 flex flex-col items-center",defaultIndex:i,onChange:y=>r(y),children:[l(Nn,{className:"inline-flex items-center gap-1 bg-[var(--cp-tabs-bg)] border border-[var(--cp-tabs-border)] p-1 rounded-lg mb-8 shadow-sm",children:v.map(y=>l(Wr,{className:`px-6 py-2 rounded-md text-sm font-medium transition-all outline-none
82
82
  text-[var(--cp-tabs-inactive-text)] hover:text-gray-900 bg-transparent
83
83
  data-[selected]:bg-[var(--cp-tabs-active-bg)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metrifox/react-sdk",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "description": "React SDK for Metrifox",
6
6
  "main": "./dist/index.cjs",
@@ -20,6 +20,23 @@
20
20
  "package.json",
21
21
  "LICENSE"
22
22
  ],
23
+ "scripts": {
24
+ "clean": "rimraf dist",
25
+ "build": "pnpm clean && rollup -c",
26
+ "dev": "vite",
27
+ "dev:build": "rollup -c -w",
28
+ "dev:link": "npx yalc publish --push",
29
+ "storybook": "storybook dev -p 6006",
30
+ "build-storybook": "storybook build",
31
+ "lint": "eslint . --ignore-pattern dist",
32
+ "lint:fix": "eslint . --fix --ignore-pattern dist",
33
+ "lint:staged": "lint-staged",
34
+ "type-check": "tsc --noEmit",
35
+ "test": "vitest run",
36
+ "test:watch": "vitest",
37
+ "test:ui": "vitest --ui",
38
+ "prepare": "husky"
39
+ },
23
40
  "keywords": [
24
41
  "react",
25
42
  "sdk",
@@ -94,20 +111,23 @@
94
111
  "prettier --write"
95
112
  ]
96
113
  },
97
- "scripts": {
98
- "clean": "rimraf dist",
99
- "build": "pnpm clean && rollup -c",
100
- "dev": "vite",
101
- "dev:build": "rollup -c -w",
102
- "dev:link": "npx yalc publish --push",
103
- "storybook": "storybook dev -p 6006",
104
- "build-storybook": "storybook build",
105
- "lint": "eslint . --ignore-pattern dist",
106
- "lint:fix": "eslint . --fix --ignore-pattern dist",
107
- "lint:staged": "lint-staged",
108
- "type-check": "tsc --noEmit",
109
- "test": "vitest run",
110
- "test:watch": "vitest",
111
- "test:ui": "vitest --ui"
114
+ "pnpm": {
115
+ "overrides": {
116
+ "esbuild@<=0.24.2": ">=0.25.0",
117
+ "glob@>=10.2.0 <10.5.0": ">=10.5.0",
118
+ "glob@>=11.0.0 <11.1.0": ">=11.1.0",
119
+ "js-yaml@>=4.0.0 <4.1.1": ">=4.1.1",
120
+ "storybook@>=9.0.0 <9.1.17": ">=9.1.17",
121
+ "vite@<4.5.10": ">=4.5.10",
122
+ "vite@<4.5.11": ">=4.5.11",
123
+ "vite@<4.5.12": ">=4.5.12",
124
+ "vite@<4.5.13": ">=4.5.13",
125
+ "vite@<=4.5.13": ">=4.5.14",
126
+ "vite@<=4.5.5": ">=4.5.6",
127
+ "vite@<=5.4.19": ">=5.4.20",
128
+ "vite@>=4.0.0 <4.5.4": ">=4.5.4",
129
+ "vite@>=4.0.0 <=4.5.2": ">=4.5.3",
130
+ "vite@>=4.0.0 <=4.5.3": ">=4.5.4"
131
+ }
112
132
  }
113
- }
133
+ }