1import{e as st,v as pe,h as nt,m as O,A as ot,b as L,w as it,T as rt,o as s,c as n,a,t as u,u as k,j as X,i as N,k as v,F as E,r as G,x as ut,y as ct,l as o,f as _,C as dt,n as ve,D as pt,E as vt,G as Pe,B as ft,_ as mt}from"./D-nGNtiX.js";import{l as Se,g as ht}from"./QYqg0UH_.js";import{u as bt}from"./e2eawtfc.js";import{r as gt}from"./WdRo7VI1.js";import{r as fe}from"./DD2xsQEL.js";import{r as xt}from"./DrFDhH72.js";import{r as yt}from"./8uiT_Uq9.js";import{r as kt}from"./BjHX7abo.js";import{r as je}from"./BsfQFRPY.js";import{r as _t}from"./QVcxE1KH.js";const wt={key:0,class:"fixed inset-0 z-[100] flex items-center justify-center p-3 sm:p-6"},Ct=["aria-label"],Tt={class:"flex shrink-0 items-center justify-between gap-4 px-5 py-4 sm:px-6"},Ut={class:"text-[20px] font-bold text-ink"},At=["disabled"],Pt={class:"shrink-0 px-5 sm:px-6"},St=["disabled"],jt={class:"mt-2 rounded-full bg-ink px-5 py-2 text-[13px] font-semibold text-white"},$t={key:2,class:"mt-2 text-[12px] text-muted"},Lt=["accept","multiple"],Et={key:0,class:"mt-2 text-[12px] text-[#B42318]",role:"alert"},Ft={key:0,class:"mt-4 shrink-0 border-b border-hairline px-5 sm:px-6"},Mt={class:"assets-tabs flex items-baseline gap-6 overflow-x-auto overflow-y-hidden","aria-label":"Asset category"},Rt=["onClick"],Bt={key:1,class:"flex shrink-0 items-center gap-3 px-5 py-3 sm:px-6"},Nt={key:1,class:"min-w-0 max-w-[260px]"},Dt={class:"truncate text-[14px] font-semibold text-ink"},qt={class:"text-[11px] text-muted"},It={class:"relative min-w-[180px] flex-1"},Vt={key:0,class:"grid h-full min-h-[220px] place-items-center"},Wt={class:"mb-4 flex items-center gap-7 border-b border-hairline","aria-label":"Project type"},Ht=["onClick"],Ot={key:0,class:"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4"},Gt=["onClick"],Jt={class:"flex aspect-[4/3] items-center justify-center overflow-hidden rounded-[12px] bg-chip"},Yt=["src"],zt=["src","alt"],Kt={class:"block px-1 pb-1 pt-2.5"},Zt={class:"block truncate text-[13px] font-semibold text-ink"},Qt={class:"mt-1 block text-[11px] text-muted"},Xt={key:1,class:"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4"},el=["onClick"],tl={class:"relative flex aspect-[4/3] items-center justify-center overflow-hidden rounded-[12px] bg-chip"},ll=["src"],al=["src","alt"],sl={class:"block px-1 pb-1 pt-2.5"},nl={class:"block truncate text-[13px] font-semibold text-ink"},ol={class:"mt-1 block text-[11px] text-muted"},il={key:2,class:"grid min-h-[220px] place-items-center text-center"},rl={class:"grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6"},ul=["disabled","aria-pressed","aria-label","onClick"],cl={class:N(["relative flex aspect-square items-center justify-center overflow-hidden rounded-[15px] border bg-chip transition","border-transparent group-hover:border-ink/20"])},dl=["src"],pl=["src"],vl={class:"mt-1.5 block truncate px-1 text-[11px] text-ink/60"},fl={key:0,class:"grid min-h-[220px] place-items-center text-center"},ml={key:3,class:"flex h-14 items-center justify-center"},hl={class:"flex shrink-0 items-center justify-between gap-4 border-t border-hairline px-5 py-4 sm:px-6"},bl={class:"text-[12px] text-ink"},gl=["disabled"],me=20,xl=st({__name:"AssetPickerModal",props:{open:{type:Boolean},mediaTypes:{},accept:{default:""},title:{default:"Add a reference"},selectionLimit:{default:1}},emits:["close","select","selectMany"],setup(J,{emit:$e}){const x=J,Y=$e,{require:F}=bt(),Le={image:"Image",video:"Video",projects:"Projects",uploads:"Uploads"},Ee=[{key:"my",label:"Created by Me"},{key:"agent",label:"Created by Agent"}],Fe={planning:"Planning",awaiting_approval:"Needs approval",approved:"Creating",running:"Creating",succeeded:"Ready",partial:"Needs review",failed:"Failed",cancelled:"Stopped"},Me={planning:"bg-white/90 text-ink",awaiting_approval:"bg-white/90 text-ink",approved:"bg-[#e7f4fb] text-[#24627f]",running:"bg-[#e7f4fb] text-[#24627f]",succeeded:"bg-[#e4f3eb] text-[#236a4d]",partial:"bg-[#fff1d8] text-[#855b12]",failed:"bg-[#fde8e5] text-[#9a3429]",cancelled:"bg-white/90 text-muted"},he=o(null),be=o(null),z=o(null),d=o("image"),A=o("my"),w=o(null),C=o(null),K=o([]),P=o([]),M=o([]),r=o([]),p=o(""),D=o(0),S=o(0),y=o(0),q=o(!1),I=o(!1),f=
1o(!1),ee=o(0),V=o(!1),m=o("");let Z=0,R=null,te="",h=!1;const T=_(()=>{const e=new Set(x.mediaTypes);return["image","video"].filter(t=>e.has(t))}),Q=_(()=>T.value.length>0),le=_(()=>[...T.value,"projects","uploads"]),ge=_(()=>x.accept?x.accept:x.mediaTypes.map(e=>`${e}/*`).join(",")),b=_(()=>Math.max(1,Math.min(5,Math.floor(x.selectionLimit)))),Re=_(()=>b.value>1?`Drop or paste up to ${b.value} supported files`:"Drop or paste one supported file"),Be=_(()=>b.value>1?`Choose up to ${b.value} supported assets`:"Choose one supported asset"),W=_(()=>!!(w.value||C.value)),Ne=_(()=>w.value?.name||(C.value?ie(C.value):"")),De=_(()=>A.value==="my"?K.value.length===0:P.value.length===0);pe(()=>x.open,e=>{if(e){if(!F()){Y("close");return}te=document.body.style.overflow,document.body.style.overflow="hidden",document.addEventListener("keydown",ce),h=!0,d.value=le.value[0]||"projects",A.value="my",w.value=null,C.value=null,p.value="",h=!1,r.value=[],m.value="",ve(()=>be.value?.focus()),$()}else document.body.style.overflow=te,document.removeEventListener("keydown",ce),Z+=1}),pe(p,()=>{!x.open||h||(R&&clearTimeout(R),R=setTimeout(()=>{R=null,r.value=[],$()},300))},{flush:"sync"}),pe(le,e=>{e.includes(d.value)||(d.value=e[0]||"projects")}),nt(()=>{R&&clearTimeout(R),document.removeEventListener("keydown",ce),x.open&&(document.body.style.overflow=te)});function qe(e){e!==d.value&&(h=!0,d.value=e,w.value=null,C.value=null,p.value="",h=!1,r.value=[],$())}function Ie(e){e!==A.value&&(A.value=e,r.value=[],$())}function Ve(e){h=!0,w.value=e,C.value=null,p.value="",h=!1,r.value=[],$()}function We(e){h=!0,w.value=null,C.value=e,p.value="",h=!1,r.value=[],$()}function He(){h=!0,w.value=null,C.value=null,p.value="",h=!1,r.value=[],$()}async function $(){const e=++Z;if(q.value=!0,I.value=!1,m.value="",M.value=[],K.value=[],P.value=[],D.value=0,S.value=0,y.value=0,z.value&&(z.value.scrollTop=0),!Q.value){q.value=!1;return}try{if(d.value==="projects"&&!W.value)if(A.value==="my"){const t=await dt({q:p.value.trim()||void 0});if(!U(e))return;K.value=t.data?.items||[]}else{const t=await Se({page:1,limit:me,q:p.value.trim()||void 0});if(!U(e))return;P.value=t.data?.items||[],S.value=t.data?.total??P.value.length,y.value=P.value.length,D.value=1}else{const t=await ye(1);if(!U(e))return;ke(t.data,1,!1)}}catch(t){if(!U(e))return;m.value=de(t,"Unable to load Assets.")}finally{U(e)&&(q.value=!1,await ve(),_e())}}async function xe(){if(q.value||I.value||y.value>=S.value)return;const e=Z,t=D.value+1;I.value=!0;try{if(d.value==="projects"&&!W.value&&A.value==="agent"){const l=await Se({page:t,limit:me,q:p.value.trim()||void 0});if(!U(e))return;const i=l.data?.items||[],j=new Set(P.value.map(c=>c.runUid));P.value.push(...i.filter(c=>!j.has(c.runUid))),S.value=l.data?.total??y.value+i.length,y.value+=i.length,i.length||(y.value=S.value),D.value=t}else{const l=await ye(t);if(!U(e))return;ke(l.data,t,!0)}}catch(l){U(e)&&(m.value=de(l,"Unable to load more Assets."))}finally{U(e)&&(I.value=!1,await ve(),_e())}}function ye(e){const t={page:e,limit:me,q:p.value.trim()||void 0};return d.value==="image"?pt(t):d.value==="video"?vt(t):d.value==="uploads"?Pe({...t,resourceType:"upload",mediaType:T.value.length===1?T.value[0]:void 0}):w.value?Pe({...t,folder:w.value.folderUid,mediaType:T.value.length===1?T.value[0]:void 0}):ht(C.value.runUid,t)}function ke(e,t,l){const i=Array.isArray(e?.items)?e.items:Array.isArray(e?.rows)?e.rows:[],j=i.filter(c=>T.value.includes(c.mediaType));if(l){const c=new Set(M.value.map(g=>g.resourceUid));M.value.push(...j.filter(g=>!c.has(g.resourceUid)))}else M.value=j;S.value=e?.total??y.value+i.length,y.value+=i.length,i.length||(y.value=S.value),D.value=t}function Oe(e){const t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<240&&xe()}function _e(){const e=z.value;e&&e.scrollHeight<=e.clientHeight+120&&y.value<S.value&&xe()}function U(e){return e===Z&&x.open}function Ge(){we(r.value.flatMap(e=>{const t=H(e);return t?[{url:t,mediaType:e.mediaType,name:ne(e)}]:[]}))}function ae(e){return r.value.some(t=>t.resourceUid===e.resourceUid)}function Je(e){if(b.value===1){r.value=[e],m.value="";return}ae(e)?r.value=r.value.filter(t=>t.resourceUid!==e.resourceUid):r.value.length<b.value?(r.value=[...r.value,e],m.value=""):m.value=`You can select up to ${b.value} assets at a time.`}function Ye(e){const t=e.currentTarget;if(!F()){t.value="";return}const l=Array.from(t.files||[]);t.value="",l.length&&se(l)}function ze(e){if(V.value=!1,!F())return;const t=Array.from(e.dataTransfer?.files||[]);t.length&&se(t)}function Ke(e){const t=Array.from(e.clipboardData?.files||[]);t.length&&(e.preventDefault(),F()&&se(t))}async function se(e){if(f.value||!F())return;const t=e.slice(0,b.value),l=t.flatMap(c=>{const g=Qe(c);return g&&x.mediaTypes.includes(g)&&Xe(c)?[{file:c,mediaType:g}]:[]});
1if(!l.length){m.value="These file types are not supported here.";return}const i=[];e.length>t.length&&i.push(`You can add up to ${b.value} files at a time.`),l.length<t.length&&i.push("Some files were skipped because their format is not supported."),f.value=!0,ee.value=0;const j=[];for(const[c,{file:g,mediaType:lt}]of l.entries())try{const B=await ft(g,at=>{ee.value=Math.max(0,Math.min(100,Math.round((c+at)/l.length*100)))}),Ae=B.data?.url||B.data?.cdnUrl||B.data?.publicUrl;if(!Ae)throw new Error("Upload completed without a usable URL.");j.push({url:Ae,mediaType:lt,name:B.data?.fileName||g.name})}catch(B){i.push(de(B,`Upload failed for ${g.name}.`))}f.value=!1,m.value=i.join(" "),j.length&&we(j)}function we(e){e.length&&(b.value===1?Y("select",e[0].url,e[0].mediaType,e[0].name):Y("selectMany",e))}function Ze(){F()&&he.value?.click()}function Qe(e){if(e.type.startsWith("image/"))return"image";if(e.type.startsWith("video/"))return"video";if(e.type.startsWith("audio/"))return"audio";const t=e.name.toLowerCase();return/\.(?:jpe?g|png|webp|gif|avif)$/.test(t)?"image":/\.(?:mp4|mov|webm|m4v)$/.test(t)?"video":/\.(?:mp3|wav|m4a|aac|ogg|flac)$/.test(t)?"audio":null}function Xe(e){return ge.value.split(",").some(t=>{const l=t.trim().toLowerCase();return l?l.endsWith("/*")?e.type.toLowerCase().startsWith(l.slice(0,-1)):l.startsWith(".")?e.name.toLowerCase().endsWith(l):e.type.toLowerCase()===l:!1})}function H(e){return e.url||e.cdnUrl||e.publicUrl||e.sourceUrl||null}function ne(e){return e.name||e.fileName||"Untitled asset"}function oe(e){return e.cover?.url||e.cover?.cdnUrl||e.cover?.publicUrl||null}function Ce(e){const t=e.cover?.mediaType;return t&&T.value.includes(t)&&oe(e)?t:null}function ie(e){return e.displayName||e.name||e.skillCode}function re(e){return e.cover?H(e.cover):null}function Te(e){const t=e.cover?.mediaType;return t&&T.value.includes(t)&&re(e)?t:null}function et(e){return e.needsApproval?"Needs approval":Fe[e.status]||"In progress"}function tt(e){return Me[e]||"bg-white/90 text-ink"}function Ue(e){return`${e} ${e===1?"file":"files"}`}function ue(){f.value||Y("close")}function ce(e){e.key==="Escape"&&ue()}function de(e,t){return e instanceof Error&&e.message?e.message:t}return(e,t)=>(s(),O(ot,{to:"body"},[L(rt,{name:"asset-picker"},{default:it(()=>[J.open?(s(),n("div",wt,[a("button",{type:"button",class:"absolute inset-0 bg-ink/40","aria-label":"Close asset picker",onClick:ue}),a("section",{ref_key:"dialogPanel",ref:be,class:"relative flex h-[calc(100vh-24px)] max-h-[720px] w-full max-w-[1040px] flex-col overflow-hidden rounded-[22px] border border-hairline bg-white shadow-2xl outline-none sm:h-[calc(100vh-48px)]",role:"dialog","aria-modal":"true","aria-label":J.title,tabindex:"-1",onPaste:Ke},[a("header",Tt,[a("h2",Ut,u(J.title),1),a("button",{type:"button",class:"grid h-9 w-9 place-items-center rounded-full text-ink transition hover:bg-chip focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/25 disabled:opacity-40","aria-label":"Close",disabled:f.value,onClick:ue},[L(k(gt),{class:"h-5 w-5"})],8,At)]),a("div",Pt,[a("button",{type:"button",class:N(["flex h-[126px] w-full flex-col items-center justify-center rounded-[20px] border border-dashed transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/25",V.value?"border-[#3bc3cd] bg-[#eefbfc]":"border-ink/15 bg-chip/45 hover:border-ink/30 hover:bg-chip/70",f.value?"cursor-wait":"cursor-pointer"]),disabled:f.value,onClick:Ze,onDragenter:t[0]||(t[0]=X(l=>V.value=!0,["prevent"])),onDragover:t[1]||(t[1]=X(l=>V.value=!0,["prevent"])),onDragleave:t[2]||(t[2]=X(l=>V.value=!1,["prevent"])),onDrop:X(ze,["prevent"])},[f.value?(s(),O(k(fe),{key:0,class:"h-6 w-6 animate-spin text-ink"})):(s(),O(k(xt),{key:1,class:"h-6 w-6 text-ink"})),a("span",jt,u(f.value?`Uploading ${ee.value}%`:"Upload"),1),f.value?v("",!0):(s(),n("span",$t,u(Re.value),1))],42,St),a("input",{ref_key:"fileInput",ref:he,type:"file",class:"hidden",accept:ge.value,multiple:b.value>1,onChange:Ye},null,40,Lt),m.value?(s(),n("p",Et,u(m.value),1)):v("",!0)]),Q.value?(s(),n("div",Ft,[a("nav",Mt,[(s(!0),n(E,null,G(le.value,l=>(s(),n("button",{key:l,type:"button",class:N(["relative shrink-0 pb-3 text-[14px] transition-colors",d.value===l?"font-semibold text-ink after:absolute after:inset-x-0 after:-bottom-px after:h-0.5 after:bg-[#3bc3cd]":"text-muted hover:text-ink"]),onClick:i=>qe(l)},u(Le[l]),11,Rt))),128))])])):v("",!0),Q.value?(s(),n("div",Bt,[W.value?(s(),n("button",{key:0,t
1ype:"button",class:"grid h-9 w-9 shrink-0 place-items-center rounded-full border border-hairline text-ink transition hover:bg-chip","aria-label":"Back to Projects",onClick:He},[L(k(yt),{class:"h-5 w-5"})])):v("",!0),W.value?(s(),n("div",Nt,[a("p",Dt,u(Ne.value),1),a("p",qt,u(Be.value),1)])):v("",!0),a("label",It,[L(k(kt),{class:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted"}),t[4]||(t[4]=a("span",{class:"sr-only"},"Search assets or projects",-1)),ut(a("input",{"onUpdate:modelValue":t[3]||(t[3]=l=>p.value=l),type:"search",placeholder:"Search assets or projects...",class:"h-10 w-full rounded-full border border-hairline bg-white pl-10 pr-4 text-[13px] text-ink outline-none placeholder:text-muted focus:border-[#3bc3cd] focus:ring-0"},null,512),[[ct,p.value]])])])):v("",!0),Q.value?(s(),n("div",{key:2,ref_key:"libraryScroller",ref:z,class:"min-h-0 flex-1 overflow-y-auto px-5 pb-4 sm:px-6",onScrollPassive:Oe},[q.value?(s(),n("div",Vt,[L(k(fe),{class:"h-6 w-6 animate-spin text-muted"})])):d.value==="projects"&&!W.value?(s(),n(E,{key:1},[a("nav",Wt,[(s(),n(E,null,G(Ee,l=>a("button",{key:l.key,type:"button",class:N(["relative pb-2.5 text-[13px] transition-colors",A.value===l.key?"font-semibold text-ink after:absolute after:inset-x-0 after:-bottom-px after:h-0.5 after:bg-[#3bc3cd]":"text-muted hover:text-ink"]),onClick:i=>Ie(l.key)},u(l.label),11,Ht)),64))]),A.value==="my"?(s(),n("div",Ot,[(s(!0),n(E,null,G(K.value,l=>(s(),n("button",{key:l.folderUid,type:"button",class:"group min-w-0 rounded-[16px] border border-hairline bg-white p-2 text-left transition hover:shadow-[0_10px_28px_-14px_rgba(15,22,25,0.25)]",onClick:i=>Ve(l)},[a("span",Jt,[Ce(l)==="video"?(s(),n("video",{key:0,src:oe(l)||void 0,class:"h-full w-full object-cover",muted:"",playsinline:"",preload:"metadata"},null,8,Yt)):Ce(l)==="image"?(s(),n("img",{key:1,src:oe(l)||void 0,alt:l.name,class:"h-full w-full object-cover"},null,8,zt)):(s(),O(k(je),{key:2,class:"h-10 w-10 text-muted"}))]),a("span",Kt,[a("span",Zt,u(l.name),1),a("span",Qt,u(Ue(l.resourceCount)),1)])],8,Gt))),128))])):(s(),n("div",Xt,[(s(!0),n(E,null,G(P.value,l=>(s(),n("button",{key:l.runUid,type:"button",class:"group min-w-0 rounded-[16px] border border-hairline bg-white p-2 text-left transition hover:shadow-[0_10px_28px_-14px_rgba(15,22,25,0.25)]",onClick:i=>We(l)},[a("span",tl,[Te(l)==="video"?(s(),n("video",{key:0,src:re(l)||void 0,class:"h-full w-full object-cover",muted:"",playsinline:"",preload:"metadata"},null,8,ll)):Te(l)==="image"?(s(),n("img",{key:1,src:re(l)||void 0,alt:ie(l),class:"h-full w-full object-cover"},null,8,al)):(s(),O(k(je),{key:2,class:"h-10 w-10 text-muted"})),a("span",{class:N(["absolute left-2 top-2 rounded-full px-2 py-1 text-[10px] font-medium",tt(l.status)])},u(et(l)),3)]),a("span",sl,[a("span",nl,u(ie(l)),1),a("span",ol,u(Ue(l.assetCount||0)),1)])],8,el))),128))])),De.value?(s(),n("div",il,[...t[5]||(t[5]=[a("div",null,[a("p",{class:"text-[14px] font-medium text-ink"},"No matching Projects"),a("p",{class:"mt-1 text-[12px] text-muted"},"Try another search.")],-1)])])):v("",!0)],64)):(s(),n(E,{key:2},[a("div",rl,[(s(!0),n(E,null,G(M.value,l=>(s(),n("button",{key:l.resourceUid,type:"button",disabled:!H(l),"aria-pressed":ae(l),"aria-label":`Select ${ne(l)}`,class:"group min-w-0 text-left disabled:cursor-not-allowed disabled:opacity-45",onClick:i=>Je(l)},[a("span",cl,[l.mediaType==="image"?(s(),n("img",{key:0,src:H(l)||void 0,alt:"",class:"h-full w-full object-cover"},null,8,dl)):l.mediaType==="video"?(s(),n("video",{key:1,src:H(l)||void 0,class:"h-full w-full object-cover",muted:"",playsinline:"",preload:"metadata"},null,8,pl)):v("",!0),a("span",{class:N(["absolute left-2 top-2 grid h-5 w-5 place-items-center rounded-full border transition",ae(l)?"border-[#3bc3cd] bg-[#3bc3cd] text-white":"border-white/90 bg-white/75 text-transparent"]),"aria-hidden":"true"},[L(k(_t),{class:"h-3.5 w-3.5"})],2)]),a("span",vl,u(ne(l)),1)],8,ul))),128))]),M.value.length?v("",!0):(s(),n("div",fl,[...t[6]||(t[6]=[a("div",null,[a("p",{class:"text-[14px] font-medium text-ink"},"No supported assets found"),a("p",{class:"mt-1 text-[12px] text-muted"},"Upload a file above or try another search.")],-1)])]))],64)),I.value?(s(),n("div",ml,[L(k(fe),{class:"h-5 w-5 animate-spin text-muted"})])):v("",!0)],544)):v("",!0),a("footer",hl,[a("span",bl,u(r.value.length)+" selected",1),a("button",{type:"button",class:"h-10 rounded-full bg-ink px-5 text-[13px] font-semibold text-white transition hover:bg-ink/85 disabled:cursor-not-allowed disabled:bg-chip disabled:text-muted",disabled:!r.value.length||f.value,onClick:Ge},u(r.value.length===1?"Add reference":"Add references"),9,gl)])],40,Ct)])):v("",!0)]),_:1})]))}}),jl=mt(xl,[["__scopeId","data-v-80e79ac1"]]);export{jl as A};
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.