1import{$l as e,$o as t,$s as n,Ac as r,Al as i,As as a,Bc as o,Bl as s,Bs as c,Bw as l,Cc as u,Cl as d,Cs as f,Dc as p,Dl as m,Ds as h,Ec as g,El as _,Es as v,Fc as y,Fl as b,Fs as x,Fw as S,Gl as C,Go as ee,Gs as w,Hc as T,Hl as te,Hs as E,Ic as D,Il as ne,Is as O,Iw as k,Jl as A,Jo as j,Js as M,Jw as re,Kl as ie,Ko as N,Ks as P,Kw as ae,Lc as F,Ll as oe,Ls as I,Lw as L,Mc as R,Ml as z,Ms as B,Mw as V,Nc as H,Nl as U,Ns as W,Nw as se,Oc as G,Ol as ce,Os as le,Pc as ue,Pl as de,Ps as fe,Pw as pe,Ql as me,Qo as he,Qs as ge,Rc as _e,Rl as ve,Rs as ye,Rw as be,Sc as xe,Sl as Se,Ss as Ce,Tc as we,Tl as Te,Ts as Ee,Uc as De,Ul as Oe,Us as ke,Vc as Ae,Vl as je,Vs as Me,Wc as Ne,Wl as Pe,Wo as Fe,Ws as Ie,Xl as Le,Xo as Re,Xs as ze,Yl as Be,Yo as Ve,Ys as He,Yw as Ue,Zl as We,Zo as Ge,Zs as Ke,_c as qe,_s as Je,aT as Ye,ac as Xe,as as Ze,au as Qe,bc as $e,bl as et,bs as tt,cc as nt,cs as rt,cu as it,dT as at,dc as ot,ds as st,du as ct,ec as lt,es as ut,eu as dt,fc as ft,fs as pt,fu as mt,gT as ht,gc as gt,go as _t,gs as vt,hc as yt,ho as bt,hs as xt,ic as St,is as Ct,iu as wt,jc as Tt,jl as Et,js as Dt,kc as Ot,kl as kt,ks as At,lc as jt,ll as Mt,ls as Nt,lu as Pt,mc as Ft,mo as It,ms as Lt,mu as Rt,nT as zt,nc as Bt,ns as Vt,nu as Ht,oc as Ut,os as Wt,ou as Gt,pc as Kt,po as qt,ps as Jt,pu as Yt,ql as Xt,qo as Zt,qs as Qt,qw as $t,r as en,rc as tn,rs as nn,ru as rn,sT as an,sc as on,ss as sn,su as cn,t as K,tc as ln,ts as un,tu as dn,uT as fn,uc as pn,us as mn,uu as hn,vc as gn,vl as _n,vs as vn,wc as yn,wl as bn,ws as xn,xc as Sn,xl as Cn,xs as wn,yc as Tn,yl as En,ys as Dn,zc as On,zl as kn,zs as An}from"./utils-DW2xwaFb.js";import{n as jn,r as Mn,t as Nn}from"./navigation-CDlrFp9y.js";import{r as Pn}from"./api-client-CI0Or3x1.js";import{t as Fn}from"./useQuery-DC78OWmn.js";import{a as In,c as Ln,f as Rn,m as zn,n as Bn,t as Vn}from"./model-logos-I6xu5H0x.js";import{t as Hn}from"./check-BeP-855d.js";import{t as Un}from"./chevron-right-C5NIBsRD.js";import{t as Wn}from"./coins-EDC85P8Y.js";import{t as Gn}from"./eye-D0PhuOB7.js";import{t as Kn}from"./folder-open-DiXedWql.js";import{t as qn}from"./studio-navigation-CHs6Gj4h.js";import{t as Jn}from"./image-Dkxzc6z0.js";import{t as Yn}from"./images-DvxgWs37.js";import{n as Xn,t as Zn}from"./scissors-Bk597stp.js";import{t as Qn}from"./plus-DX6Kafgs.js";import{t as $n}from"./refresh-cw-BwDI848I.js";import{t as er}from"./sparkles-BJxR-W2D.js";import{o as tr}from"./sheet-cO3ueWmn.js";import{R as nr,U as rr,d as ir,f as ar,g as or,h as sr,k as cr,l as lr,m as ur,p as dr,s as fr,u as pr,v as mr,x as q,y as hr}from"./index-DnGl5zPx.js";import{a as gr,i as _r,s as vr,t as yr}from"./agent-SIl-uhUv.js";import{f as br,n as xr,o as Sr,r as Cr,t as wr}from"./agent-settings-CSqg8es2.js";import{n as Tr,r as Er,t as Dr}from"./popover-VXtlVAL2.js";var Or=q(`bookmark`,[[`path`,{d:`m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z`,key:`1fy3hk`}]]),kr=q(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Ar=q(`hard-drive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),jr=q(`sliders-horizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),J=ht(at(),1),Y=fn(),X=`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[oklch(0.512_0.273_266.9)] focus-visible:ring-offset-2`,Mr=[tr,Zn,Xn],Nr=[`text-[oklch(0.512_0.273_266.9)]`,`text-[oklch(0.58_0.13_181)]`,`text-[oklch(0.58_0.22_25)]`],Pr=(0,J.forwardRef)(function({labels:e,placeholders:t,suggestions:n,initialPrompt:r=``,onPromptChange:i,onSkillChange:a,onAttachmentsChange:o,onOpenLibrary:s,onSuggestionSelect:c,className:l},u){let d=Mn(),f=jn(),{data:p}=nr(),m=(0,J.useRef)(null),h=(0,J.useRef)(null),g=(0,J.useRef)(null),_=(0,J.useRef)([]),[v,y]=(0,J.useState)(r),[b,x]=(0,J.useState)([]),[S,C]=(0,J.useState)(null),[ee,w]=(0,J.useState)(0),[T,te]=(0,J.useState)(!1),[E,D]=(0,J.useState)(!1),[ne,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)(`/`),[j,M]=Bn(),re=Sr(j.modelOption,j.resolution===`auto`?void 0:j.resolution),ie=`${e.submit}
1 · ${e.creditCost(re)}`,N=b.some(e=>e.status===`uploading`),P=b.some(e=>e.status===`uploaded`),ae=(!!S||!!v.trim()||P)&&!N&&!E,F=(S?.suggestions??n).slice(0,3),oe=t[ee%Math.max(t.length,1)]??e.promptFallback,I=t.join(`\0`),L=(0,J.useCallback)(e=>{y(e),i?.(e)},[i]);(0,J.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>te(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,J.useEffect)(()=>{w(0)},[I]),(0,J.useEffect)(()=>{if(v||T||t.length<2)return;let e=window.setInterval(()=>w(e=>(e+1)%t.length),3200);return()=>window.clearInterval(e)},[I,t.length,v,T]),(0,J.useEffect)(()=>{_.current=b,o?.(b)},[b,o]),(0,J.useEffect)(()=>()=>{_.current.forEach(e=>{e.preview.startsWith(`blob:`)&&URL.revokeObjectURL(e.preview)})},[]);let R=(0,J.useCallback)(()=>{m.current?.scrollIntoView({behavior:T?`auto`:`smooth`,block:`center`}),requestAnimationFrame(()=>{let e=h.current;e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)})},[T]),z=(0,J.useCallback)(e=>{C(e),a?.(e),R()},[R,a]),B=(0,J.useCallback)(t=>{if(t.length!==0){if(!p?.user){A(f||`/`),O(!0);return}x(n=>{let r=t.filter(e=>!!e.src&&!n.some(t=>t.url===e.src)).map(t=>({id:gr(),name:t.name||t.alt||e.untitledImage,preview:t.src,url:t.src,status:`uploaded`,kind:`source`}));return r.length>0?[...n,...r]:n}),R()}},[R,e.untitledImage,f,p?.user]),V=(0,J.useCallback)(()=>{if(!p?.user){A(f||`/`),O(!0);return}s?.()},[s,f,p?.user]),H=(0,J.useCallback)(()=>{x(e=>(e.forEach(e=>{e.preview.startsWith(`blob:`)&&URL.revokeObjectURL(e.preview)}),[])),L(``),C(null),D(!1),a?.(null),R()},[R,a,L]);(0,J.useImperativeHandle)(u,()=>({applySkill:z,fillPrompt:e=>{L(e),R()},openLibrary:V,attachLibraryImages:B,focus:R,reset:H}),[z,B,R,V,H,L]);async function U(t){let n=t.filter(e=>e.type.startsWith(`image/`));if(n.length===0)return;if(!p?.user){A(f||`/`),O(!0);return}let r=n.map(t=>({id:gr(),name:t.name||e.untitledImage,preview:URL.createObjectURL(t),status:`uploading`,kind:`source`,file:t}));x(e=>[...e,...r.map(({file:e,...t})=>t)]),await Promise.all(r.map(async t=>{try{let e=await vr(t.file);x(n=>n.map(n=>n.id===t.id?{...n,url:e,status:`uploaded`}:n))}catch{lr.error(e.uploadFailed),x(n=>n.map(n=>n.id===t.id?{...n,status:`error`,error:e.attachmentError}:n))}}))}function W(e){x(t=>{let n=t.find(t=>t.id===e);return n?.preview.startsWith(`blob:`)&&URL.revokeObjectURL(n.preview),t.filter(t=>t.id!==e)})}function se(){C(null),a?.(null),R()}function G(){if(!ae)return;let t=_r(),n=v.trim(),r=b.filter(e=>e.status===`uploaded`&&!!e.url).map(e=>({...e,preview:e.url})),i;if(S){let e=S.workflow,t=In(e);e.mode===`upload-first`&&r.length>0&&(t=Rn(e,t,r.map(e=>({id:e.id,name:e.name,url:e.url})))),i={definition:e,draft:t,...n?{supplementaryPrompt:n}:{}}}let a={...!S&&n?{prompt:n}:{},settings:j,attachments:r,...i?{skillWorkflow:i}:{}};try{sessionStorage.setItem(`agent:initial-turn:${t}`,JSON.stringify(a))}catch{lr.error(e.startFailed);return}if(!p?.user){A(`/chat/${t}`),O(!0);return}D(!0),d.push(`/chat/${t}`)}return(0,Y.jsxs)(`section`,{ref:m,className:K(`relative w-full max-w-[520px] [font-family:Poppins,ui-sans-serif,system-ui,sans-serif]`,l),children:[(0,Y.jsx)(`h1`,{className:`text-[20px] leading-7 font-normal tracking-[-0.015em] text-[oklch(0.19_0.01_260)] min-[900px]:text-center`,children:e.heading}),(0,Y.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),G()},className:`mt-5 min-h-[120px] overflow-hidden rounded-[24px] border border-[oklch(0.91_0.008_250)] bg-white shadow-[0_12px_36px_rgba(45,62,105,0.095)] transition-shadow duration-200 focus-within:shadow-[0_14px_42px_rgba(45,62,105,0.13)] min-[900px]:mt-6`,children:[(b.length>0||S)&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 pt-3`,children:[S&&(0,Y.jsxs)(`span`,{className:`inline-flex h-8 max-w-full items-center gap-1.5 rounded-lg bg-[oklch(0.952_0.03_267)] px-2.5 text-xs text-[oklch(0.42_0.22_267)]`,children:[(0,Y.jsx)(er,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e.selectedSkill}),(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:S.title}),(0,Y.jsx)(`button`,{type:`button`,onClick:se,"aria-label":e.removeSkill,title:e.removeSkill,className:K(`-mr-1 flex size-6 items-center justify-center rounded-md hover:bg-black/[0.055]`,X),children:(0,Y.jsx)(mr,{className:`size-3`,"aria-hidden":`true`})})]}),b.map(t=>(0,Y.jsxs)(`div`,{className:`relative size-14 overflow-hidden rounded-[10px] border border-[oklch(0.91_0.008_250)] bg-[oklch(0.972_0.004_260)]`,title:t.error||t.name,children:[(0,Y.jsx)(`img`,{src:t.preview,alt:t.name,className:K(`size-full object-cover`,t.status===`error`&&`opacity-45`)}),t.status===`uploading`&&(0,Y.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/30 text-white`,"aria-label":e.attachmentUploading,children:(0,Y.jsx)(hr,{className:`size-4 animate-spin`,"aria-hidden":!0})}),t.status===`error`&&(0,Y.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center text-red-600`,"aria-label":e.attachmentError,children:(0,Y.jsx)(kr,{className:`size-4`,"aria-hidden":!0})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>W(t.id),"aria-label":e.removeAttachment(t.name),title:e.removeAttachment(t.name),className:K(`absolute top-1 right-1 flex size-5 items-center justify-center rounded-full bg-black/65 text-white hover:bg-black/80`,X),children:(0,Y.jsx)(mr,{className:`size-3`,"aria-hidden":`true`})})]},t.id))]}),(0,Y.jsx)(`textarea`,{ref:h,value:v,rows:2,disabled:E,placeholder:oe,onChange:e=>L(e.target.value),onPaste:e=>{let t=yr(e.clipboardData);t.length!==0&&(e.preventDefault(),U(t))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),G())},className:`block min-h-16 w-full resize-none bg-transparent px-4 pt-4 pb-2 text-[15px] leading-6 text-[oklch(0.19_0.01_260)] outline-none placeholder:text-[oklch(0.55_0.02_260)] disabled:opacity-60`}),(0,Y.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center gap-1.5 px-3 pb-3`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:N||E,onClick:()=>
1{if(!p?.user){A(f||`/`),O(!0);return}g.current?.click()},"aria-label":e.addImages,title:e.addImages,className:K(`flex size-10 shrink-0 items-center justify-center rounded-full border border-[oklch(0.91_0.008_250)] text-[oklch(0.55_0.02_260)] transition-colors hover:bg-[oklch(0.972_0.004_260)] hover:text-[oklch(0.19_0.01_260)] disabled:pointer-events-none disabled:opacity-40 min-[900px]:size-9`,X),children:(0,Y.jsx)(Qn,{className:`size-4`,"aria-hidden":`true`})}),(0,Y.jsx)(`input`,{ref:g,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:e=>{U(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),(0,Y.jsx)(Fr,{settings:j,onChange:M,labels:e,disabled:E}),(0,Y.jsx)(`button`,{type:`submit`,disabled:!ae,"aria-label":ie,title:ie,className:K(`ml-auto flex h-10 min-w-20 shrink-0 items-center justify-center gap-1.5 rounded-full bg-[oklch(0.19_0.01_260)] px-3 text-white transition-colors hover:bg-black disabled:pointer-events-none disabled:bg-[oklch(0.84_0.008_250)] min-[900px]:h-9 min-[900px]:min-w-[72px]`,X),children:N||E?(0,Y.jsx)(hr,{className:`size-4 animate-spin`,"aria-hidden":`true`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Wn,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`text-xs font-semibold tabular-nums`,children:re}),(0,Y.jsx)(zn,{className:`size-3.5`,"aria-hidden":`true`})]})})]})]}),F.length>0&&(0,Y.jsx)(`div`,{className:`mt-5 grid gap-1 min-[900px]:absolute min-[900px]:top-[calc(100%+16px)] min-[900px]:right-0 min-[900px]:left-0 min-[900px]:mt-0`,children:F.map((e,t)=>{let n=Mr[t]??tr;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{c?.(e,t)||(L(e),R())},className:K(`flex min-h-10 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs leading-4 text-[oklch(0.48_0.018_260)] transition-colors duration-200 hover:bg-[oklch(0.972_0.004_260)] hover:text-[oklch(0.19_0.01_260)]`,X),children:[(0,Y.jsx)(n,{className:K(`size-4 shrink-0`,Nr[t]??Nr[0]),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})]},e)})}),(0,Y.jsx)(pr,{open:ne,onOpenChange:O,children:(0,Y.jsxs)(ar,{className:`border-0 bg-transparent p-0 shadow-none sm:max-w-md`,children:[(0,Y.jsx)(or,{className:`sr-only`,children:e.gateDialogTitle}),(0,Y.jsx)(dr,{className:`sr-only`,children:e.gateDescription}),(0,Y.jsx)(cr,{callbackUrl:k,onSignUp:()=>O(!1),labels:{title:e.gateTitle,description:e.gateDescription,email:e.gateEmail,emailPlaceholder:e.gateEmailPlaceholder,password:e.gatePassword,passwordPlaceholder:e.gatePasswordPlaceholder,submit:e.gateSecondary,google:e.gateGoogle,github:e.gateGithub,or:e.gateOr,noAccount:e.gateNoAccount,signUp:e.gatePrimary,noMethodsTitle:e.gateNoMethodsTitle,noMethodsDescription:e.gateNoMethodsDescription,errorFallback:e.gateErrorFallback},onSuccess:()=>{O(!1),window.location.assign(an(k))}})]})})]})});function Fr({settings:e,onChange:t,labels:n,disabled:r}){function i(n){t({...e,...n})}let a=e.resolution===`auto`?n.auto:Cr.find(t=>t.value===e.resolution)?.label??e.resolution;return(0,Y.jsxs)(Dr,{children:[(0,Y.jsxs)(Er,{render:(0,Y.jsx)(`button`,{type:`button`,disabled:r,"aria-label":n.settings,title:n.settings,className:K(`flex h-10 max-w-[210px] items-center gap-1.5 rounded-lg px-2.5 text-xs text-[oklch(0.48_0.018_260)] transition-colors hover:bg-[oklch(0.972_0.004_260)] hover:text-[oklch(0.19_0.01_260)] disabled:pointer-events-none disabled:opacity-40 min-[900px]:h-9 min-[900px]:max-w-[230px]`,X)}),children:[(0,Y.jsx)(jr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[br(e.modelOption),` · `,a]})]}),(0,Y.jsxs)(Tr,{side:`top`,align:`start`,sideOffset:8,className:`w-[min(320px,calc(100vw-24px))] gap-3 rounded-xl border-[oklch(0.91_0.008_250)] bg-white p-3 text-[oklch(0.19_0.01_260)] shadow-[0_14px_36px_rgba(45,62,105,0.13)]`,children:[(0,Y.jsx)(Ir,{children:n.imageModels}),(0,Y.jsx)(`div`,{className:`grid gap-1`,children:xr.map(t=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i({modelOption:t.value}),className:K(`flex h-10 items-center gap-2.5 rounded-lg px-2.5 text-left text-xs transition-colors hover:bg-[oklch(0.972_0.004_260)] min-[900px]:h-9`,e.modelOption===t.value&&`bg-[oklch(0.952_0.03_267)] text-[oklch(0.42_0.22_267)]`,X),children:[(0,Y.jsx)(Vn,{model:t.value,className:`size-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.label}),e.modelOption===t.value&&(0,Y.jsx)(Hn,{className:`size-3.5`,"aria-hidden":`true`})]},t.value))}),(0,Y.jsx)(Ir,{children:n.resolution}),(0,Y.jsx)(`div`,{className:`grid grid-cols-4 gap-1`,children:Cr.map(t=>{let r=e.resolution===t.value;return(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>i({resolution:t.value}),className:K(`h-10 rounded-lg border text-xs transition-colors min-[900px]:h-8`,r?`border-[oklch(0.512_0.273_266.9)]/30 bg-[oklch(0.952_0.03_267)] text-[oklch(0.42_0.22_267)]`:`border-[oklch(0.91_0.008_250)] text-[oklch(0.55_0.02_260)] hover:bg-[oklch(0.972_0.004_260)]`,X),children:t.value===`auto`?n.auto:t.label},t.value)})}),(0,Y.jsx)(Ir,{children:n.aspectRatio}),(0,Y.jsx)(`div`,{className:`grid grid-cols-4 gap-1`,children:wr.map(t=>{let r=e.aspectRatio===t;return(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>i({aspectRatio:t}),className:K(`h-10 rounded-lg border text-[11px] transition-colors min-[900px]:h-8`,r?`border-[oklch(0.512_0.273_266.9)]/30 bg-[oklch(0.952_0.03_267)] text-[oklch(0.42_0.22_267)]`:`border-[oklch(0.91_0.008_250)] text-[oklch(0.55_0.02_260)] hover:bg-[oklch(0.972_0.004_260)]`,X),children:t===`auto`?n.auto:t},t)})})]})]})}function Ir({children:e}){return(0,Y.jsx)(`p`,{className:`text-[11px] font-medium tracking-wide text-[oklch(0.55_0.02_260)] uppercase`,children:e})}var Z=`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[oklch(0.512_0.273_266.9)] focu
1s-visible:ring-offset-2`;function Lr({labels:e,categories:t,assetTabs:n,onAddToConversation:r,onAssetSelect:i,onAssetCreate:a,source:o,initialSource:s=`skills`,onSourceChange:c,pinterestConnected:l=!1,onPinterestDisconnect:u,clipperInstalled:d=!1,clipperInstallUrl:f,className:p}){let[m,h]=(0,J.useState)(s),g=o??m,[_,v]=(0,J.useState)(null);function y(e){o===void 0&&h(e),c?.(e)}let b=[{id:`skills`,label:e.skills,icon:tr},{id:`assets`,label:e.myAssets,icon:Yn}],x=_===`pinterest`?e.pinterest:_===`google-drive`?e.googleDrive:``;return(0,Y.jsxs)(`section`,{className:K(`flex h-full min-h-0 min-w-0 flex-1 flex-col border-l border-[oklch(0.91_0.008_250)] bg-white [font-family:Poppins,ui-sans-serif,system-ui,sans-serif] text-[oklch(0.19_0.01_260)] max-[899px]:h-auto max-[899px]:w-full max-[899px]:border-t max-[899px]:border-l-0`,p),children:[(0,Y.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-1 overflow-x-auto border-b border-[oklch(0.91_0.008_250)] px-2.5 [scrollbar-width:none] max-[899px]:sticky max-[899px]:top-0 max-[899px]:z-20 max-[899px]:bg-white min-[900px]:h-11 [&::-webkit-scrollbar]:hidden`,children:[b.map(e=>{let t=e.icon,n=g===e.id;return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":n,onClick:()=>y(e.id),className:K(`flex h-10 shrink-0 items-center gap-2 rounded-lg px-2.5 text-sm font-medium text-[oklch(0.55_0.02_260)] transition-colors duration-200 hover:bg-[oklch(0.972_0.004_260)] hover:text-[oklch(0.19_0.01_260)] min-[900px]:h-8`,Z,n&&`bg-[oklch(0.952_0.03_267)] text-[oklch(0.512_0.273_266.9)]`),children:[(0,Y.jsx)(t,{className:`size-4`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e.label})]},e.id)}),g===`skills`&&(0,Y.jsxs)(Nn,{href:`/skills`,className:K(`ml-auto flex h-10 shrink-0 items-center gap-1 rounded-lg px-2.5 text-xs font-semibold text-[oklch(0.512_0.273_266.9)] transition-colors hover:bg-[oklch(0.952_0.03_267)] min-[900px]:h-8`,Z),children:[e.browseAllSkills,(0,Y.jsx)(Un,{className:`size-3.5`,"aria-hidden":!0})]})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 max-[899px]:overflow-visible`,children:[g===`skills`&&(0,Y.jsx)(Rr,{labels:e,categories:t,onAddToConversation:r}),g===`pinterest`&&(0,Y.jsx)(Br,{labels:e,connected:l,onConnect:()=>v(`pinterest`),onDisconnect:u}),g===`assets`&&(0,Y.jsx)(Vr,{labels:e,tabs:n,onSelect:i,onCreate:a}),g===`clipper`&&(0,Y.jsx)(Wr,{labels:e,installed:d,installUrl:f})]}),(0,Y.jsx)(pr,{open:_!==null,onOpenChange:e=>{e||v(null)},children:(0,Y.jsxs)(ar,{showCloseButton:!1,className:`max-w-md rounded-2xl bg-white p-5 text-[oklch(0.19_0.01_260)] shadow-[0_22px_60px_rgba(40,72,150,.16)]`,children:[(0,Y.jsxs)(sr,{children:[(0,Y.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-xl bg-[oklch(0.952_0.03_267)] text-[oklch(0.512_0.273_266.9)]`,children:_===`pinterest`?(0,Y.jsx)(Xn,{className:`size-5`,"aria-hidden":!0}):(0,Y.jsx)(Ar,{className:`size-5`,"aria-hidden":!0})}),(0,Y.jsx)(or,{className:`pt-1 text-lg`,children:e.connectorDialogTitle(x)}),(0,Y.jsx)(dr,{className:`leading-6`,children:e.connectorDialogDescription(x)})]}),(0,Y.jsx)(ur,{className:`-mx-5 -mb-5 bg-[oklch(0.972_0.004_260)] px-5 py-4`,children:(0,Y.jsx)(ir,{render:(0,Y.jsx)(`button`,{type:`button`,className:K(`h-9 rounded-lg bg-[oklch(0.19_0.01_260)] px-4 text-sm font-semibold text-white hover:opacity-90`,Z)}),children:e.connectorDialogClose})})]})})]})}function Rr({labels:e,categories:t,onAddToConversation:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(new Map),a=(0,J.useRef)(null),[o,s]=(0,J.useState)(t[0]?.id??``),[c,l]=(0,J.useState)({}),[u,d]=(0,J.useState)(2);(0,J.useEffect)(()=>{t.some(e=>e.id===o)||s(t[0]?.id??``)},[o,t]);let f=(0,J.useCallback)(()=>{a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{let e=r.current;if(!e||!t.length)return;let n=e.getBoundingClientRect(),a=window.matchMedia(`(min-width: 900px)`).matches?n.top+76:Math.max(92,window.innerHeight*.2),o=t[0].id;for(let e of t){let t=i.current.get(e.id);t&&t.getBoundingClientRect().top<=a&&(o=e.id)}s(e=>e===o?e:o)})},[t]);(0,J.useEffect)(()=>{let e=r.current;if(!e)return;e.addEventListener(`scroll`,f,{passive:!0}),window.addEventListener(`resize`,f);let t=window.matchMedia(`(min-width: 900px)`).matches,n=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>
1Math.abs(e.boundingClientRect.top)-Math.abs(t.boundingClientRect.top))[0]?.target.id.replace(`studio-skills-`,``);t&&s(t)},{root:t?e:null,rootMargin:t?`-72px 0px -62% 0px`:`-96px 0px -62% 0px`,threshold:[0,.05]});return i.current.forEach(e=>n.observe(e)),f(),()=>{e.removeEventListener(`scroll`,f),window.removeEventListener(`resize`,f),n.disconnect(),a.current!==null&&cancelAnimationFrame(a.current)}},[f]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{let t=e>=980?4:e>=720?3:2;d(e=>e===t?e:t)},n=()=>t(e.getBoundingClientRect().width);if(n(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n);let i=new ResizeObserver(e=>{let n=e[0];n&&t(n.contentRect.width)});return i.observe(e),()=>i.disconnect()},[]);function p(e){s(e.id);let t=i.current.get(e.id),n=r.current;if(!t||!n)return;let a=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;if(window.matchMedia(`(min-width: 900px)`).matches){let e=n.getBoundingClientRect(),r=t.getBoundingClientRect();n.scrollTo({top:Math.max(0,n.scrollTop+r.top-e.top-36),behavior:a?`auto`:`smooth`})}else t.scrollIntoView({block:`start`,behavior:a?`auto`:`smooth`})}function m(e){l(t=>{let n=(t[e.id]??0)+u;return{...t,[e.id]:n>=e.skills.length?0:n}})}return(0,Y.jsxs)(`div`,{ref:r,className:`h-full min-h-0 overflow-y-auto overscroll-contain max-[899px]:h-auto max-[899px]:overflow-visible`,children:[(0,Y.jsx)(`div`,{role:`tablist`,"aria-label":e.skills,className:`sticky top-0 z-10 flex h-11 items-center gap-1 overflow-x-auto border-b border-[oklch(0.91_0.008_250)] bg-white/95 px-3 backdrop-blur-md [scrollbar-width:none] max-[899px]:top-12 min-[900px]:h-9 [&::-webkit-scrollbar]:hidden`,children:t.map(e=>{let t=e.id===o;return(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,"aria-controls":`studio-skills-${e.id}`,onClick:()=>p(e),className:K(`h-10 shrink-0 rounded-lg px-2.5 text-xs font-semibold text-[oklch(0.55_0.02_260)] transition-colors duration-200 hover:bg-[oklch(0.972_0.004_260)] min-[900px]:h-7`,Z,t&&`bg-[oklch(0.952_0.03_267)] text-[oklch(0.512_0.273_266.9)]`),children:e.label},e.id)})}),(0,Y.jsx)(`div`,{className:`max-w-[1320px] space-y-6 px-4 py-6`,children:t.map((t,r)=>{let a=c[t.id]??0,o=r===0?t.skills:t.skills.slice(a,a+u);return(0,Y.jsxs)(`section`,{id:`studio-skills-${t.id}`,ref:e=>{e?i.current.set(t.id,e):i.current.delete(t.id)},className:`relative scroll-mt-20`,children:[(0,Y.jsxs)(`div`,{className:K(`flex items-center justify-between gap-3`,r===0?`sr-only`:`mb-2.5`),children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold tracking-[-0.01em]`,children:t.label}),r!==0&&t.skills.length>2&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>m(t),className:K(`hidden h-7 items-center gap-1 rounded-lg px-2 text-xs font-semibold text-[oklch(0.512_0.273_266.9)] transition-colors hover:bg-[oklch(0.952_0.03_267)] min-[900px]:flex`,Z),children:[e.next,(0,Y.jsx)(Un,{className:`size-3.5`,"aria-hidden":!0})]})]}),(0,Y.jsx)(`div`,{className:K(`hidden gap-4 min-[900px]:grid`,u===4?`grid-cols-4`:u===3?`grid-cols-3`:`grid-cols-2`),children:o.map(t=>(0,Y.jsx)(zr,{skill:t,labels:e,onAdd:n},t.id))}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-6 min-[540px]:grid-cols-2 min-[900px]:hidden`,children:t.skills.map(t=>(0,Y.jsx)(zr,{skill:t,labels:e,onAdd:n},t.id))})]},t.id)})})]})}function zr({skill:e,labels:t,onAdd:n}){let[r,i]=(0,J.useState)(!1);return(0,Y.jsxs)(`article`,{className:`group min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`relative aspect-[4/3] overflow-hidden rounded-[14px] bg-[oklch(0.972_0.004_260)]`,children:[r?(0,Y.jsx)(`div`,{role:`img`,"aria-label":t.imageFallback,className:`flex size-full items-center justify-center text-[oklch(0.55_0.02_260)]`,children:(0,Y.jsx)(Jn,{className:`size-6`,"aria-hidden":!0})}):(0,Y.jsx)(`img`,{src:e.image,alt:e.imageAlt,loading:`lazy`,decoding:`async`,onError:()=>i(!0),className:`size-full object-cover transition-transform duration-200 group-hover:scale-[1.015]`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e),"aria-label":t.addToConversation,title:t.addToConversation,className:K(`absolute top-3 right-3 flex size-11 items-center justify-center rounded-full bg-white/92 text-[oklch(0.512_0.273_266.9)] opacity-0 shadow-[0_6px_18px_rgba(22,30,52,.16)] backdrop-blur-sm transition-opacity group-hover:opacity-100 focus-visible:opacity-100 max-[899px]:opacity-100 min-[900px]:size-9`,Z),children:(0,Y.jsx)(Qn,{className:`size-4`,"aria-hidden":!0})})]}),(0,Y.jsxs)(`div`,{className:`pt-3`,children:[(0,Y.jsx)(`h3`,{className:`line-clamp-1 text-sm font-semibold`,children:e.title}),(0,Y.jsx)(`p`,{className:`mt-0.5 line-clamp-1 min-h-5 text-xs leading-5 text-[oklch(0.55_0.02_260)]`,children:e.description}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-2 text-[11px] text-[oklch(0.55_0.02_260)] tabular-nums`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 font-medium text-[oklch(0.19_0.01_260)]`,children:[(0,Y.jsx)(`img`,{src:e.authorAvatar,alt:``,"aria-hidden":!0,loading:`lazy`,decoding:`async`,className:`size-4 shrink-0 rounded-full object-cover`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.author})]}),(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(Gn,{className:`size-3`,"aria-hidden":!0}),t.formatViews(e.views)]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(Or,{className:`size-3`,"aria-hidden":!0}),t.formatSaves(e.saves)]})]})]})]})]})}function Br({labels:e,connected:t,onConnect:n,onDisconnect:r}){return(0,Y.jsxs)(Gr,{children:[(0,Y.jsx)(`span`,{className:`flex size-14 items-center justify-center rounded-2xl bg-[oklch(0.952_0.03_267)] text-[oklch(0.512_0.273_266.9)]`,children:(0,Y.jsx)(Xn,{className:`size-6`,"aria-hidden":!0})}),(0,Y.jsx)(`h2`,{className:`mt-4 text-lg font-semibold`,children:e.pinterestTitle}),(0,Y.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[oklch(0.55_0.02_260)]`,children:e.pinterestDescription}),(0,Y.jsx)(`button`,{type:`button`,onClick:t?r:n,disabled:t&&!r,className:K(`mt-5 h-10 rounded-lg bg-[oklch(0.512_0.273_266.9)] px-5 text-sm font-semibold text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Z),children:t?e.pinterestDisconnect:e.pinterestConnect})]})}function Vr({labels:e,tabs:t,onSelect:n,onCreate:r}){let[i,a]=(0,J.useState)(t[0]?.id??`custom`),o=Fn({queryKey:[`studio-agent-library`],queryFn:()=>Pn(`/api/agent/library`)});(0,J.useEffect)(()=>{t.some(e=>e.id===i)||a(t[0]?.id??`custom`)},[i,t]);let s=o.data?.images??[],c=(0,J.useMemo)(()=>s.filter(e=>e.category===i||!e.category&&i===`custom`),[i,s]),l=t.find(e=>e.id===i)??t[0];return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col max-[899px]:h-auto`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0`,children:[(0,Y.jsx)(`h2`,{className:`sr-only`,children:e.assetsTitle}),(0,Y.jsx)(`div`,{role:`tablist`,"aria-label":e.assetsTitle,className:`flex h-11 gap-1 overflow-x-auto border-b border-[oklch(0.91_0.008_250)] px-3 [scrollbar-width:none] min-[900px]:h-9 [&::-webkit-scrollbar]:hidden`,children:t.slice(0,4).map(e=>{let t=e.id===i;return(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:()=>a(e.id),className:K(`relative h-10 shrink-0 px-2.5 text-xs font-semibold text-[oklch(0.55_0.02_260)] transition-colors min-[900px]:h-9`,Z,t&&`text-[oklch(0.512_0.273_266.9)]`),children:[e.label,t&&(0,Y.jsx)(`span`,{className:`absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-[oklch(0.512_0.273_266.9)]`})]},e.id)})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-5 max-[899px]:overflow-visible sm:px-6`,children:o.isPending?(0,Y.jsx)(Kr,{icon:hr,label:e.assetsLoading,spin:!0}):o.isError?(0,Y.jsx)(Kr,{icon:$n,label:e.assetsError,action:e.assets
1Retry,onAction:()=>o.refetch()}):c.length?(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-3`,children:c.map(t=>(0,Y.jsxs)(`button`,{type:`button`,"aria-label":e.assetsSelect(t.name),onClick:()=>n(t),className:K(`group overflow-hidden rounded-[14px] bg-[oklch(0.972_0.004_260)] text-left transition-shadow hover:shadow-[0_10px_28px_rgba(40,72,150,.12)]`,Z),children:[(0,Y.jsx)(Ur,{image:t,fallback:e.imageFallback}),(0,Y.jsx)(`span`,{className:`block truncate px-3 py-2 text-xs font-medium`,children:t.name})]},t.id))}):l?.id===`brand-kit`?(0,Y.jsx)(Hr,{title:l.emptyTitle,description:l.emptyDescription,action:l.actionLabel,onAction:l.actionLabel&&r?()=>r(l.id):void 0}):l?(0,Y.jsx)(Kr,{icon:Kn,label:l.emptyTitle,description:l.emptyDescription,action:l.actionLabel,onAction:l.actionLabel&&r?()=>r(l.id):void 0}):null})]})}function Hr({title:e,description:t,action:n,onAction:r}){return(0,Y.jsxs)(`div`,{className:`flex min-h-[480px] flex-col items-center justify-center px-5 py-8 text-center`,children:[(0,Y.jsx)(`div`,{className:`grid w-full max-w-[370px] grid-cols-3 gap-1 overflow-hidden rounded-xl bg-[oklch(0.952_0.03_267)] p-1 shadow-[0_12px_34px_rgba(40,72,150,.12)]`,children:[`/imgs/generated/logo-anyimg-reference-v1.webp`,`/imgs/examples/cover-1.webp`,`/imgs/examples/style-1-after.webp`,`/imgs/examples/logo-2.webp`,`/imgs/examples/cover-2.webp`].map((e,t)=>(0,Y.jsx)(`img`,{src:e,alt:``,"aria-hidden":!0,className:K(`h-24 w-full object-cover`,t===0&&`col-span-2`,t===2&&`row-span-2 h-full`)},e))}),(0,Y.jsx)(`p`,{className:`mt-5 text-base font-semibold`,children:e}),(0,Y.jsx)(`p`,{className:`mt-2 max-w-md text-xs leading-5 text-[oklch(0.55_0.02_260)]`,children:t}),n&&r&&(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:K(`mt-4 h-10 rounded-lg bg-[oklch(0.19_0.01_260)] px-4 text-xs font-semibold text-white hover:opacity-90 min-[900px]:h-9`,Z),children:n})]})}function Ur({image:e,fallback:t}){let[n,r]=(0,J.useState)(!1);return(0,Y.jsx)(`span`,{className:`block aspect-square overflow-hidden`,children:n?(0,Y.jsx)(`span`,{role:`img`,"aria-label":t,className:`flex size-full items-center justify-center text-[oklch(0.55_0.02_260)]`,children:(0,Y.jsx)(Jn,{className:`size-5`,"aria-hidden":!0})}):(0,Y.jsx)(`img`,{src:e.src,alt:e.alt||e.name,onError:()=>r(!0),className:`size-full object-cover transition-transform duration-200 group-hover:scale-[1.02]`})})}function Wr({labels:e,installed:t,installUrl:n}){return(0,Y.jsxs)(Gr,{children:[(0,Y.jsx)(`div`,{className:`grid w-full max-w-[370px] grid-cols-3 gap-1 overflow-hidden rounded-xl bg-[oklch(0.952_0.03_267)] p-1 shadow-[0_12px_34px_rgba(40,72,150,.12)]`,children:[`/imgs/examples/style-3-after.webp`,`/imgs/examples/makeup-4-after.webp`,`/imgs/examples/cover-3.webp`,`/imgs/examples/logo-4.webp`,`/imgs/examples/style-4-after.webp`,`/imgs/examples/cover-4.webp`].map(e=>(0,Y.jsx)(`img`,{src:e,alt:``,"aria-hidden":!0,className:`aspect-square w-full object-cover`},e))}),(0,Y.jsx)(`h2`,{className:`mt-4 text-lg font-semibold`,children:t?e.clipperInstalledTitle:e.clipperTitle}),(0,Y.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[oklch(0.55_0.02_260)]`,children:t?e.clipperInstalledDescription:e.clipperDescription}),(0,Y.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:K(`mt-5 inline-flex h-10 items-center gap-2 rounded-lg bg-[oklch(0.512_0.273_266.9)] px-5 text-sm font-semibold text-white transition-opacity hover:opacity-90`,Z),children:[(0,Y.jsx)(er,{className:`size-4`,"aria-hidden":!0}),t?e.clipperOpen:e.clipperInstall]})]})}function Gr({children:e}){return(0,Y.jsx)(`div`,{className:`flex h-full min-h-[420px] flex-col items-center justify-center px-6 py-12 text-center max-[899px]:h-auto`,children:e})}function Kr({icon:e,label:t,description:n,action:r,onAction:i,spin:a}){return(0,Y.jsxs)(`div`,{className:`flex min-h-72 flex-col items-center justify-center px-5 text-center`,children:[(0,Y.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-xl bg-[oklch(0.972_0.004_260)] text-[oklch(0.55_0.02_260)]`,children:(0,Y.jsx)(e,{className:K(`size-5`,a&&`animate-spin`),"aria-hidden":!0})}),(0,Y.jsx)(`p`,{className:`mt-3 text-sm font-semibold`,children:t}),n&&(0,Y.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-5 text-[oklch(0.55_0.02_260)]`,children:n}),r&&i&&(0,Y.jsx)(`button`,{type:`button`,onClick:i,className:K(`mt-4 h-10 rounded-lg bg-[oklch(0.952_0.03_267)] px-4 text-xs font-semibold text-[oklch(0.512_0.273_266.9)] hover:bg-[oklch(0.93_0.05_267)] min-[900px]:h-9`,Z),children:r})]})}var Q=[`/imgs/examples/style-1-after.webp`,`/imgs/examples/makeup-1-after.webp`,`/imgs/examples/cover-1.webp`,`/imgs/generated/logo-anyimg-reference-v1.webp`,`/imgs/examples/style-2-after.webp`,`/imgs/examples/makeup-2-after.webp`,`/imgs/examples/cover-2.webp`,`/imgs/examples/logo-2.webp`,`/imgs/examples/style-3-after.webp`,`/imgs/examples/makeup-3-after.webp`,`/imgs/examples/cover-3.webp`,`/imgs/examples/logo-3.webp`,`/imgs/examples/style-4-after.webp`,`/imgs/examples/makeup-4-after.webp`,`/imgs/examples/cover-4.webp`,`/imgs/examples/logo-4.webp`,`/imgs/examples/style-source-a.webp`,`/imgs/examples/makeup-1-before.webp`,`/imgs/examples/logo-3-before.webp`,`/imgs/examples/style-source-b.webp`,`/imgs/examples/makeup-2-before.webp`,`/imgs/examples/makeup-3-before.webp`,`/imgs/examples/makeup-4-before.webp`,`/imgs/examples/makeup-1-before-2.webp`];function $(e){return Array.from({length:20},(t,n)=>`/imgs/generated/skill-covers/${e}-${String(n+1).padStart(2,`0`)}.webp`)}var qr={recommended:$(`recommended`),ecommerce:$(`ecommerce`),branding:$
1(`branding`),social:$(`social`),website:[`/imgs/generated/skill-covers/website-01.webp`,`/imgs/generated/skill-covers/website-02.webp`,`/imgs/generated/skill-covers/website-03.webp`,`/imgs/generated/skill-covers/website-04.webp`,`/imgs/generated/skill-covers/website-05.webp`,`/imgs/generated/skill-covers/website-06.webp`,`/imgs/generated/skill-covers/website-07.webp`,`/imgs/generated/en-campaign-result-1-v1.webp`,`/imgs/generated/catalog-tech-1788061497452.png`,`/imgs/examples/style-2-after.webp`,`/imgs/examples/style-3-after.webp`,`/imgs/generated/skill-covers/website-12.webp`,`/imgs/generated/zh-campaign-key-visual-v1.webp`,`/imgs/examples/cover-1.webp`,`/imgs/generated/skill-amazon-listing-v1.webp`,`/imgs/generated/catalog-coffee-1788061110050.png`,`/imgs/generated/skill-covers/website-17.webp`,`/imgs/generated/skill-covers/website-18.webp`,`/imgs/generated/skill-covers/website-19.webp`,`/imgs/generated/skill-covers/website-20.webp`],ads:[`/imgs/generated/skill-covers/ads-01.webp`,`/imgs/generated/skill-covers/ads-02.webp`,`/imgs/generated/skill-covers/ads-03.webp`,`/imgs/generated/skill-covers/ads-04.webp`,`/imgs/generated/skill-covers/ads-05.webp`,`/imgs/generated/skill-covers/ads-06.webp`,`/imgs/generated/skill-covers/ads-07.webp`,`/imgs/generated/skill-covers/ads-08.webp`,`/imgs/generated/skill-product-launch-v1.webp`,`/imgs/generated/catalog-coffee-1788061110050.png`,`/imgs/examples/cover-3.webp`,`/imgs/examples/cover-4.webp`,`/imgs/generated/skill-skincare-comparison-v1.webp`,`/imgs/generated/catalog-coffee-1788061110050.png`,`/imgs/examples/cover-1.webp`,`/imgs/generated/skill-covers/ads-16.webp`,`/imgs/generated/skill-skincare-comparison-v1.webp`,`/imgs/examples/cover-1.webp`,`/imgs/generated/skill-product-launch-v1.webp`,`/imgs/generated/editorial-tea-v2.png`]},Jr=[`ecommerce`,`branding`,`ecommerce`,`ads`,`branding`,`branding`,`social`,`ecommerce`,`ads`,`branding`,`ads`,`branding`,`ads`,`ads`,`branding`,`branding`,`ecommerce`,`ecommerce`,`ecommerce`,`ecommerce`],Yr=[[137284,18942],[86317,12876],[64905,9801],[18640,2381],[8427,1196],[46318,7904],[12739,1832],[9605,1477],[71126,11643],[5342,816],[29871,4056],[15428,2219],[3876,547],[52603,8341],[22417,3188],[42761,6854],[31908,5142],[27443,4639],[19276,3028],[12461,2054],[8913,1417],[6208,973],[4719,688],[2846,413],[1937,291],[928,146],[517,83],[243,37],[96,14],[58,9]],Xr=20,Zr=24,Qr=520,$r=360,ei=720,ti=420,ni=`anyimg:studio-composer-pane-width`;function ri({initialSource:n=`skills`,newProjectToken:r,initialSkillId:a,initialAsset:o}={}){let c=Mn(),{data:u}=nr(),d=(0,J.useRef)(null),f=(0,J.useRef)(null),p=(0,J.useRef)(null),m=(0,J.useRef)(null),h=(0,J.useRef)(null),g=(0,J.useRef)(null),_=(0,J.useRef)(null),[v,y]=(0,J.useState)(n),[x,w]=(0,J.useState)(Qr),[T,E]=(0,J.useState)(!1);(0,J.useEffect)(()=>{y(n)},[n]),(0,J.useEffect)(()=>{!r||m.current===r||(m.current=r,requestAnimationFrame(()=>d.current?.reset()))},[r]),(0,J.useEffect)(()=>{!o?.src||f.current===o.src||(f.current=o.src,requestAnimationFrame(()=>{d.current?.attachLibraryImages([{id:o.id,src:o.src,name:o.name,alt:o.alt}])}))},[o]);function D(){let e=g.current?.getBoundingClientRect().width??1200;return{min:$r,max:Math.max($r,Math.min(ei,e-ti))}}function O(e){let{min:t,max:n}=D();return Math.round(Math.min(n,Math.max(t,e)))}function M(e){try{localStorage.setItem(ni,String(e))}catch{}}function P(e,t=!1){let n=O(e);w(n),t&&M(n)}function F(e){if(e.button!==0)return;e.preventDefault(),_.current?.();let t=e.clientX,n=x;E(!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let r=e=>{P(n+e.clientX-t)},i=e=>{let r=O(n+e.clientX-t);w(r),M(r),o()},a=()=>o(),o=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),window.removeEventListener(`pointercancel`,a),document.body.style.cursor=``,document.body.style.userSelect=``,E(!1),_.current=null};_.current=o,window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i),window.addEventListener(`pointercancel`,a)}(0,J.useEffect)(()=>{try{let e=Number(localStorage.getItem(ni));Number.isFinite(e)&&e>0&&w(O(e))}catch{}let e=()=>w(e=>O(e));return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e),_.current?.()}},[]);let I=Fn({queryKey:[`user-credits`,`balance`],queryFn:()=>Pn(`/api/credits`),enabled:!!u?.user}),R=(0,J.useMemo)(()=>ii(),[]);(0,J.useEffect)(()=>
1{if(!a||p.current===a)return;let e=ii().flatMap(e=>e.skills).find(e=>e.id===a);e&&(p.current=a,requestAnimationFrame(()=>{d.current?.applySkill({id:e.id,title:e.title,workflow:e.workflow})}))},[a]);let B=(0,J.useMemo)(()=>[{id:`custom`,label:pt(),emptyTitle:Wt(),emptyDescription:st(),actionLabel:mn()}],[]);function H(e){y(e),requestAnimationFrame(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;h.current?.scrollIntoView({block:`start`,behavior:e?`auto`:`smooth`})})}function W(e){if(e===`assets`&&!u?.user){d.current?.openLibrary();return}y(e)}function G(e){d.current?.applySkill({id:e.id,title:e.title,workflow:e.workflow})}function ce(e){d.current?.attachLibraryImages([{id:e.id,src:e.src,name:e.name,alt:e.alt}])}let le=(0,J.useMemo)(()=>new Intl.NumberFormat(Ye()===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}),[]);return(0,Y.jsx)(`div`,{className:`anyimg-studio-home flex min-h-dvh flex-col overflow-x-hidden min-[900px]:h-dvh min-[900px]:overflow-hidden`,children:(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 min-[900px]:flex min-[900px]:overflow-hidden`,children:[(0,Y.jsx)(qn,{labels:{brand:rr.app_name,newProject:Rt(),home:Yt(),projects:mt(),skills:ct(),myAssets:hn(),credits:Pt(),upgrade:it(),profile:cn(),signIn:zt(),signOut:L(),expandNavigation:Gt(),collapseNavigation:Qe(),openMenu:wt(),closeMenu:rn(),mobileNavigationTitle:Ht(),mobileNavigationDescription:dn()},user:u?.user?{name:u.user.name||u.user.email,email:u.user.email,image:u.user.image}:null,credits:I.data?.balance??0,active:`home`,onNewProject:()=>{y(`skills`),d.current?.reset()},logo:(0,Y.jsx)(`img`,{src:rr.app_logo,alt:``,className:`size-full rounded-[10px]`})}),(0,Y.jsxs)(`main`,{ref:g,className:`min-w-0 flex-1 min-[900px]:flex min-[900px]:h-full min-[900px]:overflow-hidden`,children:[(0,Y.jsx)(`div`,{style:{"--studio-composer-pane-width":`${x}px`},className:`flex w-full shrink-0 flex-col items-center px-4 pt-9 pb-8 min-[900px]:w-[var(--studio-composer-pane-width)] min-[900px]:justify-center min-[900px]:pt-0 min-[900px]:pb-20`,children:(0,Y.jsx)(Pr,{ref:d,className:`max-w-[488px]`,labels:{heading:dt(),promptFallback:e(),addImages:Be(),removeAttachment:e=>`${C()}: ${e}`,attachmentUploading:Oe(),attachmentError:kn(),untitledImage:te(),selectedSkill:s(),removeSkill:Pe(),settings:A(),imageModels:_t(),resolution:qt(),aspectRatio:bt(),auto:It(),submit:Xt(),creditCost:e=>ie({credits:e}),uploadFailed:kn(),startFailed:je(),gateDialogTitle:de(),gateTitle:ve(),gateDescription:oe(),gatePrimary:ne(),gateSecondary:b(),gateEmail:Ue(),gateEmailPlaceholder:re(),gatePassword:$t(),gatePasswordPlaceholder:ae(),gateGoogle:k(),gateGithub:S(),gateOr:be(),gateNoAccount:l(),gateNoMethodsTitle:se(),gateNoMethodsDescription:V(),gateErrorFallback:pe()},placeholders:[e(),me(),We(),Le()],suggestions:[],onOpenLibrary:()=>H(`assets`)})}),(0,Y.jsx)(`div`,{role:`separator`,"aria-label":Se(),"aria-orientation":`vertical`,"aria-valuemin":D().min,"aria-valuemax":D().max,"aria-valuenow":x,tabIndex:0,onPointerDown:F,onDoubleClick:()=>P(Qr,!0),onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),P(x-24,!0)):e.key===`ArrowRight`?(e.preventDefault(),P(x+24,!0)):e.key===`Home`?(e.preventDefault(),P(D().min,!0)):e.key===`End`&&(e.preventDefault(),P(D().max,!0))},className:`group relative z-20 -mx-1.5 hidden w-3 shrink-0 cursor-col-resize touch-none outline-none select-none min-[900px]:block`,children:(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-transparent transition-[width,background-color] duration-150 group-hover:w-0.5 group-hover:bg-[oklch(0.67_0.18_266.9)] group-focus-visible:w-0.5 group-focus-visible:bg-[oklch(0.58_0.22_266.9)]`,T&&`w-0.5 bg-[oklch(0.58_0.22_266.9)]`)})}),(0,Y.jsx)(`div`,{id:`studio-sources`,ref:h,className:`min-h-0 min-w-0 flex-1 scroll-mt-0 min-[900px]:h-full`,children:(0,Y.jsx)(Lr,{source:v,onSourceChange:W,labels:{skills:U(),pinterest:z(),myAssets:Et(),clipper:i(),addSource:kt(),browseAllSkills:Mt(),next:et(),addToConversation:Cn(),formatViews:e=>le.format(e),formatSaves:e=>le.format(e),pinterestTitle:vn(),pinterestDescription:Je(),pinterestDisconnected:xt(),pinterestConnected:Lt(),pinterestConnect:vt(),pinterestDisconnect:Jt(),assetsTitle:Et(),assetsLoading:Nt(),assetsError:rt(),assetsRetry:sn(),assetsSelect:e=>`${Ze()}: ${e}`,clipperTitle:Ct(),clipperDescription:nn(),clipperInstall:Vt(),clipperInstalledTitle:un(),clipperInstalledDescription:ut(),clipperOpen:t(),addSourceTitle:Ve(),addSourceDescription:j(),googleDrive:he(),googleDriveDescription:Ge(),connect:Re(),connectorDialogTitle:()=>Zt(),connectorDialogDescription:()=>N(),connectorDialogClose:ee(),imageFallback:Fe()},categories:R,assetTabs:B,onAddToConversation:G,onAssetSelect:ce,onAssetCreate:e=>c.push(`/library`),clipperInstallUrl:`https://chromewebstore.google.com/search/Anyimg%20Clipper`})})]})]})})}function ii(){return[{id:`recommended`,label:ce()},{id:`ecommerce`,label:m()},{id:`branding`,label:_()},{id:`social`,label:Te()},{id:`website`,label:bn()},{id:`ads`,label:d()}].map((e,t)=>({...e,skills:Array.from({length:Xr},(n,r)=>{let i=t*Xr+r,a=Yr[(t*7+r*3)%Yr.length],o=qr[e.id]?.[r]??Q[i%Q.length],s=oi(`studio.home.catalog.${e.id}.item_${r+1}`),c=Ln(s,Ye()),l=`${e.id}-skill-${r+1}`;return{id:l,title:c,description:En({title:c}),author:fr(`studio.home.creator.item_${i%Zr+1}`),authorAvatar:Q[(i*5+3)%Q.length],views:a[0],saves:a[1],workflow:si({categoryId:e.id,id:l,localizedTitle:s,skillIndex:r+1}),image:o,imageAlt:c}})}))}var ai={recommended:new Set([1,2,3,4,6,7,8,10,12,16,17,18,19,20]),ecommerce:new Set(Array.from({length:Xr},(e,t)=>t+1)),branding:new Set([2,3,4,6,7,9,18,19,20])};function oi(e){let t=en[e];return t?{en:t({},{locale:`en`}),zh:t({},{locale:`zh`})}:{en:e,zh:e}}function si({categoryId:e,id:t,localizedTitle:i,skillIndex:s}){let l=e=>({en:e({title:i.en},{locale:`en`}),zh:e({title:i.zh},{locale:`zh`})}),d=e=>({en:e({},{locale:`en`}),zh:e({},{locale:`zh`})}),m=(e,t)=>
1({id:e,label:d(t)}),_=e===`recommended`?Jr[s-1]??`ecommerce`:e;function b(){let e={id:`visual-direction`,kind:`multi`,label:l(o),description:d(On),required:!0,minSelections:1,maxSelections:3,allowOther:!0,otherLabel:d(H),options:[m(`minimal`,_e),m(`bold`,F),m(`premium`,D),m(`playful`,y),m(`editorial`,ue)]};return _===`ecommerce`?[{id:`product-brief`,kind:`text`,label:l(Ot),description:d(G),placeholder:d(p),required:!0,maxLength:500},e,{id:`commerce-output`,kind:`single`,label:l(g),description:d(we),required:!0,allowOther:!0,otherLabel:d(H),options:[m(`hero`,yn),m(`gallery`,u),m(`marketplace`,xe),m(`social-ad`,Sn)]}]:_===`branding`?[{id:`brand-brief`,kind:`text`,label:l($e),description:d(Tn),placeholder:d(gn),required:!0,maxLength:500},e,{id:`brand-deliverable`,kind:`single`,label:l(qe),description:d(gt),required:!0,allowOther:!0,otherLabel:d(H),options:[m(`logo`,yt),m(`identity`,Ft),m(`packaging`,Kt),m(`campaign`,ft)]}]:_===`social`?[{id:`social-brief`,kind:`text`,label:l(ot),description:d(pn),placeholder:d(jt),required:!0,maxLength:500},{id:`social-elements`,kind:`multi`,label:l(nt),description:d(on),required:!0,minSelections:1,maxSelections:4,allowOther:!0,otherLabel:d(H),options:[m(`headline`,Ut),m(`logo`,Xe),m(`portrait`,St),m(`product`,tn),m(`no-text`,Bt)]},{id:`social-delivery`,kind:`single`,label:l(ln),description:d(lt),required:!0,allowOther:!0,otherLabel:d(H),options:[m(`moodboard`,n),m(`final`,ge),m(`variants`,Ke)]}]:_===`website`?[{id:`website-brief`,kind:`text`,label:l(ze),description:d(He),placeholder:d(M),required:!0,maxLength:500},{id:`website-sections`,kind:`multi`,label:l(Qt),description:d(P),required:!0,minSelections:1,maxSelections:4,allowOther:!0,otherLabel:d(H),options:[m(`hero`,w),m(`features`,Ie),m(`proof`,ke),m(`pricing`,E),m(`cta`,Me)]},{id:`website-target`,kind:`single`,label:l(c),description:d(An),required:!0,allowOther:!0,otherLabel:d(H),options:[m(`responsive`,ye),m(`desktop`,I),m(`mobile`,O),m(`campaign`,x)]}]:[{id:`campaign-brief`,kind:`text`,label:l(fe),description:d(W),placeholder:d(B),required:!0,maxLength:500},{id:`proof-points`,kind:`multi`,label:l(Dt),description:d(a),required:!0,minSelections:1,maxSelections:4,allowOther:!0,otherLabel:d(H),options:[m(`product`,At),m(`benefit`,le),m(`price`,h),m(`social`,v),m(`urgency`,Ee)]},{id:`ad-placement`,kind:`single`,label:l(xn),description:d(f),required:!0,allowOther:!0,otherLabel:d(H),options:[m(`meta`,Ce),m(`google`,wn),m(`tiktok`,tt),m(`display`,Dn)]}]}let S=ai[e]?.has(s)?`upload-first`:`brief`,C={id:`${t}-workflow`,version:1,skillId:t,skillTitle:i,seedRequest:l(_n),intro:{title:l(Ne),body:l(De),bullets:[d(T),d(Ae)]},questions:b()};return S===`brief`?{...C,mode:S}:{...C,mode:S,upload:{title:l(R),body:l(Tt),referenceLabel:d(r),minReferences:1,maxReferences:8}}}export{ii as n,Or as r,ri as t};
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.