1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/upsell-dialog-Dz5ahTip.js","assets/main-BVeaUmEJ.js","assets/use-payment-Bf0Qq8HI.js","assets/IconCopy-CRqbQ6h1.js","assets/analytics-diMhel4P.js","assets/formatter-DRSuxb_l.js","assets/badge-jVzWArNv.js","assets/billing-model-uylJWD-X.js","assets/app.schema-B-SAvJF5.js","assets/customer-portal-button-B1kmK7Nc.js","assets/IconCircleCheck-mRQv__4L.js","assets/IconCircleX-B9BKclBq.js","assets/styles-C4wcY9Wz.js","assets/CSPContext-xVp9RCru.js"])))=>i.map(i=>d[i]); 2import{I3 as V,I4 as pe,I5 as xe,I6 as ye,I7 as _e,I8 as we,I9 as be,Ia as Ie,Ib as ve,Ic as Se,mh as je,Id as Ee,Ie as Ne,If as Ae,Ig as Re,Ih as Fe,Ii as De,Ij as ke,Ik as Ce,Il as Oe,Im as Te,In as Ue,Io as Me,Ip as ze,Iq as Ge,Ir as Le,m as a,AZ as X,A_ as Z,Is as ee,_ as te,A$ as ne,B0 as Pe,It as Be,a3 as W,Iu as $e,Iv as Je,Gu as Ve,u as We,g as qe,Iw as Ke,a as re,r as c,Ix as Qe,Iy as He,Iz as Ye,dg as se,IA as q,IB as Xe,xt as Ze,xu as et,xv as tt,IC as K,Be as nt,mi as T,ID as rt,mS as st,a5 as at,Bo as it,aa as ot}from"./main-BVeaUmEJ.js";import{t as Q,A as H}from"./analytics-diMhel4P.js";import{S as ct}from"./skeleton-ChuuxPGC.js";import{I as lt}from"./IconAlertTriangle-DWq3RBsQ.js";import{S as ut}from"./faq-R81VDQAb.js";import{I as dt}from"./IconArrowRight-C3mkZMZZ.js";const U="generation-upload:";function p(t){return new Error(`${U}${JSON.stringify(t)}`)}function mt(t){if(!(t instanceof Error)||!t.message.startsWith(U))return null;try{const e=JSON.parse(t.message.slice(U.length));if(!e||typeof e.code!="string")return null;switch(e.code){case"unsupported-type":return{code:e.code,...typeof e.receivedType=="string"?{receivedType:e.receivedType}:{}};case"empty-file":case"invalid-image":case"invalid-task-type":return{code:e.code};case"file-too-large":return typeof e.bytes=="number"&&typeof e.maxBytes=="number"?{code:e.code,bytes:e.bytes,maxBytes:e.maxBytes}:null;case"image-too-large":return typeof e.width=="number"&&typeof e.height=="number"&&typeof e.megapixels=="number"&&typeof e.maxMegapixels=="number"?{code:e.code,width:e.width,height:e.height,megapixels:e.megapixels,maxMegapixels:e.maxMegapixels}:null;case"pbr-dimension-too-large":case"upscale-dimension-too-small":return typeof e.width=="number"&&typeof e.height=="number"?{code:e.code,width:e.width,height:e.height}:null;case"upscale-factor-too-large":return typeof e.factor=="number"&&typeof e.maxFactor=="number"?{code:e.code,factor:e.factor,maxFactor:e.maxFactor}:null;case"provider-upload-failed":return typeof e.message=="string"?{code:e.code,message:e.message}:null;case"media-unsupported-type":return e.kind==="video"||e.kind==="audio"?{code:e.code,kind:e.kind}:null;case"media-too-large":return typeof e.bytes=="number"&&typeof e.maxBytes=="number"?{code:e.code,bytes:e.bytes,maxBytes:e.maxBytes}:null;case"media-too-short":return typeof e.seconds=="number"&&typeof e.minSeconds=="number"?{code:e.code,seconds:e.seconds,minSeconds:e.minSeconds}:null;case"media-too-long":return typeof e.seconds=="number"&&typeof e.maxSeconds=="number"?{code:e.code,seconds:e.seconds,maxSeconds:e.maxSeconds}:null;case"media-dimension-too-large":return typeof e.width=="number"&&typeof e.height=="number"&&typeof e.maxLongSide=="number"?{code:e.code,width:e.width,height:e.height,maxLongSide:e.maxLongSide}:null;case"media-variable-frame-rate":case"media-unreadable":case"media-not-found":case"media-upload-expired":return{code:e.code};default:return null}}catch{return null}}function Ct(t){const e=mt(t);if(!e)return t instanceof Error&&t.message?t.message:V({reason:""});switch(e.code){case"unsupported-type":return Ce({formats:"PNG, JPG/JPEG, WebP"});case"empty-file":return ke();case"file-too-large":return De({size:C(e.bytes),max:C(e.maxBytes)});case"invalid-image":return Fe();case"image-too-large":return Re({width:e.width,height:e.height,megapixels:e.megapixels.toFixed(2),max:e.maxMegapixels});case"upscale-dimension-too-small":return Ae({width:e.width,height:e.height});case"upscale-factor-too-large":return Ne({factor:e.factor,maxFactor:e.maxFactor});case"provider-upload-failed":return Ee({reason:e.message});
2case"pbr-dimension-too-large":case"invalid-task-type":return V({reason:""});case"media-unsupported-type":return Se({formats:je(e.kind)});case"media-too-large":return ve({size:C(e.bytes),max:C(e.maxBytes)});case"media-too-short":return Ie({seconds:e.seconds.toFixed(1),min:e.minSeconds});case"media-too-long":return be({seconds:e.seconds.toFixed(1),max:e.maxSeconds});case"media-dimension-too-large":return we({width:e.width,height:e.height,max:e.maxLongSide});case"media-variable-frame-rate":return _e();case"media-unreadable":return ye();case"media-not-found":return xe();case"media-upload-expired":return pe()}}function C(t){return`${(t/(1024*1024)).toFixed(0)} MB`}function O(t,e){return e.every((s,n)=>t[n]===s)}function ae(t){const e=t instanceof Uint8Array?t:new Uint8Array(t);return O(e,[137,80,78,71,13,10,26,10])?{mimeType:"image/png",extension:"png",acceptedExtensions:["png"]}:O(e,[255,216,255])?{mimeType:"image/jpeg",extension:"jpg",acceptedExtensions:["jpg","jpeg"]}:O(e,[82,73,70,70])&&O(e.subarray(8),[87,69,66,80])?{mimeType:"image/webp",extension:"webp",acceptedExtensions:["webp"]}:null}function ie(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),s=t.lastIndexOf(".");return s<=e+1||s===t.length-1?null:t.slice(s+1).toLowerCase()}function ft(t,e){const s=ie(t);return s?`${t.slice(0,-(s.length+1))}.${e}`:`${t}.${e}`}function gt(t,e){const s=ie(t.name),n=s!==null&&e.acceptedExtensions.includes(s);return t.type===e.mimeType&&n?t:new File([t],n?t.name:ft(t.name,e.extension),{type:e.mimeType,lastModified:t.lastModified})}function ht(t){const e=new Uint8Array(t),s=ae(e);if(!s)return null;if(s.mimeType==="image/png"&&e.length>=24){const n=new DataView(t,16,8),r=n.getUint32(0),i=n.getUint32(4);return r>0&&i>0&&r<=5e4&&i<=5e4?{width:r,height:i,megapixels:r*i/(1024*1024)}:null}if(s.mimeType==="image/jpeg"&&e.length>=4){let n=2;for(;n+4<e.length&&e[n]===255;){const r=e[n+1];if(n+=2,r===216||r===217||r===1||r>=208&&r<=215)continue;if(r===218||n+2>e.length)break;const i=(e[n]<<8|e[n+1])-2;if(n+=2,pt(r)&&i>=5){const l=e[n+1]<<8|e[n+2],u=e[n+3]<<8|e[n+4];if(u>0&&l>0&&u<=5e4&&l<=5e4)return{width:u,height:l,megapixels:u*l/(1024*1024)}}n+=i}return null}if(s.mimeType==="image/webp"&&e.length>=30){if(e[12]===86&&e[13]===80&&e[14]===56&&e[15]===88){const n=e[24]|e[25]<<8|e[26]<<16,r=e[27]|e[28]<<8|e[29]<<16,i=n+1,l=r+1;return i>0&&l>0&&i<=5e4&&l<=5e4?{width:i,height:l,megapixels:i*l/(1024*1024)}:null}if(e[12]===86&&e[13]===80&&e[14]===56&&e[15]===76){const n=(e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>0,r=(n&16383)+1,i=(n>>14&16383)+1;return r>0&&i>0&&r<=5e4&&i<=5e4?{width:r,height:i,megapixels:r*i/(1024*1024)}:null}if(e[12]===86&&e[13]===80&&e[14]===56&&e[15]===32){const n=(e[26]|e[27]<<8)&16383,r=(e[28]|e[29]<<8)&16383;if(n>0&&r>0)return{width:n,height:r,megapixels:n*r/(1024*1024)}}return null}return null}function pt(t){return t>=192&&t<=195||t>=197&&t<=199||t>=201&&t<=203||t>=205&&t<=207}function xt({step:t,failed:e,onRetry:s,onCancel:n}){const r=e?t==="session"?Oe():Te():t==="session"?Ue():Me(),i=e?t==="session"?ze():Ge():Le();return a.jsx(X,{open:!0,onOpenChange:l=>{l||n()},children:a.jsxs(Z,{showCloseButton:!1,children:[a.jsxs(ee,{children:[a.jsxs("div",{"aria-live":"polite",className:"flex items-center gap-2",children:[!e&&a.jsx(te,{"aria-hidden":"true",className:"shrink-0"}),a.jsx(ne,{children:r})]}),a.jsx(Pe,{children:i})]}),a.jsxs(Be,{children:[a.jsx(W,{variant:"outline",onClick:n,children:$e()}),e&&a.jsx(W,{onClick:s,children:Je()})]})]})})}const yt=600,_t=c.lazy(async()=>({default:(await se(()=>import("./main-BVeaUmEJ.js").then(e=>e.a5c),[])).LoginForm})),wt=c.lazy(async()=>({default:(await se(()=>import("./upsell-dialog-Dz5ahTip.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).UpsellDialog}));function Ot(){const t=Ve(),e=We(),s=qe(e),n=Ke(e.pathname)==="/"?"homepage":"derive",{data:r,error:i,isPending:l,isRefetching:u,refetch:v}=re.useSession(),b=l||u,f=r?.user?.id??null,N=c.useRef({userId:f,isSessionChecking:b,sessionError:i});N.current={userId:f,isSessionChecking:b,sessionError:i};const[d,m]=c.useState("idle"),[z,A]=c.useState(null),[R,G]=c.useState(!1),[le,ue]=c.useState(0),[L,P]=c.useState(null),[de,B]=c.useState(void 0),g=c.useRef(null),S=c.useRef(null),x=c.useRef(null),h=c.useRef(null),F=c.useRef(!1),I=c.useRef(!1),D=c.useCallback(()=>{g.current=null,S.current=null,x.current=null,h.current=null,F.current=!1,I.current=!1,q(),A(null),P(null),B(void 0),m("idle")},[]),_=c.useCallback(()=>{const o=g.current;D(),o?.onAbort()},[D]);c.useEffect(()=>()=>{g.current=null,x.current=null,h.current=null,F.current=!1,I.current=!1},[]),c.useEffect(()=>{if(d==="idle"||d==="login"||d==="upsell"){G(!1);return}if(R)return;const o=setTimeout(()=>G(!0),yt);return()=>clearTimeout(o)},[d,R]);const w=c.useCallback(o=>{I.current||(I.current=!0,A(o),m("check-error"),Q(H.generationGateCheckFailed,{reason:o,source:n}))},[n]),$=c.useCallback(async(o,y)=>{if(x.current?.action===o)return;const j={action:o,userId:y};x.current=j,S.current=y,I.current=!1,m("checking");try{const E=await t.fetchQuery(Qe(y));if(g.current!==o||x.current!==j)return;const k=N.current;if(k.isSessionChecking||h.current){m("waiting-session");return}if(k.sessionError){w("session");return}if(k.userId!==y){if(!k.userId){m("login");return}_();return}if(E.credits<o.credits){B(o.taskType),P("insufficient-credits"),m("upsell");return}D(),o.run()}catch{if(g.current!==o||x.current!==j)return;const E=N.current;E.isSessionChecking||h.current?m("waiting-session"):E.sessionError?w("session"):E.userId!==y?E.userId?_():m("login"):w("credits")}finally{x.current===j&&(x.current=null)}},[_,D,w,t]),me=c.useCallback(o=>{g.current||(g.current=o,m("waiting-session"))},[]),J=c.useCallback(async o=>{if(h.current?.action===o)return;const y={action:o};h.current=y,F.current=!0,I.current=!1,A(null),m("waiting-session");try{await v()}catch{g.current===o&&h.current===y&&w("session")}finally{h.current===y&&(h.current=null,ue(j=>j+1))}},[w,v]);c.useEffect(()=>{const o=g.current;if(!(!o||b||h.current)){if(S.current&&!i&&S.current!==f){if(!f&&He()!=="sign-out"){m("login");return}_();return}
2if(!(d==="check-error"||d==="upsell")){if(!f){i&&(S.current||F.current)?(x.current=null,w("session")):m("login");return}$(o,f)}}},[_,w,b,i,le,d,f,$]);const fe=async()=>{Q(H.generationLoginSuccess,{source:n});const o=g.current;q(),o&&(!f||f!==S.current)&&await J(o)},ge=()=>{const o=g.current;o&&(I.current=!1,z==="session"?J(o):(A(null),m("waiting-session")))},he=a.jsxs(a.Fragment,{children:[d==="login"?a.jsx(X,{open:!0,onOpenChange:o=>{o||_()},children:a.jsxs(Z,{className:"overflow-hidden border-0 p-0 sm:max-w-100",children:[a.jsx(ee,{className:"sr-only",children:a.jsx(ne,{children:Ye()})}),a.jsx(c.Suspense,{fallback:a.jsx("div",{className:"flex min-h-72 items-center justify-center",children:a.jsx(te,{})}),children:a.jsx(_t,{callbackUrl:s,onSuccess:fe,redirectAfterSuccess:!1,className:"border-0 shadow-none"})})]})}):null,(d==="check-error"||(d==="waiting-session"||d==="checking")&&R)&&a.jsx(xt,{step:z??(d==="checking"?"credits":"session"),failed:d==="check-error",onRetry:ge,onCancel:_}),d==="upsell"&&L?a.jsx(c.Suspense,{fallback:null,children:a.jsx(wt,{scene:L,mode:de,open:!0,onOpenChange:o=>{o||_()}})}):null]});return{request:me,stage:d,waitingVisible:R,dialogs:he}}const bt=Xe,Tt=bt.map(({mimeType:t})=>t).join(","),It=Ze({method:"POST"}).middleware([et]).handler(tt("45a8f88fb4ef197f53966ec67e019a0532281b6ac350a028b743a92be8580df0"));async function vt(t){if(t.size===0)throw p({code:"empty-file"});if(t.size>T.maxBytes)throw p({code:"file-too-large",bytes:t.size,maxBytes:T.maxBytes});const e=new Uint8Array(await t.slice(0,12).arrayBuffer()),s=ae(e);if(!s)throw p({code:"unsupported-type",receivedType:t.type||void 0});return gt(t,s)}async function St(t){const e=ht(await t.arrayBuffer());if(!e)throw p({code:"invalid-image"});if(e.megapixels>T.maxMegapixels)throw p({code:"image-too-large",width:e.width,height:e.height,megapixels:e.megapixels,maxMegapixels:T.maxMegapixels});return e}async function jt(t,e,s={}){const n=await vt(t),r=await St(n);if(e==="upscale"){const i=K.upscale;if(r.width<i.minDimension||r.height<i.minDimension||r.width>i.maxDimension||r.height>i.maxDimension)throw p({code:"upscale-dimension-too-small",width:r.width,height:r.height});const l=nt(r.width,r.height);if(l.maxFactor<2)throw p({code:"upscale-dimension-too-small",width:r.width,height:r.height});if(s.factor&&!l.factors.includes(s.factor))throw p({code:"upscale-factor-too-large",factor:s.factor,maxFactor:l.maxFactor})}if(e==="vectorize"){const i=K.vectorize;if(n.size>=i.maxFileBytes)throw p({code:"file-too-large",bytes:n.size,maxBytes:i.maxFileBytes});if(r.width<=i.minDimension||r.height<=i.minDimension||r.width>=i.maxDimension||r.height>=i.maxDimension||r.megapixels>=i.maxMegapixels)throw p({code:"image-too-large",width:r.width,height:r.height,megapixels:r.megapixels,maxMegapixels:i.maxMegapixels})}return{file:n,...r}}async function Ut(t,e,s){const n=await jt(t,e,s),r=new FormData;return r.append("file",n.file),r.append("taskType",e),It({data:r})}function M(t,e){return`${t.storageKeyPrefix}:${encodeURIComponent(e)}`}function oe(t,e){const s=Date.now();return t.filter(n=>n.createdAt<=s&&s-n.createdAt<=e.retentionMs).sort((n,r)=>r.createdAt-n.createdAt).slice(0,e.maxResults)}function ce(t,e){if(typeof window>"u")return[];try{try{window.localStorage.removeItem(e.storageKeyPrefix)}catch{}const s=JSON.parse(window.localStorage.getItem(M(e,t))??"[]");if(!Array.isArray(s))return[];const n=oe(s.map(r=>e.read(r)).filter(r=>r!==null),e);try{window.localStorage.setItem(M(e,t),JSON.stringify(n))}catch{}return n}catch{return[]}}function Et(t,e,s){const n=oe([e,...ce(t,s).filter(r=>r.id!==e.id)],s);try{window.localStorage.setItem(M(s,t),JSON.stringify(n))}catch{}return n}function Mt(t){const{data:e,isPending:s,isRefetching:n}=re.useSession(),r=s?null:e?.user?.id??null,[i,l]=c.useState(null);c.useEffect(()=>{!s&&!n&&l(r)},[s,n,r]);const u=i,v=c.useRef(t);v.current=t;const[b,f]=c.useState({userId:null,items:[]});return c.useEffect(()=>{f({userId:u,items:u?ce(u,v.current):[]})},[u]),{userId:u,items:b.userId===u?b.items:[],store:N=>{u&&f({userId:u,items:Et(u,N,v.current)})}}}function zt(t){return t===void 0||!Number.isFinite(t)?"â":`${Math.max(0,t/1e3).toFixed(1)}s`}function Gt(t){return t===void 0||!Number.isFinite(t)?"â":new Date(t).toISOString().slice(0,10)}function Lt({count:t,statusLabel:e}){return a.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4","aria-live":"polite",children:Array.from({length:t},(s,n)=>
2a.jsxs("div",{className:"relative aspect-square min-h-64 overflow-hidden rounded-xl border border-border/60 bg-muted/80 shadow-inner",children:[a.jsx(ct,{className:"absolute inset-0 rounded-none bg-muted/80"}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3",children:[a.jsx(st,{className:"size-8 animate-spin text-primary/80","aria-hidden":"true"}),a.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:e})]})]},n))})}function Pt({message:t}){return a.jsxs("div",{className:"flex min-h-96 flex-col items-center justify-center gap-4 p-8 text-center",role:"alert",children:[a.jsx("div",{className:"flex size-14 items-center justify-center rounded-2xl bg-destructive/10 text-destructive",children:a.jsx(lt,{className:"size-6"})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"font-semibold",children:rt()}),a.jsx("p",{className:"max-w-md text-sm leading-6 text-muted-foreground",children:t})]})]})}function Y({href:t,children:e,variant:s="default",className:n}){return a.jsxs("a",{href:t,className:at(it({variant:s,size:"lg"}),"min-h-11 px-5",n),children:[e,a.jsx(dt,{className:"size-4"})]})}function Bt({eyebrow:t,title:e,description:s,primary:n,secondary:r,watermark:i,animated:l=!0}){return a.jsx("section",{className:"py-20 sm:py-28",children:a.jsx(ot,{className:"px-4",children:a.jsxs(ut,{disabled:!l,className:"relative overflow-hidden rounded-3xl bg-linear-to-br from-accent-violet/30 to-accent-sky/20 p-8 text-center shadow-lg sm:p-12",children:[i?a.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute -bottom-20 -right-10 size-72 opacity-50",children:a.jsx("img",{src:i.src,alt:i.alt??"",width:288,height:288,className:"size-full"})}):null,t?a.jsx("p",{className:"relative z-10 text-xs font-semibold uppercase tracking-[0.14em] text-accent-foreground",children:t}):null,a.jsx("h2",{className:"relative z-10 mx-auto mt-4 max-w-4xl text-5xl font-bold leading-[0.98] tracking-normal text-balance sm:text-6xl",children:e}),a.jsx("p",{className:"relative z-10 mx-auto mt-5 max-w-2xl text-lg leading-8 text-muted-foreground sm:text-xl",children:s}),a.jsxs("div",{className:"relative z-10 mt-8 flex flex-wrap justify-center gap-3",children:[a.jsx(Y,{href:n.href,children:n.label}),a.jsx(Y,{href:r.href,variant:"outline",children:r.label})]})]})})})}export{Y as C,Bt as F,Tt as G,Pt as P,Lt as R,Gt as a,Ot as b,p as c,Ut as d,zt as f,Ct as g,ht as p,Mt as u,jt as v};
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.