PageSourceSearch

https://bamf.ai/assets/PromptPicker-AC8ELSsE.js

js bamf.ai collected 2026-10-05 15:13:37 UTC 47,559 bytes, 24 lines download raw bytes

1import{i as o,r as St,j as e,k as At}from"./react-vendor-uVchTzPA.js";import{gc as C,ez as N,f9 as ee,iJ as xe,dG as O,H as k,mE as H,nJ as tt,an as Pt,ap as Et,as as Rt,av as It,n3 as Lt,nA as Dt,ns as ve,fc as je,nR as ue,bM as $t,ah as Tt}from"./index-BMAIKaM-.js";import{inspirationsApi as Ft}from"./inspirations-B0merPnw.js";import{C as zt}from"./CreatorAudioVoiceSettings-BmXdsv8y.js";import{r as Ot,V as Mt,i as Ut}from"./AdsHubPage-CNYo1L0w.js";import{d as st,c as fe,u as qe}from"./query-BPdkB31R.js";import{e9 as se,X as at,Y as nt,Q as te,ds as Q,O as Wt,dU as Bt,aQ as qt,dw as Kt,dO as be,cb as Vt,d6 as Yt,cE as Ke,dW as Ve,k as Ye,bm as Ht,cZ as Gt,dv as He,W as Qt,bg as Xt,d5 as Jt,cQ as rt,r as Zt,bM as Ge,da as es,aO as Qe,ec as ts,x as ss}from"./icons-C8Q0fb8w.js";import{u as as}from"./utils-vendor-wHVPSVbX.js";import{s as ns}from"./client-DiZ_zWWv.js";import{r as we}from"./adBoosts-DpplnOr0.js";import{A as Xe,m as Je}from"./animation-BufnVLKX.js";const lt="identity";function ie(s,a,d){return{id:s,title:a,icon:{type:"lucide",name:"sparkles"},prompt:d}}function rs(s){const a=s.phase==="voice-ready";return{heading:"Your identity",subline:a?"Your voice, writing style, and likeness are open on the right.":"Finish your voice clone, then BAMF can speak as you.",items:[a?ie("identity-voice-best-post","Have my voice read my best post","Pick my best-performing post and read its opening with my cloned voice."):ie("identity-voice-setup","Help me record a great voice sample","Give me tips to record a clean 2-minute voice sample for my clone."),ie("identity-add-facts","Add facts about me","Interview me briefly and add new facts about me to my identity profile."),ie("identity-style-rules","Suggest style rules from my posts","Read my recent posts and suggest do and don't writing style rules."),ie("identity-whats-new","What do you know about me that's new?","What have you learned about me recently that is not yet in my identity profile?")]}}Ot(lt,rs);const ls=[{value:5,label:"Really looks like me"},{value:4,label:"Mostly"},{value:3,label:"Kind of"},{value:2,label:"Not really"},{value:1,label:"Totally wrong"}];function is({images:s,index:a,review:d,onIndexChange:n,onClose:f,onReview:w}){const c=s[a],p=c&&d[c.id]||{},[b,S]=o.useState(p.comment||""),_=o.useRef(null);o.useEffect(()=>{var i;S(((i=d[c==null?void 0:c.id])==null?void 0:i.comment)||"")},[c==null?void 0:c.id]);const j=i=>n(Math.min(s.length-1,Math.max(0,a+i)));if(o.useEffect(()=>{const i=h=>{var I;h.key==="Escape"&&f(),((I=h.target)==null?void 0:I.tagName)!=="TEXTAREA"&&(h.key==="ArrowRight"&&j(1),h.key==="ArrowLeft"&&j(-1))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)}),!c)return null;const R=i=>{const h=p.rating??null,I=i?Math.max(h??0,4):Math.min(h??5,2);w(c,{rating:I,keep:i,comment:b},!0),a>=s.length-1&&f()};return St.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[200] flex flex-col bg-black text-white",role:"dialog","aria-modal":"true","aria-label":"Review likeness image",onTouchStart:i=>{_.current=i.touches[0].clientX},onTouchEnd:i=>{if(_.current==null)return;const h=i.changedTouches[0].clientX-_.current;_.current=null,Math.abs(h)>60&&j(h<0?1:-1)},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("span",{className:"text-sm text-white/70",children:[c.description||"AI image"," · ",a+1," of ",s.length]}),e.jsx("button",{type:"button",onClick:f,"aria-label":"Close",className:"rounded-full bg-white/10 p-2 outline-none hover:bg-white/20",children:e.jsx(se,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1 items-center justify-center px-4",onClick:f,children:[e.jsx("img",{src:c.url,alt:c.description||"",className:"max-h-full max-w-full rounded-xl object-contain",onClick:i=>i.stopPropagation()}),a>0&&e.jsx("button",{type:"button","aria-label":"Previous",onClick:i=>{i.stopPropagation(),j(-1)},className:"absolute left-3 hidden rounded-full bg-white/10 p-2 outline-none hover:bg-white/20 sm:block",children:e.jsx(at,{className:"h-5 w-5"})}),a<s.length-1&&e.jsx("button",{type:"button","aria-label":"Next",onClick:i=>{i.stopPropagation(),j(1)},className:"absolute right-3 hidden rounded-full bg-white/10 p-2 outline-none hover:bg-white/20 sm:block",children:e.jsx(nt,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"mx-auto w-full max-w-xl space-y-3 px-4 pb-5 pt-3",children:[e.jsx("div",{className:"flex flex-wrap justify-center gap-1.5",children:ls.map(i=>e.jsx("button",{type:"button","aria-pressed":p.rating===i.value,onClick:()=>w(c,{...p,rating:i.value,keep:i.value>=3,comment:b},!1),className:C("rounded-full px-3 py-1.5 text-xs outline-none transition-colors",p.rating===i.value?"bg-white text-black":"bg-white/10 text-white/80 hover:bg-white/20"),children:i.label},i.value))}),e.jsx("div",{className:"rounded-xl bg-white/10 px-3 py-2 focus-within:bg-white/15",children:e.jsx("textarea",{value:b,onChange:i=>S(i.target.value),onBlur:()=>b!==(p.comment||"")&&w(c,{...p,comment:b},!1),rows:2,placeholder:"What's off or good?",className:"w-full resize-none bg-transparent text-sm text-white outline-none placeholder:text-white/40"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>R(!1),className:C("flex items-center justify-center gap-1.5 rounded-xl py-3 text-sm font-medium outline-none",p.keep===!1?"bg-red-600 text-white":"bg-red-600/80 text-white hover:bg-red-600"),children:[e.jsx(se,{className:"h-4 w-4"}),"Doesn't look like me"]}),e.jsxs("button",{type:"button",onClick:()=>R(!0),className:C("flex items-center justify-center gap-1.5 rounded-xl py-3 text-sm font-medium outline-none",p.keep===!0?"bg-green-600 text-white":"bg-green-600/80 text-white hover:bg-green-600"),children:[e.jsx(te,{className:"h-4 w-4"}),"Looks like me"]})]})]})]}),document.body)}function os(s,a){return a==="real"?s.filter(d=>!xe(d)):a==="ai"?s.filter(d=>xe(d)):s}const me=12;function cs({authorId:s,workspaceId:a,likeness:d}
1){const n=st(),[f,w]=o.useState("all"),[c,p]=o.useState(new Set),[b,S]=o.useState({}),[_,j]=o.useState(null),R=["likeness-pending-ai",s],{data:i=[]}=fe({queryKey:R,queryFn:()=>ee.listPendingAiLikeness(s,a),enabled:!!s}),{data:h}=fe({queryKey:["likeness-expand-estimate",s],queryFn:()=>ee.estimateLikenessExpand(s,me),enabled:!!s,staleTime:10*6e4}),I=()=>{n.invalidateQueries({queryKey:R}),n.invalidateQueries({queryKey:["identity-likeness"]}),n.invalidateQueries({queryKey:["author_reference_images"]})},$=qe({mutationFn:()=>ee.expandLikeness(s,me),onSuccess:u=>{N.success(`${u.images.length} new images ready to review ($${u.costUsd.toFixed(2)}).`),I()},onError:u=>N.error(u.message||"Could not generate images")}),l=qe({mutationFn:()=>ee.reviewAiLikeness({authorId:s,workspaceId:a,acceptIds:i.filter(u=>c.has(u.id)).map(u=>u.id),rejectIds:i.filter(u=>!c.has(u.id)).map(u=>u.id)}),onSuccess:()=>{N.success(c.size?`Added ${c.size} to your likeness.`:"Discarded this batch."),p(new Set),I()},onError:u=>N.error(u.message||"Could not save review")}),T=(u,y,D)=>{S(E=>({...E,[u.id]:y})),y.keep!=null&&p(E=>{const F=new Set(E);return y.keep?F.add(u.id):F.delete(u.id),F}),ee.rateLikeness({id:u.id,rating:y.rating??null,comment:y.comment}).catch(()=>N.error("Could not save rating")),D&&j(E=>E==null?E:E+1<i.length?E+1:null)},L=o.useMemo(()=>d.filter(u=>!xe(u)).length,[d]),q=d.length-L,ae=os(d,f);return e.jsxs("div",{className:"mt-4 space-y-4",children:[q>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:"flex gap-1",role:"tablist","aria-label":"Filter likeness photos",children:[["all",`All ${d.length}`],["real",`Real ${L}`],["ai",`AI ${q}`]].map(([u,y])=>e.jsx("button",{type:"button",role:"tab","aria-selected":f===u,onClick:()=>w(u),className:C("rounded-full px-3 py-1 text-xs transition-colors",f===u?"bg-foreground text-background":"bg-muted text-muted-foreground hover:text-foreground"),children:y},u))}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ae.slice(0,12).map(u=>e.jsxs("span",{className:"relative",children:[e.jsx("img",{src:u.url,alt:"",className:"h-12 w-12 rounded-full object-cover"}),xe(u)&&e.jsx(it,{className:"absolute -bottom-1 -right-1"})]},u.id))})]}),i.length>0?e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Which of these look like you?"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tap an image to view it large and rate it. Unselected ones are discarded on save."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>p(c.size===i.length?new Set:new Set(i.map(u=>u.id))),children:c.size===i.length?"Clear":"Keep all"}),e.jsx(k,{size:"sm",onClick:()=>l.mutate(),disabled:l.isPending,children:l.isPending?e.jsx("span",{className:"text-shimmer-sweep",children:"Saving…"}):`Save ${c.size} of ${i.length}`})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-4",children:i.map((u,y)=>{var F;const D=c.has(u.id),E=((F=b[u.id])==null?void 0:F.rating)??u.likeness_rating;return e.jsxs("button",{type:"button","aria-pressed":D,"aria-label":`${u.description||"AI image"}: ${D?"keep":"discard"}`,onClick:()=>j(y),className:C("group relative aspect-[4/5] overflow-hidden rounded-xl bg-muted outline-none transition",D?"ring-2 ring-primary":"opacity-70 hover:opacity-100"),children:[e.jsx("img",{src:u.url,alt:"",loading:"lazy",className:"h-full w-full object-cover"}),e.jsx("span",{className:C("absolute right-2 top-2 flex h-6 w-6 items-center justify-center rounded-full",D?"bg-primary text-primary-foreground":"bg-background/80 text-muted-foreground"),children:D?e.jsx(te,{className:"h-3.5 w-3.5"}):e.jsx(se,{className:"h-3.5 w-3.5"})}),E!=null&&e.jsxs("span",{className:"absolute left-2 top-2 rounded-full bg-background/80 px-2 py-0.5 text-[11px] font-medium",children:[E,"/5"]}),u.description&&e.jsx("span",{className:"absolute bottom-2 left-2 rounded-full bg-background/80 px-2 py-0.5 text-[11px]",children:u.description})]},u.id)})}),_!=null&&e.jsx(is,{images:i,index:_,review:b,onIndexChange:j,onClose:()=>j(null),onReview:T})]}):e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:()=>$.mutate(),disabled:$.isPending||L===0,children:$.isPending?e.jsxs("span",{className:"text-shimmer-sweep",children:["Generating ",me," images…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5"}),"Generate more of me"]})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:L===0?"Add a real photo first.":h?`${h.count} images, about $${h.estimateUsd.toFixed(2)}`:`${me} images in new poses and scenes`})]})]})}function it({className:s}){return e.jsx("span",{className:C("rounded-full bg-foreground px-1.5 py-px text-[9px] font-semibold uppercase tracking-wide text-background",s),children:"AI"})}const oe="author_reference_videos";function ds(s){return new Promise(a=>{const d=document.createElement("video"),n=URL.createObjectURL(s),f=w=>{URL.revokeObjectURL(n),a(w)};d.preload="metadata",d.onloadedmetadata=()=>f(Number.isFinite(d.duration)?Math.round(d.duration*10)/10:null),d.onerror=()=>f(null),d.src=n})}const Z={async list(s){const{data:a,error:d}=await H.from(oe).select("*").eq("author_id",s).order("is_default",{ascending:!1}).order("created_at",{ascending:!1});if(d)throw d;return a||[]},async add(s,a){var c;const d=await this.list(s),{data:n}=await H.auth.getUser(),{data:f,error:w}=await H.from(oe).insert({author_id:s,url:a.url,storage_path:a.storagePath??null,filename:a.filename??null,source:a.source,duration_seconds:a.durationSeconds??null,is_default:d.length===0,created_by:((c=n.user)==null?void 0:c.id)??null}).select("*").single();if(w)throw w;return f},async upload(s,a,d="upload"){const n=await ds(a),f=await tt.uploadVideoBlob(a,{projectId:`reference-${s}`,kind:"source",fileName:a.name,contentType:a.type});return this.add(s,{url:f.url,storagePath:f.path,filename:a.name,source:d,durationSeconds:n})},async setDefault(s,a){const{error:d}=await H.from(oe).update({is_default:!1}).eq("author_id",s).eq("is_default",!0);if(d)throw d;const{error:n}=await H.from(oe).update({is_default:!0}).eq("id",a);if(n)throw n},async remove(s){const{error:a}=await H.from(oe).delete().eq("id",s);if(a)throw a}},us=["Good, even light on your face","Look at the lens, chest-up framing","Talk naturally for 1–2 minutes with easy gestures","Keep your mouth visible, no hands over your face"];function ms({author:s,workspaceId:a}){const d=st(),n=o.useRef(null),[f,w]=o.useState(!1),[c,p]=o.use
1State(!1),[b,S]=o.useState(!1),_=["author-reference-videos",s.id],{data:j=[]}=fe({queryKey:_,queryFn:()=>Z.list(s.id)}),{data:R=[]}=fe({queryKey:["reference-video-library",s.id],queryFn:()=>tt.list({authorId:s.id}),enabled:b}),i=()=>d.invalidateQueries({queryKey:_}),h=async(l,T)=>{w(!0);try{await l(),N.success(T),await i()}catch(L){N.error(L instanceof Error?L.message:"Something went wrong.")}finally{w(!1)}},I=new Set(j.map(l=>l.url)),$=R.filter(l=>l.source_url&&!I.has(l.source_url)).slice(0,8);return e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Reference video"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your talking videos lip-sync onto this real take."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(k,{size:"sm",variant:"secondary",disabled:f,onClick:()=>p(!0),children:[e.jsx(Wt,{className:"mr-1.5 h-3.5 w-3.5"}),"Record"]}),e.jsxs(k,{size:"sm",variant:"secondary",disabled:f,onClick:()=>{var l;return(l=n.current)==null?void 0:l.click()},children:[e.jsx(Bt,{className:"mr-1.5 h-3.5 w-3.5"}),"Upload"]}),e.jsxs(k,{size:"sm",variant:"ghost",disabled:f,onClick:()=>S(l=>!l),children:[e.jsx(qt,{className:"mr-1.5 h-3.5 w-3.5"}),"From videos"]}),e.jsx("input",{ref:n,type:"file",accept:"video/*",className:"hidden",onChange:l=>{var L;const T=(L=l.target.files)==null?void 0:L[0];l.target.value="",T&&h(()=>Z.upload(s.id,T),"Reference take added")}})]})]}),e.jsxs(O,{className:"mt-3",children:[j.length?e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:j.map(l=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("video",{src:l.url,muted:!0,playsInline:!0,preload:"metadata",className:C("aspect-[9/16] w-full rounded-md bg-muted object-cover",l.is_default&&"ring-2 ring-primary")}),e.jsxs("div",{className:"flex items-center justify-between gap-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:l.is_default?"Default":l.duration_seconds?`${Math.round(Number(l.duration_seconds))}s`:"Take"}),e.jsxs("span",{className:"flex",children:[!l.is_default&&e.jsx(k,{size:"icon",variant:"ghost",className:"h-7 w-7","aria-label":"Use as default",disabled:f,onClick:()=>void h(()=>Z.setDefault(s.id,l.id),"Default take updated"),children:e.jsx(Kt,{className:"h-3.5 w-3.5"})}),e.jsx(k,{size:"icon",variant:"ghost",className:"h-7 w-7","aria-label":"Remove take",disabled:f,onClick:()=>void h(()=>Z.remove(l.id),"Take removed"),children:e.jsx(be,{className:"h-3.5 w-3.5"})})]})]})]},l.id))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Record or upload a 1–2 minute chest-up take."}),e.jsx("ul",{className:"mt-4 grid gap-1 text-xs text-muted-foreground sm:grid-cols-2",children:us.map(l=>e.jsx("li",{children:l},l))})]}),b&&e.jsx(O,{className:"mt-3",padding:"sm",children:$.length?e.jsx("div",{className:"grid grid-cols-3 gap-3 sm:grid-cols-6",children:$.map(l=>e.jsxs("button",{type:"button",disabled:f,className:"flex flex-col gap-1 text-left",onClick:()=>void h(()=>Z.add(s.id,{url:l.source_url,source:"media_library",filename:l.title,durationSeconds:l.source_duration_seconds??null}),"Reference take added"),children:[e.jsx("video",{src:l.source_url,muted:!0,playsInline:!0,preload:"metadata",className:"aspect-[9/16] w-full rounded-md bg-muted object-cover"}),e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:l.title})]},l.id))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No camera videos yet."})}),e.jsx(Pt,{open:c,onOpenChange:p,children:e.jsxs(Et,{className:"max-w-5xl",children:[e.jsx(Rt,{children:e.jsx(It,{children:"Record a reference take"})}),c&&e.jsx(Mt,{embedded:!0,workspaceId:a,author:s,onCancel:()=>p(!1),onSaved:l=>{p(!1),l.source_url&&h(()=>Z.add(s.id,{url:l.source_url,source:"camera",filename:l.title,durationSeconds:l.source_duration_seconds??null}),"Reference take added")}})]})})]})}const xs=`You are an expert personal brand strategist. Based on the provided creator information, generate a structured identity profile in JSON format.
2
3The profile should include:
4- about_you: A professional background paragraph (2-4 sentences) describing who they are and what makes them unique. Focus on their expertise and value proposition.
5- your_story: Their journey and origin story (3-5 sentences). What challenges they overcame, what drove them to do what they do, and what mission drives them today.
6- offers: Array of 1-3 products/services they provide. Each with "title" (short name) and "description" (1-2 sentences explaining the value).
7- target_audience: Array of 2-4 specific audience segments they create content for (e.g., "Startup Founders", "Marketing Leaders", "Solo Entrepreneurs").
8- personal_info: Array of 5-8 key facts about them written as statements (e.g., "My name is John Smith", "I'm based in San Francisco", "I'm the founder of XYZ", "I'm a dad of three").
9
10Be specific and use information from their actual profile. Avoid generic statements.
11Return ONLY valid JSON, no markdown or explanation.`;function fs(){var $e,Te,Fe,ze,Oe,Me,Ue,We;const s=At(),{selectedAuthorId:a}=Lt(),{currentWorkspaceAccess:d}=Dt(),[n,f]=o.useState(null),[w,c]=o.useState(!1),[p,b]=o.useState(null),[S,_]=o.useState(""),[j,R]=o.useState(null),[i,h]=o.useState(!1),[I,$]=o.useState(!1),[l,T]=o.useState(""),[L,q]=o.useState(""),[ae,u]=o.useState(!1),[y,D]=o.useState(""),[E,F]=o.useState(!1),[X,ne]=o.useState(""),[m,g]=o.useState(!1),[A,U]=o.useState([]),[K,V]=o.useState([]),[re,ce]=o.useState(""),[le,Ne]=o.useState(""),[he,ke]=o.useState([]),[Ce,_e]=o.useState(!1),[ot,Y]=o.useState(!1),pe=o.useRef(null),{data:ct,loading:dt}=ve(["top-creators"],async()=>((await Ft.listCreators({pageSize:20,minAvgLikes:100})).data||[]).sort((v,P)=>(P.stats_avg_likes||0)-(v.stats_avg_likes||0)).slice(0,20),{enabled:!0}),Se=ct||[],{data:x,loading:ut,refetch:Ae}=ve(["author",a],()=>a?je.getAuthor(a):Promise.resolve(null),{enabled:!!a});o.useEffect(()=>{if(!x||x.id!==a){f(null);return}const t=x.identity_profile;t&&t.generatedAt?f(t):f(null)},[x,a]),o.useEffect(()=>{if(window.location.hash!=="#voice")return;let t=0;const r=()=>{const v=document.getElementById("voice");if(v){v.scrollIntoView({behavior:"smooth",block:"start"});return}t+=1,t<10&&setTimeout(r,200)};r()},[x]),o.useEffect(()=>{if(x){const t=x.writing_preferences||{},r=t.do_rules||[];U(r.map((P,M)=>({id:`do-${M}`,text:P})));const v=t.dont_rules||[];V(v.map((P,M)=>({id:`dont-${M}`,text:P}))),ke(t.style_inspiration_creators||[]),Y(!1)}},[x]);const mt=()=>{re.trim()&&(U(t=>[...t,{id:`do-${Date.now()}`,text:re.trim()}]),ce(""),Y(!0))},xt=()=>{le.trim()&&(V(t=>[...t,{id:`dont-${Date.now()}`,text:le.trim()}]),Ne(""),Y(!0))},ft=t=>{U(r=>r.filter(v=>v.id!==t)),Y(!0)},ht=t=>{V(r=>r.filter(v=>v.id!==t)),Y(!0)},pt=t=>{ke(r=>r.includes(t)?r.filter(v=>v!==t):r.length>=3?(N.error("You can select up to 3 creators for style inspiration"),r):[...r,t]),Y(!0)},Pe=t=>{pe.current&&pe.current.scrollBy({left:t==="left"?-280:280,behavior:"smooth"})},gt=async()=>{if(!a){N.error("Please select a creator first");return}_e(!0);try{await je.updateAuthor(a,{writing_preferences:{do_rules:A.map(t=>t.text),dont_rules:K.map(t=>t.text),style_inspiration_creators:he}}),N.success("Writing preferences saved"),Y(!1),Ae()}catch(t){N.error(t.message||"Failed to save preferences")}finally{_e(!1)}},W=async t=>{if(x)try{await je.updateAuthor(x.id,{identity_profile:t})}catch(r){console.error("Error saving profile:",r)}},Ee=async()=>{var t;if(x){c(!0);try{const r=x.linkedin_profile_data||{},v=`
12Creator Name: ${x.name}
13Headline: ${x.linkedin_headline||r.headline||"Not provided"}
14Bio: ${x.bio||r.bio||"Not provided"}
15Industry: ${x.industry||"Not provided"}
16Job Description: ${x.job_description||"Not provided"}
17Voice/Style: ${x.fine_tune||"Not provided"}
18Custom CTA: ${x.custom_cta||"Not provided"}
19Followers: ${r.followerCount||"Unknown"}
20Location: ${typeof r.location=="string"?r.location:((t=r.location)==null?void 0:t.full)||"Unknown"}
21Website Summary: ${x.website_summary||"Not provided"}
22      `.trim(),{data:P,error:M}=await H.functions.invoke("openai-proxy",{body:{model:Tt.TEXT_GENERATION,messages:[{role:"system",content:xs},{role:"user",content:`Generate an identity profile for this creator:
23
24${v}`}],max_tokens:1500}});if(M)throw M;const Be=((P==null?void 0:P.content)||"").match(/\{[\s\S]*\}/);if(Be){const ge=JSON.parse(Be[0]);ge.generatedAt=new Date().toISOString(),f(ge),await W(ge),N.success("Identity profile generated!")}else throw new Error("Invalid response format")}catch(r){console.error("Error generating identity profile:",r),N.error("Failed to generate identity profile")}finally{c(!1)}}},vt=async t=>{if(!(!x||!n)){h(!0);try{const r={...n,[t]:S};await W(r),f(r),b(null),_(""),N.success("Updated successfully")}catch(r){N.error(r.message||"Failed to update")}finally{h(!1)}}},jt=async()=>
24{if(!n||!l.trim())return;const t={...n,offers:[...n.offers||[],{title:l,description:L}]};await W(t),f(t),$(!1),T(""),q(""),N.success("Offer added")},wt=async t=>{if(!n)return;const r={...n,offers:n.offers.filter((v,P)=>P!==t)};await W(r),f(r),N.success("Offer removed")},Re=async()=>{if(!n||!y.trim())return;const t={...n,target_audience:[...n.target_audience||[],y]};await W(t),f(t),u(!1),D(""),N.success("Audience added")},yt=async t=>{if(!n)return;const r={...n,target_audience:n.target_audience.filter((v,P)=>P!==t)};await W(r),f(r),N.success("Audience removed")},Ie=async()=>{if(!n||!X.trim())return;const t={...n,personal_info:[...n.personal_info||[],X]};await W(t),f(t),F(!1),ne(""),N.success("Info added")},bt=async t=>{if(!n)return;const r={...n,personal_info:n.personal_info.filter((v,P)=>P!==t)};await W(r),f(r),N.success("Info removed")},Nt=async t=>{if(n){h(!0);try{const r=[...n.personal_info];r[t]=S;const v={...n,personal_info:r};await W(v),f(v),b(null),R(null),_(""),N.success("Updated")}catch{N.error("Failed to update")}finally{h(!1)}}},J=(d==null?void 0:d.workspace.kind)==="client"?d.workspace.id:null,{data:kt}=ve(["identity-likeness",a,(x==null?void 0:x.workspace_id)||J],()=>a?ee.listActiveLikeness(a,(x==null?void 0:x.workspace_id)||J):Promise.resolve([]),{enabled:!!a}),z=kt||[],Le=ue("/creator-profile?tab=visual-identity"),Ct=t=>{var r;return(r=document.getElementById(t))==null?void 0:r.scrollIntoView({behavior:"smooth",block:"start"})};if(Ut(x?{surface:lt,phase:x.elevenlabs_voice_id&&((Te=($e=x.audio_voice_settings)==null?void 0:$e.voice_management)==null?void 0:Te.kind)==="instant_clone"?"voice-ready":"voice-setup",creatorName:x.name,label:"Identity",icon:"user",view:"identity",summary:`Identity page for ${x.name}: speaking voice ${x.elevenlabs_voice_id?"set":"not set"}, ${z.length} likeness photos, writing profile ${n?"ready":"not generated"}.`}:null),ut&&!x)return e.jsx($t,{});if(!a||!x)return e.jsxs("div",{className:"mx-auto w-full max-w-3xl px-4 py-16 sm:px-6",children:[e.jsx("h1",{className:"text-2xl font-medium tracking-tight",children:"Your identity"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Pick a creator to set up their voice and likeness."}),e.jsx(k,{className:"mt-5",onClick:()=>s(ue("/creators")),children:"Choose a creator"})]});const De=!!x.elevenlabs_voice_id,de=A.length+K.length,_t=[{id:"voice",icon:Vt,label:"Speaking voice",status:De?"Cloned":"Record 60s",ready:De},{id:"likeness",icon:Yt,label:"Likeness",status:z.length?`${z.length} ${z.length===1?"photo":"photos"}`:"Add photos",ready:z.length>0},{id:"writing",icon:Ke,label:"Writing voice",status:n?de?`Profile · ${de} rules`:"Profile ready":"Generate profile",ready:!!n}];return e.jsxs("div",{className:"mx-auto w-full max-w-4xl px-4 py-8 sm:px-6 sm:py-12",children:[e.jsxs("header",{className:"flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[clamp(1.6rem,5vw,2.1rem)] font-medium leading-tight tracking-[-0.03em]",children:"Your identity"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground sm:text-base",children:"How you write, sound, and look — BAMF uses all three."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>s(ue(`/creators/${x.slug||x.id}`)),children:[e.jsx(Ve,{className:"mr-1.5 h-4 w-4"}),"Full profile"]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>s(ue("/ai-analysis")),children:[e.jsx(Q,{className:"mr-1.5 h-4 w-4"}),"AI analysis"]})]})]}),e.jsx("nav",{"aria-label":"Identity readiness",className:"mt-8 grid gap-3 sm:grid-cols-3",children:_t.map(({id:t,icon:r,label:v,status:P,ready:M})=>e.jsxs(O,{as:"button",type:"button",padding:"sm",onClick:()=>Ct(t),className:"flex items-center gap-3 text-left transition-colors hover:bg-accent/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.96] [transition-property:background-color,scale]",children:[e.jsx("span",{className:C("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg",M?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-muted text-muted-foreground"),children:e.jsx(r,{className:"h-[18px] w-[18px]",strokeWidth:1.75})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:v}),e.jsxs("span",{className:C("flex items-center gap-1 text-xs",M?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:[M?e.jsx(te,{className:"h-3 w-3"}):e.jsx(Ye,{className:"h-3 w-3"}),P]})]})]},t))}),e.jsx("section",{id:"voice",className:"mt-12 scroll-mt-6",children:e.jsx(zt,{author:x,authorizedWorkspaceId:J,onUpdate:()=>void Ae()})}),e.jsxs("section",{id:"likeness",className:"mt-12 scroll-mt-6","aria-labelledby":"likeness-heading",children:[e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsx("h2",{id:"likeness-heading",className:"text-lg font-medium tracking-tight",children:"Likeness"}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>
24s(Le),children:[z.length?"Manage photos":"Add photos",e.jsx(Ye,{className:"ml-1.5 h-3.5 w-3.5"})]})]}),e.jsxs(O,{as:"button",type:"button",onClick:()=>s(Le),className:"mt-4 flex w-full items-center gap-4 text-left transition-colors hover:bg-accent/40",children:[z.length?e.jsx("span",{className:"flex -space-x-3",children:z.slice(0,5).map(t=>e.jsxs("span",{className:"relative",children:[e.jsx("img",{src:t.url,alt:"",className:"h-14 w-14 rounded-full object-cover ring-2 ring-background"}),t.source==="ai_generated"&&e.jsx(it,{className:"absolute -bottom-1 right-0"})]},t.id))}):e.jsx("span",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-muted",children:e.jsx(Ht,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:z.length?`${z.length} active reference ${z.length===1?"photo":"photos"} for images and video.`:"Add a few clear photos so images and video look like you."})]}),a&&e.jsx(cs,{authorId:a,workspaceId:(x==null?void 0:x.workspace_id)||J,likeness:z}),x&&(x.workspace_id||J)&&e.jsx(ms,{author:x,workspaceId:x.workspace_id||J})]}),e.jsxs("section",{id:"writing",className:"mt-12 scroll-mt-6","aria-labelledby":"writing-heading",children:[e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"writing-heading",className:"text-lg font-medium tracking-tight",children:"Writing voice"}),(n==null?void 0:n.generatedAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Saved ",as(new Date(n.generatedAt),{addSuffix:!0})]})]}),n&&e.jsx(k,{variant:"ghost",size:"sm",onClick:Ee,disabled:w,children:w?e.jsx("span",{className:"text-shimmer-sweep",children:"Regenerating…"}):e.jsxs(e.Fragment,{children:[e.jsx(Gt,{className:"mr-1.5 h-3.5 w-3.5"}),"Regenerate"]})})]}),!n&&e.jsxs(O,{className:"mt-4 flex flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:w?e.jsx("span",{className:"text-shimmer-sweep",children:"Reading your profile and writing…"}):"No profile yet. BAMF drafts one from your creator data."}),!w&&e.jsxs(k,{size:"sm",onClick:Ee,children:[e.jsx(Q,{className:"mr-1.5 h-4 w-4"}),"Generate profile"]})]}),n&&e.jsxs("div",{className:"mt-4 grid gap-3",children:[["about_you","your_story"].map(t=>e.jsxs(O,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:t==="about_you"?"About you":"Your story"}),p!==t&&e.jsx(B,{label:"Edit",onClick:()=>{b(t),_(n[t]||"")},children:e.jsx(He,{className:"h-4 w-4"})})]}),p===t?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx(G,{children:e.jsx("textarea",{value:S,onChange:r=>_(r.target.value),rows:5,autoFocus:!0,className:"w-full resize-y bg-transparent px-3 py-2 text-sm leading-relaxed outline-none"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{size:"sm",onClick:()=>vt(t),disabled:i,children:i?e.jsx("span",{className:"text-shimmer-sweep",children:"Saving…"}):"Save"}),e.jsx(k,{size:"sm",variant:"ghost",onClick:()=>{b(null),_("")},children:"Cancel"})]})]}):e.jsx(hs,{text:n[t]})]},t)),e.jsxs(O,{children:[e.jsx(ye,{title:"Offers",onAdd:()=>$(!0)}),e.jsxs("div",{className:"mt-2 grid gap-1",children:[(Fe=n.offers)==null?void 0:Fe.map((t,r)=>e.jsxs("div",{className:"group flex items-start justify-between gap-3 rounded-lg px-2 py-2 hover:bg-accent/40",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:t.title}),t.description&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs text-muted-foreground",children:t.description})]}),e.jsx(B,{label:"Remove offer",onClick:()=>wt(r),reveal:!0,children:e.jsx(be,{className:"h-4 w-4"})})]},r)),!((ze=n.offers)!=null&&ze.length)&&!I&&e.jsx("p",{className:"px-2 py-1 text-sm text-muted-foreground",children:"None yet."}),I&&e.jsxs("div",{className:"mt-1 space-y-2",children:[e.jsx(G,{children:e.jsx("input",{value:l,onChange:t=>T(t.target.value),placeholder:"Offer name",autoFocus:!0,className:"h-10 w-full bg-transparent px-3 text-sm outline-none"})}),e.jsx(G,{children:e.jsx("textarea",{value:L,onChange:t=>q(t.target.value),placeholder:"One line on the value",rows:2,className:"w-full resize-none bg-transparent px-3 py-2 text-sm outline-none"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{size:"sm",onClick:jt,disabled:!l.trim(),children:"Add"}),e.jsx(k,{size:"sm",variant:"ghost",onClick:()=>{$(!1),T(""),q("")},children:"Cancel"})]})]})]})]}),e.jsxs(O,{children:[e.jsx(ye,{title:"Audience",onAdd:()=>u(!0)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(Oe=n.target_audience)==null?void 0:Oe.map((t,r)=>e.jsxs("span",{className:"group inline-flex items-center gap-1 rounded-full bg-muted px-3 py-1 text-sm",children:[t,e.jsx("button",{type:"button","aria-label":`Remove ${t}`,onClick:()=>yt(r),className:"-mr-1 rounded-full p-0.5 text-muted-foreground hover:text-destructive",children:e.jsx(se,{className:"h-3.5 w-3.5"})})]},r)),!((Me=n.target_audience)!=null&&Me.length)&&!ae&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"None yet."})]}),ae&&e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx(G,{className:"flex-1",children:e.jsx("input",{value:y,onChange:t=>D(t.target.value),onKeyDown:t=>
24t.key==="Enter"&&Re(),placeholder:"e.g. Startup founders",autoFocus:!0,className:"h-9 w-full bg-transparent px-3 text-sm outline-none"})}),e.jsx(k,{size:"sm",onClick:Re,disabled:!y.trim(),children:"Add"}),e.jsx(k,{size:"sm",variant:"ghost",onClick:()=>{u(!1),D("")},children:"Cancel"})]})]}),e.jsxs(O,{children:[e.jsx(ye,{title:"Facts about you",onAdd:()=>F(!0)}),e.jsxs("div",{className:"mt-2 grid gap-1",children:[(Ue=n.personal_info)==null?void 0:Ue.map((t,r)=>e.jsx("div",{className:"group flex items-center justify-between gap-3 rounded-lg px-2 py-1.5 hover:bg-accent/40",children:p==="personal_info"&&j===r?e.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[e.jsx(G,{className:"flex-1",children:e.jsx("input",{value:S,onChange:v=>_(v.target.value),autoFocus:!0,className:"h-9 w-full bg-transparent px-3 text-sm outline-none"})}),e.jsx(B,{label:"Save",onClick:()=>Nt(r),disabled:i,children:e.jsx(te,{className:"h-4 w-4"})}),e.jsx(B,{label:"Cancel",onClick:()=>{b(null),R(null),_("")},children:e.jsx(se,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm",children:t}),e.jsxs("span",{className:"flex gap-0.5",children:[e.jsx(B,{label:"Edit fact",reveal:!0,onClick:()=>{b("personal_info"),R(r),_(t)},children:e.jsx(He,{className:"h-4 w-4"})}),e.jsx(B,{label:"Remove fact",reveal:!0,onClick:()=>bt(r),children:e.jsx(be,{className:"h-4 w-4"})})]})]})},r)),!((We=n.personal_info)!=null&&We.length)&&!E&&e.jsx("p",{className:"px-2 py-1 text-sm text-muted-foreground",children:"None yet."}),E&&e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx(G,{className:"flex-1",children:e.jsx("input",{value:X,onChange:t=>ne(t.target.value),onKeyDown:t=>t.key==="Enter"&&Ie(),placeholder:"e.g. I'm the founder of XYZ",autoFocus:!0,className:"h-9 w-full bg-transparent px-3 text-sm outline-none"})}),e.jsx(k,{size:"sm",onClick:Ie,disabled:!X.trim(),children:"Add"}),e.jsx(k,{size:"sm",variant:"ghost",onClick:()=>{F(!1),ne("")},children:"Cancel"})]})]})]})]}),e.jsxs(O,{padding:"none",className:"mt-3",children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-3 rounded-xl px-4 py-3.5 text-left transition-colors hover:bg-accent/40 sm:px-5",onClick:()=>g(t=>!t),"aria-expanded":m,children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ke,{className:"h-4 w-4 text-muted-foreground"}),"Style rules",de>0&&e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:de})]}),e.jsx(Qt,{className:C("h-4 w-4 text-muted-foreground transition-transform",m&&"rotate-180")})]}),m&&e.jsxs("div",{className:"space-y-6 px-4 pb-5 sm:px-5",children:[e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(Ze,{title:"Do",tone:"do",rules:A,value:re,onChange:ce,onAdd:mt,onRemove:ft}),e.jsx(Ze,{title:"Don't",tone:"dont",rules:K,value:le,onChange:Ne,onAdd:xt,onRemove:ht})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Write like"}),e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[he.length,"/3"]})]}),dt?e.jsx("p",{className:"mt-3 text-sm text-muted-foreground text-shimmer-sweep",children:"Loading creators…"}):Se.length===0?e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"No creators available."}):e.jsxs("div",{className:"relative mt-2",children:[e.jsx("div",{ref:pe,className:"flex gap-2 overflow-x-auto scroll-smooth py-1",style:{scrollbarWidth:"none"},children:Se.map(t=>{var P;const r=he.includes(t.id),v=t.avatar_url||((P=t.metadata)==null?void 0:P.avatarUrl);return e.jsxs("button",{type:"button",onClick:()=>pt(t.id),"aria-pressed":r,className:C("flex w-[120px] shrink-0 flex-col items-center rounded-lg px-2 py-3 text-center transition-colors",r?"bg-primary/10":"hover:bg-accent/50"),children:[e.jsxs("span",{className:"relative",children:[v?e.jsx("img",{src:v,alt:"",className:"h-11 w-11 rounded-full object-cover outline outline-1 -outline-offset-1 outline-black/10 dark:outline-white/10"}):e.jsx("span",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-muted",children:e.jsx(Ve,{className:"h-5 w-5 text-muted-foreground"})}),r&&e.jsx("span",{className:"absolute -right-1 -top-1 flex h-5 w-5 items-center justify-center rounded-full bg-primary text-primary-foreground",children:e.jsx(te,{className:"h-3 w-3"})})]}),e.jsx("span",{className:"mt-2 w-full truncate text-xs font-medium",children:t.name}),t.stats_avg_likes!=null&&e.jsxs("span",{className:"mt-0.5 flex items-center gap-0.5 text-[11px] text-muted-foreground",children:[e.jsx(Xt,{className:"h-3 w-3"}
24),Math.round(t.stats_avg_likes).toLocaleString()]})]},t.id)})}),e.jsxs("div",{className:"mt-1 hidden justify-end gap-1 sm:flex",children:[e.jsx(B,{label:"Scroll left",onClick:()=>Pe("left"),children:e.jsx(at,{className:"h-4 w-4"})}),e.jsx(B,{label:"Scroll right",onClick:()=>Pe("right"),children:e.jsx(nt,{className:"h-4 w-4"})})]})]})]}),ot&&e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),e.jsx(k,{size:"sm",onClick:gt,disabled:Ce,children:Ce?e.jsx("span",{className:"text-shimmer-sweep",children:"Saving…"}):e.jsxs(e.Fragment,{children:[e.jsx(Jt,{className:"mr-1.5 h-3.5 w-3.5"}),"Save style"]})})]})]})]})]})]})}function G({className:s,children:a}){return e.jsx("div",{className:C("rounded-lg bg-background ring-1 ring-border/70 focus-within:ring-2 focus-within:ring-ring",s),children:a})}function B({label:s,onClick:a,children:d,reveal:n,disabled:f}){return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:a,disabled:f,className:C("flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-[color,background-color,opacity] hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",n&&"sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100"),children:d})}function ye({title:s,onAdd:a}){return e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:s}),e.jsx(B,{label:`Add to ${s.toLowerCase()}`,onClick:a,children:e.jsx(rt,{className:"h-4 w-4"})})]})}function hs({text:s}){const[a,d]=o.useState(!1);if(!s)return e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Not set yet."});const n=s.length>280;return e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:C("text-sm leading-relaxed text-foreground/90",n&&!a&&"line-clamp-3"),children:s}),n&&e.jsx("button",{type:"button",onClick:()=>d(f=>!f),className:"mt-1 text-xs font-medium text-muted-foreground hover:text-foreground",children:a?"Show less":"Show more"})]})}function Ze({title:s,tone:a,rules:d,value:n,onChange:f,onAdd:w,onRemove:c}){const p=a==="do"?te:Zt,b=a==="do"?"text-emerald-600 dark:text-emerald-400":"text-red-600 dark:text-red-400";return e.jsxs("div",{children:[e.jsxs("h3",{className:C("flex items-center gap-1.5 text-sm font-medium",b),children:[e.jsx(p,{className:"h-4 w-4"}),s]}),e.jsx("div",{className:"mt-2 grid gap-1",children:d.map(S=>e.jsxs("div",{className:"group flex items-start gap-2 rounded-lg px-2 py-1.5 hover:bg-accent/40",children:[e.jsx(p,{className:C("mt-0.5 h-3.5 w-3.5 shrink-0",b)}),e.jsx("span",{className:"flex-1 text-sm",children:S.text}),e.jsx("button",{type:"button","aria-label":"Remove rule",onClick:()=>c(S.id),className:"text-muted-foreground opacity-100 transition-opacity hover:text-destructive sm:opacity-0 sm:group-hover:opacity-100",children:e.jsx(se,{className:"h-3.5 w-3.5"})})]},S.id))}),e.jsxs(G,{className:"mt-2 flex items-center",children:[e.jsx("input",{value:n,onChange:S=>f(S.target.value),onKeyDown:S=>S.key==="Enter"&&w(),placeholder:"Add a rule",className:"h-9 flex-1 bg-transparent px-3 text-sm outline-none"}),e.jsx("button",{type:"button","aria-label":`Add ${s} rule`,onClick:w,disabled:!n.trim(),className:"mr-1 flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-40",children:e.jsx(rt,{className:"h-4 w-4"})})]})]})}const As=Object.freeze(Object.defineProperty({__proto__:null,default:fs},Symbol.toStringTag,{value:"Module"}));function et({isOpen:s,onClose:a,onSelectPrompt:d,filterText:n="",workspaceId:f,authorId:w,kind:c="all"}){const[p,b]=o.useState([]),[S,_]=o.useState(!1),[j,R]=o.useState(0),[i,h]=o.useState(null),I=o.useRef(null),$=o.useRef([]);o.useEffect(()=>{if(!s)return;let m=!1;return _(!0),(async()=>{const g=await ns.listPrompts(f,{authorId:w,kinds:c==="all"?void 0:[c]});m||(b(g),_(!1))})(),()=>{m=!0}},[s,f,w,c]);const l=n.toLowerCase().replace(/^\/(?:skill|prompt|workflow)\s*/,"").trim(),T=c==="workflow"?"Saved Workflows":c==="skill"?"Saved Skills":c==="prompt"?"Saved Prompts":"Saved Workflows / Skills",L=c==="workflow"?"Type to filter workflows...":c==="skill"?"Type to filter skills...":c==="prompt"?"Type to filter prompts...":"Type to filter workflows, skills, or prompts...",q=c==="workflow"?"No saved workflows found":c==="skill"?"No saved skills found":c==="prompt"?"No saved prompts found":"No saved prompts, skills, or workflows found",u=p.filter(m=>{var g,A;return l?m.name.toLowerCase().includes(l)||we(m).toLowerCase().includes(l)||((g=m.category)==null?void 0:g.toLowerCase().includes(l))||((A=m.kind)==null?void 0:A.toLowerCase().includes(l))||(m.trigger_phrases||[]).some(U=>U.toLowerCase().includes(l)):!0}).reduce((m,g)=>{const A=E(g.category);return m[A]||(m[A]=[]),m[A].push(g),m},{}),y=Object.values(u).flat();o.useEffect(()=>{R(0),h(null)},[n,c]),o.useEffect(()=>{var m;$.current[j]&&((m=$.current[j])==null||m.scrollIntoView({behavior:"smooth",block:"nearest"}))},[j]);const D=o.useCallback(m=>{if(!(!s||y.length===0))switch(m.key){case"ArrowDown":m.preventDefault(),m.stopPropagation(),R(g=>g<y.length-1?g+1:0);break;case"ArrowUp":m.preventDefault(),m.stopPropagation(),R(g=>g>0?g-1:y.length-1);break;case"Enter":m.preventDefault(),m.stopPropagation(),y[j]&&d(y[j]);break;case"Escape":m.preventDefault(),m.stopPropagation(),a();break;case"Tab":m.preventDefault(),m.stopPropagation(),y[j]&&d(y[j]);break}},[s,y,j,d,a]);if(o.useEffect(()=>(document.addEventListener("keydown",D,!0),()=>document.removeEventListener("keydown",D,!0)),[D]),o.useEffect(()=>{const m=g=>{I.current&&!I.current.contains(g.target)&&a()};return s&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)}
24,[s,a]),!s)return null;function E(m){return m?m.replace(/[_-]+/g," ").replace(/\b\w/g,g=>g.toUpperCase()):"Other"}const F=m=>{const g=m.toLowerCase();return g.includes("generat")?e.jsx(Q,{className:"w-3 h-3"}):g.includes("edit")?e.jsx(Qe,{className:"w-3 h-3"}):g.includes("agent")||g.includes("action")?e.jsx(ts,{className:"w-3 h-3"}):e.jsx(ss,{className:"w-3 h-3"})},X=m=>m.kind==="workflow"?Ge:m.kind==="skill"?Q:Qe;let ne=0;return e.jsx(Xe,{children:s&&e.jsxs(Je.div,{ref:I,initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.15,ease:"easeOut"},className:C("absolute z-50 flex","bottom-[calc(100%+8px)] left-0 right-0 sm:right-auto"),children:[e.jsxs("div",{className:C("w-80 overflow-hidden rounded-lg border border-border/70 bg-popover/95 shadow-[0_18px_48px_rgba(0,0,0,0.16)] backdrop-blur"),children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 px-3 py-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded border border-border/60 bg-background text-muted-foreground",children:c==="workflow"?e.jsx(Ge,{className:"w-3 h-3"}):e.jsx(Q,{className:"w-3 h-3"})}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:T}),l&&e.jsxs("span",{className:"ml-1 text-[10px] text-muted-foreground/60",children:['"',l,'"']}),e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:"↑↓ navigate · Enter select"})]}),!l&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/20",children:[e.jsx(es,{className:"w-3 h-3 text-muted-foreground/50"}),e.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:L})]}),e.jsx("div",{className:"max-h-[360px] overflow-y-auto p-1",children:S?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("span",{className:"text-shimmer-sweep text-sm text-muted-foreground",children:"Loading…"})}):y.length===0?e.jsxs("div",{className:"text-center py-6 px-4",children:[e.jsx(Q,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/30"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?`No saved items matching "${l}"`:q})]}):Object.entries(u).map(([m,g])=>e.jsxs("div",{className:"mb-1 last:mb-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:[F(m),m,e.jsxs("span",{className:"text-muted-foreground/40 ml-1",children:["(",g.length,")"]})]}),g.map(A=>{const U=ne++,K=U===j,V=we(A),re=V.length>80?`${V.substring(0,80)}...`:V,ce=X(A);return e.jsxs("button",{ref:le=>$.current[U]=le,onClick:()=>d(A),onMouseEnter:()=>{R(U),h(A)},onMouseLeave:()=>h(null),className:C("w-full flex items-start gap-2.5 px-2 py-2 rounded-md","transition-colors duration-100","text-left group",K?"bg-muted text-foreground ring-1 ring-border/70":"hover:bg-accent/50"),children:[e.jsx("div",{className:C("flex-shrink-0 w-7 h-7 rounded-md flex items-center justify-center mt-0.5","transition-colors",K?"border border-border/70 bg-background text-foreground":"border border-border/50 bg-background text-muted-foreground"),children:e.jsx(ce,{className:"w-3.5 h-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:C("font-medium text-sm truncate",K&&"text-foreground"),children:A.name})}),e.jsx("p",{className:C("text-xs truncate mt-0.5","text-muted-foreground"),children:re}),e.jsxs("p",{className:"mt-1 text-[10px] uppercase tracking-wide text-muted-foreground/60",children:[A.kind||"prompt",A.version?` v${A.version}`:"",A.author_id?"":" · all creator spaces"]})]})]},A.id)})]},m))}),e.jsx("div",{className:"px-3 py-1.5 bg-muted/30",children:e.jsx("p",{className:"text-[10px] text-muted-foreground/70",children:"Click to paste into chat · Esc to close"})})]}),e.jsx(Xe,{children:i&&e.jsxs(Je.div,{initial:{opacity:0,x:-4},animate:{opacity:1,x:0},exit:{opacity:0,x:-4},transition:{duration:.12},className:"ml-2 hidden w-72 self-start overflow-hidden rounded-lg border border-border/70 bg-popover/95 shadow-[0_18px_48px_rgba(0,0,0,0.16)] backdrop-blur sm:block",children:[e.jsxs("div",{className:"bg-muted/30 px-3 py-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground truncate",children:i.name}
24),e.jsxs("span",{className:"text-[10px] text-muted-foreground/60",children:[E(i.category),i.kind?` · ${i.kind}`:""]})]}),e.jsx("div",{className:"p-3 max-h-[280px] overflow-y-auto",children:e.jsx("p",{className:"text-xs text-foreground/80 whitespace-pre-wrap leading-relaxed",children:we(i)})})]})})]})})}const Ps=Object.freeze(Object.defineProperty({__proto__:null,PromptPicker:et,default:et},Symbol.toStringTag,{value:"Module"}));export{As as I,Ps as P};

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.