1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,663919,e=>{"use strict";var t=e.i(134530);let r={"/api/generate":"studio","/api/generate/product":"product","/api/generate/variants":"variant","/api/generate/video":"video","/api/generate/fine-tune":"fine_tune","/api/listing-pack":"listing_pack","/api/generate/batch":"batch"};async function s(e,s){let n="string"==typeof e?e.split("?")[0]:"",a=s?.method==="POST"?r[n]:void 0,i=s?.method==="POST"&&/^\/api\/payments\/(creem|paypal|waffo)\/(checkout|credit-pack-checkout)$/.test(n);try{let r=await fetch(e,s);return a&&!r.ok&&(0,t.trackEvent)([400,401,402,403,409,422,429].includes(r.status)?"generation_blocked":"generation_request_failed",{generation_kind:a,error_code:`http_${r.status}`}),i&&!r.ok&&401!==r.status&&(0,t.trackEvent)("checkout_request_failed",{error_code:`http_${r.status}`}),r}catch(e){throw a&&(0,t.trackEvent)("generation_request_failed",{generation_kind:a,error_code:"network_error"}),i&&(0,t.trackEvent)("checkout_request_failed",{error_code:"network_error"}),e}}e.s(["analyticsFetch",()=>s])},33503,e=>{"use strict";let t=1900,r=19e3,s=4900,n=49e3,a=9900,i=99e3,o=[{id:"free",name:"Free",monthlyPrice:0,yearlyPrice:0,description:"Try the basics",features:["10 credits / month","~1 try-on image / month","Up to 1K output","Standard queue","Watermarked downloads","No 3-image sets","No listing video generation"],cta:"Claim Free Credits",href:"/",credits:10},{id:"pro200",name:"Starter",monthlyPrice:t/100,yearlyPrice:r/100,description:"For new sellers creating listing-ready images",features:["600 credits / month","~60 try-on images / month","Up to 2K output","Faster queue","No watermarks","Full-resolution downloads","Up to 5 try-on image sets / month","1 listing video / month","Basic history","Email support"],cta:"Choose Starter",href:"/#pricing",credits:600},{id:"pro500",name:"Pro",monthlyPrice:s/100,yearlyPrice:n/100,description:"Best for growing stores",features:["2,000 credits / month","~200 try-on images / month","Up to 4K output","Priority queue","No watermarks","Batch generation â up to 5 images","Longer history & re-download","Create 3-image try-on sets with credits","10 listing videos / month","Advanced refine tools"],cta:"Choose Pro",href:"/#pricing",badge:"Most Popular",highlight:!0,credits:2e3},{id:"pro1000",name:"Studio",monthlyPrice:a/100,yearlyPrice:i/100,description:"For high-volume sellers",features:["4,000 credits / month","~400 try-on images / month","Up to 4K output","Highest priority queue","No watermarks","Batch generation â up to 20 images","Longer history & re-download","Priority support","Best for high-volume try-on set workflows","High-volume listing video generation","Priority video processing","Early access to new features"],cta:"Choose Studio",href:"/#pricing",badge:"Best Value",credits:4e3}],l={heading:"Choose Your Plan",usageNote:"10 credits per try-on image · 3-image sets from 18 credits · Listing video usage depends on your plan · Failed generations are not charged",monthly:"Monthly",annual:"Annual",saveLabel:"2 months free",billingToggleAriaLabel:"Billing cycle toggle",paymentMethods:{label:"Payment method",card:"Card",paypal:"PayPal"},pricePerMonth:"/mo",pricePerYear:"/yr",annualBillingNote:"Billed yearly · Credits issued monthly",freeCreditNote:"Free credits can be claimed once per month.",creditsToClaim:"credits to claim",credits:"credits",states:{processing:"Processing...",claiming:"Claiming...",redirecting:"Redirecting..."},dialogActions:{maybeLater:"Maybe Later",tryNow:"Try Now",ok:"OK"},dialogs:{currentPlan:"Current Plan",billingCycleChangeNotSupported:"Billing Cycle Change Not Supported",immediateUpgradeRequired:"Upgrade Applies Immediately",downgradeNotSupported:"Downgrade Not Supported",subscriptionCanceled:"Subscription Canceled",alreadyClaimed:"Already Claimed",claimFailed:"Claim Failed",freeCreditsReady:"Free Credits Ready"},messages:{alreadyOnPlan:"You're already on this plan.",selfServeUnavailable:"This subscription can't be changed automatically online. Contact support for help.",billingCycleChangeNotAllowed:"Switching between monthly and annual billing isn't supported. Cancel your current subscription first, then subscribe again after it ends.",scheduleChangeNotAllowed:"This plan change can't be scheduled for renewal. Upgrades apply immediately with prorated billing and a prorated credit top-up.",downgradeNotAllowed:"Downgrades aren't supported. Cancel your current subscription first, then switch plans after it ends.",subscriptionNotFound:"No active managed subscription was found for this account.",updateSubscriptionFailed:"Failed to update subscription",updateSubscriptionTryAgain:"Failed to update subscription. Please try again.",checkoutLinkFailed:"Failed to create checkout link",subscriptionFailed:"Subscription failed. Please try again.",subscriptionCanceledWithDate:"This subscription has already been canceled. Your current access remains available until {date}. Subscribe again after it ends.",subscriptionCanceledNoDate:"This subscription has already been canceled. Subscribe again after your current access ends.",trialAlreadyClaimed:"Free trial credits can be claimed once per month.",trialClaimFailed:"Failed to claim free trial credits. Please try again.",free
1CreditsReady:"Great news. {amount} free credits are now in your account. Head to the studio and try your first generation now."},plans:{free:{name:"Free",description:"Try the basics",features:["10 credits / month","~1 try-on image / month","Up to 1K output","Standard queue","Watermarked downloads","No 3-image sets","No listing video generation"],cta:"Claim Free Credits"},pro200:{name:"Starter",description:"For new sellers creating listing-ready images",features:["600 credits / month","~60 try-on images / month","Up to 2K output","Faster queue","No watermarks","Full-resolution downloads","Up to 5 try-on image sets / month","1 listing video / month","Basic history","Email support"],cta:"Choose Starter"},pro500:{name:"Pro",description:"Best for growing stores",features:["2,000 credits / month","~200 try-on images / month","Up to 4K output","Priority queue","No watermarks","Batch generation â up to 5 images","Longer history & re-download","Create 3-image try-on sets with credits","10 listing videos / month","Advanced refine tools"],cta:"Choose Pro",badge:"Most Popular"},pro1000:{name:"Studio",description:"For high-volume sellers",features:["4,000 credits / month","~400 try-on images / month","Up to 4K output","Highest priority queue","No watermarks","Batch generation â up to 20 images","Longer history & re-download","Priority support","Best for high-volume try-on set workflows","High-volume listing video generation","Priority video processing","Early access to new features"],cta:"Choose Studio",badge:"Best Value"}}};function d(e,t=l){return o.map(r=>{let s="monthly"===e?r.monthlyPrice:r.yearlyPrice;return{...r,...t.plans[r.id],displayPrice:s}})}e.s(["PLAN_RANKS",0,{pro200:1,pro500:2,pro1000:3},"defaultHomePricingCopy",0,l,"getPricedPlans",()=>d,"plans",0,o],33503)},449741,778207,e=>{"use strict";var t=e.i(271645);let r=["creem","paypal","waffo"],s="waffo";function n(e){return"string"==typeof e&&r.some(t=>t===e)}function a(e){let t=["creem"];return e?.waffo===!0&&t.push("waffo"),t}function i(e,t){return n(e)&&t.includes(e)?e:t.includes(s)?s:"creem"}function o(e){return"creem"===e}function l(e){return"creem"===e}function d(e=!0,r=s){let[n,o]=(0,t.useState)(),[l,c]=(0,t.useState)(["creem"]),[u,m]=(0,t.useState)(!1),p=i(n??r,l);return(0,t.useEffect)(()=>{if(!e)return;let t=new AbortController;return fetch("/api/payments/options",{signal:t.signal}).then(async e=>e.ok?await e.json():null).then(e=>{t.signal.aborted||c(a(e))}).catch(()=>{t.signal.aborted||c(["creem"])}).finally(()=>{t.signal.aborted||m(!0)}),()=>t.abort()},[e]),{provider:p,setProvider:o,availableProviders:l,hasAlternativeProvider:l.length>1,optionsLoaded:u}}e.s(["DEFAULT_PAYMENT_PROVIDER",0,s,"getAvailablePaymentProviders",()=>a,"hasHostedBillingPortal",()=>o,"isPaymentProvider",()=>n,"resolveAvailablePaymentProvider",()=>i,"supportsSelfServePlanChanges",()=>l],778207),e.s(["usePaymentMethods",()=>d],449741)},237691,e=>{"use strict";var t=e.i(843476),r=e.i(271645);function s({value:e,onChange:s,copy:n,providers:a=["creem"],disabled:i}){let o=(0,r.useId)();return(0,t.jsxs)("fieldset",{disabled:i,className:"mx-auto flex flex-wrap items-center justify-center gap-3 text-sm",children:[(0,t.jsx)("legend",{className:"mb-3 w-full text-center font-medium text-stone-600",children:n.label}),a.map(r=>(0,t.jsxs)("label",{className:`flex cursor-pointer items-center gap-2 rounded-full border px-5 py-3 transition-colors ${e===r?"border-[var(--color-primary)] bg-[var(--color-primary)]/10 text-stone-900":"border-stone-200 text-stone-600"}`,children:[(0,t.jsx)("input",{type:"radio",name:o,value:r,checked:e===r,onChange:()=>s(r),className:"accent-[var(--color-primary)]"}),"paypal"===r?n.paypal:"waffo"===r?n.waffo??"Waffo":n.card]},r))]})}e.s(["PaymentMethodSelector",()=>s])},511877,193219,e=>{"use strict";var t=e.i(449741);function r(e=!0){return(0,t.usePaymentMethods)(e)}e.s(["useCreditPackPayment",()=>r],511877);var s=e.i(663919);class n extends Error{code;status;constructor(e,t){super(e),this.code=e,this.status=t,this.name="CreditPackCheckoutError"}}async function a(e,t,r){let a=await (0,s.analyticsFetch)(`/api/payments/${r}/credit-pack-checkout`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({packId:e,successUrl:t})}),i=await a.json();if(!a.ok||!i.url)throw new n(i.error??"CHECKOUT_FAILED",a.status);return i.url}e.s(["CreditPackCheckoutError",()=>n,"createCreditPackCheckout",()=>a],193219)},692205,e=>{"use strict";var t=e.i(33503);let r={pro200:"pro500",pro500:"pro1000",pro1000:null},s={pro200:100,pro500:300,pro1000:300};function n(e){return"pro200"===e||"pro500"===e||"pro1000"===e}function a(e,t){return"four_k"===t?"pro500"===e||"pro1000"===e?null:"pro500":n(e)?r[e]:"pro200"}function i(e){return n(e)?s[e]:null}function o(e){let r=t.plans.find(t=>
1t.id===e);if(!r)throw Error(`Missing frontend plan data for ${e}`);return r}function l(e,t){let r=o(e);return"monthly"===t?r.monthlyPrice:Math.round(12*r.monthlyPrice*70)/100}e.s(["getLowBalanceThreshold",()=>i,"getPlanCyclePrice",()=>l,"getUpgradePlan",()=>o,"isPaidPlanId",()=>n,"resolveUpgradeTarget",()=>a])},145988,e=>{"use strict";let t=["credits500","credits2000","credits5000"],r={credits500:{id:"credits500",credits:500,amountCents:2900,currency:"usd"},credits2000:{id:"credits2000",credits:2e3,amountCents:6900,currency:"usd"},credits5000:{id:"credits5000",credits:5e3,amountCents:15900,currency:"usd"}};function s(e){return"string"==typeof e&&t.includes(e)}function n(){return t.map(e=>r[e])}e.s(["CREDIT_PACKS",0,r,"CREDIT_PACK_IDS",0,t,"isCreditPackId",()=>s,"listCreditPacks",()=>n])},675558,e=>{"use strict";var t=e.i(271645);function r(e=!0){let[s,n]=(0,t.useState)(null),a=(0,t.useCallback)(async()=>{if(e)try{let e=await fetch("/api/credits/balance");if(!e.ok)return;let t=await e.json();"number"==typeof t.balance&&n(t.balance)}catch{}},[e]);return(0,t.useEffect)(()=>{let e=window.setTimeout(()=>{a()},0);return()=>window.clearTimeout(e)},[a]),(0,t.useEffect)(()=>{let e=()=>{a()};return window.addEventListener("credits:refresh",e),()=>window.removeEventListener("credits:refresh",e)},[a]),(0,t.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&a()};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[a]),e?s:null}e.s(["useCreditsBalance",()=>r])},695270,e=>{"use strict";var t=e.i(271645);let r={planId:null,billingCycle:null,packAccessActive:!1,loading:!1,fetchedAt:null},s=new Map;function n(e){let t=s.get(e);if(t)return t;let n={snapshot:r,promise:null,subscribers:new Set};return s.set(e,n),n}function a(e){e.subscribers.forEach(e=>e())}async function i(e,t){var s;let i=n(e),o=t?.force??!1,l=t?.accessOnly??!1;return i.promise?i.promise:!o&&null!==(s=i.snapshot).fetchedAt&&Date.now()-s.fetchedAt<3e4?i.snapshot:(i.snapshot={...i.snapshot,loading:!0},a(i),i.promise=(async()=>{let e=null;try{let t=await fetch(l?"/api/billing/image-access":"/api/billing/overview?limit=1");if(t.ok)if(l){let r=await t.json();e={planId:r.currentPlanId??null,billingCycle:r.billingCycle??null,packAccessActive:r.packAccessActive??!1,loading:!1,fetchedAt:Date.now()}}else{let r=await t.json();e={planId:r.currentPlanId??null,billingCycle:r.billingCycle??null,packAccessActive:r.creditPacks?.active??!1,loading:!1,fetchedAt:Date.now()}}else 401===t.status&&(e={...r,fetchedAt:Date.now()})}catch{e={planId:i.snapshot.planId,billingCycle:i.snapshot.billingCycle,packAccessActive:i.snapshot.packAccessActive,loading:!1,fetchedAt:i.snapshot.fetchedAt}}finally{return e?i.snapshot=e:i.snapshot={...i.snapshot,loading:!1},i.promise=null,a(i),i.snapshot}})(),i.promise)}function o(e){let s=(0,t.useSyncExternalStore)((0,t.useCallback)(t=>{let r;return e?((r=n(e)).subscribers.add(t),()=>{r.subscribers.delete(t)}):()=>{}},[e]),()=>e?n(e).snapshot:r,()=>r);(0,t.useEffect)(()=>{e&&i(e)},[e]),(0,t.useEffect)(()=>{if(!e)return;let t=()=>{i(e,{force:!0,accessOnly:!0})};return window.addEventListener("credits:refresh",t),()=>window.removeEventListener("credits:refresh",t)},[e]),(0,t.useEffect)(()=>{if(!e)return;let t=()=>{"visible"===document.visibilityState&&i(e,{force:!0,accessOnly:!0})};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[e]);let a=(0,t.useCallback)(()=>e?i(e,{force:!0}):Promise.resolve(r),[e]);return{planId:s.planId,billingCycle:s.billingCycle,packAccessActive:s.packAccessActive,loading:s.loading,resolved:null!==s.fetchedAt,refresh:a}}e.s(["useCurrentPlan",()=>o])},591962,e=>{"use strict";var t=e.i(843476),r=e.i(134530),s=e.i(663919),n=e.i(271645),a=e.i(538062),i=e.i(695270),o=e.i(692205),l=e.i(511877),d=e.i(193219),c=e.i(237691),u=e.i(145988);function m({payment:e,reason:r,balance:s,required:n,loadingPackId:i,error:o,locale:l,titleId:d,descriptionId:m,initialFocusRef:h,onSelect:f,onClose:b}){let g=(0,a.getDashboardCopy)(l),x=g.billing.creditPacks,y=g.upgradePrompt;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"pr-12 text-xs font-semibold uppercase tracking-[0.2em] text-[#8d681b]",children:x.eyebrow}),(0,t.jsx)("h2",{id:d,className:"mt-3 pr-8 font-serif text-3xl font-semibold leading-tight text-stone-950",children:x.title}),(0,t.jsx)("p",{id:m,className:"mt-3 text-sm leading-6 text-stone-600",children:(0,a.formatDashboardMessage)("low_credits"===r?x.promptLowBalance:x.promptInsufficient,{balance:s??"â"})}),"number"==typeof s?(0,t.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-3",children:[(0,t.jsx)(p,{label:y.metrics.balance,value:s,locale:l}),"number"==typeof n?(0,t.jsx)(p,{label:y.metrics.required,value:n,locale:l}):(0,t.jsxs)("div",{className:"rounded-xl border border-stone-200 bg-white px-4 py-3",children:[(0,t.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-stone-500",children:y.metrics.status}),(0,t.jsx)("p",{className:"mt-2 text-sm font-semibold text-[#8d681b]",children:y.metrics.runningLow})]})]}):null,e.hasAlternativeProvider?(0,t.jsx)("div",{className:"mt-5",children:(0,t.jsx)(c.PaymentMethodSelector,{value:e.provider,onCh
1ange:e.setProvider,copy:x.paymentMethods,providers:e.availableProviders,disabled:null!==i})}):null,(0,t.jsx)("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:u.CREDIT_PACK_IDS.map(r=>{var s,n,o;let d=u.CREDIT_PACKS[r],c="credits5000"===d.id,m=i===d.id;return(0,t.jsxs)("article",{className:`relative rounded-2xl border p-4 ${c?"sm:col-span-2":""} ${c?"border-[#c9a96a] bg-[#fbf5e9] shadow-[0_16px_38px_-30px_rgba(82,55,16,0.75)]":"border-stone-200 bg-white"}`,children:[c?(0,t.jsx)("span",{className:"absolute right-3 top-3 rounded-full bg-[#ead7ad] px-2.5 py-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[#6f5019]",children:x.bestValue}):null,(0,t.jsx)("p",{className:"font-serif text-3xl font-semibold text-stone-950",children:d.credits.toLocaleString((0,a.getDashboardIntlLocale)(l))}),(0,t.jsx)("p",{className:"mt-1 text-[11px] font-semibold uppercase tracking-[0.14em] text-stone-500",children:x.creditsLabel}),(0,t.jsx)("p",{className:"mt-3 text-xl font-semibold text-stone-950",children:(s=d.amountCents,n=d.currency,o=l,new Intl.NumberFormat((0,a.getDashboardIntlLocale)(o),{style:"currency",currency:n.toUpperCase(),maximumFractionDigits:0}).format(s/100))}),(0,t.jsx)("p",{className:"mt-1 text-xs text-stone-500",children:x.permanent}),(0,t.jsx)("button",{ref:c?h:void 0,type:"button",disabled:!e.optionsLoaded||null!==i,onClick:()=>f(d.id),className:`mt-4 inline-flex min-h-11 w-full items-center justify-center rounded-full px-4 py-2.5 text-sm font-semibold transition disabled:cursor-not-allowed disabled:opacity-55 ${c?"bg-stone-950 text-white hover:bg-stone-800":"border border-stone-300 bg-white text-stone-800 hover:bg-stone-100"}`,children:m?x.redirecting:x.buy})]},d.id)})}),(0,t.jsxs)("div",{className:"mt-3 rounded-xl border border-stone-200 bg-white px-4 py-3 text-xs leading-5 text-stone-600",children:[(0,t.jsx)("p",{children:x.checkoutKeepsWork}),(0,t.jsx)("p",{className:"mt-1",children:(0,a.formatDashboardMessage)(x.priorityNote,{purchased:x.purchasedBalance})})]}),o?(0,t.jsx)("div",{className:"mt-4 rounded-xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700",role:"alert",children:o}):null,(0,t.jsx)("div",{className:"mt-4 flex justify-end",children:(0,t.jsx)("button",{type:"button",onClick:b,disabled:null!==i,className:"min-h-11 rounded-full border border-stone-300 px-5 py-2.5 text-sm font-semibold text-stone-700 transition hover:bg-stone-100 disabled:cursor-not-allowed disabled:opacity-50",children:y.actions.maybeLater})})]})}function p({label:e,value:r,locale:s}){return(0,t.jsxs)("div",{className:"rounded-xl border border-stone-200 bg-white px-4 py-3",children:[(0,t.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-stone-500",children:e}),(0,t.jsx)("p",{className:"mt-1 text-2xl font-semibold text-stone-950",children:r.toLocaleString((0,a.getDashboardIntlLocale)(s))})]})}function h(e,t,r="USD"){return new Intl.NumberFormat(t,{style:"currency",currency:r,minimumFractionDigits:2*(e%1!=0),maximumFractionDigits:2}).format(e)}function f(e,t,r){return"ALREADY_ON_PLAN"===e?r.errors.alreadyOnPlan:"BILLING_CYCLE_CHANGE_NOT_ALLOWED"===e?r.errors.billingCycleChange:"DOWNGRADE_NOT_ALLOWED"===e?r.errors.downgrade:"SELF_SERVE_UNAVAILABLE"===e?r.errors.selfServeUnavailable:"SUBSCRIPTION_NOT_FOUND"===e?r.errors.subscriptionNotFound:t||r.errors.fallback}function b({open:e,prompt:c,userId:u,source:p,title:b,body:g,pricingHref:x,billingHref:y,onClose:v,onUpgradeApplied:w}){var N,j;let k,C,P=(0,a.useDashboardLocale)(),L=(0,a.getDashboardCopy)(P),S=L.upgradePrompt,{planId:_,billingCycle:A,packAccessActive:D,loading:E,refresh:I}=(0,i.useCurrentPlan)(u),[M,F]=(0,n.useState)("idle"),[T,B]=(0,n.useState)(null),[U,q]=(0,n.useState)(null),[O,R]=(0,n.useState)(!1),[K,W]=(0,n.useState)(!1),[H,$]=(0,n.useState)(0),[G,V]=(0,n.useState)(null),Y=(0,l.useCreditPackPayment)(e),[z,J]=(0,n.useState)(null),Q=(0,n.useRef)(null),X=(0,n.useRef)(null),Z=(0,n.useRef)(v),ee=(0,n.useRef)(!1),et=(0,n.useRef)(!1),er=(0,n.useId)(),es=(0,n.useId)(),en=(0,o.resolveUpgradeTarget)(_,c.reason),ea="low_credits"===c.reason||"insufficient_credits"===c.reason?c.reason:null,ei=("pro1000"===_||D)&&null!==ea,eo=en?(0,o.getUpgradePlan)(en):null,el=en?L.billing.plans[en]:L.billing.plans.pro1000,ed=(0,o.isPaidPlanId)(_),ec="insufficient_credits"===c.reason&&!ed,eu=b??(en?(k={required:c.required??"â",plan:el},"low_credits"===c.reason?(0,a.formatDashboardMessage)(S.titles.lowCredits,
1k):"insufficient_credits"===c.reason?(0,a.formatDashboardMessage)(ed?S.titles.insufficientCredits:S.titles.freeInsufficientCredits,k):"four_k"===c.reason?(0,a.formatDashboardMessage)(S.titles.fourK,k):"variant_sets"===c.reason?(0,a.formatDashboardMessage)(S.titles.variantSets,k):"video"===c.reason?(0,a.formatDashboardMessage)(S.titles.video,k):(0,a.formatDashboardMessage)(S.titles.planLimit,k)):S.highestPlan.title),em=g??(en?(C={balance:c.balance??"â",required:c.required??"â",plan:el},"low_credits"===c.reason?(0,a.formatDashboardMessage)(S.bodies.lowCredits,C):"insufficient_credits"===c.reason?(0,a.formatDashboardMessage)(ed?"number"==typeof c.required?S.bodies.insufficientCredits:S.bodies.insufficientCreditsUnknown:"number"==typeof c.required?S.bodies.freeInsufficientCredits:S.bodies.freeInsufficientCreditsUnknown,C):"four_k"===c.reason?(0,a.formatDashboardMessage)(S.bodies.fourK,C):"variant_sets"===c.reason?(0,a.formatDashboardMessage)(S.bodies.variantSets,C):"video"===c.reason?(0,a.formatDashboardMessage)(S.bodies.video,C):(0,a.formatDashboardMessage)(S.bodies.planLimit,C)):S.highestPlan.body),ep=A??"monthly",eh=en?(0,o.getPlanCyclePrice)(en,ep):null,ef=null===eh?null:(0,a.formatDashboardMessage)("monthly"===ep?S.price.monthly:S.price.yearly,{price:h(eh,(0,a.getDashboardIntlLocale)(P))}),eb=!!(en&&(0,o.isPaidPlanId)(_)&&A&&_!==en),eg=en?S.planBenefits[en]:[],ex="submitting"===M||null!==G;Z.current=v,ee.current=ex;let ey=(0,n.useMemo)(()=>{if(!en)return null;let e=x??(0,a.localizeDashboardHref)("/pricing",P),t=new URLSearchParams({section:"pricing",upgradeSource:p});return ec||(t.set("recommended",en),t.set("cycle",ep)),`${e}?${t.toString()}`},[ec,P,x,p,ep,en]),ev=y??(0,a.localizeDashboardHref)("/app/billing",P);if((0,n.useEffect)(()=>{if(!e)return;F("idle"),B(null),V(null),J(null),et.current=!1;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,r=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>X.current?.focus());let s=e=>{if("Escape"===e.key&&!ee.current)return void Z.current();if("Tab"!==e.key||!Q.current)return;let t=Array.from(Q.current.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])'));if(0===t.length)return;let r=t[0],s=t[t.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),s.focus()):e.shiftKey||document.activeElement!==s||(e.preventDefault(),r.focus())};return document.addEventListener("keydown",s),()=>{document.body.style.overflow=r,document.removeEventListener("keydown",s),t?.focus()}},[e]),(0,n.useEffect)(()=>{if(!e||!eb||!en||!A){q(null),R(!1),W(!1);return}let t=new AbortController;return q(null),R(!0),W(!1),(0,s.analyticsFetch)("/api/billing/upgrade/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({planId:en,billingCycle:A}),signal:t.signal}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(f("error"in t?t.error:void 0,"message"in t?t.message:void 0,S));if(!("creditsToGrant"in t)||"number"!=typeof t.creditsToGrant||"number"!=typeof t.renewalPriceCents)throw Error(S.preview.loadError);q(t)}).catch(e=>{"AbortError"!==e.name&&W(!0)}).finally(()=>{t.signal.aborted||R(!1)}),()=>t.abort()},[A,eb,S,e,H,en]),!e)return null;let ew=e=>{window.open(e,"_blank","noopener,noreferrer")},eN=async e=>{let t=window.open("","_blank");t&&(t.opener=null),J(null),V(e);try{let s=new URL(ev,window.location.origin);s.searchParams.set("creditPack","success");let n=await (0,d.createCreditPackCheckout)(e,s.toString(),Y.provider);t?t.location.assign(n):window.location.assign(n),(0,r.trackEvent)("checkout_redirected",{selected_plan:e}),v()}catch{t?.close(),J(L.billing.creditPacks.checkoutError),V(null)}},ej=async()=>{if((0,r.trackEvent)("upgrade_prompt_action",{action:"upgrade",reason:c.reason}),!et.current){if(B(null),!en){ew(ev),v();return}if(!eb){ey&&ew(ey),v();return}et.current=!0,F("submitting");try{let e=await (0,s.analyticsFetch)("/api/billing/upgrade",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({planId:en,billingCycle:A,source:p})}
1),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(f(t.error,t.message,S));F("requested"),window.dispatchEvent(new Event("credits:refresh"));for(let e=0;e<8;e+=1){if((await I()).planId===en){F("success"),window.dispatchEvent(new Event("credits:refresh")),w?.(en);return}await new Promise(e=>window.setTimeout(e,1500))}}catch(e){et.current=!1,F("idle"),B(e.message||S.errors.fallback)}}},ek=en?ec?S.actions.viewPlans:eb?S.actions.confirmUpgrade:(0,a.formatDashboardMessage)(S.actions.viewPlan,{plan:el}):S.actions.viewBilling;return(0,t.jsx)("div",{className:"fixed inset-0 z-[90] flex items-center justify-center bg-stone-950/55 px-4 py-8 backdrop-blur-sm",onMouseDown:e=>{e.target!==e.currentTarget||ex||v()},children:(0,t.jsxs)("div",{ref:Q,role:"dialog","data-analytics-view":"upgrade_prompt_viewed","data-analytics-reason":c.reason,"aria-modal":"true","aria-labelledby":er,"aria-describedby":es,className:"relative max-h-[calc(100vh-4rem)] w-full max-w-[560px] overflow-y-auto rounded-[24px] border border-[#eadfce] bg-[#fffdf9] shadow-[0_32px_90px_-28px_rgba(34,24,10,0.55)]",children:[(0,t.jsx)("div",{className:"h-1.5 w-full bg-gradient-to-r from-[#8d681b] via-[#d7b46a] to-[#8d681b]"}),(0,t.jsx)("button",{type:"button",onClick:v,disabled:ex,"aria-label":S.actions.close,className:"absolute right-4 top-5 flex h-10 w-10 items-center justify-center rounded-full text-stone-500 transition hover:bg-stone-100 hover:text-stone-900 disabled:cursor-not-allowed disabled:opacity-40",children:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-5 w-5",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,t.jsx)("path",{d:"M6 6l12 12M18 6L6 18",strokeLinecap:"round"})})}),(0,t.jsx)("div",{className:`px-6 sm:px-8 ${ei?"pb-5 pt-7":"pb-7 pt-8"}`,children:"success"===M?(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-full bg-emerald-100 text-emerald-700",children:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-7 w-7",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,t.jsx)("path",{d:"M5 12.5l4.2 4L19 7",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,t.jsx)("p",{className:"mt-5 text-xs font-semibold uppercase tracking-[0.2em] text-[#8d681b]",children:S.success.eyebrow}),(0,t.jsx)("h2",{id:er,className:"mt-2 font-serif text-3xl font-semibold text-stone-950",children:(0,a.formatDashboardMessage)(S.success.title,{plan:el})}),(0,t.jsx)("p",{id:es,className:"mx-auto mt-3 max-w-md text-sm leading-6 text-stone-600",children:S.success.body}),(0,t.jsx)("button",{ref:X,type:"button",onClick:v,className:"mt-7 inline-flex min-h-11 items-center justify-center rounded-full bg-stone-950 px-6 py-3 text-sm font-semibold text-white transition hover:bg-stone-800 focus:outline-none focus-visible:ring-2 focus-visible:ring-[#b68a32] focus-visible:ring-offset-2",children:S.actions.continue})]}):ei&&ea?(0,t.jsx)(m,{payment:Y,reason:ea,balance:c.balance,required:c.required,loadingPackId:G,error:z,locale:P,titleId:er,descriptionId:es,initialFocusRef:X,onSelect:e=>void eN(e),onClose:v}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"pr-12 text-xs font-semibold uppercase tracking-[0.2em] text-[#8d681b]",children:S.eyebrow}),(0,t.jsx)("h2",{id:er,className:"mt-3 pr-8 font-serif text-3xl font-semibold leading-tight text-stone-950",children:eu}),(0,t.jsx)("div",{id:es,className:"mt-3 text-sm leading-6 text-stone-600",children:em}),"number"==typeof c.balance?(0,t.jsxs)("div",{className:"mt-5 grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"rounded-xl border border-stone-200 bg-white px-4 py-3",children:[(0,t.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-stone-500",children:S.metrics.balance}),(0,t.jsx)("p",{className:"mt-1 text-2xl font-semibold text-stone-950",children:c.balance.toLocaleString((0,a.getDashboardIntlLocale)(P))})]}),"number"==typeof c.required?(0,t.jsxs)("div",{className:"rounded-xl border border-stone-200 bg-white px-4 py-3",children:[(0,t.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-stone-500",children:S.metrics.required}),(0,t.jsx)("p",{className:"mt-1 text-2xl font-semibold text-stone-950",children:c.required.toLocaleStr
1ing((0,a.getDashboardIntlLocale)(P))})]}):(0,t.jsxs)("div",{className:"rounded-xl border border-stone-200 bg-white px-4 py-3",children:[(0,t.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-stone-500",children:S.metrics.status}),(0,t.jsx)("p",{className:"mt-2 text-sm font-semibold text-[#8d681b]",children:S.metrics.runningLow})]})]}):null,eo&&en&&!ec?(0,t.jsxs)("div",{className:"mt-5 rounded-2xl border border-[#dfcda9] bg-[#fbf5e9] p-5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[#8d681b]",children:S.recommended}),(0,t.jsx)("p",{className:"mt-1 font-serif text-2xl font-semibold text-stone-950",children:el})]}),(0,t.jsx)("div",{className:"rounded-full border border-[#dfcda9] bg-white px-3 py-1.5 text-sm font-semibold text-stone-800",children:ef})]}),(0,t.jsx)("ul",{className:"mt-4 grid gap-2 text-sm text-stone-700 sm:grid-cols-2",children:eg.map(e=>(0,t.jsxs)("li",{className:"flex items-start gap-2",children:[(0,t.jsx)("svg",{viewBox:"0 0 20 20",className:"mt-0.5 h-4 w-4 shrink-0 text-[#8d681b]",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,t.jsx)("path",{d:"M4 10.5l3.4 3.2L16 5.8",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,t.jsx)("span",{children:e})]},e))})]}):null,eb?(0,t.jsxs)("div",{className:"mt-4 overflow-hidden rounded-2xl border border-stone-200 bg-white",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-stone-200 px-4 py-3.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#f6ecd8] text-[#8d681b]",children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:[(0,t.jsx)("path",{d:"M7 4.5h10M7 19.5h10M9 8h6M9 16h6",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M12 4.5V8M12 16v3.5M8 12h8",strokeLinecap:"round"})]})}),(0,t.jsx)("p",{className:"text-sm font-semibold text-stone-950",children:S.preview.title})]}),(0,t.jsx)("span",{className:"rounded-full bg-emerald-50 px-2.5 py-1 text-[11px] font-semibold text-emerald-700",children:S.preview.immediateBadge})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-stone-200",children:[(0,t.jsxs)("div",{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-stone-500",children:S.preview.estimatedCharge}),O?(0,t.jsx)("div",{className:"mt-2 h-8 w-24 animate-pulse rounded-md bg-stone-100"}):(0,t.jsx)("p",{className:"mt-1.5 text-2xl font-semibold tabular-nums text-stone-950",children:U?.estimatedChargeCents===null?S.preview.calculatedAtCharge:U?h(U.estimatedChargeCents/100,(0,a.getDashboardIntlLocale)(P),U.currency):"â"}),(0,t.jsx)("p",{className:"mt-1 text-xs leading-5 text-stone-500",children:S.preview.taxMayApply})]}),(0,t.jsxs)("div",{className:"bg-[#fffbf3] px-4 py-4",children:[(0,t.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-[#8d681b]",children:S.preview.creditsToGrant}),O?(0,t.jsx)("div",{className:"mt-2 h-8 w-28 animate-pulse rounded-md bg-[#f3e6cc]"}):(0,t.jsx)("p",{className:"mt-1.5 text-2xl font-semibold tabular-nums text-stone-950",children:U?(0,a.formatDashboardMessage)(S.preview.creditsAmount,{credits:U.creditsToGrant.toLocaleString((0,a.getDashboardIntlLocale)(P))}):"â"}),(0,t.jsx)("p",{className:"mt-1 text-xs leading-5 text-stone-500",children:S.preview.creditsNote})]})]}),U?(0,t.jsx)("div",{className:"border-t border-stone-200 px-4 py-3",children:(0,t.jsxs)("p",{className:"text-xs leading-5 text-stone-600",children:[(0,t.jsx)("span",{className:"font-semibold text-stone-800",children:S.preview.nextRenewal})," ",(0,a.formatDashboardMessage)(U.renewalDate?S.preview.renewalWithDate:S.preview.renewalWithoutDate,{date:U.renewalDate?(N=U.renewalDate,j=(0,a.getDashboardIntlLocale)(P),new Intl.DateTimeFormat(j,{year:"numeric",month:"short",day:"numeric"}).format(new Date(N))):"",price:h(U.renewalPriceCents/100,(0,a.getDashboardIntlLocale)(P),U.currency)})]})}):null,(0,t.jsxs)("div",{className:"flex items-start gap-2 border-t border-stone-200 bg-stone-50 px-4 py-3",children:[(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"mt-0.5 h-4 w-4 shrink-0 text-stone-500",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"8.5"}),(0,t.jsx)("path",{d:"M12 10v6M12 7.2v.1",strokeLinecap:"round"})]}),(0,t.jsx)("p",{className:"text-xs leading-5 text-stone-600",children:S.preview.finalAmountNote})]}),K?(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t border-rose-200 bg-rose-50 px-4 py-3",children:[(0,t.jsx)("p",{className:"text-xs leading-5 text-rose-700",children:S.preview.loadError}),(0,t.jsx)("button",{type:"button",onClick:()=>$(e=>e+1),className:"shrink-0 text-xs font-semibold text-rose-800 underline decoration-rose-300 underline-offset-4",children:S.preview.retry})]}):null]}):(0,t.jsxs)("div",{className:"mt-4 flex gap-3 rounded-xl border border-stone-200 bg-white px-4 py-3.5",children:[(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"mt-0.5 h-5 w-5 shrink-0 text-[#8d681b]",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"8.5"}),(0,t.jsx)("path",{d:"M12 10v6M12 7.2v.1",strokeLinecap:"round"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-semibold text-stone-900",children:S.keepWork.title}),(0,t.jsx)("p",{className:"mt-1 text-xs leading-5 text-stone-600",children:S.keepWork.body})]})]}),"requested"===M?(0,t.jsxs)("div",{className:"mt-4 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm leading-6 text-amber-800",children:[(0,t.jsx)("p",{className:"font-semibold",children:S.requested.title}),(0,t.jsx)("p",{children:S.requested.body}
1)]}):null,T?(0,t.jsx)("div",{className:"mt-4 rounded-xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700",role:"alert",children:T}):null,(0,t.jsxs)("div",{className:"mt-6 flex flex-col-reverse gap-3 sm:flex-row sm:justify-end",children:[(0,t.jsx)("button",{type:"button",onClick:v,disabled:ex,className:"min-h-11 rounded-full border border-stone-300 px-5 py-2.5 text-sm font-semibold text-stone-700 transition hover:bg-stone-100 disabled:cursor-not-allowed disabled:opacity-50",children:"requested"===M?S.actions.done:S.actions.maybeLater}),"requested"!==M?(0,t.jsxs)("button",{ref:X,type:"button",onClick:()=>{ej()},disabled:ex||E||eb&&(O||K||!U),className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-full bg-stone-950 px-6 py-2.5 text-sm font-semibold text-white shadow-[0_14px_28px_-16px_rgba(28,25,23,0.9)] transition hover:bg-stone-800 focus:outline-none focus-visible:ring-2 focus-visible:ring-[#b68a32] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60",children:[ex?(0,t.jsx)("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white/35 border-t-white"}):null,ex?S.actions.applying:ek]}):null]})]})})]})})}e.s(["UpgradePromptDialog",()=>b],591962)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.